cprezzi / grbl-LPC

Multiple compiled versions for different boards & machines (under releases)
Other
56 stars 39 forks source link

[solved] M9 don't stop M8 Pin #24

Closed gerrylenz closed 4 years ago

gerrylenz commented 5 years ago

M8 will set pin high or low but M9 will not set it back again.

original code in coolant_control.c

void coolant_stop()
{
  #ifdef INVERT_COOLANT_FLOOD_PIN
    COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
  #else
    COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
  #endif
  #ifdef ENABLE_M7
    #ifdef INVERT_COOLANT_MIST_PIN
      COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
    #else
      COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
    #endif
  #endif
}

change to

void coolant_stop()
{
  #ifdef INVERT_COOLANT_FLOOD_PIN
    COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
    delay_ms(1);
  #else
    COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
    delay_ms(1);
  #endif

  #ifdef ENABLE_M7
    #ifdef INVERT_COOLANT_MIST_PIN
      COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
    delay_ms(1);
    #else
      COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
    delay_ms(1);
    #endif
  #endif
}

In block #ifdef ENABLE_M7 i write too delays im not sure is necessary. I think this is a bug in toolchain.

Regards Gerry

cprezzi commented 5 years ago

Interesting. It doesn't make sense that a delay has any effect on this.

gerrylenz commented 5 years ago

I think the compilers optimization is wrong.

cprezzi commented 5 years ago

That might be. I will make some tests...

cprezzi commented 4 years ago

I have added this workaround to the code, which seems to solve the issue.