以下这段代码是抄来的,新塘N76E003
输入50hz PWM 捕获转为P12输出 用逻辑分析器测试时间不对,请求大神指点
void Capture_ISR (void) interrupt 12
{
unsigned int TMP;
clr_CAPF0; // clear capture0 interrupt flag
TMP =(unsigned int)C0H<<8;
TMP = C0L; // For capture mode CxL/CxHwith data capture from I/O pin
P12 = TMP;
//P12 = ~P12; //toggle GPIO1 to show int
printf("\n TM2 CAP 0x%bX",C0H);
clr_TF2;
}
/***************************************************************************************************
*********
* Main function
****************************************************************************************************
********/
void main (void)
{
Set_All_GPIO_Quasi_Mode;
InitialUART0_Timer3(115200);
P00_Input_Mode;
P00 = 1;
TIMER2_CAP0_Capture_Mode;
IC3_P00_CAP0_BothEdge_Capture;
set_ECAP; //Enable Capture interrupt
set_TR2; //Triger Timer2
set_EA;
while(1);
} |