Skip to content

Add LED Fade Example #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

mjaspers2mtu
Copy link

An example that uses ULP self-modifying code to create a PWM-like LED dimming effect on GPIO 15.

An example that uses ULP self-modifying code to create a PWM-like LED dimming effect on GPIO 15.
@wnienhaus
Copy link
Collaborator

Very cool contribution! I like the self-modification to work around WAIT's fixed operand limitation.

Did you run this on an S2 or S3 (given that we're using the esp32s2 cpu option for both)? I want to test it too. Then we can merge this example.

@mjaspers2mtu
Copy link
Author

Thanks, I have only tested this on an S2 (see here for the board I used) , as this is all I have access to right now.

Example code for reading the temperature of the chip using the ULP of the ESP32-S2
@wnienhaus
Copy link
Collaborator

Just tested this on my S2 and it worked a charm.

Except for one small niggly... related to my board: the LED was already on with a faint glow, before I started the program. The reason turns out, that on my board (Waveshare ESP32-S2 Pico), GPIO15 is used for I2C and pin 15 is pulled high with an external resistor. So current leaks via that resistor and my LED.

Looking at the schematic of your board, GPIO15 is not connected to anything else, so in your case GPIO15 will work fine.

Was there a reason you picked GPIO15? I have generally used GPIO4 for my projects, which does not usually seem to be used for anything else. I googled for a few dev boards, and none used GPIO4 for anything. And the ESP32-S2 Technical Reference Manual also shows that GPIO4 has no other functions mapped to it. I have also often used GPIO2, but on one of my boards it was connected to the onboard LED (but in active-low mode).

Perhaps it's useful to change the example to use GPIO4? That way is should not (as far as I can see) interfere with other things. Also the code might read more easily, because the current constants refer to XTAL32 (because of what Espressif named it) and it might not be obvious to readers that this refers to GPIO15. GPIO4 instead is named TOUCH_PAD4, which is still somewhat confusing, but a bit more obvious in that it refers to GPIO4.

I don't mind that much keeping the example at GPIO15, but if you had no specific reason (or wish) to have it on GPIO15, then I'd suggest changing it.

i.e.
replace RTC_IO_XTAL_32P_PAD_REG with RTC_IO_TOUCH_PAD4_REG
replace RTC_IO_X32P_MUX_SEL_M with RTC_IO_TOUCH_PAD4_MUX_SEL_M
replace RTCIO_GPIO15_CHANNEL with RTCIO_GPIO4_CHANNEL
...of course with their correct values as per https://github.com/espressif/esp-idf/blob/v5.0.2/components/soc/esp32s2/include/soc/rtc_io_reg.h#L922

@wnienhaus
Copy link
Collaborator

Btw, the temperature sensing example also works as advertised. Very nice. We can merge it as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants