cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L431RCT6 internal temperature value too high when using DMA

unsigned_char_array
Senior III

I have an STM32L431RCT6. I'm trying to read the internal temperature sensor using DMA, but I get temperature values > 130 degrees C.

I can read the temperature without the DMA just fine. And the other channels can be read fine using regular conversion or DMA.

I now first read the VREF channel, then ADC channel 1 and then the Temperature sensor. But I've tried putting the internal temperature sensor at different ranks (first, last, multiple times in a row), but that didn't help.

The values are pretty consistent and I set ADC cycles to 640.5 for each channel. My CPU is clocked at 80MHz and my ADC at 5MHz. I've tried lower and higher clocks.

ADC is calibrated after initialization.

My ADC temperature calibration values are 1034 and 1370 for 30 and 130 degrees C respectively, but I get ADC values > 1500 @ 20C when using DMA!

My VDDA is 3.3V instead of the calibration value of 3.0V, so I would expect lower ADC values than the calibration values, not 50% higher.

Without the DMA I get values between 21 and 23 degrees C, which is what I expect.

In the errata sheet I've read that the first conversion can be faulty, but even taking multiple samples doesn't change anything.

What am I doing wrong?

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
1 ACCEPTED SOLUTION

Accepted Solutions
unsigned_char_array
Senior III

I found the solution:

https://community.st.com/s/question/0D50X0000AX7SRDSQ3/ll-adc-with-dma

It is a bug in CubeMX! It uses the wrong define!

It used LL_ADC_PATH_INTERNAL_TEMPSENSOR instead of LL_ADC_CHANNEL_TEMPSENSOR and it used LL_ADC_PATH_INTERNAL_VREFINT instead of LL_ADC_CHANNEL_VREFINT!

Edit:

I also experienced the following problem, but that was fixed too: https://community.st.com/s/question/0D53W00001uJJ3KSAW/adc-register-adrdy-never-sets-when-i-enable-the-adc-so-it-keeps-waiting-there-to-start-stm32f303rbt6

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

View solution in original post

3 REPLIES 3

Is the temperature sensor enabled in ADC_CCR?

Do the values from other channels match the expectation?

What exactly is your hardware? Is this a "known good" board like Nucleo? If not, how exactly is VREF+/VDDA pin(s) connected, do they measure a rock stable voltage against VSSA?

JW

"Is the temperature sensor enabled in ADC_CCR?"

Yes

"Do the values from other channels match the expectation?"

Unfortunately they are either close to 0 or VDDA due to a hardware error (opamps cliping to almost VDDA due to too high gain), so I cannot their accuracy, but they do behave as expected.

"What exactly is your hardware? Is this a "known good" board like Nucleo? If not, how exactly is VREF+/VDDA pin(s) connected, do they measure a rock stable voltage against VSSA?"

It is a custom board. VDDA is a low pass filtered 3V3. VDDA and VREF+ are internally connected in this MCU. VDDA measures 3.28V with the ADC and I measured 3.26V with a cheap multimeter.

All ADC values only vary about 1 LSb.

Edit: I just noticed the value of the ADC values for temperature are identical to the VREF INT measurements when using the DMA. Is it possible the DMA switches the wrong channel?

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
unsigned_char_array
Senior III

I found the solution:

https://community.st.com/s/question/0D50X0000AX7SRDSQ3/ll-adc-with-dma

It is a bug in CubeMX! It uses the wrong define!

It used LL_ADC_PATH_INTERNAL_TEMPSENSOR instead of LL_ADC_CHANNEL_TEMPSENSOR and it used LL_ADC_PATH_INTERNAL_VREFINT instead of LL_ADC_CHANNEL_VREFINT!

Edit:

I also experienced the following problem, but that was fixed too: https://community.st.com/s/question/0D53W00001uJJ3KSAW/adc-register-adrdy-never-sets-when-i-enable-the-adc-so-it-keeps-waiting-there-to-start-stm32f303rbt6

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.