I started with the uart_events example and when I use xTimerCreate() and run vTaskStartScheduler() this is what happens:
If I don't start the timer before running the scheduler = Crash
If I do start the timer before running the scheduler = Crash with stack overflow errorassertion "xReturn != ( -1 )" failed: file "C:/ESP32/ESP-IDF/components/freertos
/tasks.c", line 2312, function: vTaskStartScheduler
abort() was called at PC 0x400d513f on core 0
0x400d513f: __assert_func at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-min
gw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:62 (discriminator 8
)
Setting breakpoint at 0x400843da and returning...
0x400843da: panic_abort at C:/ESP32/ESP-IDF/components/esp_system/panic.c:367
I've look around and some suggested increasing the timer and task stacks. I doubled them and still get the same errors.***ERROR*** A stack overflow in task Tmr Svc has been detected.
Setting breakpoint at 0x400843da and returning...
0x400843da: panic_abort at C:/ESP32/ESP-IDF/components/esp_system/panic.c:367
My Timer callback is quite light.
Code: Select all
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/timers.h"
#include "driver/uart.h"
#include "esp_log.h"
#include "driver/timer.h"
//...
static TaskHandle_t xHandle = NULL;
static TimerHandle_t xTimer = NULL;
bool timeout;
//...
void vTimerCallback( TimerHandle_t xTimer )
{
if (xTimer == xModbusTimer){ //modbus timer expired
Timeout = 1;
if(xHandle != NULL){
vTaskResume(xHandle);
}
}
}
//...
void app_main(void)
{
xTimer = xTimerCreate("Timer", pdMS_TO_TICKS(10), pdFALSE, ( void * ) 0, vTimerCallback);
xTimerStart(xTimer,0);
xTaskCreate(handler_task, "handler_task", 2048, NULL, 12, &xHandle);
//Create a task to handler UART event from ISR
xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, 12, NULL);
vTaskStartScheduler();
}