有电路图和程序,电路是isis的,程序是uv3的,仿真工程文件下载:http://www.51hei.com/f/dgnplj.rar 下面是程序源代码:
#include
#include
#include
//端口定义
sbit LCDRS = P3^5;
sbit LCDRW = P3^6;
sbit LCDEN = P3^7;
sbit LCDBF = P2^7;
#define DBPORT 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
#define LCD_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 Fctrl P0_3
#define Tctrl P0_4
#define Distc P0_5
#define Width P0_6
#define Cut P0_7
#define Stop P1_6
#define Clrs P1_7
#define Enex P3_0
#define Disall P0=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 Backb P1_3
#define Backc P1_4
#define BackLight P1_0
unsigned char sbuffer[15],w[5];
unsigned char contrast=5;
unsigned long value=0,copyer=0,wvalue=0;
bit IsFreq=1;
bit IsLow=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!='