![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Jeff Stevens Guest
|
F877 Timer 1 overflow |
Posted: Fri Nov 01, 2002 10:51 am |
|
|
I'm trying to use timer1 to measure the period of a signal on RC0. Timer 1 is configured as such:
SETUP_TIMER_1(T1_INTERNAL|T1_DIV_BY_2); // Configure 16 bit timer1
and the oscillator is 4Mhz ( 1µsecond instruction cycle ).
With the divide-by-2 prescale on a 16 bit timer, I'm expecting the timer1 overflow flag (TMR1IF) to be set after 131072 µseconds (65536 µseconds * 2). Instead, I'm finding that it gets set when the count is 32768 ( still 65536 µseconds ). No matter the divide-by value, the flag is set after 65536 µseconds.
Can anyone offer some insight into what might be happening?
Thanks in advance. ~ Jeff
___________________________
This message was ported from CCS's old forum
Original Post ID: 8387 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: F877 Timer 1 overflow |
Posted: Fri Nov 01, 2002 4:33 pm |
|
|
:=I'm trying to use timer1 to measure the period of a signal on RC0. Timer 1 is configured as such:
:=
:=SETUP_TIMER_1(T1_INTERNAL|T1_DIV_BY_2); // Configure 16 bit timer1
:=
:=and the oscillator is 4Mhz ( 1µsecond instruction cycle ).
:=
:=With the divide-by-2 prescale on a 16 bit timer, I'm expecting the timer1 overflow flag (TMR1IF) to be set after 131072 µseconds (65536 µseconds * 2). Instead, I'm finding that it gets set when the count is 32768 ( still 65536 µseconds ). No matter the divide-by value, the flag is set after 65536 µseconds.
:=
--------------------------------------------------
Can you post a short, but complete demo program that demonstrates the problem ? (Please include all pre-processor statements).
The common method for measuring the time between two pulses
is to use the CCP capture mode. I don't think you're doing
it that way, so please give an explanation of what you're
doing, and why, along with your demo program.
___________________________
This message was ported from CCS's old forum
Original Post ID: 8413 |
|
![](templates/subSilver/images/spacer.gif) |
Jeff Stevens Guest
|
Re: F877 Timer 1 overflow |
Posted: Wed Nov 06, 2002 8:57 am |
|
|
:=:=I'm trying to use timer1 to measure the period of a signal on RC0. Timer 1 is configured as such:
:=:=
:=:=SETUP_TIMER_1(T1_INTERNAL|T1_DIV_BY_2); // Configure 16 bit timer1
:=:=
:=:=and the oscillator is 4Mhz ( 1µsecond instruction cycle ).
:=:=
:=:=With the divide-by-2 prescale on a 16 bit timer, I'm expecting the timer1 overflow flag (TMR1IF) to be set after 131072 µseconds (65536 µseconds * 2). Instead, I'm finding that it gets set when the count is 32768 ( still 65536 µseconds ). No matter the divide-by value, the flag is set after 65536 µseconds.
:=:=
:=--------------------------------------------------
:=
:=Can you post a short, but complete demo program that demonstrates the problem ? (Please include all pre-processor statements).
:=
:=The common method for measuring the time between two pulses
:=is to use the CCP capture mode. I don't think you're doing
:=it that way, so please give an explanation of what you're
:=doing, and why, along with your demo program.
Okay, my bad. The problem was not the timer, but the device that produces the pulses. It wouldn't configure itself if the pulse period was a µsecond too long.
And thanks for reminding me of CCP capture mode. I'm going to use it. ~ Odd how one sometimes can't see the forest for the trees.
___________________________
This message was ported from CCS's old forum
Original Post ID: 8602 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|