Don't set TMR0, instead add to it. The correct value to add should be 256-193+2 The +2 is required because the timer update is inhibited for 2 cycles after the add. You should do the add instead of the MOVF to avoid problems with interrupt jitter. Bob Ammerman RAm Systems ----- Original Message ----- From: "Pic Dude" To: Sent: Friday, May 17, 2002 4:37 PM Subject: Re: Antwort: [PIC]: External clock... > Don't ask -- I think I just need more sleep or something. > As you were typing this email, I realized the flaw. Switched > back to the 32.768khz crystal, saw the (correct) timing and > was looking at the code for that, when I realized I'm > accounting for the 256 in that code, but not in the 1.544Mhz > code. > > I think that train of thought started when I was trying > to find the factors of 1,544,000 Hz for the dividers, and > being non-divisible by 256, I somehow managed to ignore it. > > Okay, it's confirmed, I'm brain-dead. > > Guess what I really need to do is set TMR0 to 255-193 on > each interrupt cycle and drop my SCALER0 altogether. > > Thanks much, > -Neil. > > > > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Andrew Warren > Sent: Friday, May 17, 2002 3:06 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: Antwort: [PIC]: External clock... > > > Pic Dude wrote: > > > 1.544 MHz external oscillator .... (which I connected to > > OSC1/CLKIN). OSC2/CLKOUT is now open. > > > > Pre-scaler is now 1:8 and ISR routine divides a few times: first by > > 193, then by 25, then by 10, to give me 1-sec pulses. (There's a > > reason for those divisors in case you're wondering -- I can get 0.1 > > sec pulses I need for something else). > > > > However, it's running MUCH slower than that -- taking a few minutes to > > generate a 1-sec pulse! > > Neil: > > Lemme guess... It's taking exactly 4 minutes and 16 seconds per "1- > second" pulse, right? > > I think you're misunderstanding how the TMR0 interrupt works. The > TMR0 register is incremented by the prescaler, but the TMR0 interrupt > doesn't fire until the TMR0 register overflows from 255 to 0... So > your interrupts are actually happening at 1/256 the rate that you > thought. > > Does that explain the behavior you're seeing? > > -Andy > > === Andrew Warren -- aiw@cypress.com > === Principal Design Engineer > === Cypress Semiconductor Corporation > === > === Opinions expressed above do not > === necessarily represent those of > === Cypress Semiconductor Corporation > > -- > 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 > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads