PWM control for a single pin.
The chip-dependent type of a PWM pin.
Generate a PWM single on the given pin at the given frequency and duty cycle.
frequency_hzis specified in Hertz.
duty_cycleis specified as a portion of the max duty cycle supported by the chip. Clients should call
get_maximum_duty_cycle()to get the value that corresponds to 100% duty cycle, and divide that appropriately to get the desired duty cycle value. For example, a 25% duty cycle would be
PWM0.get_maximum_duty_cycle() / 4.
Stop a PWM pin output.
Return the maximum PWM frequency supported by the PWM implementation. The frequency will be specified in Hertz.
Return an opaque number that represents a 100% duty cycle. This value will be hardware specific, and essentially represents the precision of the underlying PWM hardware.
Users of this HIL should divide this number to calculate a duty cycle
value suitable for calling
start(). For example, to generate a 50%
let max = PWM0.get_maximum_duty_cycle(); let dc = max / 2; PWM0.start(pin, freq, dc);