📄 intprg.c
字号:
/***********************************************************************/
/* */
/* FILE :intprg.c */
/* DATE :Mon, Oct 03, 2005 */
/* DESCRIPTION :Interrupt Program */
/* CPU TYPE :H8/38024F */
/* */
/* This file is generated by Renesas Project Generator (Ver.3.0). */
/* */
/***********************************************************************/
#include "includes.h"
//#include <machine.h>
#pragma section IntPRG
// vector 1 Reserved
// vector 2 Reserved
// vector 3 Reserved
// vector 4 IRQ0
__interrupt(vect=4) void INT_IRQ0(void)
{
HF_IRR1_IRRI0=0;/*clear the int request*/
Com485Cnt=8;
}
// vector 5 IRQ1
__interrupt(vect=5) void INT_IRQ1(void) {/* sleep(); */}
// vector 6 IRQAEC
__interrupt(vect=6) void INT_IRQAEC(void) {/* sleep(); */}
// vector 7 IRQ3
__interrupt(vect=7) void INT_IRQ3(void) {/* sleep(); */}
// vector 8 IRQ4
__interrupt(vect=8) void INT_IRQ4(void) {/* sleep(); */}
// vector 9 WKP0_7
__interrupt(vect=9) void INT_WKP0_7(void) {/* sleep(); */}
// vector 10 Reserved
// vector 11 Timer A Overflow
__interrupt(vect=11) void INT_TimerA(void)//周期 (1/5000000)*32*256=0.0016384s
{
INT8U GuB_SysTmp;
HF_IRR1_IRRTA=0;/*remove the Timer A intterrupt requst*/
/*掉电检测*/
if(_PowerDown)
return;
if(_PowerTest_)
{
HB_AMR=0x0b6;
nop();
HF_ADSR_ADSF=1;
GuB_SysTmp=0;
while(HF_ADSR_ADSF)
{
GuB_SysTmp--;
nop();
if(GuB_SysTmp<1)
break;
}
AdResult=HW_ADRR;
AdResult>>=8;
if(AdResult<VoltageLoseLve)
{
VoltageLowCnt++;
if(VoltageLowCnt>2)
{
VoltageLowCnt=0;
_PowerDown=1;
}
}
else
VoltageLowCnt=0;
}
else//电池检测
{
HB_AMR=0x0b5;
nop();
HF_ADSR_ADSF=1;
GuB_SysTmp=0;
while(HF_ADSR_ADSF)
{
GuB_SysTmp--;
nop();
if(GuB_SysTmp<1)
break;
}
AdResult=HW_ADRR;
AdResult>>=6;
if(AdResult>0x1c9)
{
MeterRunningState&=0xfe;
}
else
{
MeterRunningState|=0x01;//电池故障
}
_PowerTest_=1;
}
if(_PowerDown==0)
{
CountOf1dot64Ms++;
if(CountOf1dot64Ms>=6)//0.0016384s*6=0.0098304s
{
_Span10msTask=1;
CountOf1dot64Ms=0;
CountOf10Ms++;
if(CountOf10Ms>=102)//0.0098304s*102=1.0027008s
{
CountOf10Ms=0;
_SpanSecondTask=1;
}
if(IS_P_PulseIn_High)
{
PulseSample.PulseLowCnt=0;
PulseSample.PulseHighCnt++;
if(PulseSample.PulseHighCnt>=3)
{
PulseSample.PulseHighCnt=0;
PulseSample.PulseState=0;
}
}
else
{
PulseSample.PulseHighCnt=0;
PulseSample.PulseLowCnt++;
if(PulseSample.PulseLowCnt>=3)
{
PulseSample.PulseLowCnt=0;
if(!PulseSample.PulseState)
{
PulseSample.PulseState=1;
switch(TimeSliceInfo.CurrentRateID)
{
case 2:
PulseSample.PulseNum[0]++;
if(PulseSample.PulseNum[0]>=PULSE_NUM_OF_001KWH)
{
PulseSample.PulseNum[0]-=PULSE_NUM_OF_001KWH;
_EnergyAccum=1;
}
break;
case 3:
PulseSample.PulseNum[1]++;
if(PulseSample.PulseNum[1]>=PULSE_NUM_OF_001KWH)
{
PulseSample.PulseNum[1]-=PULSE_NUM_OF_001KWH;
_EnergyAccum=1;
}
break;
case 4:
PulseSample.PulseNum[2]++;
if(PulseSample.PulseNum[2]>=PULSE_NUM_OF_001KWH)
{
PulseSample.PulseNum[2]-=PULSE_NUM_OF_001KWH;
_EnergyAccum=1;
}
break;
default:
break;
}
if(EnergyReverseTest.ReverseState)
{
PulseSample.PulseNum[3]++;
if(PulseSample.PulseNum[3]>=PULSE_NUM_OF_001KWH)
{
PulseSample.PulseNum[3]-=PULSE_NUM_OF_001KWH;
_ReverseEnergyAccum=1;
}
}
}
}
}
}
}
}
// vector 12 Counter Overflow
__interrupt(vect=12) void INT_Counter(void) {/* sleep(); */}
// vector 13 Timer C Overflow
__interrupt(vect=13) void INT_TimerC(void) {/* sleep(); */}
// vector 14 Timer FL Overflow
__interrupt(vect=14) void INT_TimerFL(void)
{
HF_TCSRF_OVFL=0;
HF_TCSRF_CMFL=0;
HF_IRR2_IRRTFL=0;
}
// vector 15 Timer FH Overflow
__interrupt(vect=15) void INT_TimerFH(void)
{
HF_IRR2_IRRTFH=0;
/* sleep(); */
}
// vector 16 Timer G Overflow
__interrupt(vect=16) void INT_TimerG(void) {/* sleep(); */}
// vector 17 Reserved
// vector 18 SCI3
__interrupt(vect=18) void INT_SCI3(void)
{
if((HB_SSR&0x38)!=0)/*correct the communicatio err if happening*/
{
HB_SSR&=0x0c7;
RecState=0;
}
else
{
if(HF_SSR_RDRF)
{
if(Com485Cnt>0)
Com485ReceiveBytes++;
DataReceive();
}
}
}
// vector 19 ADI
__interrupt(vect=19) void INT_ADI(void) {/* sleep(); */}
// vector 20 Direct Transition
__interrupt(vect=20) void INT_Direct_Transition(void) {/* sleep(); */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -