Hi Russ,
Have you considered using timer derived periodic interrupts and performing just one PWM "step" per interrupt? Perhaps spreading out 256 "steps" across the 8.333-msec period (8333-usecs/256 = 32.55-usec interrupts)?
Here's another method like Darrel's which would work well if you group the outputs consecutively (B7..B3 or B4..B0 for example). Updating the port from a 'shadow' register allows precise bit update timing (multiple bits with same duty cycle value will update at exactly the same time).
Regards, Mike
Code:; ; 1/256th step, 18 cycles (isochronous), active high output ; on duty cycle match until end-of-period ; clrf shadow ; clear 'shadow' |B0 movf led+4,W ; led[4] duty cycle, 0..255 |B0 subwf dcy,W ; C = led[4] >= dcy |B0 rlf shadow,F ; |B0 movf led+3,W ; led[3] duty cycle, 0..255 |B0 subwf dcy,W ; C = led[3] >= dcy |B0 rlf shadow,F ; |B0 movf led+2,W ; led[2] duty cycle, 0..255 |B0 subwf dcy,W ; C = led[2] >= dcy |B0 rlf shadow,F ; |B0 movf led+1,W ; led[1] duty cycle, 0..255 |B0 subwf dcy,W ; C = led[1] >= dcy |B0 rrf shadow,F ; |B0 movf led+0,W ; led[0] duty cycle, 0..255 |B0 subwf dcy,W ; C = led[0] >= dcy |B0 rlf shadow,W ; W = led 'step' output |B0 movwf PORTB ; update LEDs |B0 incf dcy,F ; bump duty cycle counter |B0 ;




Bookmarks