NHD-4.3-480800EF-CTXP#-T - HX8369 continious memory write problem

Comments

3 comments

  • Michael_L

    I'm not 100% sure on how you are writing to the display, however, the below example code will serve as a great reference for you as it has been tested to work:

    //---------------------------------------------------------
    /*
    NHD_4_3_480800EF_CTXP_mega.ino
    Program for writing to Newhaven Display 4.3” TFT with HX8369 controller

    (c)2014 Mike LaVine - Newhaven Display International, LLC.

            This program is free software; you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation; either version 2 of the License, or
            (at your option) any later version.

            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.
    */
    //---------------------------------------------------------

    // The lower 8 bits of the 16 bit data bus are connected to PORTA of the Arduino Mega2560
    // The upper 8 bits of the 16 bit data bus are connected to PORTC of the Arduino Mega2560
    // 5V voltage regulator on Arduino Mega has been replaced with a 3.3V regulator to provide 3.3V logic


    int DC  = 38;          // D/C signal connected to Arduino digital pin 38
    int WR  = 39;          // /WR signal connected to Arduino digital pin 39
    int RD  = 40;          // /RD signal connected to Arduino digital pin 40
    int RES = 41;          // /RES signal connected to Arduino digital pin 41

    // /CS signal tied to ground
    // BLPWM signal is a No Connect

    //****************************************//
    void comm_out(unsigned char command)
    {
        digitalWrite(DC, LOW);
        PORTA = command;
        digitalWrite(WR, LOW);
        digitalWrite(WR, HIGH);
    }

    void data_out(unsigned char data)
    {
        digitalWrite(DC, HIGH);
        PORTA = data;
        digitalWrite(WR, LOW);
        digitalWrite(WR, HIGH);
    }

    void data_out_16bit(unsigned int data)
    {
         //digitalWrite(DC, HIGH);
         PORTA = data;
         PORTC = (data>>8);
         digitalWrite(WR, LOW);
         digitalWrite(WR, HIGH);
    }
    //========================================//
    // Initialize controller
    //========================================//
    void Init_HX8369A()
    {
            digitalWrite(RD, HIGH);
            digitalWrite(RES, HIGH);
    delay(120);
    digitalWrite(RES, LOW);     //HW reset
    delay(120);
    digitalWrite(RES, HIGH);
    delay(120);

    comm_out(0xB9);     //Enter Extension Command
    data_out(0xFF);     //Followed by 3 extension parameters
    data_out(0x83);
    data_out(0x69);

            comm_out(0xB1);     //Set Power
    data_out(0x01);   
            data_out(0x00);   
            data_out(0x34);     
            data_out(0x06);   
            data_out(0x00);   
            data_out(0x0F);   
            data_out(0x0F);   
            data_out(0x2A);   
            data_out(0x32);   
            data_out(0x3F);   
            data_out(0x3F);   
            data_out(0x07);   
            data_out(0x23);   
            data_out(0x01);   
            data_out(0xE6);   
            data_out(0xE6);   
            data_out(0xE6);   
            data_out(0xE6);   
            data_out(0xE6);

            comm_out(0xB2);     //Set Display
    data_out(0x00);   
            data_out(0x20);   
            data_out(0x0A);   
            data_out(0x0A);   
            data_out(0x70);   
            data_out(0x00); 
            data_out(0xFF); 
            data_out(0x00);   
            data_out(0x00);   
            data_out(0x00); 
            data_out(0x00);   
            data_out(0x03);   
            data_out(0x03); 
            data_out(0x00); 
            data_out(0x01);
           
            comm_out(0xB4);             //Set display column inversion
            data_out(0x00);   
            data_out(0x18);   
            data_out(0x80);   
            data_out(0x10);   
            data_out(0x01);   

            comm_out(0xB6);     //Set VCOM
    data_out(0x2C);   
    data_out(0x2C);   

            comm_out(0xD5);             //set GIP
            data_out(0x00);   
            data_out(0x05);   
            data_out(0x03);   
            data_out(0x00);   
            data_out(0x01);   
            data_out(0x09);   
            data_out(0x10);   
            data_out(0x80);   
            data_out(0x37);   
            data_out(0x37);   
            data_out(0x20);   
            data_out(0x31);   
            data_out(0x46); 
            data_out(0x8A);   
            data_out(0x57);   
            data_out(0x9B);   
            data_out(0x20);   
            data_out(0x31);   
            data_out(0x46);   
            data_out(0x8A);   
            data_out(0x57);   
            data_out(0x9B);   
            data_out(0x07);   
            data_out(0x0F);   
            data_out(0x02);   
            data_out(0x00);

    comm_out(0xE0);   //Gamma
    data_out(0x00);       
    data_out(0x08);       
    data_out(0x0D);       
    data_out(0x2D);       
    data_out(0x34);   
    data_out(0x3F);       
    data_out(0x19);       
    data_out(0x38);       
    data_out(0x09);       
    data_out(0x0E);
    data_out(0x0E);       
    data_out(0x12);       
    data_out(0x14);       
    data_out(0x12);       
    data_out(0x14);
    data_out(0x13);
    data_out(0x19);       
    data_out(0x00);       
    data_out(0x08);       
    data_out(0x0D);       
    data_out(0x2D);
    data_out(0x34);       
    data_out(0x3F);       
    data_out(0x19);       
    data_out(0x38);       
    data_out(0x09);
    data_out(0x0E);
    data_out(0x0E);       
    data_out(0x12);       
    data_out(0x14);       
    data_out(0x12);       
    data_out(0x14);
    data_out(0x13);       
    data_out(0x19);   
         
            comm_out(0x3A);    //Interface pixel format
    data_out(0x77);    //3bytes per pixel

            comm_out(0x36);            //MADCTL
            data_out(0x80);

            comm_out(0x11);            //exit sleep mode
            delay(120);
           
    comm_out(0x29);    //Display ON
            delay(10);     
    }
    //=====================================================//
    void WindowSet(unsigned int s_x,unsigned int e_x,unsigned int s_y,unsigned int e_y)
    {
    comm_out(0x2a); //SET column address
    digitalWrite(DC, HIGH);
    data_out((s_x)>>8); //SET start column address=0
    data_out(s_x);
    data_out((e_x)>>8); //SET end column address=479
    data_out(e_x);

    comm_out(0x2b); //SET page address
    digitalWrite(DC, HIGH);
    data_out((s_y)>>8); //SET start page address=0
    data_out(s_y);
    data_out((e_y)>>8); //SET end page address=779
    data_out(e_y);
    }
    //*****************************************************//
    //*****************************************************//
    void setup()                                   
    {
            pinMode(DC, OUTPUT);          //set digital pin 38 as output
            pinMode(WR, OUTPUT);          //set digital pin 39 as output
            pinMode(RD, OUTPUT);          //set digital pin 40 as output
            pinMode(RES, OUTPUT);          //set digital pin 41 as output
            digitalWrite(DC, LOW);
            digitalWrite(WR, LOW);
            digitalWrite(RD, LOW);
            digitalWrite(RES, LOW);
            DDRA = 0xFF;                  //set PORTA as output
            DDRC = 0xFF;                  //set PORTC as output
    PORTA = 0;
            PORTC = 0;
            Init_HX8369A();               //initialize the HX8369 controller
    }
    void loop()
    {
             for(int c=0;c<3;c++)
             {
               switch(c)
               {
                 case 0 : WindowSet(0x0000,0x01df,0x0000,0x031f);    //set start/end column and page addresses
                          comm_out(0x2C);                            //command to write to frame memory
                          digitalWrite(DC, HIGH);
                          for(int j=0;j<800;j++)                     //fill display with red pixels
                          {
                            for(int k=0;k<240;k++)
                            {
                              data_out_16bit(0xFF00);
                              data_out_16bit(0x00FF);
                              data_out_16bit(0x0000);
                            }
                          }
                          break;
                  case 1 : WindowSet(0x0000,0x01df,0x0000,0x031f);    //set start/end column and page addresses
                           comm_out(0x2C);                            //command to write to frame memory
                           digitalWrite(DC, HIGH);
                           for(int j=0;j<800;j++)                     //fill display with green pixels
                           {
                             for(int k=0;k<240;k++)
                             {
                               data_out_16bit(0x00FF);
                               data_out_16bit(0x0000);
                               data_out_16bit(0xFF00);
                             }
                           }
                           break;
                  case 2 : WindowSet(0x0000,0x01df,0x0000,0x031f);    //set start/end column and page addresses
                           comm_out(0x2C);                            //command to write to frame memory
                           digitalWrite(DC, HIGH);
                           for(int j=0;j<800;j++)                     //fill display with blue pixels
                           {
                             for(int k=0;k<240;k++)
                             {
                               data_out_16bit(0x0000);
                               data_out_16bit(0xFF00);
                               data_out_16bit(0x00FF);
                             }
                           }
                           break;
                  default: break;
               }
             }
    }

     

    0
  • Henning_S

    Thanks for your code! Unfortunately this didn't work for me, but I had confirmation that I was using the right commands.

    This lead to some more testing and I was finally able to get it to work.
    The problem seemed to be that the used interface is too fast for continious GRAM data write. I added some NOPs after each data write to delay the next write and now the display is showing the sent pixel data.
    I'm using a STM32F2 microcontroller and writing to the display via the FSMC (memory controller) 16 bit data interface und using the lowest address bit as command/data control signal.
    What's strange is that during initialization I write to the display's LUT for color conversion (command 0x2D followed by 192 consecutive bytes as data) and there all data is received correctly, without an extra delay. There seems to be a slower timing for GRAM access than register access contrary to the datasheet information where register access has a 100 ns write cycle and GRAM 33 ns write cycle in SLPOUT.

    0
  • Henning_S

    Update: I tested all of this with a second display, with which there were no problems. No additional delays were needed and everything worked as expected. So it seems that the display I first used had some error in the controller.

    0

Please sign in to leave a comment.