I2C slave address for LCD NHD-C0220BIZ-FS(RGB)-FBW-3VM

Comments

2 comments

  • Saurabh_B

    I have been able to write to this using 0x78, I have attached my code below:

    /*************************************************
    *  Code written to drive NHD-C0220BiZ-FS... Using Arduino Mega.
    *  Arduino Mega (Voltage Regulator switched with 3.3 V)
    **************************************************/

    #define SC_L 33
    #define SD_A 35

    /*****************************************************/
    char const text1[]=("COG Test 2x20 Module");
    char const text2[]=("TESTING TESTING TEST");
    char const text3[]=("Testing Contrast Set");
    char const text4[]=("Testing Folower Cont");
    /*****************************************************/
    /*****************************************************/
    const char Slave = 0x78;
    const char Comsend = 0x00;
    const char Datasend = 0x40;
    const char Line2 = 0xC0;
    /*****************************************************/

    /****************************************************
    * Output command or data via I2C *
    *****************************************************/
    void I2C_out(unsigned char j){ //I2C Output
        int n;
        unsigned char d;
        d=j;
        for(n=0;n<8;n++){
          if((d&0x80)==0x80)
            digitalWrite(SD_A,HIGH);
          else
            digitalWrite(SD_A,LOW);
         d=(d<<1);
         digitalWrite(SC_L,LOW);
         digitalWrite(SC_L,HIGH);
         digitalWrite(SC_L,LOW);
       }
       digitalWrite(SC_L,HIGH);
       while(SD_A==1){
          digitalWrite(SC_L,LOW);
          digitalWrite(SC_L,HIGH);
       }
       digitalWrite(SC_L,LOW);
    }
    /*****************************************************/
    /****************************************************
    * I2C Start *
    *****************************************************/
    void I2C_Start(void){
       digitalWrite(SC_L,HIGH);
       digitalWrite(SD_A,HIGH);
       digitalWrite(SD_A,LOW);
       digitalWrite(SC_L,LOW);
    }
    /*****************************************************/
    /****************************************************
    * I2C Stop *
    *****************************************************/
    void I2C_Stop(void){
       digitalWrite(SD_A,LOW);
       digitalWrite(SC_L,LOW);
       digitalWrite(SC_L,HIGH);
       digitalWrite(SD_A,HIGH);
    }
    /*****************************************************/
    /****************************************************
    * Initialization For ST7036i *
    *****************************************************/
    void init_LCD(){
        I2C_Start();
        I2C_out(Slave);//Slave=0x78
        I2C_out(Comsend);//Comsend = 0x00
        I2C_out(0x38);
        delay(10);
        I2C_out(0x39);
        delay(10);
        I2C_out(0x14);
        I2C_out(0x78);
        I2C_out(0x5E);
        I2C_out(0x6D);
        //I2C_out(0x38);
        I2C_out(0x0F);
        I2C_out(0x01);
        I2C_out(0x06);
        delay(10);
        I2C_Stop();
    }
    /*****************************************************
     *         CONTRAST CONTROL                          *
     /***************************************************/
     void contrast(){

      /************************************************
       *    TESTING CONTRAST SET LOWER / Higher Bits   *
       ************************************************/
       int n;
       I2C_Start();
       I2C_out(Slave); //Slave=0x78
       I2C_out(Datasend);//Datasend=0x40
       for(n=0;n<20;n++){
          I2C_out(text1[n]);
          //++text;
       }
       I2C_Stop();
       nextline();
       I2C_Start();
       I2C_out(Slave); //Slave=0x78
       I2C_out(Datasend);//Datasend=0x40
       for(n=0;n<20;n++){
          I2C_out(text3[n]);
          //++text;
       }
       I2C_Stop();
       delay(200);

        for (int i = 112; i < 128; i++){
            I2C_Start();
            I2C_out(Slave);
            I2C_out(Comsend);
            I2C_out(0x39);
            delay(10);
            I2C_out(i);
            I2C_Stop();
            delay (300);
        }
        for (int i = 94; i < 96; i++){
            I2C_Start();
            I2C_out(Slave);
            I2C_out(Comsend);
            I2C_out(0x39);
            delay(10);
            I2C_out(i);
            I2C_Stop();
            delay (300);
        }
        init_LCD(); // Return to normal
       /************************************************
       *    TESTING Folower mode
       ************************************************/
       I2C_Start();
       I2C_out(Slave); //Slave=0x78
       I2C_out(Datasend);//Datasend=0x40
       for(n=0;n<20;n++){
          I2C_out(text1[n]);
          //++text;
       }
       I2C_Stop();
       nextline();
       I2C_Start();
       I2C_out(Slave); //Slave=0x78
       I2C_out(Datasend);//Datasend=0x40
       for(n=0;n<20;n++){
          I2C_out(text4[n]);
          //++text;
       }
       I2C_Stop();
       delay(200);
         for (int i = 104; i < 112; i++){
            I2C_Start();
            I2C_out(Slave);
            I2C_out(Comsend);
            I2C_out(0x39);
            delay(10);
            I2C_out(i);
            I2C_Stop();
            delay (600);
        }
        init_LCD();
       
       
     
     }
    /****************************************************
    *            Send string of ASCII data to LCD       *
    *****************************************************/
    void Show(){
       int n;
       I2C_Start();
       I2C_out(Slave); //Slave=0x78
       I2C_out(Datasend);//Datasend=0x40
       for(n=0;n<20;n++){
          I2C_out(text1[n]);
          //++text;
       }
       I2C_Stop();
       nextline();
       I2C_Start();
       I2C_out(Slave); //Slave=0x78
       I2C_out(Datasend);//Datasend=0x40
       for(n=0;n<20;n++){
          I2C_out(text2[n]);
          //++text;
       }
       I2C_Stop();
    }
    /*****************************************************/
    void nextline(){
        I2C_Start();
        I2C_out(Slave);
        I2C_out(Comsend);
        I2C_out(Line2);
        I2C_Stop();
    }
    void setup() {
      // put your setup code here, to run once:
      //pinMode(pin, mode)
      pinMode(33, OUTPUT);
      pinMode(35, OUTPUT);
      DDRD = 0xFF;
      init_LCD();
      Show();
      delay(300);
     
     
    }

    void loop() {
      int i;
      init_LCD();
      delay(2);
      // CONTRAST TESTING
      contrast();
     delay(1000);
    }

    How does your code send the bits?

    0
  • pradeepsysargus

    The problem is now solved, the slave address is just 0x78 only.

    The problem is that, I need to send each command to the LCD module separately using the function: HAL_I2C_Master_Transmit().

    I posted the solution at the following url as a reply to the main post: Please read the complete post to get an understanding of it if u wish.
    https://community.st.com/thread/28843

    Thanks,

    0

Please sign in to leave a comment.