2017-04-07 07:42 AM
Hi
I am beginning to wonder if this is an issue with CubeMX? I recently posted an issue I am having below on the ADC of the STM32L073 chip. Its a small application created with CubeMX and have checked it many times, and still have the same issues as in the link below. I wanted to check it many times (most of the day) before thinking it must be a CubeMX issue. The 'HAL_ADC_ConvCpltCallback' was only called once on one channel , even though 3 channels have been added. The if (__HAL_ADC_GET_FLAG(hadc, ADC_IT_EOC)) code was executed, and straight after the 'if (__HAL_ADC_GET_FLAG(hadc, ADC_IT_EOS))' was also executed. This makes me think that it is setup for only 1 channel to convert.
https://community.st.com/0D50X00009XkYLuSAN
<< link to issueI have it working, but more like a work around. Within CubeMX I have 'Discontinues convertion mode ' Enabled. And within the HAL_ADC_ConvCpltCallback(..) routine I done the following, just to check to see if it works: In my main.cpp routine I call HAL_ADC_Start_IT(&hadc); to start convertion, then:
HAL_ADC_ConvCpltCallback(..)
{
if (__HAL_ADC_GET_FLAG(hadc, ADC_IT_EOC)) //check convertion on channel
{ EOCCount++; ADC_Raw[ADC_index++]=HAL_ADC_GetValue(hadc); if(ADC_index==3) ADC_index=0; //after the 3 channels converted reset else HAL_ADC_Start_IT(hadc); //restart on next channel}
//this time, the below got called only once as expected, after the 3 ADC_IT_EOC above were executed.
if (__HAL_ADC_GET_FLAG(hadc, ADC_IT_EOS))
{ EOSCount++;}
Anyone suggest the best way to go from here regarding this?
Thanks
Scott
null2017-04-10 09:21 AM
Hi
devlin.scott
,Thank you for reported issue.
I will raise this internally for more checking and we come back to you soon.
Imen
2017-06-07 01:48 PM
Hi Imen
I having the exact same issues on the stm32L011k4, has this been resolved?
Thanks
Nathan
2017-06-08 04:50 AM
Hi
gates.nathan
,I have checked the status of this issue internally and our teamis working on the analysis for fixing it in the coming releases.
Sorry for any inconvenienceit may bring for you.
Best Regards
Imen
2017-09-07 04:05 AM
Hi Scott Dev,
It is not safe to call HAL_ADC_Start_IT(hadc) after each EOC interrupt because the value that is read may not correspond to the channel you are expecting in the sequence of ADC channels (Especially if the sequence is already finished).
Please try to check what are the frequencies of the CPU code and the sample time of the ADC. CPU speed should be enough compare to sampling time of ADC. May you try with sampling time being longer?Please find also some advices from Philippe CHERBONNEL:
'When ADC conversions in sequence, it is recommended to use DMA transfer:
- if using ADC only (polling or interruption), each conversion of the sequence has its result stored in data register and overwrites the data of previous conversion. If the CPU does not read data register is time (CPU load too high versus ADC IRQ priority), then the ADC conversion data is lost (overwritten by conversion of the following sequence rank). - if using ADC+DMA, all ADC conversions are transferred independently of CPU load. DMA manages to transfer all data in a table with circular rollback.Note: If using interruption at each DMA transfer completion (this is the case using HAL driver, optional using LL driver), user must take care that DMA IT occurrence rate does not saturate CPU. This can be done by decreasing ADC conversion rate (increase ADC sampling time, decrease ADC trigger frequency, …).
You can find some examples in STM32L0 FW package (can be downloaded here:
http://www.st.com/en/embedded-software/stm32cubel0.html
). Some examples showing ADC+DMA transfer with several channels are available here: - using LL driver: …\Firmware\Projects\STM32L073RZ-Nucleo\Examples_LL\ADC\ADC_MultiChannelSingleConversion - using HAL driver: …\Firmware\Projects\STM32L053R8-Nucleo\Examples\ADC\ADC_Sequencer'
Philippe also reminded the following link:
https://community.st.com/thread/36558-adc-values-reading-with-dma
Thanks to Philippe and hope it is going to help you.
Regards
Cyril
2017-09-11 10:08 AM
Thanks Cyril
I have decided to not use CubeMX , I used it to learn the processor and amazed at the large overhead of the code. I am now just using the registers .
Thanks
Scott