My typical set up is something like this, with the default internal rc oscillator:
Code: Select all
//if enough time has elapsed
if (ticks() - tick0 > LED_DLY) { //if enough time has passed
tick0 += LED_DLY; //advance to the next match point
pinFlip(LED); //digitalWrite(LED, !digitalRead(LED)); //flip led, 105 ticks
//measure timing
tmp0=ticks();
//put some tasks here
tmp0=ticks() - tmp0;
//display something on uart
u2Print("F_CPU= ", F_CPU); //89.9K polling, 9.3K interrupt
u2Print("F_PHB= ", F_PHB);
u2Print("ticks= ", ticks());
u2Print("tmp0 = ", tmp0);
u2Print("U2BRG= ", tmp0=U2BRG);
u2Print("u2bps= ", u2bps());
u2Println();
}
So I thought maybe this particular chip is bad so I tried the code on the other chip. off by 10% and in the same direction. So either this vendor has gone downhill as of late (two chips have markings from 2021) or I struck gold

a couple days passed and I chanced upon an article about this chip family having an internal RC oscillator at 7.37Mhz - and my code came from a chip with an 8Mhz internal oscillator.

I have been at this for quite sometime now and I have always stressed the importance of reading the DS front to back. I should have taken up my own advice.
my embarrassment and your gain.
