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.

LCD interfacing with TM4123GH6PMI

Other Parts Discussed in Thread: EK-TM4C123GXL, TM4C123GH6PM

I am trying to interface a 16 X 2 text LCD to the TIVA C TM4C123GH6PMI Launchpad..... I am encountering the following error in my code:

#20 identifier "unint32_t" is undefined

Which header file needs to be included in my code to eliminate this error?

  • This error appears for the gpio.h and sysctl.h files

  • Prachi Joshi said:
    #20 identifier "unint32_t" is undefined

    wrong spelling.

    - kel

  • Markel Robregado said:

    #20 identifier "unint32_t" is undefined

    wrong spelling.

    - kel

    [/quote]

    Yes, sorry... the spelling was wrong. 

    The error appears as:

    #20 identifier "uint32_t" is undefined              sysctl.h                  /TIVA C                lcd line 587            C/C++ Problem

    This error appears for gpio.h and sysctl.h.

  • Prachi Joshi said:
    Yes, sorry... the spelling was wrong.

    Thousands of hours (likely 10x that) of programming time is lost each year via such, "manual data entry."  (not a spelling error - but a manual transcription - too often these prove an, "adventure!")

    Cure is to use, "Cut & Paste" when moving/copying such items (or code blocks) as this minimizes/eliminates the need for (always suspect) manual (typing) data entry...

    Once you "escape" such (unnecessary) transcription errors you may wish to review HD44780 spec (Google) which reveals (and best guides) your complex initialization & timing requirements for these parallel input Lcds...

  • Prachi Joshi said:

    The error appears as:

    #20 identifier "uint32_t" is undefined              sysctl.h                  /TIVA C                lcd line 587            C/C++ Problem

    This error appears for gpio.h and sysctl.h.

    If you fixed the wrong spelling and still have that error, you are missing this below.

    #include <stdint.h>

    - kel

  • f you fixed the wrong spelling and still have that error, you are missing this below.

    #include <stdint.h>

    - kel

    Yes, I have included the statement 

    #include<stdint.h>

    Still getting the same error

  • I have not entered this line..... It is an error that appears.

  • Markel Robregado said:
    uint32_t

    Compare your project settings to project settings of a working example program that uses unnt32_t. 

    Also, you can just use a working example program like "hello", and then append your code.

    - kel

  • Markel Robregado said:
    working example program that uses unnt32_t.

    Working example - with that, "transcription error" ...unlikely!

    You've further illustrated (and proved) my point - manual data entry leads too often to such error!  Cut and paste from the original (correct) item listing avoids...

  • Markel Robregado said:
    Compare your project settings to project settings of a working example program that uses unnt32_t. 

    I am also correcting my wrong spelling.

    What I meant was   . . .

    Compare your project settings to project settings of a working example program that uses uint32_t.

    - kel

  • Last post much better.

    Cut/Paste (again) avoids any "spelling" (really transcription) errors.  We've seen clients spend hours searching large code when the issue revolved around a, "mis-transcribed" variable name.  Can be completely avoided by enforcing, "Cut/Paste" only. 

    Further - should language be an issue - users may more easily, "miss" the incorrect data item.  Cut/Paste rescues/prevents...

  • Hi Prachi,

                     If you are using ek-tm4c123gxl launch pad from Tiva C seires and Keil IDE, then try to use the Tivaware examples->boards->ek-tm4c123gxl and there you can see project0. Make a copy of that and paste at the same location and rename it as your current project. Open the renamed project and paste your new code on the main file and compile it.

  • HI,
    Can you post the code with header files. LCD. If you post the code it will help to develope my project. Thank you.
  • Hello Prachi

    Can you paste the order of the includes, in your main code?

    Regards
    Amit
  • Hi Babitha,

                        Here I am posting TM4C123GXL launchpad interfacing 2*16 LCD code. This one is also had serial comm code files.I hope this will be suitable for you to interface the LCD.

    Regards,

    Nithin

  • Amit Ashara said:
    Hello Prachi

    Can you paste the order of the includes, in your main code?

     Hi Amit, I fear we both need some vacation ;)

  • Hi Nithin,

    I can't find any code or file with your reply. Can you send it one more time. Thank you.

  • Hi Babitha ,

                         Sorry,I can't able to upload those files because of some technical issue. So I can provide you the link for LCD interfacing. All you have to do is change the header from lm4f to TM4C. You can able to find this headers from tivaware library. Here is the link

    https://gist.github.com/vinodstanur/4179275/download#

    Regards,

    Nithin. 

  • Hi Nithin,
    Thank you for your link. I change the header to tm4c. but the code doesn't work. Can you give any other suggestions. Thank you.
  • Hi Babitha,
    First of all let me know whether you are using 4 bit or 8bit LCD?, your IDE?,tivaware peripheral driver library version.I am assuming that your hardware connections are perfect, is it?

    Regards,
    Nithin
  • Hi Nithin,

             I am using 8bit JHD162A LCD. I am using CCS 6 and  TM4C123GH6PM controller. The LCD backlight is on but the data not displayed.

  • Hello friend,

                           I am using Keil IDE but you can try this in CCS as well.

    LCD is connected with PORTF and PORTB as:
    D0...D7 -->PB0..PB7
    RS -->PF1
    RW-->PF2
    EN -->PF3
    VSS --> GND
    VDD --> VBUS
    
    
    ===== LCD.h file ====
    
    #include <stdio.h>
    #include "tm4c123gh6pm.h"
    #include "PIN_PORTS_DEFIENATIONS.h"
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    typedef unsigned char uint8;
    
    void LCD_init(void);
    void LCD_Send_Command(uint8 command);
    void LCD_Goto(uint8 x, uint8 y);
    void LCD_Send_Character(uint8 character);
    void LCD_Send_String(char *str);
    void Delay_ms(unsigned long time);
    void LCD_Clear(void);
    void LCD_Send_Integer(int number);
    void LCD_Send_Float(float f);
    //void Delay_5_ms(void);
    ===================

     ==================
    =====LCD .c file =====
    ==================
    
    
    #include "LCD.h"
    
    #define LCD_DATA_PORT GPIO_PORTB_DATA_R
    
    #define LCD_CONTROL_PORT GPIO_PORTF_DATA_R
    
    #define LCD_RS_PIN PF1
    #define LCD_RW_PIN PF2
    #define LCD_E_PIN  PF3
    
    
    void LCD_init(void)
    {
    /* initialization for lcd data and command (ALL PINS OF PORT B)*/
    volatile unsigned long delay;
    SYSCTL_RCGC2_R |=SYSCTL_RCGC2_GPIOB; //ative clock for PORT B
    delay = SYSCTL_RCGC2_R;
    
    GPIO_PORTB_AMSEL_R = 0x00; //DISABLE ANLOG ON PORT B
    GPIO_PORTB_PCTL_R = 0x00000000; //
    GPIO_PORTB_DIR_R = 0xFF; // MAKE PORTB IS OUTPUT PORT
    GPIO_PORTB_AFSEL_R = 0x00; //DISABLE ALTERNATIVE FUNCTION
    GPIO_PORTB_DEN_R =0xFF; // ENABLE DIGITAL I/O FOR PORT B
    
    /*initialization for lcd control ()*/
    /*SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
    delay = SYSCTL_RCGC2_R;
    GPIO_PORTF_LOCK_R = GPIO_LOCK_KEY;
    GPIO_PORTF_CR_R = 0x0E;
    GPIO_PORTF_AMSEL_R = 0x00;
    GPIO_PORTF_PCTL_R = 0x00000000;
    GPIO_PORTF_DIR_R = 0x0E;
    GPIO_PORTF_AFSEL_R = 0x00;
    GPIO_PORTF_DEN_R = 0x0E;*/
    
    LCD_Send_Command(0x38);
    Delay_ms(100);
    LCD_Send_Command(0x0C);
    Delay_ms(100);
    LCD_Send_Command(0x01);
    Delay_ms(100);
    LCD_Send_Command(0x06);
    }
    
    
    void LCD_Send_Command(uint8 command)
    {
    LCD_DATA_PORT = command;
    
    LCD_RS_PIN = 0x00;
    LCD_RW_PIN = 0x00;
    LCD_E_PIN = 0xFF;
    Delay_ms(100);
    LCD_E_PIN = 0x00;
    }
    
    
    void LCD_Goto(uint8 x, uint8 y)
    {
    uint8 firstAddress[]={0x80,0xC0};
    LCD_Send_Command(firstAddress[x-1] + y-1);
    Delay_ms(100);
    }
    
    
    void LCD_Send_Character(uint8 character)
    {
    LCD_DATA_PORT = character;
    
    LCD_RS_PIN = 0xFF;
    LCD_RW_PIN = 0x00;
    LCD_E_PIN = 0xFF;
    Delay_ms(100);
    LCD_E_PIN = 0x00;
    }
    
    
    void LCD_Send_String(char *str)
    {
    while(*str)
    {
    LCD_Send_Character(*str++);
    
    }
    }
    
    void Delay_ms(unsigned long time)
    {
    time = 145448;  // 0.1sec
      while(time){
    time--;
      }
    }
    void LCD_Clear()
    {
    LCD_Send_Command(0x01);
    }
    void LCD_Send_Float(float f)
    {
    unsigned int v,p;
    long int num;
    num=f*10000;
    p=num%10000;
    
    v=num/10000;
    
    LCD_Send_Integer(v);
    LCD_Send_Character('.');
    LCD_Send_Integer(p);
    
    }
    void LCD_Send_Integer(int number){// This function prints integer on LCD
    char buffer[10];
    Delay_ms(10);
    sprintf(buffer,"%d",number); // function sprintf converts integer to string
    LCD_Send_String(buffer);
    }

  • We note requesting poster details her failure as, "Does not Work!"   (always immensely helpful...)

    HD44780 data details that a delay is required between rise of Enable, post any change to RS/RW.

    Code supplied - specifically:

    LCD_RS_PIN = 0x00;
    LCD_RW_PIN = 0x00;
    LCD_E_PIN = 0xFF;
    Delay_ms(100);
    LCD_E_PIN = 0x00;

    and

    LCD_RS_PIN = 0xFF;
    LCD_RW_PIN = 0x00;
    LCD_E_PIN = 0xFF;
    Delay_ms(100);
    LCD_E_PIN = 0x00;

    Causes the (initial) rise of E to (likely) violate that set-up time enforced between RS/RW and E.  Such will only be impactful upon a change from "Command Writes to Data Writes" (or vice-versa) when RS/RW will change from past levels.   This may be noted by a "missed" first character.  Once RS/RW have toggled (post a change from Command to Data Write) there will be no violation - until a call to the other (Command/Data) mode is issued.

    Insertion of an adequate, small delay (w/in both functions) between LCD_RW_PIN and LCD_E_PIN = 0xFF; will remove this timing violation.  It's always best practice to comply w/chip's timing/level specifications.   If you've escaped this "first character or command" error (so far) - it may be that your MCU is running at very low system clock - faster MCUs "MUST" comply with the RS/RW to E rise specified data timing.

    Use of 0xFF and 0x00 - to set/clear individual pins - is bit brutal - is it  not?   At some point those key control pins are likely to reside on the same port - and such "broad" stroked data may very well wreak havoc...

  • Thank you friends for your valuable suggestions. Now the display works.