Getting started with FreeRTOS on nrf52

Hi, I'm trying to use FreeRTOS on a custom board featuring a nRF52832. I've started adapting the blinky_freertos example in the SDK 17.1.0 and replacing the code in led_toggle_task_function with the following snippet:

static int myVar;

static void led_toggle_task_function (void * pvParameter)
{
    UNUSED_PARAMETER(pvParameter);
    myVar = 0;
    while (true)
    {
        myVar++;
        vTaskDelay(100);
        myVar++;
    }
}

I'm using IAR (with low optimization) and a jlink and, apparently, the code never reaches the increment after the first vTaskDelay (i.e., myVar stays at 1). Or rather, sometimes it works as expected but it mostly doesn't.

Do you have any hint at what might be causing this? Is it the fact that I'm using a custom board (I doubt it, since there is no board specific initialization in the example, aside from the LEDs and the button), or is it maybe this bug still looming around?

I should probably mention that I already had a more serious try with the SDK 13.0.0, where I successfully started some tasks and communicated over SPI, but I noticed that some timers were not firing when they should have.

Thanks in advance for any feedback

Parents
  • The FreeRTOS example we have relies on the RTC to handle the kernel tick required for housekeeping of the kernel. IF the RTC is not ticking correctly then there are no interrupts generated. You can put a breakpoint in the nRF5_SDK_17.1.0_ddde560\external\freertos\portable\CMSIS\nrf52\port_cmsis_systick.c:: Line 117 and see if this interrupt is being triggered at all. My guess is that this interrupt might not be triggered at all (or enough) propbably due to issues in your external LFCLK needed by the RTC?

Reply
  • The FreeRTOS example we have relies on the RTC to handle the kernel tick required for housekeeping of the kernel. IF the RTC is not ticking correctly then there are no interrupts generated. You can put a breakpoint in the nRF5_SDK_17.1.0_ddde560\external\freertos\portable\CMSIS\nrf52\port_cmsis_systick.c:: Line 117 and see if this interrupt is being triggered at all. My guess is that this interrupt might not be triggered at all (or enough) propbably due to issues in your external LFCLK needed by the RTC?

Children
Related