SLAZ753A October 2023 – May 2024 MSPM0C1103 , MSPM0C1103-Q1 , MSPM0C1104 , MSPM0C1104-Q1
ADC offset error needs to be calibrated in application code
Rev C
The calibration data of ADC offset error is not applied correctly AND needs to be implemented in application code.
The calibration data is stored at address 0x41C40040 in factory region. Two DriverLib APIs DL_ADC12_getADCOffsetCalibration AND DL_FactoryRegion_getADCOffset have been implemented in the SDK to facilitate this.
__STATIC_INLINE int16_t DL_ADC12_getADCOffsetCalibration(float userRef)
{
float adcBuff = DL_FactoryRegion_getADCOffset() * (3.3 / userRef);
return (int16_t)(round(adcBuff));
}
__STATIC_INLINE float DL_FactoryRegion_getADCOffset(void)
{
return ((float) (*(int16_t *) (0x41C40040)));
}
The calibration data can be saved into a variable AND subsequently applied to the ADC conversion result.
Below is the example code demonstrating how to apply the calibration data, which has been integrated into the ADC examples provided in the SDK:
volatile uint16_t gAdcResult;
volatile int16_t gADCOffset;
gADCOffset = DL_ADC12_getADCOffsetCalibration(ADC12_0_ADCMEM_0_REF_VOLTAGE_V);
gAdcResult = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_0);
int16_t adcRaw = (int16_t) gAdcResult + gADCOffset;
if (adcRaw < 0) {
adcRaw = 0;
}
if (adcRaw > 4095) {
adcRaw = 4095;
}
gAdcResult = (uint16_t) adcRaw;
The ADC offset calibration data can be applied for the example use cases below: