新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機頻率計Proteus仿真設(shè)計(帶程序電路)

51單片機頻率計Proteus仿真設(shè)計(帶程序電路)

作者: 時間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
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;

本文引用地址:http://m.butianyuan.cn/article/201612/324329.htm

#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!=