📄 isr.c
字号:
#pragma interrupt INTTM80 MD_INTTM80
#pragma interrupt INTAD MD_INTAD
//#pragma interrupt INTP1 MD_INTP1
#pragma interrupt INTP0 MD_INTP0
#pragma interrupt INTTMH1 MD_INTTMH1
#include "includes.h"
unsigned char sencond_1_per_8 = 7;
void TM80_Init(void)
{
TMMK80=1;
TMIF80=0;
TMC80 = 0x02;
CR80=125; // Timer 4ms
TMMK80=0;
TMC80|=0x80;
}
void TM80_Stop(void)
{
TMMK80=1;
TMC80&=~0x80;
}
__interrupt void MD_INTTM80( void )
{
SYS_EVT_ADD(SYS_EVT_KEYPRESS);
//TMC80&=~0x80;
//TMIF80 = 0;
}
__interrupt void MD_INTP0( void )
{
//P4.0 = 0;
SYS_EVT_ADD(SYS_EVT_KEYDOWN);
}
unsigned long chk_dog_time_val = 0;
unsigned char chk_dog_time_count = 0;
unsigned long chk_dog_count = 0;
__interrupt void MD_INTTMH1( void )
{
unsigned char new_val;
_clr_wdt();
sencond_1_per_8--;
if(sencond_1_per_8 == 0)
{
sencond_1_per_8 = 8;
SYS_EVT_ADD(SYS_EVT_SECONDS);
if( LED_on_time )
{
LED_on_time--;
if(LED_on_time == 0)
{
LED = 1;
}
}
}
if(check_dog_timer_flag)
{
if(TMC00 & 0x04)
{
chk_dog_time_val += TM00;
TMC00 = 0x00;
TMC00 = 0x04;
chk_dog_time_count++;
}
else
{
TMC00 = 0x04;
//P4.2 = 0;
}
if(chk_dog_time_count > 7)
{
chk_dog_count = chk_dog_time_val>>3;
check_dog_timer_flag = 0;
chk_dog_time_count = 0;
chk_dog_time_val = 0;
//P4.2 = 1;
new_val = ((((unsigned long)31250) * CMP01) / chk_dog_count) >> 3;
TMHE1 = 0;
CMP01 = new_val;
TMHE1 = 1;
TMC00 = 0;
}
}
}
__interrupt void MD_INTAD()
{
unsigned short ad_result;
ad_result = ADCR;
AD_conv_times++;
if(AD_conv_times < AD_SAMPLE_TIMES_MAX)
{
if(AD_conv_result[AD_conv_phase] < ad_result)
AD_conv_result[AD_conv_phase] = ad_result;
if(++AD_conv_phase < AD_MAX_CHANNEL)
{
ADS = AD_conv_phase;
}
else
{
AD_conv_phase = 0;
ADS = AD_conv_phase;
}
ADIF = 0;
}
else
{
AD_conv_times = 0;
AD_conv_phase = AD_MAX_CHANNEL;
ADCS = 0;
ADCE = 0;
ADMK = 1;
}
//_clr_wdt();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -