@@ -35,7 +35,7 @@ Example usage::
35
35
Constructors
36
36
------------
37
37
38
- .. class :: PWM(dest, freq, \*, duty_u16, duty_ns, keyword_arguments)
38
+ .. class :: PWM(dest, freq, \*, duty, duty_u16, duty_ns, keyword_arguments)
39
39
:noindex:
40
40
41
41
Construct and return a new PWM object using the following parameters:
@@ -47,7 +47,8 @@ Constructors
47
47
If the object tuple is specified, the two pins act in complementary
48
48
mode. These two pins must be the A/B channels of the same submodule.
49
49
- *freq * should be an integer which sets the frequency in Hz for the
50
- PWM cycle. The valid frequency range is 15 Hz - > 1 MHz.
50
+ PWM cycle. The valid frequency range is 15 Hz or 18Hz up to > 1 MHz.
51
+ - *duty * sets the duty cycle as a percent value .
51
52
- *duty_u16 * sets the duty cycle as a ratio ``duty_u16 / 65536 ``.
52
53
The duty cycle of a X channel can only be changed, if the A and B channel
53
54
of the respective submodule is not used. Otherwise the duty_16 value of the
@@ -80,9 +81,6 @@ Constructors
80
81
- *sync *\= True|False. If a channel of a module's submodule 0 is already active, other
81
82
submodules of the same module can be forced to be synchronous to submodule 0. Their
82
83
pulse period start then at at same clock cycle. The default is False.
83
- - *start *\= True|False. Start the PWM clock immediately. If set to False, you can define
84
- a group of channels first and then start them using the PWM.start() method. The
85
- default is True.
86
84
- *xor *\= 0|1|2. If set to 1 or 2, the channel will output the XORed signal from channels
87
85
A or B. If set to 1 on channel A or B, both A and B will show the same signal. If set
88
86
to 2, A and B will show alternating signals. For details and an illustration, please
@@ -92,14 +90,14 @@ Constructors
92
90
channels are set to low. That allows connected H-bridges to switch off one side
93
91
of a push-pull driver before switch on the other side.
94
92
95
- *freq *, *duty_u16 * and *duty_ns * may be given as keyword arguments as well. Only the
93
+ *freq *, *duty *, * duty_u16 * and *duty_ns * may be given as keyword arguments as well. Only the
96
94
*freq * argument is mandatory.
97
95
98
96
99
97
Methods
100
98
-------
101
99
102
- .. method :: PWM.init(freq, \*, duty_u16, duty_ns, keyword_arguments)
100
+ .. method :: PWM.init(freq, \*, duty, duty_u16, duty_ns, keyword_arguments)
103
101
:noindex:
104
102
105
103
Modify settings for the PWM object. See the above constructor for details
@@ -121,6 +119,17 @@ Methods
121
119
With a single *value * argument the frequency is set to that value in Hz. The
122
120
method may raise a ``ValueError `` if the frequency is outside the valid range.
123
121
122
+ .. method :: PWM.duty([value])
123
+ :noindex:
124
+
125
+ Get or set the current percent duty cycle of the PWM output, as an unsigned
126
+ value in the range 0 to 100 inclusive.
127
+
128
+ With no arguments the duty cycle is returned.
129
+
130
+ With a single *value * argument the duty cycle is set to that value, measured
131
+ as the ratio ``value / 65536 ``.
132
+
124
133
.. method :: PWM.duty_u16([value])
125
134
:noindex:
126
135
@@ -141,29 +150,13 @@ Methods
141
150
142
151
With a single *value * argument the pulse width is set to that value.
143
152
144
- .. method :: PWM.center([value])
145
-
146
- Get or set the current pulse center of the PWM output, as an unsigned 16-bit
147
- value in the range 0 to 65535 inclusive.
148
-
149
- With no arguments the center position is returned.
150
-
151
- With a single *value * argument the center position is set to that value.
152
-
153
- .. method :: PWM.start([mask])
154
-
155
- Start the PWM of the respective FLEXPWM submodule or QTMR channel. If a mask is specified,
156
- the bits of it designate the respective submodules or channels.
157
-
158
- .. method :: PWM.stop([mask])
159
-
160
- This is an alias to PWM.deinit.
161
-
162
153
Pin Assignment
163
154
--------------
164
155
165
- Each FLEX submodule or QTMR module may run at different frequencies. The frequency range
166
- is 5 Hz to >1 MHz, with increasing error for frequency an duty cycle at higher frequencies.
156
+ Each FLEX submodule or QTMR module may run at different frequencies. The lowest frequency
157
+ is clock_freq/2**25, or 15Hz for MIMXRT1010 and MIMXRT1020, and 18 Hz for the other
158
+ boards. The highest frequency with U16 resolution is clock_frequency/2**18 (1907 and 2288 Hz),
159
+ the highest frequency with 1 percent resolution is clock_frequency/400 (1.25 and 1.5 MHz).
167
160
Pins are specified in the same way as for the Pin class.
168
161
169
162
The following table shows the assignment of the board Pins to PWM units:
0 commit comments