Hello,
The NXP - MKL03Z32VFK4 chip is experiencing a strange behaviour during boot-up due to the NMI pin being used as a peripheral.
PTB5 (Port B Pin 5) on the M0 chip has NMI activated as default (as mentioned in the data sheet). This pin needs to be used as a peripheral input to the ADC (ADC0_SE1), but while booting up the NMI is always triggered and the code execution gets stuck in the NMI handler. This is condition is true when using a debugger or while just running.
The NMI was disabled by changing the FOPT register in the startup file from 0x3F to 0x3B, as indicated in the reference manual.
After this change:
1. The NMI does not trigger while starting up
2. The system takes about 5 seconds to start (i.e for the execution to enter the main function) - This is a random condition, does not occur always.
3. When the above condition occurs LPUART Tx Rx does not happen.
Is there any way to disable the NMI function on the M0 chip or atleast make sure the NMI does not trigger before changing the PIN MUX to enable the ADC function on the pin?
I am using the Segger j-link base version for debugging and Keil IDE for development. I have also attached the .s file that I am using at the moment.
Thanks in advance,
Mrudhul
Hi James,
I did eventually get it to work, but given that I encountered this problem over 2 years ago, I cannot fully recall the solution. I have reattached my startup files which work.
And I also followed this, "PTB3 and PTB4 are true open drain pins. The external pullup resistor must be added to make them output correct values in using I2C, GPIO, and LPUART0". This is mentioned as a note in the datasheet just before the pinouts.
Hope this helps.
Best Regards,
Mrudhul
Thanks Mrudhul,
I did get my system working. For me, I had to change the FOPT value of the flash configuraiton in startup_mkl03z4.c to 0x3B. That set it to boot from flash and ignore the NMI pin altogether. With that, it worked as expected.
Cheers,
James.
Hi Ankur,
Thanks for your reply, but I have already tried to disable the NMI function [NMI_DIS in Flash Option Register - which is in the FOPT register].
In my current configuration my BOOT source is selected as flash and I have disabled the NMI by setting the NMI_DIS bit to 0. This change successfully disables the NMI but I run into another problem when I make this change. My LPUART stops functioning until I do system reset.
I am not sure if my LPUART interrupts are also being affected by this change. Is there any work around for this??
Best Regards,
Mrudhul
Mrudhul, did you ever figure this out? I have a very similar problem.
Hi,
Please have a look at the following thread:
https://community.nxp.com/thread/457305
Hope it helps.