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

timeslot configuration for ADC reading series

in my application i have to read the ADC (single channel) each 30us within 3 ms. And there must be no interruptions in this period of time. Then i can let radio up to 3ms before i get back to my ADC series. What is the best approach for such a case? Do i have to use timeslot API?

After reading the article i copied the code to my project and run it. The LED is blinking appr. 2 times per second. But i can't figure out how to configure the time slot for my case.

Besides, the text says i have to modufy "sys_evt_dispatch" but i can't find it in my project (based on uart example)

i am using SDK15.

Parents
  • Hi 

    If I understand you correctly you need to sample continuously for 3ms with an interval of 30us (so around 100 samples total), and then you will have a 3ms break where there is no ADC activity. Then you repeat the procedure, and start a new 3ms sampling period. 

    Is this correct?

    There is no need to use the timeslot API to implement this. You can set up the SAADC module to sample automatically at an interval of 30us, and configure the maximum number of samples before you want the SAADC to stop. Then all you have to do is trigger the SAADC START task when you want the sampling sequence to start, and process the data once it is ready. 

    Since the SAADC uses easyDMA to store data in RAM you can safely use it during radio activity, and it will do it's work in the background while the MCU is busy handling radio interrupts. 

    If you want to make sure that the SAADC sampling sequence starts at an exact, pre-defined time you can set up a TIMER or RTC module, and have the timer trigger the SAADC through the PPI controller. 

    The blog you linked to is based on a much older SDK, and in the new SDK you won't find the sys_evt_dispatch function in the code directly. 

    Instead modules that want to receive system events have to register a callback through the NRF_SDH_SOC_OBSERVER(..) macro, and set up the event handler this way. For an example of this please have a look at the nrf_storage_sd.c file in the SDK.

    Best regards
    Torbjørn

Reply
  • Hi 

    If I understand you correctly you need to sample continuously for 3ms with an interval of 30us (so around 100 samples total), and then you will have a 3ms break where there is no ADC activity. Then you repeat the procedure, and start a new 3ms sampling period. 

    Is this correct?

    There is no need to use the timeslot API to implement this. You can set up the SAADC module to sample automatically at an interval of 30us, and configure the maximum number of samples before you want the SAADC to stop. Then all you have to do is trigger the SAADC START task when you want the sampling sequence to start, and process the data once it is ready. 

    Since the SAADC uses easyDMA to store data in RAM you can safely use it during radio activity, and it will do it's work in the background while the MCU is busy handling radio interrupts. 

    If you want to make sure that the SAADC sampling sequence starts at an exact, pre-defined time you can set up a TIMER or RTC module, and have the timer trigger the SAADC through the PPI controller. 

    The blog you linked to is based on a much older SDK, and in the new SDK you won't find the sys_evt_dispatch function in the code directly. 

    Instead modules that want to receive system events have to register a callback through the NRF_SDH_SOC_OBSERVER(..) macro, and set up the event handler this way. For an example of this please have a look at the nrf_storage_sd.c file in the SDK.

    Best regards
    Torbjørn

Children
Related