for example i want to use TIM0Ch1 as input caputure to get the pwm signal .
step1, i config the register of timer0
"
void initTIM(void)
{
TIM0TIOS_IOS1 = 0; // Input Capture/Output Compare Channel3 Configuration//Input
TIM0TIE_C1I = 1; // Input Capture/Output Compare channel3 //Interrupt Enable
TIM0TCTL4_EDG1A = 1; // falling edge channel3
TIM0TCTL4_EDG1B = 1; // rising edge channel3
TIM0OCPD_OCPD3 = 1; // Enabled | Output compare pin disconnect register
TIM0OCPD_OCPD2 = 1; // Enabled | Output compare pin disconnect register
TIM0OCPD_OCPD1 = 1; // Enabled | Output compare pin disconnect register
TIM0OCPD_OCPD0 = 1; // Enabled | Output compare pin disconnect register
TIM0PTPSR = 49; // Timer Pre-scaler =49+1
TIM0TSCR1_PRNT = 1; // Precision timer divider enable
TIM0TSCR2_TOI = 1; // Overflow interrupt enabled
}
void EnableTIM()
{
TIM0TC1 = 0; // Timer Input Capture/Output channel3 Compare Registers High and Low 0–1(TCxH and TCxL)
TIM0TSCR1_TEN = 1; // Enabled | Timer Enable
}
"
step2 setup isr for tim0ch1
interrupt VectorNumber_Vtim0ch1 void TIM0chan1_ISR(void)
{
// Read PWM input control pin and update status
PWMControlUpdate(TIM0TC1, &pwmControlData);
// Read the PWM Control output
pwmControlData.outputValue = PWMControlGetOutputValue(&pwmControlData);
// Toggle edge detection
if(pwmControlData.flags.risingEdge)
{
TIM0TCTL4_EDG1A = 1;
TIM0TCTL4_EDG1B = 0;
}
if(pwmControlData.flags.fallingEdge)
{
TIM0TCTL4_EDG1A = 0;
TIM0TCTL4_EDG1B = 1;
}
// Clear interrupt flag
TIM0TFLG1 = TIM0TFLG1_C1F_MASK; //TIM0TFLG1_C0F_MASK | TIM0TFLG1_C1F_MASK | TIM0TFLG1_C2F_MASK | TIM0TFLG1_C3F_MASK;
}
step3 calculate pwm input value
...
about the register setup is there anything wrong?