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.

Interfacing 16x2 LCD with Piccolo TMS320F28027

Other Parts Discussed in Thread: TMS320F28027

Hey Folks,

Couple of months ago, when I was working with the Piccolo C2000 launchpad, I tried to interface 16x2 lcd with it. But, many times it didn't work. So, I decided to write a code of mine with the help of the knowledge from various websites. Finally, it worked. I had written it as an article, take a look at this:  http://embedjournal.com/interfacing-16x2-character-lcd-with-c2000-launchpad/

  • Hi Mani,

    Nice to see your work on the same! Can you share the pic of your running setup?
    8-bit mode consumes lot of GPIOs; 4-bit mode should be preferable.

    Regards,
    Gautam
  • Hi Gautam,

    I had implemented it for TI University program. You can watch the setup through the video demonstration. Here's the link
    https://youtu.be/w287KbiFHDI

    Yes, 4 bit mode is preferable. But, in that project I had the provision for consuming more GPIO pins. So, I didn't consider going for 4 bit mode. If there is any need we can always switch to another one easily.

    Regards,
    Mani.
  • Sure, will check this out and comment later :)

    Good job!
  • Thanks Gautham,

    I have gone through that link but the source code is not downloading. Can u please provide me the source code.?

  • Hello Nayeem,

    Source code is available there. Kindly click "Download the Source code" at the bottom of the page. Or else find the link below.

    www.dropbox.com/.../16x2_lcd_c2000_Launchpad.zip

    Regards,

    Mani.

  • Thanks for your reply.

    the link is not loading. Can u share me in rar file format.
  • Hai Mani,

    Can u please mail me the procedure with source code and header files.
    my email ID: nayeembasha452@gmail.com.

    Thanks & regards
    Nayeem Shaik
  • Hello Nayeem,

    Sorry for the inconvenience. 

    Try out this link:  

    Regards,

    Mani.

  • Hai Mani,

    Its throwing fatal error #1965. How to fix it.?

    Regards
    Nayeem Sk
  • What fatal error are you talking about? In CCS? Can you share the screenshot? Also, please open a new thread for fresh queries.

    Regards,
    Gautam
  • Error Description
    #1965 cannot open source file "f2802x_common/include/gpio.h"
  • This refers to your project include settings. Check your Project -> Properties and include the files required.
  • Hi Mani - I've been trying to use your code for my own 16x2 lcd but am unable to make an appropriate main function to run it - the board displays a row of black boxes, indicating that the lcd wasn't initialized properly. Could you supply a main function to run with your code? Thanks a bunch!
  • Hi Natalie,

    The main function can have the default peripherals settings like in adc_soc example. Apart from that you will need the following code:

    InitializeGpio();

    InitializeLCD();

    DELAY_US(500);

    DisplayLCD(1," ....Ready.... ");

    void InitializeGpio()
    {
    GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_2, GPIO_2_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_4, GPIO_4_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_4, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_5, GPIO_5_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_5, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_6, GPIO_6_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_6, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_7, GPIO_7_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_7, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_18, GPIO_18_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_18, GPIO_Direction_Output);
    GPIO_setMode(myGpio, GPIO_Number_19, GPIO_19_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_19, GPIO_Direction_Output);
    }

    InitializeLCD, DELAY_US, DisplayLCD  functions  are defined in piccolo_lcd.c source file.

    Hope it helps!

     

  • Hi Mani - thank you so much. Unfortunately, when I tried to implement the main function per your suggestion, nothing showed up but the same black boxes on the first line as before. Here's my main function - do you think you could tell me what's wrong?

    int main(void) {

    // 1. disable Watch Dog timer
    WDOG_Handle myWDog;
    myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
    WDOG_disable(myWDog);

    CLK_Handle myClk;
    PLL_Handle myPll;
    myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
    myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));

    CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

    PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2);


    // 2. initialize Gpio
    InitializeGpio();

    // 3. initialize LCD
    InitializeLCD();
    DELAY_US(500);


    // 4. display to LCD
    //char s[] = "Hello";
    DisplayLCD('1', " ....Ready.... ");

    return 0;
    }
  • Hi Natalie,

    I hope you have initialized all peripheral handles at the start of main() function.

    I can see that you are passing line number in DisplayLCD as character, it should be not be a character.

    You can just give it as DisplayLCD(1,"....Ready....");

    Also make sure the hardware connections are correct. Some times you may have increased the contrast of the LCD that could show black boxes in each rows. So, try to adjust the Potentiometer and watch out for the strings if you had done the above steps correctly.

  • hello, maybe you also want to try using this type of communication with the LCD screen.

    Regards

    Martin

  • Hi Mani - thanks for your reply. The peripheral handles that you are referring to - these are WDOG_Handle, CLK_Handle, and PLL_Handle, correct? If so, I did initialize these at the start of my main function that I sent to you in my previous post. And these were from your previous post. What else am I missing?

    I don't believe it's a hardware connection problem - I have hooked up this same LCD to an arduino and it ran just fine. And I connected my LCD to my launchpad per your circuit diagram. 

    As for the DisplayLCD comment, I noticed that the function DisplayLCD expects a character as its first input and not an integer. 

    Thank you so much for your help. This is my first time working with a LaunchPad. 

  • Hi Mani - thank you so much for all of your help. I figured it out - turns out I didn't initialize the gpio properly. Now it works beautifully! Thank you!
  • Hi Natalie,

    I'm so glad that you got it to work! 

    Regarding the argument for DisplayLCD function, I assigned char data type for saving memory only, anyway its not a problem when you pass 1 as integer or character because I'm comparing with integer only.

    Once again I'm so happy for you.

  • Hi Mani!

    where can I get all these definitions?

    #define RS GPIO_Number_12
    #define E GPIO_Number_19

    #define D0 GPIO_Number_0
    #define D1 GPIO_Number_1
    #define D2 GPIO_Number_2
    #define D3 GPIO_Number_3
    #define D4 GPIO_Number_4
    #define D5 GPIO_Number_5
    #define D6 GPIO_Number_6
    #define D7 GPIO_Number_7
    GPIO_Handle myGpio;

  • Hello Richa,

    I'm not sure what definitions you're looking for. To include gpio related declarations you can include the following header from Control Suite;

    #include "f2802x_common/include/gpio.h"

    -Mani

  • Hi Mani,

    Thanks for sharing the code.

    I have been working with Piccolo and pretty much understood the basics. I wanted to interface a 20x4 LCD with Piccolo TMS320F28027. If you could suggest the changes to be made in your code  or help me find documents related to it, it would be really helpful.

    Thank You.

    Mahesh

  • Mahesh,

    While Mani may still reply here, I can suggest what you might try.

    If you go the the embedjournal page, Mani steps through each of the Major pieces of the code that interface with the LCD array. For example, you will need to make a modification to the DisplayLCD function in order to add additional rows and columns. Look up the part number for your specific LCD array, as the values may be slightly different to address each line individually. There are many examples on the web that you can find that should help give you pointers on how to move forward.