Hey, I know this is probably a bad idea, because it isn't always perfect at timing, but I run my pwm routine inside my delay routine - I padded it out with nops, to get it to the right length, and because my program spends nearly all it's time in delays, there is only a few instructions between the delays, meaning it's almost continuously updating the pwm. On 5/27/05, Spehro Pefhany wrote: > At 06:49 AM 5/27/2005 -0700, you wrote: > > > > A 20MHz clocked PIC would update the PWM counters every 50 cycles > >* 0.2uS/cycle = 25 uS. The PWM period is 256 * 25uS ~ 6.4mS which > >translates into a PWM frequency of 1/6.4mS = 156Hz. Triggering the LED > >refresh at this frequency should be fast enough to remove perceivable > >flicker. > > Scott, 156Hz is nowhere near fast enough in most cases. You have to multiply > the minimum "flicker" rate times the number of digits being sequentially muxed > and apply a healthy "quality appearance" multiplier if you don't want the > display > to "break up" visually when it or the user's head moves a bit. 1000Hz is more > like it (or perhaps 500Hz in this case, since he's got only 3 digits). > > This could be still done by the PWM routine, by triggering off of every n'th > update, and making sure that the display routine takes less than the > cycles or so available until you have to return so the next interrupt can > take place on schedule. Probably would have less issues than trying to use > nested interrupts or whatever. There would be a bit more overhead in each > interrupt to decide whether to scan the display this int or not. Of course > there would be more room to play with a 40MHz (or 120MHz) PIC. > > Best regards, > > Spehro Pefhany --"it's the network..." "The Journey is the reward" > speff@interlog.com Info for manufacturers: http://www.trexon.com > Embedded software/hardware/analog Info for designers: http://www.speff.com > ->> Inexpensive test equipment & parts http://search.ebay.com/_W0QQsassZspeff > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- Dave All us base are belong to you. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist