corrected pwm code for 1KHz