diff options
author | Zach Eveland <zeveland@blacklabel-development.com> | 2012-04-19 15:52:16 -0400 |
---|---|---|
committer | Zach Eveland <zeveland@blacklabel-development.com> | 2012-04-19 15:52:16 -0400 |
commit | 6ae1a1723561266767ed1ba39ae61c35ea263162 (patch) | |
tree | 1a3789e14a2bc246fb0d57b6d0b473c5951ffc0b /cores/arduino/wiring_analog.c | |
parent | 56ddc4637de1b8b0e21840519ed0b94966395ff5 (diff) |
bugfix for configuring PWM on D6 and D13 too early. (thanks to Limor Fried)
was starting PWM on these pins too soon - in init() instead of when analogWrite() was called. as a result doing output on port registers directly failed.
Diffstat (limited to 'cores/arduino/wiring_analog.c')
-rw-r--r-- | cores/arduino/wiring_analog.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index c06cad4..0e9881f 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -210,6 +210,9 @@ void analogWrite(uint8_t pin, int val) case TIMER4A: //connect pwm to pin on timer 4, channel A sbi(TCCR4A, COM4A1); + #if defined(COM4A0) // only used on 32U4 + cbi(TCCR4A, COM4A0); + #endif OCR4A = val; // set pwm duty break; #endif @@ -234,6 +237,9 @@ void analogWrite(uint8_t pin, int val) case TIMER4D: // connect pwm to pin on timer 4, channel D sbi(TCCR4C, COM4D1); + #if defined(COM4D0) // only used on 32U4 + cbi(TCCR4C, COM4D0); + #endif OCR4D = val; // set pwm duty break; #endif |