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 support@ccsinfo.com

Timer1 help - 500ms ISR for Timer1 on 16F688

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







Timer1 help - 500ms ISR for Timer1 on 16F688
PostPosted: Fri Dec 05, 2008 4:55 pm     Reply with quote

Hello,
I've never used Timer1 before, I always use Timer2 for my LEDs, etc. This time I'm using a 16F688 and it doesn't support Timer2.

I'm using the internal clock @ 8mhz.

I need to check a pin every 500ms.

8,000,000/4 = 2,000,000 -> clock ticks
2,000,000/8 = 250,000 ticks per ISR

250,000 ticks = 5ms (1000/250,000) right?

So that means I've got to have a counter that counts 100 ISRs. Any better way to do it?
kd5uzz_
Guest







PostPosted: Fri Dec 05, 2008 4:57 pm     Reply with quote

Oh yeah..
Code:
#include <16F688.h>
#fuses NOWDT,NOPROTECT,NOBROWNOUT, NOMCLR, INTRC
#use delay(clock=8000000)
#use rs232(stream=Jech_Bus, baud=19200, xmit=PIN_C4, rcv=PIN_C5)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 05, 2008 5:35 pm     Reply with quote

It's a 16-bit counter. It can count from 0 to 65535. If you use a
pre-scaler of 8, the timer clock is 250,000 Hz. It takes that many clocks
to count up 1 second. To count for a 1/2 second, it takes half that many
clocks: 125,000. The timer can do that in two interrupts, at 62,500
clocks each.
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