Author Topic: NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization  (Read 3738 times)

BMohlman

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
« on: March 31, 2015, 10:41:06 AM »
Hello,
 I have on of the above displays connected to a Kinetis K63F freedom board via SPI with I/O to the /RST and A0 inputs. I am running the SPI at 2MHz and I can't seem to get anything on the display. Here is my init routine: (hex value in the comments)

void GLCDInit(void)
{
     // toggle RST low to reset;
      OLED_Reset();
      WAIT1_Waitms(100);
      OLED_WriteCmd(CMD_DISPLAY_OFF);            // Turn Display Off
      OLED_WriteCmd(CMD_SET_ADC_NORMAL);         // ADC select       ----->   0xA0
      OLED_WriteCmd(CMD_SET_DISP_NORMAL);         // Segment select   ----->  0xA6

      OLED_WriteCmd(CMD_SET_COM_NORMAL);         // 0xC0
      OLED_WriteCmd(CMD_SET_BIAS_9);            // 0xA2
      //OLED_WriteCmd(CMD_SET_BIAS_7);
      OLED_WriteCmd(CMD_SET_DISP_START_LINE);      // Initial display line ----> 0x40
      OLED_WriteCmd(CMD_SET_PAGE);            // 0xB0
      OLED_WriteCmd(CMD_SET_VOLUME_FIRST);      // 0x81
      OLED_WriteCmd(CMD_SET_VOLUME_SECOND);      // 0x20
      OLED_WriteCmd(CMD_SET_POWER_CONTROL | 0x4);   // turn on voltage converter (VC=1, VR=0, VF=0) 0x2C
      WAIT1_Waitms(50);                     // wait for 50% rising
      OLED_WriteCmd(CMD_SET_POWER_CONTROL | 0x6);   // turn on voltage regulator (VC=1, VR=1, VF=0) 0x2E
      WAIT1_Waitms(50);
      OLED_WriteCmd(CMD_SET_POWER_CONTROL | 0x7);   // turn on voltage follower (VC=1, VR=1, VF=1) 0x2F
      WAIT1_Waitms(10);
        OLED_WriteCmd(CMD_SET_RESISTOR_RATIO | 0x07);// set lcd operating voltage (regulator resistor, ref voltage resistor)
      OLED_WriteCmd(CMD_SET_ALLPTS_ON);         // Display ON Testing ****** Doesn't work 0xA5
      OLED_WriteCmd(CMD_DISPLAY_ON);            // Display ON 0xAF
}
  Display is always blank, I have scoped the SPI and I/O and the look correct. I have tried several different versions of init values to no avail. I have a NewHaven 2.7 OLED that I can plug into the same port and it works with no problems. (Same SPI and I/O)  Any help would be greatly appreciated.

Thanks,


Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
« Reply #1 on: April 03, 2015, 01:30:46 PM »
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.

Code: [Select]
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
}

facotl

  • Newbie
  • *
  • Posts: 8
  • Karma: 2
    • View Profile
Re: NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
« Reply #2 on: January 13, 2016, 01:40:30 AM »
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);
 
 
    }
}

facotl

  • Newbie
  • *
  • Posts: 8
  • Karma: 2
    • View Profile
Re: NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
« Reply #3 on: January 13, 2016, 01:50:36 AM »
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" ?

facotl

  • Newbie
  • *
  • Posts: 8
  • Karma: 2
    • View Profile
Re: NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
« Reply #4 on: January 13, 2016, 03:31:29 AM »
Ok i found sorry.

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


Paul_B

  • Administrator
  • Sr. Member
  • *****
  • Posts: 248
  • Karma: 16
    • View Profile
Re: NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
« Reply #5 on: January 13, 2016, 07:44:16 AM »
Morning Facotl,

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

 

NHD-C12864A1Z-FSRGB-FBW-HT1 boost speed (clear to black and black to clear)

Started by facotlBoard Graphic LCDs

Replies: 4
Views: 2455
Last post January 27, 2016, 10:18:45 AM
by facotl
Use of Timing characteristics in the initialization code of the display

Started by ShabdaBoard TFTs

Replies: 1
Views: 2818
Last post May 20, 2014, 08:00:39 AM
by Michael_L
Initialization code for M0220SD-202SDAR1 module??

Started by Javier OrtizBoard Vacuum Fluorescent Displays

Replies: 1
Views: 2400
Last post November 17, 2015, 05:12:51 PM
by Saurabh_B
NHD-14432WG-BTFH-V#T Datasheet's Initialization Code

Started by Terence DBoard Graphic LCDs

Replies: 2
Views: 547
Last post May 26, 2017, 05:54:45 PM
by Terence D
NHD-320240WG-BxTGH-VZ#-3VR initialization sequence

Started by wbealsBoard Graphic LCDs

Replies: 6
Views: 2561
Last post June 01, 2016, 11:39:03 AM
by Saurabh_B