Author Topic: Problem with NHD-C0220BiZ LCD  (Read 4254 times)

redcrow

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Problem with NHD-C0220BiZ LCD
« on: March 26, 2014, 09:09:53 AM »
Hi All,

I've a problem with the initialization of the  NHD-C0220BiZ LCD. The code that i use is the same used with NHD-C00216CIZ, this one worked but changing the I2C address and the LCD with the first one not work. The LCD seems to be initialized, i see the black squares in background but when I stop the I2C connection the LCD seems to restart itself.
Where is the issu, please help.

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Problem with NHD-C0220BiZ LCD
« Reply #1 on: March 26, 2014, 10:05:38 AM »
The same code works between the two displays, if the slave address is changed.  Do you have the same setup as you did with the C0216CiZ? I have provided some Arduino code for this display below, (you will see that it says C0216CiZ, but you will see in the comments by the slave address how it should be changed):

Code: [Select]
#include <Wire.h>

int RES = 22;
int ASDA = 20;
int ASCL = 21;

int test = 55;

unsigned char text1[]={"Newhaven Display"};
unsigned char text2[]={"    I2C TEST    "};
unsigned char text3[]={" March 26 2014  "};
unsigned char text4[]={" Michael LaVine "};

const char slave2w = 0x3C;  //3E for CiZ (0x7C shifted over 1 bit)  //3C for BiZ (0x78 shifted over 1 bit)
const char comsend = 0x00;
const char datasend = 0x40;
const char line2 = 0xC0;

void show(unsigned char *text)
{
  int n, d;
  d=0x00;
  Wire.beginTransmission(slave2w);
  Wire.write(datasend);
  for(n=0;n<16;n++)
  {
    Wire.write(*text);
    ++text;
  }
  Wire.endTransmission();
}

void nextline(void)
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(line2);
  Wire.endTransmission();
}

void CGRAM(void)
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x38);
  Wire.write(0x40);
  Wire.endTransmission();
  delay(10);
  Wire.beginTransmission(slave2w);
  Wire.write(datasend);
  Wire.write(0x00);
  Wire.write(0x1E);
  Wire.write(0x18);
  Wire.write(0x14);
  Wire.write(0x12);
  Wire.write(0x01);
  Wire.write(0x00);
  Wire.write(0x00);
  Wire.endTransmission();
}

void CiZ_init()
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x38);
  delay(10);
  Wire.write(0x39);
  delay(10);
  Wire.write(0x14);
  Wire.write(0x70);
  Wire.write(0x5E);
  Wire.write(0x6D);
  Wire.write(0x0C);
  Wire.write(0x01);
  Wire.write(0x06);
  Wire.endTransmission();
 
  CGRAM();
 
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x39);
  Wire.write(0x01);
  test = Wire.endTransmission();
  Wire.endTransmission();
  if(test!=0)
  {
    while(1)
    {
      delay(100);
    }
  }
  delay(10);
}

void setup()
{
  pinMode(RES, OUTPUT);
  pinMode(ASCL, OUTPUT);
  pinMode(ASDA, OUTPUT);
  digitalWrite(RES, HIGH);
  delay(10);
  digitalWrite(ASCL, LOW);
  digitalWrite(ASDA, LOW);
  delay(10);
 
  delay(10);
  //CiZ_init();
  //delay(5);
}

void loop()
{
 
  Wire.begin();
  //TWBR = 12;
  //TWSR |= _BV(TWPS0);
  while(1)
  {
  CiZ_init();
  show(text1);
  nextline();
  show(text2);
  delay(1000);
 
  CiZ_init();
  show(text3);
  nextline();
  show(text4);
  delay(1000);
  }
}

redcrow

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Problem with NHD-C0220BiZ LCD
« Reply #2 on: March 28, 2014, 09:15:54 AM »
Thank you!, I've solved the problem.

Now I've another question: is it possible to add custom characters?

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Problem with NHD-C0220BiZ LCD
« Reply #3 on: March 28, 2014, 03:50:17 PM »
Yes you can add custom characters to the CGRAM of the ST7036.  In the ST7036 datasheet, see pages 22-23 for details on the CGRAM, and pages 27 & 33 for details on how to use this command.  I've provided a small example below of me making a smiley face to address location 0x00 of the CGRAM:

Code: [Select]
void i2cwritecom(unsigned char c)
{
  Wire.beginTransmission(slave2w);  //slave2w = 0x3C (0x78 shifted over 1 bit)
  Wire.write(comsend);  //comsend = 0x00
  Wire.write(c);
  Wire.endTransmission();
}

void i2cwritedat(unsigned char d)
{
  Wire.beginTransmission(slave2w);
  Wire.write(datasend);  //datasend = 0x40
  Wire.write(d);
  Wire.endTransmission();
}

void CiZ_init()
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x39);
  delay(1);
  Wire.write(0x14);
  Wire.write(0x70);
  Wire.write(0x5E);
  Wire.write(0x6D);
  Wire.write(0x0C);
  Wire.write(0x01);
  Wire.write(0x06);
  Wire.endTransmission();
}

void setup()
{
  pinMode(RES, OUTPUT);
  pinMode(ASCL, OUTPUT);
  pinMode(ASDA, OUTPUT);
  digitalWrite(RES, HIGH);
  delay(10);
  digitalWrite(ASCL, LOW);
  digitalWrite(ASDA, LOW);
  delay(10);
  Wire.begin();
  delay(10);
  CiZ_init();
  delay(5);
  i2cwritecom(0x38);  //function set to set IS[2:1] to 0,0
  i2cwritecom(0x40);  //set CGRAM address (in this case, to 0x00)
  i2cwritedat(0x1B);   //write custom pattern to CGRAM
  i2cwritedat(0x00);   //
  i2cwritedat(0x0A);  //
  i2cwritedat(0x0A);  //
  i2cwritedat(0x00);  //
  i2cwritedat(0x04);  //
  i2cwritedat(0x11);  //
  i2cwritedat(0x0E);  //
  i2cwritecom(0x01);  //clear display and set DDRAM address to 0x00 (line 1, character 1)
  delay(2);  //2 ms delay
  i2cwritedat(0x00);  //write custom pattern stored in CGRAM address location 0x00 to DDRAM
}

redcrow

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Problem with NHD-C0220BiZ LCD
« Reply #4 on: March 31, 2014, 02:18:56 AM »
Thank you!

 

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

Started by Ticoti0xFFBoard Character LCDs

Replies: 1
Views: 2782
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: 1808
Last post June 22, 2016, 04:51:17 PM
by Saurabh_B
NHD‐3.5‐320240MF‐ATXL#‐CTP‐1 Problem with standby mode

Started by guenterBoard TFTs

Replies: 0
Views: 1929
Last post June 16, 2016, 12:14:36 PM
by guenter
NHD‐2.4‐240320SF‐CTXL#‐FTN1 touch-screen problem

Started by hbcelebiBoard TFTs

Replies: 5
Views: 4161
Last post December 10, 2014, 11:19:05 AM
by Michael_L
Working on NHD‐2.4‐240320SF‐CTXL#‐FTN1, have problem in initialization

Started by sli25Board TFTs

Replies: 6
Views: 3773
Last post June 04, 2015, 09:52:25 PM
by sli25