I'm working on some code and can't seem to figure out how to get these two functions to work together.
I have a LED on GPIO_25
I have the ledc fade code working and can get the fades to happen as I want.
I have a component that was wrote that takes a GPIO pin number and blinks a LED using gpio_set_level().
When I try to use them together the Fade will work if I initialize its code last and the GPIO_set_level() does nothing.
Then vise versa if I set the GPIO direction last then the GPIO_set_level() will work but the fade does not.
I thought I wasn't able to get them to both work because I needed to use ledc_stop() so I added it when I'm not needing to fade and still gpio_set_level() does nothing.
Then it got me to thinking how based on the order I initialize them dictates which one works, So this must be a more complex issue.
So is it the fact that they are setup a certain way and one over writes the other on initialization is my issue? Would I need to uninstall the LEDC and reinstall when I need it?
Possible to use LEDC Fade along with GPIO_SET_LEVEL() on the same PIN
-
- Posts: 20
- Joined: Wed Nov 10, 2021 7:13 pm
-
- Posts: 1726
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Possible to use LEDC Fade along with GPIO_SET_LEVEL() on the same PIN
Yes. A pin can only be connected to one output signal at a time; this can be a GPIO signal or a signal from a peripheral like the LEDC. Both the GPIO and the LEDC driver connect "their" respective output signal to the pin, overwriting/replacing any previous output signal routing for that pin.Ravenholem wrote: ↑Wed Oct 09, 2024 6:36 pmSo is it the fact that they are setup a certain way and one over writes the other on initialization is my issue?
Not really. You can set up the LEDC once, then switch between the pin's functions by using gpio_config() to make the pin work as GPIO and ledc_set_pin() to make it work as LEDC output.Would I need to uninstall the LEDC and reinstall when I need it?
Or you could modify the other code to use the LEDC too (100%/0% duty cycle).
Who is online
Users browsing this forum: No registered users and 77 guests