欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
想要搞個簡單單片機頻率計 中斷1秒計算頻率,請幫忙看看
[打印本頁]
作者:
wjx111123
時間:
2021-6-25 10:31
標題:
想要搞個簡單單片機頻率計 中斷1秒計算頻率,請幫忙看看
#include"reg51.h"
#include"lcd1602.h"
#define uchar unsigned char
#define uint unsigned int
uchar count=0,valueH=0,valueL=0;
uchar str[]={"0123456789"};
uchar str1[]={"FREQUENCE:"};
uint fre=0;
uint num;
void initex0()
{
IT0=1;
EX0=1;
EA=1;
}
void inittimer0()
{
TMOD=0x01;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
}
void T0_time()interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
if(num==20)
{}
}
void datadeal()
{
uint value=0;
value=valueH*256+valueL;
fre=10000000/value;
}
void display()
{
uchar temp0=0,temp1=0,temp2=0,temp3=0,temp4=0,temp5=0;
uchar i=0;
temp0=(fre%1000000)/100000;
temp1=(fre%100000)/10000;
temp2=(fre%10000)/1000;
temp3=(fre%1000)/100;
temp4=(fre%100)/10;
temp5=fre%10;
writecom(0x80);
delay(1);
while(str1[i]!='\0')
{
writedat(str1[i]);
delay(1);
i++;
}
writecom(0x80+0x40+5);
delay(1);
writedat(str[temp0]);
delay(1);
writedat(str[temp1]);
delay(1);
writedat(str[temp2]);
delay(1);
writedat(str[temp3]);
delay(1);
writedat(str[temp4]);
delay(1);
writedat('.');
delay(1);
writedat(str[temp5]);
delay(1);
writedat('H');
delay(1);
writedat('Z');
delay(1);
}
void main()
{
initex0();
inittimer0();
initlcd();
while(1)
{
datadeal();
display();
}
}
void ex0_isr() interrupt 0
{
if(count==0)
{
TH0=0x00;
TL0=0x00;
TR0=1;
}
else if(count==1)
{
TR0=0;
valueH=TH0;
valueL=TL0;
count=0;
}
count++;
}
復制代碼
作者:
xuyaqi
時間:
2021-6-25 11:28
還是一步步來,你的外中斷計數(shù)就有問題。
作者:
yzwzfyz
時間:
2021-6-25 13:44
本帖最后由 yzwzfyz 于 2021-6-26 10:03 編輯
計數(shù)要做如下三件事,你是否同意?
1、何時開始?
2、何時結(jié)束?
3、誰來數(shù)數(shù)?
這三條你是如何做的呢?
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1