hippy
Ex-Staff (retired)
Following on from other projects connecting a 32kHz watch crystal to a PICAXE, here's one way to do it with the 20X2.
The only downside is that the chip can no longer be programmed in-circuit and C.7 is unavailable for use, though it should be possible to add a 3-way molex to select between download 10K/22K or crystal.
For maximum accuracy you might have to play with crystal make and capacitor values. Worked on breadboard with no capacitors but I didn't check frequency.
The code enables the LP Oscillator and Timer 1 to use it, then watches the TMR1 register increment. The msb changes state every 32768 clock ticks which is conveniently one second. In most applications which loop in less than one second all that would be needed is to call a subroutine to check the msb has changed. The program as a whole can run at any speed up to 64MHz.
It might be possible to generate a genuine 'Interrupt:' every two seconds. Will need to investigate that further.
The only downside is that the chip can no longer be programmed in-circuit and C.7 is unavailable for use, though it should be possible to add a 3-way molex to select between download 10K/22K or crystal.
For maximum accuracy you might have to play with crystal make and capacitor values. Worked on breadboard with no capacitors but I didn't check frequency.
The code enables the LP Oscillator and Timer 1 to use it, then watches the TMR1 register increment. The msb changes state every 32768 clock ticks which is conveniently one second. In most applications which loop in less than one second all that would be needed is to call a subroutine to check the msb has changed. The program as a whole can run at any speed up to 64MHz.
It might be possible to generate a genuine 'Interrupt:' every two seconds. Will need to investigate that further.
Attachments
-
3.2 KB Views: 232