James, You have the right idea here. The better idea is to ADD a value to TMR0 in your interrupt handler. This avoids issues with interrupt timing jitter. Assuming no prescaler, the actual interrupt rate will be every: 256 - (Value_Added - 2) Instructions. One particularly useful case: movlw 8 addwf TMR0 This will result in an interrupt every 250 instructions (250 uSec at 4MHz clock, or exactly 4000 interrupts per second). Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) ----- Original Message ----- From: "James Paul" To: Sent: Friday, April 27, 2001 9:01 AM Subject: Re: [PIC]: tmr0 on 16F84 interrupt period > Nick, > > If you have no prescaler and you write 255 to the TMR0 register, > you can get an interrupt in 3us I believe. It may be slightly > more than that, but not much. I get this from the fact that > writing a value (255) to TMR0 means the next clock will overflow > it. But, since you wrote to it, there is a two cycle delay before > it increments again because it has to synchronize. Therefore 3us. > If this is wrong, I'm sure someone will correct me. I'm recalling > this from memory because I don't have the datasheet in front of me. > So don't be too harsh if I'm not completely correct. > > Regards, > > Jim > > > On Thu, 26 April 2001, Nick Veys wrote: > > > > > Just double checking this. At 4MHz, the timer will interrupt every: > > 256((2^(prescaler+1)/(2^22)) seconds. So with a 0 prescalar you'll be > > getting an interrupt every: 256(2/(2^22)) seconds (122us)? This appears to > > be the smallest obtainable period with this clock speed. If anyone can > > confirm this, it'd be much appreciated!! > > > > Also, if someone has a better timer interrupt reference than the 16F84 data > > sheet, I'd appreciate that too. The datasheet merely says 1:2 .. 1:256 > > prescalars are available and I only assume that means clock/2^(prescale+1). > > > > Thanks! > > > > -- > > http://www.piclist.com hint: PICList Posts must start with ONE topic: > > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > jim@jpes.com > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads