cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L031, VREFINT error depending on prior channel voltage.

DJack.8
Associate II

I am using a STM32L031 on a Nucleo board to sample analog inputs and VREFINT. When I sample the VREFINT voltage after another channel I observe some error that changes depending on the voltage on that previous channel. I assuming that charge is being carried from the previous sample to the VREFINT channel. I could not find this issue discussed in documentation. A long delay between the sampling helps but it is undesirable due to energy usage. How can I eliminate this issue.

A second issue is the code only works correctly when I sample channels in order. If I instead sample 5, 3, 4, VREFINT the data is incorrect. What am I missing?

I attached the code.

3 REPLIES 3

Do you observe the sampling time for VREFINT channel, specified by the datasheet?

 0693W00000CzcaeQAB.pngIf you switch off/on VREFBUF, you have to observe also the related delay, defined in the same table.

JW

TDK
Guru

Increase the sampling time to both increase accuracy and meet the datasheet requirement on sampling time for VREFINT.

0693W00000CzchSQAR.png 

ST really should make the max sampling time the default.

If you feel a post has answered your question, please click "Accept as Solution".
DJack.8
Associate II

That was it. Thanks to both of you for that !!

I just need to figure out why the scan always goes 3,4,5, VREFINT even when I try 5,3,4,VREFINT. I though discontinuous meant I could pick the order.