Skip to main content
DJack.8
Associate II
July 14, 2021
Question

STM32L031, VREFINT error depending on prior channel voltage.

  • July 14, 2021
  • 3 replies
  • 1057 views

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.

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
July 14, 2021

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
July 14, 2021

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
DJack.8Author
Associate II
July 14, 2021

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.