NHD-C12832A1Z - with TI microcontroller
Hello Team,
I am working with NHD-C12832A1Z-FSW-FBW-3V3 display via SPI communication using microcontroller TMS320F280049. I tried various methods found online already but, still all I am getting is a fully white display at my LCD screen. I am attaching my code with this post, please have a look at it. My test setup is as follows,
1. TMS320F280049 32 bit MCU
2. NHD-C12832A1Z-FSW-FBW-3V3
3. SPI communication Mode 3 at 1 MHz clock
Please consider that I am new to this whole area of coding, so simple explanations will be greatly appreciated.
Following are my questions on this device.
1. How do I know my LCD is correctly configured?
2. If I say a Pixel is ON the corresponding pixel will display as dark right? ( if am using command ALL ON for a normal display my LCD will be full
of (128*32) dark pixels?)
3. Is there is any delay required after each command transfer or can I send all the needed commands sequentially at once using FIFO?
4. Is there is any delay actually required after setting power control set (command 0x2F) ? if required how much?
5. Is there is any delay required between command and data and transfer?
6. Do we need any minimum pulse HIGH duration between each chip select LOW ? or can I use chip select LOW immediately after it is made HIGH?
#include"F28x_Project.h"
void Init_LCD(void);
void Init_GPIO(void);
void Init_SPI(void);
void Init_All(void);
void LCD_CMD(int16);
void LCD_DATA(int16);
int16 cmd = 0x0000, data = 0x0000;
void main(void)
{
Init_All();
DELAY_US(10);
LCD_CMD(0xAE00);
DELAY_US(1);
LCD_CMD(0x4000);
DELAY_US(1);
LCD_CMD(0xB000);
DELAY_US(1);
LCD_CMD(0x1000);
DELAY_US(1);
LCD_CMD(0x0000);
DELAY_US(1);
LCD_DATA(0x2900);
DELAY_US(1);
LCD_DATA(0x2900);
DELAY_US(1);
LCD_CMD(0xAF00);
while(1)
{
LCD_CMD(0xAF00);
DELAY_US(1000);
LCD_CMD(0xAE00);
DELAY_US(1000);
}
}
void Init_All(void)
{
InitSysCtrl();
InitGpio();
Init_GPIO();
Init_SPI();
Init_LCD();
}
void Init_GPIO()
{
EALLOW;
// SPI Pins
GpioCtrlRegs.GPAGMUX1.bit.GPIO9 = 1; // SPIA_CLK
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3;
GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO8 = 1; // SPIA_SIMO
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 3;
GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO8 = 3; // Qualifier Selection
GpioCtrlRegs.GPAGMUX1.bit.GPIO10 = 1; // SPIA_SOMI
GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 3;
GpioCtrlRegs.GPAPUD.bit.GPIO10 = 0; // Pull up enable
GpioCtrlRegs.GPAQSEL1.bit.GPIO10 = 3; // Qualifier Selection
// LCD controls
GpioCtrlRegs.GPAGMUX1.bit.GPIO13 = 0; // RST for LCD
GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO13 = 1; // Direction as output
GpioCtrlRegs.GPAGMUX2.bit.GPIO16 = 0; // CS/ for LCD
GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO16 = 1; // Direction as output
GpioCtrlRegs.GPAGMUX1.bit.GPIO12 = 0; // A0 input of LCD
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO12 = 1; // Direction as output
EDIS;
GpioDataRegs.GPASET.bit.GPIO13 = 1; // set RESET
GpioDataRegs.GPASET.bit.GPIO16 = 1; // set CS/
}
void Init_SPI(void)
{
SpiaRegs.SPIFFTX.bit.SPIRST = 1; // SPI Reset. SPI FIFO can resume transmit or
receive. No effect to the SPI registers bits.
SpiaRegs.SPIFFTX.bit.SPIFFENA = 1; // SPI FIFO Enhancements Enable
SpiaRegs.SPIFFTX.bit.TXFIFO = 1; // Release transmit FIFO from reset.
SpiaRegs.SPIFFTX.bit.TXFFINTCLR = 1; // TXFIFO Interrupt Clear.
SpiaRegs.SPIFFTX.bit.TXFFIENA = 0; // TX FIFO interrupt based on TXFFIL match
SpiaRegs.SPIFFTX.bit.TXFFIL = 0; // A TX FIFO interrupt request is generated
SpiaRegs.SPIFFRX.bit.RXFFOVFCLR = 1; // Receive FIFO Overflow Clear.
SpiaRegs.SPIFFRX.bit.RXFIFORESET = 1; // Re-enable receive FIFO operation.
SpiaRegs.SPIFFRX.bit.RXFFINTCLR = 1; // Receive FIFO Interrupt Clear.
SpiaRegs.SPIFFRX.bit.RXFFIENA = 1; // RX FIFO interrupt based on RXFFIL match
SpiaRegs.SPICCR.bit.SPISWRESET = 0; // clear software reset bit
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1; // master mode selected
SpiaRegs.SPICTL.bit.CLK_PHASE = 0; // clock phase selection
SpiaRegs.SPICCR.bit.CLKPOLARITY = 1; // clock polarity
SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = 24; //(25MHz/25 = 1 MHz)
SpiaRegs.SPICCR.bit.SPICHAR = 7; // character per transfer
SpiaRegs.SPISTS.bit.INT_FLAG = 1; // clear interrupt flag
SpiaRegs.SPISTS.bit.OVERRUN_FLAG = 1; // clear over run flag
SpiaRegs.SPIPRI.bit.FREE = 1; // Emulation free run enabled
SpiaRegs.SPICCR.bit.SPILBK = 0; // loop back disable
SpiaRegs.SPICTL.bit.TALK = 1; // slave talk enabled
SpiaRegs.SPICTL.bit.SPIINTENA = 0; // interrupt disable
SpiaRegs.SPICCR.bit.SPISWRESET = 1; // software reset disabled
}
void Init_LCD(void)
{
GpioDataRegs.GPACLEAR.bit.GPIO13 = 1; // set RESET
DELAY_US(50000);
GpioDataRegs.GPASET.bit.GPIO13 = 1; // set RESET
DELAY_US(10000);
LCD_CMD(0xA000);
DELAY_US(5);
LCD_CMD(0xAE00);
DELAY_US(5);
LCD_CMD(0xC000);
DELAY_US(5);
LCD_CMD(0xA200);
DELAY_US(5);
LCD_CMD(0x2F00);
DELAY_US(2000);
LCD_CMD(0x2100);
DELAY_US(5);
LCD_CMD(0x8100);
DELAY_US(5);
LCD_CMD(0x2F00);
}
void LCD_CMD(int16 cmd)
{
GpioDataRegs.GPACLEAR.bit.GPIO16 = 1; // clear CS/
GpioDataRegs.GPACLEAR.bit.GPIO12 = 1; // SET A0
while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG !=0);
SpiaRegs.SPITXBUF = cmd;
while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG !=0);
GpioDataRegs.GPASET.bit.GPIO16 = 1; // clear CS/
}
void LCD_DATA(int16 data)
{
GpioDataRegs.GPACLEAR.bit.GPIO16 = 1; // clear CS/
GpioDataRegs.GPASET.bit.GPIO12 = 1; // SET A0
while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG !=0);
SpiaRegs.SPITXBUF = data;
while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG !=0);
GpioDataRegs.GPASET.bit.GPIO16 = 1; // clear CS/
}
Best Regards,
Vineeth N
-
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, 0x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 0xFF, 0xFF, 0xFD, 0xFC, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFD,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFD, 0xFD, 0xFD, 0xFC, 0xFE, 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, 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 -
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,
Vineeth0 -
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: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 -
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 -
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 -
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,
Vineeth0 -
Please somebody help me with this please! Is there is any header file available for 128*32 display for my requirement described above ? 0 -
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.
Comments
8 comments