Newhaven Display Forum

Newhaven Products => Character LCDs => Topic started by: Krishkakarla on April 18, 2015, 05:09:52 PM

Title: NHD-C0216CZ-NSW-BBW-3V3 LCD initialization
Post by: Krishkakarla on April 18, 2015, 05:09:52 PM
Hello All,
1. I am having trouble initializing my NHD-C0216CZ-NSW-BBW-3V3 LCD using an STM32f303 discovery board. I am using the logic analyzer to debug my SPI communication protocol and the data I'm sending seems to be fine. I'm using the following SPI clock settings to send data; CPOL=1, CPHA=1.
2. I've done the following hardware connections: Between C1+ to C1- a 2.2uF cap, Vout to 1uF to GND; rest of the LCD pins to the microcontroller pins.
3. I've used the following initialization routine. The timing between the instructions sent is correct when I checked with my logic analyzer:

void lcd_initialization(void)
{
   SS=1;
        MOSI=1;
        SCK=1;
       
        RS=1;

   
   RST=1   
        Delay(2);
   RST=0
   Delay(20);
   send_inst(0x30);            // wake up
   Delay(2);
   send_inst(0x30);            // wake up
   send_inst(0x30);            // wake up
   send_inst(0x39);
   send_inst(0x14);            // wake up
   send_inst(0x56);            // function set and instruction table = 1
   send_inst(0x6D);            // interanl oscillator frequency
   send_inst(0x70);          // power control
   send_inst(0x0C);            // follower control
   send_inst(0x06);            // contrast set
   send_inst(0x01);
   Delay(2);
}



4. I also used the following initialization routine:
void lcd_initialization(void)
{
   SS=1;
        MOSI=1;
        SCK=1;
       
        RS=1;
   
   
   RST=1   
        Delay(2);
   RST=0
   
    Delay(40);
   send_inst(0x38);            // wake up
   send_inst(0x39);            // wake up
   send_inst(0x14);            // wake up
   send_inst(0x78);            // function set and instruction table = 1
   send_inst(0x5E);            // interanl oscillator frequency
   send_inst(0x6A);          // power control
    delay (200);
   send_inst(0x0C);            // follower control
   send_inst(0x01);            // contrast set
   delay (2);
   send_inst(0x06);         // entry mode set

}

Also, how do I check for the LCD busy flag when I only have a MOSI pin for the LCD but not a MISO pin??

I'm clueless on how to proceed further and the LCD shows no signs of life whatsoever except for the backlight. Any help would be really appreciated.

Thanks,
Krishna

   
Title: Re: NHD-C0216CZ-NSW-BBW-3V3 LCD initialization
Post by: Michael_L on April 22, 2015, 11:41:23 AM
How fast is your SPI clock?  The clock period has a minimum rating of 200ns.  Also, have you tried using the write routines provided in the example code section of the datasheet?
Title: Re: NHD-C0216CZ-NSW-BBW-3V3 LCD initialization
Post by: Krishkakarla on April 28, 2015, 04:20:08 AM
@Michael,
Thanks for the quick reply. I saw that the clock speed specified in the datasheet is 380kHz at the least and so I reduced my SPI clock speed to 250kHz. I did not use the write routines that were specified in the datasheet. The ones that I'm using are built in SPI data transfer routines provided by STMicro. I've been able to see the clock toggling and the correct data being sent using my logic analyzer. I've also rechecked to ensure that there's no violation in the timing too.

Krishna
Title: Re: NHD-C0216CZ-NSW-BBW-3V3 LCD initialization
Post by: Michael_L on May 01, 2015, 07:40:15 AM
It might be worth a try to give those write routines in the datasheet a try, just as a means of troubleshooting.  That code should work regardless of what mcu you are using, therefore it will make for a good test.