0
\$\begingroup\$

I want to connect C2000 Piccolo LAUNCHXL-F28027 and LCD 1602A. And I already found this example: http://embedjournal.com/interfacing-16x2-character-lcd-with-c2000-launchpad/. I downloaded the source code and connected pins as shown in the example, after that I used exactly the same code:

#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_16
#define D7  GPIO_Number_17
GPIO_Handle myGpio;


/* Initializes LCD */
void InitializeLCD(void)
{

    GPIO_setHigh(myGpio, E);
    LCDDelay1600();
    LCDDelay1600();
    LCDDelay1600();
    LCDDelay1600();

    WriteCommandLCD(0x38);          //Command to select 8 bit interface
    LCDDelay1600();

    WriteCommandLCD(0x38);          //Command to select 8 bit interface
    LCDDelay();                     //Small delay

    WriteCommandLCD(0x38);          //Command to select 8 bit interface
    LCDDelay();


    WriteCommandLCD(0x08);          //Command to off cursor,display off
    WriteCommandLCD(0x01);          //Command to Clear LCD
    LCDDelay1600();
    WriteCommandLCD(0x06);          //Command for setting entry mode

    WriteCommandLCD(0x0f);          //Command to on cursor,blink cursor
    WriteCommandLCD(0x02);          //Command return the cursor to home
    LCDDelay1600();
    DisplayLCD(1, "hello");

}


/* Writes a command byte to LCD */
void WriteCommandLCD(unsigned char CommandByte)
{
    GPIO_setLow(myGpio, RS);        //Clear RS pin to write command
    SendByte(CommandByte);
    LCDDelay();                     //Small delay
}


/* Send a byte of data to LCD */
void SendByte(unsigned char Value)
{
    unsigned char temp;


    if((Value & 0x01) == 0x01)
        GPIO_setHigh(myGpio, D0);
    else
        GPIO_setLow(myGpio, D0);


    if((Value & 0x02) == 0x02)
        GPIO_setHigh(myGpio, D1);
    else
        GPIO_setLow(myGpio, D1);


    if((Value & 0x04) == 0x04)
        GPIO_setHigh(myGpio, D2);
    else
        GPIO_setLow(myGpio, D2);

    if((Value & 0x08) == 0x08)
        GPIO_setHigh(myGpio, D3);
    else
        GPIO_setLow(myGpio, D3);

    if((Value & 0x10) == 0x10)
        GPIO_setHigh(myGpio, D4);
    else
        GPIO_setLow(myGpio, D4);


    if((Value & 0x20) == 0x20)
        GPIO_setHigh(myGpio, D5);
    else
        GPIO_setLow(myGpio, D5);


    if((Value & 0x40) == 0x40)
        GPIO_setHigh(myGpio, D6);
    else
        GPIO_setLow(myGpio, D6);


    if((Value & 0x80) == 0x80)
        GPIO_setHigh(myGpio, D7);
    else
        GPIO_setLow(myGpio, D7);


    GPIO_setHigh(myGpio, E);            //Set E pin to select LCD
    for(temp=0;temp<5; temp++);
    GPIO_setLow(myGpio, E);             //Clear E pin to deselect LCD
    LCDDelay();                         //Small delay

}

/* Writes a Data byte to LCD */
void WriteDataLCD(unsigned char DataByte)
{
    GPIO_setHigh(myGpio, RS);           //Set RS pin to 1 to write Data
    SendByte(DataByte);
    LCDDelay();                         //Small delay
}


/* Small delay */
void LCDDelay(void)
{
    DELAY_US(500);
}

/* Big delay */
void LCDDelay1600(void)
{
    DELAY_US(16000);
}


/* Makes cursor visible */
void CursorON(void)
{
    WriteCommandLCD(0x0f);          //Command to switch on cursor
}



/* Makes cursor invisible */
void CursorOFF(void)
{
    WriteCommandLCD(0x0c);          //Command to switch off cursor
}


