mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
Merge branch 'bugfix/update_duty_on_tez_tep_v5.0' into 'release/v5.0'
mcpwm: update compare value on both tep and tez (v5.0) See merge request espressif/esp-idf!20766
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user