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. Sure. Whatever... What I find incredulous is that many people are stating very obvious facts but the original poster is having trouble grokking it. What he should've of said is, " I saw this routine for PWM'ing 8 I/O pins and since I'm using the 18F452 I figured out how to save 9-bytes of RAM. For example, you can replace the DECFSZ with a CPFSEQ in the pwm_update section and write: pwm_update: MOVF rising_edge,W CLRF temp CPFSEQ pwm0,F ;If the first pwm has not reached the BSF temp,0 ;end then don't turn it off. ; CPFSEQ pwm1,F ;Same for the second one BSF temp,1 ; ; CPFSEQ pwm2,F ; BSF temp,2 ; ; .... MOVF temp,W ANDWF PWM_LATCH RETURN The 8-bytes for the counters in the old routine are no longer needed. The 9'th byte saved is 'pwm_state'. Now we can use I/O port's latch." But we didn't see that. Scott -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist