Ok, here's another little idea (probably mentioned in old threads):
Code:
----------o---
|
.-.
| | R1
| |
R2 '-'
Picaxe ___ |
I/O Pin ----|___|-----o
--- C1
---
|
-----------o---
Fig1
Set up an interrupt on the picaxe I/O pin when the pin goes high, using SetInt command.
Tick cycle ...
- Start with picaxe pin as input.
- C1 charges via R1.
- Interrupt fires when pin goes high.
- Interrupt routine increments tick counter then sets the pin as an output briefly and set the level low. C1 discharges through R2. Set pin back to an input. ReEnable interrupt using Setint command. Then interrupt routine ends.
Cycle repeats over and over at constant rate determined by values of R1 and C1.
If rate is high then the frequent interrupts might be quite disruptive to running of your main code (although interrupt routine would be very fast if R2 a low value so discharge is very quick). But it's a simple idea that might work (even on 08M), and wouldn't need any external chip. Wouldn't be good enough for accurate clock because of temperature effects etc.
Example code ...
Code:
'DECLARATIONS
Symbol TickCounterW = w0
Symbol TickPin = 'choose an I/O pin
Symbol DischargePause = 'set a small time in ms
'INITIALISE
SetInt ...
Input TickPin
'MAIN PROGRAM
bla bla
Interrupt:
'Increment the tick counter
Inc TickCounter
'Make TickPin an output and sets it low
Low TickPin
'Discharge C1
Pause DischargePause
'Set the TickPin back to being an input
Input TickPin
'Re-enable interrupt
SetInt ...
Return