c 单片机 中断 追加100分

来源:百度知道 编辑:UC知道 时间:2024/07/02 11:22:35
void measureCycle(){ TMOD = 0x10; //T1设为:定时器模式,工作方式1 TH1 = 0; //计数器清零 TL1 = 0; ET1 = 1; //溢出中断请求开启 while( P3_2 ); while( !P3_2 ); TR1 = 1; //开启定时计数 while( P3_2 ); //等待下降沿 while( !P3_2 ); //等待上升沿,结束计时 TR1 = 0; //结束计时 display(92160000UL/(65536UL*int3_Count+256*TH1+TL1);}
void int3() interrupt 3{ TH1 = 0; TL1 = 0; ++int3_Count; //溢出计数}
程序:http://hi.baidu.com/girlkoo/blog/item/f579ccef766572202df534d6.html
int3_Count在measureCycle中不能改变。
把measureCycle放到main函数中时正常。
为什么?
谁能提供一些C语言单片机相关很重要,易被忽略的知识,分就给谁!!!!!!

void measureCycle() {

TMOD = 0x10; //T1设为:定时器模式,工作方式1
TH1 = 0; //计数器清零
TL1 = 0;
ET1 = 1; //溢出中断请求开启
while( P3_2 );
while( !P3_2 );
TR1 = 1; //开启定时计数
while( P3_2 ); //等待下降沿
while( !P3_2 ); //等待上升沿,结束计时
TR1 = 0; //结束计时
display(92160000UL/(65536UL*int3_Count+256*TH1+TL1);}

void int3() interrupt 3 {
TH1 = 0;
TL1 = 0;
++int3_Count; //溢出计数}

程序:http://hi.baidu.com/girlkoo/blog/item/f579ccef766572202df534d6.html
int3_Count在measureCycle中不能改变。
把measureCycle放到main函数中时正常。
为什么?

不明白

单片机程序执行的顺序是从main函数开始顺序执行 你的measureCycle子程序放在main程序前事不会执行了 除非在main函数里调用啊

我看了程序,好像没开总中断允许标志哦,这样应该跳不到中断程序吧?自然就不能执行++