Skip to main content
PHryn
Associate III
June 19, 2021
Solved

STM32G4 temperature internal sensor gives wrong reading when fast sampled

  • June 19, 2021
  • 3 replies
  • 2429 views

Hi All,

As is the topic. Maybe someone else is stuck with the same problem?

I wasted the last few days trying to find why my code is giving wrong (to low) temperature readings but it looks like a device limitation. I try to isolate the test case but in the meantime maybe someone else can confirm or point me to some information why sampling the internal temperature sensor with short time gives incorrect values.

To low I mean values below zero ...

Regards,

Pawel

This topic has been closed for replies.
Best answer by TDK

How fast? There's a minimum sampling time requirement per the datasheet, you're probably running into that. Also a start-up time.

3 replies

TDK
TDKBest answer
June 19, 2021

How fast? There's a minimum sampling time requirement per the datasheet, you're probably running into that. Also a start-up time.

"If you feel a post has answered your question, please click ""Accept as Solution""."
PHryn
PHrynAuthor
Associate III
June 20, 2021

You are right.

I started with default stm32cubeide values which is 15 cycles per ADC conversion, prescaler equal 4 and 170MHz clock.

Its interesting that temperature reading is ok if you mix one slow conversion (650) with fast ones.

I didn't read LL_ADC_SetChannelSamplingTime function description:

* @note In case of internal channel (VrefInt, TempSensor, ...) to be
 * converted:
 * sampling time constraints must be respected (sampling time can be
 * adjusted in function of ADC clock frequency and sampling time
 * setting).
 * Refer to device datasheet for timings values (parameters TS_vrefint,
 * TS_temp, ...).

Repository with my test:

https://github.com/phryniszak/app_nucleo_g431kb_temperature

waclawek.jan
Super User
June 20, 2021

Also, note the Wrong ADC result if conversion done late after calibration or previous conversion erratum.

JW