Author Topic: NHD-C0216CiZ-FSW-FBW-3V3  (Read 2714 times)

carlosflr

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
NHD-C0216CiZ-FSW-FBW-3V3
« on: August 07, 2015, 11:21:25 AM »
I am trying to use the NHD-C0216CiZ-FSW-FBW-3V3 display with a Kinetis microcontroller (Cortex M4). I think I'm following the datasheet for the initialization routine and to send data. However, the display doesn't show the proper data. The first five characters of the first row are missing. The rest of the characters on the same line are shifted to the right. The second line looks OK. I'm attaching an image of how it looks. I tried this with two boards and it looks the same so I assume I am doing something wrong in my code.

I would appreciate any help you can provide.

Thanks,
Carlos

This is my code:

Code: [Select]
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");


Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-C0216CiZ-FSW-FBW-3V3
« Reply #1 on: August 07, 2015, 11:35:39 AM »
From my experience, this happens when the timing is not correct.  Can you please try to increase the delay after you set the RAM address for the first line?  I know it looks as if the delay you have is 30us, however I still think it will be beneficial to try what I have suggested to see if anything changes.
Perhaps also try increasing the delay after the controller is initialized.

carlosflr

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: NHD-C0216CiZ-FSW-FBW-3V3
« Reply #2 on: August 07, 2015, 11:48:40 AM »
I just increased all my delays to 500 ms, including the delays in the initialization routine. I can see how each character is displayed. However, the display looks the same. Anything else that could be wrong?

Thanks,
Carlos

carlosflr

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: NHD-C0216CiZ-FSW-FBW-3V3
« Reply #3 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.

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-C0216CiZ-FSW-FBW-3V3
« Reply #4 on: August 10, 2015, 08:09:56 AM »
You're very welcome, thank you for sharing you solution!  :)

 

NHD-C0216CIZ-FSW-FBW-3V3 unexpected I2C levels

Started by kentavvBoard Character LCDs

Replies: 3
Views: 2483
Last post April 30, 2016, 06:13:19 PM
by perky
NHD-C0216CiZ-FSW-FBW-3V3 with arduino nano

Started by litunBoard Character LCDs

Replies: 4
Views: 332
Last post Today at 08:46:27 AM
by tolikkk
NHD-C0216CIZ Not Acknowledging

Started by danbujakBoard Character LCDs

Replies: 7
Views: 3460
Last post February 23, 2015, 08:16:16 AM
by Michael_L
NHD-C0216CiZ-FSW-FBW-3V3 not working

Started by gab_electroBoard Character LCDs

Replies: 1
Views: 872
Last post October 21, 2016, 03:09:51 PM
by Saurabh_B
Using NHD-C0216CiZ-FSW-FBW-3V3 on I2C on Linux

Started by ABSysacomBoard Character LCDs

Replies: 0
Views: 810
Last post November 08, 2016, 03:56:00 PM
by ABSysacom