void timer1_phase_correct_pwm_init() {
// Set PB1 (OC1A) as output
DDRB |= (1 << PB1);
// Configure Timer1 for Phase Correct PWM
TCCR1A = (1 << WGM11)|(1 << WGM10) | (1 << COM1A1); // 8-bit Phase Correct PWM, Clear OC1A on Compare Match
TCCR1B = (1 << CS11)|(1 << CS10); // Phase Correct PWM, Prescaler = 8
// Set the TOP value for Phase Correct PWM (10-bit, max value is 1023)
ICR1 = 1023;
// Set initial duty cycle to 50% (OCR1A = TOP/2)
OCR1A = 700;
// Initialize TCNT1 to 0 (start counting from the beginning)
TCNT1 = 0;
}
int main() {
timer1_phase_correct_pwm_init();
while (1) {
}
return 0;
}