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

Using DMA with ADC on nRF52832

Is there any ready-made example that would show how to configure nRF52 to make analog-to-digital conversions automatically on the background, without CPU intervention between samples, by using direct memory access (DMA)?

  • Hi, I believe the \examples\peripheral\saadc in the nRF5 SDK v11 does exactly what you want. It will sample the SAADC every 400ms, the conversion is triggered through a PPI channel from compare0 event of timer0 to sample task of SAADC module. You will however notice that the current consumption is slightly high, that is because the SAADC require the external HFCLK running and because of the the DMA channel is prepared for the sampling. Depending on how frequently you want to sample, it might be more energy friendly to only enable the SAADC module and ppi channel 1-2ms before the actual conversion should take place. The actual timing depends on the startup time of the external HFCLK and is crystal dependant. The rest of the time the SAADC and HFCLK can be disabled.

  • Thanks! I did not notice that example, but tried to convert from ...\adc -example. But looked like there was no implementation for nRF52 there, actually. I'll continue with your hints :)

  • Actually, SAADC on nRF52 does not need crystal clock, especially if you're not that interested in accurate timing between samples. The absolute accuracy is not affected by the high frequency clock. But if your doing signal processing on the samples then crystal will give you less jitter.

    nRF51 does need crystal clock, because the ADC architecture is different.

Related