Getting Started with TIVA C Series TM4C123G LaunchPad from Texas Instruments

Published  June 25, 2019   0
Getting Started with TIVA C Series TM4C123G LaunchPad from Texas Instruments

We are all familiar with AVR and PIC based microcontrollers as they are widely used but ARM based microcontrollers are getting popular nowadays because of their cost and speed. Texas Instruments' Tiva C Series TM4C123G LaunchPad (EK-TM4C123GXL) is one of them, it is a low cost development board based on ARM Coretx-M4F Evaluation Board. This beautiful shiny Red board is fascinating to work just because of the very fact that it belongs to Texas Instruments. Learning how to use TI Microcontrollers would definitely be a mighty tool up in our sleeve because TI has a wide verity of MCU’s to choose from for a very competitive price. We already previously covered another popular board from TI – MSP430 LaunchPad and built many projects using it.

 

 

In this series of tutorials, we will learn about this TM4C123 LaunchPad and how to program it. Using this LaunchPad we can work with C series Microcontrollers which offers 32-bit performance with an operational speed up to 180MHz. The tutorials will be written for very beginners in electronics and hence every topic would be briefed as crisp as possible. The hardware required for these tutorials would be a laptop and the TIVA LaunchPad Development Toolkit with few other basic electronics components that you can easily find in your local electronics hardware shop. So without any further delay let’s dive into the Development Tool and check out what’s included in the box and how to use them. We will be able to Blink an LED using TIVA TM4C123G at the end of this tutorial.

 

TM4C123 TIVA LaunchPad Contents

When you purchase the TM4C123 TIVA LaunchPad Development Tool from TI or any other local vendor you will get the following materials included in your Box.

  • TM4C123 TIVA LaunchPad Development Board (EK-TM4C123GXL)
  • On-board In-Circuit Debug Interface (ICDI)
  • USB micro-B plug to USB-A plug cable
  • Quick start guide

 

Let’s see Features and specifications of TM4C123 LaunchPad.

 

TIVA C Series TM4C123G LaunchPad

 

The TIVA C series LaunchPad Features

There are three variants in TIVA C series LaunchPad with different features and specifications. They all have different number of GPIO pins, speed, memory and connectivity. All the important features of different TIVA boards are compared in the table given below:

 

               MCU Name

               Features

TM4C123G LaunchPad: EK-TM4C123GXL

  • TM4C Series MCU - 80 MHz ARM Cortex-M4 CPU w/ Floating Point.
  • 256KB Flash, 32KB RAM, 2KB EEPROM, 2x12-bit 1MSPS ADC, 6x64-bit & 6x32-bit timers
  • Up to 16 Motion PWM, 8 UART, 4 I2C, 4 SSI, 2 CAN, 1 USB H/D
  • On-board USB in-circuit debug interface
  • Stackable 40-pin BoosterPack XL interface
  • RGB user LED , Two user switches (application/wake)

 

 

TM4C1294 Connected LaunchPad: EK-TM4C1294XL

  • Fastest TM4C Series MCU - 120 MHz ARM Cortex-M4 CPU w/ Floating Point
  • Integrated 10/100 Ethernet MAC+PHY & scalable, cloud-based application solution
  • 1MB Flash, 256KB RAM, 6KB EEPROM, 2x12-bit 2MSPS ADC, 8x32-bit(16x16-bit) timers
  • Up to 8 Motion PWM Channels, 10 I2C, 8 UART, 4 QSPI, 2 CAN, 1 EPI, 1 USB H/D
  • On-board USB in-circuit debug interface
  • Two Stackable 40-pin BoosterPack XL interfaces
  • I/O grid for solder-less breadboard & custom baseboard connection

 

