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.
LEDC output low configuration how to
Re: LEDC output low configuration how to
Did you try just calling first?
Code: Select all
gpio_set_level(gpio_num, 1)
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: LEDC output low configuration how to
I did tried but it didn't help. Still see all the LEDs flashing at the power up.
Just to clarify, did you suggested
1. gpio_set_level(gpio_num, 1)
2. then ledc_channel_config()
Just to clarify, did you suggested
1. gpio_set_level(gpio_num, 1)
2. then ledc_channel_config()
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: LEDC output low configuration how to
Also the one needed mod is
if (gpio_num < 32) {
GPIO.enable_w1tc = (0x1 << gpio_num);
} else {
GPIO.enable1_w1tc.data = (0x1 << (gpio_num - 32));
}
if (gpio_num < 32) {
GPIO.enable_w1tc = (0x1 << gpio_num);
} else {
GPIO.enable1_w1tc.data = (0x1 << (gpio_num - 32));
}
Re: LEDC output low configuration how to
Ok but that disables the output
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: LEDC output low configuration how to
@WiFive
That is the point
The original code in the SDK is
if (gpio_num < 32) {
GPIO.enable_w1ts = (0x1 << gpio_num);
} else {
GPIO.enable1_w1ts.data = (0x1 << (gpio_num - 32));
}
If I keep this, at the power up, all the LEDs will flash once, I have to change to
if (gpio_num < 32) {
GPIO.enable_w1tc = (0x1 << gpio_num);
} else {
GPIO.enable1_w1tc.data = (0x1 << (gpio_num - 32));
}
In order for the LEDs are not flashing at the power up.
I am seeking the way to overwrite the SDK without actually modify the SDK itself.
I already have one solution that copy exactly the same source code and call them as the static function and place them on APP's space, but it seems double code defines.
I am trying to search for any API if there is any available that can achieve the same goal
That is the point
The original code in the SDK is
if (gpio_num < 32) {
GPIO.enable_w1ts = (0x1 << gpio_num);
} else {
GPIO.enable1_w1ts.data = (0x1 << (gpio_num - 32));
}
If I keep this, at the power up, all the LEDs will flash once, I have to change to
if (gpio_num < 32) {
GPIO.enable_w1tc = (0x1 << gpio_num);
} else {
GPIO.enable1_w1tc.data = (0x1 << (gpio_num - 32));
}
In order for the LEDs are not flashing at the power up.
I am seeking the way to overwrite the SDK without actually modify the SDK itself.
I already have one solution that copy exactly the same source code and call them as the static function and place them on APP's space, but it seems double code defines.
I am trying to search for any API if there is any available that can achieve the same goal
Re: LEDC output low configuration how to
So then you manually enable the output later? You could create your own user_ledc_channel_config function.
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: LEDC output low configuration how to
@WiFive,
Yes, once I have all the gpios configured like that, to turn on/off the leds i will call
ledc_set_duty () and ledc_update_duty() with DutyCycle and 0 respectively, my Leds will be on/off.
The part I can't figure out is my method of before configure the gpios to ledc for pwm control, I tried to set gpio_set_level(gpio_num, 1), but someone (boot maybe) still pull the gpios low hence there was a glitch/flash at the power up.
Yes, once I have all the gpios configured like that, to turn on/off the leds i will call
ledc_set_duty () and ledc_update_duty() with DutyCycle and 0 respectively, my Leds will be on/off.
The part I can't figure out is my method of before configure the gpios to ledc for pwm control, I tried to set gpio_set_level(gpio_num, 1), but someone (boot maybe) still pull the gpios low hence there was a glitch/flash at the power up.
Who is online
Users browsing this forum: No registered users and 87 guests