ADC Queued Conversion Question

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

cross mob
Ikavalis
Level 1
Level 1
10 sign-ins First like given 5 sign-ins

Hello!

I am trying to configure the VADC module of tc234 to read from 5 analog pins and convert the inputs based on a timed interrupt.

For this purpose I am initializing 5 channels of group 0 and adding them to the queue. The STM is triggering an interrupt every 1ms and that's when I request a conversion using a software trigger.

My questions are:

1. does the above flow make sense or would it be better that I use an external trigger generated by i.e STM?

2. where and when should I refill the queue after a successful conversion? Should I refill after I generate the software trigger? Should I wait for the result to be read first? I don't want to use the auto-refill option.

My code for requesting a conversion looks like this:

/* This function starts an ADC conversion */
void convertADC(void)
{
/* Software Trigger for Conversion */
VADC_G0QMR0.B.TREV = 1;

/* Add channel to queue */
for(int i = 0; i < NUM_OF_CHANNELS; i++){
VADC_G0QINR0.U = i /*channel*/ | 0 /*options*/;
}
}

0 Likes
3 Replies
Prudhvi_E
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 25 likes received

Hi,

Please refer to following links to training and code examples on ADC queued scan:

https://www.infineon.com/dgdl/Infineon-AURIX_ADC_Queued_Scan_1_KIT_TC275_LK-TR-Training-v01_00-EN.pd... 

https://github.com/Infineon/AURIX_code_examples/tree/master/code_examples/ADC_Queued_Scan_1_KIT_TC27... - ADS example for TC275 but you may adapt for your derivative.

1. Are you intending to do a SW based or HW based Conversion Trigger?

2. My understanding is you're starting the conversion (convertADC) in the 1ms Timer ISR. Is my understanding correct ?

Regards,

Prudhvi.

0 Likes

Hello, thank you for your reply.

Regarding your second question, yes, that is correct.

For the first question, I am currently using a software trigger. My only requirement is that the trigger is timer based.

What I want, ultimately, is that a sequence of conversions is triggered every 1 ms and an interrupt is generated when the whole sequence has been completed.

Currently, I am calling the convertADC function in a 1ms Timer ISR and have a result ISR setup on the last element of the queue.

It works, but my question is, what would be an optimal/standard way of doing this?

0 Likes
Prudhvi_E
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 25 likes received

Hello,

GTM TOM could be used to periodically trigger the ADC conversions at a defined rate or you could call the same ConvertADC function in Task context instead of an ISR.

Regards,

Prudhvi. 

0 Likes