Author Topic: SPI initialization of NHD-0216AW-SB3  (Read 154 times)

m_ozzie

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
SPI initialization of NHD-0216AW-SB3
« on: January 09, 2020, 11:12:46 AM »
In the forum I have seen samples of bitbanging the initialization but none for standard 8 bit SPI transfer (Mode 3).  I am using PIC24F to send the many SPI write commands but the display shows no signs of life after my initialization routine.  Scope confirms correct CS operation and data being clocked in to SDI pin of device.  Other New Haven LCDs I've used in the past document specific wait times between different operations.  This product data sheet doesn't show any required wait times after each command.  The clear screen command would normally require some time to process before receiving another command.  Initialization code provided in data sheet shows no wait after issuing CLEAR (0x01) command.  Any thoughts on how I can get PIC24F SPI transfer up and running would be appreciated.  Init routine attached.

Alee_S

  • Administrator
  • Jr. Member
  • *****
  • Posts: 66
  • Karma: 4
    • View Profile
Re: SPI initialization of NHD-0216AW-SB3
« Reply #1 on: January 22, 2020, 09:04:14 AM »
Hello m_ozzie,

The US2066 controller cannot be run from your typical standard 8-bit SPI transmission, and instead requires manual manipulating of the GPIO states within your software. Please refer to the github below for proper bit-banging implementation of SPI data transmission (Case 2). More details on serial data transfer can be found on pg. 11 of the US2066 controller specs.

Our initialization sequence is also a good indicator of whether any delays are needed between certain commands as our code has been tested and verified.

https://github.com/NewhavenDisplay/NHD_US2066/blob/master/NHD_US2066.cpp
https://www.newhavendisplay.com/appnotes/datasheets/OLEDs/US2066.pdf

Hope this is helpful!

m_ozzie

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Re: SPI initialization of NHD-0216AW-SB3
« Reply #2 on: January 22, 2020, 11:46:09 AM »
Hello Alee_S   Thank you for the response.  I integrated the bit bang functions (command & data) into my code but there is still no response from OLED.  VDD_SEL & VDDIO are tied to 3.3V and jumper SJ1 is open.  My micro's SDO pin is connected to OLED "SDI" pin.  This conflicts with the wiring diagram but I believe I saw a post stating to do so.

Should I expect the back-light to come on after initialization? 

What about the CS?  The sample code you pointed me to doesn't address the CS.  The timing diagram (fig. 5-5) provided in the US2066 spec. shows a CS transition at beginning and end of the 24 bit transfer.  I've tried code with and without CS with same result.  Using scope, I've verified the first 3 commands per the data stream shown in fig. 5-5

Are CS commands required?
Thank you for your help.


command(0x2A);
command(0x71);
data(0x00);

void lcd_init(void)
{
    LCD_RST_SetHigh();     
    __delay_ms(10);

    command(0x2A); //function set (extended command set)
    command(0x71); //function selection A
    data(0x00); // disable internal VDD regulator (2.8V I/O). data(0x5C) = enable regulator (5V I/O)
    command(0x28); //function set (fundamental command set)
    command(0x08); //display off, cursor off, blink off
    command(0x2A); //function set (extended command set)
    command(0x79); //OLED command set enabled
    command(0xD5); //set display clock divide ratio/oscillator frequency
    command(0x70); //set display clock divide ratio/oscillator frequency
    command(0x78); //OLED command set disabled
    command(0x08); //extended function set (2-lines)
    command(0x06); //COM SEG direction
    command(0x72); //function selection B
    data(0x00); //ROM CGRAM selection
    command(0x2A); //function set (extended command set)
    command(0x79); //OLED command set enabled
    command(0xDA); //set SEG pins hardware configuration
    command(0x00); //set SEG pins hardware configuration
    command(0xDC); //function selection C
    command(0x00); //function selection C
    command(0x81); //set contrast control
    command(0x7F); //set contrast control
    command(0xD9); //set phase length
    command(0xF1); //set phase length
    command(0xDB); //set VCOMH deselect level
    command(0x40); //set VCOMH deselect level
    command(0x78); //OLED command set disabled
    command(0x28); //function set (fundamental command set)
    command(0x01); //clear display
    command(0x80); //set DDRAM address to 0x00
    command(0x0C); //display ON

    __delay_ms(100);
   
}


