This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
My system is the following:
1. PWM SOCA interrupt trigger ADC conversion
// Disable SOCA
EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
// Configure the SOC to occur on the first period event
EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO);
// Set prescale to trigger ADC each 20us (2 periods of PWM)
EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 2);
// Start ePWM1, enabling SOCA
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
// Measure TLoad, pin A1
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0,ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN1, 140);
// Measure IBus, pin A2
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1,ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN2, 140);
// Measure UBus, pin A3
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2,ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN3, 140);
// Measure VLoad is connected to PGA5_IN pin internally connected to A14
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN14, 140);
// Set SOC3 to set the interrupt 1 flag of ADC A. Enable the interrupt and make
// sure its flag is cleared.
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER3);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
// Enable ADC A interrupt 1
Interrupt_enable(INT_ADCA1);
2. At is turn, interrupt 1 of ADC trigger DMA transfer
DMA_initController();
DMA_setEmulationMode(DMA_EMULATION_STOP);
DMA_configAddresses(DMA_CH1_BASE, (void*)(&adcaRawMeasureSamples[0]), (void*)(&AdcaResultRegs.ADCRESULT0));
DMA_configBurst(DMA_CH1_BASE, sizeof(ADCA_MEASURE_t), DMA_SRC_BURST_STEP, DMA_DEST_BURST_STEP);
DMA_configTransfer(DMA_CH1_BASE, NUM_MEASURE_SAMPLE, DMA_CH1_SRC_TRANSFER_STEP, DMA_DEST_TRANSFER_STEP);
DMA_configMode(DMA_CH1_BASE, DMA_TRIGGER_ADCA1, DMA_CFG_ONESHOT_DISABLE | DMA_CFG_CONTINUOUS_ENABLE | DMA_CFG_SIZE_16BIT);
DMA_enableTrigger(DMA_CH1_BASE);
DMA_setInterruptMode(DMA_CH1_BASE, DMA_INT_AT_END);
DMA_enableInterrupt(DMA_CH1_BASE);
DMA_disableOverrunInterrupt(DMA_CH1_BASE);
DMA_clearTriggerFlag(DMA_CH1_BASE);
Interrupt_enable(INT_DMA_CH1);
DMA_startChannel(DMA_CH1_BASE);
3. At the end of DMA transfer ADC result is treated inside DMA channel 1 interrupt
My problem is that my system doesn't works if I don't declare and interrupt function for ADC as following:
Interrupt_register(INT_ADCA1, &adcA1ISR);
static __interrupt void adcA1ISR(void)
{
// Clear the interrupt flag and issue ACK
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
//
// Check if overflow has occurred
//
if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1))
{
ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}
else
{
// Nothing to do
}
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
So I need help to disable ADC interrupt because for me DMA component is in charge to clear ADC interrupt flag and this interrupt is not needed normaly.
Thanks in advance.
Best regards,
Martial
Can you give me more detail about in what way it doesn't work when the interrupt isn't enabled? It makes sense that you would need to enable it in the ADC, but you shouldn't have to enable it in the PIE or CPU.
Can you try enabling continuous mode for the ADC interrupt?
Whitney
Hello Whitney,
If I don't activate interrupt inside PIE (with Interrupt_enable()), ADC interrupt flag is set and never cleared by DMA. However, activation of coutinous mode resolved this problem because interrupt flag state has no effect on interrupt generation. So continuous mode is a solution (thanks Whitney).
Just for my understanding, can you tell me why ADC interrupt flag is not cleared by DMA because on part 10.3.2 of reference manual, it is write : "Upon receipt of a peripheral interrupt event signal,the DMA will automatically send a clear signal to the interrupt source so that subsequent interrupt events will occur."
Martial
That line might be referring to the PERINTFLG within the DMA registers. It does seem misleading though. I'll confirm the behavior and file a request to get the document updated to clarify.
Whitney