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.

Compiler/CC2538-CC2592EM-RD: Hard time interfacing HD44780 with CC2538

Part Number: CC2538-CC2592EM-RD


Tool/software: TI C/C++ Compiler

Can anyone suggest a good library which I can use to interface HD44780 based 16x4 Alphanumeric display?

As of now , I am referring  <-this link and finding difficulties in getting the library to work. 

Any help would be really appreciated.

Thanks.

  • Issue resolved ! GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_0,1 ) works fine but GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1,1 ) wont work ever as third argument '1' means 0x00000001 and GPIO_PIN_1 would expect '2' as third argument because '2' would mean 0x00000010. Alternatively, we can write GPIO_PIN_X, GPIO_PIN_X as 2nd and 3rd arguments to write pin X HIGH.

    While testing pin writes , I used GPIO pin 0 all the times and that's why 3rd arg=1 worked okay. Thus , the issue could not be seen that time and later I did not suspect the third argument at all. Now , after taking note of it and doing necessary changes , i see text on HD44780 16x4 LCD running at 3.3v without backlight. (backlight needs separate supply and is optimal at 5v supply).

    Note - Now I am working on creating a library for the same.

    Following code works just fine (in zmain.c).

    ...
    extern uint32_t varhigh=0;
    extern uint32_t varlow=0;
    extern uint32_t cntvar=0;
    /******************************************************************************
    * LOCAL DEFINITIONS
    */
    ...

    ...
    /******************************************************************************
    * LOCAL FUNCTIONS
    */

    static void zmain_dev_info( void );
    static void zmain_ext_addr( void );

    static void helloworld(void);
    ...

    ...
    /* Display the device info on the LCD */
    #ifdef LCD_SUPPORTED
    zmain_dev_info();
    zmain_lcd_init();
    #endif

    #ifdef LCD3
    helloworld();
    while(1)
    {}//*/
    #endif
    ...

    ...
    #ifdef LCD3
    static void helloworld( void )
    {
    varhigh= GPIOPinRead(GPIO_B_BASE, GPIO_PIN_1);
    GPIOPinTypeGPIOOutput(GPIO_C_BASE, GPIO_PIN_2|GPIO_PIN_3);//PC2 is RS, PC3 is RW.LED4 is PC3

    GPIOPinTypeGPIOOutput(GPIO_B_BASE, GPIO_PIN_1);//PB1 is EN

    GPIOPinTypeGPIOOutput(GPIO_A_BASE, GPIO_PIN_6|GPIO_PIN_7);//PA6 is DB4,PA7 is DB5
    GPIOPinTypeGPIOOutput(GPIO_D_BASE, GPIO_PIN_4|GPIO_PIN_5);//PD4 is DB6,PD5 is DB7
    //D3 to D0 are tied to ground and data/commands are transferred 1, 4 bit nibble at a time.
    //while(1)
    //{
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_3, 0);//RW goes LOW
    //0 0 0 1 0 - 0 0 0 0 Set to 4 bit operation (note: 1 nibble operation)
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, 0);//D6 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, GPIO_PIN_7);//D5 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms

    //next command
    // 0 0 0 1 0 - 0 0 0 0 Function set, 8 bit
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, 0);//D6 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, GPIO_PIN_7);//D5 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms
    //0 1 0 0 0 - 0 0 0 0 2nd nibble
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 1);//D7 is 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, 0);//D6 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, 0);//D5 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms

    // next command
    // 0 0 0 0 0 - 0 0 0 0 Display ON, Cursor On, Cursor Blinking
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, 0);//D6 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, 0);//D5 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms
    //0 1 1 1 1 - 0 0 0 0 2nd nibble
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, GPIO_PIN_5);//D7 is 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, GPIO_PIN_4);//D6 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, GPIO_PIN_7);//D5 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, GPIO_PIN_6);//D4 is 1
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms

    //next command
    //0 0 0 0 0 - 0 0 0 0 Entry Mode, Increment cursor position, No display shift
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, 0);//D6 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, 0);//D5 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms
    //0 0 1 1 0 - 0 0 0 0 2nd nibble
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, 0);//RS goes 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, GPIO_PIN_4);//D6 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, GPIO_PIN_7);//D5 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms

    for (varhigh=0;varhigh<4;varhigh++)
    {
    //data 'H'
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, GPIO_PIN_2);//RS goes 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, GPIO_PIN_4);//D6 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, 0);//D5 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms
    // 1 1 0 0 0 - 0 0 0 0 2nd nibble
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, GPIO_PIN_2);//RS goes 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, GPIO_PIN_5);//D7 is 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, 0);//D6 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, 0);//D5 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms

    //data 'E'
    //1 0 1 1 0 - 0 0 0 0 e
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, GPIO_PIN_2);//RS goes 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, GPIO_PIN_4);//D6 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, GPIO_PIN_7);//D5 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, 0);//D4 is 0
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms
    //1 0 1 0 1 - 0 0 0 0 2nd nibble
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, GPIO_PIN_1);//EN goes HIGH
    GPIOPinWrite(GPIO_C_BASE, GPIO_PIN_2, GPIO_PIN_2);//RS goes 1
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_5, 0);//D7 is 0
    GPIOPinWrite(GPIO_D_BASE, GPIO_PIN_4, GPIO_PIN_4);//D6 is 1
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_7, 0);//D5 is 0
    GPIOPinWrite(GPIO_A_BASE, GPIO_PIN_6, GPIO_PIN_6);//D4 is 1
    GPIOPinWrite(GPIO_B_BASE, GPIO_PIN_1, 0);//EN goes LOW
    for(cntvar=0;cntvar<5000;cntvar++){};//wait for 31 ms
    //}
    }
    //data "l"

    }
    #endif
  • EDIT: 5v supply is REQUIRED for powering the HD44780 based LCD modules unless stated in datasheet. I tested mine with 3.3v and eventually i got the setup working with 5v supply. However, the data lines are still driven from 3.3v logic,which might not be the ideal solution but it works .