grblHAL / iMXRT1062

grblHAL driver for NXP iMXRT1062 (Teensy 4.x)
Other
51 stars 39 forks source link

COOLANT_MIST_PIN changing from pin 24 to any other available pin breaks communication with board after flashing successfully. #74

Closed karoria closed 10 months ago

karoria commented 11 months ago

I am having a weird issue where in my customized board map, when I change pin 24 to other than COOLANT_MIST_PIN or even disabling COOLANT_MIST_PIN breaks USB as well as Ethernet communication after successfully compiling and flashing to Teensy 4.1. Any clues? Here is my board map file for your reference:

if N_ABC_MOTORS > 2

error "Axis configuration is not supported!"

endif

if SPINDLE_SYNC_ENABLE

error "Spindle sync is not supported for T41U5XBB!"

endif

define BOARD_NAME "BOARD_VALAY_V7P6"

define HAS_IOPORTS

define STEPPERS_ENABLE_PIN (30u)

define X_STEP_PIN (2u)

define X_DIRECTION_PIN (3u)

//#define X_ENABLE_PIN (10u)

define X_LIMIT_PIN (19u)

//#define X_LIMIT_PIN_MAX (17u)

define Y_STEP_PIN (4u)

define Y_DIRECTION_PIN (5u)

// #define Y_ENABLE_PIN (40u)

define Y_LIMIT_PIN (20u)

//#define Y_LIMIT_PIN_MAX (21u)

define Z_STEP_PIN (6u)

define Z_DIRECTION_PIN (7u)

// #define Z_ENABLE_PIN (39u)

define Z_LIMIT_PIN (21u)

//#define Z_LIMIT_PIN_MAX (23u) // Define ganged axis or A axis step pulse and step direction output pins.

if N_ABC_MOTORS > 0

define M3_AVAILABLE

define M3_STEP_PIN (8u)

define M3_DIRECTION_PIN (9u)

define M3_LIMIT_PIN (22u)

//#define M3_ENABLE_PIN (38u)

endif

// Define ganged axis or B axis step pulse and step direction output pins.

if N_ABC_MOTORS == 2

define M4_AVAILABLE

define M4_STEP_PIN (10u)

define M4_DIRECTION_PIN (11u)

define M4_LIMIT_PIN (23u)

//#define M4_ENABLE_PIN (37u)

endif

// Define spindle enable and spindle direction output pins.

define SPINDLE_ENABLE_PIN (28u)

define SPINDLE_DIRECTION_PIN (29u)

define SPINDLE_PWM_PIN (12u) // NOTE: only pin 12 or pin 13 (LED) can be assigned!

// Define flood and mist coolant enable output pins.

define COOLANT_FLOOD_PIN (25u)

define COOLANT_MIST_PIN (24u)

// Define user-control CONTROLs (cycle start, reset, feed hold, door) input pins.

define RESET_PIN (41u)

define FEED_HOLD_PIN (40u)

define CYCLE_START_PIN (39u)

define SAFETY_DOOR_PIN (14u)

define ESTOP_PIN (17u)

if MOTOR_FAULT_ENABLE

define MOTOR_FAULT_PIN (16u)

endif

//For LED blink plugin //#define LED_BUILTIN (13u) // Define probe switch input pin.

define PROBE_PIN (18u)

if QEI_ENABLE

define QEI_A_PIN (30u) // ST1

define QEI_B_PIN (34u) // ST2

define QEI_SELECT_PIN (35u) // ST3

endif

// Define auxillary input pins

define AUXINPUT0_PIN (36u) // ST0

if !QEI_ENABLE

define AUXINPUT1_PIN (37u) // ST1

define AUXINPUT2_PIN (38u) // ST2

define AUXINPUT3_PIN (15u) // ST3

endif

define AUXOUTPUT0_PIN (33u) // AUX0 13 is LED pin, 24 is mist pin, 33 is final

define AUXOUTPUT1_PIN (34u) // AUX1

define AUXOUTPUT2_PIN (35u) // AUX2

//#define AUXOUTPUT3_PIN (32u) // AUX3

if KEYPAD_ENABLE

define KEYPAD_STROBE_PIN (41u) // I2C ST

endif

//#if EEPROM_ENABLE || KEYPAD_ENABLE //#if I2C_ENABLE //#define I2C_PORT 4 //#define I2C_SCL4 (24u) // Not referenced, for info only //#define I2C_SDA4 (25u) // Not referenced, for info only //#endif

terjeio commented 11 months ago

Oops, guards for the mist pin not beeing defined is missing, change this code to:

// Start/stop coolant (and mist if enabled).

// coolant_state_t is defined in grbl/coolant_control.h.
static void coolantSetState (coolant_state_t mode)
{
    mode.value ^= settings.coolant_invert.mask;

    DIGITAL_OUT(Flood, mode.flood);
#ifdef COOLANT_MIST_PIN
    DIGITAL_OUT(Mist, mode.mist);
#endif
}

// Returns coolant state in a coolant_state_t variable.
// coolant_state_t is defined in grbl/coolant_control.h.
static coolant_state_t coolantGetState (void)
{
    coolant_state_t state = { settings.coolant_invert.mask };

    state.flood = (Flood.reg->DR & Flood.bit) != 0;
#ifdef COOLANT_MIST_PIN
    state.mist = (Mist.reg->DR & Mist.bit) != 0;
#endif
    state.value ^= settings.coolant_invert.mask;

    return state;
}

Does this make it work?

karoria commented 11 months ago

Thanks. I am out of station for some days. When I check, will inform you here.

karoria commented 10 months ago

Does this make it work?

That works @terjeio. Thanks! Please merge it in next commit.

terjeio commented 10 months ago

It is already merged.