现在正在对一块ST7920的LCD进行编程,可是程序烧写后,无论如何,LCD都没有反应,只有背光,下面是与LCD相关的程序,请各位高人帮忙指点迷津,谢谢。
#define StartLCMData PORTA |= 0X10 #define StopLCMData PORTA &= 0XEF #define LCMParaMode PORTF |= 0X20 #define LCMInstruction PORTF &= 0XF7 #define LCMData PORTF |= 0X08 #define LCMWrite PORTF &= 0XEF #define LCMRead PORTF |= 0X10 #define StartResetLCM PORTF &= 0XBF #define StopResetLCM PORTF |= 0X40
void InitializeLCM(void) { unsigned int i = 0; StartResetLCM; for(i=0;i<=400;i++) { Delay(); } StopResetLCM; Delay(); DisableLatch; LCMParaMode; LCMWriteCommand(0X30); //功能设定 LCMWriteCommand(0X30); //根据ST7920手册,再次功能设定 LCMWriteCommand(0X02); //位址归位 LCMWriteCommand(0X0C); //显示状态设定 LCMWriteCommand(0X01); //清屏 LCMWriteCommand(0X06); //进入点设定 LCMWriteCommand(0X80); //设定DDRAM地址 return; }
void LCMWriteCommand(unsigned char command) { unsigned int i; LCMInstruction; LCMWrite; StartLCMData; PORTB = command;
Delay(); if((0x01 == portb)&&(0x00 == portg)) { for(i=0;i<=20;i++) { Delay(); } } StopLCMData; return; }
void LCMWriteData(unsigned char data) { LCMData; LCMWrite;
PORTB = data; StartLCMData; Delay(); StopLCMData; return; }
void main() { InitializeLCM(); LCMWriteData(0x41); //显示"A" while(1) {;} } |