From 9f462f0cf52cfddd9271766cb62e8d1a38ab1f85 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Fri, 4 Sep 2015 15:59:19 -0700
Subject: [PATCH] Hack to address stuttering caused by ISR not finishing in
 time (PR #138)

When the ISR does not finish in time, the timer will
wrap in the computation of the next interrupt time.

This hack replaces the correct (past) time with a time not far in the future.
---
 Marlin/stepper.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp
index 42b903e415..2d10820823 100644
--- a/Marlin/stepper.cpp
+++ b/Marlin/stepper.cpp
@@ -749,6 +749,8 @@ ISR(TIMER1_COMPA_vect) {
       step_loops = step_loops_nominal;
     }
 
+    OCR1A = (OCR1A < (TCNT1 +16)) ? (TCNT1 + 16) : OCR1A;
+
     // If current block is finished, reset pointer
     if (step_events_completed >= current_block->step_event_count) {
       current_block = NULL;