crash using timers
Posted: Thu Mar 16, 2017 8:26 am
Hi, i'm trying to run some code on timer, using FreeRTOS xTimerCreate and when timer expires, i get reset... This is on ESP32 (ESP32 thing dev board)
if I exit vCallbackFunction quicker (without doing printfs just increment xx seems to work), but otherwise it fails with either Stack overflow or some other Guru panicked error (ex errors I get:
Guru Meditation Error of type InstrFetchProhibited occurred on core 0. Exception was unhanded.
or
***ERROR*** A stack overflow in task Tmr Svc has been detected.
abort() was called at PC 0x400853b0
Guru Meditation Error: Core 0 panic'ed (abort)
or is it that some things are just not available form callbacks like printf and fflush ?
or is it limited to how long I can remain in the callback before returning (If I start a task inside the callback instead, and do all the printing in that task it seems to be fine)?
Thank you
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/timers.h"
#include "freertos/task.h"
int xx=0;
void vCallbackFunction( TimerHandle_t xTimer ) {
printf("in timer xx=%d\n", xx++);
fflush(stdout);
}
void app_main()
{
int myTimerID = 1;
TimerHandle_t tm = xTimerCreate("refresh", 3000/portTICK_PERIOD_MS, pdTRUE, (void*)&myTimerID, vCallbackFunction);
BaseType_t res = xTimerStart(tm,0);
if(tm && res==pdPASS) {
printf("timer created\n");
} else {
printf("faled making timer\n");
}
fflush(stdout);
for(;;) { // also, can I let app_main exit, and expect timer keep expiring to run code in vCallbackFunction, or start new task in vCallbackFunction date app_main was exited
vTaskDelay(100);
printf(".");
fflush(stdout);
}
}
Guru Meditation Error of type InstrFetchProhibited occurred on core 0. Exception was unhanded.
or
***ERROR*** A stack overflow in task Tmr Svc has been detected.
abort() was called at PC 0x400853b0
Guru Meditation Error: Core 0 panic'ed (abort)
or is it that some things are just not available form callbacks like printf and fflush ?
or is it limited to how long I can remain in the callback before returning (If I start a task inside the callback instead, and do all the printing in that task it seems to be fine)?
Thank you