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

How does "nrfx_saadc_sample()" work?

Hi I am building a project, where I need to initialize the ADC using a timer. Whenever there is a timer interrupt "nrfx_saadc_sample" gets called and ADC starts sampling. I want to know whether it converts single value or it depends on the buffer size or number of samples? Suppose the timer generates an interrupt at every 100ms, and adc starts sampling. Does it sample only single value read from analog pin or it just stores up the buffer and converts them altogether?

Parents
  • Hi,

    The nrfx_saadc_sample() function triggers the START task or SAMPLE task register, depending on weather the driver is configured in low power mode or not. If you want to use a timer to trigger ADC sampling yo could trigger the task directly via PPI instead. This way you get precise timing, as it happens in HW and won't be delayed by a potential high priority interrupt.

    The HW supports continuous sampling, and the driver will configure the number of samples when you call nrfx_saadc_buffer_convert(). The second/last parameter is the number of samples collected. Then actual sampling will occur every time the SAMPLE task is triggered, either from SW or PPI.

Reply
  • Hi,

    The nrfx_saadc_sample() function triggers the START task or SAMPLE task register, depending on weather the driver is configured in low power mode or not. If you want to use a timer to trigger ADC sampling yo could trigger the task directly via PPI instead. This way you get precise timing, as it happens in HW and won't be delayed by a potential high priority interrupt.

    The HW supports continuous sampling, and the driver will configure the number of samples when you call nrfx_saadc_buffer_convert(). The second/last parameter is the number of samples collected. Then actual sampling will occur every time the SAMPLE task is triggered, either from SW or PPI.

Children
No Data
Related