SAADC PPI trigger channels separately

Hello, I'm working on an application with precise timing requirements. Basically I need to generate a short pulse and sample two channels during the pulse. In addition, I would like to use a third channel for a slower/low-priority battery monitor task.

I already have implemented the GPIO control for the pulse via Timers and PPI, and I was planning to use it as well to trigger ADC acquisitions during the pulse. However, I have two doubts:

  • Since the pulses happen with high frequency, I would like the ADC to store samples in a buffer autonomously. While the ADC supports buffering, it's unclear to me if I can still trigger manually each acquisition (via PPI) when using this feature (nrf_drv_saadc_buffer_convert or similar), or if the ADC just samples on its own time. For me, it's critical that the trigger is controlled for each sample by the PPI. To clarify with an example, I would like to setup a buffer (eg: 10 samples), then trigger via PPI 10 single acquisitions and only after the 10th get the callback/read the ADC buffered data. Is this possible?
  • Secondly, I would like to add a third channel that I can trigger occasionally for battery monitoring, independent of the time-sensitive application.

If not, what approach do you suggest?

Thank you!

Parents
  • Hi Andrea

    For me, it's critical that the trigger is controlled for each sample by the PPI. To clarify with an example, I would like to setup a buffer (eg: 10 samples), then trigger via PPI 10 single acquisitions and only after the 10th get the callback/read the ADC buffered data. Is this possible?

    Yes, this is possible, and as it happens there is a chapter in the DevAcademy that walks through this specifically. Please have a look at the relevant chapter here

    Essentially you can trigger the SAADC SAMPLE task from anywhere over PPI, and only get a callback from the ADC driver when the buffer is full. 

    Secondly, I would like to add a third channel that I can trigger occasionally for battery monitoring, independent of the time-sensitive application.

    There is no good way to implement different channels that you sample at different frequencies unfortunately. Essentially you have to choose between one of the following workarounds:

    a) Sample all the channels at the same, high frequency, and discard the samples you don't need for the slow channel. 

    b) Reconfigure the SAADC module every time you want to sample the slow channel, and add the slow channel to the list. This only works if you can accept a bit of downtime when the SAADC module is being reconfigured. 

    Best regards
    Torbjørn

  • Hi, thank you the resource you provided is very useful. the solution you linked uses double buffering which I do not really need.

    However, it was good to understand the problem. It looks like the buffers are "consumed" as if in a queue, correct?
    I imagined that the START event would prepare the ADC with the current buffer, without the need to setup a new one (since I am only using one).

Reply
  • Hi, thank you the resource you provided is very useful. the solution you linked uses double buffering which I do not really need.

    However, it was good to understand the problem. It looks like the buffers are "consumed" as if in a queue, correct?
    I imagined that the START event would prepare the ADC with the current buffer, without the need to setup a new one (since I am only using one).

Children
No Data
Related