我编的程序 用c8051f120点亮LCD 为啥不能显示呢,以下是我的程序
#include <C8051F120.H>
unsigned long x; //"wwwxhlcomcn"
unsigned char xdata Netdata[16]={0x77,0x77,0x77,0x2e,0x78,0x68,0x6c,0x2e,0x63,0x6f,
0x6d,0x2e,0x63,0x6e};
//" BT F020 V1.0 "
unsigned char xdata NCDdata[17]={0x20,0x20,0x42,0x54,0x20,0x46,0x30,0x32,0x30,0x20,
0x56,0x31,0x2e,0x30,0x20,0x20};
unsigned char *lcdpoint;
unsigned char lcd_data_count;
void SYSCLK_Init (void);
void PORT_Init (void);
void LCD_Init(void);
void main (void)
{
static unsigned char data1;
WDTCN = 0xde;
WDTCN = 0xad;
SYSCLK_Init ();
PORT_Init ();
while(1){
LCD_Init();
P2 = 0xA0;
for(x=0;x<5000;x++);
lcdpoint=&NCDdata;
for(lcd_data_count=14;lcd_data_count>0;lcd_data_count--
{
data1=*lcdpoint;
P3 = data1;
P2 = 0X20;
P2 = 0XA0;
lcdpoint++;
for(x=0;x<5000;x++);
}
P2 = 0X80;
P3 = 0xc0;
P2 = 0x00;
P2 = 0x80;
for(x=0;x<1000;x++);
lcdpoint=&Netdata;
for(lcd_data_count=14;lcd_data_count>0;lcd_data_count--
{
data1=*lcdpoint;
P3 = data1;
//-----------------------------------------------------
// P2 = 0x20;
// P2 = 0xA0;
//-----------------------------------------------------
P2 = 0xA0;
P2 = 0x20;
//------------------------------------------------------/
lcdpoint++;
for(x=0;x<5000;x++);
}
}
}
void SYSCLK_Init (void)
{
// int i; // delay counter
// OSCXCN = 0x67; // start external oscillator with
// // 22.1184MHz crystal
// for (i=0; i < 256; i++) ; // Wait for osc. to start up
// while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
// OSCICN = 0x88;
OSCICN = 0x05;
}
void PORT_Init (void)
{
SFRPAGE = CONFIG_PAGE;
XBR0 = 0x00; // ûóDÑ¡Ôñêy×Öíaéè
XBR2 = 0x40;
P2MDOUT = 0xe0; // P2¿úéèÎaíÆíì·½ê½
}
void LCD_Init(void)
{
P2 = 0X80;
for(x=0;x<50000;x++);
//P7 = 0x30; /*ò»DDÏÔê¾*/
P3 = 0x38; /*á½DDÏÔê¾*/
P2 = 0X00;//0x08;
P2 = 0X80;//0x09;
for(x=0;x<1000;x++);
P3 = 0x0e;
P2 = 0x00;
P2 = 0x80;
for(x=0;x<1000;x++);
P3= 0x06;
P2 = 0x00;
P2 = 0x80;
for(x=0;x<5000;x++);
P3 = 0x01;
P2 = 0x00;
P2 = 0x80;
for(x=0;x<5000;x++);
}
|