Tool/software: TI C/C++ Compiler
dear all:
I use ecap4 ecap5 to capture two pwms,but ecap4 ecap5 conflict.
when ecap4 Interrupt computations duty,ecap5 coming.
duty4 jump to zero.
void dts_capInit(void)
{
ecapInit();
/* Configure ECAP4 */ /* Configure Event 1 to Capture the rising edge */
ecapSetCaptureEvent1(ecapREG4, RISING_EDGE, RESET_DISABLE);
/* Configure Event 2 to Capture the falling edge */
ecapSetCaptureEvent2(ecapREG4, FALLING_EDGE, RESET_DISABLE);
/* Configure Event 3 to Capture the rising edge with reset counter enable */
ecapSetCaptureEvent3(ecapREG4, RISING_EDGE, RESET_ENABLE);
/* Set Capure mode as Continuous and Wrap event as CAP3 */
ecapSetCaptureMode(ecapREG4, CONTINUOUS, CAPTURE_EVENT3);
/* Start counter */
ecapStartCounter(ecapREG4);
/* Enable Loading on Capture */
ecapEnableCapture(ecapREG4);
/* Enable Interrupt for CAP3 event */
ecapEnableInterrupt(ecapREG4, ecapInt_CEVT3);
/* Configure ECAP5 */ /* Configure Event 1 to Capture the rising edge */
ecapSetCaptureEvent1(ecapREG5, RISING_EDGE, RESET_DISABLE);
/* Configure Event 2 to Capture the falling edge */
ecapSetCaptureEvent2(ecapREG5, FALLING_EDGE, RESET_DISABLE);
/* Configure Event 3 to Capture the rising edge with reset counter enable */
ecapSetCaptureEvent3(ecapREG5, RISING_EDGE, RESET_ENABLE);
/* Set Capure mode as Continuous and Wrap event as CAP3 */
ecapSetCaptureMode(ecapREG5, CONTINUOUS, CAPTURE_EVENT3);
/* Start counter */
ecapStartCounter(ecapREG5);
/* Enable Loading on Capture */
ecapEnableCapture(ecapREG5);
/* Enable Interrupt for CAP3 event */
ecapEnableInterrupt(ecapREG5, ecapInt_CEVT3);
}
int Dts_duty1,Dts_duty2;
float duty_cap4,period_cap4,duty_cap5,period_cap5;
void ecapNotification(ecapBASE_t *ecap,uint16 flags)
{
uint32 cap_1, cap_2, cap_3;
if(ecap ==ecapREG4)
{
cap_1 = ecapGetCAP1(ecapREG4);
cap_2 = ecapGetCAP2(ecapREG4);
cap_3 = ecapGetCAP3(ecapREG4);
duty_cap4 = (cap_2 - cap_1)*1000/VCLK4_FREQ;
period_cap4 = (cap_3 - cap_1)*1000/VCLK4_FREQ;
Dts_duty1 = duty_cap4/period_cap4*100;
}
else if(ecap ==ecapREG5)
{
cap_1 = ecapGetCAP1(ecapREG5);
cap_2 = ecapGetCAP2(ecapREG5);
cap_3 = ecapGetCAP3(ecapREG5);
duty_cap5 = (cap_2 - cap_1)*1000/VCLK4_FREQ;
period_cap5 = (cap_3 - cap_1)*1000/VCLK4_FREQ;
Dts_duty2 = duty_cap5/period_cap5*100;
}
}