Skip to content

Commit 306488e

Browse files
authored
Add note in documentation about behaviour of one-shot Hardware timer with Esp8266 (#2713)
1 parent 3d86fb3 commit 306488e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Sming/Arch/Esp8266/Components/driver/include/driver/hw_timer.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ void IRAM_ATTR hw_timer1_attach_interrupt(hw_timer_source_type_t source_type, hw
8080
* @brief Enable the timer
8181
* @param div
8282
* @param intr_type
83-
* @param auto_load
83+
* @param auto_load true for repeating timer, false for one-shot
84+
*
85+
* Note: With one-shot timer application callback must stop the timer when it is no longer required.
86+
* This is to reduce callback latency.
87+
* If this is not done, timer will trigger again when timer counter wraps around to 0.
88+
* For /16 divisor this is only 1.7s.
8489
*/
8590
inline void IRAM_ATTR hw_timer1_enable(hw_timer_clkdiv_t div, hw_timer_intr_type_t intr_type, bool auto_load)
8691
{

docs/source/framework/timers/hardware-timer.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,19 @@ The API for hardware (and :doc:`timer-queue` timers) is identical, implemented u
1111
:cpp:class:`CallbackTimer` class template for best performance.
1212

1313

14+
.. note::
15+
16+
**Applies to Esp8266 architecture only.**
17+
18+
As with all Callback timers, the :cpp:type:`HardwareTimer` can be one-shot or repeating.
19+
20+
With the Esp8266 a one-shot timer will repeat after it has been triggered, but only after the timer
21+
counter wraps around. The Esp8266 only has 23 bits of resolution so with a clock divider of 16
22+
this will happen after about 1.7s.
23+
24+
Because the Esp8266 lacks any proper PWM hardware the timer latency is critical.
25+
Adding any additional code to the callback is therefore left to the programmer.
26+
27+
1428
.. doxygengroup:: hardware_timer
1529
:members:

0 commit comments

Comments
 (0)