Protect pulse generation timing by disabling interrupts for longer #27131
+12
−8
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.
Description
Protect pulse generation timing by disabling interrupts within
Stepper::isr()
for longer.This is a mitigation for the stepper isr jitter seen in #27115 and other sources of stepper isr jitter on other platforms. On microcontrollers with ISR prioritization, note that only higher priority ISRs can ever interrupt the stepper ISR.
Benefits
More consistent pulse timings. I've tested on LPC176x and here's some before/after logic analyzer captures:
Before:
![jitter-interrupt-before](https://private-user-images.githubusercontent.com/299015/334075616-4180f188-36b7-49de-b25d-b43e7f847ab0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3NDM3MjgsIm5iZiI6MTcxOTc0MzQyOCwicGF0aCI6Ii8yOTkwMTUvMzM0MDc1NjE2LTQxODBmMTg4LTM2YjctNDlkZS1iMjVkLWI0M2U3Zjg0N2FiMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYzMFQxMDMwMjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01YzkwMjI1NDIyOWRiMzc0ZGMyNTJmMGIwZGJlNmE3YzI5MmU5MGZmMTllODEzY2E5OTVlM2QwMjI1N2YzZGRhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Ky0QsWs7nsfiRZEE1U7DeLIqaUsKySNlnkG2W29JnG8)
After (edit, recaptured due to forgotten local changes):
![jitter-interrupt-after](https://private-user-images.githubusercontent.com/299015/334157314-d44697ef-2196-4921-b2fd-307f45b27d4a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3NDM3MjgsIm5iZiI6MTcxOTc0MzQyOCwicGF0aCI6Ii8yOTkwMTUvMzM0MTU3MzE0LWQ0NDY5N2VmLTIxOTYtNDkyMS1iMmZkLTMwN2Y0NWIyN2Q0YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYzMFQxMDMwMjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04ZTFjMDVmZDllYzUxZjk3YjQxM2VkYmZiY2YzOTFmYmZkMGQzMjFjNGFiOTQ0Y2E4ODQ0NjdiNTJmYzNkYWJhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.ctJrgj05n54-Kmm-diYVB32SxzyzQEv6V6yh1Faa_-c)
Basically no improvements in actual printing quality/noise unless
ADAPTIVE_STEP_SMOOTHING
is enabled sinceADAPTIVE_STEP_SMOOTHING
reduces a larger source of speed jitter, namely bresenham aliasing for the minor axes.Related Issues
Mostly mitigates #27115