mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(ledc): fix frequency calculation
ledc.c: Fix frequency calculation. Round int instead of truncate. Merges https://github.com/espressif/esp-idf/pull/11810
This commit is contained in:
committed by
Song Ruo Jing
parent
6f3e07d97b
commit
909d8b6db5
@@ -849,7 +849,7 @@ uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num)
|
||||
ESP_LOGW(LEDC_TAG, "LEDC timer not configured, call ledc_timer_config to set timer frequency");
|
||||
return 0;
|
||||
}
|
||||
return ((uint64_t) src_clk_freq << LEDC_LL_FRACTIONAL_BITS) / precision / clock_divider;
|
||||
return (((uint64_t) src_clk_freq << LEDC_LL_FRACTIONAL_BITS) + (uint64_t) precision * clock_divider / 2) / precision / clock_divider;
|
||||
}
|
||||
|
||||
static inline void IRAM_ATTR ledc_calc_fade_end_channel(uint32_t *fade_end_status, uint32_t *channel)
|
||||
|
||||
Reference in New Issue
Block a user