Skip to content
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

Request for Clarification of ULP GPIO example #76

Open
wz2b opened this issue Jun 28, 2022 · 1 comment
Open

Request for Clarification of ULP GPIO example #76

wz2b opened this issue Jun 28, 2022 · 1 comment

Comments

@wz2b
Copy link

wz2b commented Jun 28, 2022

WRITE_RTC_REG(RTC_IO_TOUCH_PAD0_REG, RTC_IO_TOUCH_PAD0_FUN_IE_M, 1, 1)

Can I ask for a clarification on this line of the gpio example? What's got me confused here is that it references bit 13 of this register:

image

Bit 13 is reserved. I don't know if the intent here really was to write an input enable, like this:

image

What am I missing?

@wz2b wz2b changed the title Clarification on example Clarification on ULP GPIO example Jun 28, 2022
@wz2b wz2b changed the title Clarification on ULP GPIO example Request for Clarification of ULP GPIO example Jun 28, 2022
@wnienhaus
Copy link
Collaborator

I have found that the documentation and code (ESP-IDF) don't always match 100%. In such cases, I tend to trust the code in the ESP-IDF, as that is what's actually running on devices. Then again, I have seen a case where the code was incorrect (espressif/binutils-esp32ulp#18) and the Technical Manual was actually correct.

In this case, the example follows the approach used by Espressif's own example: https://github.com/espressif/esp-idf/blob/v4.4.1/examples/system/ulp_fsm/ulp/main/ulp_example_main.c#L72, where the rtc_gpio_set_direction function calls rtcio_ll_input_enable (here), which in turn sets the input enable on the RTC_IO_TOUCH_PADx_REG using the RTC_IO_TOUCH_PADx_FUN_IE_M mask (here). That last code uses a lookup table to find the correct register REG for the rtc pin and then the corresponding input-enable IE mask. And since the mask is always 1 bit wide, in our example, we're simply using it as a low-bit number with a bit-width of 1.

(Note, I have also found that with ESP32 low level code, there are often multiple ways of achieving something and the naming used everywhere is not always intuitive or consistent. So it may well be that the other approach you found in the documentation also works. Have you managed to try the other approach with success?)

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

No branches or pull requests

2 participants