MBED_RP2040_PWM library
How To Install Using Arduino Library Manager
Features
This library enables you to use Hardware-based PWM to create and output PWM to pins on RP2040 board to create and output PWM to pins.
The most important feature is they're purely hardware-based PWM
channels. Therefore, the frequency can be higher than hybrid or software-based PWM
, and their executions are not blocked by bad-behaving functions / tasks. This important feature is absolutely necessary for mission-critical tasks.
The PWM_Multi will demonstrate the usage of multichannel PWM using multiple Hardware PWM. The 4 independent Hardware-PWMs are used to control 4 different PWM outputs, with totally independent frequencies and dutycycles. You can start, stop, change and restore the settings of any PWM channel on-the-fly
Currently supported Boards
- RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, etc. using Arduino-mbed RP2040 core
Changelog
Initial Releases v1.0.0
- Initial coding to support RP2040-based boards such as Nano_RP2040_Connect and RASPBERRY_PI_PICO, etc. using Arduino-mbed core
Examples:
Debug Terminal Output Samples
1. PWM_Single on RaspberryPi Pico
The following is the sample terminal output when running example PWM_Multi on RaspberryPi Pico to demonstrate how to start multiple PWM channels, then stop, change, restore the PWM settings on-the-fly.
Starting PWM_Multi on RaspberryPi Pico
MBED_RP2040_PWM v1.0.0
[PWM] Freq = 1000.00, DutyCycle % = 50.00, DutyCycle = 0.50, Pin = GP12
[PWM] Freq = 2500.00, DutyCycle % = 50.00, DutyCycle = 0.50, Pin = GP13
[PWM] Freq = 4000.00, DutyCycle % = 50.00, DutyCycle = 0.50, Pin = GP14
[PWM] Freq = 5000.00, DutyCycle % = 50.00, DutyCycle = 0.50, Pin = GP15
=========================================================
PW (us) 0 PW (us) 1 PW (us) 2 PW (us) 3
=========================================================
500.00 200.00 125.00 100.00
Stop all PWM
0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00
Change all PWM
125.00 50.00 31.25 25.00
125.00 50.00 31.25 25.00
Restore all PWM
500.00 200.00 125.00 100.00
500.00 200.00 125.00 100.00
Stop all PWM
0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00
Change all PWM
125.00 50.00 31.25 25.00
125.00 50.00 31.25 25.00
Restore all PWM
500.00 200.00 125.00 100.00
500.00 200.00 125.00 100.00