From 5489ddccab2e334a290c11bbe0d6c1ab1d0c0272 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 13 Jul 2015 12:56:20 +0200 Subject: [PATCH] heater.c: set up timer 2 only when present. This was found by running the new regression tests. ...and seeing that this is pretty old code, I wonder how Teacup could ever compile for the Teensy2 guys. --- heater.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/heater.c b/heater.c index 9f34db6..072ad45 100644 --- a/heater.c +++ b/heater.c @@ -117,15 +117,17 @@ void heater_init() { // timer 1 is used for stepping - TCCR2A = MASK(WGM21) | MASK(WGM20); - // PWM frequencies in TCCR2B, see page 156 of the ATmega644 reference. - TCCR2B = MASK(CS20); // F_CPU / 256 (about 78(62.5) kHz on a 20(16) MHz chip) - #ifndef FAST_PWM - TCCR2B = MASK(CS20) | MASK(CS21) | MASK(CS22); // F_CPU / 256 / 1024 - #endif - TIMSK2 = 0; - OCR2A = 0; - OCR2B = 0; + #ifdef TCCR2A + TCCR2A = MASK(WGM21) | MASK(WGM20); + // PWM frequencies in TCCR2B, see page 156 of the ATmega644 reference. + TCCR2B = MASK(CS20); // F_CPU / 256 (about 78(62.5) kHz on a 20(16) MHz chip) + #ifndef FAST_PWM + TCCR2B = MASK(CS20) | MASK(CS21) | MASK(CS22); // F_CPU / 256 / 1024 + #endif + TIMSK2 = 0; + OCR2A = 0; + OCR2B = 0; + #endif #ifdef TCCR3A TCCR3A = MASK(WGM30); @@ -180,12 +182,14 @@ void heater_init() { case (uint16_t) &OCR0B: TCCR0A |= MASK(COM0B1); break; + #ifdef TCCR2A case (uint16_t) &OCR2A: TCCR2A |= MASK(COM2A1); break; case (uint16_t) &OCR2B: TCCR2A |= MASK(COM2B1); break; + #endif #ifdef TCCR3A case (uint16_t) &OCR3AL: TCCR3A |= MASK(COM3A1);