nrf_drv_saadc_abort doesn't raise SAADC DONE task

I have an application where I am using the SAADC to take ADC samples. At any point during the measurements, I want to be able to stop the samples prior to the ADC buffer filling completely. I've created a mock project of the general issue shown where the app_timer callback successfully calls the SAADC abort, however I don't receive a DONE task as the function description declares it does.

This is using the BLE SoftDevice as my intention is to essentially start ADC sampling from a BLE command. I will also be having a BLE command to provide an early stop to the measurements as well as activity detection to stop ADC sampling during movement, then resume afterwards (hence a timer interrupt occurs to stop the sampling as an expected time the ADC sampling would have completed if no activity was detected).

/**
 * @brief Function for aborting the ongoing and buffered conversions.
 *
 * @note @ref NRFX_SAADC_EVT_DONE event will be generated if there is a conversion in progress.
 *       Event will contain number of words in the sample buffer.
 *
 * @warning This function must not be called from the context of event handler of the SAADC driver
 *          or from the context of interrupt with priority equal to or higher than priority
 *          of the SAADC interrupt.
 */
void nrfx_saadc_abort(void);

Based on the above @warning I have attempted to use the abort directly from main() as well as ensuring the app_timer interrupt is a lower priority without success.

I have attached a dummy project based on the BLE App Template where I added the SAADC example where I also added an App Timer to abort the measurements early.

Any thoughts on the SAADC abort is not raising the DONE task or what I'm doing wrong here?

0654.ble_app_template.zip

Parents
  • Hi,

    I'm guessing that your basing your assumption on this comment regarding the driver function:

    NRFX_SAADC_EVT_DONE is a HW event that isn't propagated to the application in this case. Calling nrfx_saadc_abort() will trigger the task NRF_SAADC_TASK_STOP which again will generate the NRF_SAADC_EVENT_STOPPED.
     
    regards
    Jared 
  • Thanks for the info!

    I need to be able to cause an early stop using while still knowing how many samples were taken during the period before nrfx_saadc_abort was called. For example, my sampling period fills a buffer of 512 ADC measurements. If the abort is called and only 300 measurements were taken, I need to know this number and be able to still convert the 300 measurements with nrfx_saadc_buffer_convert. Do you have a suggestion on how I would accomplish this if nrfx_saadc_abort does not propogate the HW event to the application?

  • Hi,

    When you call nrfx_saadc_abort() it will effectively call trigger the NRF_SAADC_TASK_STOP task which will eventually result in the EVENTS_STOPPED to be generated. When that event has been generated, you can check the RESULT.AMOUNT register to see how many samples that has been transferred to RAM.

     
    regards
    Jared
Reply Children
Related