Leonardo, (32u4) hardware timer4 PWM does not work as expected

I am trying to use timer4 to generate two PWM's:
Using this library(from libraries): GitHub - samverstraete/TimerFour: Allow usage of the 10-bit hardware high speed Timer4 on ATMega16u4 and ATMega32u4

Testing:

#include <TimerFour.h>

#define GATE_A  9   //pin 29  PB5(PCINT5/OC1A/OC4B#/ADC12)
#define GATE_B 10   //pin 30  PB6(PCINT6/OC1B/OC4B/ADC13)

void setup(void)
{
  pinMode(GATE_A, OUTPUT);
  pinMode(GATE_B, OUTPUT);
  Timer4.initialize(100);  //100us
  Timer4.pwm(GATE_A, 256);
  Timer4.pwm(GATE_B, 512);
}

void loop(void)
{
  delay(200);
}

Measured with an oscilloscope:
The problem is that the GATE_B output is ok (50% duty cycle) - but GATE_A is just low.

Did you read the documentation of that library:

It has only been tested (yet) on a generic Pro Micro. For the Pro Micro you can use pin 5, 6, 9, 10, 12 or 13. However, note that half of the ports are complimentary ports, so you can't set the duty cycle seperately, see the table below:

Pins 9 and 10 are complimentary, so you cannot set different duties.

1 Like

thank you, this explains the time I've seen the same PWM on both.
I'll make a software PWM then.

Just use other pins, then you can set different duties.

Measured with an oscilloscope:
The problem is that the GATE_B output is ok (50% duty cycle) - but GATE_A is just low.

In your posting you said that there was no output on one pin, not two outputs with similar duty cycles. The no output made no sense to me and is not consistent with the complementary outputs.

Yes, I did change the pin(had mod the PCB), and now have a decent and easy hardware PWM, thanks.