I was asked to do a rough count of people walking through a hallway. So I ordered some PIR sensors, that are typically used in light switches that turn off when no one is there. I could have used any of our boards, and the LPC1756 has a crystal controlled real time clock. But that would be too easy, so I chose an LPC1114 board, as I have many of those. It does not have a crystal oscillator, but a 1% trimmed internal RC, that is also accurate to less than 1/4 % variation over a wide temperature range. So I grabbed one out of the experimental bin (boards used for testing and not for sale). First to do was to set the clock for accuracy while I'm waiting for the PIR sensor order to arrive. Starting with the TIMER1.bas example, modified it to print something every minute, and run it for a while against a web stopwatch. Mods to that example below.
#define SEC60 57640 ' adjusted by hand from 60000 milliseconds
main:
ON_TIMER(SEC60, ADDRESSOF TIMER1IRQ)
s3 = 0
e3 = 0
print "start"
dim minut
WHILE (1)
if s3 <> e3 then
s3 = e3
print ".";
minut += 1
if (minut mod 10) = 0 then print minut;chr(7) ' beep every 10 minutes
endif
LOOP
So running that for many hours (like overnight), the value SEC60 can me tweaked.
So after a day of running and adjusting it is accurate to about 1 second per day, good enough for this project.