Bug of AnalogWrite(pin,val)

code of function AnalogWrite(pin,val) in wiring_analog.c:

pinMode(pin, OUTPUT);
if (val == 0)
{
digitalWrite(pin, LOW);
}
else if (val == 255) // not correct for 9-bit and 10-bit mode of TIMER1 !
{
digitalWrite(pin, HIGH);
}
else
{
...
...
}

The best place to report such things is here...

There is a similar open issue that, if implemented, would very likely help...

Since there's already an issue report I'd recommend submitting a pull request instead of a duplicate issue report that will just get closed. I don't see that anyone has done this yet. The issue is almost 2 year old so obviously it hasn't been considered a high priority but finished code might have a better response. It shouldn't take much time to do.

I wonder if there's more overhead to setting the pulse to full width rather than doing the digitalWrite? That's the only reason I could see for doing it the way they did.