1
Character LCDs / Re: NHD-C0216CiZ-FSW-FBW-3V3
« on: August 08, 2015, 07:35:57 AM »
I checked my I2C timing and it was too fast. I fixed this and now I see the correct strings on the display. Thanks for your help Michael.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
void vfnLCDInit(void)
{
// send LCD reset pulse
GPIOD_PCOR |= (1 << LCD_RST);
GPIOD_PDDR |= (1 << LCD_RST);
SysTickWait(0.0005);
GPIOD_PSOR |= (1 << LCD_RST);
SysTickWait(0.001);
// disable backlight by default
GPIOD_PCOR |= (1 << LCD_BK);
GPIOD_PDDR |= (1 << LCD_BK);
//Function Set
ST7032iCommandWrite(0x38);
SysTickWait(0.000030);
//Function Set
ST7032iCommandWrite(0x39);
SysTickWait(0.000030);
//Bias and OSC frequency
ST7032iCommandWrite(0x14);
SysTickWait(0.000030);
//Contrast set
ST7032iCommandWrite(0x72);
SysTickWait(0.000030);
//Power
ST7032iCommandWrite(0x5E);
SysTickWait(0.000030);
//Follower control
ST7032iCommandWrite(0x6D);
SysTickWait(0.000030);
//Display control : on
ST7032iCommandWrite(0x0C);
SysTickWait(0.000030);
//Clear
ST7032iCommandWrite(0x01);
SysTickWait(0.002);
//Entry mode
ST7032iCommandWrite(0x06);
// wait 100 ms
SysTickWait(0.1);
}
void vfnLCDPutString(int8_t x, int8_t y, int8_t String[])
{
uint8_t i = 0;
uint8_t addr;
if (y == 1)
addr = 0x00;
else if (y == 2)
addr = 0x40;
else
return;
addr += (x - 1);
ST7032iCommandWrite(0x80 | addr);
SysTickWait(0.000030);
while(String[i] != '\0')
{
ST7032iPutchar(String[i]);
i++;
}
}
void ST7032iPutchar(int8_t chardata)
{
uint32_t i;
ST7032iDataWrite((uint8_t)chardata);
SysTickWait(0.000030);
}
void ST7032iCommandWrite(uint8_t Data)
{
uint8_t buf[2];
buf[0] = 0x00;
buf[1] = Data;
ST7032ii2cWrite(buf, 2);
}
void ST7032iDataWrite(uint8_t Data)
{
uint8_t buf[2];
buf[0]= 0x40;
buf[1] = Data;
ST7032ii2cWrite(buf, 2);
}
on main...
vfnLCDInit();
vfnLCDPutString(1,1,"0123456789abcdef");
vfnLCDPutString(1,2,"0123456789ABCDEF");