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

zephyr ADC 8K

Hello 

I would like to use SAADC 2 channels sample at 8K samples  \ per second for each channel

based on:

https://github.com/zephyrproject-rtos/zephyr/blob/master/tests/drivers/adc/adc_api/src/test_adc.c

I tried to define ADC readings with callback, so I will not have "busy wait"

I could not reach better results then 1K samples  \ second, please advice (as I need to sample audio signals)

Parents
  • I suggest you use the nrfx saadc driver directly: 

    #include <zephyr.h>
    #include <nrfx_saadc.h>
    
    void main(void)
    {
    	/* Connect SAADC IRQ to nrfx_twim_3_irq_handler */
    	IRQ_CONNECT(DT_IRQN(DT_NODELABEL(adc)),
    		    DT_IRQ(DT_NODELABEL(adc), priority),
    		    nrfx_isr, nrfx_saadc_irq_handler, 0);
    
    	/* Initialize driver */
    
    }

    Add CONFIG_NRFX_SAADC=y to prj.conf. 

    See SAADC driver and SAADC HAL APIs on use. 

    You'll also need to set up a source to trigger the SAADC's sample task. At 16ksps you can use an RTC unless you need higher precision of the sample rate, in that case you use a TIMER. 

    Are you familiar with the nRF5 SDK? Specifically PPI and how to connect events to tasks? 

Reply
  • I suggest you use the nrfx saadc driver directly: 

    #include <zephyr.h>
    #include <nrfx_saadc.h>
    
    void main(void)
    {
    	/* Connect SAADC IRQ to nrfx_twim_3_irq_handler */
    	IRQ_CONNECT(DT_IRQN(DT_NODELABEL(adc)),
    		    DT_IRQ(DT_NODELABEL(adc), priority),
    		    nrfx_isr, nrfx_saadc_irq_handler, 0);
    
    	/* Initialize driver */
    
    }

    Add CONFIG_NRFX_SAADC=y to prj.conf. 

    See SAADC driver and SAADC HAL APIs on use. 

    You'll also need to set up a source to trigger the SAADC's sample task. At 16ksps you can use an RTC unless you need higher precision of the sample rate, in that case you use a TIMER. 

    Are you familiar with the nRF5 SDK? Specifically PPI and how to connect events to tasks? 

Children
Related