This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT: GPIO register 7:0 bits meaning

Part Number: TM4C129ENCPDT

Hi, when I read GPIO register descriptions in the data sheet of TM4C129ENCPDT, I am confused on the meaning of bits. E.g. GPIOAFSEL register, 7:0 bits are GPIO alternate function select. I would e.g. select UART0 as GPIO port A, how do I know which bits should be selected? 7:0 bits contain 256 variables, and I was guessing these are configured for pin numbers? I tried to read the data sheet couldn't figure out how to select these 7:0 bits to configure UART0(pin 33, 34) in GPIO?

Regarding GPIO port control register(GPIOPCTL), the description is so confusing again. e.g. Port Mux Control 0: this field controls the configuration for GPIO pin 0. This 'pin 0' is not the 'physical pin 0'. What is the definition/meaning of the GPIO pin 0-7 in this register?

Many thanks for your kind help!

  • Hello Bin,

    GPIOAFSEL maps the 8 bits of the register to the 8 GPIO pins. Each pin is either a 0 or a 1. If its a 0, then the pin is used as a GPIO. If its a 1, then the pin is used by another peripheral.

    So for example is using UART0 with Port A, the register should read 0x03 because Bits 0 and 1 should be set to '1' to indicate Port A0 and A1 will be used by another peripheral (UART).

    For GPIOPCTL, Table 29-5. GPIO Pins and Alternate Functions should be referenced.

    Alternatively, you can skip all these details and just use provided TivaWare APIs that handle all of this for you like the following example:

        /* Enable GPIO port A which is used for UART0 pins. */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
        /* Configure the pin muxing for UART0 functions on port A0 and A1. */
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
    
        /* Select the alternate (UART) function for these pins. */
        GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    Best Regards,

    Ralph Jacobi

  • Hi Ralph,

    Many thanks for your kind explanation. 

    BR, Bin