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

  • ziv123 said:
    so if i put the "SAMPLES_IN_BUFFER = 4 " this means i will get the "NRFX_SAADC_EVT_DONE" only after 4 sampling of the 2 channels ? or maybe i need to define one buffer with 8 bytes in it instead of 2 buffers of 4 ? pretty sure the issue is not clear for me as you can see by my questions i don't really get how this works yet, sorry for that .. hope you help me with that

     Yes you need a buffer size of 8 samples for 2 channels. 

    ziv123 said:
    also, what does the following function do in the nrf event handler when receiving an "NRFX_SAADC_EVT_DONE"  even

     It prepares the current buffer to be used again for the next iteration. The driver alternates 2 buffers. 

    I suggest you read both the prod spec and the driver implementations if you want to understand how the saadc works. 

  • It prepares the current buffer to be used again for the next iteration. The driver alternates 2 buffers. 

    so in the saadc_init function do i really need to prepper both elements of the buffer like this:

        err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

    or is it enough to call the first convert only (with the m_buff_pool[0]) and the second element of the buff will be prepared within the NRFX_SAADC_EVT_DONE ?

    I suggest you read both the prod spec and the driver implementations if you want to understand how the saadc works.

    I have read it but not all of it and it does not make me an expert yet, there is still much clarifications to be given even after reading data sheet cause there is not enough guidance regarding programing and working with the SDK to my humble opinion, this is why i also seek for help in the forum

  • ziv123 said:
    or is it enough to call the first convert only (with the m_buff_pool[0]) and the second element of the buff will be prepared within the NRFX_SAADC_EVT_DONE ?

     No, the first time you need to call it twice with the two buffers.  

    ziv123 said:
    I have read it but not all of it and it does not make me an expert yet, there is still much clarifications to be given even after reading data sheet cause there is not enough guidance regarding programing and working with the SDK to my humble opinion, this is why i also seek for help in the forum

     I suggest you read the driver implementation as it show how to interpret the spec, also, the HAL might be easier to understand than the driver.

Related