TM4C129E Crypto Connected LaunchPad: EK-TM4C129EXL

  • Fastest TM4C Series MCU - 120 MHz ARM Cortex-M4 CPU w/ Floating Point
  • Integrated 10/100 Ethernet MAC+PHY & scalable, cloud-based application solution
  • 1MB Flash, 256KB RAM, 6KB EEPROM, 2x12-bit 2MSPS ADC, 8x32-bit(16x16-bit) timers
  • Crypto acceleration hardware
  • Up to 8 Motion PWM Channels, 10 I2C, 8 UART, 4 QSPI, 2 CAN, 1 EPI, 1 USB H/D
  • On-board USB in-circuit debug interface
  • Two Stackable 40-pin BoosterPack XL interfaces
  • I/O grid for solder-less breadboard & custom baseboard connection
  • Secured cloud connection out-of-box demonstration with TI-RTOS, WolfSSL and Exosite

 

 

As you can see in above table that all LaunchPad boards feature on-board emulation for programming and debugging code, push buttons and LEDs, as well as connectors which are used to connect TI based BoosterPacks plug-in modules, which adds new functionality to the LaunchPad such as wireless connectivity, LEDs, sensors and more. 

TIVA C Series LaunchPads

 

From all the three LaunchPads, Connected and Crypto connected LaunchPads are vast features and they are used in industries for high performance computing and also there sizes are almost double of TM4C123G LaunchPad. So, for smaller applications TM4C123G LaunchPad is best choice. Hence in this series of tutorials, we will be using the TM4C123G LaunchPad to explore all the functionalities of this Development kit.

 

Comparing TIVA LaunchPad with Arduino and MSP430

In previous tutorials, we have frequently used Arduino and MSP430 Launchpad. Now, lets see how they are different from TIVA LaunchPad. Each family of microcontrollers have some features in common like GPIO pins, an ADC or two, timers etc. However, the way they work internally are totally different because they have different registers and different process for using them. TIVA LaunchPads are ARM cortex M4 based 32-bit microcontrollers while Arduino (atmega328) and MSP430 has totally different architecture with 8-bit bus. Dimensions of these developments kits are almost same but they have different number of GPIOs and processing speeds. Coding techniques are also different in each family.

Interesting thing is that the LaunchPads from TI have a processing-based language similar to the Arduino which is called Energia which can work with TIVA C series LaunchPads.

 

Powering and Testing TIVA C series TM4C123G Development Board

Below image shows all the on-board components of TIVA LaunchPad. There are two USB connectors and one power select switch. For programming and Debug purpose you have to use USB connector with Debug written under it, also make the power select switch towards debug to program it. Also, you can power the board using this connector.

Alternatively, for powering the microcontroller you can use second USB connector and make the power select switch towards Device. But this will only power up the board and cannot be programmed.

Before start anything, TI would have already uploaded a sample Program on your TIVA Microcontroller, so let us power the board and check if it is working. So power the board through the micro USB jack and once you do it, you should notice the RGB LEDs at the bottom of Reset button of your board glowing alternatively.

Powering and Testing TIVA C series TM4C123G Development Board

 

Now, let us move on to the Software Environment.

 

Programming Software (IDE) for TIVA LaunchPad

Texas Instruments allows us to program their Microcontrollers through a variety of Environments. The Official one is the Code Composer Studio commonly known as the CCS. Another IDE is Keil uVision. These softwares are free but using these requires some minimal level of experience with Microcontrollers.

Since this series of tutorials are targeted for absolute beginners we use another Development Environment called Energia. Energia is an Open source and free Environment that enables us to program the TI Microcontrollers easily. The main aim of Energia is to make programming TI MCU’s as easy as programming in Arduino. So Energia is an Equivalent for Arduino IDE that supports Texas Instruments Microcontrollers. People who have used Arduino will agree more on this once they download and launch the Energia IDE. We previously used Energia IDE for programming MSP430 board.

 

Downloading and Launching the Energia IDE to Program TIVA Launchpad

