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

SAADC BURST problems in scan vs non-scan acquisitions

I'm using the SAADC peripheral by controlling its registers directly (no SDK or MDK HAL). I have an application that alternates between two configurations:

* One sample from AIN1
* A sample from AIN4 followed by a sample from AIN5

Reduced reproducing code is available in this gist.

For each case I configure the SAADC registers including setting RESULT.MAXCNT set to 1 or 2 as appropriate, enable SAADC and issue START and SAMPLE, then when it's done stop and disable the SAADC, and sleep for one second.  All configurations use oversampling and enable BURST in all channels.  Per the nRF52832 PS and this devzone question this should work for both one-shot and scan mode, even though it's not supported in the SDK/nrfx driver.

If I repeat the sequence above I get the following results:

* The first acquisition of one sample from AIN1 works correctly.
* The first acquisition of two samples from AIN4-AIN5 works correctly.
* The second acquisition of one sample from AIN1 works correctly.
* The second acqusition of two samples from AIN4-AIN5 fails.

For the last case I get a successful collection from AIN4 (one EVENTS_RESULTDONE), then the SAADC STATUS goes to idle with RESULT.AMOUNT=1 but RESULT.MAXCNT=2 as configured. I never get an END event.

I can repeat one-sample acquisitions forever.

I can repeat scan-mode (2, 3, 4 channels) acquisitions forever.

What I can't do is capture scan-mode, capture one-shot, then capture scan-mode again: the peripheral always stops after the first channel in the scan-mode completes.

If I turn off BURST in CH.CONFIG and trigger the extra samples manually after each EVENTS_DONE it works.

My current hypothesis is that BURST works in one-shot mode, and in scan mode, but does not work in scan mode after use in one-shot mode.

Can anybody confirm this? I notice that CONFIG.BURST is not discussed in the nRF52840 oversampling documentation, which suggests it's not stable even though it's worked fine except for this situation.

Parents Reply
  • Thanks, I've confirmed that works, but have a question:

    This appears to power-cycle the SAADC peripheral (that being the role of 0xFFC within other peripherals). I've confirmed that although INTEN appears to be preserved, the sequence clears the CH[i], RESOLUTION, OVERSAMPLE, and RESULT registers (didn't test SAMPLERATE).

    Is SAADC calibration affected by this sequence?

    If so, this workaround may not be useful in my applications since I'd hoped to only have to calibrate when the temperature changed, not before every acquisition.

    [Later: Testing suggests the undocumented registers at 0x62C and 0x630 are affected by calibration.  The workaround does reset those registers.]

Children
Related