-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Fix esp32 clock definitions #2456
Merged
Merged
Conversation
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
SmingHub#2455 changed the timer2 timebase so it no longer corresponds with the microsecond system clock used for OsTimer.
ccount value accurately reflects selected CPU frequency
Systick is a down-counter
slaff
added
3.5 - Approved - Waiting for CI results
and removed
3.5 - Approved - Waiting for CI results
labels
Dec 27, 2021
slaff
pushed a commit
that referenced
this pull request
Jan 16, 2024
This PR fixes an issue with `HostTests` which hangs consistently when testing Timer1 (used by HardwareTimer) on the Esp8266. The problem occurs whilst checking each timer for consistency against system time. This happens because the test code doesn't set a callback interrupt routine. It is only a problem on the Esp8266 because the callback routine is set directly on the interrupt vector. Other architectures use indirection and so do nothing if the callback isn't set. NB. Doing this with the Esp8266 would increase interrupt latency which would affect PWM timing, etc. Normal code uses the `HardwareTimer` class which contains logic to ensure this doesn't happen during setup. Timer1 has only a 23-bit counter so fails test with /16 divisor as it wraps at around 1.7s (test duration is 2 seconds). Fixed by restricting duration to timer maximum (less 1ms). Elapsed tick calculation check also improved by first checking whether timer is an UP or DOWN counter, and using timer maximum tick value to handle wraps correctly. This PR also reduces the number of test loops on the Host (from 2000 to 50). Note: Bug was introduced in #2456. Timer1 needed to be correctly configured (but inactive) to produce correct result for Esp32.
slaff
pushed a commit
that referenced
this pull request
Jan 19, 2024
This PR fixes an issue with `HostTests` which hangs consistently when testing Timer1 (used by HardwareTimer) on the Esp8266. The problem occurs whilst checking each timer for consistency against system time. This happens because the test code doesn't set a callback interrupt routine. It is only a problem on the Esp8266 because the callback routine is set directly on the interrupt vector. Other architectures use indirection and so do nothing if the callback isn't set. NB. Doing this with the Esp8266 would increase interrupt latency which would affect PWM timing, etc. Normal code uses the `HardwareTimer` class which contains logic to ensure this doesn't happen during setup. Timer1 has only a 23-bit counter so fails test with /16 divisor as it wraps at around 1.7s (test duration is 2 seconds). Fixed by restricting duration to timer maximum (less 1ms). Elapsed tick calculation check also improved by first checking whether timer is an UP or DOWN counter, and using timer maximum tick value to handle wraps correctly. This PR also reduces the number of test loops on the Host (from 2000 to 50). Note: Bug was introduced in #2456. Timer1 needed to be correctly configured (but inactive) to produce correct result for Esp32.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#2455 changed the timer2 timebase so it no longer corresponds with the microsecond system clock used for OsTimer.
Added check in HostTests to catch this.
Also improve Host CPU clock emulation to accurately reflect selected frequency.
Also fix rp2040 esp_get_ccount return value, now passes tests.