Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Timer0

Status
Not open for further replies.

Angy

New Member
Can somene please explain the procedure to initialize timers in 16f micro series.
For example a 4mhz clock with internal freq of 1mhz. And if i need a 10msec timer0 interrupt, what value do i need to put in tmro?
 
Last edited:
Can somene please explain the procedure to initialize timers in 16f micro series.
For example a 4mhz clock with internal freq of 1mhz. And if i need a 10msec timer0 interrupt, what value do i need to put in tmro?

hi,
Can you post the code you have written so far.:)
 
You can't get exactly 10mS out of Timer 0 with a 4Mhz clock

The nearest you would get is I think 9.984mS with 1:64 prescaler and timer loaded with 101.

Useful PIC timer calc application can be found here:
**broken link removed**
 
I dont have a code yet, but i got this
; 1 msec = 1000 pulses,1000/8=125 and it will fit into single byte
; so prescaler will be set AT 8 and assigned to TMR0,and TMR0 will be
; pre loaded with 131; (256-131)*8 =1000.

now assuming the above is right, how do we do a 10 msec interrupt?

10000 pulses is 10msec, if prescaler set at 64
so 10000/64=157 and it will fit into single byte
so prescler will be 64? assigned to tmr0 so preloaded with 99?so (256-99)*64=10,048(approx)
 
Last edited:
I dont have a code yet, but i got this
; 1 msec = 1000 pulses,1000/8=125 and it will fit into single byte
; so prescaler will be set AT 8 and assigned to TMR0,and TMR0 will be
; pre loaded with 131; (256-131)*8 =1000.

now assuming the above is right, how do we do a 10 msec interrupt?

10000 pulses is 10msec, if prescaler set at 64
so 10000/64=157 and it will fit into single byte
so prescler will be 64? assigned to tmr0 so preloaded with 99?so (256-99)*64=10,048(approx)

Are you able to use a 3.2768MHz crystal in place of the 4MHz xtal.?
 
What I do not understand is why Angry does not answer the questions put to him in his own thread. When people make the effort to help you each and every post should be answered. Even if to say I do not know what jitter is. Or better yet take it as a clue and look it up.

3v0
 
i looked it up on wiki, but i couldnt understand. yes its a big leap to jump to dspic processor but i got some time in my hand.If you actually look at the thread posted time there is not much of gap. I was looking at the answers and trying to figure things out.
 
Last edited:
Simply put how accurate do you need the 10ms clock to be? Can you use TMR2 or one of the CCPx modules?

Why can't you change the crystal?
 
Bill,

You do know there are ways to reload Timer 0 to avoid jitter, don't you?

But, your suggestion to use Timer 2 is "right on"...
 
Last edited:
Thanks for suggestions, I will try to use the tmr2.I will also look into the thread Mike
sent. Thanks!
 
I have two displays , I have written routines for them and they seem to be working fine individually.Now for example if I'm trying to display 'DIP' on one display and 2.32 on the other display at the same time for 2seconds and go to other routines, does someone have any idea as to how this can be done? I guess this can be done using timers so I'm posting it here.

I have written routines to display DIP and 2.32 and I can display them individually and they work fine.
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top