Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SAADC + EasyDMA + timer

Is there an example that shows the "Nordic way" of "continuous" conversions using DMA? I think a timer and PPI are needed to generate a conversion task for each timer compare event?

Also, the SAADC END (of EasyDMA transfers for a conversion round) event is still available for interrupt?

I didn't find library support for ADC with DMA.

The idea is to let timer to trig several "rounds" of multi-channel conversions that DMA would store in a buffer. After pre-defined number of rounds a new buffer is taken into use by the N:th SAADC END interrupt, and the old buffer is used for further calculations.

Parents
  • Hello,

    Is there an example that shows the "Nordic way" of "continuous" conversions using DMA? I think a timer and PPI are needed to generate a conversion task for each timer compare event?

    Additionally, you can check out how things are done in this github repository - please not that the NordicPlayground repositories are just intended as simple demos, and are not as thoroughly tested as our SDK examples.

    I didn't find library support for ADC with DMA.

    The saadc peripheral uses easyDMA, by extension so does the nrfx_saadc and nrfx_saadc2 drivers.

    Also, the SAADC END (of EasyDMA transfers for a conversion round) event is still available for interrupt?

    No, the END event is not part of the nrfx_saadc driver - this is only available to the driver itself, or in the SAADC HAL.
    I would advice against mixing from both SAADC HAL and the nrfx driver, as this may place the driver in an invalid state.
    I would also recommend using the driver instead of implementing the functionality yourself from HAL - since a lot of this work is already done for you in the driver.

    If you want to do continuous sampling you should use the double buffering feature, and instead do your data processing once one buffer fills up - generating the DONE event.

    Please do not hesitate to ask if anything should be unclear, or if you should encounter any issues or questions!

    Best regards,
    Karl

  • BTW, if I try to look into the SAADC V2 driverAPI, I get:

    "

    HTTP ERROR: 404

    Problem accessing /help/drivers/include/nrfx_saadc_v2.h. Reason:

        ProxyServlet: /help/drivers/include/nrfx_saadc_v2.h
    "
  • Hello,

    turboscrew said:
    BTW, if I try to look into the SAADC V2 driverAPI

    Yes, it seems that the API documentation for SAADC V2 is not found, I will alert our technical writes about this.
    In the meantime, you may see the API documentation in the inline docstrings in the SDK17/modules/nrfx/include/nrfx_saadc_v2.h file. The API Reference documentation is generated from this file, and is an exact match of the docstrings in the .h file.

    turboscrew said:
    I guess this means that EVENTS_DONE signals that the last conversion is done, but the results are not yet read from the registers to memory?

    I think you might still be confusing the HAL and NRFX_driver events and interrupts. As I said in my initial reply, I advise you to only use one of them; either use only the HAL, or only the nrfx_driver. If you use both, then the driver might be placed in an invalid state and/or behave unpredictable.
    Which one do you intend to use? If you intend on using the nrfx_driver ( which I recommend highly ) you will not need to use the SAADC HAL events at all.
    The SAADC peripheral documentation is written about the peripheral itself, and neither cares nor knows for the existence of the nrfx_driver.

    turboscrew said:
    Also, does timer always generate interrupts internally? I was hoping to set the HW up such that timer compare just trigs an ADC scan (conversion of 4 channels) with DMA, and I only get an interrupt (event) after the DMA is finished, to start the next timer compare (and ADC scan).

    If the SAADC is configured to SCAN mode, and the START task is triggered, it will scan all the enabled channels. When the provided buffer is filled, the DONE event is generated.
    What do you mean when you ask if the timer always generate interrupts internally? If the TIMER COMPARE event is linked to the SAADC through PPI then the interrupt will be generated externally from the SAADC. You may leave the event handler passed to your TIMER empty, if you would like.

    Best regards,
    Karl

  • I'm probably not mixing HAL and NRFX much anymore, but I do look at the HW documentation. I'm just concerned about, possibly, too many interrupts eating up the processor cycles. I'm sampling 4 channels  every 2.5 ms, I need to write some driving data via SPI, I need to read some more data (at different rate) via SPI and I need to store the data into an SPI-flash. Something like 2.5 kBps. There's also BLE connection for commands and responses.

    We need to figure out if NFR25832 / nRF5 SDK is a good way to go.

    Now the HW looks fine (at least so far), but I'm still not sure about the SDK.

    It looks like the HW would be capable of reading arbitrary many "scans" of ADC-values without SW intervention. That approach is not very useful to us for the task at hand, though.

Reply
  • I'm probably not mixing HAL and NRFX much anymore, but I do look at the HW documentation. I'm just concerned about, possibly, too many interrupts eating up the processor cycles. I'm sampling 4 channels  every 2.5 ms, I need to write some driving data via SPI, I need to read some more data (at different rate) via SPI and I need to store the data into an SPI-flash. Something like 2.5 kBps. There's also BLE connection for commands and responses.

    We need to figure out if NFR25832 / nRF5 SDK is a good way to go.

    Now the HW looks fine (at least so far), but I'm still not sure about the SDK.

    It looks like the HW would be capable of reading arbitrary many "scans" of ADC-values without SW intervention. That approach is not very useful to us for the task at hand, though.

Children
No Data
Related