/* Displays a message on LCD */
void DisplayLCD(char LineNumber,char *Message)
{
    int a;
    if(LineNumber ==1)
    {   //First Line
        WriteCommandLCD(0x80);      //Select the first line
    }
    else
    {   //Second line
        WriteCommandLCD(0xc0);      //Select the second line
    }
    for(a=0;a<16;a++)
    {
        WriteDataLCD(*Message);     //Display a character
        Message++;                  //Increment pointer
    }
    return;
}

void main(){
    InitializeLCD();
}

But after execution of this code absolutely nothing has changed on the LCD - I see only a several rectangles in the first line(just like the after power up). I think that is because lm016l used in the example, but I use 1602A. Could it be? If yes then which functions I need to change and how exactly I need to change them? Please give me comprehensive information if you can, because I am a novice at this and it's very hard to understand what I exactly need.

Thanks!

UPD:

I found microcontroller for the 1602A LCD, it's KS0066U. Am I right? So, if yes, then I also found KS0066U datasheet with the "INITIALIZING BY INSTRUCTION. 1) 8-bit interface mode...", please check it (page 26).

Using this instruction I created this code:

#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_16
#define D7  GPIO_Number_17

    GPIO_Handle myGpio1;

    //...

     void function_set(){
        GPIO_setLow(myGpio1, RS);
        GPIO_setLow(myGpio1, D7);
        GPIO_setLow(myGpio1, D6);
        GPIO_setHigh(myGpio1, D5);
        GPIO_setHigh(myGpio1, D4);
        GPIO_setHigh(myGpio1, D3);
        GPIO_setHigh(myGpio1, D2);
    }

    void display_control(){
        GPIO_setLow(myGpio1, RS);
        GPIO_setLow(myGpio1, D7);
        GPIO_setLow(myGpio1, D6);
        GPIO_setLow(myGpio1, D5);
        GPIO_setLow(myGpio1, D4);
        GPIO_setHigh(myGpio1, D3);
        GPIO_setHigh(myGpio1, D2);
        GPIO_setHigh(myGpio1, D1);
        GPIO_setHigh(myGpio1, D0);
    }

    void display_clear(){
        GPIO_setLow(myGpio1, RS);
        GPIO_setLow(myGpio1, D7);
        GPIO_setLow(myGpio1, D6);
        GPIO_setLow(myGpio1, D5);
        GPIO_setLow(myGpio1, D4);
        GPIO_setLow(myGpio1, D3);
        GPIO_setLow(myGpio1, D2);
        GPIO_setLow(myGpio1, D1);
        GPIO_setHigh(myGpio1, D0);
    }

    void entry_mode(){
        GPIO_setLow(myGpio1, RS);
        GPIO_setLow(myGpio1, D7);
        GPIO_setLow(myGpio1, D6);
        GPIO_setLow(myGpio1, D5);
        GPIO_setLow(myGpio1, D4);
        GPIO_setLow(myGpio1, D3);
        GPIO_setHigh(myGpio1, D2);
        GPIO_setHigh(myGpio1, D1);
        GPIO_setHigh(myGpio1, D0);
    }
    void main(void) {
        myGpio1 = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));//default initialization

            DELAY_US(31000);
            function_set();
            DELAY_US(1500);
            display_control();
            DELAY_US(1500);
            display_clear();
            DELAY_US(20300);
    }

But it also does not change anything.

