/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
MODIFICATIONS :
******************************************************************************/ #include "version.h" static unsigned char TmpOcl; unsigned int TEST_TIME; #pragma TRAP_PROC SAVE_REGS void Clear_TimerB_TOF(void) //070605 { unsigned char i; i=TBCSR; //和下面一句一起清除TOF(中断溢出标记位) i=TBCLR; // } void EnableTimer2Int(void) //070605 { Clear_TimerB_TOF(); TBCR1=0x20; // enable timerb int } void DisableTimer2Int(void) //070605 { TBCR1=0x00; // enable timerb int } unsigned int FIRST_TEST_TIME,SECOND_TEST_TIME; void Get_Org_Time(void) //070605 { FIRST_TEST_TIME=TBCHR; FIRST_TEST_TIME=FIRST_TEST_TIME<<8; FIRST_TEST_TIME=(FIRST_TEST_TIME+TBCLR)/100; //得到开始时间 } void Enable_VtInt(void) //070605 { PFOR = 0x02; } void PF_RiseInt(void) //070605 { EICR=0x08; } void PF_FallInt(void) //070605 { EICR=0x10; } void Enable_PGInt(void) //070605 { PFOR = 0x01; } void Disable_PFInt(void) //070605 { PFOR = 0x00; }
/*----------------------------------------------------------------------------- ROUTINE NAME : dummy_rt INPUT/OUTPUT : None
DESCRIPTION : Empty Interrupt Service Routine
COMMENTS : all the non-connected interrupt vectors are connected to this empty function -----------------------------------------------------------------------------*/ void dummy_rt(void) { } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : sw_rt INPUT/OUTPUT : None
DESCRIPTION : Software Interrupt Service Routine
COMMENTS : -----------------------------------------------------------------------------*/ void sw_rt(void) { } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : eit0_rt INPUT/OUTPUT : None
DESCRIPTION :
COMMENTS : -----------------------------------------------------------------------------*/ void eit0_rt(void) //PA3 { if((test_project==setup_time_test)||(test_project==holdon_time_test))//070605 { EnableTimer2Int(); Get_Org_Time(); Enable_VtInt(); PF_RiseInt(); } else if((test_project==riseon_time_test)||(test_project==powergood_time_test)) { Enable_VtInt(); PF_RiseInt(); } else if(test_project==falloff_time_test) { Enable_VtInt(); PF_FallInt(); } else if(test_project==powerfail_time_test) { Enable_PGInt(); PF_FallInt(); } TIMERB_Over_Count=0; } void Test_Off(void) //070605 { Calculate_Time(); Clear_TimerB_TOF(); DisableTimer2Int(); // enable timerb int Disable_PFInt(); VtCnt=0; } static void Calculate_Time(void) //070605 { SECOND_TEST_TIME = TBCHR; SECOND_TEST_TIME=SECOND_TEST_TIME<<8; SECOND_TEST_TIME = (SECOND_TEST_TIME+TBCLR)/100; if(TIMERB_Over_Count==0) { if(SECOND_TEST_TIME<FIRST_TEST_TIME) //--防止SECOND_TEST_TIME比FIRST_TEST_TIME小产生很大的值 { TEST_TIME=655-FIRST_TEST_TIME+SECOND_TEST_TIME; } else TEST_TIME = SECOND_TEST_TIME-FIRST_TEST_TIME; } else { TEST_TIME=(TIMERB_Over_Count*655-FIRST_TEST_TIME+SECOND_TEST_TIME); //得到XX.Xms } } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : eit1_rt INPUT/OUTPUT : None
DESCRIPTION :
COMMENTS : -----------------------------------------------------------------------------*/ unsigned char VtCnt; void eit1_rt(void) //PF0 PF1 PF2 { VtCnt++; if((test_project==setup_time_test)||(test_project==holdon_time_test))//070605 Test_Off(); else if((test_project==riseon_time_test)||(test_project==falloff_time_test)) { if(VtCnt==1) { Set_Load(Compare_Voltage2); EnableTimer2Int(); Get_Org_Time(); } else Test_Off(); } else if(test_project==powergood_time_test) { if(VtCnt==1) { Enable_PGInt(); EnableTimer2Int(); Get_Org_Time(); } else Test_Off(); } else if(test_project==powerfail_time_test) { if(VtCnt==1) { Enable_VtInt(); EnableTimer2Int(); Get_Org_Time(); } else Test_Off(); } } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : eit2_rt INPUT/OUTPUT : None
DESCRIPTION :
COMMENTS : -----------------------------------------------------------------------------*/ void eit2_rt(void) // PB0 PB1 PB2 PB3 { } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : eit3_rt INPUT/OUTPUT : None
DESCRIPTION : STA310 interrupt
COMMENTS : -----------------------------------------------------------------------------*/ void eit3_rt(void) // PB4 { } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : spi_rt INPUT/OUTPUT : None
DESCRIPTION :
COMMENTS : -----------------------------------------------------------------------------*/ void spi_rt(void) { }
#pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : tima_rt INPUT/OUTPUT : None
DESCRIPTION : timer A Interrupt Service Routine
COMMENTS : -----------------------------------------------------------------------------*/ unsigned int TIMERB_Over_Count; //070605 void tima_rt(void) { Clear_TimerB_TOF(); //070605 TIMERB_Over_Count++; //070605 } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : timb_rt INPUT/OUTPUT : None
DESCRIPTION : timer B Interrupt Service Routine
COMMENTS : -----------------------------------------------------------------------------*/ void timb_rt(void) { } #pragma TRAP_PROC SAVE_REGS /*----------------------------------------------------------------------------- ROUTINE NAME : sci_rt INPUT/OUTPUT : None
DESCRIPTION : SCI Interrupt Service Routine
COMMENTS : -----------------------------------------------------------------------------*/ void sci_rt(void) { unsigned char Temp_CR2,temp; /****************************************************************************** Reception in Interrupt Driven Without Buffer mode ******************************************************************************/ if(SCISR & SCI_ORE) /*If Interrupt is generated due to overrun error*/ { temp=SCIDR; } else if (SCISR & SCI_RDRF) { if(!(Sci_Receive_Transmit_Flag&receive_complete)) { if (SCI_Reci_Data[0]!=0xa9) { SCI_Reci_Data[0]=SCIDR; SCI_Reci_Idex=1; } else { SCI_Reci_Data[SCI_Reci_Idex]=SCIDR; if (SCI_Reci_Idex<SCI_Reci_Data[1]-1) SCI_Reci_Idex++; else { SCI_Reci_Idex=0; Sci_Receive_Transmit_Flag|=receive_complete; } } } else Temp_CR2=SCIDR; }
/****************************************************************************** Transmission in Interrupt Driven without Buffer mode ******************************************************************************/ Temp_CR2 = SCICR2 ;/*Checks if transmit complete flag is set*/ if((SCISR & SCI_TC)&& (Temp_CR2 & SCI_TC)) { if (SCI_Trans_Idex <SCI_Trans_Data[1]-1) /*Checks if all the bytes are transmitted*/ { SCI_Trans_Idex++; SCIDR = SCI_Trans_Data[SCI_Trans_Idex]; /*Transmits a single byte*/ } else if(SCI_Trans_Idex == SCI_Trans_Data[1]-1) { SCI_Trans_Idex=0; SCICR2 &= 0xbf; /*Disable IT if complete string is transmitted*/ Sci_Receive_Transmit_Flag&=(~transmit_flag); } } /*Checks if TDRE Flag is set*/ else if ((SCISR & SCI_TDRE)&&(Temp_CR2 & SCI_TDRE)) { } }
|