Skip to content

Conversation

@wisp3rwind
Copy link
Contributor

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the latest Migration Guide.
  • My changes are in accordance to the esp-rs developer guidelines

Extra:

Pull Request Details 📖

Tentative fix for the timing/clock divider issues pointed out in the comments at #3930 (comment). See the commit messages for much more detail.

@ Espressif people: Is there any way for you to figure out what's required to make this work reliably? Whatever the precise issue with large SCLK dividers is, it seems to be entirely undocumented.

cc @kleinesfilmroellchen

Testing

HIL tests on C3.

This is currently broken due to undocumented timing/ordering constraints
of the peripheral, which leads to erroneous behavior when the sclk
divider is large (i.e. presuamably when the RMT sclk is slow compared to
some bus clock?).
Setting a large RMT SCLK divider breaks the driver in unexpected ways.
There's nothing in the documentation hinting at relevant timing
constraints (the only thing mentioned are limits on pulse code periods,
but that's not the issue here), and the IDF code also doesn't seem to do
anything special. It does order some register operations differently,
first sets register and only then fills the hardware buffer, and also
does more stuff (book keeping, locking, ...).

This PR does the following:
- match update() calls better to what IDF does (only before tx start,
  after tx stop, after rx start)
- add some delays between configuring channels and actually starting
  transactions: It appears that adding a delay of about 1 SCLK period
  fixes all the weirdness. This suggests that some settings take a while
  to be properly propagated in the peripheral, and failing to provide
  that time results in weird glitches and hangs.
  It might be that IDF accidentally sidesteps this due to ordering
  things as follows (and due to overall doing more including locking,
  runtime checks, ...):

  1. write RMT config registers
  2. write data to RMT RAM
  3. start tx

  whereas we switch steps 1 + 2. Thus, switching order might be a way to
  decrease the required delay, but that would require more research into
  whether that is really sufficient (e.g. when the data is short and
  writing it to RAM completes quickly). If there's no overall better way
  to fix this, maybe one could use cycle counters to just wait the
  minimal necessary time?

  In any case, this commit seems to be a minimally-invasive
  workaround/fix.
Give a more precise error when specifying timings that would make some
of the pulses longer than the idle_threshold
@MabezDev MabezDev added the trusted-author Allow the author of this Pull Request to run HIL tests and the `binary-size` test. label Dec 9, 2025
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

[HIL trust list]

Trusted users for this PR (click to expand)

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Author @wisp3rwind was trusted for this PR via the trusted-author label.
They can now use /hil quick or /hil full.

@wisp3rwind
Copy link
Contributor Author

/hil full

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Triggered full HIL run for #4637.

Run: https://github.com/esp-rs/esp-hal/actions/runs/20063369980

Status update: ❌ HIL (full) run failed (conclusion: failure).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trusted-author Allow the author of this Pull Request to run HIL tests and the `binary-size` test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants