I want to generate 2 PWM signals at 100 kHz as shown in this image. However, I want to align the falling edges of the PWM signal with a low duty cycle with those of the PWM signals with a high duty cycle.
This code allows me to generate a 100 kHz PWM signal with a 65% duty cycle. How can I generate the other PWM signal?
#include <avr/io.h>
void setup() {
// Set Timer/Counter 1 for Fast PWM mode, non-inverted output
TCCR1A = (1 << WGM11);
TCCR1B = (1 << WGM13) | (1 << WGM12);
TCCR1A |= (1 << COM1A1); // Non-inverted PWM output on OC1A (Pin 9 on Arduino Uno)
// Set prescaler to 1 (no prescaling)
TCCR1B |= (1 << CS10);
// Set the initial values for PWM frequency and duty cycle
ICR1 = (F_CPU / ( 100000)) - 1; // Calculate ICR1 for 100 kHz frequency
OCR1A = (ICR1 + 1) * 0.65 - 1; // Calculate OCR1A for 65% duty cycle
// Set OC1A (Pin 9 on Arduino Uno) as output
DDRB |= (1 << PB1);
}
void loop() {
}
