SAADC with PPI using TIMER0 vs TIMER2.

Hello Nordic Team and Community, 

During the exercise3 from  Lesson6 ADC in nRF Connect SDK Intermediate course, I changed the sample buffer size to 1000  with a 1Khz sampling hate, as my understanding of the using ADC, the DONE event from SAADC event handler should be triggered and shown close to each second, but by using the TIMER0, in the logs the DONE event is triggered every 6 seconds and this should not happen, but when the timer used is the TIMER2 the sample works correctly, I just need to understand the reason of it, if the timers shouldn't be similar or there are differences between them? 

I'm using NCS SDK 2.5.0 and nRF52840DK.


/*Logs using TIMER0 instance to trigger adc */
00:08:39.178,039] <inf> main: SAADC buffer at 0x20002b98 filled with 1000 samples
[00:08:39.178,070] <inf> main: AVG=3380, MIN=3367, MAX=3394
[00:08:45.027,496] <inf> main: SAADC buffer at 0x20003368 filled with 1000 samples
[00:08:45.027,496] <inf> main: AVG=3379, MIN=3367, MAX=3392
[00:08:50.867,767] <inf> main: SAADC buffer at 0x20002b98 filled with 1000 samples
[00:08:50.867,797] <inf> main: AVG=3379, MIN=3367, MAX=3392
[00:08:56.693,511] <inf> main: SAADC buffer at 0x20003368 filled with 1000 samples
[00:08:56.693,542] <inf> main: AVG=3380, MIN=3367, MAX=3392

/* Logs using TIMER2 instance */

[00:17:36.734,130] <inf> main: SAADC buffer at 0x20003368 filled with 1000 samples
[00:17:36.734,161] <inf> main: AVG=3380, MIN=3369, MAX=3392
[00:17:37.729,156] <inf> main: SAADC buffer at 0x20002b98 filled with 1000 samples
[00:17:37.729,156] <inf> main: AVG=3381, MIN=3367, MAX=3392
[00:17:38.724,578] <inf> main: SAADC buffer at 0x20003368 filled with 1000 samples
[00:17:38.724,609] <inf> main: AVG=3380, MIN=3369, MAX=3396

Parents Reply
  • Hi, 

    Sorry for delay. The following changes I've made in code was:

    prj.conf: 

    CONFIG_NRFX_TIMER0=y

    main.c:

    /* STEP 3.1 - Define the SAADC sample interval in microseconds */
    #define SAADC_SAMPLE_INTERVAL_US 1000
    
    /* STEP 4.1 - Define the buffer size for the SAADC */
    #define SAADC_BUFFER_SIZE 1000
    
    /* STEP 3.2 - Declaring an instance of nrfx_timer for TIMER2. */
    const nrfx_timer_t timer_instance = NRFX_TIMER_INSTANCE(0);
    

    These were the changes, the rest of it is the same.

    Best Regards, Caio.

Children
Related