AnalogWrite Bug or Feature?

Status
Not open for further replies.

luni

Well-known member
I noticed that analogWrite(255) does not generate a solid HIGH signal but generates a PWM with a duty cycle of some 99.6%. (this corresponds to 1-1/255).

Code:
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);

    analogWriteFrequency(3, 5000);
    analogWriteFrequency(4, 5000);

    analogWrite(4, 50);
    analogWrite(3, 255);

Here a screen shot of the output (Teensy 3.1, current Teensyduino):
analogWrite.PNG

Is this expected behavior or is it a bug? At least it might lead to confusion (see: (https://www.arduino.cc/en/Tutorial/PWM). BTW: analogWrite(0) works as expected (generating a solid LOW)
 
Yes, that works (and is even documented on the PJRC homepage...). I was confused since the Arduino doc states that it should be HIGH at 255.
Thanks a lot
 
Status
Not open for further replies.
Back
Top