cancel
Showing results for 
Search instead for 
Did you mean: 

DutyCycle von 5 PWM Inputs

am2
Associate
Posted on August 12, 2010 at 09:08

DutyCycle von 5 PWM Inputs

1 REPLY 1
picguy2
Associate II
Posted on May 17, 2011 at 14:01

It’s clear that English is not your favorite language.  I’m also guessing that you are fairly new to embedded microcontrollers.  Neither is a problem except that I had to guess what you need.

Simple almost useless answer: ports are memory mapped.  Read just like reading RAM.  It would also be a good idea to Read The Fine Manual - its only a little over 1000 pages.  

I can only guess at your “I must detection the [duty cycle] of 5 PWMs.�?  For the rest of this note I will assume that you have 5 PWM inputs with unrelated duty cycles.

If the period of the fastest PWM is around 100 Hz or less you can (for each input) sample in a 1KHz ISR recording ISR counts and GPIO high levels.  Divide to get duty cycle.  10 seconds should be more than enough.  (With a 72 MHz CPU clock a 1 kHz event happens every 72,000 clocks.  This is far from serious overhead.)

In the 500 Hz and above range a different approach works better.  Use external hardware to route your processor clock into a timer input pin when your duty-cycle-to-be-measured is high.  Read counter(s) before they overflow.  Every 0.5 seconds should be enough..