Hi again guys, I am currently working on a software PWM. I got it to work fine with 1 pin, and now I'm extending it to 8 pins. I am using a regularly incremented PWMtimer, and 8 GPRs, called PWMlevel 1 to 8. Inside the PWMupdate function, I use a loop, and indirect addressing to access each pwmlevel, and check if it's higher or lower than pwmtimer, to decide when to turn it off. Therefore, the pwmlevel decides on average, how high the pin is. All the loop code works just fine, in checking each pwmlevel, but then I come to set or clear each bit on portb. I need a way to set or clear a particular bit, depending on a variable, i.e. if the variable is 4, I want to set/clear bit 4. I cannot think of a way to access a bit, specified on the fly. The only method I could think of is to use the variable as a loop counter, and in each loop, bit shift d'1' to the left, and then move this to portb. Unfortunately, this would disturb all the other bits in porta. Thanks in advance. -- 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