Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
srgbtl
Level 1
Level 1
First reply posted 5 sign-ins First like given

Hi all,

I am trying to configure ADC to transfer measurement results from several channels to DMA. But with my configuration, only the result which was configured lastly is transferred to DMA.

After some investigation, I found that interrupts are not triggered. What am I doing wrong?

Here is how ADC channels are configured:

 

/* ADC Interrupt Service Routine */
IFX_INTERRUPT(ISR_ADC_result1, 0, 20); // Not triggered
IFX_INTERRUPT(ISR_ADC_result2, 0, 21); // Not triggered
IFX_INTERRUPT(ISR_ADC_result3, 0, 22); // Triggered
//.....

#define CHANNELS_NUM        3
#define AN17_CHID           1 /* Channel ID for pin AN17                          */
#define AN20_CHID           4 /* Channel ID for pin AN20                          */
#define AN21_CHID           5 /* Channel ID for pin AN21          */
IfxEvadc_Adc         g_evadc;
IfxEvadc_Adc_Group   g_adcGroup;
IfxEvadc_Adc_Channel g_adcChannel[CHANNELS_NUM];/* EVADC channels handle array                      */
uint8 g_grp2channels[CHANNELS_NUM] = {AN17_CHID, AN20_CHID, AN21_CHID}; /* AN17, AN20, AN21 channel IDs array       */

//...
void initAdc(void)
{
    /* Create configuration */
    IfxEvadc_Adc_Config adcConfig;
    IfxEvadc_Adc_initModuleConfig(&adcConfig, &MODULE_EVADC);

    /* Initialize module */
    IfxEvadc_Adc_initModule(&g_evadc, &adcConfig);

    /* Create and initialize group configuration with default values */
    IfxEvadc_Adc_GroupConfig adcGroupConfig;
    IfxEvadc_Adc_initGroupConfig(&adcGroupConfig, &g_evadc);

    /* Setting user configuration using group 2 */
    adcGroupConfig.groupId = IfxEvadc_GroupId_2;
    adcGroupConfig.master = IfxEvadc_GroupId_2;

    /* Enable queued source */
    adcGroupConfig.arbiter.requestSlotQueue0Enabled = TRUE;

    /* Enable all gates in "always" mode (no edge detection) */
    adcGroupConfig.queueRequest[0].triggerConfig.gatingMode = IfxEvadc_GatingMode_always;

    /* Initialize the group */
    IfxEvadc_Adc_initGroup(&g_adcGroup, &adcGroupConfig);

    /* Create channel configuration */
    IfxEvadc_Adc_ChannelConfig adcChannelConfig[CHANNELS_NUM];

    for(uint16 idx = 0; idx < CHANNELS_NUM; idx++)
    {
        /* Initialize the configuration with default values */
        IfxEvadc_Adc_initChannelConfig(&adcChannelConfig[idx], &g_adcGroup);

        /* Select the channel ID and the respective result register */
        adcChannelConfig[idx].channelId = (IfxEvadc_ChannelId)(g_grp2channels[idx]);
        adcChannelConfig[idx].resultRegister = (IfxEvadc_ChannelResult)(g_grp2channels[idx]);

        adcChannelConfig[idx].resultPriority = 20 + idx;

        /* Initialize the channel */
        IfxEvadc_Adc_initChannel(&g_adcChannel[idx], &adcChannelConfig[idx]);
    }
    
    for(uint16 idx = 0; idx < CHANNELS_NUM; idx++)
    {
        /* Add channel to queue with refill option enabled */
        IfxEvadc_Adc_addToQueue(&g_adcChannel[idx], IfxEvadc_RequestSource_queue0, IFXEVADC_QUEUE_REFILL);
    }
    
    /* Start the queue */
    IfxEvadc_Adc_startQueue(&g_adcGroup, IfxEvadc_RequestSource_queue0);
}

 

 

The code is based on examples:
https://github.com/Infineon/AURIX_code_examples/blob/master/code_examples/DMA_ADC_Transfer_1_KIT_TC3...
https://github.com/Infineon/AURIX_code_examples/blob/master/code_examples/ADC_Queued_Scan_1_KIT_TC39...

0 Likes
3 Replies
Di_W
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

Hi srgbtl,

If not use DMA, if your ADC result interrupt works? And how many ADCs works?

 

dw

0 Likes
srgbtl
Level 1
Level 1
First reply posted 5 sign-ins First like given

Hi @Di_W 

 

An interrupt is triggered only for the latest configured channel in the group. In the example above the configuration sequence is: G2CH1, G2CH4, G2CH5, so interrupt will be triggered for G2CH5 only. In case the configuration sequence is changed to G2CH5, G2CH4, and G2CH1, then an interrupt will be triggered for G2CH1.

0 Likes
Curious
Level 2
Level 2
25 sign-ins First like received 5 replies posted

Hi srgbtl,

did you find a solution to your Problem?

I've seen the same result in my Code. Only the last defined Interrupt works for the Group.

0 Likes