View previous topic :: View next topic |
Author |
Message |
bwhiten
Joined: 26 Nov 2003 Posts: 151 Location: Grayson, GA
|
"Stop" Timers question |
Posted: Mon Feb 04, 2008 1:26 pm |
|
|
I am looking at a Microchip code sample that mentions the next step in an ISR as "StopTimers();". No further description of the function is given of course, so my question is, would disabling a timer be the same as stopping one and can the last timer value still be read after disabling? I'm using a 16F887 PIC. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 04, 2008 1:50 pm |
|
|
Post the appnote number and post a link to it. |
|
|
bwhiten
Joined: 26 Nov 2003 Posts: 151 Location: Grayson, GA
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 04, 2008 2:37 pm |
|
|
The short answer is:
You can stop Timer1 by setting the TMR1ON bit = 0 in the T1CON register.
Example:
Code: |
#byte T1CON = 0x10
#bit TMR1ON = T1CON.0
void main()
{
TMR1ON = 0; // Turn Timer1 off
TMR1ON = 1; // Turn Timer1 On
while(1);
} |
Timer0 doesn't have an on/off bit.
To really solve your problem I'd have to read the whole appnote, and
I don't want to do that right now. |
|
|
bwhiten
Joined: 26 Nov 2003 Posts: 151 Location: Grayson, GA
|
|
Posted: Mon Feb 04, 2008 9:11 pm |
|
|
Really not a problem, just clarification. I did test and disabling does not clear the count so it accomplishes my purpose. I like using your bit method better because it is clearer to me what I am accomplishing, rather than the T1_DISABLE control for SETUP_TIMER_1() function. |
|
|
|