https://static.assets-stash.eet-china.com/album/old-resources/2008/10/28/a831f82a-a6eb-4bcc-9c40-2db482d64957.rarLCD1602频率计数器
#include<reg52.h>
#include<intrins.h>
#include"LCD1602_8.H"
unsigned char k[8];
unsigned int num;
unsigned char i;
unsigned long x,t;
void main(void)
{
lcd_init();
TMOD=0x25; //T0计数 T1定时
TH0=0x00; //计数值清零
TL0=0x00;
TH1=0x06; //250us
TL1=0x06;
/* ET0=1;
ET1=1;
EA=1;
*/ IE=0x8a;
/* TR0=1;
TR1=1;
*/ TCON=0x50;
// PT1=1; //T1优先级最高
while(1)
{
x=(t<<16)+TH0*256+TL0;
while(x/10)
{
k=x%10;
x/=10;
i++;
}
k=x;
lcd_pos(4,1);
for(i=7;i!=0;i--)
{
lcd_wdat(k+48);
}
lcd_wdat(k+48);
}
}
void t0(void) interrupt 1 using 1
{
t++;
}
void t1(void) interrupt 3 using 3
{
num++;
if(num==4000)
{
TR0=0;
TR1=0;
}
}
文章评论(0条评论)
登录后参与讨论