Thursday, 31 October 2013

ARM (LPCXXXX) Assembly Program for LED Blinking

@;===========================================================================
@;      LED Blinking program
@;     
@;      Modified by GAURAV VERMA
@;      
@;===========================================================================

AREA PROGRAM, CODE, READONLY
                        ENTRY
                                               
PINSEL0 EQU 0xE002C000
PINSEL1 EQU 0xE002C004

IOPIN   EQU 0xE0028000
IODIR   EQU 0xE0028008
IOSET   EQU 0xE0028004
IOCLR   EQU 0xE002800C
                               
                        ldr     r1,=PINSEL0             ; PINSEL0 controls pin 0-15,@; PINSEL1 controls pin 16-31
                        ldr     r2,=0x00000000    ;default GPIO function 00
                        str     r2, [r1]
                                                               
                        ldr     r1,=IODIR
                        ldr     r2,=0xFFFFFFFF  ; 0-INPUT 1-OUTPUT 0:31 (12 -LED)
                        str     r2, [r1]
                               
                         ; ON LED (GPIO) (GPIO LOW-ON)
BACK              ldr     r0,=IOCLR
                         ldr     r1,=0xFFFFFFFF ; CLR ALL
                         str     r1, [r0]
                         BL WAIT
                               
                       ; OFF LED (GPIO) (GPIO HIGH-OFF)
                          ldr     r0,=IOSET
                          ldr     r1,=0xFFFFFFFF ; SET ALL
                          str     r1, [r0]
                          BL WAIT
                          BAL BACK

WAIT                MOV r4, #0x00100000
BACK1              nop
                           SUBS r4, r4, #1
                            bne  BACK1
                            bx R14

                            END

No comments:

Post a Comment