Wednesday, June 10, 2009

Flash a LED!

Yesterday, I configured GPIO port C to be able to flash the status LED. I now have two processes yielding to each other. One of them turns on the LED, the other turns it off. Here is one of them. It writes to the GPIO C BSRR (bit set/reset register) to set port C bit 12 high, which turns the LED off.


.global CM3_proc0
.thumb_func

CM3_proc0:
ldr r1, =0x40011010 @ PORT C BSRR register.
mov r2, 0x00001000 @ Set bit 12.
str r2, [r1]
mov r0, 0x1 @ Yield system call.
svc @ Perform the system call.
mov r0, 0x800000 @ Delay loop.
loop0:
sub r0, 0x1
cmp r0, 0x0
bne loop0
b CM3_proc0