As said earlier the Energia is an open source and free Development environment, and it can be downloaded from this Download link. Select the Version based on your operating system, for windows you should notice a ZIP file being downloaded. After downloading the ZIP just extract it on your preferred location and open the folder. You find the application named Energia. Launch it and it should Look something like below.

Launching the Energia IDE to Program TIVA Launchpad

 

Arduino users don’t be surprised as it just might look like your Arduino IDE has dressed up like a Santa to appear as Energia. The resemblance of both Arduino and Energia are same because they both are built on top of a platform called Processing.

Now, we have to download the board files for the TIVA LaunchPad.

Go to Tools -> Board -> Boards Manager. Search for TivaC boards and download it as shown below.

Install TivaBoard Library in Energia IDE

 

Now, we are ready to program our Launchpad.

 

Blinking an LED on Tiva C Series TM4C123G LaunchPad

Now, that we are ready with our hardware and software let us try a basic example program from Energia to blink the on board LED. Before we start programming we have to know the pin names of each pin on our TIVA C board. Because we will be using these names while programming our board. The following picture from the Energia website will help us understand the name and functionality of each pin. Based on the Revision of your board the image might vary slightly.

Tiva C Series TM4C123G LaunchPad Front Pinout

Tiva C Series TM4C123G LaunchPad Back Pinout

 

Save these images, as we will need it all time while programming our board through Energia.

 

Understanding the Example Blink Program

Let’s, start with the Example blink program which will blink the onboard RGB LED alternatively which is connected to the PF_1 (red), PF_2 (blue) and PF_3 (green) pin of your Microcontroller.

To open this example program go to File->Example->Basics-> Blink as shown below

Understanding the Example Blink Program in Energia

 

The following program will appear on your IDE

#define LED RED_LED
// the setup routine runs once when you press reset:
void setup() {              
  pinMode(LED, OUTPUT);     // initialize the digital pin as an output.
}
// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

 

Above code is for blink the RED led only but we have to blink RGB led so Lets break the above code into line by line and add some more lines of code for other two LEDs, but before that let us understand the basic programming structure of Energia. Every Energia Program will have two mandatory functions, they are void Setup() and void Loop().

The code present inside the void Setup() will be executed only once and the program present inside the void Loop()will be executed for ever. All the pin declarations and initializations will be done inside the Setup() and the main program which has to be executed forever will be written inside the void Loop(). You can think of void Loop() as an equivalent to while(1) (Infinite while loop). With this in mind let us start exploring above code line by line.

 

The first line of the program is called macros. The Energia IDE is smart enough to understand words like RED_LED, GREEN_LED, TEMP_SENSOR and much more. These are nothing but the name of the pins to which the hardware is connected to. This is possible because the Red, blue and Green Led’s are hardwired on our board and hence the MCU pin to which it’s connected to is known. Again for the comfort of programming we use a Macros which says that instead of using the name “RED_LED” in my program I will use only “LED1”  by using the #define as shown in the below line. Similarly declare macro for other two leds.

#define LED1 RED_LED
#define LED2 BLUE_LED
#define LED3 GREEN_LED

 

Next we come into our void setup() function, this is the place where we tell our MCU which pins should be used as input pins and which should be use as output pins. In our program we are using 3 LEDs and these are Output device, so we declare it to be an output pin like shown below

void setup() {               
pinMode(LED1, OUTPUT);   
  pinMode(LED2, OUTPUT);  
  pinMode(LED3, OUTPUT);    
} 

 

The line pinMode() is used to say that I am going to declare input/output pins and then we say the name and type of the pin in bracket. Here the name of the pin is LED and the type of the pin OUTPUT.

There are many ways in which we can call a pin. In this example we have named it LED using the #define macro, but we can also name it using its original name. Like in our case the LED1 is connected to the 30th pin of the MCU and that pin is named as PF_1, Refer the pin-out picture above to see the names. So instead of calling it as LED we can also call it by the following

