Skip to content

Commit dd639c4

Browse files
mmoneme-no-dev
authored andcommitted
Fix wrong range of duty cycle (#1353)
The esp-idf expects duty values for the the sigma delta modulator in the range of -128 to 127 The arduino framework is supposed to use the range 0-255 thus the offset caclulation was wrong.
1 parent f14de5c commit dd639c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: cores/esp32/esp32-hal-sigmadelta.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
6060
if(channel > 7) {
6161
return;
6262
}
63-
duty += 128;
63+
duty -= 128;
6464
SD_MUTEX_LOCK();
6565
SIGMADELTA.channel[channel].duty = duty;
6666
SD_MUTEX_UNLOCK();
@@ -72,7 +72,7 @@ uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
7272
return 0;
7373
}
7474
SD_MUTEX_LOCK();
75-
uint8_t duty = SIGMADELTA.channel[channel].duty - 128;
75+
uint8_t duty = SIGMADELTA.channel[channel].duty + 128;
7676
SD_MUTEX_UNLOCK();
7777
return duty;
7878
}

0 commit comments

Comments
 (0)