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.

[FAQ] How to get locked GPIO pins on TM4C123 devices to work

 Affected GPIO Ports for TM4C123x Devices:

  • Port C0, C1, C2, C3
  • Port D7
  • Port F0

Behavior:

The I/O port will not operate as a GPIO when trying to change output levels or read input signals.

  • Solution: The Port Pins C0-3, D7 and F0 are locked pins for specific functionality of JTAG, NMI and NMI respectively. To use them in GPIO or any other function they need to be unlocked and commit register be set. The following example function shows how to unlock and commit the Pins "before" calling any GPIO Pin Configuration Function.

    Note: With the release of TivaWare Version 2.2.0.295, an API has been added to DriverLib to address this need: GPIOUnlockPin

    An example of proper API usage would be:

    GPIOUnlockPin(GPIO_PORTF_BASE, GPIO_PIN_0);

    Former method for older TivaWare Versions:

    Step 1) Include Header files:

    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "inc/hw_memmap.h"

    Step 2) Use the following code based on the required port and target device

    • Port C
    HWREG(GPIO_PORTC_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTC_BASE+GPIO_O_CR) |= (GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
    • Port D
    HWREG(GPIO_PORTD_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTD_BASE+GPIO_O_CR) |= GPIO_PIN_7;
    • Port F
    HWREG(GPIO_PORTF_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
    HWREG(GPIO_PORTF_BASE+GPIO_O_CR) |= GPIO_PIN_0;