cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behavior of STM32L053 ADC

Zoran Daric
Associate II
Posted on February 01, 2017 at 18:02

Hi

By writing a program for very simple one channel ADC I faced with very strange behawior of the ADC in my MCU. During tests of the A/D converter, I read Vrefint (channel 17). If very shortly after calibration, about 1 second, I do the A/D conversion, everything is OK, I have correct value. In case I wait for a few seconds (more then 4 seconds) result is wrong. If I do second read very shortly, less then 4 second, I got correct result. If I do reading every second, the results are OK except first one. Note that incorrect value always is 2048 decimal (very strange).

In case I do reading two different channels effect is the same. This mean that I always have to do two conversions to have correct value or to do readings non-stop for all the necessary channels even if I don't need it.

In the attachment are flowcharts for ADC calibration, setup and conversion. I need to know what I'm doing wrong.

Note that clock source for the ADC is HSI at 4MHz. All other parameters except parameters changed in setup after calibration are default values after reset. Changing sampling time doesn't help.

    Regards,

    Zoran

13 REPLIES 13
Posted on February 13, 2017 at 09:25

 ,

 ,

Hi Danilo,

Thank you for advice but bit ADVREGEN can be cleared only if

ADEN=0. In this case ADEN=1. This is already tested on real hardware.

Zoran

W dniu 2017-02-13 o 08:44, bessone.danilo pisze:

>,

STMicroelectronics Community

<,https://community.st.com/?et=watches.email.thread>,

>,

Re: Strange behavior of STM32L053 ADC

reply from bessone.danilo

<,

in /STM32 MCUs Forum/ - View the full discussion

<,https://community.st.com/0D70X000006SPWbSAO

>,

danilo239955
Associate II
Posted on February 13, 2017 at 11:06

Hi,

you are right. 

ADVREGEN can be modified only when ADEN=0. Sorry for my error.

I have read the errata sheet and I found that this bug is a known issue reported in this document (page 14).

Danilo

Posted on February 13, 2017 at 11:23

I have read the errata sheet and I found that this bug is a known issue reported in this document (page 14).

And there it is, indeed... Well spotted, Danilo!

Jan

Posted on February 13, 2017 at 11:31

 ,

 ,

Hi,

You are right it is in Errata. Thanks Danilo

Zoran

W dniu 2017-02-13 o 11:07, bessone.danilo pisze:

>,

STMicroelectronics Community

<,https://community.st.com/?et=watches.email.thread>,

>,

Re: Strange behavior of STM32L053 ADC

reply from bessone.danilo

<,

in /STM32 MCUs Forum/ - View the full discussion

<,https://community.st.com/0D70X000006SWBISA4

>,