![]() |
nRF5 SDK
v15.2.0
|
Choose documentation: | nRF5 SDK | S112 SoftDevice API | S132 SoftDevice API | S140 SoftDevice API | S212 SoftDevice API |
The low-power pulse-width modulation (PWM) library provides functions to generate a pulse-width modulated output signal while using minimal power. The signal can be used, for example, to change the intensity or the color of LEDs.
Key features include:
This library uses an application timer and is therefore not very accurate. It can be used to control, for example, LEDs, but for peripherals that need a high accuracy, you should use the PWM library instead.
Complete the following steps to generate a low-power PWM signal:
The following code example shows how to initialize and start a low-power PWM instance with the default configuration and a given pin mask:
As a result, a PWM signal is generated on the selected output pins.
In the default configuration, the RTC frequency is 32768 Hz. The prescaler must not be greater than 6, therefore the timer cannot be started with less than 5 ticks. This means that the break between time-outs is at least 150 microseconds.
See the Low-Power PWM Example for a full example that uses the low-power PWM library.
Low-power PWM uses RTC. Therefore, it is less accurate when used with a SoftDevice.