On Tue, 11 May 1999, Seyler Jean-Yves wrote: > I'm looking for ideas for a specific project : > > I have to check for serial inputs while out-puting one or more PWM depending > on the input(s). > > In fact, my first application should be an attempt to read 1 RC pulsed > command, ie : > > 1) Measure the "n"st positive pulse among 7 overall pulses ; synchro being > made by a 1st larger pulse and length of the usefull pulse varying between 1 > and 2 ms ; overall time = 10 to 20 ms > > 2) While outputing a PWM at 10 to 100 Hz, from #0 to #100% duty cycle > > 3) That's all ! > > 4) I've thought of an absolute timing that each individual task could check > and determine if their allowed time have passed. That shouldn't be very > accurate but enough for me ? You may wish to check out: http://www.interstice.com/~sdattalo/technical/software/pic/pwm256.txt This an all-software, 256-level pwm routine capable of 0 to 100% duty cycles. Since it doesn't use interrupts, it's suitable for the 12 bit core. Roughly half of the 256 cycles are available for other (isochronous) tasks. The only problem I can see with it is that it may be too fast for your application. For example, with a 20Mhz clock this routine can produce a nearly 20khz pwm'd square wave. I suppose you could slow the pic down a factor of 200 or so, but I don'tsee this as being too practical. Another possibility is to use the 16-bit delay loop that we were discussing just last week. There was one solution that a) created a delay with 3 instruction cycle resolution and 16-bits of dynamic range and b) provided additonal cycles for simultaneously performing other tasks. The number of 'additional cycles' can be varied between 1 to ~240 out of every 256 cycles. In fact, this number could vary depending on the time required for each task. I unfortunately don't have time to expand upon the details (gotta go to the Mchip seminar) - perhaps someone else may? Scott