sample timer program not working
Posted: Wed Jun 21, 2017 3:05 pm
Hi All,
I was trying to do a hands-on using FreeRTOS timer infrastructure on a ESP32 board. I wrote a simple program of repetitive timer which will just print the no. of times timer is fired.
Only config I have alter from default config is as below
- Set TICK_RATE set to 1000 , I am assuming doing this will make 1 tick = 1second
- Changed another config to invoke GDBstub when a panic occurs to debug the issue better.
Unfortunately the system is panicking with following message
My sample program looks as below
Function name and its implementation are opposite in nature and it is intentional.
Moreover the timer specific config set is
CONFIG_TIMER_TASK_PRIORITY=1
CONFIG_TIMER_TASK_STACK_DEPTH=2048
CONFIG_TIMER_QUEUE_LENGTH=10
Is this a known issue? Am I missing some other config here with respect to ESP32 board config.
The esp-idf I am using is 1 week old. I assume there is nothing fixed in past 1 week which has fix for this issue. At least googling it did not point me that way.
Thanks
I was trying to do a hands-on using FreeRTOS timer infrastructure on a ESP32 board. I wrote a simple program of repetitive timer which will just print the no. of times timer is fired.
Only config I have alter from default config is as below
- Set TICK_RATE set to 1000 , I am assuming doing this will make 1 tick = 1second
- Changed another config to invoke GDBstub when a panic occurs to debug the issue better.
Unfortunately the system is panicking with following message
Code: Select all
I (912) cpu_start: Starting scheduler on PRO CPU.
****SAMPLE Timer TEST Start***
I (200) cpu_start: Starting scheduler on APP CPU.
Hndl 0x3ffaffc8
CREATE PASS
TIMER START PASS
/home/das/esp/esp-idf/components/freertos/./queue.c:1442 (xQueueGenericReceive)- assert failed!
abort() was called at PC 0x400832ff on core 0
0x400832ff: xQueueGenericReceive at /home/das/esp/esp-idf/components/freertos/./queue.c:2034
Guru Meditation Error: Core 0 panic'ed (abort)
Backtrace: 0x40008155:0x3ffb5ce0 0x40007d16:0x3ffb5d00 0x40083434:0x3ffb5d40 0x40081c68:0x3ffb5d60 0x40081d48:0x3ffb5d90 0x400d82b1:0x3ffb5db0 0x400dc6d0:0x3ffb60c0 0x400dbb42:0x3ffb6110 0x40084e9a:0x3ffb6130 0x40084f10:0x3ffb6150 0x40084f83:0x3ffb6170 0x400850b3:0x3ffb61a0
0x40083434: xQueueTakeMutexRecursive at /home/das/esp/esp-idf/components/freertos/./queue.c:2034
0x40081c68: lock_acquire_generic at /home/das/esp/esp-idf/components/newlib/./locks.c:147
0x40081d48: _lock_acquire_recursive at /home/das/esp/esp-idf/components/newlib/./locks.c:161
0x400d82b1: _vfprintf_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:862
0x400dc6d0: printf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/printf.c:61
0x400dbb42: tm_clbk at /home/das/esp/sample_timer_app/main/./sample_timer.c:14
0x40084e9a: prvSwitchTimerLists at /home/das/esp/esp-idf/components/freertos/./timers.c:744
0x40084f10: prvSampleTimeNow at /home/das/esp/esp-idf/components/freertos/./timers.c:539
0x40084f83: prvProcessTimerOrBlockTask at /home/das/esp/esp-idf/components/freertos/./timers.c:462
0x400850b3: prvTimerTask at /home/das/esp/esp-idf/components/freertos/./timers.c:445 (discriminator 1)
Code: Select all
/*
* Timer Example
*
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/timers.h"
volatile int g_cnt = 1;
void tm_clbk(TimerHandle_t tm_hndl)
{
printf("Timer Callback Called %d time", g_cnt);
++g_cnt;
}
void one_shot_timer_start(void)
{
TimerHandle_t tm_hndl;
char *tm_name = "Demo Timer";
TickType_t tm_period = 3000;
int ret;
tm_hndl = xTimerCreate(tm_name, tm_period, pdTRUE, (void *) 0, tm_clbk);
printf("Hndl %p\n", tm_hndl);
if(tm_hndl == NULL) {
printf("timer create FAILED\n");
return;
} else {
printf("CREATE PASS\n");
ret = xTimerStart(tm_hndl, 0);
if(ret != pdPASS) {
printf("Timer Start FAILED\n");
return;
}
printf("TIMER START PASS\n");
}
vTaskStartScheduler();
}
void app_main()
{
//xTaskCreate(&blink_task, "blink_task", 512, NULL, 5, NULL);
printf("****SAMPLE Timer TEST Start***\n");
one_shot_timer_start();
for (;;);
}
Moreover the timer specific config set is
CONFIG_TIMER_TASK_PRIORITY=1
CONFIG_TIMER_TASK_STACK_DEPTH=2048
CONFIG_TIMER_QUEUE_LENGTH=10
Is this a known issue? Am I missing some other config here with respect to ESP32 board config.
The esp-idf I am using is 1 week old. I assume there is nothing fixed in past 1 week which has fix for this issue. At least googling it did not point me that way.
Thanks