Skip to content

Commit 6782797

Browse files
authored
Merge pull request #4702 from rsbohn/patch-1
esp32-s2: Don't set PWMOut frequency to 0
2 parents 94ed5e0 + d1db782 commit 6782797

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ports/esp32s2/common-hal/pwmio/PWMOut.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
6363
uint16_t duty,
6464
uint32_t frequency,
6565
bool variable_frequency) {
66+
67+
// check the frequency (avoid divide by zero below)
68+
if (frequency == 0) {
69+
return PWMOUT_INVALID_FREQUENCY;
70+
}
71+
6672
// Calculate duty cycle
6773
uint32_t duty_bits = 0;
6874
uint32_t interval = LEDC_APB_CLK_HZ / frequency;

0 commit comments

Comments
 (0)