EasyManua.ls Logo

Espressif ESP32-S2 - Page 330

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
ESP_ERR_INVALID_ARG Parameter error
ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current
duty_resolution.
Parameters
timer_conf: Pointer of LEDC timer configure struct
esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel)
LEDC update channel parameters.
Note Call this function to activate the LEDC updated parameters. After ledc_set_duty, we need to call this
function to update the settings.
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
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
esp_err_t ledc_set_pin(int gpio_num, ledc_mode_t speed_mode, ledc_channel_t ledc_channel)
Set LEDC output gpio.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
gpio_num: The LEDC output gpio
speed_mode: Select the LEDC channel group with specified speed mode. Note that not all targets
support high speed mode.
ledc_channel: LEDC channel (0 - LEDC_CHANNEL_MAX-1), select from ledc_channel_t
esp_err_t ledc_stop(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idle_level)
LEDC stop. Disable LEDC output, and set idle level.
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
idle_level: Set output idle level after LEDC stops.
esp_err_t ledc_set_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num, uint32_t freq_hz)
LEDC set channel frequency (Hz)
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current
duty_resolution.
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
freq_hz: Set the LEDC frequency
uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num)
LEDC get channel frequency (Hz)
Espressif Systems 319
Submit Document Feedback
Release v4.4

Table of Contents