mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-19 13:54:23 +01:00
fixed digitalWrite on timer 4 pins (D6 and D13)
This commit is contained in:
parent
4b358f21d9
commit
6a44faedbb
@ -281,11 +281,15 @@ void init()
|
||||
|
||||
#if defined(TCCR4A) && defined(TCCR4B) && defined(TCCR4D) /* beginning of timer4 block for 32U4 and similar */
|
||||
sbi(TCCR4A, COM4A1); // clear channel A on output compare match
|
||||
cbi(TCCR4A, COM4A0);
|
||||
sbi(TCCR4C, COM4D1); // clear channel D on output compare match
|
||||
cbi(TCCR4C, COM4D0);
|
||||
sbi(TCCR4B, CS42); // set timer4 prescale factor to 64
|
||||
sbi(TCCR4B, CS41);
|
||||
sbi(TCCR4B, CS40);
|
||||
sbi(TCCR4D, WGM40); // put timer 4 in phase- and frequency-correct PWM mode
|
||||
sbi(TCCR4A, PWM4A); // enable PWM mode for comparator OCR4A
|
||||
sbi(TCCR4C, PWM4D); // enable PWM mode for comparator OCR4D
|
||||
#else /* beginning of timer4 block for ATMEGA1280 and ATMEGA2560 */
|
||||
#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
|
||||
sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64
|
||||
|
@ -207,11 +207,7 @@ void analogWrite(uint8_t pin, int val)
|
||||
#if defined(TCCR4A)
|
||||
case TIMER4A:
|
||||
//connect pwm to pin on timer 4, channel A
|
||||
#if defined(PWM4A) /* ATMEGA32U4 and related */
|
||||
sbi(TCCR4A, PWM4A);
|
||||
#elif defined(COM4A1) /* ATMEGA1280/2560 and related */
|
||||
sbi(TCCR4A, COM4A1);
|
||||
#endif
|
||||
OCR4A = val; // set pwm duty
|
||||
break;
|
||||
#endif
|
||||
@ -235,9 +231,7 @@ void analogWrite(uint8_t pin, int val)
|
||||
#if defined(TCCR4C)
|
||||
case TIMER4D:
|
||||
// connect pwm to pin on timer 4, channel D
|
||||
#if defined(PWM4D) /* ATMEGA32U4 and related */
|
||||
sbi(TCCR4C, PWM4D);
|
||||
#endif
|
||||
sbi(TCCR4C, COM4D1);
|
||||
OCR4D = val; // set pwm duty
|
||||
break;
|
||||
#endif
|
||||
|
@ -105,29 +105,17 @@ static void turnOffPWM(uint8_t timer)
|
||||
case TIMER3C: cbi(TCCR3A, COM3C1); break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR4A)
|
||||
case TIMER4A:
|
||||
#if defined(PWM4A)
|
||||
cbi(TCCR4A, PWM4A);
|
||||
#elif defined(COM4A1)
|
||||
cbi(TCCR4A, COM4A1);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR4A) && defined(COM4A1)
|
||||
case TIMER4A: cbi(TCCR4A, COM4A1); break;
|
||||
#endif
|
||||
#if defined(TCCR4A) && defined(COM4B1)
|
||||
case TIMER4B: cbi(TCCR4A, COM4B1); break;
|
||||
#endif
|
||||
#if defined(TCCR4A) && defined(COM4C1)
|
||||
case TIMER4C: cbi(TCCR4A, COM4C1); break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR4C)
|
||||
case TIMER4D:
|
||||
#if defined(PWM4D)
|
||||
cbi(TCCR4C, PWM4D);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#if defined(TCCR4C) && defined(COM4D1)
|
||||
case TIMER4D: cbi(TCCR4C, COM4D1); break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR5A)
|
||||
|
Loading…
x
Reference in New Issue
Block a user