Proteus仿真电路图如下:(下载仿真文件后有明晰图)
有电路图和程序,电路是isis的,程序是uv3的,仿真工程文件下载:http://www.51hei.com/f/dgnplj.rar 下面是程序源代码:
#include
#include
#include
//端口界说
sbitLCDRS = P3^5;
sbit LCDRW = P3^6;
sbit LCDEN = P3^7;
sbitLCDBF = P2^7;
#defineDBPORT P2
#define DIS_CURS_OFF 0x0c
#define LCD_CLRS 0x01
#define DIS_HIDE 0x08
#define LCD_INIT 0x38
#define LCD_HOME 0x02
#define LCD_DATA 1
#defineLCD_COMMAND 0
#define LCD_READ 1
#define LCD_WRITE 0
#define K1 6
#define K2 5
#define K3 4
#define K4 3
#define K5 2
#define K6 1
#define K7 0
#define FctrlP0_3
#define TctrlP0_4
#define DistcP0_5
#define WidthP0_6
#defineCutP0_7
#define StopP1_6
#define ClrsP1_7
#define EnexP3_0
#define DisallP0=0xff;P1=0xff
#define StopCount P1_6=0
#define StarCount P1_6=1
#define ClrsCount P1_7=0;_nop_();P1_7=1
#define ClrsDff P1_2=0;_nop_();P1_2=1
#define BackbP1_3
#define BackcP1_4
#define BackLight P1_0
unsigned char sbuffer[15],w[5];
unsigned char contrast=5;
unsignedlongvalue=0,copyer=0,wvalue=0;
bit IsFreq=1;
bitIsLow=1;
void lcd_wait();
void lcd_command(unsigned char command);
void lcd_putchar(unsigned char character);
void lcd_moveto(unsigned char x, unsigned char y);
void lcd_print(unsigned char *str);
void delay1s();
void high_init();
void key_delay();
void key_jud();
void low_init();
void width_init();
void depart_w();
void intrT2();
void width_get();
void count();
void count_init();
void low_get();
void show_high_t();
void show_high_f();
void show_low_t();
void show_low_f();
void intr0();
void intr1();
void high_get();
void contrast_handle();
void install();
void lcd_init();
void lcd_wait()
{
LCDEN=0;
DBPORT=0xff;
LCDRS=LCD_COMMAND;
LCDRW=LCD_READ;
LCDEN=1;_nop_();
while(LCDBF)
{LCDEN=0;_nop_();
LCDEN=1;_nop_();
}
LCDEN=0;
}
void lcd_command(unsigned char command)
{
lcd_wait();
LCDRS=LCD_COMMAND;
LCDRW=LCD_WRITE;
DBPORT=command;
LCDEN=1;_nop_();
LCDEN=0;
}
void lcd_putchar(unsigned char character)
{
lcd_wait();
LCDRS=LCD_DATA;
LCDRW=LCD_WRITE;
DBPORT=character;
LCDEN=1;_nop_();
LCDEN=0;
}
void lcd_moveto(unsigned char x, unsigned char y)
{
if(x==0)
lcd_command(0x80|y);
if(x==1)
lcd_command(0xc0|y);
}
void lcd_print(unsigned char *str)
{
while(*str!=)
{lcd_putchar(*str);
str++;
}
}
void delay1s()
{
unsigned char i,j,k;
for(i=0;i<255;i++)
for(j=0;j<103;j++)
for(k=0;k<11;k++);
for(k=0;k<216;k++);
_nop_();
}
void high_init()
{
EA=0;
Disall;
Fctrl=0;
TMOD=0x05;
TR0=1;
StopCount;
ClrsCount;
TL0=0;
TH0=0;
}