• 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.

Just one second!

Not open for further replies.


New Member
Hello all! I need your neurons :twisted:

I'm working with a PIC16F629, writing a program in its assembly:


I want to make a passive wait of one second (what I want to say with passive is that I want the timer interrupts me when finish counting that single second, I don't want to be checking once and again till the second is past, ok?). So, here is what I've got:

Internal RC clock of 4MHz
TMR0 [8 bits, prescaled 1:256]
TMR1 [16 bits, prescaled 1:8]

I don't need an exact second (I mean, 1.1 second is ok too)

Now, pleeease. Be kind and suggest me some ideas about how to do it. I thought about chaining both timers. The key is I've never worked with any 16 bit timer and I'm quite confused about how to make it work together the other timer. :?

Thanks in advance!


Active Member
What about the links I had PM'ed you? Didn't they help you in any way?


New Member
No, thanks, kindalgp. But in the end, the way they think the timing in those tutorials results unuseful for my needs.

I think I'll change the way I'm doing things or I'll never end this. Thanks anyway.


New Member
How about counting down your own counter (on or two bytes) with each clock interrupt in the ISR ? Then if you reach zero, deactivate the timer, set a flag for the rest of your program, preload again for one second and start when needed again.


New Member
I think I understand you: You're suggesting me to make myself another
timer, isn't it? But, can you explain me this you wrote in another way,please?

"...with each clock interrupt in the ISR?"

Thanks for your reply :D


New Member
Hi timing problems like this are realy quite easy, the first thing to remeber is that the PIC has an instruction cycle of 1MHz (4 / 1)

0.000001s per instruction, a 8bit timer with 256 prescaler would have an interval of 0.000001 * 256 * 256

so that is now 0.065536second interval

a simple way of getting somthign like a second, would be to stack a file register with 15 and at the top of your ISR (Interupt Service Routine, where the TM0 int will goto)
have something like
DECFSZ    0x20 ; some file reg
MOVLW     d'15'
MOVWF     0x20 ;
; your 0.98second interval here

Hope that helps!


New Member
Darn phpBB messed up with a nice error about a missing email template :?

bit strange as i hand't asked for a notify me when a reply is posted!
Not open for further replies.

Latest threads

EE World Online Articles