Chapter 2. API Reference
Return
• 0 error
• Others Current LEDC frequency
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• timer_num: LEDC timer index (0-3), select from ledc_timer_t
esp_err_t ledc_set_duty_with_hpoint(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t
duty, uint32_t hpoint)
LEDC set duty and hpoint value Only after calling ledc_update_duty will the duty update.
Note ledc_set_duty, ledc_set_duty_with_hpoint and ledc_update_duty are not thread-safe, do not call these
functions to control one LEDC channel in different tasks at the same time. A thread-safe version of API
is ledc_set_duty_and_update
Note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
Other duty operations will have to wait until the fade operation has finished.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• channel: LEDC channel (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
• duty: Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution) - 1]
• hpoint: Set the LEDC hpoint value(max: 0xfffff)
int ledc_get_hpoint(ledc_mode_t speed_mode, ledc_channel_t channel)
LEDC get hpoint value, the counter value when the output is set high level.
Return
• LEDC_ERR_VAL if parameter error
• Others Current hpoint value of LEDC channel
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• channel: LEDC channel (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
esp_err_t ledc_set_duty(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty)
LEDC set duty This function do not change the hpoint value of this channel. if needed, please call
ledc_set_duty_with_hpoint. only after calling ledc_update_duty will the duty update.
Note ledc_set_duty, ledc_set_duty_with_hpoint and ledc_update_duty are not thread-safe, do not call these
functions to control one LEDC channel in different tasks at the same time. A thread-safe version of API
is ledc_set_duty_and_update.
Note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
Other duty operations will have to wait until the fade operation has finished.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
• channel: LEDC channel (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
• duty: Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution) - 1]
uint32_t ledc_get_duty(ledc_mode_t speed_mode, ledc_channel_t channel)
LEDC get duty.
Return
• LEDC_ERR_DUTY if parameter error
• Others Current LEDC duty
Espressif Systems 320
Submit Document Feedback
Release v4.4