Exact match. Not showing close matches.
**
PICList
Thread
**

**
'[PIC]: Setting up Timer 2 (Sorry 1)'
**

2001\04\23@093240
by
Graham North

Thanks

Graham

Hi,

Could someone please give me some help on hoe to work out TMR1H and TMR1L so

that I get an interupt on rollover every 2.275ms on a 16F877.

Does someone have a formula that you can 'plug' values into.

Thanks

Graham North

_________________________________________________________________________

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--

http://www.piclist.com hint: The list server can filter out subtopics

(like ads or off topics) for you. See http://www.piclist.com/#topics

_________________________________________________________________________

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--

http://www.piclist.com hint: The list server can filter out subtopics

(like ads or off topics) for you. See http://www.piclist.com/#topics

2001\04\23@094723 by Drew Vassallo

>so

>that I get an interupt on rollover every 2.275ms on a 16F877.

>

>Does someone have a formula that you can 'plug' values into.

I don't have a formula, but if you break it down into time per instruction,

you can figure out how many cycles you need to roll over. It is helpful to

do this anyways instead of using a formula, because the old "plug-and-chug"

method rarely leads to an *understanding* of what you're really trying to

do.

At 4MHz, each instruction cycle is 1us. TMR1L will overflow in 256us.

TMR1H will overflow in 256*256us = 65.535ms, which will be enough for your

purpose. (If you're using 20MHz, you can use the same theory, except that

TMR1L will overflow in 51.2us and TMR1H will overflow in 13.1ms. Etc. for

any other frequency.)

2.275ms/256us = 8.8875..... So, you need a TMR1H of 8 and some extra value

(.8875.....*256) for TMR1L.

8*256us = 2.048ms 2.275ms-2.048ms = 227us. So, you need a TMR1L of 227us

in addition to your 8 for TMR1H.

Preload TMR1L with 256-227= 29 (decimal) and preload TMR1H with 256-8= 248

decimal to begin your timer. Then just check for TMR1H. When TMR1H rolls

over to 0x00, then 2.275ms has passed since you set your TMR1 values.

--Andrew

_________________________________________________________________

Get your FREE download of MSN Explorer at http://explorer.msn.com

--

http://www.piclist.com hint: The list server can filter out subtopics

(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)

- Last day of these posts

- In 2001
, 2002 only

- Today

- New search...