What am I missing(please note that I'm really newbie)?

UPD2: New full code, but it still gives nothing:

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
#include "clk.h"
#include "flash.h"
#include "gpio.h"
#include "pie.h"
#include "pll.h"
#include "wdog.h"
#include "LCD.h"
#include "Keypad.h"

#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_16
#define D7  GPIO_Number_17

GPIO_Handle myGpio1;

void enable(void)        //This enable E pin,whenever you send command/data to the pin
{
     GPIO_setLow(myGpio1,E);
     DELAY_US(1000);
     GPIO_setHigh(myGpio1,E);
}
void function_set(void)  //function set as you declared
{
      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setHigh(myGpio1, D5);
      GPIO_setHigh(myGpio1, D4);
      GPIO_setHigh(myGpio1, D3);
      GPIO_setHigh(myGpio1, D2);
}
void display_control(void)
{
      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setLow(myGpio1, D5);
      GPIO_setLow(myGpio1, D4);
      GPIO_setHigh(myGpio1, D3);
      GPIO_setHigh(myGpio1, D2);
      GPIO_setHigh(myGpio1, D1);
      GPIO_setHigh(myGpio1, D0);
}
void entry_mode(void)     //entry mode to make increment or decrement DDRAM
{
      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setLow(myGpio1, D5);
      GPIO_setLow(myGpio1, D4);
      GPIO_setLow(myGpio1, D3);
      GPIO_setHigh(myGpio1, D2);
      GPIO_setHigh(myGpio1, D1);
      GPIO_setHigh(myGpio1, D0);
}
void clear_display(void)  //clear the display
{
       GPIO_setLow(myGpio1, RS);
       GPIO_setLow(myGpio1, D7);
       GPIO_setLow(myGpio1, D6);
       GPIO_setLow(myGpio1, D5);
       GPIO_setLow(myGpio1, D4);
       GPIO_setLow(myGpio1, D3);
       GPIO_setLow(myGpio1, D2);
       GPIO_setLow(myGpio1, D1);
       GPIO_setHigh(myGpio1, D0);
}
void initialization(void){
    GPIO_setPullUp(myGpio1, GPIO_Number_0, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_0);
    GPIO_setMode(myGpio1, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_0, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_1, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_1);
    GPIO_setMode(myGpio1, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_1, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_2, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_2);
    GPIO_setMode(myGpio1, GPIO_Number_2, GPIO_2_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_2, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_3, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_3);
    GPIO_setMode(myGpio1, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_3, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_4, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_4);
    GPIO_setMode(myGpio1, GPIO_Number_4, GPIO_4_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_4, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_5, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_5);
    GPIO_setMode(myGpio1, GPIO_Number_5, GPIO_5_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_5, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_16, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_16);
    GPIO_setMode(myGpio1, GPIO_Number_16, GPIO_16_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_16, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_17, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_17);
    GPIO_setMode(myGpio1, GPIO_Number_17, GPIO_17_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_17, GPIO_Direction_Output);



    GPIO_setPullUp(myGpio1, GPIO_Number_12, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_12);
    GPIO_setMode(myGpio1, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_12, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_19, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_19);
    GPIO_setMode(myGpio1, GPIO_Number_19, GPIO_19_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_19, GPIO_Direction_Output);
}
void main()
{
     InitSysCtrl();

     myGpio1 = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
     initialization();

    GPIO_setLow(myGpio1,E);  //declare the enable pin as HIGH first

      function_set();
      enable();      //set this to enable the LED with given data to the pins
      DELAY_US(50);  //need some delay of 39us,roughly 50us
      display_control(); //to customize the display you need
      enable();
      DELAY_US(50);  //again need 39us ,roughly 50us
      entry_mode();
      enable();    //makes to enable the LED with given data
      DELAY_US(50);
      GPIO_setHigh(myGpio1,RS);  //This displays letter A
      GPIO_setHigh(myGpio1,D7);
      GPIO_setLow(myGpio1,D6);
      GPIO_setLow(myGpio1,D5);
      GPIO_setLow(myGpio1,D4);
      GPIO_setLow(myGpio1,D3);
      GPIO_setLow(myGpio1,D2);
      GPIO_setLow(myGpio1,D1);
      GPIO_setHigh(myGpio1,D0);
      enable();
      DELAY_US(5000000);// letter A stays for 5 seconds in the display
      clear_display(); //clears the display
      DELAY_US(3000);  //need to wait 1.39ms roughly 3ms
}

UPD3:

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
#include "clk.h"
#include "flash.h"
#include "gpio.h"
#include "pie.h"
#include "pll.h"
#include "wdog.h"
#include "LCD.h"
#include "Keypad.h"

#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_16
#define D7  GPIO_Number_17

GPIO_Handle myGpio1;
interrupt void xint1_isr(void);


void enabl(void)        //This enable E pin,whenever you send command/data to the pin
{
     GPIO_setLow(myGpio1,E);
     DELAY_US(10000);
     GPIO_setHigh(myGpio1,E);
}
void function_set(void)  //function set as you declared
{
      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setHigh(myGpio1, D5);
      GPIO_setLow(myGpio1, D4);

        DELAY_US(20000);
        enabl();      //set this to enable the LED with given data to the pins
        DELAY_US(20000);  //need some delay of 39us,roughly 50us

      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setHigh(myGpio1, D5);
      GPIO_setLow(myGpio1, D4);

        DELAY_US(20000);
        enabl();      //set this to enable the LED with given data to the pins
        DELAY_US(20000);  //need some delay of 39us,roughly 50us

      GPIO_setLow(myGpio1, RS);
      GPIO_setHigh(myGpio1, D7);
      GPIO_setHigh(myGpio1, D6);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);

}
void display_control(void)
{
      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setLow(myGpio1, D5);
      GPIO_setLow(myGpio1, D4);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);

      GPIO_setLow(myGpio1, RS);
      GPIO_setHigh(myGpio1, D7);
      GPIO_setHigh(myGpio1, D6);
      GPIO_setHigh(myGpio1, D5);
      GPIO_setHigh(myGpio1, D4);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);

}

