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.
Have you read the processor documentation?
Have you looked at the sample code available? Note that sample code in C is just as valuable when it comes to figuring out how to use the processor.
Have you talked with the school if you are unhappy with the tutoring?
Since this is a task given to you - how far have you got?
Hi, I have to do it for tomorrow. I've read about GPIO and I know that I have to: - Activate the clock for Port D that is disactivated by default. - Set bit 5 of GPIO_PORTD_PDDR (Port Data Direction Register). - Set bit 5 of GPIO_PORTD_PDOR (Port Data Output Register).
I know the addresses of all these registers but I don't know which instructions I have to do(LDR, STR, ...)
For sure there is a simple solution.
Thanks for your answer.
"For sure there is a simple solution."
There is. But why do you not think you can find it yourself? As I asked before - do you feel your school does a bad job? Are your school mates also stuck?
I am sorry, but I am not going to talk about my school teacher and teammates here. I don't find it useful. I think I can find it myself, maybe it is a bit difficult but not imposible. If I find the solution, I'll write it here.
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