Howdy Group,
I'm currently working on a project which requires detecting a PWM train using a microcontroller. The pulse width must be between 800ns and 35us to be considered valid, and the duty cycle must be 1% +/-
2%. Additional requirements are: 1) The uC be in as small a package as possible, something like an 8pin Atmel AVR uC or PIC may do the trick. 2) No external oscillators may be used. I believe this is due to the device being used in an RF application.I was looking at possibly using an ATtiny25 family from Atmel. My thinking was that if I could use the edge triggered interrupt, start a timer to measure the pulse width, if that width is within the valid range, start the timer to measure the LOW time, and go from there, accounting for interrupt latency and clock cycles for executing instructions. If I tune the oscillator to 5 MHz, I could get a timer to increment ever 200ns, and overflow at 51.2us. That seems to be good for timing the pulse width, but won't do the job when it comes to timing the low time.
Using the above approach, I thought it may be possible to change the counters prescaler value to accomodate the time needed to measure the LOW time, or use a second timer with the prescaler value set appropriately, but I have a feeling that I may get myself into some trouble going that route.
Of course, I may be way off on the way I am approaching this, so any advice or direction would be greatly appreciated.
Regards, ~clark