用霍尔传感器测直流电机转速,连到单片机的P3.2口,计算它的脉冲数,请问这中断计数程序怎么写啊,谢谢了
答案:1 悬赏:0
解决时间 2021-10-16 09:32
- 提问者网友:蔚蓝的太阳
- 2021-10-16 00:26
用霍尔传感器测直流电机转速,连到单片机的P3.2口,计算它的脉冲数,请问这中断计数程序怎么写啊,谢谢了
最佳答案
- 二级知识专家网友:鸠书
- 2021-10-16 00:35
void int0_isr(void) interrupt 0 /*外部中断0,接P3.2口*/
{
unsigned int temp;
ct++;
if(ct==100){cc++;ct=0;}
time=bb;
TR0=0;
temp=TH0;
temp=((temp << 8) | TL0);
TH0=0x3c;
TL0=0xaf;
bb=0;
TR0=1;
time=time*50000+temp;
}
void account()
{
unsigned long a;
if (time!=0)
{
a=L*360000000/time;
}
aa=a/10;
}
{
unsigned int temp;
ct++;
if(ct==100){cc++;ct=0;}
time=bb;
TR0=0;
temp=TH0;
temp=((temp << 8) | TL0);
TH0=0x3c;
TL0=0xaf;
bb=0;
TR0=1;
time=time*50000+temp;
}
void account()
{
unsigned long a;
if (time!=0)
{
a=L*360000000/time;
}
aa=a/10;
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