Merge branch 'bugfix/ledc_get_freq_calc_v5.0' into 'release/v5.0'

fix(ledc): fix ledc_get_freq calculation err due to overflow (v5.0)

See merge request espressif/esp-idf!36023
This commit is contained in:
Jiang Jiang Jian
2025-01-03 15:25:10 +08:00
3 changed files with 5 additions and 5 deletions

View File

@@ -838,7 +838,7 @@ uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num)
ledc_hal_get_clock_divider(&(p_ledc_obj[speed_mode]->ledc_hal), timer_num, &clock_divider); ledc_hal_get_clock_divider(&(p_ledc_obj[speed_mode]->ledc_hal), timer_num, &clock_divider);
ledc_hal_get_duty_resolution(&(p_ledc_obj[speed_mode]->ledc_hal), timer_num, &duty_resolution); ledc_hal_get_duty_resolution(&(p_ledc_obj[speed_mode]->ledc_hal), timer_num, &duty_resolution);
ledc_hal_get_clk_cfg(&(p_ledc_obj[speed_mode]->ledc_hal), timer_num, &clk_cfg); ledc_hal_get_clk_cfg(&(p_ledc_obj[speed_mode]->ledc_hal), timer_num, &clk_cfg);
uint32_t precision = (0x1 << duty_resolution); uint64_t precision = (0x1 << duty_resolution);
uint32_t src_clk_freq = ledc_get_src_clk_freq(clk_cfg); uint32_t src_clk_freq = ledc_get_src_clk_freq(clk_cfg);
portEXIT_CRITICAL(&ledc_spinlock); portEXIT_CRITICAL(&ledc_spinlock);
if (clock_divider == 0) { if (clock_divider == 0) {

View File

@@ -261,14 +261,14 @@ The LEDC API provides several ways to change the PWM frequency "on the fly":
More Control Over PWM More Control Over PWM
""""""""""""""""""""" """""""""""""""""""""
There are several lower level timer-specific functions that can be used to change PWM settings: There are several individual timer-specific functions that can be used to change PWM output:
* :cpp:func:`ledc_timer_set` * :cpp:func:`ledc_timer_set`
* :cpp:func:`ledc_timer_rst` * :cpp:func:`ledc_timer_rst`
* :cpp:func:`ledc_timer_pause` * :cpp:func:`ledc_timer_pause`
* :cpp:func:`ledc_timer_resume` * :cpp:func:`ledc_timer_resume`
The first two functions are called "behind the scenes" by :cpp:func:`ledc_channel_config` to provide a startup of a timer after it is configured. The first two functions are called "behind the scenes" by :cpp:func:`ledc_timer_config` to provide a startup of a timer after it is configured.
Use Interrupts Use Interrupts

View File

@@ -261,14 +261,14 @@ LED PWM 控制器 API 有多种方式即时改变 PWM 频率:
控制 PWM 的更多方式 控制 PWM 的更多方式
""""""""""""""""""""" """""""""""""""""""""
有一些较底层的定时器特定函数可用于更改 PWM 设置 有一些较独立的定时器特定函数可用于更改 PWM 输出
* :cpp:func:`ledc_timer_set` * :cpp:func:`ledc_timer_set`
* :cpp:func:`ledc_timer_rst` * :cpp:func:`ledc_timer_rst`
* :cpp:func:`ledc_timer_pause` * :cpp:func:`ledc_timer_pause`
* :cpp:func:`ledc_timer_resume` * :cpp:func:`ledc_timer_resume`
前两个功能可通过函数 :cpp:func:`ledc_channel_config` 在后台运行,在定时器配置后启动。 前两个功能可通过函数 :cpp:func:`ledc_timer_config` 在后台运行,在定时器配置后启动。
使用中断 使用中断