Hello there,
I'm trying to implement and FOC on an F2837x or an F2838x µC and using some examples of Ti for it.
I found this code snippet (from tidm_02009_F2838x_cpu1 from the digitalPower SDK) which I cannot really understand:
void configInterrupt(void)
{
//
// Setup EPWM1 INT to generate MotorControlISR
//
#if(SAMPLING_METHOD == SINGLE_SAMPLING)
//
// Select INT @ ctr = 0
//
EPWM_setInterruptSource(PHASE_U_PWM_BASE, EPWM_INT_TBCTR_PERIOD);
#elif(SAMPLING_METHOD == DOUBLE_SAMPLING)
//
// Select INT @ ctr = 0 or ctr = prd
//
EPWM_setInterruptSource(PHASE_U_PWM_BASE, EPWM_INT_TBCTR_ZERO_OR_PERIOD);
#endif
//
// 1 for INTFRC to work
//
EPWM_setInterruptEventCount(PHASE_U_PWM_BASE, 1);
//
// Enable INT from EPWM1
//
EPWM_enableInterrupt(PHASE_U_PWM_BASE);
//
// Enable AdcA-ADCINT1- to help verify EoC before result data read
//
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
//
// Enable AdcC-ADCINT1- ADCEoCINT to generate ResolverISR
//
ADC_setInterruptSource(ADCC_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER1);
ADC_enableContinuousMode(ADCC_BASE, ADC_INT_NUMBER1);
//
// Enable INT1 from ADCC
//
ADC_enableInterrupt(ADCC_BASE, ADC_INT_NUMBER1);
//
// PWM Clocks Enable
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
}
Then in the ISR function is the following
__interrupt void ISR1(void)
{
TRINV_focControlCode();
TRINV_debugCode();
TRINV_HAL_clearInterruptFlag();
TRINV_HAL_clearInterrupt(INTERRUPT_ACK_GROUP3 | INTERRUPT_ACK_GROUP11);
isrTicker++;
}
In my understanding the ePWM module triggers the focControlCode on every begin of the PWM Period and also the Satrt of conversion of the ADCs. I thought that actually the ADC End of Conversion should trigger the focControlCode and the PWM triggers the ADC Start of conversion. As comment it says in the configInterrupt:
// Enable AdcA-ADCINT1- to help verify EoC before result data read
How you can actually verify that at the focControlCode really takes the new ADC results altough no interrupt routine is used from the ADCs?