cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 temperature internal sensor gives wrong reading when fast sampled

PHryn
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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".

View solution in original post

3 REPLIES 3
TDK
Guru

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
Associate III

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

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

JW