Questions about FreeRTOS and RTC on nrf52832

Hi all,

I am having an issue with FreeRTOS on the NRF52832 (SDK 17.1.0).

I need precise time so I use the io to measure the time. the code like this:

    nrf_gpio_cfg_output(18);
    PRINTF("nrf_gpio_cfg_output 18.");
    while(1)
    {
        nrf_gpio_pin_write(18, 1);
        vTaskDelay(1);
        nrf_gpio_pin_write(18, 0);
        vTaskDelay(1);
        nrf_gpio_pin_write(18, 1);
        nrf_delay_us(500);
        nrf_gpio_pin_write(18, 0);
        nrf_delay_us(500);
        nrf_delay_ms(10);
        PRINTF("while loop.");
    }

#define configTICK_RATE_HZ        1024

But the oscilloscope waveform shows that the interval is abnormal.

The first pullup interval is 738 us, and the first pulldown interval is 910us, but the second pullup interval is exact time 500us.

That means delay time on rtos is not accurate, but nrf_delay is accurate.

Did I set something wrong about freertos?

The config file is here.

8508.FreeRTOSConfig.h

5432.sdk_config.h

Hope you can give me some suggestions.

Best regards

Lurn

Parents
  • Hi,

    The time resolution of vtaskdelay is limited by the configTICK_RATE_HZ from the RTC. For short accurate delays I would recommend using busy waits (nrf_delay_us()). When you factor in the processing overhead associated with context switching, I don't think the power consumption difference will be significant. Another alternative is to use a TIMER instance.

    Best regards,

    Vidar

  • Hi Vidar,

    Another qusetions.

    1.

    I would recommend using busy waits (nrf_delay_us())

    If i use the nrf_delay_ms(time1); Can Freertos schedule tasks at this time? I need rtos to schedule tasks in this time. 

    2. I saw in this link @Edvin said the PPI is very accurate, and in my project, since I'm using ESB and UARTE, I'm also using HFCLK.

     Can I also use the PPI in FreeRTOS? Can it trigger the ESB write payload and send it? Can I use it to sync time between two devices?

    Best regards,

    Lurn

Reply
  • Hi Vidar,

    Another qusetions.

    1.

    I would recommend using busy waits (nrf_delay_us())

    If i use the nrf_delay_ms(time1); Can Freertos schedule tasks at this time? I need rtos to schedule tasks in this time. 

    2. I saw in this link @Edvin said the PPI is very accurate, and in my project, since I'm using ESB and UARTE, I'm also using HFCLK.

     Can I also use the PPI in FreeRTOS? Can it trigger the ESB write payload and send it? Can I use it to sync time between two devices?

    Best regards,

    Lurn

Children
No Data
Related