From 74a2d1cb904ae085ec10440a9beda7028a94e67c Mon Sep 17 00:00:00 2001 From: nick6x Date: Sun, 30 Jul 2017 12:08:24 -0700 Subject: [PATCH] Update DDS.ino example for DDS library changes --- examples/DDS/DDS.ino | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/DDS/DDS.ino b/examples/DDS/DDS.ino index c738a5b..de6e916 100644 --- a/examples/DDS/DDS.ino +++ b/examples/DDS/DDS.ino @@ -18,6 +18,7 @@ #define RESET_PIN A3 #define SWITCH_PIN 2 +#define DDS_USE_ONLY_TIMER2 true #define TIMER2_PHASE_ADVANCE 24 HamShield radio; @@ -41,7 +42,7 @@ void setup() { radio.frequency(438000); radio.setModeTransmit(); dds.start(); - dds.startPhaseAccumulator(false); + dds.startPhaseAccumulator(DDS_USE_ONLY_TIMER2); dds.playWait(600, 3000); dds.on(); //dds.setAmplitude(31); @@ -55,23 +56,21 @@ void loop() { } -//Uncomment if using dds.startPhaseAccumulator(true); -/*ISR(TIMER2_OVF_vect) { +#if DDS_USE_ONLY_TIMER2 +ISR(TIMER2_OVF_vect) { static unsigned char tcnt = 0; if(++tcnt == TIMER2_PHASE_ADVANCE) { tcnt = 0; dds.clockTick(); } -}*/ - -//Comment if using dds.startPhaseAccumulator(true); -ISR(ADC_vect) { - if(false){ - static unsigned char tcnt = 0; - TIFR1 = _BV(ICF1); // Clear the timer flag - if(++tcnt == 4) { - tcnt = 0; - } - dds.clockTick(); - } } +#else // Use the ADC timer instead +ISR(ADC_vect) { + static unsigned char tcnt = 0; + TIFR1 = _BV(ICF1); // Clear the timer flag + if(++tcnt == 4) { + tcnt = 0; + } + dds.clockTick(); +} +#endif