void display_clear(void)  //clear the display
{
       GPIO_setLow(myGpio1, RS);
       GPIO_setLow(myGpio1, D7);
       GPIO_setLow(myGpio1, D6);
       GPIO_setLow(myGpio1, D5);
       GPIO_setLow(myGpio1, D4);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);

       GPIO_setLow(myGpio1, RS);
       GPIO_setLow(myGpio1, D7);
       GPIO_setLow(myGpio1, D6);
       GPIO_setLow(myGpio1, D5);
       GPIO_setHigh(myGpio1, D4);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);
}

void entry_mode(void)     //entry mode to make increment or decrement DDRAM
{
      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setLow(myGpio1, D6);
      GPIO_setLow(myGpio1, D5);
      GPIO_setLow(myGpio1, D4);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);

      GPIO_setLow(myGpio1, RS);
      GPIO_setLow(myGpio1, D7);
      GPIO_setHigh(myGpio1, D6);
      GPIO_setHigh(myGpio1, D5);
      GPIO_setHigh(myGpio1, D4);

      DELAY_US(20000);
      enabl();      //set this to enable the LED with given data to the pins
      DELAY_US(20000);

}

void initialization(void){
    GPIO_setPullUp(myGpio1, GPIO_Number_0, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_0);
    GPIO_setMode(myGpio1, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_0, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_1, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_1);
    GPIO_setMode(myGpio1, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_1, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_2, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_2);
    GPIO_setMode(myGpio1, GPIO_Number_2, GPIO_2_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_2, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_3, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_3);
    GPIO_setMode(myGpio1, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_3, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_4, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_4);
    GPIO_setMode(myGpio1, GPIO_Number_4, GPIO_4_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_4, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_5, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_5);
    GPIO_setMode(myGpio1, GPIO_Number_5, GPIO_5_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_5, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_16, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_16);
    GPIO_setMode(myGpio1, GPIO_Number_16, GPIO_16_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_16, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_17, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_17);
    GPIO_setMode(myGpio1, GPIO_Number_17, GPIO_17_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_17, GPIO_Direction_Output);



    GPIO_setPullUp(myGpio1, GPIO_Number_12, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_12);
    GPIO_setMode(myGpio1, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_12, GPIO_Direction_Output);

    GPIO_setPullUp(myGpio1, GPIO_Number_19, GPIO_PullUp_Enable);
    GPIO_setLow(myGpio1, GPIO_Number_19);
    GPIO_setMode(myGpio1, GPIO_Number_19, GPIO_19_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio1, GPIO_Number_19, GPIO_Direction_Output);
}


