#include <reg52.h>
# define uchar unsigned char
# define uint unsigned int
# define ulong unsigned long
sbit LCD_RS=P1^0;
sbit LCD_RW=P1^1;
sbit LCD_EN=P1^2;
sbit Q0=P2^0; //計數器0位
sbit Q1=P2^1; //計數器1位
sbit Q2=P2^2; //計數器2位
sbit Q3=P2^3; //計數器3位
sbit Q4=P2^4; //計數器4位
sbit Q5=P2^5; //計數器5位
sbit Q6=P2^6; //計數器6位
sbit Q7=P2^7; //計數器7位
sbit kaishi=P3^0; //頻率計數的邏輯開關
sbit qingling=P3^1; //計數器清零信號端
sbit s0=P1^3; //待機功能鍵
sbit s1=P1^4; //測頻率功能鍵
sbit s2=P1^5; //測周期功能鍵
sbit s3=P1^6; //測占空比功能鍵
sbit led1=P3^2; //功能指示燈
sbit led2=P3^4;
sbit led3=P3^6;
sbit t1in=P3^3; //測占空比信號的輸入引腳
sbit lcden=P3^5;
//uchar code table1[]={" Welcome "};
uchar i,table[10],q0,q1,q2,q3,q4,q5,q6,q7,table2[9],
table1[]={"welcome"},dis[5],T0num,T1num,th1,tl1;
uint num,bizhi;
ulong pinglv,time1,time0;
bit zq=0; //頻率周期標志位
void delay(uint time)
{
uint i,j;
for(i=time;i>0;i--)
for(j=110;j>0;j--);
}
void write_com(uchar com)
{
LCD_RS=0;
LCD_RW=0;
P0=com;
delay(2);
LCD_EN=1;
delay(2);
LCD_EN=0;
}
void write_date(uchar date)
{
LCD_RS=1;
LCD_RW=0;
P0=date;
delay(2);
LCD_EN=1;
delay(2);
LCD_EN=0;
}
void LCD_init()
{
write_com(0x38);
write_com(0x0c);
write_com(0x01);
}
|