#include <c8051f020.h>
unsigned long x;
unsigned char xdata Netdata[16]={0x77,0x77,0x77,0x2e,0x78,0x68,0x6c,0x2e,0x63,0x6f,
0x6d,0x2e,0x63,0x6e};
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;//10100000 RS="1";
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;//00100000 RS="1";RW=0;E=0;
P2 = 0XA0;//10100000 RS="1";RW=0;E=1;
lcdpoint++;
for(x=0;x<5000;x++); //delay
}
P2 = 0X80; //10000000 RS="0";RW=0;E=1;
P3 = 0xc0; //11000000 RS="0";RW=1;E=1;
P2 = 0x00; //00000000 RS="0";RW=0;E=1;
P2 = 0x80; //10000000 RS="0";RW=0;E=1;
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 = 0xA0; //10100000 RS="1"; RW="0"; E="1";
P2 = 0x20; //00100000 RS="1";RW=0;E=0;
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)
{
XBR0 = 0x00;
XBR2 = 0x40;
P2MDOUT = 0xe0;
}
void LCD_Init(void)
{
P2 = 0X80; //10000000 RS="0";RW=0;E=1;
for(x=0;x<50000;x++);
//P7 = 0x30;
P3 = 0x38;
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++);
}
文章评论(0条评论)
登录后参与讨论