Skip to content

Commit

Permalink
Merge branch 'bugfix/update_duty_on_tez_tep' into 'master'
Browse files Browse the repository at this point in the history
mcpwm: update compare value on both tep and tez

Closes IDFGH-8438

See merge request espressif/esp-idf!20631
  • Loading branch information
suda-morris committed Oct 19, 2022
2 parents 7a58ffa + 78dfb58 commit f89b68e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/driver/deprecated/driver/mcpwm.h
Expand Up @@ -72,6 +72,7 @@ esp_err_t mcpwm_init( mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, const mcp
* This will override default resolution of group(=10,000,000).
* This WILL NOT automatically update frequency and duty. Call mcpwm_set_frequency() and mcpwm_set_duty() manually
* to set them back.
* The group resolution must be an integral multiple of timer resolution.
*
* @param mcpwm_num set MCPWM unit(0-1)
* @param resolution set expected frequency resolution
Expand All @@ -88,6 +89,7 @@ esp_err_t mcpwm_group_set_resolution(mcpwm_unit_t mcpwm_num, unsigned long int r
* This WILL override default resolution of timer(=1,000,000).
* This WILL NOT automatically update frequency and duty. Call mcpwm_set_frequency() and mcpwm_set_duty() manually
* to set them back.
* The group resolution must be an integral multiple of timer resolution.
*
* @param mcpwm_num set MCPWM unit(0-1)
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
Expand Down
2 changes: 2 additions & 0 deletions components/driver/deprecated/mcpwm_legacy.c
Expand Up @@ -284,6 +284,7 @@ esp_err_t mcpwm_set_duty(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_
uint32_t set_duty = mcpwm_ll_timer_get_peak(hal->dev, timer_num, false) * duty / 100;
mcpwm_ll_operator_set_compare_value(hal->dev, op, cmp, set_duty);
mcpwm_ll_operator_enable_update_compare_on_tez(hal->dev, op, cmp, true);
mcpwm_ll_operator_enable_update_compare_on_tep(hal->dev, op, cmp, true);
mcpwm_critical_exit(mcpwm_num);
return ESP_OK;
}
Expand All @@ -305,6 +306,7 @@ esp_err_t mcpwm_set_duty_in_us(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
uint64_t compare_val = real_timer_clk_hz * duty_in_us / 1000000;
mcpwm_ll_operator_set_compare_value(hal->dev, op, cmp, (uint32_t)compare_val);
mcpwm_ll_operator_enable_update_compare_on_tez(hal->dev, op, cmp, true);
mcpwm_ll_operator_enable_update_compare_on_tep(hal->dev, op, cmp, true);
mcpwm_critical_exit(mcpwm_num);
return ESP_OK;
}
Expand Down

0 comments on commit f89b68e

Please sign in to comment.