On a sunny day (Tue, 1 Jun 2010 15:47:35 +0000 (UTC)) it happened Cydrome Leader wrote in :
under the GPL.
of RGB LED strings.
The reference values are in the 8 bit registers red, green, and blue. The registers red_sum, green_sum, and blue_sum are also 8 bits wide. The reference value is added each loop iteration to the sum value, when overflow a carry results, and the LED is set 'on', if no carry the LED is set 'off'. If you add a little bit (say low value for red) then it takes longer (more iterations) for the sum to overflow. If you add a lot, then the sum overflows more often, you get more ON states per number of loop iterations, so per time.
This is executed in main in a loop:
; do the PWM thing do_rgb: do_red: bcf STATUS, C movfw red addwf red_sum btfsc STATUS, C goto red_on ; red off bcf RED_PWM goto do_green red_on: bsf RED_PWM nop
do_green: bcf STATUS, C movfw green addwf green_sum btfsc STATUS, C goto green_on ; green off bcf GREEN_PWM goto do_blue green_on: bsf GREEN_PWM nop
do_blue: bcf STATUS, C movfw blue addwf blue_sum btfsc STATUS, C goto blue_on ; blue off bcf BLUE_PWM goto col_done blue_on: bsf BLUE_PWM nop col_done: ; do other things
Is it correct to say you're really changing the duty cycle of on and off, but not at fixed rates as in true PWM, and this rate is based off how fast you overflow?
[I can't read assembler so I'm truncating the code]
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.