David Euans wrote: > I am trying to use an 18F448 to light a RGB LED such that the > intensities of each LED can be varied independently. This needs to > occur in the background. What is your definition of "background" ? In an ISR ? Anyway, How many "levels" do you need ? Let's say 20 in this example. We will also "blink" each LED at 100Hz (could be a little lower, maybe 70-80 Hz). Set up three counters to hold a value between 0 and 20 (or 19). This is the "duty cycle" for each LED. Set up one main counter to keep count of the LED "period". This will always count 1-20 (or 0-19). Set up one timer to give a 100*20 Hz interrupt (or 70-80*20 depending on what period you select). On each interrupt, inc the "period" counter. If period > 20 (or 19) then reset period to 1 (or 0) endif For each LED If LED "duty cycle" > "period" then LED = "ON" else LED = "OFF" endif endfor A "duty cycle" = 0 will keep the LED OFF all the time. A "duty cycle" > 20 (or >19) will kep the LED ON all the time. The ducy cycle values are inc/dec on input from the rotary encoder. The ultimate use is to have the LED change color in response to changes in a digital rotary encoder. Using PIC Basic Pro, I was trying to use the HPWM command to send differing duty cycle PWM outputs to channels 1, 2 and 3 of the PIC. This has not worked for me and may be due to not properly initializing the PWM ECCP1CON or other registers. However, looking at the data sheet, I get the impression that only two pins as most can be modulated at one time. (Perhaps I'm reading it wrong). At any rate, has anyone been successful in having this chip provide more than two PWM outputs running in the background. Thanks in advance. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics