0
\$\begingroup\$

I'm trying to make the led blinks on the tm4c1294ncpdt, so the basic idea its to make 2 routines , one to select the GPIO port (in this case the F) and other to keep up on and off.

the setup routine is the next code

PIO_Init
    LDR R1,=0x400FE608
    LDR R0,[R1]
    ORR R0,R0,#0x20
    STR RO,[R1]

    LDR R1,=0x4005D400
    MOV R0,#0x
`   STR R0,[R1]

    LDR R1,=0x4005D51C
    MOV R0,#0x
`   STR R0,[R1]

    BX LR

SWITCH_ON
        LDR R1,=0x4005D000
        MOV R0,#0x
        STR R0,[R1]
        BX LR

The idea its to select the PORTF using the base address and the offset (0x400F.E000+0x608), store it in the R0 and later orr it with 0x20 value.
Now these 0x20 is calculated this way, from the datasheet and the RCGCGPIO definition I'm using the F (6th) port so is this one
enter image description here

so this would be 0b 0010 0000 = 0x 20,

In the next part using the 0x4005D400/(GPIODIR) to configure the pin as output
enter image description here this would be also the

0b 0010 0000 = 0x20

But this seems to do nothing and besides I remember to see in class that in similar GPIODIR configurations the number used was 0x02 (so I taked as a bad written number since I was using 0x20).

I don't know which one is right.

LDR R1,=0x4005D400
MOV R0,#0x20
STR R0,[R1]

or

LDR R1,=0x4005D400
MOV R0,#0x02
STR R0,[R1]

how must be calculated these values in the MOV instruction?

UPDATE from the gpio.h in the SW-TM4C-2.1.4.178.exe, under the section "Values that can be passed to GPIOIntEnable() and GPIOIntDisable() functions" // in the ui32IntFlags parameter.

I have found that

#define GPIO_INT_PIN_0          0x00000001
#define GPIO_INT_PIN_1          0x00000002
#define GPIO_INT_PIN_2          0x00000004
#define GPIO_INT_PIN_3          0x00000008
#define GPIO_INT_PIN_4          0x00000010
#define GPIO_INT_PIN_5          0x00000020
#define GPIO_INT_PIN_6          0x00000040
#define GPIO_INT_PIN_7          0x00000080
#define GPIO_INT_DMA            0x00000100

so the 0x00000002 is used and at the end the right version is

LDR R1,=0x4005D400
MOV R0,#0x02
STR R0,[R1]

As pointed by Ellio Anderson enabling the clock, selecting and using the port are different things.

And the right version of the code is

 PIO_Init
        LDR R1,=0x400FE608
        LDR R0,[R1]
        ORR R0,R0,#0x20
        STR RO,[R1]

        LDR R1,=0x4005D400
        MOV R0,#0x02
    `   STR R0,[R1]

        LDR R1,=0x4005D51C
        MOV R0,#0x02
    `   STR R0,[R1]

        BX LR

    SWITCH_ON
            LDR R1,=0x4005D000
            MOV R0,#0x02
            STR R0,[R1]
            BX LR
\$\endgroup\$
  • 1
    \$\begingroup\$ Most programmers would prefer to use the manufacturers header provided for the specific chip. \$\endgroup\$ – Wouter van Ooijen Mar 12 at 19:08
  • 1
    \$\begingroup\$ @WoutervanOoijen: where's the challenge in that? \$\endgroup\$ – TimWescott Mar 12 at 19:23
  • 1
    \$\begingroup\$ It depends on the chip manufacturer, but all of the ones that I've used recently clearly try to keep things nicely symmetrical, so that bit 5 in the DIR register corresponds to bit 5 in the data register corresponds to bit 5 on the output. Read the data sheet. The datasheet is as close to truth as you can get until you have working hardware. \$\endgroup\$ – TimWescott Mar 12 at 19:24
1
\$\begingroup\$

The choice of which bit to manipulate in the Port F registers is determined by which physical port pin the LED is connected to. It is an entirely different issue than configuring RCGCGPIO. But you haven't told us how the LED is connected, so I can't help you there.

Also, at some point you should probably write something to the port's DATA register.

\$\endgroup\$
  • \$\begingroup\$ I put the routine to make use of DATa register, but Im facing the same issue \$\endgroup\$ – riccs_0x Mar 12 at 19:34
  • \$\begingroup\$ So Im using the D1 withh GPIO PN1 \$\endgroup\$ – riccs_0x Mar 12 at 19:35
  • 2
    \$\begingroup\$ Then the bit you manipulate in the port's DIR, DEN, and DATA registers should be the bit that corresponds to D1. \$\endgroup\$ – Elliot Alderson Mar 12 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.