diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index b1b29b58e..41590d4e3 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -10,7 +10,7 @@ // Firmware version #define FW_version "3.1.0" -#define FW_local_variant 6 +#define FW_local_variant 7 #define FW_report_version FW_version " r" STR(FW_local_variant) #define FW_PRUSA3D_MAGIC "PRUSA3DFW" diff --git a/Firmware/MarlinSerial.cpp b/Firmware/MarlinSerial.cpp index ad973a692..4a48a0a56 100644 --- a/Firmware/MarlinSerial.cpp +++ b/Firmware/MarlinSerial.cpp @@ -46,12 +46,8 @@ FORCE_INLINE void store_char(unsigned char c) } } - -//#elif defined(SIG_USART_RECV) #if defined(M_USARTx_RX_vect) - // fixed by Mark Sproul this is on the 644/644p - //SIGNAL(SIG_USART_RECV) - SIGNAL(M_USARTx_RX_vect) + ISR(M_USARTx_RX_vect) { // Test for a framing error. if (M_UCSRxA & (1<decelerate_after after which it decelerates until the trapezoid generator is reset. // The slope of acceleration is calculated with the leib ramp alghorithm. -void st_wake_up() { - // TCNT1 = 0; - ENABLE_STEPPER_DRIVER_INTERRUPT(); -} - unsigned short calc_timer(unsigned short step_rate) { unsigned short timer; if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY; @@ -348,6 +337,13 @@ ISR(TIMER1_COMPA_vect) { } void isr() { + #ifndef LIN_ADVANCE + // Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars) + DISABLE_TEMPERATURE_INTERRUPT(); // Temperature ISR + DISABLE_STEPPER_DRIVER_INTERRUPT(); + sei(); + #endif + // If there is no current block, attempt to pop one from the buffer if (current_block == NULL) { // Anything in the buffer? @@ -366,6 +362,7 @@ void isr() { if(current_block->steps_z > 0) { enable_z(); _NEXT_ISR(2000); //1ms wait + ENABLE_ISRs(); return; } #endif @@ -573,7 +570,8 @@ void isr() { for(uint8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) #ifndef AT90USB - MSerial.checkRx(); // Check for serial chars. + // Not needed - ints are enabled here + //MSerial.checkRx(); // Check for serial chars. #endif #ifdef LIN_ADVANCE @@ -719,6 +717,10 @@ void isr() { plan_discard_current_block(); } } + + #ifndef LIN_ADVANCE + ENABLE_ISRs(); // Re-enable ISRs + #endif } #ifdef LIN_ADVANCE @@ -750,6 +752,11 @@ void isr() { } void advance_isr_scheduler() { + // Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars) + DISABLE_TEMPERATURE_INTERRUPT(); // Temperature ISR + DISABLE_STEPPER_DRIVER_INTERRUPT(); + sei(); + // Run main stepping ISR if flagged if (!nextMainISR) isr(); @@ -777,6 +784,9 @@ void isr() { // Don't run the ISR faster than possible if (OCR1A < TCNT1 + 16) OCR1A = TCNT1 + 16; + + // Restore original ISR settings + ENABLE_ISRs(); } void clear_current_adv_vars() { diff --git a/Firmware/stepper.h b/Firmware/stepper.h index 3427f12fa..20a1dc8f2 100644 --- a/Firmware/stepper.h +++ b/Firmware/stepper.h @@ -102,6 +102,11 @@ void microstep_readings(); void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif +// Interrupt enable/disable macros +#define ENABLE_STEPPER_DRIVER_INTERRUPT() sbi(TIMSK1, OCIE1A) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() cbi(TIMSK1, OCIE1A) + +#define ENABLE_ISRs() do { cli(); if (in_temp_isr) DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0) #endif diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index f249f98f0..48c0cb8ce 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -991,7 +991,7 @@ void tp_init() // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt OCR0B = 128; - TIMSK0 |= (1< -1) @@ -1770,7 +1786,6 @@ ISR(TIMER0_COMPB_vect) ADMUX = ((1 << REFS0) | (TEMP_0_PIN & 0x07)); ADCSRA |= 1<