pinMode(LED1, OUTPUT);     //Instead of this we can also
pinMode(30, OUTPUT);     //Call by pin number
pinMode(PF_1, OUTPUT);     //Call by pin name

 

Next lets step down to the void Loop() function. Here we have to write the code to blink the LEDs. To blink an LED we have to turn it ON wait for a pre-defined timed and then turn it OFF and again wait for a pre-defined time and again the cycle continues.

To turn a pin ON or OFF in Energia we have to use the digitalWrite() function. The parameters pass the name of the pin and its state in the brackets like shown below

digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)

 

Here the name of the pin is LED and the state is HIGH, similarly you can also turn it off by using the state LOW like below

digitalWrite(LED1, LOW);    // turn the LED off by making the voltage LOW

 

As said earlier the name of the pin can be anything like LED1, 30 or PF_1 for this pin. So other forms like

digitalWrite(30, LOW); digitalWrite(PF_1, LOW); 

are also possible.

 

Now, that we have learnt how to turn ON or OFF the pins. We will learn how to introduce delay using the delay(). We can specify delay by passing a value inside the brackets in terms of milli-seconds

delay(100);          

 

So let’s combine all these into our while loop. We should turn ON each LED wait for 100mS, then turn OFF and again wait for 100mS. This cycle should continue forever. So our program will look something like this below

void loop() {
  digitalWrite(LED1, HIGH);  
  delay(100);              
  digitalWrite(LED1, LOW);   
  delay(100);              
    digitalWrite(LED2, HIGH);  
  delay(100);              
  digitalWrite(LED2, LOW);   
  delay(100);              

  digitalWrite(LED3, HIGH);  
  delay(100);              
  digitalWrite(LED3, LOW);   
  delay(100);              
}                     

 

Compiling and uploading your Blink Program

The next step would be to upload this program to our TIVA board. To do this simply connect your board to the computer using the micro USB cable provided and wait for some time. The drivers for the board should start installing automatically. Then Open your device manager and under the COM ports option you should see your Board name like shown below

Compiling Blink Program in Energia

 

Once your board is discovered, make a note to which COM port it is connected to. Mine is connected to Port 24 here. Then go back to the Energia IDE and select Tools -> Port and select the same port I have select COM24 for me. Then again go to Tools -> Boards and select the LaunchPad(TIVA C) w/ tm4c123 . Once done you should notice the following at the bottom right corner of your Energia IDE.

Processing Blink Program in Energia

 

Now click on the upload icon on the top left corner and your program should start uploading to your board. If everything works fine you should notice the “Done uploading” message appearing on your IDE as shown below

Uploading Blink Program in Energia

 

Verifying our Blink Output

Once the program is uploaded you can notice the RGB Led on your Board blinking alternatively as programmed from our Energia IDE as shown below.

Blink an LED using TIVA C Series TM4C123G LaunchPad from Texas Instruments

 

You can also verify the same using the video below that shows how I got the output. If everything has worked out till now, then give yourself a cookie and gear up for the next tutorial for more exciting stuff.

Hope you understood the tutorial and learned something useful if you got stuck anywhere please feel free to use the comment section below or the forums to post your questions and I would be happy to help you out.

Code

#define LED1 RED_LED
#define LED2 BLUE_LED
#define LED3 GREEN_LED

//see pins_energia.h for more LED definitions
//#define LED GREEN_LED
  
// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(LED1, OUTPUT);   
  pinMode(LED2, OUTPUT);  
  pinMode(LED3, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(LED1, HIGH);   
  delay(100);               
  digitalWrite(LED1, LOW);    
  delay(100);               

  digitalWrite(LED2, HIGH);   
  delay(100);               
  digitalWrite(LED2, LOW);    
  delay(100);               

  digitalWrite(LED3, HIGH);   
  delay(100);               
  digitalWrite(LED3, LOW);    
  delay(100);               
}

Video

Have any question realated to this Article?

Ask Our Community Members