How To Install Using Arduino Library Manager
This library enables you to use Hardware Timers on an STM32H747XI-based Portenta_H7 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 PWMs_Array_Complex example will demonstrate the nearly perfect accuracy, compared to software-based PWM, by printing the actual period / duty-cycle in `microsecs` of each of PWM-channels.
Releases v1.0.0
1. Initial coding to support **Portenta_H7 boards** such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta
Supported Boards
1. STM32H747XI-based Portenta_H7 using using ArduinoCore-mbed mbed_portenta
Examples:
1. PWM_Multi
2. PWM_Multi_Args
3. PWMs_Array_Complex
Debug Terminal Output Sample
The following is the sample terminal output when running example PWMs_Array_Complex on Portenta_H7 to demonstrate the accuracy of Hardware-based PWM, especially when system is very busy.
Code: Select all
Starting PWMs_Array_Complex on PORTENTA_H7_M7
Portenta_H7_PWM v1.0.0
Index = 0, Instance = 0x40010000, channel = 3, TimerIndex = 0
Index = 1, Instance = 0x40000800, channel = 1, TimerIndex = 3
Index = 2, Instance = 0x40010400, channel = 2, TimerIndex = 7
Index = 3, Instance = 0x40001800, channel = 2, TimerIndex = 8
SimpleTimer (ms): 2000, us : 12659505, Dus : 9933701
PWM Channel : 0, programmed Period (us): 500000, actual : 499994, programmed DutyCycle : 20, actual : 20.00
PWM Channel : 1, programmed Period (us): 200000, actual : 199999, programmed DutyCycle : 30, actual : 30.00
PWM Channel : 2, programmed Period (us): 100000, actual : 100000, programmed DutyCycle : 50, actual : 50.00
PWM Channel : 3, programmed Period (us): 10000, actual : 10000, programmed DutyCycle : 70, actual : 70.00
SimpleTimer (ms): 2000, us : 22594086, Dus : 9934581
PWM Channel : 0, programmed Period (us): 500000, actual : 499994, programmed DutyCycle : 20, actual : 20.00
PWM Channel : 1, programmed Period (us): 200000, actual : 199998, programmed DutyCycle : 30, actual : 30.00
PWM Channel : 2, programmed Period (us): 100000, actual : 99999, programmed DutyCycle : 50, actual : 50.00
PWM Channel : 3, programmed Period (us): 10000, actual : 10000, programmed DutyCycle : 70, actual : 70.00
SimpleTimer (ms): 2000, us : 32528951, Dus : 9934865
PWM Channel : 0, programmed Period (us): 500000, actual : 499994, programmed DutyCycle : 20, actual : 20.00
PWM Channel : 1, programmed Period (us): 200000, actual : 199999, programmed DutyCycle : 30, actual : 30.00
PWM Channel : 2, programmed Period (us): 100000, actual : 100000, programmed DutyCycle : 50, actual : 50.00
PWM Channel : 3, programmed Period (us): 10000, actual : 10001, programmed DutyCycle : 70, actual : 69.99
SimpleTimer (ms): 2000, us : 42463635, Dus : 9934684
PWM Channel : 0, programmed Period (us): 500000, actual : 499994, programmed DutyCycle : 20, actual : 20.00
PWM Channel : 1, programmed Period (us): 200000, actual : 199999, programmed DutyCycle : 30, actual : 30.00
PWM Channel : 2, programmed Period (us): 100000, actual : 99999, programmed DutyCycle : 50, actual : 50.00
PWM Channel : 3, programmed Period (us): 10000, actual : 10000, programmed DutyCycle : 70, actual : 69.99
SimpleTimer (ms): 2000, us : 52398502, Dus : 9934867
PWM Channel : 0, programmed Period (us): 500000, actual : 499994, programmed DutyCycle : 20, actual : 20.00
PWM Channel : 1, programmed Period (us): 200000, actual : 199998, programmed DutyCycle : 30, actual : 30.00
PWM Channel : 2, programmed Period (us): 100000, actual : 99999, programmed DutyCycle : 50, actual : 50.00
PWM Channel : 3, programmed Period (us): 10000, actual : 10000, programmed DutyCycle : 70, actual : 70.00