[−][src]Module imxrt1062_hal::pwm
Pulse Width Modulation (PWM)
The PWM module provides abstractions for using the iMXRT1062's PWM capabilities. It relies on a user mutliplexing appropriate pins from. IOMUXC. It also relies on some of the timing functionality available in the CCM. See those modules for details.
Usage
In the list below, we describe the typical usage of
the PWM abstractions. For example code, please consult
the examples in the teensy4-examples
crate.
-
The system starts up with unclocked PWM controllers, represented as
UnclockedController
. Enable clocking to the controller by providing the CCM's handle. This returns aController
type that can be used to allocate PWM pins. The example below shows how to enable clocks for the PWM2 module. -
Obtain PWM pin pairs by providing processor pads to the PWM controller. As of this writing, we only provide output PWM pins, and complementary PWM pins (PWM23 and PWM45 in processor parlance) are not implemented. Use
output()
to transform PWM pins into output PWM pairs, then usesplit()
to make the pins independent instances. It's at this stage that we specify the PWM driving period (frequency), the prescalar, and the clock selection. We may only select the IPG clock; new variants will be added as necessary. -
The two
PWM
instances returned fromsplit()
implement theembedded_hal::PwmPin
trait, and they may be used to control duty cycles.
Re-exports
pub use crate::iomuxc::pwm::module; |
pub use crate::iomuxc::pwm::output; |
pub use crate::iomuxc::pwm::submodule; |
Structs
Controller | A PWM controller |
PWM | A PWM output instance. It has a module, submodule, and output type. |
Pairs | PWM complementary pairs |
Timing | Specifies the timing-related parameters for a PWM submodule |
UnclockedController | A PWM module that is not receiving a clock input |