Folks (i.e Hugh), I think I've encountered a possible 'undocumented feature' in the InitTimer0 routine.  I'm trying to make a light sequencer in which the LEDS are driven by an interrupt routine from the Timer0 interrupt, i.e. they are updated from a data object every ms or so.  I was getting very erratic flashing behaviour, so I stripped the routine down to its simplest form, which is as follows:

#chip 16F690, 4
#config HS_OSC, WDT_OFF

'set up timer prescale 
InitTimer0 (Osc,PS0_1/4)

'clear the interrupt flag
SET INTCON.T0IF OFF

'enable global and timer interrupts
set INTCON.GIE ON
SET INTCON.T0IE ON

'LED is wired to C0 so make it an output
dir C0 out

'now this is the simplest possible light flasher:

start:
leds = 0
wait 50 ms
leds = 1
wait 50 ms
goto start

sub interrupt
if leds = 0 then set PORTC.0 OFF
if leds = 1 then set PORTC.0 ON
'clear the interrupt flag
SET INTCON.T0IF OFF
end sub

Now the point is this.  For no reason I could find, the LED flashed very irregularly.  So I set up Timer0 manually by replacing the InitTimer0 call with:

SET OPTION_REG.T0CS OFF
SET OPTION_REG.PS0 ON

Now the circuit works perfectly and the flashing is uniform!  Interestingly you have to select the clock source, it seems to default to OPTION_REG.T0CS ON

Despite the fact I now have a successful system, I have no clue why the InitTimer0 routine caused problems!

Clive Washington