The purpose of this forum post is to figure out why the internal temperature sensor on my STM32L0 processor is reading all 1’s (0x7FF) after a power cycle or software reset. I will try to include as much information as I can about my setup, the way I reproduce the problem, and all the different things I have tried to fix the problem so that anyone reading this can jump in at the same place I am in this investigation.
I will start by describing the device I am using, all the debugging tools I have available, and the STMCubeMX settings for the internal temperature channel of the ADC.
Debugger: ST-Link/V2 (B 2018 15)
Power Supply: Variable Voltage Supply
Debug Equipment: Oscilloscope, DMM, Soldering Iron, Spare Wire (for snooping), Access to lab
IDE: System Workbench
Cube MX Settings:
Use Of Temperature Sensor In Code:
‘HAL-generated’ initialization of the adc
My code that reads temperature calibration points(defined in datasheet) from device ROM.
My code that triggers an ADC conversion, throws that first conversion away (per suggestion from device errata), performs a second conversion, then calculates temperature from that second conversion.
Reproducing The Error
Launching a debug session, flashing a release build of the firmware to the processor with system workbench, and using the ST-Link programming utility to flash the processor all allow the code to work correctly and convert temperature in the way I would expect. I get counts that make sense and convert them to roughly 25 degrees c which is reasonable for my room temperature.
The problem occurs if I power cycle the processor or perform a software reset after flashing the processor or launching a debug session. After either of these reset methods, my temperature calculation is always 601 degrees c which converts to 0x7FF in adc counts. As this is all ones, it seems like there is a problem with the ADC after a power cycle or software reset.
Any help or direction you can provide as to what is happening would be greatly appreciated.
If you are more interested in the ways I have tried to troubleshoot this issue, I have detailed my debugging in the following forum post.