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.

A question on counting.

Status
Not open for further replies.

gibbon_82

New Member
I have to program the 16f84 to count input pulses. depending on the amount of pulses depends on what subroutine has to be executed. Can i use the watchdog timer to count input pluses from an input pin while executing a subroutine? Or is there another way to do this?

cheers

Craig
 
ehh.. that is not the use of watchdog timer.
Watchdog timer is to reset the microcontroller when the operation is stuck
 
Timer 0 can be configured to count pulses on RA4. Check the datasheet, its all in there.
 
im using ra4 for my timer. im having to count the time in a subroutine at the same time as counting input pulses for an input pin. if i used this pin to increment a count somewhere else in memory, this will not carry on counting when executing a subroutine will it?
 
If you use timer0 as timer somewhere else, it cannot be used as pulse counter at the same time.

How fast are the pulses you're counting? How wide are the pulse widths? If they are not too fast, you can poll the RA4 pin as an ordinary I/O pin.
 
Use the interrupt on RB0 to set and stop counter. After that, you can re-compute the real length of your pulse, because it need 3 cycles to come to the interrupts, and 1 cycles to get back. But you know exactly when it interrupts.

If you count a variable, it can happen that the pulse is falling down as you are counting, you don't know exactly when it is. But with interrupt, you know it.
 
Status
Not open for further replies.

Latest threads

Back
Top