; *********************************************************************** ; * * ; * Flash the LEDs on the DSLMU Microcontroller Board * ; * * ; *********************************************************************** ; ; Author: John Zaitseff ; Date: 9th March, 2003 ; Version: 1.8 ; ; This program, when run on the DSLMU Microcontroller Board, flashes the ; LEDs on and off. It shows how easy it is to access the peripherals on ; the DSLMU Microcontroller Board! ; ----------------------------------------------------------------------- ; Constant values used in this program .equ portA, 0x10000000 ; Address of Port A in the I/O space .equ Value1, 0b11111111 ; Value to turn LEDs on .equ Value2, 0b00000000 ; Value to turn LEDs off .equ WaitVal, 10000 ; Number of loops to wait ; ----------------------------------------------------------------------- ; Assembly-language preamble .text ; Executable code follows _start: .global _start ; "_start" is required by the linker .global main ; "main" is our main program b main ; ----------------------------------------------------------------------- ; Start of the main program ; void main (void) main: ; Entry to the function "main" ; Although "main" is technically a function, this particular ; function has an infinite loop and so never returns to its caller. ldr r4, =portA ; Load address of Port A into R4 ; (ie, the value of the constant ; LED_port) into register R4 main_loop: ; Start of the infinite loop mov r5, #Value1 ; Load value to turn LEDs on strb r5, [r4] ; Write the byte to Port A ldr r0, =WaitVal ; R0 = number of loops to wait bl delay ; Delay the program... mov r5, #Value2 ; Load value to turn LEDs off strb r5, [r4] ; Write the byte to Port A ldr r0, =WaitVal ; R0 = number of loops to wait bl delay ; Delay the program... b main_loop ; Do this forever (or until stopped) ; ----------------------------------------------------------------------- ; Function "delay": delay program execution by wasting time in a loop ; void delay (int delaycount) delay: ; This function expects R0 to contain the number of loops for ; which to wait. It does not return any meaningful values. The ; value in R0 is destroyed. All other registers are preserved. cmp r0, #0 ; Check if delaycount is <= 0 movle pc, lr ; Return to the caller if it is delay_1: subs r0, r0, #1 ; Decrement number of cycles to go moveq pc, lr ; Return to the caller if finished b delay_1 ; Otherwise, repeat the loop ; ----------------------------------------------------------------------- .end