Have a look at Olympic Timer (search the forum) to give you an idea of how TMR1 could be used to increment variables to count whatever time period you require.
Have a look at Olympic Timer (search the forum) to give you an idea of how TMR1 could be used to increment variables to count whatever time period you require.
Hi Melanie,
Thanks for the link. Did not fully understand all the code. Would you happen to know the simplist way to acheive a 1 second rate using the timer1. I'm using a 0.5 second rate now but I need more time to execute my code. 1 second would be great before the flag gets set. Any idea how to do this.
Thanks
Regards,
Brutis.
Datasheet! *sigh*
Timer1 ticks every 1uS @ 4MHz.
It's 16 bits wide, therefore with a 4MHz clock will time 65.536mS between each Flag.
Using the 1:8 prescaler your maximum time is 8*65.536mS=524.288mS
So unless Microchip has shoved hardware into your PIC that mine doesn't have, the answer is NO, Timer1 will NEVER tick 1 second @ 4MHz.
You can always use a Bit Variable as a Flag... If BitFlag=0 and Timer1Flag then half a second has elapsed - so Set the BitFlag. If BitFlag=1 and Timer1Flag then one second has elapsed, so reset the BitFlag and start over for a new Second.
Homework: What has Timer2 got that Timer1 doesn't have?
Timer2 has a prescaler and a postscaler. Am I right Melanie, am I right??
Yup, you're right... Homework Part Deux: Which now means what's the maximum Time you can let Timer2 run for at 4MHz with all the prescalers and postscalers enabled?
Boy - you're putting me through the mill. I come up with 16.777 seconds. Am I right... am I right??
Close, but no cigar...(we're talking about Timer2 in a PIC16F876/877)...
Bookmarks