Hi Xiangjun,
Please see my functions below. I do the ADC_Init in the main at the beginning, then I run my battlvl_read() and temperature_read() in my other task alternatively. I configured my reference voltage source to Valt, I also tried to connect my Vref to VDD as well. But my temperature read became negative value with the taskdelay. See result in the images.
void ADC16_GetDefaultConfig(adc16_config_t *config)
{
assert(NULL != config);
config->referenceVoltageSource = kADC16_ReferenceVoltageSourceValt;
config->clockSource = kADC16_ClockSourceAsynchronousClock;
config->enableAsynchronousClock = true;
config->clockDivider = kADC16_ClockDivider8;
config->resolution = kADC16_ResolutionSE12Bit;
config->longSampleMode = kADC16_LongSampleCycle10;
config->enableHighSpeed = true;
config->enableLowPower = true;
config->enableContinuousConversion = false;
}
void ADC_Init(void)
{
ADC16_GetDefaultConfig(&adc16ConfigStruct);
ADC16_Init(ADC16_BASE, &adc16ConfigStruct);
ADC16_SetHardwareAverage(ADC16_BASE, kADC16_HardwareAverageCount32);
ADC16_EnableHardwareTrigger(ADC16_BASE, false);
ADC16_DoAutoCalibration(ADC16_BASE);
adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = false;
adc16ChannelConfigStruct.enableDifferentialConversion = false;
}
uint32_t BattLvl_Read()
{
static uint32_t ADC_BattValue;
adc16ChannelConfigStruct.channelNumber = BATTLVL_ADC16_USER_CHANNEL;
ADC16_SetChannelConfig(ADC16_BASE, ADC16_CHANNEL_GROUP, adc16ChannelConfigStruct);
vTaskDelay(15/portTICK_RATE_MS);
ADC_BattValue = ADC16_GetChannelConversionValue(ADC16_BASE, ADC16_CHANNEL_GROUP);
return ADC_BattValue;
}
int32_t Temperature_Read()
{
static uint32_t ADC_TempValue;
static int32_t ADC_CValue;
adc16ChannelConfigStruct.channelNumber = TEMPSEN_ADC16_USER_CHANNEL;
ADC16_SetChannelConfig(ADC16_BASE, ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
vTaskDelay(15/portTICK_RATE_MS);
ADC_TempValue = ADC16_GetChannelConversionValue(ADC16_BASE,ADC16_CHANNEL_GROUP);
if (ADC_TempValue >= 917)
ADC_CValue = 25 - (((ADC_TempValue - 917) * 100) / 204); // Cold Slope
else
ADC_CValue = 25 + (((917 - ADC_TempValue) * 100) / 219); // Hot Slope
return ADC_CValue;
}
With time delay, ADC value reads properly on both functions.

Without the time delay, the temperature read became negative.

Please advise. Thank you.
Gilbert