Tool/software:
Hello Experts,
I have configured ePWM11 in up-down mode and trying to enable pwm interrupts when TCBR is zero or period by writing the INTSEL bit as 011
EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_ZERO_OR_PERIOD);
Am I correct is asuming that 2 interrupts will be generated , one when TCBR = 0 and the other when TCBR = Period, for every PWM cycle(marked in red)?
Now , when TCBR is 0, if i check the direction (TBSTS.CTRDIR), am i correct in asuming that the counter will be counting up? And when TCBR is equal to Period, the counter will be counting down?
I tried to verify the above , by checking the direction in the PWM ISR, but it always shows as theough it is counting up, it never counts down, I tried to toggle a GPIO to verify this but is is always low!!
__interrupt void pwm11_ISR(void)
{
pwm_CounterDIR = EPWM_getTimeBaseCounterDirection(EPWM11_BASE);
testTCBR1 = EPWM_getTimeBaseCounterValue(EPWM11_BASE);
if(EPWM_getTimeBaseCounterDirection(EPWM11_BASE))
{
GPIO_writePin(46,0);
}
else
{
GPIO_writePin(46,1);
}
testTCBR2 = EPWM_getTimeBaseCounterValue(EPWM11_BASE);
EPWM_clearEventTriggerInterruptFlag(EPWM11_BASE);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
Interrupt_clearACKGroup( INTERRUPT_ACK_GROUP3 |
INTERRUPT_ACK_GROUP11 );
}
What configuration am i missing here?
If i set the interrupt source as :
EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_ZERO);, Then the GPIO is always Low.
Similarly if i set the interrupt source as
EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_PERIOD);, Then the GPIO is always High.
But when i set the interrupt source as
EPWM_setInterruptSource(EPWM11_BASE ,EPWM_INT_TBCTR_ZERO_OR_PERIOD);, The GPIO is always Low!!,