void main()
{
     InitSysCtrl();

     myGpio1 = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
     initialization();

      DELAY_US(20000);

      GPIO_setHigh(myGpio1,E);  //declare the enable pin as HIGH first
      DELAY_US(20000);

      function_set();

      display_control(); //to customize the display you need

      display_clear();

      entry_mode();

      GPIO_setHigh(myGpio1,RS);  //This displays letter A
      GPIO_setHigh(myGpio1,D7);
      GPIO_setLow(myGpio1,D6);
      GPIO_setLow(myGpio1,D5);
      GPIO_setLow(myGpio1,D4);
      GPIO_setLow(myGpio1,D3);
      GPIO_setLow(myGpio1,D2);
      GPIO_setLow(myGpio1,D1);
      GPIO_setHigh(myGpio1,D0);
      enabl();
      DELAY_US(5000000);// letter A stays for 5 seconds in the display

      display_clear(); //clears the display
      DELAY_US(20000);  //need to wait 1.39ms roughly 3ms
      enabl();

}
\$\endgroup\$
  • \$\begingroup\$ I dont have idea about your C program but I can help you to understand the working of 16x2 LCD.One think I want to know from your program.Is that the 'GPIO_setHigh(myGpio, E)' and 'GPIO_setLow(myGpio, E)' are inbuilt functions?How it function.Please also specify the other inbuilt function you used in this C program and it's functionality. \$\endgroup\$ – Aadarsh Jan 25 '16 at 15:14
  • \$\begingroup\$ @Aadarsh hello and thanks for the reply! GPIO_setHigh(gpioHandle, gpioNumber) - sets the specified GPIO pin signal high. GPIO_setLow(gpioHandle, gpioNumber) - sets the specified GPIO pin signal low. gpioHandle - the GPIO object handle, gpioNumber - the GPIO number. DELAY_US(A) - delay in microseconds(I guess in microseconds). And I already tried sample which more understandable, but got nothing too. Please check the updated question! \$\endgroup\$ – don-prog Jan 26 '16 at 5:12
  • \$\begingroup\$ @One think I want to know from your program,Where did you use the read/write pin(I mean which GPIO you selected.)I cant notice the R/W is set.Even though you dont use it,just declare it as zero.May this this can possibly cause a problem.could you please try this think and tell the effects while declaring R/W as zero.or if you don't going to use it,tie it to ground.tell whether it's useful.We need the R/W pin to track only the busy flag.Mostly we don't use it. \$\endgroup\$ – Aadarsh Jan 26 '16 at 19:00
  • \$\begingroup\$ Try changing for(temp=0;temp<5; temp++); to lcddelay();. I bet that for loop is getting optimized out. Also the KS 006 and the other lcd type are both HD lcd clones, same code should work without a problem. \$\endgroup\$ – Passerby Jan 27 '16 at 19:53
  • \$\begingroup\$ @Passerby thanks! I tried to use lcddelay() instead of for(temp=0;temp<5; temp++), but it also gives nothing. Anyway I don't use first variant of the code anymore, now I trying to launch program which described in the UPD2, any help with it would be useful! \$\endgroup\$ – don-prog Jan 28 '16 at 0:42
1
\$\begingroup\$

