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.

Measuring Pulse width

Status
Not open for further replies.

autaorte

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

Any guy have a example?
 
Last edited:
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.
 
I have a few examples measuring 1 to 2ms pulses on my site. See 'pulse width', 'port mirror', 'lvc1' and 'lvc2' here: **broken link removed**
Regards, David.
 
The hardware will do it for you. Read the section in the data sheet on the CCP module.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top