displays only the 8 leds

Thread Starter

NAFISA22

Joined Mar 22, 2016
2
this is a code that displays 1 led after 3 secs 4 leds then 8 leds.the problem us that it displays only the 8 leds.i changed the delay but nothing.please help
.data
.equ TIMER_BASE, 0x10002000
.equ PERIOD, 0x1111ffff
.equ DELAY, 20ns
.equ LED, 0x10000010

.text
.global _start
_start:


movia r4, TIMER_BASE
movi r5, 6
movia r2, PERIOD #load initial timer values
stwio r2, 8(r4)
srli r2, r2, 16
stwio r2, 12(r4)
stwio r5, 4(r4) #start the timer
movi r6, DELAY #delay


oneLED:
movi r14, 0b10000000 #turn on One LED
movia r15, LED
stw r14, 0(r15)
br fourLED

##############

DELAY:
subi r6,r6,1 #subtract 1 from delay
bne r6,r0, DELAY #continue subtracting if delay not elapsed
br DELAY #delay elapsed, redo the LOOP

##############

fourLED:
movi r14, 0b11110000 #turn on Four LEDs
movia r15, LED
stw r14, 0(r15)
br eightLED

eightLED:
movi r14, 0b11111111 #turn on Eight LEDs
movia r15, LED
stw r14, 0(r15)
br oneLED
 

blocco a spirale

Joined Jun 18, 2008
1,546
What happens if you disable or skip the section of code that turns on the 8 LEDs, do you just see 4 LEDs on?

I haven't analysed your code but I suspect there is a problem with the delay routine and the code is cycling through so fast that it appears that 8 LEDs are on all the time.
 
Last edited:

blocco a spirale

Joined Jun 18, 2008
1,546
Did you also modify the code so that it doesn't try to jump to the 8 LED code. i.e.

fourLED:
movi r14, 0b11110000 #turn on Four LEDs
movia r15, LED
stw r14, 0(r15)
br oneLED
 
Top