void command(uint8_t c)
{
//  LCD_CS_SetLow();
   
    uint8_t temp,i;
           
    temp = 0xF8;
    for(i=0;i<8;i++)
        {
            SCLK_SetLow();
            if((temp&0x80)>>7==1)
            {
                SDO_SetHigh();
            }
            else
            {
                SDO_SetLow();
            }
                temp = temp << 1;
                SCLK_SetHigh();
         }
 
            for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                if((c&0x01)==1)
                {
                SDO_SetHigh();
                }
                else
                {
                SDO_SetLow();
                }
                c = c >> 1;
                SCLK_SetHigh();
              }
   
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                SDO_SetLow();
                SCLK_SetHigh();
              }
   
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                if((c&0x01)==1)
                {
                SDO_SetHigh();
                }
                else
                {
                SDO_SetLow();
                }
                c = c >> 1;
                SCLK_SetHigh();
              }
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                SDO_SetLow();
                SCLK_SetHigh();
              }
//                LCD_CS_SetHigh(); 
}

void data(uint8_t d)
{
//    LCD_CS_SetLow();
   
        uint8_t temp,i;
       
              temp = 0xFA;
              for(i=0;i<8;i++)
              {
                SCLK_SetLow();
                if((temp&0x80)>>7==1)
                {
                SDO_SetHigh();
                }
                else
                {
                SDO_SetLow();
                }
                temp = temp << 1;
                SCLK_SetHigh();
              }
 
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                if((d&0x01)==1)
                {
                SDO_SetHigh();
                }
                else
                {
                SDO_SetLow();
                }
                d = d >> 1;
                SCLK_SetHigh();
              }
             
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                SDO_SetLow();
                SCLK_SetHigh();
              }
             
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                if((d&0x01)==1)
                {
                SDO_SetHigh();
                }
                else
                {
                SDO_SetLow();
                }
                d = d >> 1;
                SCLK_SetHigh();
              }
             
              for(i=0;i<4;i++)
              {
                SCLK_SetLow();
                SDO_SetLow();
                SCLK_SetHigh();
              }
        __delay_ms(10);
//        LCD_CS_SetHigh(); 
}

Alee_S

  • Administrator
  • Jr. Member
  • *****
  • Posts: 66
  • Karma: 4
    • View Profile
Re: SPI initialization of NHD-0216AW-SB3
« Reply #3 on: January 24, 2020, 12:57:59 PM »
Hello m_ozzie,

OLED displays don't have backlights like LCDs, so there may not be a visual confirmation of the display being initialized properly.

If the OLED display is the only device being communicated too, the /CS pin could be tied LOW for the duration of your code.
The /CS pin must be tied low in order to enable MCU communication.

Best,

 

NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization

Started by BMohlmanBoard Graphic LCDs

Replies: 5
Views: 10080
Last post January 13, 2016, 07:44:16 AM
by Paul_B
Working on NHD‐2.4‐240320SF‐CTXL#‐FTN1, have problem in initialization

Started by sli25Board TFTs

Replies: 6
Views: 10425
Last post June 04, 2015, 09:52:25 PM
by sli25
Use of Timing characteristics in the initialization code of the display

Started by ShabdaBoard TFTs

Replies: 1
Views: 6397
Last post May 20, 2014, 08:00:39 AM
by Michael_L
Initialization code for M0220SD-202SDAR1 module??

Started by Javier OrtizBoard Vacuum Fluorescent Displays

Replies: 1
Views: 6472
Last post November 17, 2015, 05:12:51 PM
by Saurabh_B
NHD-14432WG-BTFH-V#T Datasheet's Initialization Code

Started by Terence DBoard Graphic LCDs

Replies: 2
Views: 4758
Last post May 26, 2017, 05:54:45 PM
by Terence D