cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Continuous Conversion Mode .

Khoo.B
Associate III

I have a sensor with analog data and I am connecting it to one of the ADC pins (STM32L152). I have no problem to read a single conversion data. However, I would like to one shot capture multiple ADC data (for example, 128) so it will be more consistent in terms of sampling rate.

Which mode should I use and do we have an example for it?

Thanks!

4 REPLIES 4
Ozone
Lead

> However, I would like to one shot capture multiple ADC data (for example, 128) so it will be more consistent in terms of sampling rate.

Then, continuous mode is not the way to go. This is just an endless sequence of back-to-back conversions.

Use a timer as trigger to establish the proper sampling rate, and preferably DMA to retrieve the results.

DMA can be setup to any size up to 64kByte, so 128 values is perfectly fine.

I had done this with a F407 and F303 multiple times, but have no L152 example, though.

Perhaps Cube/HAL generated, albeit I would not really recommend it ...

Khoo.B
Associate III

Thanks! I thought there will be a way to capture multiple data (stored at buffer/DMA) and each data is sampled at X kHz. But, it seems like I will have to use the timer.

That's basically what happens.

You set up the timer, and start it when you are ready.

You set up DMA for a specific number of samples (e.g. 128 words = 256 bytes), and a TC interrupt (transmission complete).

Then you get a DMA-TC interrupt every time another buffer of 128 values is ready.

The sampling rate itself is determined by the timer.

With continuous mode, you could only adjust the timing via sampling time settings.

Check the datasheet / reference manual for timers and DMA channels appropriate for working with the ADC.

I didn't do many projects on the L152, though.

Khoo.B
Associate III

Thanks! How do you set the DMA for a specific number of samples. Any particular function?