看不清是JPdownload 还是IPdownload 在图最左上角
这个电路是用总线方式控制1602液晶显示屏,以AT89S52为核心
源程序
#i nclude<reg51.h> #i nclude<stdio.h> #i nclude<stdlib.h> #i nclude<intrins.h> #i nclude<absacc.h>
#define busy 0x80 file://用于检测LCD状态字中的Busy标识 #define RSaddr 0x1000 #define RWaddr 0x2000 #define CSaddr 0x0400
#define wc 0xcfff #define wd 0xdfff #define rc 0xefff
unsigned char code homepage[] = {"www.ispdown.com"}; unsigned char code email[] = {"ispdown@21cn.com"};
void delay5ms(void) { unsigned int TempCyc = 5552; while(TempCyc--); }
void delay400ms(void) { unsigned char TempCycA = 5; unsigned int TempCycB; while(TempCycA--) { TempCycB=7269; while(TempCycB--); }; }
void waitLcd() { char temp; bit flag=1; while(flag==1) {
temp=XBYTE[rc]; if (temp>>7==0) flag=0; P1=temp; } P1=0xff; }
void WC_Lcd(bit isCheck,char c) { if (isCheck==1) waitLcd();
XBYTE[wc]=c; }
void WD_Lcd(char c) { waitLcd();
XBYTE[wd]=c; }
void LcdInit() { delay5ms(); delay5ms(); delay5ms(); WC_Lcd(0,0x38);
delay5ms(); WC_Lcd(0,0x38); delay5ms(); WC_Lcd(0,0x38); delay5ms();
WC_Lcd(1,0x38); WC_Lcd(1,0x08); WC_Lcd(1,0x01); WC_Lcd(1,0x06); // 显示光标移动设置 WC_Lcd(1,0x0C); // 显示开及光标设置 }
void displayOneChar(unsigned char X, unsigned char Y, unsigned char DData) { Y &= 0x1; X &= 0xF; if (Y) X |= 0x40; X |= 0x80; WC_Lcd(0,X); WD_Lcd(DData); }
void displayListChar(unsigned char X, unsigned char Y, unsigned char code *DData) { unsigned char ListLength;
ListLength = 0; Y &= 0x1; X &= 0xF; while (DData[ListLength]>0x20) { if (X <= 0xF) { displayOneChar(X, Y, DData[ListLength]); ListLength++; X++; } } }
void main(void) { delay400ms(); LcdInit();
displayListChar(0, 0, homepage); displayListChar(0, 1, email);
while(1); }
|