Other Parts Discussed in Thread: MSPM0L1306
Dear Sir or Madam!
I have such a problem, that the internal temperature sensor is very noisy when there is a delay between two measurements. If there is not any delay, the measurements are not noisy at all. The ADC monitors 4 channel using external reference, the rest 3 channel are good, but the temperature channel is not. I tried many settings of ADC. but the problem is present.
I tried the followings:
-Different Clock sources/divide values/f range values and different sampling times(greater than 6.1us)
-Disabling Temperature sensor by selecting another channel for that conversion memory , and enabling again by selecting channel 11
-Using repeat mode causing more floating result
-relocating DL_ADC12_enableConversions function, and usage of DL_ADC12_disableConversions(ADC0);
I attach an example code for being more understandable.
Example 1: when the temperature sensor is not noisy:
int main(){
initSystem();
initAdc();
while(true){
makeMeasurement();
}
}
Example 2: when the temperature sensor is noisy (often adc measures too low or zero value)
int main(){
initSystem();
initAdc();
while(true){
makeMeasurement();
someDelay();
}
}
someDelay could be delay_cycles() or for(int i=0;i<10000;i++) or any timer polled boolean value(while(!value);)
initAdc(){
DL_GPIO_reset(GPIOA);
DL_ADC12_reset(ADC12_0_INST);
DL_VREF_reset(VREF);
DL_GPIO_enablePower(GPIOA);
DL_ADC12_enablePower(ADC12_0_INST);
DL_VREF_enablePower(VREF);
DL_ADC12_ClockConfig gADC12_0ClockConfig = {
.clockSel = DL_ADC12_CLOCK_ULPCLK,
.divideRatio = DL_ADC12_CLOCK_DIVIDE_1,
.freqRange = DL_ADC12_CLOCK_FREQ_RANGE_24_TO_32
};
static const DL_VREF_Config gVREFConfig = {
.vrefEnable = DL_VREF_ENABLE_DISABLE,
.bufConfig = DL_VREF_BUFCONFIG_OUTPUT_2_5V,
.shModeEnable = DL_VREF_SHMODE_DISABLE,
.holdCycleCount = DL_VREF_HOLD_MIN,
.shCycleCount = DL_VREF_SH_MIN,
};
static const DL_VREF_ClockConfig gVREFClockConfig = {
.clockSel = DL_VREF_CLOCK_BUSCLK,
.divideRatio = DL_VREF_CLOCK_DIVIDE_8,
};
DL_ADC12_initSeqSample(ADC0,
DL_ADC12_REPEAT_MODE_DISABLED,
DL_ADC12_SAMPLING_SOURCE_AUTO,
DL_ADC12_TRIG_SRC_SOFTWARE,
DL_ADC12_SEQ_START_ADDR_00, DL_ADC12_SEQ_END_ADDR_03,
DL_ADC12_SAMP_CONV_RES_12_BIT,
DL_ADC12_SAMP_CONV_DATA_FORMAT_UNSIGNED);
DL_ADC12_configConversionMem(ADC0,
DL_ADC12_MEM_IDX_0,
DL_ADC12_INPUT_CHAN_11,
DL_ADC12_REFERENCE_VOLTAGE_EXTREF, //3.3V
DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0,
DL_ADC12_AVERAGING_MODE_ENABLED,
DL_ADC12_BURN_OUT_SOURCE_DISABLED,
DL_ADC12_TRIGGER_MODE_AUTO_NEXT,
DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
DL_ADC12_setPowerDownMode(ADC0, DL_ADC12_POWER_DOWN_MODE_AUTO);
DL_ADC12_configHwAverage(ADC0, DL_ADC12_HW_AVG_NUM_ACC_8, DL_ADC12_HW_AVG_DEN_DIV_BY_8);
DL_ADC12_setSampleTime0(ADC0, 240); //tried longer samp time
DL_ADC12_clearInterruptStatus(ADC0, DL_ADC12_INTERRUPT_MEM3_RESULT_LOADED);
DL_ADC12_enableInterrupt(ADC0, DL_ADC12_INTERRUPT_MEM3_RESULT_LOADED);
DL_VREF_setClockConfig(VREF,
(DL_VREF_ClockConfig *)&gVREFClockConfig);
DL_VREF_configReference(VREF,
(DL_VREF_Config *)&gVREFConfig);
while (DL_VREF_CTL1_READY_NOTRDY == DL_VREF_getStatus(VREF));
NVIC_EnableIRQ(ADC0_INT_IRQn);
DL_ADC12_enableConversions(ADC0);
}
initSystem(){
DL_SYSCTL_setSYSOSCFreq(DL_SYSCTL_SYSOSC_FREQ_BASE);
DL_SYSCTL_setMCLKDivider(DL_SYSCTL_MCLK_DIVIDER_DISABLE);
DL_SYSCTL_setPowerPolicyRUN0SLEEP0// i tried also DL_SYSCTL_setPowerPolicyRUN1SLEEP1();
DL_SYSCTL_setBORThreshold(DL_SYSCTL_BOR_THRESHOLD_LEVEL_0);
}
makeMeasurement(){
DL_ADC12_startConversion(ADC0);
while(!adcready);
adcready=false;
filteredAdcValue =filteredAdcValue*0.99+0.01*DL_ADC12_getMemResult(ADC0, DL_ADC12_MEM_IDX_0);
float V_Sample = (filteredAdcValue - 0.5) * 3.3 / 4096.0;
float V_Trim = (factoryTrimValue - 0.5) * 3.3 / 4096.0;
float T_Sample = ((1.0 / -0.002044) * (V_Sample - V_Trim) + 30.0);
DL_ADC12_enableConversions(ADC0);
}
ADC0_IRQHandler()
{
switch (DL_ADC12_getPendingInterrupt(ADC0))
{
case DL_ADC12_IIDX_MEM3_RESULT_LOADED:
{
adcready=true;
break;
}
default:
break;
}
}
Thank you in advance for helping!