Question: Why is this code not working. When I run it and click the reset button it goes back to the ldr r 3 , =
Why is this code not working. When I run it and click the reset button it goes back to the ldr rstr line. The user button does nothing. I need it to be a bit binary counter led where I click the button and the corresponding lights light up
syntax unified
text
global main
equ MODER, x
equ AHBENR, x
equ GPIOBSRRx
equ GPIOA, x
equ GPIOD, xC
equ RCCx
equ IDR, x
equ ODR, x
equ Blue, x
equ Red, x
equ orx
equ grx
main:
bl InitLED
bl InitButton
ldr rCount
ldr rr
mainloop:
bl WAIT
ldr rr
cmp r#
bgt resetCount
bl LEDonoff
bl Delay
add rr#
str rr
bl CheckButton
cmp r#
beq mainloop
resetCount:
mov r#
str rr
b mainloop
WAIT:
bl CheckButton
cmp r#
beq WAIT
release:
bl CheckButton
cmp r#
beq release
bx lr
InitLED:
ldr rRCC
ldr rr #AHBENR
orr r r #x
str rr #AHBENR
ldr rGPIOD
ldr rr #MODER
bic r r #xF
orr r r #x
str rr #MODER
bx lr
InitButton:
ldr rRCC
ldr rr #AHBENR
orr r r #x
str rr #AHBENR
ldr rGPIOA
ldr rr #MODER
bic r r #x
str rr #MODER
bx lr
CheckButton:
ldr rGPIOA
ldr rr #IDR
and r r #x
bx lr
LEDonoff:
push r r r
ldr rGPIOD
ldr rr
and rr#xF
mov r#xF
str rr#GPIOBSRR
lsl rr#
str rr#ODR
pop rrr
bx lr
Delay:
ldr r#x
loop:
subs r r #
bne loop
bx lr
data
Count: word
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
