NHD-C0220BiZ-FSW-FBW-3V3M stucking at "39"
Sir,
We are using NHD-C0220BiZ-FSW-FBW-3V3M LCD. We write I2C code using bit banging.
We are not getting ACK for "0x39" command....
Kindly help out to resolve this issue.
ALSO let us know what I2C slave address we should use...as I have seen in forum post "3C" used instead of "78".
This is our code....
void LCD_GPIO_INIT()
{
gpio_pin_config_t LCD_I2C_SCL_config = {
kGPIO_DigitalOutput, 1,
};
gpio_pin_config_t LCD_I2C_SDA_config = {
kGPIO_DigitalOutput, 1,
};
gpio_pin_config_t LCD_THERMAL_SD_config = {
kGPIO_DigitalOutput, 1,
};
/*Init TX_EN High*/
GPIO_PinInit(GPIOC, 10, &LCD_I2C_SCL_config);
/*Init RX_EN Low*/
GPIO_PinInit(GPIOC, 11, &LCD_I2C_SDA_config);
GPIO_PinInit(GPIOA, 26, &LCD_THERMAL_SD_config);
}
/****************************************************
* I2C Start *
*****************************************************/
void I2C_Start(void)
{
//SCL=1;
//SDA=1;
//SDA=0;
//SCL=0;
GPIO_PinWrite(GPIOC, 10,1);
GPIO_PinWrite(GPIOC, 11,1);
GPIO_PinWrite(GPIOC, 11,0);
GPIO_PinWrite(GPIOC, 10,0);
}
/*****************************************************/
/****************************************************
* I2C Stop *
*****************************************************/
void I2C_Stop(void)
{
//SDA=0;
//SCL=0;
//SCL=1;
//SDA=1;
GPIO_PinWrite(GPIOC, 11,0);
GPIO_PinWrite(GPIOC, 10,0);
GPIO_PinWrite(GPIOC, 10,1);
GPIO_PinWrite(GPIOC, 11,1);
}
/****************************************************
* Output command or data via I2C *
*****************************************************/
void I2C_out(unsigned char j) //I2C Output
{
int n;
gpio_pin_config_t LCD_I2C_SDA_config_out = {
kGPIO_DigitalOutput, 1,
};
gpio_pin_config_t LCD_I2C_SDA_config_in = {
kGPIO_DigitalInput, 1,
};
uint8_t d;
d=j;
for(n=0;n<8;n++)
{
if((d&0x80)==0x80)
GPIO_PinWrite(GPIOC, 11,1);//SDA=1;
else
GPIO_PinWrite(GPIOC, 11,0); //SDA=0;
d=(d<<1);
cdelay();
GPIO_PinWrite(GPIOC, 10,0); //SCL = 0;
cdelay();
GPIO_PinWrite(GPIOC, 10,1); //SCL = 1;
cdelay();
GPIO_PinWrite(GPIOC, 10,0); //SCL = 0;
}
cdelay();
GPIO_PinWrite(GPIOC, 10,1);//SCL = 1;
GPIO_PinInit(GPIOC, 11, &LCD_I2C_SDA_config_in);
cdelay();
while(GPIO_PinRead(GPIOC,11) == 1)// while(SDA==1)
{
GPIO_PinWrite(GPIOC, 10,0); //SCL=0;
cdelay();
GPIO_PinWrite(GPIOC, 10,1); //SCL=1;
cdelay();
}
GPIO_PinInit(GPIOC, 11, &LCD_I2C_SDA_config_out);
GPIO_PinWrite(GPIOC, 10,0); //SCL=0;
cdelay();
}
/****************************************************
* Initialization For ST7036i *
*****************************************************/
void init_LCD()
{
I2C_Start();
I2C_out(Slave);//Slave=0x78
I2C_out(Comsend);//Comsend = 0x00
I2C_out(0x38);
delay(10);
delay(10);
I2C_out(0x39);
delay(10);
delay(10);
I2C_out(0x14);
I2C_out(0x78);
I2C_out(0x5E);
I2C_out(0x6D);
I2C_out(0x0C);
I2C_out(0x01);
I2C_out(0x06);
delay(10);
I2C_Stop();
}
/****************************************************
* Send string of ASCII data to LCD *
*****************************************************/
void Show(unsigned char *text)
{
int n,d;
d=0x00;
I2C_Start();
I2C_out(Slave); //Slave=0x78
I2C_out(Datasend);//Datasend=0x40
for(n=0;n<20;n++){
I2C_out(*text);
++text;
}
I2C_Stop();
}
int lcd_test()
{
uint8_t data[]={0x41, 0x42, 0x43, 0x44};
LCD_GPIO_INIT();
init_LCD();
Show(data);
}
0
-
Pin 6 Voltage is 2.94V. 0 -
This may be the issue with the slave address:
// I2C LCD Slave address
#define SLAVE_ADDRESS 0x3C // 0x3C = (0x78<<1) since i2c sends 7 bit address
Also, try slowing down the SPI clock frequency and adding 10k pullups on the clock and data lines.
Please check and confirm the "L" level input is less than 0.8V and the "H" level input is more than 2.31V to be withing the logic level specification.
Regards,0
Please sign in to leave a comment.
Comments
2 comments