NHD-C12832A1Z - with TI microcontroller

Comments

8 comments

  • Ted M.
    NHD Staff

    Hi Vineeth,

    First verify the LCD voltage booster circuit is working properly to provide the correct contrast voltage to the LCD.

    We offer a PCB for testing the display, part # NHD-PCB12832A1Z https://www.newhavendisplay.com/nhdpcb12832a1z-p-3569.html
    The schematic for it can be found here to confirm your configuration: https://www.newhavendisplay.com/specs/NHD-PCB12832A1Z.pdf

    I have attached some example code for your reference and there are some differences in the controller initialization code.

    Please update your code to use the following Initialization sequence:

    /****************************************************
    *           Initialization For controller           *
    *****************************************************/

    void init_LCD()  {
    comm_write(0xA0)    // ADC select
    comm_write(0xAE);   // Display OFF
    comm_write(0xC8);   // COM direction scan
    comm_write(0xA2);   // LCD bias set
    comm_write(0x2F);   // Power Control set
    comm_write(0x21);   // Resistor Ratio Set
    comm_write(0x81);   // Electronic Volume Command (set contrast) Double Btye: 1 of 2
    comm_write(0x20);   // Electronic Volume value (contrast value) Double Byte: 2 of 2
    comm_write(0xAF);   // Display ON
    }

    Working Example code for Arduino Uno:

    /*****************************************************************************
     *
    / Program for writing to NHD-C12832A1Z display Series with the ST7565R Controller.
    / This code is written for the Arduino Uno R3 using Serial Interface
    /
    / Newhaven Display invests time and resources providing this open source code,
    / Please support Newhaven Display by purchasing products from Newhaven Display!

    * Copyright (c) 2019, Newhaven Display International
    *
    * This code is provided as an example only and without any warranty by Newhaven Display.
    * Newhaven Display accepts no responsibility for any issues resulting from its use.
    * The developer of the final application incorporating any parts of this
    * sample code is responsible for ensuring its safe and correct operation
    * and for any consequences resulting from its use.
    * See the GNU General Public License for more details.
    *
    * Use Vertical Orientation when converting BMP to hex code to display custom image using LCD assistant. 
    *
    *****************************************************************************/


    /****************************************************
    *               Pinout on Arduino Uno               *
    *****************************************************/

    #define RES 8   //Reset signal
    #define CS  9   //Chip select signal
    #define RS 10   //Register select signal
    #define SC 11   //Serial clock signal
    #define SI 12   //Serial data signal

    /****************************************************
    *               Hex Table for Image Pic             *
    *****************************************************/

    unsigned char NHD_Logo [] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x10, 0x90, 0x50,
    0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0xF0, 0x30, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0xF0, 0x50,
    0x50, 0x50, 0x00, 0x00, 0x10, 0xF0, 0x00, 0xE0, 0x10, 0xC0, 0x80, 0x70, 0x00, 0x00, 0x00, 0xF0,
    0x40, 0x40, 0xF0, 0x00, 0x00, 0x80, 0xE0, 0x90, 0xE0, 0x80, 0x00, 0x00, 0x30, 0xE0, 0x00, 0xE0,
    0x30, 0x00, 0x00, 0xF0, 0x50, 0x50, 0x50, 0x00, 0x00, 0x00, 0xF0, 0x30, 0xC0, 0xF0, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00,
    0x70, 0x50, 0x50, 0x50, 0xD0, 0x00, 0x00, 0x00, 0xF0, 0x50, 0x50, 0x70, 0x00, 0x00, 0x00, 0xF0,
    0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x90, 0xE0, 0x80, 0x00, 0x00, 0x30, 0xE0, 0x60, 0x30, 0x00,
    0x00, 0x70, 0x70, 0x60, 0x20, 0x22, 0x27, 0x27, 0x22, 0x22, 0x22, 0x12, 0x11, 0x09, 0x04, 0x02,
    0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01,
    0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
    0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
    0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
    0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };

    unsigned char FMRadio [] = {
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xB7, 0xB7, 0xB7, 0xF7, 0xFF, 0x07,
    0xEF, 0x8F, 0xEF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xB7, 0xB7, 0xB7, 0x0F,
    0xFF, 0x3F, 0xBF, 0xBF, 0xBF, 0x3F,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xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xDF, 0xDF, 0xDF, 0xC0, 0xDF, 0xDF, 0xDF, 0xE0, 0x93, 0xD9, 0x9C, 0xDE, 0xE0, 0xFF, 0xDF,
    0xDF, 0xDF, 0xC0, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xCF, 0xCF, 0xFF, 0xFF, 0xFF, 0xF8, 0xD3, 0xD3,
    0xD3, 0xD3, 0xE0, 0xFF, 0xFC, 0xD3, 0xD3, 0xD3, 0xD3, 0xE0, 0xFE, 0xC0, 0xC0, 0xFC, 0xC0, 0xFC,
    0xFC, 0xC1, 0xC0, 0xFC, 0xFC, 0xFC, 0xFC, 0xC1, 0xC3, 0xDD, 0xCD, 0xC5, 0xD1, 0xDD, 0xDC, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
    };

    /****************************************************
    *                 Function Commands                  *
    *****************************************************/

    void data_write(unsigned char d) //Data Output Serial Interface
    {
    unsigned int n;
    digitalWrite(CS, LOW);
    digitalWrite(RS, HIGH);
    for(n=0;n<8;n++){
    if((d&0x80)==0x80)
    digitalWrite(SI, HIGH);
    else
    digitalWrite(SI, LOW);
    while(0);
    d=(d<<1);
    digitalWrite(SC, LOW);
    while(0);
    digitalWrite(SC, HIGH);
    while(0);
    digitalWrite(SC, LOW);
    }
    digitalWrite(CS, HIGH);
    }


    void comm_write(unsigned char d) //Command Output Serial Interface
    {
    unsigned int n;
    digitalWrite(CS, LOW);
    digitalWrite(RS, LOW);
    for(n=0;n<8;n++){
    if((d&0x80)==0x80)
    digitalWrite(SI, HIGH);
    else
    digitalWrite(SI, LOW);
    while(0);
    d=(d<<1);
    digitalWrite(SC, LOW);
    while(0);
    digitalWrite(SC, HIGH);
    while(0);
    digitalWrite(SC, LOW);
    }
    digitalWrite(CS, HIGH);
    }


    void DispPic(unsigned char *lcd_string)
    {
      unsigned int i,j;
      unsigned char page = 0xB0;
      comm_write(0xAE);          //Display OFF
      comm_write(0x40);         //Display start address + 0x40
      for(i=0;i<4;i++){       //32pixel display / 8 pixels per page = 4 pages
        comm_write(page);       //send page address
        comm_write(0x10);       //column address upper 4 bits + 0x10
        comm_write(0x00);       //column address lower 4 bits + 0x00
        for(j=0;j<128;j++){     //128 columns wide
          data_write(*lcd_string);    //send picture data
          lcd_string++;
          }
          page++;         //after 128 columns, go to next page
          }
      comm_write(0xAF);   
     
    }

    void ClearLCD(unsigned char *lcd_string)
    {
        unsigned int i,j;
      unsigned char page = 0xB0;
      comm_write(0xAE);          //Display OFF
      comm_write(0x40);         //Display start address + 0x40
      for(i=0;i<4;i++){       //32pixel display / 8 pixels per page = 4 pages
        comm_write(page);       //send page address
        comm_write(0x10);       //column address upper 4 bits + 0x10
        comm_write(0x00);       //column address lower 4 bits + 0x00
        for(j=0;j<128;j++){     //128 columns wide
          data_write(0x00);    //send picture data
          lcd_string++;
          }
          page++;         //after 128 columns, go to next page
          }
      comm_write(0xAF);   
    }

    /****************************************************
    *           Initialization For controller           *
    *****************************************************/

    void init_LCD()  {
    comm_write(0xA0)    // ADC select
    comm_write(0xAE);   // Display OFF
    comm_write(0xC8);   // COM direction scan
    comm_write(0xA2);   // LCD bias set
    comm_write(0x2F);   // Power Control set
    comm_write(0x21);   // Resistor Ratio Set
    comm_write(0x81);   // Electronic Volume Command (set contrast) Double Btye: 1 of 2
    comm_write(0x20);   // Electronic Volume value (contrast value) Double Byte: 2 of 2
    comm_write(0xAF);   // Display ON
    }

    /*****************************************************
    *           Setup Function, to run once              *
    *****************************************************/

    void setup() {
      DDRD = 0xFF;          // configure PORTD as output
      pinMode(RES, OUTPUT); // configure RES as output
      pinMode(CS, OUTPUT);  // configure CS as output
      pinMode(RS, OUTPUT);  // configure RS as output
      pinMode(SC, OUTPUT);  // configure SC as output
      pinMode(SI, OUTPUT);  // configure SI as output
      digitalWrite(RES, LOW);           
      delay(100);                     
      digitalWrite(RES, HIGH);           
      delay(100);
      init_LCD();     
    }

    /*****************************************************
    *           Loop Function, to run repeatedly         *
    *****************************************************/

    void loop() {
    delay(10);   
    while(1)
    {
        DispPic(NHD_Logo);
        delay(2000);
        ClearLCD(NHD_Logo);
        delay(500);

        DispPic(FMRadio);
        delay(2000);
        ClearLCD(FMRadio);
        delay(500);
    }
    }
    0
  • vineeth
    Hi Ted,

    Thank you for your fast response.

    How can I check my LCD voltage booster circuit is working properly or not?

    I will consider your suggestion `PCB for testing the display` but now I am running late on my schedule here. So, if it is possible to rectify my problem without the PCB it will be helpful.

    Can you please tell me about the delays that I asked about in the original thread.

    Regards,
    Vineeth
    0
  • Ted M.
    NHD Staff

    Hi Vineeth,

    To determine if the voltage booster circuit is working, please measure the voltage at pin 10 for the contrast voltage Vout.
    Please review the previous threads on this topic:

    https://support.newhavendisplay.com/hc/en-us/community/posts/4421098666903-NHD-C12832A1Z-FSW-FBW-3V3-won-t-initialize 

    The initialization routine does affect the generated Voltage for the LCD glass to an extent, but the construction of the voltage booster circuit is more important in this regard, and the best way to verify its operation would be to measure the voltage at V_out and V1-4 pins. We measured the V_out pin to measure about 9.3V on one of our units for reference, and the value you should expect to see.

    We typically use non-polarized ceramic SMD capacitors in our test fixtures and for our prototype board NHD-PCB12832A1Z, as these provided the best results consistently. We have also found polarized electrolytic capacitors to pose some issues in properly activating the voltage booster circuit correctly. Please share more details on the capacitor type and values used for this setup.

    Depending on the command, some extra delay time may be needed.
    Adding delay time is typical after commands that will be sending data following directly after the command.
    A busy flag is also set when the controller is processing commands and it can be read to determine when the controller is ready for input. 

    Command 0x2F does not require an additional delay.  Please review the example code "void init_LCD()" routine for initializing the display.

    The display's timing characteristics can be found in our datasheet: https://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSW-FBW-3V3.pdf

    Please review the controller datasheet for more details on commands and timing characteristics: https://www.newhavendisplay.com/app_notes/ST7565R.pdf

    Regards,

    0
  • labounty
    Hey, I'm a newbie so sorry if the question is pretty obvious: What should I do if the voltage is higher or lower than needed?
    0
  • Ted M.
    NHD Staff
    Hi labounty,

    The capacitors will provide the voltage boost based on the display's input voltage of 3.0V VDD. The final boosted voltage measured for V0 on pin 10 will determine the overall contrast level of the display.
    If the result is too little contrast or too much contrast to start with, then this will be the result of an incorrect voltage for V0 on pin 10.

    Regards,

    0
  • vineeth
    Hi Ted,

    Thanks for your suggestions, now it is working perfectly. I am glad that now I am able to display some lines and NHD logo. I need to display real time and temperature using this display. Since I am a newbie I don`t know how to do it. How to write at a particular point in the display? Do we have any header file for this 128*32 display? Since I am working with TIs microcontroller it is hard to find an example on the same. If you have any suggestions on it it will be greatly helpful.

    Best Regards,
    Vineeth
    0
  • vineeth
    Please somebody help me with this please! Is there is any header file available for 128*32 display for my requirement described above ?
    0
  • Ted M.
    NHD Staff
    Hi Vineeth,

    The NHD-C12832A1Z display uses the ST7565R controller/Driver.  Have you tried searching on Github for some example code for the ST7565R that may work with the TI microcontroller.

    Regards,
    0

Please sign in to leave a comment.