There’s only one real advantage running a PIC at 32kHz, and that it’s power consumption is minimal. Beyond that you leave yourself with no room to manoeuvre with instructions.
The 32,768 Hz Oscillator gives you an instruction time of one quarter of that... 122.0703uS. That’s only 8192 ($2000) instructions per second.
Knowing that a 16-bit Timer generates an interrupt, or pops up a Flag when it rolls over from $FFFF across to $0000, so therefore if you take $0000 and subtract $2000 from it you get $E000. Preload the 16-Bit Timer with $E000, and every second you’ll get an interrupt or Flag waving about.
Each time you see the Flag you need to reload the Timer with $E000 for the start of the next second, and reset the Flag. Those actions will themselves take a few instructions, so you may have to play and adjust $E000 accordingly, adding a little to trim the timekeeping... therefore you probably might end up with something like $E008.
However this ‘Background’ method of timekeeping leaves the PIC with eight thousand instructions each second to play with and do other useful things before the next Flag pops up.
For really accurate timekeeping, you need a FASTER Clock, not a slower one. At 32.768kHz each instruction cycle (clock tick) you add or take away costs you 122.07uS. At 20MHz, each clock tick costs you 200nS. You can see that you can achieve a much finer adjustment allowing for far more precise timekeeping if you go FASTER rather than slower.
Bookmarks