Ok, just to be on the same page here...
When you say 'PWM' code, what do you mean exactly?
Something tells me that you're using the 'PWM' command and not the hardware, or even an interrupt based PWM method...