SD busy when using PAUSE / RESUME

I have a macro to change extruder temp at a given momento of the print (it's intended to be inserted as custom gcode at some places).
[gcode_macro _SET_LAYER_TEMP]
description: Pauses, changes temperature and resumes
gcode:
    {% set previous_target = printer.extruder.target %}
    PAUSE
    #G4 P1000
    M109 S{params.TEMP|default(previous_target) }
    RESUME


I can use the macro from the console all day long without issues, but as soon as I use it inside a gcode file, I get SD busy error and the print stops. No matter if it is in a real gcode file or a gcode file with just a single line calling the macro.

I tried with a simple G4 command instead of the M109 and even without any command between PASUSE and RESUME, just calling them back to back. Same result always: calling the macro from the console: OK, calling it from within a file: SD busy.

Another piece of info: I get the same error just by calling PAUSE / RESUME back to back from within a gcode file, without using the macro.

Does anyone have an idea of whats going on? I noticed it while trying to use this macro, but now I'm afraid it can affect me in filament changes or other PAUSE / RESUME situations.
Was this page helpful?