Good Day,
If anyone has code examples in Picbasic Pro using Timer1 Module for Pic16F876 & Pic16F877 and using a 4Mhz clock. That would be great. I basically need a 0.5 second timer so I can execute another function in the code.
Thank You
Brutis
Good Day,
If anyone has code examples in Picbasic Pro using Timer1 Module for Pic16F876 & Pic16F877 and using a 4Mhz clock. That would be great. I basically need a 0.5 second timer so I can execute another function in the code.
Thank You
Brutis
Brutis,
Had you visioned using PBP interrupts, "Instant Interrupts," ASM interrupts, or polling for TMR1 overflows? This might help people help you.
Paul Borgmeier
Salt Lake City, Utah
USA
Hi Paul,
Thanks for the reply, I'm using the timer1 module in PBP. But I cannot seem to get a 1 second timer from this. The most I can get is 5.24 ms before the interrupt flag gets set. Do you know how I can get a 1 second timer form TMR1?
Regards,
Brutis
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?
Bookmarks