Skip to content
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

Further improvement to prevent potential LA related hang #25696

Merged
merged 2 commits into from
Apr 17, 2023

Conversation

tombrazier
Copy link
Contributor

Description

#25557 fixed a problem where a division by zero in the 32 bit code for Stepper::calc_timer_interval() resulted in la_interval == 0 which caused an infinite loop in the stepper ISR.

There remains a potential edge case where Stepper::calc_timer_interval() is passed a very low step_rate which results in a return value that is larger than can fit into hal_timer_t. In the very edgiest case it could even be a number that truncates to zero when converted to type hal_timer_t, also causing a hang. But even in the more general edge case it will result in a smaller value for la_interval than is correct.

This PR introduces an analogy to the 8 bit code which tests for min_step_rate and returns a fixed large number if step_rate is too small.

In addition, whilst working on this, I realised that if la_interval ends up being a large number (because step_rate is really low) then the E steps will freeze until la_interval has expired. But step_rate will only ever be really low momentarily (at the point where the E stepper reverses during a deceleration ramp due to linear advance). Long before la_interval has expired, it will receive a new, smaller value which should be honoured to avoid missed E steps. So there is a correction for this as well.

Requirements

Enable LIN_ADVANCE.

Benefits

Removes a potential edge case hang and potential lost E steps.

Related Issues

#25553
#25557

@thinkyhead thinkyhead merged commit 4d8ab1c into MarlinFirmware:bugfix-2.1.x Apr 17, 2023
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 8, 2023
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 17, 2023
tspiva pushed a commit to tspiva/Marlin that referenced this pull request May 25, 2023
Andy-Big pushed a commit to Andy-Big/Marlin_FB_Reborn that referenced this pull request Jul 14, 2023
@tombrazier tombrazier deleted the lafreeze2 branch August 13, 2023 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants