Searching \ for '[PIC]:timer problem' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/time.htm?key=time
Search entire site for: 'timer problem'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:timer problem'
2001\02\19@054513 by ajcsa Laszlo AII IV

flavicon
face
Hi!

 I want to count the time beetwen two interrupts; the maximum i have to
count is 2 seconds.
 If i using a 4MHz xtal and a 16 bit timer(16f627-8) witch has only
1:1, 1:2, 1:4, 1:8 prescaler value the result is a 24 bit value.
 How can i increase the value of the prescaler, to have only a 16 bit
value.

 2000000microsec./x to be only 16 bit (x=???) and how

Or anybody has any else good idea how to count that time???

thanx a lot



       /--------------------------------------------------------------\
       | Kajcsa Laszlo   | E-mail : spam_OUTlkajcsaTakeThisOuTspamuttgm.ro                  |
       |                 | Web Page : http://193.226.19.131/~lkajcsa  |
       \--------------------------------------------------------------/

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\02\19@060526 by Vasile Surducan

flavicon
face
You must use tmr1 with external clock source or external (32768 Hz) Xtal
or if you have enough time ( minimum time = ? ) you may increment
a n bit counter every t0if using tmr0.
Prescaler for tmr1 is max 1:8.
Vasile

On Mon, 19 Feb 2001, Kajcsa Laszlo AII IV wrote:

{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\02\19@064613 by brah

flavicon
face
Kajcsa Laszlo AII IV wrote:
>
> Hi!
>
>   I want to count the time beetwen two interrupts; the maximum i have to
> count is 2 seconds.
>   If i using a 4MHz xtal and a 16 bit timer(16f627-8) witch has only
> 1:1, 1:2, 1:4, 1:8 prescaler value the result is a 24 bit value.
>   How can i increase the value of the prescaler, to have only a 16 bit
> value.
>
What I have done in the past is to use a register as a counter.  Every
interrupt, increment the counter, then check the counter to see if it's
up your target number.  If so, reset it to zero and go away and do what
you want to do.  If not, just exit the interrupt, and so on.
I have done this a few times. It's possible to, say, have a sixteen bit
register pair, which efectively multiplies your timer maximum by 16 bits
- by 65000 or whatever it is.
Howard Simpson.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2001\02\19@101045 by Olin Lathrop

face picon face
>   I want to count the time beetwen two interrupts; the maximum i have to
> count is 2 seconds.
>   If i using a 4MHz xtal and a 16 bit timer(16f627-8) witch has only
> 1:1, 1:2, 1:4, 1:8 prescaler value the result is a 24 bit value.
>   How can i increase the value of the prescaler, to have only a 16 bit
> value.

There are lots of ways to do this.  One way is to "unwrap" timer 1 in the
foreground processing loop.  Nothing will be lost as long as you get to it
once every 65000 instructions, and that's at a prescaler of 1:1.  In other
words, you periodically look at timer 1 to find the new amount it got
incremented since the last time you checked.  This time increment is then
added to a software counter that can have as many bits as you need.  Note
that you only really need to look at the high byte of timer 1 when doing
unwrapping.  This is a bit more tricky to think thru, but also more
efficient.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, @spam@olinKILLspamspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\02\20@025535 by Vasile Surducan

flavicon
face
On Mon, 19 Feb 2001, Olin Lathrop wrote:

> There are lots of ways to do this.  One way is to "unwrap" timer 1 in the
> foreground processing loop.  Nothing will be lost as long as you get to it
> once every 65000 instructions, and that's at a prescaler of 1:1.  In other
> words, you periodically look at timer 1 to find the new amount it got
> incremented since the last time you checked.  This time increment is then
> added to a software counter that can have as many bits as you need.  Note
> that you only really need to look at the high byte of timer 1 when doing
> unwrapping.  This is a bit more tricky to think thru, but also more
> efficient.
>
 This is an interesting ideea. But is not more easy to check only the
tmr1if bit, to reset that bit and to increment the software counter every
time after that ? What would be the benefit of reading the tmr1h register
instead ? ( except when is important to know the whole value of TMR1...)
Vasile

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\02\20@101235 by Olin Lathrop

face picon face
>   This is an interesting ideea. But is not more easy to check only the
> tmr1if bit, to reset that bit and to increment the software counter every
> time after that ? What would be the benefit of reading the tmr1h register
> instead ? ( except when is important to know the whole value of TMR1...)

The assumption is that a period start event can happen at any time.  The
easiest way to measure period is with a CCP module that saves the value of
timer 1 at the time of the event.  The software doesn't find out about this
until after the timer 1 snapshot has already been taken.  The timer 1 state
must therefore always be ready for an event.  Checking TMR1IF leaves a gap
between the overflow and its handling.  If the handling is done by
interrupt, then you could make an assumption that very small capture values
with TMR1IF set happened after the wrap but before it was handled.

I like keeping the interrupts free for important time-critical stuff, so
usually handle timer 1 wraps in the foreground loop.  The code is a bit more
tricky, but at this point it's been used a number of times and is well
tested.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spamBeGoneolinspamBeGonespamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


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