unsigned int loop_count_pll; void setup() { unsigned char divisor; Serial.begin(9600); //This pipes to the serial monitor // put your setup code here, to run once: pinMode(10, OUTPUT); // Target frequency 271250. With 64 MHz PLL this should give 271186 Hz. // Actual frequency varies with tollerance of assumed ceramic resonator // effective divide is 118. loop_count_pll = 117; PLLFRQ = B01101010; // Set high speed timer to 64 MHz TCCR4B = B00000000;// Stop Timer/Counter1 clock by setting the clock source to none. TCCR4A = B00000000;// Set Timer/Counter1 to normal mode. TCCR4D = B00000000; // Turn off PWM TCNT4 = 0;// Set Timer/Counter4 to 0 TC4H = loop_count_pll >> 8; OCR4B = loop_count_pll;// Set the Output Compare D for Timer/Counter4 OCR4C = loop_count_pll; // Reset count at this value TCCR4A = B00010000;// Set Timer/Counter4 to CTC mode. Set OC4B to toggle. TCCR4B = 0x41;// Start Timer/Counter4 clock by setting prescale of PLL source. sei();//allow interrupts Serial.println("Starting"); } void loop() { // put your main code here, to run repeatedly: }