kopia lustrzana https://github.com/espressif/esp-idf
mcpwm: update compare value on both tep and tez
Closes https://github.com/espressif/esp-idf/issues/9904pull/10244/head
rodzic
755ce1077d
commit
79ee98e229
|
@ -374,6 +374,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
|
||||
|
@ -390,6 +391,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
|
||||
|
|
|
@ -270,6 +270,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;
|
||||
}
|
||||
|
@ -291,6 +292,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;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue