2016-01-14 02:06 AM
To sample the temperature sensor I am using the HAL_ADCEx_InjectedConfigChannel. Since the ADC_CHANNEL_TEMPSENSOR and ADC_CHANNEL_VBAT share ADC channel, only one of them can be sampled at a time, depending on the bits set in ADC->CCR. The HAL_ADCEx_InjectedConfigChannel seems to set both the VBAT and TSVREF bit which will favour VBAT, thus impossible to sample temperature.
From reference manual (RM0385):15.11 Battery charge MonitoringNote:The VBAT and temperature sensor are connected to the same ADC internal channel (ADC1_IN18). Only one conversion, either temperature sensor or VBAT, must be selected at a time. When both conversion are enabled simultaneously, only the VBAT conversion is performed. #adc-vbat-tempsensor-hal