Hello @PabloBajista ,
Thanks for your post.
First it's not recommended due to it will effect SWD function when you want to debug it again.
You may need to recover it by specify method: Bricking and Recovering FRDM-KL25Z Boards: Reset, SWD Clock and Low Power
In addition, where did you put the code below?
SIM->SOPT &= ~(uint32_t)SIM_SOPT_SWDE_MASK;
Software:
SWDE is not write‑once, but it is also enabled by default after a reset, and requires software to clear it at the earliest stage. Please modify the startup code or early initialization to clear the SWDE bit in SIM_SOPT before any other GPIO configurations. This disables the SWD function immediately, preventing the MCU from responding to noise on PTC4/PTA4.
Hardware:
I recommend you add a 10~47kΩ pull-down resistor to PTC4 (SWD_CLK) on the PCB. This stabilizes the pin level during power-up, reducing false SWD triggers. Add 47–100 pF to ground to form an RC filter if necessary, optimize the wiring and interference isolation.
You can also clear PORT_PUEL[PTCPE4] to 0.

Hope it helps.
BR
Celeste
--------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the "ACCEPT AS SOLUTION" button. Thank you!
--------------------------------------------------------------------------------------------------------------------