⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 int.c

📁 2051数字频率计源码,运行在AT892051上
💻 C
字号:

//#pragma src


//=====================================================================

#include <intrins.h>

//#define MAIN_BODY

#include "paramac.h"
#include "show.h"
#include "dog.h"





//---------------------- extern interrupt 0  -------------------


void intx0(void) small interrupt 0 using 1 {

  if(_testbit_(cntstart)){       	//若要求开始则开始
    TL0=timer0_const.low; 
    TH0=timer0_const.high;       	//重装定时器时间常数
	TR0=1;
    cntstop=CNT_RUN;

  }else{

    if(_testbit_(rq_cntstop)){ 		//若请求停止则停止
      TR0=0;
      cntstop=CNT_STOP;         
//    test.t_th0x=TH0;test.t_tl0x=TL0-10;
	}else{
	  if(cntstop==CNT_RUN){      	//否则看:运行中吗?
        if(++test.p_num==0xffff){   //运行中... ...
	      TR0=0;                 	//脉冲计数溢出,停止计数
          cntstop=CNT_STOP;
//          test.t_th0x=TH0;test.t_tl0x=TL0-15;
        }
	  }
	}
  }
  real_work=TRUE;					//working flag = true
}







//----------------------  interrupt t0 ---------------------

void intt0(void) small interrupt 1 using 2 {

  TH0=timer0_const.high;
  TL0=timer0_const.low;    							//重装定时器时间常数  about 10 mS

  if(cntstop==CNT_RUN){       						//运行中吗?
    if(++test.t_num==test.t_num_c)rq_cntstop=1;  	//刷新时间到,发出停止请求
    if(test.t_num==test.t_num_max){      			//时间溢出,强行终止计数.
      TR0=0;
//      test.t_th0x=TH0;test.t_tl0x=TL0-8;
      cntstop=CNT_STOP;
	  real_work=FALSE;								//working flag = false
    }   											//时间到,则计数停
  }
  about10ms=1;										//set a flag
}






//       数码管动态移位显示定时器    T1   中断


void intt1(void) small interrupt 3 using 3 {	
  TH1=timer0_const.high1;
  TL1=timer0_const.low1;    					//重装定时器时间常数  约2mS
  if(_testbit_(rq_show)){
	LED_Port=0xff;				//关显示
	CK_164=0;					//移位送数
	CK_164=1;
	LED_Port=show.showing;		//开显示,显示新数
	DA_164=0;
  }
  run_time.run_stack++;			//时间累加信号加一
  show2led();					//显示重装

  if(--work.dog_timer==0)dog_bark();				//看门狗检测

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -