Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- start
- BL longpulse
- BL longpulse
- BL longpulse
- BL shortpulse
- BL shortpulse
- BL shortpulse
- B start
- longpulse PUSH {LR}
- BL ledon
- MOV R0,#2000
- BL delay
- BL ledoff
- MOV R0,#1000
- BL delay
- POP {LR}
- BX LR
- shortpulse PUSH {LR}
- BL ledon
- MOV R0,#200
- BL delay
- BL ledoff
- MOV R0,#1000
- BL delay
- POP {LR}
- BX LR
- ; delay subroutine - blocks for the number of milliseconds in R0.
- delay PUSH {lr}
- PUSH {R0}
- PUSH {R1}
- delayo MOV R1,#3200 ; Start of outer loop, counts down from R0.
- delayi SUB R1,#0x01 ; Start of inner loop, counts down from 3200 (takes ~1ms).
- CMP R1,#0x00
- BNE delayi ; End of inner loop
- SUB R0,#1 ; Subtract 1 from number of milliseconds.
- CMP R0,#0 ; Check if we got to 0ms.
- BNE delayo ; If not, go around the inner loop again...
- POP {R1}
- POP {R0}
- POP {lr}
- BX LR ; Otherwise return.
- ; ledon subroutine - switches the LED on.
- ledon
- PUSH {lr}
- PUSH {R1}
- PUSH {R2}
- PUSH {R0}
- LDR R0,=0x40020000 ; Put GPIOA register Base Address in R0 (see page 38 RM0368).
- LDR R1,[R0, #0x14] ; Load the current value of port A ODR (base+0x14) into R1.
- MOV R2,#1 ; 1 of 3 lines to do a 'R1=R1|(1<<5)'
- LSL R2,#5 ; 2 of 3 lines to do a 'R1=R1|(1<<5)'
- ORR R1,R2 ; 3 of 3 lines to do a 'R1=R1|(1<<5)'
- STR R1,[R0, #0x14] ; Store new value for port A ODR with 5th bit set.
- POP {R0}
- POP {R2}
- POP {R1}
- POP {lr}
- BX LR
- ; ledoff subroutine - switches the LED off.
- ledoff PUSH {lr}
- PUSH {R1}
- PUSH {R2}
- PUSH {R0}
- LDR R0,=0x40020000 ; Put GPIOA register Base Address in R0 (see page 38 RM0368).
- LDR R1,[R0, #0x14] ; Load the current value of port A ODR (base+0x14) into R1.
- MOV R2,#1 ; 1 of 3 lines to clear the 5th bit of R1.
- LSL R2,#5 ; 2 of 3 lines to clear the 5th bit of R1.
- BIC R1,R2 ; 3 of 3 lines to clear the 5th bit of R1.
- STR R1,[R0, #0x14] ; Store new value for port A ODR with 5th bit set.
- POP {R0}
- POP {R2}
- POP {R1}
- POP {lr}
- BX LR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement