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

example project hrs_freertos in SDK14, incorrect initialization?

Because this is my first time on this forum, therefore first: "Greetings to everybody".

I'm just start digging into nrf with FreeRTOS (NRF52832, custom board, SDK14.0.0.3, SD 5.0, GCC, debugging through NRF52DK). I start my job base on example "ble_app_hrs_freertos". In main function there is bunch of initialisations and AFTER that is created task with softdevice. Snippet:

sensor_simulator_init();
conn_params_init();
peer_manager_init();
application_timers_start();

// Create a FreeRTOS task for the BLE stack.
// The task will run advertising_start() before entering its loop.
nrf_sdh_freertos_init(advertising_start, &erase_bonds);

During my test I met assertion failure. Stack looks in this way:

Thread #1 57005 (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)	
0xa2c94710	
<signal handler called>() at 0xfffffff1	
app_error_fault_handler() at app_error_weak.c:54 0x233c8	
app_error_handler() at app_error.c:73 0x2330a	
assert_nrf_callback() at main.c:246 0x2a31c	
vTaskNotifyGiveFromISR() at tasks.c:4 309 0x2859e	
SWI2_EGU2_IRQHandler() at nrf_sdh_freertos.c:65 0x33e84	
<signal handler called>() at 0xfffffff9	
xTaskGetSchedulerState() at tasks.c:3 365 0x28262	
xQueueGenericSend() at queue.c:624 0x26c5a	
xTimerGenericCommand() at timers.c:338 0x287a2	
application_timers_start() at main.c:585 0x2aa9c	
main() at main.c:1 086 0x2b20a

In main() NRF was in application_timers_start(), so before creating task with softdevice. In SWI2_EGU2_IRQHandler() processor attempt to run this function: vTaskNotifyGiveFromISR(m_softdevice_task, &yield_req). But variable m_softdevice_task was equal to 0 (because there wasn't such task).

Now, according FAQ in FreeRtos page, this isn't allowed to init interrupt before we create tasks, those can i.e. receive notifications, sent from these IRQ.

My question is: is this example incorrect, or I miss something? Let me note, that in SDK13.1.0.7, same example looks differ, in my opinion in correct way. There initialization of i.e. timers was made inside of task, at begin.

best regards, Gregor

  • thank you for your answer. (1) Yes, I'm sure that in makefile I have app_timer_freertos.c and not app_timer.c (2) I read thread from your link. I see there two zip's file with projects made by you: a) ble_app_hrs_freertosSDK14.zip. In main.c function nrf_sdh_freertos_init() (it create thread with SD) is after all init functions. So, this example is same as I wrote at the beginning. b) ble_app_hrs_freertos_840.zip. There, first is create thread ble_stack_thread and inside it, are present all initialization functions. To be honest, same solution (like in ble_app_hrs_freertos_840.zip) I made yesterday. All work well. However I'm new in NRF stuff, so maybe my job was pointless (before change, error was sporadic). I will check it during tests in next days.

  • did you change anything in the example?

  • @kbb64: What do you eman by "Yes the examples are incorrect as the SDK14 does not support FreeRtos yet:" FreeRTOS is supported for nrf52832 on SDK14.

  • Just flashed pca10040 SDK14.2 freertos hrs example on to PCA10056, except the LEDS everything is working normally as i expected. I do not think that apart the pin mapping there is any difference in 52832DK and 52840DK atleast with respect to freertos.