Search code examples
mipsarduino-unopicpic32

MIPS and PIC32 LED blink delay


LA $t1, TRISE
LI $t2, 0x0000
SW $t2, 0($t1)

LA $t1, TRISD
LI $t2, 0xFFFF
SW $t2, 0($t1)

LI $t8, 0b0000000001

LA $t1, PORTE
LA $t2, PORTD

LI $t7, 0x2000

Loop:
SW $t8, 0($t1)
SLL $t8,$t8,1
JAL determinedelay
NOP
SW $t8, 0($t1)
SLL $t8,$t8,1
JAL determinedelay
NOP
SW $t8, 0($t1)
SLL $t8,$t8,1
JAL determinedelay
NOP
SW $t8, 0($t1)
SLL $t8,$t8,1
SW $t8, 0($t1)
SLL $t8,$t8,1
SW $t8, 0($t1)
SLL $t8,$t8,1
SW $t8, 0($t1)
SLL $t8,$t8,1
SW $t8, 0($t1)

SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
SRL $t8,$t8,1
SW $t8, 0($t1)
JAL Loop
NOP  

determinedelay:
LI $t7, 0x2000
LW $t4,0($t2)
SRL $t4,$t4,8

mydelay:
ADDI $t7,$t7,-1
BGEZ $t7, mydelay
NOP
JR $ra
NOP

This code is supposed to turn on an LED, move to the left, turn on another, move to the left, get to the far left end of the strip, repeat the same process going right, and so on in an endless loop.

I believe my portion of the code does that correctly, but I'm having trouble with the delay. Ultimately, the full delay will need to rely on switch inputs, but I'm currently just trying to get it to work with a consistent set delay.

When I run the program, nothing happens on the hardware.


Solution

  • Walk before you attempt to run. Write code to turn on a single LED.

    When you have that working, write code to flash that LED on and off.

    When you have that working, write code to flash all of the LEDs in the strip on and off.