GPIOs are the basic interfaces of any microcontroller. Without GPIOs we won’t have any other way to use a micro and it will be nothing more different than a chunk of well-fabricated silicon. Through them we can interface both transducers or sensors and actuators. We can also connect other devices like a display, external devices and so on. As with any ARM microcontroller, the GPIOs of TM4C12x Tiva C ARM microcontrollers are very elaborate, having many options that are usually unavailable in common 8-bit microcontrollers. The one we are interested in – the TM4C123GH6PMI – is a 64-pin micro with more than 40 usable GPIO pins. Here in this post we will explore the GPIOs of TIVA C micros.
Tiva C micros are low power ARM Cortex M4 MCUS and run typically at 3.3V and so you can guess the logic levels of GPIO pins. However, except a few GPIOs (PB0, PB1, PD4 and PD5) all GPIO pins are 5V tolerant. This 5V tolerant feature is a smart addition and most people will simply overlook it or won’t fully realize its potential use. At present microcontrollers are getting more and more energy efficient, and so their operating voltage levels are gradually decreasing. Most modern micros, especially the ARM family don’t operate at 5V and the use of 5V TTL logic level will eventually diminish in the future. The most common new voltage standard is that of a cell phone, i.e. 3.3V. Many microcontrollers like the ATMega16A and the PIC18F252 that usually operate at 5V have the ability to operate at 3.3V or even below. However, there are lots of other devices that can’t operate below 4V. These devices will operate erroneously or may even reset frequently due to brownout. Here the 5V tolerant feature of Tiva C MCUs come to aid, allowing us to use legacy external interfaces and devices like sensors, external modules, legacy microcontrollers, etc. without the need of additional logic level translator circuits or too much consideration about different voltage levels. It is as simple as plug-and-play. Thus, cost, space and size remain at a minimum.
At this point we need to note a few things:
Never exceed input logic high voltage of any pin beyond VDD limit unless you are sure that the source will not exceed the 5V limit and you aren’t using the any of the exceptional pins (PB0, PB1, PD4 and PD5). It is better to leave these pins idle unless you have memorized these pin numbers. Fortunately, PD4 and PD5 are inaccessible in the Tiva C Launchpad board.
Likewise, don’t use negative input voltages with any pin. Be sure of polarity.
Some GPIO pins are not accessible in Launchpad board while others are physically non-existent, e.g. PF7 and so don’t try to program them. Leave them alone just like a don’t care bit of a register.
When coding a new project, I recommend adding a delay of about 2 – 3 seconds at the start of the code to avoid part lockout.
Don’t stress any GPIO pin beyond 10 – 15mA, although the max limit is 25mA. Use external switching devices like opto-isolators, FETs and BJTs to drive high power loads.
Though most pins are 5V tolerant, it doesn’t necessarily mean that the logic level is based on 5V TTL logic level. The logic level voltage limits are still realized with respect to VDD, 3.3V.
Similarly, when using TIVA C micro’s ADC, the ADC pins can withstand voltages beyond VDD voltage limit but can’t measure voltages beyond VDD or reference voltage level.
GPIO pins have alternate functions and so use Pinmux software to find required GPIO pins. You can also checkout the alternate function pins in the help section of MikroC compiler under the GPIO library. In the compiler, if you type _GPIO and hit CTRL + Space, you’ll see all available options for GPIO.