NHD-1.8-128160EF-CSXN#-F Programming
I recently purchased the above display together with the NHD-COG14-36 adapter, Molex connector and 2x12 pin header. I used the example 'NHD-1.8-128160EF with PIC32' and adapted it to my RC5600WM processor from digi.com. Besides any effort to verify my connection and coding the display plays dead - nothing whatsoever shows up on the display.
I am using 3.3V for VDD and IOVDD which should be the max according to specs. I verified every connection line that when I change it from my program that it reaches the Molex connector. My test program should fill the display with a single color but the display stays black. I turned on the backlight which showed all pixels white.
I would appreciate if someone could check for a mistake I made.
Thanks
Guenther
// Test NHD-1.8-128160EF-CSXN#-F display with RC5600WM processor
//
// Port A - display DB0..DB7
// Port E.0 - !CS
// Port E.1 - !RST
// Port E.2 - D/C
// Port E.3 - !WR
// Port E.5 - !RD
#define TFT_18E_SET_NOT_CS BitWrPortI(PEDR, &PEDRShadow, 1, 0)
#define TFT_18E_SET_CS BitWrPortI(PEDR, &PEDRShadow, 0, 0)
#define TFT_18E_SET_NOT_RST BitWrPortI(PEDR, &PEDRShadow, 1, 1)
#define TFT_18E_SET_RST BitWrPortI(PEDR, &PEDRShadow, 0, 1)
#define TFT_18E_SET_D BitWrPortI(PEDR, &PEDRShadow, 1, 2)
#define TFT_18E_SET_C BitWrPortI(PEDR, &PEDRShadow, 0, 2)
#define TFT_18E_SET_NOT_WR BitWrPortI(PEDR, &PEDRShadow, 1, 3)
#define TFT_18E_SET_WR BitWrPortI(PEDR, &PEDRShadow, 0, 3)
#define TFT_18E_SET_NOT_RD BitWrPortI(PEDR, &PEDRShadow, 1, 5)
#define TFT_18E_SET_RD BitWrPortI(PEDR, &PEDRShadow, 0, 5)
#define TFT_18E_WRITE(data) WrPortI(PADR, &PADRShadow, data)
#define DELAY_10US(n) for (delay_10us = 0; delay_10us < 3*n; delay_10us++) {}
void TFT_18E_Initialize();
void TFT_18E_Write_Command(unsigned char command);
void TFT_18E_Write_Data(unsigned char data);
unsigned long delay_10us;
main()
{
int i;
unsigned long il;
char data;
// set port D bit 0 for high/low output for LED
BitWrPortI(PDDCR, &PDDCRShadow, 0, 0);
BitWrPortI(PDDDR, &PDDDRShadow, 1, 0);
// set port A for high/low output
WrPortI(SPCR, &SPCRShadow, 0x84);
// set port E bits 0,1,2,3,5 for high/low output
WrPortI(PEDDR, &PEDDRShadow, 0x2F);
WrPortI(PEDCR, &PEDCRShadow, ~0x3F); // Keep output enabled for PE.4 which is
// SMODE on the Interface Adapter
// Hard reset TFT
TFT_18E_SET_RST;
DELAY_10US(15000);
TFT_18E_SET_NOT_RST;
DELAY_10US(15000);
TFT_18E_Initialize();
TFT_18E_SET_CS; // Chip select on for TFT
TFT_18E_SET_NOT_RD; // TFT read off
TFT_18E_SET_WR;
// Fill screen with color
TFT_18E_Write_Command(0x2A); // set column address 0 to 127
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x7F);
TFT_18E_Write_Command(0x2B); // set page address 0 to 159
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x9F);
TFT_18E_Write_Command(0x2C); // write memory start
for (i = 0; i < 20480; i++)
{
// 18-bit pixel format
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0xFF);
}
while (1)
{
}
}
void TFT_18E_Write_Command(unsigned char command)
{
TFT_18E_SET_C;
TFT_18E_WRITE(command);
TFT_18E_SET_WR;
DELAY_10US(15);
TFT_18E_SET_NOT_WR;
}
void TFT_18E_Write_Data(unsigned char data)
{
TFT_18E_SET_D;
TFT_18E_WRITE(data);
TFT_18E_SET_WR;
TFT_18E_SET_NOT_WR;
}
void TFT_18E_Initialize()
{
// Initialize TFT
TFT_18E_Write_Command(0x11); // sleep out
DELAY_10US(10000);
TFT_18E_Write_Command(0x28); // display off
TFT_18E_Write_Command(0x26);TFT_18E_Write_Data(0x04); // select gamma curve 4
TFT_18E_Write_Command(0xF2);TFT_18E_Write_Data(0x00);
TFT_18E_Write_Command(0xB1);TFT_18E_Write_Data(0x0A);TFT_18E_Write_Data(0x14);
TFT_18E_Write_Command(0xC0);TFT_18E_Write_Data(0x0A);TFT_18E_Write_Data(0x00);
DELAY_10US(1000);
TFT_18E_Write_Command(0xC1);TFT_18E_Write_Data(0x02);
DELAY_10US(1000);
TFT_18E_Write_Command(0xC5);TFT_18E_Write_Data(0x2F);TFT_18E_Write_Data(0x3E);
TFT_18E_Write_Command(0xC7);TFT_18E_Write_Data(0x40);
TFT_18E_Write_Command(0x2A); // set column address 0 to 127
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x7F);
TFT_18E_Write_Command(0x2B); // set page address 0 to 159
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x00);
TFT_18E_Write_Data(0x9F);
TFT_18E_Write_Command(0x36);TFT_18E_Write_Data(0xC8); // set address mode
TFT_18E_Write_Command(0x3A);TFT_18E_Write_Data(0x06); // set 18-bit pixel format
TFT_18E_Write_Command(0x29); // set display on
DELAY_10US(1000);
TFT_18E_Write_Command(0x2C); // write memory start
}
-
I changed the voltage for Vdd and IOVdd to 2.8V. No difference. I read the datasheet for the ILI9163 controller up-and-down to check for anything I may have missed. This datasheet looks like a poorly written document to me(!!!). Impossible for me to get all the technical information I need.
Questions:
- How to determine the setting for Power_Control1?
- Ditto for VCOM_Control1?
- Why can VCOML be negative?
Anyway, there's a chance this is a DOA.
/Guenther0 -
Guenther,
I will look over your code for any mistakes.
All displays are tested before they leave our Facility, chances that it is DOA is fairly low.
You can provide 3.3V to both the VDDIO and VDD pins.
You can use the optimal settings for the VCOM and Power_Control found in our example code here: https://newhavendisplay.com/content/app_notes/Arduino_nhd-1_8-128160EF-CTXI.txt
Is it possible to also share your wiring diagram / Schematic for your connections?0 -
The second unit I got showed the same symptom. So I dug deeper into my code. I finally got to the bottom of it. It was the definition of my delay code for 'DELAY_10US'.
For values '3*n'>32767 the generated instructions created a huge number like FFFFxxxx. That kept my 'DELAY_10US(15000) looping for a looooong time. Changing the '3*n' to '3L*n' created the expected result.
I think this a compiler bug - not promoting the calculation of '3*n' to be done in 'long'.
All is working now as expected.0 -
Thanks for sharing your solution Guenther!
0
Please sign in to leave a comment.
Comments
4 comments