@@ -69,7 +69,27 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) {
69
69
}
70
70
71
71
//| class PWMOut:
72
- //| """Output a Pulse Width Modulated signal on a given pin."""
72
+ //| """Output a Pulse Width Modulated signal on a given pin.
73
+ //|
74
+ //| .. note:: The exact frequencies possible depend on the specific microcontroller.
75
+ //| If the requested frequency is within the available range, one of the two
76
+ //| nearest possible frequencies to the requested one is selected.
77
+ //|
78
+ //| If the requested frequency is outside the range, either (A) a ValueError
79
+ //| may be raised or (B) the highest or lowest frequency is selected. This
80
+ //| behavior is microcontroller-dependent, and may depend on whether it's the
81
+ //| upper or lower bound that is exceeded.
82
+ //|
83
+ //| In any case, the actual frequency (rounded to 1Hz) is available in the
84
+ //| ``frequency`` property after construction.
85
+ //|
86
+ //| .. note:: The frequency is calculated based on a nominal CPU frequency.
87
+ //| However, depending on the board, the error between the nominal and
88
+ //| actual CPU frequency can be large (several hundred PPM in the case of
89
+ //| crystal oscillators and up to ten percent in the case of RC
90
+ //| oscillators)
91
+ //|
92
+ //| """
73
93
//|
74
94
//| def __init__(
75
95
//| self,
@@ -134,7 +154,9 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) {
134
154
//| pwm = pwmio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True)
135
155
//| time.sleep(0.2)
136
156
//| pwm.frequency = 880
137
- //| time.sleep(0.1)"""
157
+ //| time.sleep(0.1)
158
+ //|
159
+ //| """
138
160
//| ...
139
161
STATIC mp_obj_t pwmio_pwmout_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
140
162
enum { ARG_pin , ARG_duty_cycle , ARG_frequency , ARG_variable_frequency };
@@ -234,7 +256,8 @@ MP_PROPERTY_GETSET(pwmio_pwmout_duty_cycle_obj,
234
256
//| for the PWM's duty cycle may need to be recalculated when the frequency
235
257
//| changes. In these cases, the duty cycle is automatically recalculated
236
258
//| from the original duty cycle value. This should happen without any need
237
- //| to manually re-set the duty cycle."""
259
+ //| to manually re-set the duty cycle. However, an output glitch may occur during the adjustment.
260
+ //| """
238
261
//|
239
262
STATIC mp_obj_t pwmio_pwmout_obj_get_frequency (mp_obj_t self_in ) {
240
263
pwmio_pwmout_obj_t * self = MP_OBJ_TO_PTR (self_in );
0 commit comments