I am a computer science student and am working on a lab for school. I have been trying to make this work, to no avail. So far, All that happens is my motor runs forward without stopping. I connected my sensor to the LED's on the DE2 board to see if I was able to receive and store their values correctly, and that seems to be the case. However, the motor is not running in correspondence to the sensor. I have been tinkering around with this code for hours with no luck. I am an assembly programming noob and shall really appreciate your help with this.
I have attached my code here:
.equ ADDR, 0x10000070 .equ LEDR, 0x10000000 .equ LEDG, 0x10000010
movia r22, LEDR movia r23, LEDG movia r8, ADDR movia r9, 0x07f557ff stwio r9, 4(r8)
movia r9, 0xfffffbff stwio r9, 0(r8)
ldwio r5, 0(r8) srli r5, r5, 11 andi r5, r5, 0x1 bne r5, r0, loop1 ldwio r10, 0(r8) srli r10, r10, 27 andi r10, r10, 0x0f stwio r10, 0(r22)
movia r9, 0xffffefff stwio r9, 0(r8)
ldwio r6, 0(r8) srli r6, r6, 13 andi r6, r6, 0x1 bne r6, r0, loop2 ldwio r11, 0(r8) srli r11, r11, 27 andi r11, r11, 0x0f stwio r11, 0(r23)
/*beq r10, r11, motorOFF*/ blt r10, r11, motorR movia r15, 0xfffffffc stwio r15, 0(r8) br sensor1
movia r15, 0xfffffffe stwio r15, 0(r8) br sensor1
and here is a link to the lego controller manual:
I am just trying to make this work for now, and then later I will have to use pulse width modulation to make it more accurate... I might have to use the nios2 timer?
I am lost and shall appreciate any help.
Thanks a lot guys, I really appreciate it.
Thanks a lot, I think I have been spending too much time on this and now this just needs a fresh pair of eyes to help me.
User contributions licensed under CC BY-SA 3.0