[rtl872x] Poll micros instead of rom DelayUs function. Tweak 1ms test #2499
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.
Problem
DELAY_01_delay_1ms_is_within_tolerance
fails occasionally on p2no_fixture
tests, ie the 1ms delay ends up being out of the 6% margin of error ( > 1060 us).Solution
Changing the
HAL_Delay_Microseconds()
implementation to a simple poll ofHAL_Timer_Get_Micro_Seconds()
seems to be no worse than using the romDelayUs()
function.Also tweaked the
system_delay_pump()
logic when doing a 1ms delay, which is what happens in the DELAY_01 test.However, the 6% threshold is still too short in some situations. Doubling it seems to ensure tests pass a higher % of the time. I still see an occasional failure where the delay took >1120 us, but this happened once in 300 test iterations. Not sure if this is infrequent enough to ignore or if the threshold should be raised even higher.
Steps to Test
Run wiring/no_fixture tests
Example App
wiring/no_fixture
References
Links to the Community, Docs, Other Issues, etc..
Completeness