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

Need a program in Assembly that reads PWM

Not open for further replies.


New Member

I am doing a project that requires me to read a PWM signal generated by an Electronic Compass.

When the PIC16F877 reads the PWM signal from the compass it has to determine how long the PWM signal is Positive for the Duty Cycle.

I need the code in Assembly. I am not lazy or anything and I am willing to work with anyone who wants to help me with this.

The compass by the way is the Devantech CMPS03. And i am trying my best to avoid using the I2C and MSSP. This is why I want to be able to write a routine to read the PWM positive time for the Duty Cycle.

So any ideas on where to begin?

Yours Respectfully
Avin Sinanan


New Member
Hi as i mentioned in an previous post where someone had to effectivly time the lenght of a low the easyest way is to use a TMRx register.

Set it to a incriment that will give u a suiteble level of acuracy, set an interupt for that pin, bit test on that pin, if its low, disable increment, you have ur value in the TMR register, if its high, clear it, and allow increment.
Not open for further replies.

Latest threads

EE World Online Articles