Make the diag pins open collector with pullup.
Solves random crash detected on startup
This commit is contained in:
parent
bb57d99c35
commit
510f13b24a
4 changed files with 22 additions and 32 deletions
|
@ -2201,7 +2201,7 @@ bool calibrate_z_auto()
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
static void check_Z_crash(void)
|
static void check_Z_crash(void)
|
||||||
{
|
{
|
||||||
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
if (!READ(Z_TMC2130_DIAG)) { //Z crash
|
||||||
FORCE_HIGH_POWER_END;
|
FORCE_HIGH_POWER_END;
|
||||||
current_position[Z_AXIS] = 0;
|
current_position[Z_AXIS] = 0;
|
||||||
plan_set_position_curposXYZE();
|
plan_set_position_curposXYZE();
|
||||||
|
|
|
@ -974,7 +974,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (READ(Z_TMC2130_DIAG) != 0)
|
if (!READ(Z_TMC2130_DIAG))
|
||||||
{
|
{
|
||||||
//printf_P(PSTR("crash detected 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
|
//printf_P(PSTR("crash detected 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
|
||||||
goto error; //crash Z detected
|
goto error; //crash Z detected
|
||||||
|
@ -1011,7 +1011,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (READ(Z_TMC2130_DIAG) != 0) {
|
if (!READ(Z_TMC2130_DIAG)) {
|
||||||
//printf_P(PSTR("crash detected 2, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
|
//printf_P(PSTR("crash detected 2, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
|
||||||
goto error; //crash Z detected
|
goto error; //crash Z detected
|
||||||
}
|
}
|
||||||
|
@ -2857,7 +2857,7 @@ bool sample_mesh_and_store_reference()
|
||||||
homeaxis(Z_AXIS);
|
homeaxis(Z_AXIS);
|
||||||
|
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (!axis_known_position[Z_AXIS] && (READ(Z_TMC2130_DIAG) != 0)) //Z crash
|
if (!axis_known_position[Z_AXIS] && (!READ(Z_TMC2130_DIAG))) //Z crash
|
||||||
{
|
{
|
||||||
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -495,7 +495,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
#if ( (defined(X_MIN_PIN) && (X_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMINLIMIT)
|
#if ( (defined(X_MIN_PIN) && (X_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMINLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
SET_BIT_TO(_endstop, X_AXIS, (READ(X_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, X_AXIS, (!READ(X_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
SET_BIT_TO(_endstop, X_AXIS, (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, X_AXIS, (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING));
|
||||||
|
@ -512,7 +512,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
#if ( (defined(X_MAX_PIN) && (X_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMAXLIMIT)
|
#if ( (defined(X_MAX_PIN) && (X_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_XMAXLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
SET_BIT_TO(_endstop, X_AXIS + 4, (READ(X_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, X_AXIS + 4, (!READ(X_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
SET_BIT_TO(_endstop, X_AXIS + 4, (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, X_AXIS + 4, (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING));
|
||||||
|
@ -536,7 +536,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
#if ( (defined(Y_MIN_PIN) && (Y_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMINLIMIT)
|
#if ( (defined(Y_MIN_PIN) && (Y_MIN_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMINLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
SET_BIT_TO(_endstop, Y_AXIS, (READ(Y_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, Y_AXIS, (!READ(Y_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
SET_BIT_TO(_endstop, Y_AXIS, (READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Y_AXIS, (READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING));
|
||||||
|
@ -553,7 +553,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
#if ( (defined(Y_MAX_PIN) && (Y_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMAXLIMIT)
|
#if ( (defined(Y_MAX_PIN) && (Y_MAX_PIN > -1)) || defined(TMC2130_SG_HOMING) ) && !defined(DEBUG_DISABLE_YMAXLIMIT)
|
||||||
#ifdef TMC2130_SG_HOMING
|
#ifdef TMC2130_SG_HOMING
|
||||||
// Stall guard homing turned on
|
// Stall guard homing turned on
|
||||||
SET_BIT_TO(_endstop, Y_AXIS + 4, (READ(Y_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, Y_AXIS + 4, (!READ(Y_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
// Normal homing
|
// Normal homing
|
||||||
SET_BIT_TO(_endstop, Y_AXIS + 4, (READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Y_AXIS + 4, (READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING));
|
||||||
|
@ -579,7 +579,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
||||||
else
|
else
|
||||||
#endif //TMC2130_STEALTH_Z
|
#endif //TMC2130_STEALTH_Z
|
||||||
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (!READ(Z_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
|
@ -601,7 +601,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
SET_BIT_TO(_endstop, Z_AXIS + 4, 0);
|
SET_BIT_TO(_endstop, Z_AXIS + 4, 0);
|
||||||
else
|
else
|
||||||
#endif //TMC2130_STEALTH_Z
|
#endif //TMC2130_STEALTH_Z
|
||||||
SET_BIT_TO(_endstop, Z_AXIS + 4, (READ(Z_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, Z_AXIS + 4, (!READ(Z_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
SET_BIT_TO(_endstop, Z_AXIS + 4, (READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Z_AXIS + 4, (READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING));
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
|
@ -634,7 +634,7 @@ FORCE_INLINE void stepper_check_endstops()
|
||||||
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
||||||
else
|
else
|
||||||
#endif //TMC2130_STEALTH_Z
|
#endif //TMC2130_STEALTH_Z
|
||||||
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0));
|
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (!READ(Z_TMC2130_DIAG)));
|
||||||
#else
|
#else
|
||||||
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
SET_BIT_TO(_endstop, Z_AXIS, (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING));
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
|
@ -1179,22 +1179,6 @@ void st_init()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//endstops and pullups
|
//endstops and pullups
|
||||||
|
|
||||||
#ifdef TMC2130_SG_HOMING
|
|
||||||
SET_INPUT(X_TMC2130_DIAG);
|
|
||||||
WRITE(X_TMC2130_DIAG,HIGH);
|
|
||||||
|
|
||||||
SET_INPUT(Y_TMC2130_DIAG);
|
|
||||||
WRITE(Y_TMC2130_DIAG,HIGH);
|
|
||||||
|
|
||||||
SET_INPUT(Z_TMC2130_DIAG);
|
|
||||||
WRITE(Z_TMC2130_DIAG,HIGH);
|
|
||||||
|
|
||||||
SET_INPUT(E0_TMC2130_DIAG);
|
|
||||||
WRITE(E0_TMC2130_DIAG,HIGH);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
||||||
SET_INPUT(X_MIN_PIN);
|
SET_INPUT(X_MIN_PIN);
|
||||||
#ifdef ENDSTOPPULLUP_XMIN
|
#ifdef ENDSTOPPULLUP_XMIN
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
#define TMC2130_GCONF_NORMAL 0x00000000 // spreadCycle
|
#define TMC2130_GCONF_NORMAL 0x00000000 // spreadCycle
|
||||||
#define TMC2130_GCONF_SGSENS 0x00003180 // spreadCycle with stallguard (stall activates DIAG0 and DIAG1 [pushpull])
|
#define TMC2130_GCONF_SGSENS 0x00000180 // spreadCycle with stallguard (stall activates DIAG0 and DIAG1 [open collector])
|
||||||
#define TMC2130_GCONF_SILENT 0x00000004 // stealthChop
|
#define TMC2130_GCONF_SILENT 0x00000004 // stealthChop
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,10 +152,16 @@ void tmc2130_init(TMCInitParams params)
|
||||||
SET_OUTPUT(Y_TMC2130_CS);
|
SET_OUTPUT(Y_TMC2130_CS);
|
||||||
SET_OUTPUT(Z_TMC2130_CS);
|
SET_OUTPUT(Z_TMC2130_CS);
|
||||||
SET_OUTPUT(E0_TMC2130_CS);
|
SET_OUTPUT(E0_TMC2130_CS);
|
||||||
|
|
||||||
SET_INPUT(X_TMC2130_DIAG);
|
SET_INPUT(X_TMC2130_DIAG);
|
||||||
SET_INPUT(Y_TMC2130_DIAG);
|
SET_INPUT(Y_TMC2130_DIAG);
|
||||||
SET_INPUT(Z_TMC2130_DIAG);
|
SET_INPUT(Z_TMC2130_DIAG);
|
||||||
SET_INPUT(E0_TMC2130_DIAG);
|
SET_INPUT(E0_TMC2130_DIAG);
|
||||||
|
WRITE(X_TMC2130_DIAG,HIGH);
|
||||||
|
WRITE(Y_TMC2130_DIAG,HIGH);
|
||||||
|
WRITE(Z_TMC2130_DIAG,HIGH);
|
||||||
|
WRITE(E0_TMC2130_DIAG,HIGH);
|
||||||
|
|
||||||
for (uint_least8_t axis = 0; axis < 2; axis++) // X Y axes
|
for (uint_least8_t axis = 0; axis < 2; axis++) // X Y axes
|
||||||
{
|
{
|
||||||
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
||||||
|
@ -224,10 +230,10 @@ void tmc2130_init(TMCInitParams params)
|
||||||
uint8_t tmc2130_sample_diag()
|
uint8_t tmc2130_sample_diag()
|
||||||
{
|
{
|
||||||
uint8_t mask = 0;
|
uint8_t mask = 0;
|
||||||
if (READ(X_TMC2130_DIAG)) mask |= X_AXIS_MASK;
|
if (!READ(X_TMC2130_DIAG)) mask |= X_AXIS_MASK;
|
||||||
if (READ(Y_TMC2130_DIAG)) mask |= Y_AXIS_MASK;
|
if (!READ(Y_TMC2130_DIAG)) mask |= Y_AXIS_MASK;
|
||||||
// if (READ(Z_TMC2130_DIAG)) mask |= Z_AXIS_MASK;
|
// if (!READ(Z_TMC2130_DIAG)) mask |= Z_AXIS_MASK;
|
||||||
// if (READ(E0_TMC2130_DIAG)) mask |= E_AXIS_MASK;
|
// if (!READ(E0_TMC2130_DIAG)) mask |= E_AXIS_MASK;
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue