mcpwm_timer_set_period() function
Set a new period for MCPWM timer
Arguments
timer
MCPWM timer handle, allocated by `mcpwm_new_timer`
period_ticks
New period in count ticks
Return value
- ESP_OK: Set new period for MCPWM timer successfully - ESP_ERR_INVALID_ARG: Set new period for MCPWM timer failed because of invalid argument - ESP_FAIL: Set new period for MCPWM timer failed because of other error
Notes
If `mcpwm_timer_config_t::update_period_on_empty` and `mcpwm_timer_config_t::update_period_on_sync` are not set, the new period will take effect immediately. Otherwise, the new period will take effect when timer counts to zero or on sync event. You may need to use `mcpwm_comparator_set_compare_value` to set a new compare value for MCPWM comparator in order to keep the same PWM duty cycle.
mcpwm_timer_set_period() calls 4 functions:
![]()
mcpwm_timer_set_period()
mcpwm_timer_set_period() reads 7 variables and writes 1 variable:
![]()
mcpwm_timer_set_period()