LEDC output low configuration how to
Posted: Tue Sep 24, 2019 7:07 am
Hi all,
I use LEDC driver to configure the pwm to drive my leds. The hardware team designed the gpios to control the on/off by signal low/high.
However, I need to configure the output gpios as the high output at the power up to prevent the glitch at the power up at these pins.
This is what I have to do to prevent the glitches
During the pwm initialization I called
1. ledc_channel_config(), which will call
2. gpio_set_direction() which in turn will call
3. gpio_output_enable().
In this function I have to do 2 modifications: change GPIO.enable_w1ts to GPIO.enable_w1tc and call gpio_set_level to 1
static esp_err_t gpio_output_enable2(gpio_num_t gpio_num)
{
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);
if (gpio_num < 32) {
GPIO.enable_w1tc = (0x1 << gpio_num);
} else {
GPIO.enable1_w1tc.data = (0x1 << (gpio_num - 32));
}
gpio_set_level(gpio_num, 1); // DT
gpio_matrix_out(gpio_num, SIG_GPIO_OUT_IDX, false, false);
return ESP_OK;
}
I would like to keep the SDK driver the same and only use the app layer to configure the pwm channels. Is there any API or different ways to configure pwm as output high at the power up?
Thank you so much for your helps.
I use LEDC driver to configure the pwm to drive my leds. The hardware team designed the gpios to control the on/off by signal low/high.
However, I need to configure the output gpios as the high output at the power up to prevent the glitch at the power up at these pins.
This is what I have to do to prevent the glitches
During the pwm initialization I called
1. ledc_channel_config(), which will call
2. gpio_set_direction() which in turn will call
3. gpio_output_enable().
In this function I have to do 2 modifications: change GPIO.enable_w1ts to GPIO.enable_w1tc and call gpio_set_level to 1
static esp_err_t gpio_output_enable2(gpio_num_t gpio_num)
{
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);
if (gpio_num < 32) {
GPIO.enable_w1tc = (0x1 << gpio_num);
} else {
GPIO.enable1_w1tc.data = (0x1 << (gpio_num - 32));
}
gpio_set_level(gpio_num, 1); // DT
gpio_matrix_out(gpio_num, SIG_GPIO_OUT_IDX, false, false);
return ESP_OK;
}
I would like to keep the SDK driver the same and only use the app layer to configure the pwm channels. Is there any API or different ways to configure pwm as output high at the power up?
Thank you so much for your helps.