void setup() {
OCR1B = 0x127; // Output (PB4) goes to 0 at count 127, this gives 50% duty cycle.
OCR1C = 0x255; // timers resets at value 255, i.e., with freq PLL_freq/256.
// At PLL_freq = 64Mhz, this means 250Khz
pinMode(PB4, OUTPUT); // Enable PWM output pin
// Enable 64 MHz PLL and use as source for Timer1
PLLCSR = 1<<PCKE | 1<<PLLE;
// Waits until the bit PLOCK is set, which is once PLL has locked.
// while ( (PLLCSR & (1<<PLOCK)) == 0){}
// Set up Timer/Counter1 for PWM output
TIMSK = 0; // Timers interrupts are all OFF
// Non needed if PMW1 is set.
// TCCR1 |= 1<<CTC1; // Reset the timer after a match with OCR1C
TCCR1 = 1<<CS10; // 1:1 prescale
GTCCR |= 1<<PWM1B; // PWM B,
GTCCR |= 1<<COM1B1; // OC1x cleared on compare match. Set when TCNT1 = $00.
}
void loop() { }