高级会员
 
主题
帖子
积分119
阅读权限30
注册时间2013-4-18
最后登录1970-1-1
在线时间 小时
|
I had a devil of a time getting an Optrex F-51852 128x64 graphical display to initialize properly, so I'm posting the working code here in case anyone else runs into the same problems I did.
Optrex doesn't recommend using the internal charge pumps to create the LCD drive voltages for the NJU6676 controller. I am posting two different connections/methods of driving this display. The code is clearly commented as to which h/w layout each pertains to.
The 2.2 uF capacitors I used in the schematic are simply what I had on hand. Optrex recommends using these particular capacitors:
4.7uf, NACEW4R7M35V4X5.5TR13 MFG: NIC
1uf, UWX1H010MCR1GB MFG: NIC
For what it's worth, I've seen 'reference' designs that use 0.1 to 4.7 uF capacitors, so size doesn't seem to be an issue.
The connections are as follows:
To initialize the LCD, simply call:
Code:
glcd_init();
NOTE: Allow for a 100 millisecond delay after the PIC powers up before attempting the LCD init routine.
Here is the driver code, as tested using an 18F4680:
Code:
#define ON 1
#define OFF 0
#define YES 1
#define NO 0
struct lcd_pin_def
{
int data : 8;
};
#define LCD_WR PIN_B2
#define LCD_RD PIN_B3
#define LCD_RESET PIN_B4
#define LCD_A0 PIN_B5
#define set_tris_lcd(x) set_tris_c(x);
struct lcd_pin_def GLCD;
#byte GLCD = 0xf82 // port c on the 18f4680
void glcd_writeByte(int1 DI, int data);
void glcd_init(void);
void glcd_init(void) {
output_low(LCD_RESET); // hard reset
delay_us(20);
output_high(LCD_RESET);
delay_ms(100);
// init code for h/w connection METHOD 1
glcd_writeByte(0, 0xE2);
glcd_writeByte(0, 0xb0);
glcd_writeByte(0, 0x10);
glcd_writeByte(0, 0x00);
glcd_writeByte(0, 0xa1);
glcd_writeByte(0, 0x81); // contrast set
glcd_writeByte(0, 0x3f); // contrast set
glcd_writeByte(0, 0xaf);
glcd_writeByte(0, 0x2b);
delay_ms(50);
glcd_writeByte(0, 0xe7);
// note that with this method, the contrast is s/w adjustable
// init code for h/w connection METHOD 2
/*glcd_writeByte(0, 0xE2);
glcd_writeByte(0, 0xa2);
glcd_writeByte(0, 0xa1);
glcd_writeByte(0, 0xc0);
glcd_writeByte(0, 0x40);
glcd_writeByte(0, 0x28);
glcd_writeByte(0, 0xa4);
glcd_writeByte(0, 0xa6);
glcd_writeByte(0, 0xe7);
glcd_writeByte(0, 0xaf);*/
}
void glcd_writeByte(int1 DI, int data) {
if (DI) {
output_high(LCD_A0);
}
else {
output_low(LCD_A0);
}
set_tris_lcd(0x00);
GLCD.data = data;
delay_us(2);
output_low(LCD_WR);
delay_us(2);
output_high(LCD_WR);
set_tris_lcd(0xff);
}
转帖地址:http://www.ccsinfo.com/forum/viewtopic.php?t=30399
|
|