Having these addresses:
; - User data section ------------------------------------- AREA UserData, DATA, READONLY
LEDS EQU 0x4000703C ; access PD3-PD0 GPIO_PORTD_DOR EQU 0xF80FF0C0 GPIO_PORTD_PSOR EQU 0xF80FF0C4 GPIO_PORTD_PCOR EQU 0xF80FF0C8 GPIO_PORTD_PTOR EQU 0xF80FF0CC GPIO_PORTD_PDIR EQU 0xF80FF0D0 GPIO_PORTD_PDDR EQU 0xF80FF0D4 GPIO_PORTD_PCR EQU 0x4004c004 SIM_BASE_SCG5 EQU 0x40048038 SYSCTL_RCGC2_GPIOD EQU 0x1000 ; port D Clock Gating Control PORT_PCR_MUX EQU 0X100
How can I turn on a LED that it is on bit 5 of port D?
I have to do it with assembly code, not C.
Thanks in advantage.
Our teacher gave us this:
Peripheral registers are memory mapped and can be accessed by memory pointers.
DEV1 EQU 0x1000 ; Define location for device ; Read/Write code: LDR r1, #DEV1 set up device adrs LDR r0, [r1] read DEV1 LDR r0, #8 ; set up valued to write STR r0, [r1] ; write value to device
When I tried to copy it on my code, an error ocurred related with the #
So I substituted that code with this:
; - User data section ------------------------------------- AREA UserData, DATA, READONLY K DCD 5
; - Main Program ------------------------------------------ AREA MainCode, CODE, READONLY, ALIGN=3 __main PROC ; 1) activate clock for Port D LDR r1, =SYSCTL_RCGC2_GPIOD LDR r0, =K LDR r0, [r0] STR r0, [r1]
ENDP END
; - User data section AREA UserData, DATA, READONLY K DCD 5 ; - Main Program AREA MainCode, CODE, READONLY, ALIGN=3 __main PROC ; 1) activate clock for Port D LDR r1, =SYSCTL_RCGC2_GPIOD LDR r0, =K LDR r0, [r0] STR r0, [r1] ENDP END