From 016ad2398a5496364b0392e94c3269670700d015 Mon Sep 17 00:00:00 2001 From: Stephen Olesen Date: Wed, 1 Jul 2015 15:01:55 -0600 Subject: [PATCH] Added a define to use pin 3 for PWM, instead of the new default pin 11. --- DDS.cpp | 6 ++++++ DDS.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/DDS.cpp b/DDS.cpp index da39970..27129aa 100644 --- a/DDS.cpp +++ b/DDS.cpp @@ -10,8 +10,14 @@ void DDS::start() { // First, the timer for the PWM output // Setup the timer to use OC2B (pin 3) in fast PWM mode with a configurable top // Run it without the prescaler +#ifdef DDS_PWM_PIN_3 TCCR2A = (TCCR2A | _BV(COM2B1)) & ~(_BV(COM2B0) | _BV(COM2A1) | _BV(COM2A0)) | _BV(WGM21) | _BV(WGM20); +#else + // Alternatively, use pin 11 + TCCR2A = (TCCR2A | _BV(COM2A1)) & ~(_BV(COM2A0) | _BV(COM2B1) | _BV(COM2B0)) | + _BV(WGM21) | _BV(WGM20); +#endif TCCR2B = (TCCR2B & ~(_BV(CS22) | _BV(CS21))) | _BV(CS20) | _BV(WGM22); // Set the top limit, which will be our duty cycle accuracy. diff --git a/DDS.h b/DDS.h index a1d54f5..edab90a 100644 --- a/DDS.h +++ b/DDS.h @@ -3,6 +3,11 @@ #include +// Use pin 3 for PWM? If not defined, use pin 11 +// #define DDS_PWM_PIN_3 + +// Use a short (16 bit) accumulator. Phase accuracy is reduced, but speed +// is increased, along with a reduction in memory use. #define SHORT_ACCUMULATOR #ifdef SHORT_ACCUMULATOR