5.2.5.12 Temperature Sensor
The temperature sensor is internally connected to the channel with the highest index. For temperature measurement, ADC_TEMPMR.TEMPON must be set.
Temperature measurement can be performed in different ways through the ADC Controller. The different methods of measurement depend on configuration bits ADC_TRGR.TRGMOD and ADC_CHSR.CHmax (max=highest index).
Temperature measurement can be triggered like the other channels by enabling its associated conversion channel, writing 1 in ADC_CHER.CHmax (max=highest index).
The manual start can only be performed if ADC_TRGR.TRGMOD = 0. When ADC_CR.START is set, the temperature sensor channel conversion is scheduled together with the other enabled channels (if any). The result of the conversion is placed in the ADC_CDRmax (max=highest index) register and the associated ADC_EOC_ISR.EOCmax (max=highest index) flag is set.
If ADC_TRGR.TRGMOD = 1, 2, 3 or 5, the temperature sensor channel is periodically converted together with other enabled channels and the result is placed on the ADC_LCDR and ADC_CDRmax (max=highest index) registers. Thus, the temperature conversion result is part of the DMA Controller buffer. The temperature channel can be enabled/disabled at any time but this may not be optimal for downstream processing.
When the conversion result matches the conditions defined in the ADC_TEMPMR and ADC_TEMPCWR, the ADC_ISR.TEMPCHG flag is set.
The temperature factor having a slow variation rate and being potentially totally different from the other conversion channels, the ADC Controller allows a different way of triggering the measure when ADC_TEMPMR.TEMPON is set but ADC_CHSR.CHmax (max=highest index) is not set.
Under these conditions, the measure is triggered every second by means of an internal trigger generated by the RTC, always enabled and totally independent of the internal/external triggers. The RTC event will be processed on the next internal/external trigger event, as described in the following figure. The internal/external trigger is selected through ADC_MR.TRGSEL.
In this mode of operation, the temperature sensor is only powered for a period of time covering the start-up time and conversion time (see the figure Temperature Conversion Only for more details).
Every second, a conversion is scheduled for the temperature channel but the result of the conversion is only uploaded in the ADC_CDRmax (max=highest index) register and not in ADC_LCDR. Therefore, there is no change in the structure of the DMA Controller buffer due to the conversion of the temperature channel, only the enabled channels are kept in the buffer. The end of conversion of the temperature channel is reported by the ADC_EOC_ISR.EOCmax (max=highest index) flag.
If TEMPON = 1, TRGMOD = 0 and none of the channels are enabled in ADC_CHSR (ADC_CHSR = 0), then only the temperature channel is converted at a rate of 1 conversion per second (see the figure Temperature Conversion Only).
This mode of operation, when combined with the Sleep mode operation of the ADC Controller, provides a low-power mode for temperature measurement (assuming there is no other ADC conversion to schedule at a high sampling rate, or simply no other channel to convert).
Furthermore, it is possible to raise a flag only if there is a predefined change in the temperature measure. The user can define a range of temperatures or a threshold in ADC_TEMPCWR, and the mode of comparison that can be programmed in ADC_TEMPMR.TEMPCMPMOD. These values define how the ADC_ISR.TEMPCHG flag is raised.
In any case, if TEMPON is set and a conversion trigger event occurs, the temperature can be read in ADC_CDRmax (max=highest index).