analogWrite, sets pin high at 255

waqaszahid:
analogWrite() function which seems to set the PWM to HIGH whenever you write analogWrite(PWM, 255)

That seems perfectly logical to me.

If it causes you a problem why do you let your code use a higher value than 254?

...R