[PIC] Hi! Help me using timers in PIC 16F877A

Status
Not open for further replies.

Prashanth SA

Newbie level 1
Joined
Apr 10, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
9
I'm new to PIC micro controller and I want to know how to set timer TMR0 of PIC16F877A as counter for 1 hour in a while loop so that i can perform a specified function for that one hour...i.e I have drive a triac for one hour with a specific delay and the next hour with other delay ............. it would be helpful if any one can post a sample code in mikroC
please help me............
thanks in advance ...................
 

Initialize timer0 and make it interrupt ebery 500 ms then write ISR code and increment a counter on every timer0 interrupt. For one sec there will be 2 timer0 interrupts. So, calculate counter test value needed for hour (60 minutes = 3600 seconds). A if condition sets a flag when counter reaches this much value and the flag can be used in while(1) to do the required operation.

https://www.best-microcontroller-projects.com/article-pic-timer-calculation.html
 

TMR0 is only 8-bits wide so unless you are using a slow master clock it might be difficult to make it generate an interrupt every half second. If you can, use TMR1 instead which is 16 bits wide so can generate delays up to 256 times longer than TMR0.

Brian.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…