espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
12.56k stars 7.01k forks source link

esp_timer软件定时器 (IDFGH-12699) #13689

Open heyangxinmei opened 2 weeks ago

heyangxinmei commented 2 weeks ago

Answers checklist.

General issue report

软件定时器的回调函数,有时候会停止运行一段时间。之后有正常回调。请问什么原因会引起这个问题呢?谢谢 image

o-marshmallow commented 2 weeks ago

Hello @heyangxinmei ,

In order to help you, I have a few questions:

heyangxinmei commented 2 weeks ago
  1. esp32s3 2. idf v4.4.5 3. 通过日志观察到的计数值不增加了。4. 通过串口输出日志 是有比软件定时器优先级的任务运行引起的吗?
ESP-Marius commented 2 weeks ago

Yes, the callback is called from a task with ESP_TASK_TIMER_PRIO, so there could be tasks with a higher priority (e.g. BT)

会停止运行一段时间

How long is 一段时间? Is the callback delayed a few ms, or is it multiple seconds? Are you using power-management/sleep in your application?

It is also possible to dispatch the callback directly from the ISR: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/esp_timer.html#using-the-interrupt-dispatch-method