2017-05-06 04:31 AM
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
.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.
adc stm32f030-adc2017-05-06 05:08 AM
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.
2017-05-06 07:48 AM
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).
2017-05-06 09:23 AM
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.
2017-05-06 10:34 AM
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?
2017-05-06 11:28 AM
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