Understanding the TIVA GPIO

In this i will describe the GPIO module features that is in the TM4C123 Launchpad. Other Tiva MCUs have a very similar GPIO but can have more or less GPIO modules or features so it's best to consult the datasheet always for more information. I won't refer to registers since this is intended to understand how to program with TivaWare. The tables refered to are always from the tm4c123gh6pm MCU.

What is GPIO?

GPIO stand for General Purpose Input/Outputs, meaning that it's a module capable of receiving and transmitting signals. They work with digital signals but can be muxed to use the pins with other peripheral functions (ADC, SSI, UART, etc).

Tiva GPIO specs

The tm4c123gh6pm has 6 GPIO blocks, each with his own GPIO port (port A, port B, port C, port D , port E , port F).

The specs are:

  • Up to 43 GPIOs, depending on configuration

  • Highly flexible pin muxing allows use as GPIO or one of several peripheral functions

  • 5-V-tolerant in input configuration

  • Ports A-G accessed through the Advanced Peripheral Bus (APB)

  • Fast toggle capable of a change every clock cycle for ports on AHB, every two clock cycles for ports on APB

  • Programmable control for GPIO interrupts

    • Interrupt generation masking

    • Edge-triggered on rising, falling, or both

    • Level-sensitive on High or Low values

  • Bit masking in both read and write operations through address lines

  • Can be used to initiate an ADC sample sequence or a μDMA transfer

  • Pin state can be retained during Hibernation mode

  • Pins configured as digital inputs are Schmitt-triggered

  • Programmable control for GPIO pad configuration

    • Weak pull-up or pull-down resistors

    • 2-mA, 4-mA, and 8-mA pad drive for digital communication; up to four pads can sink 18-mA for high-current applications

    • Slew rate control for 8-mA pad drive

    • Open drain enables

    • Digital input enables

So these are the specs, it has some really nice like the fact that almost all GPIO are 5V tolerant, a extra fast access bus called AHB and various interrupts in all the GPIO. Note that PD4, PD5, PB0 and PB1 aren't 5V tolerant and are maxed at a 3.6V input.

Each GPIO has 8 pins which should make a total of 48 pins but some of those are internal and can't be used so the maximum is 43. The launchpads usualy have less since some are not physically available. The TM4C123 launchpad has just 37 GPIO pins.

Alternate functions

The GPIO is what allows your processor to interface with the outside. It allows digital inputs or outputs and also allows alternate functions. What are these functions?

The alternate functions can be analog readings by muxing the ADC to a pin, or UART communication by making the right muxing.

The availability of such functions depend on the pin and you can see them in this table:

(table 10.2 and continuation from datasheet)

Every time you want to use a peripheral like the PWM module or ADC that needs to use a pin, remember to also set the GPIO to the alternate functionuncommitting

Very Important

GPIO Pins With Special Considerations

Some pins are locked to a certain configuration and can only be used if you unlock them. You need to do that in the GPIOLOCK register and uncommitted it by setting the GPIOCR register. If you use TivaWare this should work, just chose the right base:

HWREG(GPIO_PORTx_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;

HWREG(GPIO_PORTx_BASE + GPIO_O_CR) |= 0x80;

(table 10.1 from the datasheet)

The end

Since this tutorial doesn't get into registers this is the end. Check the code examples to use the simple GPIO input and output.