Get 16 consecutive samples - ADC

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

cross mob
Not applicable
Hi all,

I was wondering if it is possible to configure the ADC and its conversion request sources in the following way.

1. All conversions (i.e. some conversion sequence that I define) are triggered once per PWM period - by the period match event. After that, the conversion sequence executes once, and the module waits for the next trigger.
2. At the end, I want 16 results from 3 channels - the sampling sequence is something like this: 1, 2, 1, 3, 1, 2, 1, 3... and so on. I am using DMA to get data out of the result registers and into the main memory - as a result, it is fine if I use 3 result registers total - one per channel.

The main challenge that I am currently facing is that I can only add up to 8 entries to the queue source (note that the background source looks like it can handle more than 8 samples, but I need control over the sampling order). Is there a way to implement this sampling pattern?

Thank you for your time and I appreciate all the suggestions.

Best regards,

Andrey
0 Likes
5 Replies
User7282
Level 4
Level 4
Hello,

If you are using a queue source, I think that you can use the refill option. In that way the sampling will always follow the defined order.
0 Likes
Not applicable
Hi apereira,

I've looked into the refill option - it makes sense to run the same sequence twice to get 16 conversions. However, I don't know how to stop it after 16 conversions have happened. Do you think there is a way to do it? Thank you in advance.

Best regards,

Andrey
0 Likes
User7282
Level 4
Level 4
I'm not sure how are you implementing the ADC trigger and reading, but I assume that you are triggering some kind of interrupt to read the result register.
If this is correct, you can implement a counter that increments in each interrupt and just stop requesting conversions when you have the 16 that you need.
0 Likes
Not applicable
Hi apereira,

Thank you for your reply and I apologise for taking my time to answer this. Here's how my setup works: I do have an interrupt that triggers when the conversion is finished. However, I don't have an interrupt handler enabled - this service request is routed to DMA that reads the results out of the result registers. As much of the program as it is possible is hardware-based - to make it work as fast as it possibly can with as little as possible IRQ "distractions" 🙂 .

What you suggested in the other post - using ERU to route the signals - did work. I routed End-of-Conversion signal from group 0 to group 1 Start-of-Conversion trigger through ERU. Both groups do 8 conversion each - and 16 in total. When group 1 is finished, the entire ADC module waits for the trigger for group 0 to do the sequence all over again.

Do you think this is a good way to do it?

Best regards,

Andrey
0 Likes
User7282
Level 4
Level 4
I think that it is a good solution.

If you want to do "full hardware" implementation, I'm not seeing any better possibility.
0 Likes