All right, everything was moved to TMR2, saved, recompiled and reinstalled… it runs but otherwise no joy…
Changes to OCR2A cause no changes in the output signal… 41.2 KHz measured here.
Changes to prescaler ratio ( TCCR2B ) also have no effect, output signal = always 42.2 KHz
Datasheet I am using is straight from the Microchip website, I must assume it is current :
Thanks for your help, but this is ridiculous… I’m almost ready to walk away from this… for a few days anyway.
Here is the current code I am using… It compiles, it downloads, it runs and it wiggles the output pin at 41.2 KHz… PERIOD.
/*
Bob's Arduino AtMega 328P timer interrupt program
Timer_Interrupts_Bob.ino
BobStuff/Products/Si5351/Source
*/
// Definitions
#define OutputPin 12 // output pin for TMR0 signal
// TMR0 Interrupt Service Routine
ISR(TIMER2_COMPA_vect)
{
digitalWrite(OutputPin, digitalRead(OutputPin) ^ 1); // toggle the output pin
}
// Startup Code
void setup()
{
pinMode(OutputPin, OUTPUT); // digital pin 12 = output
noInterrupts(); // disable all interrupts ( temporary )
TCCR2A = 0; // clear TCCR2A
TCCR2B = 0; // clear TCCR2B
TCNT2 = 0; // clear TMR2 8 bit count register
OCR2A = 50; // count up to 50, then INTERRUPT
TCCR2A |= (1 << WGM21); // turn on TMR2 CTC mode
TCCR2B |= (1 << CS20); // set CS20, no prescaler ( = DIV BY 1 )
TIMSK2 |= (1 << OCIE2A); // enable TMR2 COMPARE interrupt
interrupts(); // enable all unmasked interrupts
}
// Main Program Loop
void loop()
{
}