Using 8 pins as pwm output

The Arduino Uno R4 is equipped with the R7FA4M1AB3CFM processor. According to the schematics of the Arduino R4 WiFi, all digital pins are capable of hardware-based PWM. However, the Arduino API does not currently support the initiation of 8 different PWM signals, each with a unique duty cycle. Despite this, the chip's hardware manual includes an example demonstrating that it is indeed possible.

I have gone through the PWM and FspTimer files, but I don’t have enough experience to make this work.

Does anyone know how to get this working? My end goal is to control 8 individual LEDs with different duty cycles.

Why not just use PCA9685 or TLC5940? Or even smart LEDs like WS2812 or PL9823 for example.

Thank you for your response.

I tried your solution, and it works. Using analogWrite, you can write to both Channel A and Channel B of a timer. So I can work with this solloution!

Interestingly, the following example code using pwm.h works only when you use either Channel A or Channel B, but not both at the same time.

#include "pwm.h"

PwmOut pwm1(D2);
PwmOut pwm2(D5);

void setup() {

  pwm1.begin(20000.0f, 0.0f);
  pwm2.begin(20000.0f, 0.0f);

  pwm1.pulse_perc(100.0f);
  pwm2.pulse_perc(100.0f);
}

void loop(){}

When you change D5 to D3, the processor crashes.
I think it because you set twice the frequency of the timer.