Jump to content
Sign in to follow this  

16F84A TMR0 1 sec Interrupt

Recommended Posts

Hi all;

anybody knows how can I implement 1 sec delay using TMR0 interrupt? Any example?



Share this post

Link to post
Share on other sites

If you want the delay in seconds:

                     (256 - InitTMR0) * prescaler

Delay =   -----------------------------------------

                              Frequency / 4


Or if you want the value to put in TMR0 to get a determinate DELAY:

InitTMR0 = 256 - ( DELAY * Frequency ) / ( 4* Prescaler)


For example 1 sec delay using a LP crystal 32.768 KHZ


 option_reg  = 00000100b    (prescaler = 32)

 tmr0 = 0

 intcon = 10100000b


When an interrupt occured don't forget to clear tmr0if.




Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...