Okay,I found the problem where you got struck.It's the Enable pin.You made mistake in enable pin.The Enable pin should be declared HIGH first.Whenever passing commands,you just need to make the Enable pin LOW for just a small time(typically 1 ms) and then you have to make it HIGH.Thus the Enable pin should only go LOW whenever you pass the bits in the pins of LCD.All the time,it should remain HIGH.So I remake your program as

    #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_16
    #define D7  GPIO_Number_17
    
    GPIO_Handle myGpio1;
    GPIO_setLow(myGpio1,E);  //declare the enable pin as HIGH first
    
    void enable(void)        //This enable E pin,whenever you send command/data to the pin   
    {
         GPIO_setLow(myGpio1,E);
         dELAY_US(1000);
         GPIO_setHigh(myGpio1,E);
    }
    void function_set(void)  //function set as you declared
    {
          GPIO_setLow(myGpio1, RS);
          GPIO_setLow(myGpio1, D7);
          GPIO_setLow(myGpio1, D6);
          GPIO_setHigh(myGpio1, D5);
          GPIO_setHigh(myGpio1, D4);
          GPIO_setHigh(myGpio1, D3);
          GPIO_setHigh(myGpio1, D2);
    }
    void display_control(void)  
    {
          GPIO_setLow(myGpio1, RS);
          GPIO_setLow(myGpio1, D7);
          GPIO_setLow(myGpio1, D6);
          GPIO_setLow(myGpio1, D5);
          GPIO_setLow(myGpio1, D4);
          GPIO_setHigh(myGpio1, D3);
          GPIO_setHigh(myGpio1, D2);
          GPIO_setHigh(myGpio1, D1);
          GPIO_setHigh(myGpio1, D0);
    }
    void entry_mode(void)     //entry mode to make increment or decrement DDRAM
    {
          GPIO_setLow(myGpio1, RS);
          GPIO_setLow(myGpio1, D7);
          GPIO_setLow(myGpio1, D6);
          GPIO_setLow(myGpio1, D5);
          GPIO_setLow(myGpio1, D4);
          GPIO_setLow(myGpio1, D3);
          GPIO_setHigh(myGpio1, D2);
          GPIO_setHigh(myGpio1, D1);
          GPIO_setHigh(myGpio1, D0);
    }
    void clear_display(void)  //clear the display
    {
           GPIO_setLow(myGpio1, RS);
           GPIO_setLow(myGpio1, D7);
           GPIO_setLow(myGpio1, D6);
           GPIO_setLow(myGpio1, D5);
           GPIO_setLow(myGpio1, D4);
           GPIO_setLow(myGpio1, D3);
           GPIO_setLow(myGpio1, D2);
           GPIO_setLow(myGpio1, D1);
           GPIO_setHigh(myGpio1, D0);
    }
    void main()
    {
          function_set();
          enable();      //set this to enable the LED with given data to the pins
          DELAY_US(50);  //need some delay of 39us,roughly 50us 
          display_control(); //to customize the display you need  
          enable();       
          DELAY_US(50);  //again need 39us ,roughly 50us
          entry_mode();
          enable();    //makes to enable the LED with given data
          DELAY_US(50); 
          GPIO_setHigh(myGpio1,RS);  //This displays letter A
          GPIO_setHigh(myGpio1,D7);
          GPIO_setLow(myGpio1,D6);
          GPIO_setLow(myGpio1,D5);
          GPIO_setLow(myGpio1,D4);
          GPIO_setLow(myGpio1,D3);
          GPIO_setLow(myGpio1,D2);
          GPIO_setLow(myGpio1,D1);
          GPIO_setHIGH(myGpio1,D0);
          enable();
          DELAY_US(5000000);// letter A stays for 5 seconds in the display
          clear_display(); //clears the display
          DELAY_US(3000);  //need to wait 1.39ms roughly 3ms  
    }
    
      The place you made mistake is that,you didn't make the enable pin to go low for instant and then make it HIGH.So this above program will display A for 5 sec and clears the LCD screen.Again the loop starts from main() and goes on.The same I have done in AVR processor.Take a glance on it.If you understand,it's good.
    int rs =12;
    int rw =11;
    int e =10;
    void enabl()   //enable LCD for instant
    {
        digitalWrite(e,LOW);
        delay(1);
        digitalWrite(e,HIGH);
    }
    void setup()
    {
       DDRD=0xFF;   //make the portD as output
       digitalWrite(e,HIGH); //initially E with HIGH
       pinMode(rs,OUTPUT);  //declaring the pins as output
       pinMode(rw,OUTPUT);
       pinMode(e,OUTPUT);
    }
    void loop()
    {
       digitalWrite(rw,LOW);  //function set
       digitalWrite(rs,LOW);
       PORTD=B00111000;
       enabl();
       delayMicroseconds(50);  //display control
       digitalWrite(rw,LOW);
       digitalWrite(rs,LOW);
       PORTD=B00001111;
       enabl();
       delay(50);
       digitalWrite(rs,HIGH);  //Letter A
       PORTD=0x41;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //letter A
       PORTD=0x41;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //letter D
       PORTD=0x44;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //letter A
       PORTD=0x41;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //letter R
       PORTD=0x52;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //letter S
       PORTD=0x53;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //letter H
       PORTD=0x48;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //symbol @
       PORTD=0x40;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //space bar  
       PORTD=0x20;
       enabl();
       delay(1);
       digitalWrite(rs,HIGH);  //symbol delta(may vary with LCD to LCD)
       PORTD=B01111111;
       enabl();
       delay(4000);            //wait for 4 seconds to stay on display
       digitalWrite(rs,LOW);  //clear display()
       PORTD=0x01;
       enabl();
       delay(3000);           
    }
    

    The output of the display is like this

    LCD
    May be I can make this program simple,but when I was learn for first time,I done my program like this to understand in depth of what will happens if I change a small value and moreover I like to program in assembly rather than C.

