MKE02z issue using SWD_CLK as GPIO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKE02z issue using SWD_CLK as GPIO

125 Views
PabloBajista
Contributor I

Hi.

 

I made a custom PCB with a MKE02Z32VLD2 (44 pins), and I need to use SWD_CLK and SWD_DIO as GPIO, which are PTC4 and PTA4 respectively.

 

The MCU halts at power-up. If I left unconnected PTC4, the MCU works perfectly, so I suspect the problem is a transient while power-up sequence, which produce noise on PTC4 before  enable PTA4 and PTC4 as GPIO with the next code:

 

SIM->SOPT &= ~(uint32_t)SIM_SOPT_SWDE_MASK;

 

MCU interprets this as a failed attempt to connect the debugger, and because that MCU halts.

 

The problem is really I don’t know how to fix it. Before this, I had another issue like this with PTB4 pin, which behaves as NMI by default but I needed to us it as GPIO. MCU halted, so I found the solution in the next topic:

 

https://community.nxp.com/t5/Kinetis-Microcontrollers/powering-up-issue-on-MKE02Z-GPIO/m-p/544613#M3...

 

But in my case, I have no idea how to fix this issue. Anyone could help me, please?

 

Thanks.

Labels (1)
0 Kudos
Reply
1 Reply

49 Views
Celeste_Liu
NXP Employee
NXP Employee

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.

Celeste_Liu_0-1763538977122.png

Hope it helps.

BR

Celeste

 

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

0 Kudos
Reply