拿timer 2 capture作抓pwm
初始化
P05_Input_Mode;
TIMER2_CAP0_Capture_Mode;
IC6_P05_CAP0_BothEdge_Capture;
set_ECAP; //Enable Capture interrupt
set_TR2; //Triger Timer2
set_EA; //enable interrupts
中断
void Capture_ISR (void) interrupt 12
{
clr_CAPF0; // clear capture0 interrupt flag
if(P05==0)
{
input_capture_state=1;
low_input = (C0H<<8)&0xff00;
low_input |= C0L; // For capture mode CxL/CxH with data capture from I/O pin
}else
{
input_capture_state=2;
high_input = (C0H<<8)&0xff00;
high_input |= C0L;
}
clr_TF2;
}
|