10000 mimxrt: Add a short documentation for PWM. · micropython/micropython@cf84ec4 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf84ec4

Browse files
comm 10000 itted
mimxrt: Add a short documentation for PWM.
Showing examples and listing the assignment of signals to pins.
1 parent dde54ff commit cf84ec4

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

docs/mimxrt/quickref.rst

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,134 @@ MIXMXRT1060-EVK D0/D1 D7/D6 D8/D9 A1/A0 - - -
135135
MIXMXRT1064-EVK D0/D1 D7/D6 D8/D9 A1/A0 - - - -
136136
=============== ===== ===== ======= ======= ===== ===== ===== =====
137137

138+
PWM (pulse width modulation)
139+
----------------------------
140+
141+
The i.MXRT has up to four dedicated PWM modules with four FLEXPWM submodules each
142+
and up to four QTMR modules with four channels, which can be used to generate
143+
a PWM signal of signal pair.
144+
145+
The PWM functions are provided by the :ref:`machine.PWM <machine.PWM>` class.
146+
It supports all basic methods listed for that class and a few additional methods for
147+
handling signal groups. ::
148+
149+
# Samples for Teensy
150+
#
151+
152+
from machine import Pin, PWM
153+
154+
pwm2 = PWM(Pin(2)) # create PWM object from a pin
155+
pwm2.freq() # get current frequency
156+
pwm2.freq(1000) # set frequency
157+
pwm2.duty_u16() # get current duty cycle, range 0-65535
158+
pwm2.duty_u16(200) # set duty cycle, range 0-65535
159+
pwm2.deinit() # turn off PWM on the pin
160+
# create a complementary signal pair on Pin 2 and 3
161+
pwm2 = PWM((2, 3), freq=2000, duty_ns=20000)
162+
163+
# Create a group of four synchronized signals.
164+
# Start with Pin(4) at submodule 0, which creates the sync pulse.
165+
pwm4 = PWM(Pin(4), freq=1000, align=PWM.HEAD)
166+
# Pins 5, 6, and 9 are pins at the same module
167+
pwm5 = PWM(Pin(5), freq=1000, duty_u16=10000, align=PWM.HEAD, sync=True)
168+
pwm6 = PWM(Pin(6), freq=1000, duty_u16=20000, align=PWM.HEAD, sync=True)
169+
pwm9 = PWM(Pin(9), freq=1000, duty_u16=30000, align=PWM.HEAD, sync=True)
170+
171+
pwm3 # show the PWM objects properties
172+
173+
174+
175+
Each FLEX submodule or QTMR module may run at different frequencies. The frequency range
176+
is 5 Hz to >1 MHz, with increasing error for frequency an duty cycle at higher frequencies.
177+
Pins are specified in the same way as for the Pin class.
178+
179+
The following table shows the assignment of the board Pins to PWM units:
180+
181+
=========== ====== ====== ==============
182+
Pin/ MIMXRT 1010 1020 1050/1060/1064
183+
=========== ====== ====== ==============
184+
D0 - F1/1/B -
185+
D1 - F1/1/A -
186+
D2 F1/3/B - F1/3/B
187+
D3 F1/3/A F2/3/B F4/0/A
188+
D4 F1/3/A Q2/1 F2/3/A
189+
D5 F1/0/B F2/3/A F1/3/A
190+
D6 - F2/0/A Q3/2
191+
D7 - F1/0/A Q3/3
192+
D8 F1/0/A F1/0/B F1/1/X
193+
D9 F1/1/B F2/0/B F1/0/X
194+
D10 F1/3/B F2/2/B F1/0/B (*)
195+
D11 F1/2/A F2/1/A F1/1/A (*)
196+
D12 F1/2/B F2/1/B F1/1/B (*)
197+
D13 F1/3/A F2/2/A F1/0/A (*)
198+
D14 F1/0/B - Q3/0
199+
D15 F1/0/A - Q3/1
200+
A0 - F1/2/A -
201+
A1 F1/3/X F1/2/B -
202+
A2 F1/2/X F1/3/A -
203+
A3 - F1/3/B -
204+
=========== ====== ====== ==============
205+
206+
Pins denoted with (*) are by default not wired at the board.
207+
208+
209+
==== ========== ==== ==========
210+
Pin Teensy 4.0 Pin Teensy 4.1
211+
==== ========== ==== ==========
212+
0 F1/1/X 0 F1/1/X
213+
1 F1/0/X 1 F1/0/X
214+
2 F4/2/A 2 F4/2/A
215+
3 F4/2/B 3 F4/2/B
216+
4 F2/0/A 4 F2/0/A
217+
5 F2/1/A 5 F2/1/A
218+
6 F2/2/A 6 F2/2/A
219+
7 F1/3/B 7 F1/3/B
220+
8 F1/3/A 8 F1/3/A
221+
9 F2/2/B 9 F2/2/B
222+
10 Q1/0 10 Q1/0
223+
11 Q1/2 11 Q1/2
224+
12 Q1/1 12 Q1/1
225+
13 Q2/0 13 Q2/0
226+
14 Q3/2 14 Q3/2
227+
15 Q3/3 15 Q3/3
228+
18 Q3/1 18 Q3/1
229+
19 Q3/0 19 Q3/0
230+
22 F4/0/A 22 F4/0/A
231+
23 F4/1/A 23 F4/1/A
232+
24 F1/2/X 24 F1/2/X
233+
25 F1/3/X 25 F1/3/X
234+
28 F3/1/B 28 F3/1/B
235+
29 F3/1/A 29 F3/1/A
236+
33 F2/0/B 33 F2/0/B
237+
- - 36 F2/3/A
238+
- - 37 F2/3/B
239+
DAT1 F1/1/B 42 F1/1/B
240+
DAT0 F1/1/A 43 F1/1/A
241+
CLK F1/0/B 44 F1/0/B
242+
CMD F1/0/A 45 F1/0/A
243+
DAT2 F1/2/A 46 F1/2/A
244+
DAT3 F1/2/B 47 F1/2/B
245+
- - 48 F1/0/B
246+
- - 49 F1/2/A
247+
- - 50 F1/2/B
248+
- - 51 F3/3/B
249+
- - 52 F1/1/B
250+
- - 53 F1/1/A
251+
- - 54 F3/0/A
252+
==== ========== ==== ==========
253+
254+
Legend:
255+
256+
* Qm/n: QTMR module m, channel n
257+
* Fm/n/l: FLEXPWM module m, submodule n, channel l. The X-Channels duty cycle is not
258+
independent from the A and B channels of the same submodule.
259+
If you use the A/B channels as well, the duty cycle will be 32768 (or 50%).
260+
261+
Pins without a PWM signal are not listed. A signal may be available at more than one Pin.
262+
PWM may also be activated at CPU pins, which are not available at the board connectors.
263+
Such a Pin may be used as synchronisation master.
264+
265+
138266
ADC (analog to digital conversion)
139267
----------------------------------
140268

0 commit comments

Comments
 (0)
0