\$\endgroup\$
  • \$\begingroup\$ @I also what to know other thing.In AVR we initialize a pin either output of input( in arduino pinMode(pin,i/o); ).I cant see any pin declaration as input/output in your program. Possibly it'll also cause problem. \$\endgroup\$ – Aadarsh Jan 27 '16 at 15:13
  • \$\begingroup\$ Many thanks for your help, I really need it! I tried to use your code but still got nothing, also I attached this full new code in the my updated question(UPD2), you can check it. \$\endgroup\$ – don-prog Jan 28 '16 at 0:47
  • \$\begingroup\$ Okay.Still I don't know where the problem is.One think I want you to perform whether the program is running correct or not.Instead of the pin D0 to D7 which is connected to LCD,connect 8 LED and just run only the 'function set()'and 'enable()' with repeated loop in the 'void main()'.You should see the LED's will glow accordingly you gave value in the D0 to the D7 pin.Also add 2 LED for RS declared pin and Enable declared pin.The Enabled declared pin will flash very fast or even looks it's continuously lighting. \$\endgroup\$ – Aadarsh Jan 28 '16 at 14:28
  • \$\begingroup\$ And also the change the name of 'enable()' to 'enabl()' because 'enable()' may possibly any builtin function.I also referred the datasheet,try to use Digital GPIO pins for easy initialization and declaration rather than choosing a random pin for output.I think your chip has 22 Digital I/O pins.Make use of those. \$\endgroup\$ – Aadarsh Jan 28 '16 at 14:32
  • \$\begingroup\$ If still not working,tell me that you initialized the GPIO pins correctly as output.If you can understand the arduino program which I posted in answer,that's very easy for you to translate from the Arduino to the CCS compiler C language.Or comment me How to set a pin HIGH or LOW.I mean which function you use and it's syntax.It's more than enough.Also tell me the correct syntax delay function.I just help to display a single word like in the picture of my answer :) \$\endgroup\$ – Aadarsh Jan 28 '16 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.