You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/PINIO PWM.md
+36-14Lines changed: 36 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,22 @@
2
2
3
3
INAV provides two mechanisms for generating output signals on GPIO pins:
4
4
5
-
1.**PINIO channels (0-3)** — Any PWM-capable timer output defined as `PINIOx_PIN`in the target. Supports full 0-100% duty cycle PWM at 24 kHz.
6
-
2.**LED strip idle level (channel 4)** — The WS2812 LED strip pin can be switched between idle-LOW and idle-HIGH between LED update bursts. Binary on/off only.
5
+
1.**PINIO channels (1-4)** — PWM-capable timer outputs, either defined in the target (`PINIOx_PIN`) or assigned by the user in the configurator's Output tab. Supports full 0-100% duty cycle PWM at 24 kHz.
6
+
2.**LED strip idle level (channel 0)** — The WS2812 LED strip pin can be switched between idle-LOW and idle-HIGH between LED update bursts. Binary on/off only.
7
7
8
8
## PINIO PWM channels
9
9
10
-
PINIO channels are configured per-target in `target.h` using `PINIO1_PIN` through `PINIO4_PIN`. When a PINIO pin has a timer, it is automatically configured as a 24 kHz PWM output.
10
+
PINIO channels can come from two sources:
11
+
12
+
1.**Target-defined:**`PINIO1_PIN` through `PINIO4_PIN` in `target.h`. These are always available on supported boards.
13
+
2.**User-assigned:** Any timer output pad can be set to PINIO mode in the configurator's Output tab (timer_output_mode = PINIO). No target.h changes needed.
14
+
15
+
When a PINIO pin has a hardware timer, it is automatically configured as a 24 kHz PWM output. Pins without a timer fall back to GPIO on/off.
PINIO channels can be controlled by both mode boxes (Modes tab) and the programming framework (Programming tab). When both are used:
33
+
34
+
- The **programming framework** sets the duty cycle (0-100%).
35
+
- The **mode box** gates the output on or off. When the mode is active, the programmed duty is output. When inactive, the pin is driven to 0%.
36
+
37
+
If no RC channel range is assigned to the USERx mode in the Modes tab, the programming framework has exclusive uninterrupted control — the mode box does not interfere.
38
+
39
+
The default duty (before the programming framework sets a value) is 100%, so toggling a mode box without any programming gives full on/off behavior.
40
+
41
+
## LED strip idle level (channel 0)
25
42
26
43
When the LED strip feature is enabled, the WS2812 pin sends data bursts (~1 ms) every 10-20 ms. Between bursts, the pin idles at a configurable level.
27
44
28
-
The LED strip idle level is accessible as channel `4` (the next channel after PINIO hardware channels 0-3):
45
+
The LED strip idle level is accessible as channel `0`:
-**Programming framework:** Operation 52, Operand A = value (>0 = HIGH, 0 = LOW), Operand B = 0
32
49
33
50
This can be used to drive a MOSFET or similar device connected to the LED pin, toggled by the programming framework based on flight mode, RC channel, GPS state, etc.
34
51
@@ -43,17 +60,22 @@ Normally LED pin is held low between WS2812 updates:
43
60
44
61
When idle is set HIGH, the pin is held high between updates. Total ws2812 pulse duration is ~1ms with ~9ms pauses. Connected devices should be tolerant of these brief transients.
45
62
46
-
# Generating PWM/output signals with programming framework
63
+
# Channel numbering
64
+
65
+
| Channel | Target | Description |
66
+
|---------|--------|-------------|
67
+
| 0 | LED strip | Binary idle level (HIGH/LOW) |
68
+
| 1-4 | PINIO 1-4 | Full 0-100% PWM at 24 kHz |
47
69
48
-
See operation 52 "PINIO PWM" in [Programming Framework](Programming%20Framework.md)
70
+
This numbering is consistent across the CLI (`piniopwm`), programming framework (operation 52), and the `pinio_box1`-`pinio_box4` settings.
0 commit comments