cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030 - problems with ADC conversion time

David Martins
Senior
Posted on May 06, 2017 at 13:31

Hello,

I need help finding a problem.

I have been studying this situation for some time and I can not solve it.

The MCU used is the

http://www.st.com/content/ccc/resource/technical/document/reference_manual/cf/10/a8/c4/29/fb/4c/42/DM00091pdf/files/DM00091pdf/jcr:content/translations/en.DM00091pdf

.

I configured the ADC to use the dedicated ADC clock of 14MHz, use continuous conversion with 12bits and with interrupt at the end of each conversion.

According to the reference manual, I should be able to get conversions in 1us and that's what I'm looking for!

But at this point the conversion time is much higher than that, as you can see in the image.

A pin does toggle whenever the interrupt is called and so the conversion time is 4.16us.

I can not find any math calculation for that value.

Can you help me?

I have no idea what can cause this!

I have read the datasheet, reference manual, application notes, etc ... but nothing gives me clues as to what can happen.

https://spostimg.org/c5unxnldz/SDS00jpg

adc stm32f030-adc

5 REPLIES 5
Posted on May 06, 2017 at 14:08

DMA is designed for high rates, IRQ eat a lot of cycles in entry/exit costs.

Try using a small DMA buffer to decimate  IRQ loading.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 06, 2017 at 14:48

Hello Clive!

Thank you for your help.

I had already tested it, but I only did 2-position circular buffer and the results were not any good.

I have now buffered 10 and the timmings have already hit it right!

Thank you.

https://spostimg.org/oxck2z1tj/SDS00jpg

But I have another question.

I noticed that the interrupt routine (using DMA) is always called.

Is there any way to not waste time with it?

I want to read 2 ADC channels and I want to access the ADC DMA buffer and collect the last 2 readings performed.

For this I use the circular buffer, but every time the buffer gets full (2 readings = 2us) the interrupt is created, then the CPU never gets free ...

I just want the ADC interrupt not to be called (unless it's important to make the circular buffer).

Posted on May 06, 2017 at 16:23

The DMA interrupt does not need to be used. With the SPL I typically enable both HT and TC to manage alternate halves of the buffer. Ie the inactive half.

If you pace the ADC via a TIM there are ways to use a trigger and repetition count to enable more exotic behavior.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 06, 2017 at 17:34

If you use CUBEMX, there is not much choice ...

https://spostimg.org/letuwpu9f/Capturar.jpg

In the MX_DMA_Init function, I can comment on the initialization of the NVIC interrupt.

How can I prove that the operation is not affected by this?

void MX_DMA_Init(void)

{

/* DMA controller clock enable */

__HAL_RCC_DMA1_CLK_ENABLE(); /* DMA interrupt init */

/* DMA1_Channel1_IRQn interrupt configuration */

//HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);

//HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);

}

[EDIT]

I made debug of this and the buffer is filled correctly by DMA ...

But I still do not know for certain that the conversion timings are the same.

But I can assume so, right?

Posted on May 06, 2017 at 20:28

How long does your ISR take? Set the pin at the ISR entry and clear it at exit. I mean the real ISR, not the callback. And add some 30-40 cycles for entry/exit (HW+compiler-imposed). What's the system clock frequency?

JW