Home / Embedded Systems / Interfacing 16×2 LCD with C2000 launchpad

Interfacing 16×2 LCD with C2000 launchpad


c2000_lauchpadThe C2000 Launchpad is an inexpensive evaluation module based on Piccolo family microcontrollers from Texas Instruments (TI). The famous one is TMS320F28027 Digital Signal Controller (DSC). This DSC is indented for real time control and digital signal processing applications. If you wanna learn about digital signal controllers, I would recommend this as the starting point. More information about the C2000 Launchpad can be found at TI website.

There is CCS (Code Composer Studio) IDE for programming and debugging the Launchpad. It includes an optimizing C/C++ compiler, source code editor, project build environment, debugger, profiler, and many other features. Also, the presence of Control Suite, a support software containing libraries and examples makes the learning easy.

P.S. I’ll be referring the C2000 by its family name as Piccolo DSC in this article.

LCD Interfacing part

For this post, I will assume that you are fairly acquitted with the basics involved in the interface of the LCD. We have covered that topic at much detail at Embed Journal. For those who need to get basics on interfacing LCD with microcontrollers read the post Interfacing LCD module with microcontroller by Siddharth. And as always, there are two modes of operation of the LCD 8 bit and 4 bit depending on the number of data lines you are willing to give for the interface. As I did not have any limitation on the number of pins available on the controller, I choose to use the 8 bit mode.

Circuit Diagram:


Piccolo DSC provides multiplexed I/O lines, so we need to carefully choose the I/O lines for interfacing the modules. The following image shows the pin mapping of 16×2 LCD with the Piccolo DSC. The R/W line is always tied to ground, since we are always writing to the LCD.

Initializing LCD

This function initializes the LCD interfacing. Initially, the Enable pin is held high and then four delays of 1600 microseconds is given. After that, hex value 0X38 is sent as the command for selecting the 8 bit interface.

Here, two delays were used. One is small delay of 50 microseconds and another one is long delay of 1600 microseconds.

After selecting the 8 bit mode, the commands for clearing the display, setting entry mode (cursor moving direction), blink cursor and placing the cursor at home.

Writing Command to LCD

This function sends command to the LCD. First, the Register Select pin is set low before writing command. After that the command is written with the help of SendByte function. At the end of the function a small delay is given.

Sending Byte to LCD

Here, the data pin is set to high or low according to the command or data received. This routine is used to write both data and command to the LCD. Each value is ANDed with the corresponding bit. If the result is 1, then the pin will be set high. If it is 0, then the pin will be set low.

At the end, the enable pin is set high and low as negative edge triggering is required for transferring the data from the register to the LCD. For this, a short delay has been generated using the for loop.

Displaying character in LCD

This function receives the line number along with the message to be shown in the LCD. Here, the message is received in the form of pointer array. For, loop is used to send each character to the LCD. Maximum of 16 characters can be displayed in a row. Line number 1 and 2 is used to select the rows 1 and 2.

Only necessary functions has been explained. For more information refer the code at the end of this article.

Using the functions

With the help of the above header file and source code, we can start using the functions in our own code. Here, I had written code for displaying the text in both the rows of the LCD.

Necessary header files has been included at the starting of the code along with our Piccolo_lcd header file. InitialGpio() function is used to initialise the I/O pins used for interfacing the LCD to output. For this the inbuilt setMode and setDirection functions were used.

In the main() function, the Watch Dog timer is disabled first in order to avoid un necessary reset during the program execution. Then, the GPIO pins are initialised. After that, the LCD initialize function is called to initialize LCD. The, the text has been displayed using the DisplayLCD function.

Hope this post will be of help in interfacing a 16×2 Character LCD with Piccolo DSC. The code used here can also be ported for any microcontroller families with minimal changes.

Download Souce Code

About Mani

Mani is an Embedded Linux hobbyist having perennial interest towards Electronics and Agriculture. You can reach him by the following social channels.

Check Also


Are you reading the datasheet? What to look for and how to find them!

Did you know that experienced engineers spend up to an hour on every major component …

  • Nayeem

    I need source code for LCD interface with F28027 Launchpad.
    Can anybody help me please..?

    • Mani Sadhasivam

      Hi Nayeem,

      You can find the source code at the bottom of the post.

  • Made

    could you also provide the main function?
    Would be great!

Keep in touch with the current trends!
Did you like this article? Sign up and get our latest posts delivered to your inbox!
  We hate spam and never share your details.