-
Notifications
You must be signed in to change notification settings - Fork 220
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
Disable TWAI CLKOUT when initializing peripheral #1949
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain why you added this piece of code, not (or not only, I guess...) what it does. It's completely unobvious to me (as an uninformed reader) why this has any effect.
Also, do we want this done for all MCUs, when the issue only seems to affect C3? Slightly related, do we want to have a test case in our test suite for this? (I think yes!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there is no support for using the CLKOUT functionality of the TWAI peripheral in
esp-hal
, so I do not think there is a reason to leave the clock divider active. This also matches the behaviour from the ESP-IDF, which in the default configuration also does not use the CLKOUT functionality.In the default configuration
clkout_divider
is zero, andclkout_gpio
isTWAI_IO_UNUSED
. Theclkout_divider
configuration is passed fromtwai_driver_install_v2
totwai_hal_configure
, which in turn callstwai_ll_set_clkout
(https://github.com/espressif/esp-idf/blob/master/components/driver/twai/twai.c#L475 and https://github.com/espressif/esp-idf/blob/master/components/hal/twai_hal.c#L64).The function
twai_ll_set_clkout
is chip specific, but for all chips with a TWAI peripheral does the exact same thing when passed zero. It sets theTWAI_CLOCK_OFF
bit and setsTWAI_CD
to zero. See esp32, esp32c3, esp32c6, esp32p4, esp32s2 and esp32s3. So I think it makes sense to match this configuration.Why exactly this fixes the issue with receiving on GPIO1, I do not know. In theory leaving the clock divider active should not influence the receive operation, but I guess it does. If
esp-hal
is going to support the CLKOUT functionality, then we should probably add a note about receiving on GPIO1 when CLKOUT is enabled.As for the test case, could you point me in the right direction where to add the test?