CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

"Stop" Timers question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

"Stop" Timers question
PostPosted: Mon Feb 04, 2008 1:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 04, 2008 1:50 pm     Reply with quote

Post the appnote number and post a link to it.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

App Note AN1104
PostPosted: Mon Feb 04, 2008 2:01 pm     Reply with quote

http://ww1.microchip.com/downloads/en/AppNotes/01104A.pdf

Examples 1 and 3.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 04, 2008 2:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 04, 2008 9:11 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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