Under what circumstances does NMI happen?

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

Under what circumstances does NMI happen?

1,552 Views
joeygouly
Contributor IV

Hi,

When exactly does an NMI interrupt happen? I thought it was strictly related to the NMI_b pin being asserted. However it seems it's happening at other times during execution, and I can't figure out why.

This is on MKL27Z.

Thanks,

Joey

Labels (1)
0 Kudos
8 Replies

977 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Joey,

    If the NMI_b pin asserted, and you already add the NMI interupt service code, the code will enter in the NMI interrupt handler.

  Let's take KSDK2.0-FRDM-KL27 as an example, you can download it from this link:

Welcome to Kinetis Expert | Kinetis Expert

  Choose board as FRDM-KL27, and generate the KSDK2.0-FRDM-KL27 sample code, modify the :SDK_2.0_FRDM-KL27Z\boards\frdmkl27z\demo_apps\hello_world

  hello_world.c and the NMI interrupt handler code:

void NMI_Handler(void)

{

  PRINTF("NMI interrupt.\r\n");

}

After you build and download the code to your FRDM-KL27, when you press the NMI button, the code will enter NMI_Handler, and printf : NMI interrupt

This is the test result from my side after assert the RESET_b pin:

71.jpg

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

977 Views
joeygouly
Contributor IV

Hi,

Is the NMI_b pin the *ONLY* way of the NMI interrupt firing? I'm seeing my NMI interrupt firing when I'm not intentionally asserting that pin.

Joey

0 Kudos

977 Views
rastislav_pavlanin
NXP Employee
NXP Employee

Hi Joey,

if you have not asserted that pin and it has entered NMI inetrrupt handler then it can be caused by some voltage disturbancies on your board (dependes on PCB layout, power supply, etc.). Especially, it can happend after POR (power on reset) that the capacity + pull up on the NMI pin is not correctly selected (the time constant of rising voltage on NMI pin is slower than power supply). If you think this is not you problem, then chceck whether you have correctly assigned interrupts/expections handler to appropriate vectors. It can happed that the other vector call NMI handler (e.g. hardfalut which can be called by some sporadicall software issue - misalignment etc.).

regards

R.

0 Kudos

977 Views
joeygouly
Contributor IV

No other functions call the NMI isr directly. So I think it might be that I don't have the external pull up, as described above.

0 Kudos

977 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Joey,

  Please add 4.7K to 10K pullup resistor in the NMI pin, and try again.

  After test, please tell us your test result!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

977 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Joey,

    Is the board designed by yourself?

   Did you add an 4.7K to 10K external pullup resistor in the NMI_b pin?

   If you don't add the external pullup resistor, because the internal pullup is weak, the NMI pin maybe interrupt by some interference signal, this also will caused the NMI interrupt.

  So, please check the external pullup resistor.

Have a great day,

Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

977 Views
joeygouly
Contributor IV

Thanks, this might be the answer. It's a board I designed and I didn't add an external pull-up resistor to my NMI pin.

I'm using the MCU with 5v from USB. I assume the pull-up resistor should be connected to VOUT33 (aka 3v)?

For now I'll either try to patch the PCB or I'll look at using the RESET button and checking the reason for reset. If it was via the button I will jump to the bootloader otherwise I will continue with normal execution.

0 Kudos

977 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Joey,

  The pull-up resistor should be connected to the VDD, 3.3V. If your VDD is connected to the VOUT33, you can use VOUT33 as the pull-up points.

    You said: I'll look at using the RESET button and checking the reason for reset.

Do you mean your reset pin always have the sawtooth wave? If yes, to an new chip which have not been programmed, it is correct, after the chip have the code, the reset pin will be high.

    Now, because your NMI already been interrupt, I suggest you add external pull-up, actually, in our KL quick start guide, chapter2.1.3.4.1 RESET_b and NMI_b, we recommend customer add the pull-up in the reset and NMI pin.


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos