Author Topic: I2C slave address for LCD NHD-C0220BIZ-FS(RGB)-FBW-3VM  (Read 996 times)

pradeepsysargus

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
I2C slave address for LCD NHD-C0220BIZ-FS(RGB)-FBW-3VM
« on: January 27, 2017, 06:22:07 AM »
I am trying to make communication between STM32F4xx and LCD module NHD-C0220BIZ-FS(RGB)-FBW-3VM using I2C protocol.
I am using HAL libraries provided by the ST in this regard and developing in C language.

From the data sheet of the LCD, slave address is given as 0x78.
I am not getting a valid response for the data transfer function call HAL_I2C_Master_Trasmit() from master to slave.
It should return a zero value, while I am getting one value.

In the data sheet on page 6, Fig 5, the slave address is given like 0b01111100, I added 0 at the end because I am writing to the slave.
I tried this address which is 0x7C in HEX.
In one of the arduino codes, the device address is shifted right by 1 bit. 0x78 becomes 0x3C.
I tried all these combinations with no success.

Please update me about this.

Thanks,

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 341
  • Karma: 10
    • View Profile
Re: I2C slave address for LCD NHD-C0220BIZ-FS(RGB)-FBW-3VM
« Reply #1 on: February 13, 2017, 10:38:50 AM »
I have been able to write to this using 0x78, I have attached my code below:

Code: [Select]
/*************************************************
*  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?

pradeepsysargus

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: I2C slave address for LCD NHD-C0220BIZ-FS(RGB)-FBW-3VM
« Reply #2 on: February 18, 2017, 06:30:48 AM »
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,

 

NHD‐C0220BiZ‐FS(RGB)‐FBW‐3VM capacitor on pin 7&8

Started by Ticoti0xFFBoard Character LCDs

Replies: 1
Views: 2688
Last post April 09, 2014, 10:17:30 AM
by Michael_L
NHD‐C0220BiZ‐FS(RGB)‐FBW‐3VM Potting

Started by SebKisterBoard Character LCDs

Replies: 1
Views: 1729
Last post June 22, 2016, 04:51:17 PM
by Saurabh_B
Blank Display on NHD‐C0220BiZ‐FS(RGB)‐FBW‐3VM

Started by SteveCBoard Character LCDs

Replies: 3
Views: 4393
Last post May 13, 2014, 12:04:36 AM
by SteveC
NHD‐C0220BiZ‐FS(RGB)‐FBW‐3VM - Cable for LED Backlights

Started by wadehBoard Character LCDs

Replies: 2
Views: 770
Last post December 02, 2016, 06:02:27 PM
by wadeh
Sample Code Question for NHD‐C0220BiZ‐FS(RGB)‐FBW‐3VM LCD

Started by SteveCBoard Character LCDs

Replies: 2
Views: 2908
Last post July 31, 2014, 08:44:29 PM
by SteveC