marlin "In the while loop the timer overflows if TEMP_RESIDENCY_TIME is larger than 32 When TEMP_RESIDENCY_TIME is set to be 32 or larger, the timer overflows yielding always false in the comparison in the while condition. Issue 55: https://github.com/MarlinFirmware/Marlin/issues/55"

Bug fixed by commit f87c80889fe
Type IntegerOverflow
Config "TEMP_RESIDENCY_TIME" (1st degree)
Fix-in code
Location main/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TEMP_RESIDENCY_TIME 30

void process_commands(){
	unsigned long millis = 123456789l; 	
	  #ifdef TEMP_RESIDENCY_TIME
        long residencyStart;
        residencyStart = -1;
        /* continue to loop until we have reached the target temp   
          _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
        while((residencyStart == -1) ||
              (residencyStart > -1 && (millis - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { // ERROR if TEMP_RESIDENCY_TIME > 32 => int overflow
      #else
        printf("%s", "Cooling down or heating hotend");
      #endif //TEMP_RESIDENCY_TIME
         
    }
}

int main(int argc, char **argv)
{
  #ifdef TEMP_RESIDENCY_TIME
	process_commands();
  #endif
  return 0;
}
diff --git a/simple/f87c808.c b/simple/f87c808.c
--- a/simple/f87c808.c
+++ b/simple/f87c808.c
@@ -13,7 +13,7 @@ void process_commands(){
         /* continue to loop until we have reached the target temp   
           _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
         while((residencyStart == -1) ||
-              (residencyStart > -1 && (millis - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { // ERROR if TEMP_RESIDENCY_TIME > 32 => int overflow
+              (residencyStart > -1 && (millis - residencyStart) < TEMP_RESIDENCY_TIME*1000l) )
       #else
         printf("%s", "Cooling down or heating hotend");
       #endif //TEMP_RESIDENCY_TIME
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TEMP_RESIDENCY_TIME 30

int main(int argc, char **argv)
{
  #ifdef TEMP_RESIDENCY_TIME
	unsigned long millis = 123456789l;
    long residencyStart;
    residencyStart = -1;
    /* continue to loop until we have reached the target temp   
    _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
    while((residencyStart == -1) ||
        (residencyStart > -1 && (millis - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { // ERROR if TEMP_RESIDENCY_TIME > 32 => int overflow
  #else
    printf("%s", "Cooling down or heating hotend");
  #endif //TEMP_RESIDENCY_TIME
  
  return 0;
}
. call  Marlin.pde:521: void process_comands()
. 806:  case 109:
. 845:  while((residencyStart == -1) ||
. ERORR 846:    (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) )