stale-issue-message:'This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.'
// Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#define PID_K1 0.95 // Smoothing factor within any PID loop
#if ENABLED(PIDTEMP)
#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM)
#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
@ -480,7 +491,7 @@
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2]
#define PID_FUNCTIONAL_RANGE 15 // If the temperature difference between the target temperature and the actual temperature
//#define PID_FUNCTIONAL_RANGE 15 // If the temperature difference between the target temperature and the actual temperature
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
@ -561,6 +572,14 @@
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED
#if EITHER(PIDTEMP, PIDTEMPBED)
//#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation.
//#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#endif
// @section extruder
/**
@ -599,7 +618,7 @@
#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed
//#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber
#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber
A("lds r16, %[timsk0]")/* 2 Load into R0 the Temperature timer Interrupt mask register */ \
A("push r16")/* 2 Save TIMSK0 into the stack */ \
A("andi r16,~%[msk0]")/* 1 Disable the temperature ISR */ \
A("sts %[timsk0], r16")/* 2 And set the new value */ \
A("lds r16, %[timsk1]")/* 2 Load into R0 the stepper timer Interrupt mask register [TIMSK1] */ \
A("andi r16,~%[msk1]")/* 1 Disable the stepper ISR */ \
A("sts %[timsk1], r16")/* 2 And set the new value */ \
A("push r16")/* 2 Save TIMSK1 into stack */ \
A("in r16, 0x3B")/* 1 Get RAMPZ register */ \
A("push r16")/* 2 Save RAMPZ into stack */ \
A("in r16, 0x3C")/* 1 Get EIND register */ \
A("push r0")/* C runtime can modify all the following registers without restoring them */ \
A("push r1") \
A("push r18") \
A("push r19") \
A("push r20") \
A("push r21") \
A("push r22") \
A("push r23") \
A("push r24") \
A("push r25") \
A("push r26") \
A("push r27") \
A("push r30") \
A("push r31") \
A("clr r1")/* C runtime expects this register to be 0 */ \
A("call TIMER1_COMPA_vect_bottom")/* Call the bottom handler - No inlining allowed, otherwise registers used are not saved */ \
A("pop r31") \
A("pop r30") \
A("pop r27") \
A("pop r26") \
A("pop r25") \
A("pop r24") \
A("pop r23") \
A("pop r22") \
A("pop r21") \
A("pop r20") \
A("pop r19") \
A("pop r18") \
A("pop r1") \
A("pop r0") \
A("out 0x3C, r16")/* 1 Restore EIND register */ \
A("pop r16")/* 2 Get the original RAMPZ register value */ \
A("out 0x3B, r16")/* 1 Restore RAMPZ register to its original value */ \
A("pop r16")/* 2 Get the original TIMSK1 value but with stepper ISR disabled */ \
A("ori r16,%[msk1]")/* 1 Reenable the stepper ISR */ \
A("cli")/* 1 Disable global interrupts - Reenabling Stepper ISR can reenter amd temperature can reenter, and we want that, if it happens, after this ISR has ended */ \
A("sts %[timsk1], r16")/* 2 And restore the old value - This reenables the stepper ISR */ \
A("pop r16")/* 2 Get the temperature timer Interrupt mask register [TIMSK0] */ \
A("sts %[timsk0], r16")/* 2 And restore the old value - This reenables the temperature ISR */ \
A("pop r16")/* 2 Get the old SREG value */ \
A("out __SREG__, r16")/* 1 And restore the SREG value */ \
A("lds r16, %[timsk0]")/* 2 Load into R0 the Temperature timer Interrupt mask register */ \
A("andi r16,~%[msk0]")/* 1 Disable the temperature ISR */ \
A("sts %[timsk0], r16")/* 2 And set the new value */ \
A("sei")/* 1 Enable global interrupts - It is safe, as the temperature ISR is disabled, so we cannot reenter it */ \
A("push r16")/* 2 Save TIMSK0 into stack */ \
A("in r16, 0x3B")/* 1 Get RAMPZ register */ \
A("push r16")/* 2 Save RAMPZ into stack */ \
A("in r16, 0x3C")/* 1 Get EIND register */ \
A("push r0")/* C runtime can modify all the following registers without restoring them */ \
A("push r1") \
A("push r18") \
A("push r19") \
A("push r20") \
A("push r21") \
A("push r22") \
A("push r23") \
A("push r24") \
A("push r25") \
A("push r26") \
A("push r27") \
A("push r30") \
A("push r31") \
A("clr r1")/* C runtime expects this register to be 0 */ \
A("call TIMER0_COMPB_vect_bottom")/* Call the bottom handler - No inlining allowed, otherwise registers used are not saved */ \
A("pop r31") \
A("pop r30") \
A("pop r27") \
A("pop r26") \
A("pop r25") \
A("pop r24") \
A("pop r23") \
A("pop r22") \
A("pop r21") \
A("pop r20") \
A("pop r19") \
A("pop r18") \
A("pop r1") \
A("pop r0") \
A("out 0x3C, r16")/* 1 Restore EIND register */ \
A("pop r16")/* 2 Get the original RAMPZ register value */ \
A("out 0x3B, r16")/* 1 Restore RAMPZ register to its original value */ \
A("pop r16")/* 2 Get the original TIMSK0 value but with temperature ISR disabled */ \
A("ori r16,%[msk0]")/* 1 Enable temperature ISR */ \
A("cli")/* 1 Disable global interrupts - We must do this, as we will reenable the temperature ISR, and we don't want to reenter this handler until the current one is done */ \
A("sts %[timsk0], r16")/* 2 And restore the old value */ \
A("pop r16")/* 2 Get the old SREG */ \
A("out __SREG__, r16")/* 1 And restore the SREG value */ \
A("pop r16")/* 2 Restore R16 */ \
A("reti")/* 4 Return from interrupt */ \
: \
:[timsk0]"i"((uint16_t)&TIMSK0), \
[msk0]"M"((uint8_t)(1<<OCIE0B)) \
: \
); \
} \
voidTIMER0_COMPB_vect_bottom()
// ADC
#ifdef DIDR2
#define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
#error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
A("lds r16, %[timsk0]")/* 2 Load into R0 the Temperature timer Interrupt mask register */ \
A("push r16")/* 2 Save TIMSK0 into the stack */ \
A("andi r16,~%[msk0]")/* 1 Disable the temperature ISR */ \
A("sts %[timsk0], r16")/* 2 And set the new value */ \
A("lds r16, %[timsk1]")/* 2 Load into R0 the stepper timer Interrupt mask register [TIMSK1] */ \
A("andi r16,~%[msk1]")/* 1 Disable the stepper ISR */ \
A("sts %[timsk1], r16")/* 2 And set the new value */ \
A("push r16")/* 2 Save TIMSK1 into stack */ \
A("in r16, 0x3B")/* 1 Get RAMPZ register */ \
A("push r16")/* 2 Save RAMPZ into stack */ \
A("in r16, 0x3C")/* 1 Get EIND register */ \
A("push r0")/* C runtime can modify all the following registers without restoring them */ \
A("push r1") \
A("push r18") \
A("push r19") \
A("push r20") \
A("push r21") \
A("push r22") \
A("push r23") \
A("push r24") \
A("push r25") \
A("push r26") \
A("push r27") \
A("push r30") \
A("push r31") \
A("clr r1")/* C runtime expects this register to be 0 */ \
A("call TIMER1_COMPA_vect_bottom")/* Call the bottom handler - No inlining allowed, otherwise registers used are not saved */ \
A("pop r31") \
A("pop r30") \
A("pop r27") \
A("pop r26") \
A("pop r25") \
A("pop r24") \
A("pop r23") \
A("pop r22") \
A("pop r21") \
A("pop r20") \
A("pop r19") \
A("pop r18") \
A("pop r1") \
A("pop r0") \
A("out 0x3C, r16")/* 1 Restore EIND register */ \
A("pop r16")/* 2 Get the original RAMPZ register value */ \
A("out 0x3B, r16")/* 1 Restore RAMPZ register to its original value */ \
A("pop r16")/* 2 Get the original TIMSK1 value but with stepper ISR disabled */ \
A("ori r16,%[msk1]")/* 1 Reenable the stepper ISR */ \
A("cli")/* 1 Disable global interrupts - Reenabling Stepper ISR can reenter amd temperature can reenter, and we want that, if it happens, after this ISR has ended */ \
A("sts %[timsk1], r16")/* 2 And restore the old value - This reenables the stepper ISR */ \
A("pop r16")/* 2 Get the temperature timer Interrupt mask register [TIMSK0] */ \
A("sts %[timsk0], r16")/* 2 And restore the old value - This reenables the temperature ISR */ \
A("pop r16")/* 2 Get the old SREG value */ \
A("out __SREG__, r16")/* 1 And restore the SREG value */ \
A("lds r16, %[timsk0]")/* 2 Load into R0 the Temperature timer Interrupt mask register */ \
A("andi r16,~%[msk0]")/* 1 Disable the temperature ISR */ \
A("sts %[timsk0], r16")/* 2 And set the new value */ \
A("sei")/* 1 Enable global interrupts - It is safe, as the temperature ISR is disabled, so we cannot reenter it */ \
A("push r16")/* 2 Save TIMSK0 into stack */ \
A("in r16, 0x3B")/* 1 Get RAMPZ register */ \
A("push r16")/* 2 Save RAMPZ into stack */ \
A("in r16, 0x3C")/* 1 Get EIND register */ \
A("push r0")/* C runtime can modify all the following registers without restoring them */ \
A("push r1") \
A("push r18") \
A("push r19") \
A("push r20") \
A("push r21") \
A("push r22") \
A("push r23") \
A("push r24") \
A("push r25") \
A("push r26") \
A("push r27") \
A("push r30") \
A("push r31") \
A("clr r1")/* C runtime expects this register to be 0 */ \
A("call TIMER0_COMPB_vect_bottom")/* Call the bottom handler - No inlining allowed, otherwise registers used are not saved */ \
A("pop r31") \
A("pop r30") \
A("pop r27") \
A("pop r26") \
A("pop r25") \
A("pop r24") \
A("pop r23") \
A("pop r22") \
A("pop r21") \
A("pop r20") \
A("pop r19") \
A("pop r18") \
A("pop r1") \
A("pop r0") \
A("out 0x3C, r16")/* 1 Restore EIND register */ \
A("pop r16")/* 2 Get the original RAMPZ register value */ \
A("out 0x3B, r16")/* 1 Restore RAMPZ register to its original value */ \
A("pop r16")/* 2 Get the original TIMSK0 value but with temperature ISR disabled */ \
A("ori r16,%[msk0]")/* 1 Enable temperature ISR */ \
A("cli")/* 1 Disable global interrupts - We must do this, as we will reenable the temperature ISR, and we don't want to reenter this handler until the current one is done */ \
A("sts %[timsk0], r16")/* 2 And restore the old value */ \
A("pop r16")/* 2 Get the old SREG */ \
A("out __SREG__, r16")/* 1 And restore the SREG value */ \