This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SAADC - Calibration

nrf52832.

SDK14.2

Segger ES V3.34a

I am using nrf_drv_saadc_calibrate_offset() and find the next sample immediately after the calibration is erroneous.

There is an errata for this [86].  This suggests the following...

Workaround

Calibration should follow the pattern STOP -> STOPPED -> CALIBRATEOFFSET -> CALIBRATEDONE -> STOP -> STOPPED -> START.

I have tried to implement this, which has improved the problem, although 1 in 4 calibrations still cause the erroneous first sample.

implemented every 100 ADC events

nrf_drv_saadc_abort();                                                               // Abort all ongoing conversions. Calibration cannot be run if SAADC is busy

NRF_LOG_INFO("SAADC calibration starting... \r\n");

while(nrf_drv_saadc_calibrate_offset() != NRF_SUCCESS);    //Trigger calibration task

nrf_saadc_disable();
while(NRF_SAADC->STATUS == (SAADC_STATUS_STATUS_Busy << SAADC_STATUS_STATUS_Pos))
{}


nrf_saadc_enable();
while(NRF_SAADC->STATUS == (SAADC_STATUS_STATUS_Busy << SAADC_STATUS_STATUS_Pos))
{}

Then...continue with ADC samples as normal.

 

I am tempted not to bother with the workaround and just discard the first sample after a calibration.

Has anyone else implemented this workaround successfully?

 

  • I have not encountered this specifically, but I have observed that SAADC calibration results in multiple DONE events, including one final DONE event that occurs after CALIBRATEDONE has been asserted. The interval between CALIBRATEDONE and the extra DONE is TACQ + 1.252 us, which is the interval between DONE events during calibration.

    If STOP is issued less than 4 us after CALIBRATEDONE the additional DONE event is not generated.

    My hypothesis is this extra DONE event is the underlying cause of PAN 86.  Perhaps the workaround is being initiated too late sometimes.

Related