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

NRF52840 SAADC configuration with easyDMA interrupt after x samplings

hello Nordic

i am using nrf 52840 dev kit, sdk 16.0

i want to make a sampling of 2 channels at 32MHz rate. the data shell be passed to RAM via easyDMA, after every 4 samplings i whish to raise an interrupt so i can average the readings from each channel. 

(as i understand if i do oversampling and burst then it reads one channel several time and averaging and then do the same for the other channel, this solution is not good for me because i need to compare the reading of the 2 channels with each other so the data needs to be collected as simultaneously as possible) 

what the optimal way to achieve the above ?

also, if i use app_timer as the RTC timer for the saadc, does it involves the CPU ?, can it use ppi? (the name "app" makes me suspicious :) ) and is it a good solution for 32MHz sampling rate or is it to fit ?

best regards

Ziv

  • Do you mean kHz or MHz?
    I ask because the SAADC has a max sample rate of 200ksps.

  • also, does the timer configured as default in the saadc example is the HFCLOCK ?

    static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(0);

    basically, since i  need sampling at accurate 32KHz, the LOW FCLOCK is not suck a good solution cause according to data sheet it counts 32.768KHz and not 32.000KHz

  • hi haakonsh 

    so i found out that instead of using the "nrf_drv_timer_us_to_ticks()" , i can just put the value 500 assuming the default prescalar is 16MHz. pleas correct me if i am wrong .

    how ever, i want to check 2 channels every 31.25 microsec (which is 32KHz) with the saadc and i see that the 

    nrf_drv_timer_extended_compare(&m_timer, NRF_TIMER_CC_CHANNEL0, TICS_FOR_32KHZ, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true); //false);

    is defined for one channel, so how can i set that both channels will be sampled one after the other each timer event ? 

    also, in the saadc event handler where is the attention to which sample is read and where is the value saved ?

    void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
    {
        if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
        {...

    p.s. i am referring to the sdk example 

    last question for now is that in the future a ble will be implemented to the system, it will not work at the same time with the saadc but is there some timers issue i need to consider when adding softdevice ?

    best regards

    Ziv

  • ziv123 said:
    so i found out that instead of using the "nrf_drv_timer_us_to_ticks()" , i can just put the value 500 assuming the default prescalar is 16MHz. pleas correct me if i am wrong .

     Yeah that's right. 

    ziv123 said:
    is defined for one channel, so how can i set that both channels will be sampled one after the other each timer event ?

     All enabled SAADC channels will be sampled once, in succession, starting with the lowest channel number, for each triggered SAMPLE task. 

    ziv123 said:
    also, in the saadc event handler where is the attention to which sample is read and where is the value saved ?

     It's stored in the buffer who's address was last used. See the SAADC example for use. 

    The SoftDevice Requires TIMER0, and also has execution priority. If you can use much larger buffers than 4 samples then you will be fine with BLE. When the RADIO peripheral is running the SAADC accuracy is a tiny bit lower. 

     

    if i use app_timer as the RTC timer for the saadc, does it involves the CPU ?, can it use ppi? (the name "app" makes me suspicious :) ) and is it a good solution for 32MHz sampling rate or is it to fit ?

    The app_timer does use an RTC peripheral, but it can not be used with PPI. For that you need to use the RTC driver.

Related