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

Measuring Pulse width

Not open for further replies.


New Member
How i do for measuring Pulse Width in C langue? (Pic 16f628A)

Any guy have a example?
Last edited:


New Member
I've never seriously messed with 16F628A interrupts to measure pulse widths, but for a AVR I'd set an interrupt pin to trigger on both edges, and simply measure how many clock ticks with a timer it stays in each state.

For the 628A it looks like PORTB has an interrupt option on state change. You can probably use one of portb 7:4 to do something similar.

If you're out of resources you may have to use a tight loop to check if the port changed state or not, I'd probably avoid this method unless the pulse widths are quite a bit longer than several instruction cycle time.


Well-Known Member
Most Helpful Member
The hardware will do it for you. Read the section in the data sheet on the CCP module.

Not open for further replies.

EE World Online Articles