From Teensyduino 1.19, file: pins_teensy.c
I believe the 'max' value for analogWrite is wrong. I believe it should be
At least this works better for me.
Jeff
Code:
void analogWrite(uint8_t pin, int val) {
uint32_t cval, max;
#if defined(__MK20DX256__)
if (pin == A14) {
uint8_t res = analog_write_res;
if (res < 12) {
val <<= 12 - res;
} else if (res > 12) {
val >>= res - 12;
}
analogWriteDAC0(val);
return;
}
#endif
max = 1 << analog_write_res;
if (val <= 0) {
digitalWrite(pin, LOW);
pinMode(pin, OUTPUT); // TODO: implement OUTPUT_LOW
return;
} else if (val >= max) {
digitalWrite(pin, HIGH);
pinMode(pin, OUTPUT); // TODO: implement OUTPUT_HIGH
return;
}
I believe the 'max' value for analogWrite is wrong. I believe it should be
Code:
max = (1 << analog_write_res)-1;
Jeff