NHD2.4 240320CF-CTXI nothing on screen - initialized right?
Hello,
I have an NHD-2.4-240320CF-CTXI#F Display which I want to control with a Teensy3.6. I have set up the 8-bit parallel port and confirmed with a logic analysator that the bits and writes are ok from the Teensy. Yet, the display is just pure bright (background LEDs on) and the pixels never change. In a WAG I switched the PinPorts, maybe it was MSB/LSB swapped, but still no change.
Can anyone confirm the code is not the problem?
#define D0 12
#define D1 11
#define D2 13
#define D3 10
#define D4 9
#define D5 23
#define D6 22
#define D7 15
#define CS 14
#define WR 16
#define RD 17
#define RESET 18
#define DC 19
void setup() {
// put your setup code here, to run once:
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D4, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D7, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(WR, OUTPUT);
pinMode(RD, OUTPUT);
pinMode(DC, OUTPUT);
pinMode(RESET, OUTPUT);
display_init();
randomSeed(3000);
}
void loop() {
// put your main code here, to run repeatedly:
display_rainbow();
delay(200);
}
void display_rainbow(){
write_command(0x2C);
for(int i = 0; i < 76800; i++){
write_pixelInfo( (uint16_t) i);
}
}
void write_pixelInfo(uint16_t pixel){
write_data(pixel>>8);
write_data(pixel & 0xFF);
}
void write_command(uint8_t data){
digitalWriteFast(DC, LOW);
digitalWriteFast(CS, LOW);
digitalWriteFast(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *)(&GPIOC_PDOR)) = data;
digitalWriteFast(WR, HIGH);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(CS, HIGH);
}
void write_data(uint8_t data){
digitalWriteFast(DC, HIGH);
digitalWriteFast(CS, LOW);
digitalWrite(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *)(&GPIOC_PDOR)) = data;
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWrite(WR, HIGH);
digitalWriteFast(CS, HIGH);
}
void write_follow(uint8_t data){
digitalWriteFast(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *) (&GPIOC_PDOR)) = data;
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(WR, HIGH);
}
void display_init(){
digitalWriteFast(RESET, HIGH);
delay(10);
digitalWriteFast(RESET, LOW);
delay(10);
digitalWriteFast(RESET, HIGH);
delay(120);
write_command(0x11);
delay(100);
write_command(0x36);
write_data(0x80);
write_command(0x3A);
write_data(0x66);
write_command(0xB2);
write_data(0x0C);
write_data(0x0C);
write_data(0x00);
write_data(0x33);
write_data(0x33);
write_command(0xB7);
write_data(0x35);
write_command(0xBB);
write_data(0x2B);
write_command(0xC0);
write_data(0x2C);
write_command(0xC2);
write_data(0x01);
write_data(0xFF);
write_command(0xC3);
write_data(0x11);
write_command(0xC4);
write_data(0x20);
write_command(0xC6);
write_data(0x0F);//FRCTRL2: Frame Rate control in normal mode
write_command(0xD0);
write_data(0xA4);
write_data(0xA1);//PWCTRL1: Power Control 1
write_command(0xE0);
write_data(0xD0);
write_data(0x00);
write_data(0x05);
write_data(0x0E);
write_data(0x15);
write_data(0x0D);
write_data(0x37);
write_data(0x43);
write_data(0x47);
write_data(0x09);
write_data(0x15);
write_data(0x12);
write_data(0x16);
write_data(0x19);//PVGAMCTRL: Positive Voltage Gamma control
write_command(0xE1);
write_data(0xD0);
write_data(0x00);
write_data(0x05);
write_data(0x0D);
write_data(0x0C);
write_data(0x06);
write_data(0x2D);
write_data(0x44);
write_data(0x40);
write_data(0x0E);
write_data(0x1C);
write_data(0x18);
write_data(0x16);
write_data(0x19);//NVGAMCTRL: Negative Voltage Gamma control
write_command(0x2A);
write_data(0x00);
write_data(0x00);
write_data(0x00);
write_data(0xEF);
write_command(0x2B);
write_data(0x00);
write_data(0x00);
write_data(0x01);
write_data(0x3F);
write_command(0x3A);
write_data(0x55); //!!!SWAPPED FROM 66 to 55 - 16 bit per pixel
//******
write_command(0x11);
delay(120);
write_command(0x29);
write_command(0x2C);
delay(10);
}
Best regards,
Christoph
-
Hi Christoph,
Please make sure the initialization code is programmed correctly for the display.
Example code can be found on our website at this link: https://support.newhavendisplay.com/hc/en-us/articles/4413936008727--2-4-TFT-ST7789-Controller
Best Regards,0 -
Hello,
I managed to get the display to periodically switching the display on and off. It displays merely random pixels, but the same on every startup. Since the display on and display off commands do their bidding, I'm rather confident that the wiring and at least the command writing is correct.
I get a rather weird behaviour when trying to update the pixels with !any! value. It does not update the display in any color when writing constant values. The initial random pixels show up when i connect an logic analyzer to pin 12 (WRITE) and GND on startup. But then the synchronous on-and-off does not work, it just turns the display off for a very brief time and not 50%. When i take the LA off the adapter platine, it shows the random pixels with working 50% off-time.
I attached two photos of the "random" pixels, appearing wether the LA is connected when powering up or not.
The main code follows. In the loop it should draw the whole display black, but it is just the random displays appearing.#define D0 15
#define D1 22
#define D2 23
#define D3 9
#define D4 10
#define D5 13
#define D6 11
#define D7 12
#define CS 14
#define WR 16
#define RD 17
#define RESET 18
#define DC 19
void setup() {
// put your setup code here, to run once:
randomSeed(15000);
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D4, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D7, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(WR, OUTPUT);
pinMode(RD, OUTPUT);
pinMode(DC, OUTPUT);
pinMode(RESET, OUTPUT);
display_init();
display_rainbow();
write_command(0x29);
}
void loop() {
// put your main code here, to run repeatedly:
write_command(0x28);
delay(1000);
// display_rainbow();
write_command(0x2C);
for(int i = 0; i < 76800; i++){
write_data(0xFF);
write_data(0xFF);
}
write_command(0x29);
delay(1000);
Serial.println("Weiterer Durchlauf");
}
void display_rainbow(){
write_command(0x2C);
digitalWriteFast(DC, HIGH);
for(int i = 0; i < 76600; i++){
write_data((uint16_t) random(65000));
write_data((uint16_t) random(65000));
}
}
void write_command(uint8_t data){
digitalWriteFast(DC, LOW);
digitalWriteFast(CS, LOW);
digitalWriteFast(RD, HIGH);
digitalWriteFast(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *)(&GPIOC_PDOR)) = data;
digitalWriteFast(WR, HIGH);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(CS, HIGH);
}
void write_data(uint8_t data){
digitalWriteFast(DC, HIGH);
digitalWriteFast(CS, LOW);
digitalWriteFast(RD, HIGH);
digitalWrite(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *)(&GPIOC_PDOR)) = data;
digitalWrite(WR, HIGH);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(CS, HIGH);
}
void write_follow(uint8_t data){
digitalWriteFast(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *) (&GPIOC_PDOR)) = data;
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(WR, HIGH);
}
void display_init(){
digitalWriteFast(CS, LOW);
digitalWriteFast(RD, HIGH);
digitalWriteFast(WR, LOW);
digitalWriteFast(RESET, HIGH);
delay(10);
digitalWriteFast(RESET, LOW);
delay(100);
digitalWriteFast(RESET, HIGH);
delay(120);
write_command(0x11);
delay(100);
write_command(0x36);
write_data(0x80);
write_command(0x3A);
write_data(0x55);
write_command(0xB2);
write_data(0x0C);
write_data(0x0C);
write_data(0x00);
write_data(0x33);
write_data(0x33);
write_command(0xB7);
write_data(0x35);
write_command(0xBB);
write_data(0x2B);
write_command(0xC0);
write_data(0x2C);
write_command(0xC2);
write_data(0x01);
write_data(0xFF);
write_command(0xC3);
write_data(0x11);
write_command(0xC4);
write_data(0x20);
write_command(0xC6);
write_data(0x0F);//FRCTRL2: Frame Rate control in normal mode
write_command(0xD0);
write_data(0xA4);
write_data(0xA1);//PWCTRL1: Power Control 1
write_command(0xE0);
write_data(0xD0);
write_data(0x00);
write_data(0x05);
write_data(0x0E);
write_data(0x15);
write_data(0x0D);
write_data(0x37);
write_data(0x43);
write_data(0x47);
write_data(0x09);
write_data(0x15);
write_data(0x12);
write_data(0x16);
write_data(0x19);//PVGAMCTRL: Positive Voltage Gamma control
write_command(0xE1);
write_data(0xD0);
write_data(0x00);
write_data(0x05);
write_data(0x0D);
write_data(0x0C);
write_data(0x06);
write_data(0x2D);
write_data(0x44);
write_data(0x40);
write_data(0x0E);
write_data(0x1C);
write_data(0x18);
write_data(0x16);
write_data(0x19);//NVGAMCTRL: Negative Voltage Gamma control
write_command(0x2A);
write_data(0x00);
write_data(0x00);
write_data(0x00);
write_data(0xEF);
write_command(0x2B);
write_data(0x00);
write_data(0x00);
write_data(0x01);
write_data(0x3F);
delay(10);
}0 -
Hi Christoph,
For 8-bit Data mode, please confirm that the Teensy is wired to the TFT's data pins 22-29 for (DB8 to DB15) and the IMO pin 31 is is tied high.
Best Regards,0 -
Hello Ted,
yes, IMO pin 31 is tied to VCC and the pins 22 to 29 are the corresponding data pins on the teensy. Since the loop does turn the display on and off, I assume the parallel port is wired correct.
I just can't get the frame buffer to update via write_command(0x2C) and consecutive data-writes.
My loop-Function:void loop() {
// put your main code here, to run repeatedly:
write_command(0x28); ##THIS WORKS
delay(1000);
// display_rainbow();
write_command(0x2C); ##THIS DOES NOT WORK
for(int i = 0; i < 76800; i++){
write_data(0x3F); ##I changed 0x3A to 0x66 so three byte per pixel information
write_data(0x48); ##exact pixel value is not important, but this should get me a unicoloured full frame?
write_data(0x35);
}
write_command(0x29); ## THIS ALSO WORKS
delay(1000);
Serial.println("Weiterer Durchlauf");
}0 -
Hi everyone,
I found the solution. The null-commands during command and data write were not sufficent enough - i added four cycles after setting the port pins, now it works.
Thanks for your help!void write_command(uint8_t data){
digitalWriteFast(DC, LOW);
digitalWriteFast(CS, LOW);
digitalWriteFast(RD, HIGH);
digitalWriteFast(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *)(&GPIOC_PDOR)) = data;
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(WR, HIGH);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(CS, HIGH);
}
void write_data(uint8_t data){
digitalWriteFast(DC, HIGH);
digitalWriteFast(CS, LOW);
digitalWriteFast(RD, HIGH);
digitalWrite(WR, LOW);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
*((volatile uint8_t *)(&GPIOC_PDOR)) = data;
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWrite(WR, HIGH);
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
digitalWriteFast(CS, HIGH);
}0 -
Hi Christoph,
Its great to hear you have it working, thanks for the update!
Best Regards,0
Please sign in to leave a comment.
Comments
6 comments