GPTimer Alarm with Auto-Reload on Doesn't Get Re-enabled after Triggered

atlisty
Posts: 1
Joined: Tue Sep 30, 2025 4:20 am

GPTimer Alarm with Auto-Reload on Doesn't Get Re-enabled after Triggered

Postby atlisty » Tue Sep 30, 2025 4:25 am

The code is adapted from hello-world, with gptimer added. The log shows that `timer->hal.dev->hw_timer[id].config.tx_alarm_en` never gets set to true. Is that intended behavior?

And the task_wdt seems to be unhappy either, even with `vTaskDelay(0);` in the loop. Hints about it would be appreciated too.

My esp-idf ver is v5.5.1. Chip is ESP32C3FH4 Rev 0.4.

The log (output) is:

Code: Select all

Restarting after 5 seconds...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x403831aa
--- 0x403831aa: esp_restart_noos at /COMPONENT_ESP_SYSTEM_DIR/port/soc/esp32c3/system_internal.c:115
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x16e4
load:0x403cbf10,len:0xdec
load:0x403ce710,len:0x30c0
entry 0x403cbf1a
I (24) boot: ESP-IDF v5.5.1 2nd stage bootloader
I (24) boot: chip revision: v0.4
I (24) boot: efuse block revision: v1.3
I (24) qio_mode: Enabling default flash chip QIO
I (28) boot.esp32c3: SPI Speed      : 80MHz
I (32) boot.esp32c3: SPI Mode       : QIO
I (35) boot.esp32c3: SPI Flash Size : 4MB        
I (39) boot: Enabling RNG early entropy source...
I (43) boot: Partition Table:
I (46) boot: ## Label            Usage          Type ST Offset   Length  
I (52) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (59) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (65) boot:  2 factory          factory app      00 00 00010000 00100000
I (72) boot: End of partition table
I (75) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=09498h ( 38040) map 
I (88) esp_image: segment 1: paddr=000194c0 vaddr=3fc8b800 size=01218h (  4632) load
I (91) esp_image: segment 2: paddr=0001a6e0 vaddr=40380000 size=05938h ( 22840) load
I (101) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=1871ch (100124) map
I (119) esp_image: segment 4: paddr=00038744 vaddr=40385938 size=05e18h ( 24088) load
I (123) esp_image: segment 5: paddr=0003e564 vaddr=50000000 size=00020h (    32) load
I (127) boot: Loaded app from partition at offset 0x10000
I (128) boot: Disabling RNG early entropy source...
I (144) cpu_start: Unicore app
I (152) cpu_start: Pro cpu start user code
I (152) cpu_start: cpu freq: 160000000 Hz
I (152) app_init: Application information:
I (153) app_init: Project name:     test1
I (156) app_init: App version:      1
I (160) app_init: ELF file SHA256:  
I (164) app_init: ESP-IDF:          v5.5.1
I (168) efuse_init: Min chip rev:     v0.4
I (172) efuse_init: Max chip rev:     v1.99
I (176) efuse_init: Chip rev:         v0.4
I (179) heap_init: Initializing. RAM available for dynamic allocation:
I (186) heap_init: At 3FC8D9E0 len 00032620 (201 KiB): RAM
I (191) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (197) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (203) heap_init: At 50000020 len 00001FC8 (7 KiB): RTCRAM
I (209) spi_flash: detected chip: generic
I (212) spi_flash: flash io: qio
I (215) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (221) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (228) main_task: Started on CPU0
I (228) main_task: Calling app_main()
================= Hello world! =================
This is esp32c3 chip with 1 CPU core(s), WiFi/BLE, silicon revision v0.4, 4MB external flash
Minimum free heap size: 331408 bytes
================= Start! =================
initial timer0 cur last_val = 0 enable=1 autoreload=1
timer0 cur tim_val = 100002 enable=1 autoreload=1
timer0 cur tim_val = 200008 enable=1 autoreload=1
timer0 cur tim_val = 300012 enable=1 autoreload=1
timer0 cur tim_val = 400017 enable=1 autoreload=1
timer0 cur tim_val = 500021 enable=1 autoreload=1
timer0 cur tim_val = 600027 enable=1 autoreload=1
timer0 cur tim_val = 700033 enable=1 autoreload=1
timer0 cur tim_val = 800039 enable=1 autoreload=1
timer0 cur tim_val = 900045 enable=1 autoreload=1
timer0 cur tim_val = 3 enable=0 autoreload=1
timer0 cur tim_val = 100005 enable=0 autoreload=1
timer0 cur tim_val = 200010 enable=0 autoreload=1
timer0 cur tim_val = 300014 enable=0 autoreload=1
timer0 cur tim_val = 400019 enable=0 autoreload=1
timer0 cur tim_val = 500023 enable=0 autoreload=1
(truncated)
timer0 cur tim_val = 3700114 enable=0 autoreload=1
timer0 cur tim_val = 3800117 enable=0 autoreload=1
timer0 cur tim_val = 3900119 enable=0 autoreload=1
E (5228) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (5228) task_wdt:  - IDLE (CPU 0)
E (5228) task_wdt: Tasks currently running:
E (5228) task_wdt: CPU 0: main
E (5228) task_wdt: Print CPU 0 (current core) registers
Core  0 register dump:
MEPC    : 0x40384052  RA      : 0x403840e2  SP      : 0x3fc8f090  GP      : 0x3fc8c000  
--- 0x40384052: vPortClearInterruptMaskFromISR at /COMPONENT_FREERTOS_DIR/FreeRTOS-Kernel/portable/riscv/port.c:515
--- 0x403840e2: vPortExitCritical at /COMPONENT_FREERTOS_DIR/FreeRTOS-Kernel/portable/riscv/port.c:627
TP      : 0x3fc8f140  T0      : 0x4005890e  T1      : 0x30000000  T2      : 0x00000000
--- 0x4005890e: _data_end_btdm_rom in ROM
S0/FP   : 0x00000000  S1      : 0x3fc8f0b8  A0      : 0x00000001  A1      : 0x00000000
A2      : 0x00000000  A3      : 0x6001f000  A4      : 0x00000000  A5      : 0x600c2000
A6      : 0xa0000000  A7      : 0x0000000a  S2      : 0x003b82d7  S3      : 0x00000000
S4      : 0x003b82d7  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000
T3      : 0x00000000  T4      : 0xffc00000  T5      : 0x00000000  T6      : 0x00000000
MSTATUS : 0x00001889  MTVEC   : 0x40380001  MCAUSE  : 0xdeadc0de  MTVAL   : 0xdeadc0de
--- 0x40380001: _vector_table at /COMPONENT_RISCV_DIR/vectors_intc.S:54
MHARTID : 0x00000000
Please enable CONFIG_ESP_SYSTEM_USE_FRAME_POINTER option to have a full backtrace.
timer0 cur tim_val = 4071957 enable=0 autoreload=1
timer0 cur tim_val = 4171962 enable=0 autoreload=1
timer0 cur tim_val = 4271964 enable=0 autoreload=1
(truncated)
timer0 cur tim_val = 8772066 enable=0 autoreload=1
timer0 cur tim_val = 8872069 enable=0 autoreload=1
timer0 cur tim_val = 8972071 enable=0 autoreload=1
E (10228) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (10228) task_wdt:  - IDLE (CPU 0)
E (10228) task_wdt: Tasks currently running:
E (10228) task_wdt: CPU 0: main
E (10228) task_wdt: Print CPU 0 (current core) registers
Core  0 register dump:
MEPC    : 0x40381cb8  RA      : 0x40384116  SP      : 0x3fc8f090  GP      : 0x3fc8c000  
--- 0x40381cb8: esp_crosscore_int_send_yield at /COMPONENT_ESP_SYSTEM_DIR/crosscore_int.c:126
--- 0x40384116: vPortYield at /COMPONENT_FREERTOS_DIR/FreeRTOS-Kernel/portable/riscv/port.c:649
TP      : 0x3fc8f140  T0      : 0x4005890e  T1      : 0x80000000  T2      : 0x00000000
--- 0x4005890e: _data_end_btdm_rom in ROM
S0/FP   : 0x00000000  S1      : 0x3fc8fb18  A0      : 0x00000001  A1      : 0x00000001
A2      : 0x00000000  A3      : 0x00000004  A4      : 0x00000001  A5      : 0x600c0000
A6      : 0xa0000000  A7      : 0x0000000a  S2      : 0x0088e727  S3      : 0x00000000
S4      : 0x0088e727  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000
T3      : 0x00000000  T4      : 0xffc00000  T5      : 0x00000000  T6      : 0x00000000
MSTATUS : 0x00001889  MTVEC   : 0x40380001  MCAUSE  : 0xdeadc0de  MTVAL   : 0xdeadc0de
--- 0x40380001: _vector_table at /COMPONENT_RISCV_DIR/vectors_intc.S:54
MHARTID : 0x00000000
Please enable CONFIG_ESP_SYSTEM_USE_FRAME_POINTER option to have a full backtrace.
timer0 cur tim_val = 9072381 enable=0 autoreload=1
timer0 cur tim_val = 9172383 enable=0 autoreload=1
timer0 cur tim_val = 9272385 enable=0 autoreload=1
(truncated)
timer0 cur tim_val = 13772595 enable=0 autoreload=1
timer0 cur tim_val = 13872600 enable=0 autoreload=1
timer0 cur tim_val = 13972605 enable=0 autoreload=1
E (15228) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (15228) task_wdt:  - IDLE (CPU 0)
E (15228) task_wdt: Tasks currently running:
E (15228) task_wdt: CPU 0: main
E (15228) task_wdt: Print CPU 0 (current core) registers
Core  0 register dump:
MEPC    : 0x40381cb8  RA      : 0x40384116  SP      : 0x3fc8f090  GP      : 0x3fc8c000  
--- 0x40381cb8: esp_crosscore_int_send_yield at /COMPONENT_ESP_SYSTEM_DIR/crosscore_int.c:126
--- 0x40384116: vPortYield at /COMPONENT_FREERTOS_DIR/FreeRTOS-Kernel/portable/riscv/port.c:649
TP      : 0x3fc8f140  T0      : 0x4005890e  T1      : 0x10000000  T2      : 0x00000000
--- 0x4005890e: _data_end_btdm_rom in ROM
S0/FP   : 0x00000000  S1      : 0x3fc8fb18  A0      : 0x00000001  A1      : 0x00000001
A2      : 0x00000000  A3      : 0x00000004  A4      : 0x00000001  A5      : 0x600c0000
A6      : 0xa0000000  A7      : 0x0000000a  S2      : 0x00d5347d  S3      : 0x00000000
S4      : 0x00d5347d  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000
T3      : 0x00000000  T4      : 0xffc00000  T5      : 0x00000000  T6      : 0x00000000
MSTATUS : 0x00001889  MTVEC   : 0x40380001  MCAUSE  : 0xdeadc0de  MTVAL   : 0xdeadc0de
--- 0x40380001: _vector_table at /COMPONENT_RISCV_DIR/vectors_intc.S:54
MHARTID : 0x00000000
Please enable CONFIG_ESP_SYSTEM_USE_FRAME_POINTER option to have a full backtrace.
timer0 cur tim_val = 14072626 enable=0 autoreload=1
timer0 cur tim_val = 14172627 enable=0 autoreload=1
timer0 cur tim_val = 14272632 enable=0 autoreload=1
Attachments
c3-test-gptimer.zip
(11.59 KiB) Downloaded 26 times

MicroController
Posts: 2669
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: GPTimer Alarm with Auto-Reload on Doesn't Get Re-enabled after Triggered

Postby MicroController » Tue Sep 30, 2025 1:02 pm

The re-enabling of the next alarm upon an alarm is done in the timer's ISR.
And the timer's interrupt is never enabled when there is no "event callback" registered for the timer.
And the task_wdt seems to be unhappy either, even with `vTaskDelay(0);` in the loop.
a) Use blocking functions instead of busy-waiting/spinning.
b) A 0 delay doesn't give the IDLE task any CPU time. vTaskDelay(1); should work.

Who is online

Users browsing this forum: Qwantbot, Semrush [Bot] and 5 guests