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; }