NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization
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,
-
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 -
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 -
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 -
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 -
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.
Comments
5 comments