NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization

Comments

5 comments

  • Michael_L

    I have shared some code for this display below, please review the write routines and how to display an image on the screen and verify you are doing this in your program.
    Also, please ensure your interface selection pins are configured correctly.

    void comm_out(char c)
    {
      int i;
      digitalWrite(CS, LOW);
      digitalWrite(AO, LOW);
      for(i=0;i<8;i++)
      {
        if((c&0x80) == 0x80)
        {
          PORTA |= 0x80;
          PORTA &= ~0x40;
          PORTA |= 0x40;
        }
        else
        {
          PORTA &= ~0x80;
          PORTA &= ~0x40;
          PORTA |= 0x40;
        }
        c = c<<1;
      }
      digitalWrite(CS, HIGH);
      digitalWrite(AO, HIGH);
    }

    void data_out(unsigned char d)
    {
      int i;
      digitalWrite(CS, LOW);
      //digitalWrite(AO, HIGH);
      for(i=0;i<8;i++)
      {
        if((d&0x80) == 0x80)
        {
          PORTA |= 0x80;
          PORTA &= ~0x40;
          PORTA |= 0x40;
        }
        else
        {
          PORTA &= ~0x80;
          PORTA &= ~0x40;
          PORTA |= 0x40;
        }
        d = d<<1;
      }
      digitalWrite(CS, HIGH);
    }
    void disp1(unsigned char pic[1024])
    {
    unsigned int a, i;
    unsigned char page = 0xB0;
            unsigned int x = 0;
           
    for(i=0;i<8;i++)
    {

    comm_out(page);
    comm_out(0x10);
    comm_out(0x00);
    for (a=0;a<128;a++)
    {
      data_out(pic[(a+x)]);
    }
                     x+=128;
     page++;
    }
    }
    void setup(){
      pinMode(RES, OUTPUT);
      digitalWrite(RES, LOW);
      delay(120);
      digitalWrite(RES, HIGH);
      pinMode(CS, OUTPUT);
      pinMode(AO, OUTPUT);
      DDRA = 0xFF;
      PORTA = 0xFF;
      digitalWrite(CS, HIGH);
      digitalWrite(AO, HIGH);
     
      comm_out(0xA2);  //added 1/9 bias
      comm_out(0xA0);   //ADC segment driver direction (A0=Normal)
      comm_out(0xC8);   //added
      comm_out(0xC0);   //COM output scan direction (C0=Normal)
      comm_out(0x40);   //Operating Mode
      comm_out(0x25);   //resistor ratio
      comm_out(0x81);   //electronic volume mode set
      comm_out(0x19);   //electronic volume registerset
      comm_out(0x2F);   //power control set
      comm_out(0xAF);   //displayON/OFF ‐ set to ON
    }

     

    0
  • facotl

    Hello,
    I ported code on mbed for test and it doesn t work. I have blue backlight on if i call disp1 in while, and blue disapear if i just call disp1 before while.

    #include "mbed.h"


    DigitalOut mosi(PC_12);
    DigitalOut sclk(PC_10);
    DigitalOut cs(PA_13);
    DigitalOut rst(PA_14);
    DigitalOut a0(PC_3);


    void comm_out(char c)
    {
      int i;
      cs = 0; //digitalWrite(CS, LOW);
      a0 = 0;//digitalWrite(AO, LOW);
      wait(0.000001);
      for(i=0;i<8;i++)
      {
        if((c&0x80) == 0x80)
        {
          mosi = 1;
          sclk = 0;
          wait(0.000001);
          sclk = 1;
          wait(0.000001);
        }
        else
        {
          mosi = 0;
          sclk = 0;
          wait(0.000001);
          sclk = 1;
          wait(0.000001);
        }
        c = c<<1;
      }
      cs = 1; //digitalWrite(CS, HIGH);
      a0 = 1; //digitalWrite(AO, HIGH);
      wait(0.000001);
    }

    void data_out(unsigned char d)
    {
      int i;
      cs = 0; //digitalWrite(CS, LOW);
      //digitalWrite(AO, HIGH);
      wait(0.000001);
      for(i=0;i<8;i++)
      {
        if((d&0x80) == 0x80)
        {
          mosi = 1;
          sclk = 0;
          wait(0.000001);
          sclk = 1;
          wait(0.000001);
        }
        else
        {
          mosi = 0;
          sclk = 0;
          wait(0.000001);
          sclk = 1;
          wait(0.000001);
        }
        d = d<<1;
      }
      cs = 1; //digitalWrite(CS, HIGH);
      wait(0.000001);
    }
    void disp1(unsigned char pic[1024])
    {
        unsigned int a, i;
        unsigned char page = 0xB0;
        unsigned int x = 0;
           
        for(i=0;i<8;i++)
        {
           
            comm_out(page);
            comm_out(0x10);
            comm_out(0x00);
            for (a=0;a<128;a++)
            {
                data_out(pic[(a+x)]);
            }
                     x+=128;
             page++;
        }
    }
    void screen_init(){
      //pinMode(RES, OUTPUT);
      //digitalWrite(RES, LOW);
      rst = 0;
      //delay(120);
      wait(0.120);
      //digitalWrite(RES, HIGH);
      rst = 1;
      //pinMode(CS, OUTPUT);
      //pinMode(AO, OUTPUT);
      //DDRA = 0xFF;
      //PORTA = 0xFF;
      //digitalWrite(CS, HIGH);
      //digitalWrite(AO, HIGH);
      cs = 1;
      a0 = 1;
     
      comm_out(0xA2);  //added 1/9 bias
      comm_out(0xA0);   //ADC segment driver direction (A0=Normal)
      comm_out(0xC8);   //added
      comm_out(0xC0);   //COM output scan direction (C0=Normal)
      comm_out(0x40);   //Operating Mode
      comm_out(0x25);   //resistor ratio
      comm_out(0x81);   //electronic volume mode set
      comm_out(0x19);   //electronic volume registerset
      comm_out(0x2F);   //power control set
      comm_out(0xAF);   //displayON/OFF ‐ set to ON
    }



    int main()
    {
        screen_init();
     
        unsigned char pic[1024];
       
        for (int i = 0; i < 1024; i++)
        {
            if (((i >> 4) & 0x00000001) > 0)
            {
                pic = 0xFF;
            }
            else
            {
                pic = 0x00;
            }
        }
       
        while(1) {
             disp1(pic);
     
     
        }
    }

     

    0
  • facotl
    When i say doesn t work it s nothing on screen.

    Can screen have been broken with a bad value of "V5 Voltage Regulator Internal Resistor Ratio Set" ?
    0
  • facotl

    Ok i found sorry.

    NHD to MPU schematic is with 1 on left (view from screen side) and i imagined it was bottom side.

    0
  • Paul_B

    Morning Facotl,

    Correct pin 1 starts from the left hand side, glad to hear your display is up and running  :)

    0

Please sign in to leave a comment.