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.

Decoding a PWM signal

Status
Not open for further replies.

gaspode42

Member
Hi

I am working on a project which requires the decoding of a PWM signal. I believe this can be achieved by looking for rising or falling edges (using CCP & a timer).

Am I correct in thinking that once the timer is running I have to manually poll the port to detect a state change and then stop the timer?

If anybody can advise or point me at a good tutorial/technote about this I would be most gratefull.

Chears
 
I believe this can be achieved by looking for rising or falling edges (using CCP & a timer).
Yup. It's fairly easy to do.

Am I correct in thinking that once the timer is running I have to manually poll the port to detect a state change and then stop the timer?
Well... You could do that, but that's a very lame way to do it. Instead, use the CCP1 capture register & interrupt. Makes it very easy to do, and accurate. Polling won't be as accurate, and it takes all your MCU's time to do it. With interrupts you can get other things done while capturing your pulse widths.

If anybody can advise or point me at a good tutorial/technote about this I would be most grateful.
Have a look at **broken link removed** and **broken link removed** on my site. Very simple code that shows how to do exactly what you want to do for PIC 12F683 and 18F1320. Written in BoostC.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top