Hello,
when i use the ADC ADC0_IRQn handler, my question is :how to identify the convertion complete channel in the hanler?It seems that the interupt is enter when each channel's convetion is comlete. Thank you first!
codes are bellow
init:
/*adc*/
ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
ADC_DRV_AutoCalibration(INST_ADCONV1);
ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);
ADC_DRV_ConfigChan(INST_ADCONV1, 1U, &adConv1_ChnConfig1);
INT_SYS_InstallHandler(ADC0_IRQn, &ADC0_IRQHandler, (isr_t*) 0);
if (adConv1_ConvConfig0.resolution == ADC_RESOLUTION_8BIT)
g_adc0Max = (uint16_t) (1 << 8);
else if (adConv1_ConvConfig0.resolution == ADC_RESOLUTION_10BIT)
g_adc0Max = (uint16_t) (1 << 10);
else
g_adc0Max = (uint16_t) (1 << 12);
/* Calculate the value needed for PDB instance
* to generate an interrupt at a specified timeout.
* If the value can not be reached, stop the application flow
*/
if (!calculateIntValue(&pdb0_InitConfig0, PDLY_TIMEOUT, &delayValue))
{
/* Stop the application flow */
while(1);
}
/* Setup PDB instance
* - See PDB component for details
* Note: Pre multiplier and Prescaler values come from
* calculateIntValue function.
*/
/*pdb for ADC*/
PDB_DRV_Init(INST_PDB0, &pdb0_InitConfig0);
PDB_DRV_Enable(INST_PDB0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0UL, &pdb0_AdcTrigInitConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0UL, &pdb0_AdcTrigInitConfig1);
PDB_DRV_SetTimerModulusValue(INST_PDB0, (uint32_t) delayValue);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0UL, 0UL, (uint32_t) delayValue);
PDB_DRV_LoadValuesCmd(INST_PDB0);
PDB_DRV_SoftTriggerCmd(INST_PDB0);
INT_SYS_EnableIRQ(ADC0_IRQn);
hanler:
void ADC0_IRQHandler(void)
{
ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &g_adc0Ch1RawValue);
ADC_DRV_GetChanResult(INST_ADCONV1, 1U, &g_adc0Ch2RawValue);
PINS_DRV_TogglePins(LED_GPIO, (1 << LED_CHN_1));
ulNotifiedValue |= (1 << 0);
}
Hello Wang,
When a conversion is complete, the SC1n[COCO] flag is set.
You can read it with the ADC_DRV_GetConvCompleteFlag(const uint32_t instance, const uint8_t chanIndex) function.
Regards,
Daniel
Hello,
Firstly, thanks for your reply.
But, when I add the code as below, the callback func still execute twice, that means when channel 0 convert complete, ADC_DRV_GetConvCompleteFlag(ADC0_INSTANCE, 0U) and ADC_DRV_GetConvCompleteFlag(ADC0_INSTANCE, 1U) will both return SUCESS. Now I am confused, the project is attached, could you check it please, many thanks!