Skip to content

Commit 3ba69e9

Browse files
Add interrupt section to docs
Adds a section on interrupts to the docs and lists the restrictions and warnings about running long tasks. Fixes esp8266#6428
1 parent fadc71f commit 3ba69e9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/reference.rst

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Reference
22
=========
33

4+
Interrupts
5+
----------
6+
7+
Interrupts can be used on the ESP8266, but they must be used with care
8+
and have several limitations:
9+
10+
* Interrupt callback functions must be in IRAM, because the flash may be
11+
in the middle of other operations when they occur. Do this by adding
12+
the ``ICACHE_RAM_ATTR`` attribute on the function definition.
13+
14+
* Interrupts should not perform delay() or any long-running (>1ms) task.
15+
WiFi and other portiong of the code can become unstable if interrupts
16+
are blocked by a long-running interrupt. If you have much to do, you can
17+
set a volatile global flag that your main ``loop()`` can check each pass
18+
or use a scheduled function (which will be called by the OS when it is
19+
safe, and not at IRQ level) to do the work.
20+
21+
* Memory operations can be dangerous and avoided in interrupts. Calls to
22+
``new`` or ``malloc`` should be minimized, and calls to ``realloc`` and
23+
``free`` must NEVER be used.
24+
425
Digital IO
526
----------
627

0 commit comments

Comments
 (0)