ESP32-S3 hardware timer interrupt doesn't work stable
Posted: Sat May 28, 2022 9:54 am
Hi, everyone.
I have timer and 1 tcp server task.
The problem is:
My timer interrupt code for debug is:
Timer init code is:
What can i do, to make timer interrupts work stable?
I have timer and 1 tcp server task.
The problem is:
My timer interrupt code for debug is:
- static bool IRAM_ATTR timer_group_isr_callback(void *args)
- {
- BaseType_t high_task_awoken = pdFALSE;
- gpio_set_level(GPIO_NUM_48, 1);
- gpio_set_level(GPIO_NUM_48, 0);
- return high_task_awoken == pdTRUE; // return whether we need to yield at the end of ISR
- }
- static void example_tg_timer_init(int group, int timer, bool auto_reload, int timer_interval_sec)
- {
- /* Select and initialize basic parameters of the timer */
- timer_config_t config = {
- .divider = TIMER_DIVIDER,
- .counter_dir = TIMER_COUNT_UP,
- .counter_en = TIMER_PAUSE,
- .alarm_en = TIMER_ALARM_EN,
- .auto_reload = auto_reload,
- }; // default clock source is APB
- timer_init(group, timer, &config);
- /* Timer's counter will initially start from value below.
- Also, if auto_reload is set, this value will be automatically reload on alarm */
- timer_set_counter_value(group, timer, 0);
- /* Configure the alarm value and the interrupt on alarm. */
- timer_set_alarm_value(group, timer, timer_interval_sec);
- timer_enable_intr(group, timer);
- example_timer_info_t *timer_info = calloc(1, sizeof(example_timer_info_t));
- timer_info->timer_group = group;
- timer_info->timer_idx = timer;
- timer_info->auto_reload = auto_reload;
- timer_info->alarm_interval = timer_interval_sec;
- timer_isr_callback_add(group, timer, timer_group_isr_callback, timer_info, 0);
- timer_start(group, timer);
- }
- // ....
- example_tg_timer_init(TIMER_GROUP_1, TIMER_1, true, (1814 / 2));