chiark / gitweb /
Removed ISR overtaken message from ISR routine
authorErik van der Zalm <erik@vdzalm.eu>
Fri, 25 Nov 2011 12:59:58 +0000 (13:59 +0100)
committerErik van der Zalm <erik@vdzalm.eu>
Fri, 25 Nov 2011 12:59:58 +0000 (13:59 +0100)
Marlin/Marlin.pde
Marlin/stepper.cpp
Marlin/stepper.h

index 61078eee7c27865c5ad38e09d3eefe4b89dec380..edba13f35fba44e9f10b0ea302528118ab6adde9 100644 (file)
@@ -289,6 +289,7 @@ void loop()
   manage_heater();
   manage_inactivity(1);
   checkHitEndstops();
+  checkStepperErrors();
   LCD_STATUS;
 }
 
index ad1fda9e09637b0122f8b3d37c6120b94036ade1..2a3b8d8cafbb7614d9b332db2e085058bebc2de5 100644 (file)
@@ -77,6 +77,9 @@ static bool old_y_max_endstop=false;
 static bool old_z_min_endstop=false;
 static bool old_z_max_endstop=false;
 
+static bool bussy_error=false;
+unsigned char OCR1A_error=12345;
+
 volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
 volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
 
@@ -160,6 +163,16 @@ asm volatile ( \
 #define ENABLE_STEPPER_DRIVER_INTERRUPT()  TIMSK1 |= (1<<OCIE1A)
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
 
+void checkStepperErrors()
+{
+  if(bussy_error) {
+    SERIAL_ERROR_START
+    SERIAL_ERROR(OCR1A_error);
+    SERIAL_ERRORLNPGM(" ISR overtaking itself.");
+    bussy_error = false;
+  }
+}
+
 void checkHitEndstops()
 {
  if( endstop_x_hit || endstop_y_hit || endstop_z_hit) {
@@ -264,9 +277,8 @@ inline void trapezoid_generator_reset() {
 ISR(TIMER1_COMPA_vect)
 {        
   if(busy){ 
-    SERIAL_ERROR_START
-    SERIAL_ERROR(*(unsigned short *)OCR1A);
-    SERIAL_ERRORLNPGM(" ISR overtaking itself.");
+    OCR1A_error = OCR1A;
+    bussy_error = true;
     OCR1A = 0x30000;
     return; 
   } // The busy-flag is used to avoid reentering this interrupt
index 468838486d0522aef2ba1cda3530bc4383681fd9..97f72bf2ed93bf6dbaff35849665fd6dcceb2aea 100644 (file)
@@ -44,7 +44,7 @@ void st_wake_up();
 void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
 void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
 
-
+void checkStepperErrors(); //Print errors detected by the stepper
 
 extern block_t *current_block;  // A pointer to the block currently being traced