From 135dda1bff765a5297b55bc904ea8b13022b99cf Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 12 Jan 2018 21:01:01 +0100 Subject: [PATCH] Slight optimization of the stepper timer routine. Use WRITE_NC instead of WRITE for writing into the slow ports. --- Firmware/stepper.cpp | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 352f243c..38ece7ea 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -432,27 +432,27 @@ void isr() { // Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY) if((out_bits & (1<steps_x; if (counter_x > 0) { - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN); LastStepMask |= X_AXIS_MASK; #ifdef DEBUG_XSTEP_DUP_PIN - WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN); + WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN); #endif //DEBUG_XSTEP_DUP_PIN counter_x -= current_block->step_event_count; count_position[X_AXIS]+=count_direction[X_AXIS]; - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE_NC(X_STEP_PIN, INVERT_X_STEP_PIN); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN); + WRITE_NC(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN); #endif //DEBUG_XSTEP_DUP_PIN } counter_y += current_block->steps_y; if (counter_y > 0) { - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN); LastStepMask |= Y_AXIS_MASK; #ifdef DEBUG_YSTEP_DUP_PIN - WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN); + WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN); #endif //DEBUG_YSTEP_DUP_PIN #ifdef Y_DUAL_STEPPER_DRIVERS - WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE_NC(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE_NC(Y_STEP_PIN, INVERT_Y_STEP_PIN); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN); + WRITE_NC(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN); #endif //DEBUG_YSTEP_DUP_PIN #ifdef Y_DUAL_STEPPER_DRIVERS - WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE_NC(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif } counter_z += current_block->steps_z; if (counter_z > 0) { - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN); LastStepMask |= Z_AXIS_MASK; #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); + WRITE_NC(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; - WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); + WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); + WRITE_NC(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif } @@ -853,7 +853,7 @@ void isr() { // interrupt repeats at a 100us rate (10kHz). if (OCR1A < TCNT1) { stepper_timer_overflow_state = true; - WRITE(BEEPER, HIGH); + WRITE_NC(BEEPER, HIGH); } #endif } @@ -871,12 +871,12 @@ void advance_isr() { (e_steps < 0) #endif ? INVERT_E0_DIR : !INVERT_E0_DIR; //If we have SNMM, reverse every second extruder. - WRITE(E0_DIR_PIN, dir); + WRITE_NC(E0_DIR_PIN, dir); for (uint8_t i = step_loops; e_steps && i--;) { - WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); + WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN); e_steps < 0 ? ++e_steps : --e_steps; - WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); + WRITE_NC(E0_STEP_PIN, INVERT_E_STEP_PIN); #ifdef PAT9125 fsensor_counter++; #endif //PAT9125