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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.