From 77a8c62b78a678fd7f6a2c91545783de0b3818ba Mon Sep 17 00:00:00 2001 From: Stephen Olesen Date: Thu, 2 Jul 2015 19:57:32 -0600 Subject: [PATCH] Correct Pin 3 output to scale to the reduced comparator size. --- DDS.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DDS.cpp b/DDS.cpp index 6d86f80..eeaabb3 100644 --- a/DDS.cpp +++ b/DDS.cpp @@ -140,13 +140,13 @@ uint8_t DDS::getDutyCycle() { uint8_t phAng; #endif phAng = (accumulator >> ACCUMULATOR_BIT_SHIFT); - int8_t position = pgm_read_byte_near(ddsSineTable + phAng)>>(8-COMPARATOR_BITS); + int8_t position = pgm_read_byte_near(ddsSineTable + phAng); //>>(8-COMPARATOR_BITS); // Apply scaling and return int16_t scaled = position; // output = ((duty * amplitude) / 256) + 128 // This keeps amplitudes centered around 50% duty scaled *= amplitude; - scaled >>= 8; - scaled += 128; + scaled >>= 8+(8-COMPARATOR_BITS); + scaled += 128>>(8-COMPARATOR_BITS); return scaled; }