Hello.
I am trying to use FreeRTOS and have run into a problem. If I call logging in the FreeRTOS software timer handler, the program stops.
Here is a simple example:
#include <stdbool.h> #include <stdint.h> #include <string.h> #include "nrf_drv_common.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "FreeRTOS.h" #include "timers.h" #include "task.h" volatile TimerHandle_t xOneSec_Timer; void blink_task(void *p){ while(1){ NRF_LOG_INFO("Blink"); vTaskDelay(1000); } }; void vOneSecTimer( TimerHandle_t xTimer ){ configASSERT( xTimer ); NRF_LOG_INFO("Timer"); } int main(void) { ret_code_t err_code; // Initialize. err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); NRF_LOG_INFO("Start"); for(uint32_t i=0; i<20; i++){ NRF_LOG_INFO("Count %d",i); for(uint32_t k=0; k<0x100000; k++){__NOP();}; } xOneSec_Timer = xTimerCreate( "1STimer", 1000 , pdTRUE, NULL, vOneSecTimer); xTimerStart(xOneSec_Timer,0); xTaskCreate(blink_task, "Blink", 256, NULL, 2, NULL); vTaskStartScheduler(); while(1); }
The output to the Ozone terminal looks like this: I see a "Start" message, messages with a counter, but as soon as the timer handler is called, the program stops. If in the timer handler you do not call a log entry, but for example blink the LED, then everything works. I see messages from the blink task and blinking LED.
What am I doing wrong?