Hi,
I used a way, maybe can help you if you dont disabled NMI interrupt.
But the correct is disable NMI pin in CPU configuration (remember to switch to advanced mode)
and use a external pull-up in this pin, thats is recommended in User Guide.
rafaeltoledo_0-1608141903762.png
in Events.c file:
/*
** ===================================================================
** Event : Cpu_OnNMIINT (module Events)
**
** Component : Cpu [MKE02Z64QH2]
*/
/*!
** @brief
** This event is called when the Non maskable interrupt had
** occurred. This event is automatically enabled when the [NMI
** interrupt] property is set to 'Enabled'.
*/
/* ===================================================================*/
void Cpu_OnNMIINT(void) {
/* Write your code here ... */
SIM_SOPT = (uint32_t)((SIM_SOPT & (uint32_t)~(uint32_t)(
SIM_SOPT_CLKOE_MASK |
SIM_SOPT_NMIE_MASK
)) | (uint32_t)(
SIM_SOPT_RSTPE_MASK
));
}