Barry, Thanks for your answer. I think you've got it. I've disabled the WDT in the config bits, but the datasheet says to call CLRWDT even if WDT is disabled whern reassigning the prescaler. I'll give it a go. Cheers, Andy -----Original Message----- From: Barry King [mailto:barry@NRGSYSTEMS.COM] Sent: 09 December 1999 17:10 To: PICLIST@MITVMA.MIT.EDU Subject: Re: TMR0 and prescaler Andy, > PIC16F84 with 4MHz clock > TMR0 driven from the external clock I think you mean from the internal clock, i.e. T0CS = 0, right? > the prescaler assigned to TMR0 and set to /256 > load TMR0 with 0x3D, so that TMR0 increments 195 time before wrapping > This generates an interrupt from the timer wrap every 50ms or so. I want > this timer to keep running, so as part of the interrupt handler, I reprime > TMR0 with 0x3D to wait for another 50ms, OK so far. > but in doing so, I discovered, this > turns off the prescaler. No. writing to TMR0 register does not change the prescaler assignment. It does _clear_ the prescaler register to 0, which means that the clock cycles since rollover are discarded. Exactly how many cycles are "missed" depends on how many cycles your interrupt routine uses. > So my fix was also to reset the OPTION byte to > reassign the prescaler each time I reprime TMR0. > This works fine But its not needed. What was the symptom that led you to believe it was needed? Does the program work if you remove that re-set of the OPTION register? One other point- when you re-assign the prescalerto TMR0 by writing OPTION, you should always CLRWDT first according to the manual. There seems to be the possibility that a spurious WDT reset will occur when the OPTION write flips the prescaler switches away from the WDT. Maybe that was what you were seeing? A Reset will set OPTION back to 0FFh, so the prescaler is back on the WDT. Regards, ------------ Barry King, KA1NLH Engineering Manager NRG Systems "Measuring the Wind's Energy" Hinesburg, Vermont, USA www.nrgsystems.com