Searching \ for '[PIC] interupt question using TMR0' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'interupt question using TMR0'.

Exact match. Not showing close matches.
'[PIC] interupt question using TMR0'
2005\10\31@011114 by

Sort of a basic question that I thought I had understood.....you would think by now....the obvious would be obvious...

Have a crystal, 4.1952MHz, so it has a cycle time of 0.95347uS.  I am using TMR0 to generate an interupt, with a prescaler set for TMR0 (not the watchdog) of 1:64.

OK, so by calculations, that should be every 64 tics or 61.022uS, TMR0 is clocked.  Using the rollover for the interupt it should then be 15.621mS for each interupt cycle.  I am measuring 13.32mS.  What am I missing here...

---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
> Have a crystal, 4.1952MHz

Are you sure it's 4.1952 ? Not the more common 4.9152 ?

4.9152MHz cycle time = 0.8138us

> so it has a cycle time of 0.95347uS

> prescaler of 1:64 -> 61.022uS

> rollover -> 15.621mS for each interupt cycle

> I am measuring 13.32mS.  What am I missing here...

2.301ms ? ;-))

Oooh look, (0.8138 * 64) * 256 = guess what

alan smith wrote:
> Sort of a basic question that I thought I had understood.....you would
> think by now....the obvious would be obvious...
>
> Have a crystal, 4.1952MHz, so it has a cycle time of 0.95347uS.  I am
> using TMR0 to generate an interupt, with a prescaler set for TMR0 (not
> the watchdog) of 1:64.
>
> OK, so by calculations, that should be every 64 tics or 61.022uS, TMR0
> is clocked.  Using the rollover for the interupt it should then be
> 15.621mS for each interupt cycle.  I am measuring 13.32mS.  What am I
> missing here...

Your calculations are correct assuming your code does what you say it does.
So therefore your hardware or code is not doing what you say it does.  How
are you measuring the interrupt period?  Are you doing anything to TMR0 in
the interrupt?  Did you disable the watchdog?  What PIC are you using?  What
voltage?

******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products
Jinx might be right....I am going to have to check with the client because...of course...he told me that frequency, the crystals arent marked and the schematic doesn't show a value....grrr..

And to answer these questions.. using a F877@5V, doing nothing but resetting the interupt for TMR0, watchdog is disabled and using a scope to watch a flag that toggles an output pin everytime the interupt occurs.

Thinking Jinx has the right answer....I always label crystals on a schematic...wish he would.  The whole purpose is to generate a one second interupt.  Correct me if I am wrong, but TMR0 will continue to run, as long as you don't touch the TMR0 registers, so renabling the interupt sometime later, but prior to when it should occur, has no effect on the occurance of the interupt.

Thus, by calculations.....IF its a 4.9152 xtal, 64 prescale, 256 rollover, and counting it for 75 cycles, that SHOULD result in a 1 second interupt.

>
> OK, so by calculations, that should be every 64 tics or 61.022uS, TMR0
> is clocked. Using the rollover for the interupt it should then be
> 15.621mS for each interupt cycle. I am measuring 13.32mS. What am I
> missing here...

Your calculations are correct assuming your code does what you say it does.
So therefore your hardware or code is not doing what you say it does. How
are you measuring the interrupt period? Are you doing anything to TMR0 in
the interrupt? Did you disable the watchdog? What PIC are you using? What
voltage?

******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014. #1 PIC
consultant in 2004 program year. http://www.embedinc.com/products
alan smith wrote:
> Thinking Jinx has the right answer....

Yes, I think there's a good chance of that.

> Correct me if I am wrong, but TMR0 will continue to
> run, as long as you don't touch the TMR0 registers,

Yup, it just keeps on ticking.

******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...