| ??? 01/07/04 07:11 Read: times |
#62058 - RE: PWM assembly code for 5 PWM signals Responding to: ???'s previous message |
Well, first, why limit yourself to the classic 8051, given e.g. variants with 6 PCA channels that can easily be set to do PWM? Or, is this a homework assignment? Regardless, you'll find the "gimme code" schtick to have gotten kinda old hereabouts...
Anyhow, the basic software approach is to first determine the atom of granularity of your interval timing, e.g. 1 ms, 10 ms, whatever. Set your hardware timer to auto-rollover at this rate. From its rollover, maintain 5 sets of software timers, one for each channel. A set would have a timer for the period, one for the "on" duration (or one each for the high & low parts of the cycle), and perhaps a third timer if you need some kind of phase alignment between the channels and/or something else. You can do all this at the base level, via polling for rollover. If, however, your requirements are small with respect to your base level processing load, do it in the timer ISR instead. Now, was that so hard? David |



