Searching \ for '[PIC]: Set Up TMR0' 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/devices.htm?key=pic
Search entire site for: 'Set Up TMR0'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Set Up TMR0'
2004\01\14@155707 by Lee Wright

flavicon
face
Hi,

How do I configure TMR0 to cycle 256 times.   Then how do I read the value?

Thanks,


Lee.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\01\14@162004 by Jinx

face picon face
> How do I configure TMR0 to cycle 256 times.
> Then how do I read the value?

The questions are too simple and vague, more info
would be helpful so you get what you actually need.
For example, which PIC ? What speed ? Internal or
external clocking ? Are you wanting to delay a certain
time or a number of instruction cycles ?

But basically, clear a RAM counter, turn TMR0 on,
detect when it rolls over from FF to 00, increment
the RAM counter, detect when that rolls over from
FF to 00 and then stop

If you can use a 16-bit timer (like Timer1) then a full count
of that is 256* 256. Which is what you want. Isn't it ?

Reading the TMR0 register is done exactly as it is for
any other register. MOVF TMR0,W

If you start a timer at a value and increment it in multiples
of 256, you'll end up with exactly the same value as you
started with

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\01\14@162421 by Olin Lathrop

face picon face
Lee Wright wrote:
> How do I configure TMR0 to cycle 256 times.

This is a poorly asked question, probably due to bad supposition of how to
solve a particular problem.

However, to answer the question, wait for the T0IF bit to be set 256 times.
You would end up with the same number of elapsed cycles if the prescaler was
1:8 and you waited for timer 0 to cycle 32 times.

> Then how do I read the value?

    dbankif  tmr0        ;set banks for access to TMR0
    movf     tmr0, w     ;get the timer 0 value into W


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

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