Could NMI/PTA4 pin for MKL16Z128VFM4 function both NMI and Input/output with interrupt?

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

Could NMI/PTA4 pin for MKL16Z128VFM4 function both NMI and Input/output with interrupt?

1,352 Views
sheng_deng
Contributor II

Hi,

Could NMI/PTA4 pin be both NMI and GPIO with interrupt?  I have tried enabling NMI, which generate

Cpu_OnNMIINT function that I could use to tell NMI is interrupt.   For the GPIO, I used BitIO with ExtInt_LDD.  When I ran the code, it seem the GPIO interrupt is not triggering.  Anyone have any guideline or example to get these working?  Currently, I used processor expert to set things up.  Thanks for the help.

0 Kudos
9 Replies

1,144 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Sheng Deng,

This pin is default as NMI_b function.
PORTA_PCR4[MUX] can be used to switch the PTA4 pin from NMI_b function to GPIO function.  

PTA4 ALT1 NMI_b ALT7.png

PORTA_PCR4[MUX].png

Due to NMI interrupt is enabled by default. You may need to disable the NMI interrupt by clear FTFA_FOPT[NMI_DIS]. (Notice: The new settings will take effect on subsequent POR, VLLSx recoveries, and any system reset.)

6.3.2 FOPT boot options.png

I am confused why you want to use both NMI interrupts and GPIO interrupts at this pin.

Best Regards,

Robin

 

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

0 Kudos

1,144 Views
sheng_deng
Contributor II

Hi Robin,

Above you describe changing the NMI_B to GPIO function, what about adding an interrupt to the GPIO function once its switch over?  Is it possible to do?

The only reason I am using the NMI as NMI interrupts and GPIO interrupt is a legacy design.  Is it recommended to use one of the LLWU pin to do what I want better then NMI if the choice is available?

Thanks,

Sheng

0 Kudos

1,144 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Sheng,

Can you tell us what functions NMI and GPIO interrupts want to achieve under each situation?

Want to use the NMI function wake up MCU from  low power modes?
Use GPIO interrupt function as external event trigger source?

Must use the same pin?

Best Regards,

Robin

0 Kudos

1,144 Views
sheng_deng
Contributor II

Hi Robin,

In the current board layout,  NMI pin is use as the below function.

 

Want to use the NMI function wake up MCU from  low power modes?

-Yes


Use GPIO interrupt function as external event trigger source?

-Yes

Must use the same pin?

-Yes

Here is a more detail description.

Once the system enter low power modes:

   When the daughter board want to transfer data, it will pulse the NMI from high to Low to wake up the system from sleep. 

When the system is not in low power mode:

   When MCU want to transfer data to the daughter board, NMI will act like a GPIO OUTPUT and pulse high to low then change back to GPIO INPUT with Interrupt as external event trigger to wait for when the daughter board want to transfer data.

Thanks,

Sheng

0 Kudos

1,144 Views
mjbcswitzerland
Specialist V

Hi

Which low power mode is low power mode?

Can NMI wake you from the one you want to use?

Regards

Mark

0 Kudos

1,144 Views
sheng_deng
Contributor II

Hi Mark,

Which low power mode is low power mode?

 -low leakage stop 

Can NMI wake you from the one you want to use?

- From the spec, it should be able to wake up form low leakage stop mode.

Do you know any example that does what I want to do with the nmi?  Or is it better to use another pin, such as llwu pin?

Thanks,

Sheng

0 Kudos

1,144 Views
mjbcswitzerland
Specialist V

Hi

I did initially think that NMI wouldn't allow wake up from a low leakage mode since it is not in the list of low leakage wake-up sources:

pastedImage_2.png

But when I tried it it did work.

Then I noticed a note:

pastedImage_3.png

where it is indeed specified.

I don't know whether this is what you based your decision on but it is OK.

I have attached a FRDM-KL26Z binary to show it working:

1. On the Open SDA UART VCOM at 115200 Baud there is a menu.
Enter the menu item 4 (Administrator)


2. List the low power modes supported by the chip with "show_lp"

RUN = 0
WAIT = 1 [active]
STOP = 2
VLPR = 3
VLPS = 4
LLS = 5
VLLS0 = 6
VLLS1 = 7
VLLS3 = 8

3. Select whatever low power mode you want to check to set the system to it - eg. "set_lp 5" to put it to LLS
I this state the current consumption can be verified.

4. Press the SW1 button to wake up from the mode using LLWU port input method.

5. Repeat and apply a short '0' to the NMI pin to verify that it behaves the same.

Regards

Mark

Complete KL26 solutions, training and support:http://www.utasker.com/kinetis.html
Kinetis KL26:
http://www.utasker.com/kinetis/FRDM-KL26Z.html
http://www.utasker.com/kinetis/TEENSY_LC.html

0 Kudos

1,144 Views
sheng_deng
Contributor II

Hi Mark,

Thank you for verifying its possible to use NMI in the way I describe.  Unfortunately, I do not have FRDM-KL26Z.  From your previous reply, I think you did not use PE to accomplish this.  Could you be able to share your code or thoughts on how you make this work?   I been trying to get this work with PE only.

Thanks,

Sheng

0 Kudos

1,144 Views
mjbcswitzerland
Specialist V

Hi

You can switch between NMI and GPIO interrupt (or DMA) modes on PTA4.

In the uTasker project I can do it like this by calling fnConfigIRQ()  [see reference code below] to use it as GPIO interrupt and then call fnConfigureNMI() to switch it to NMI interrupt handling, followed by fnConfigIRQ(), etc. etc.

static void test_irq_PTA4(void)
{
    // toggle LED
}

extern void fnConfigureIRQ(void)
{
    INTERRUPT_SETUP interrupt_setup;                                     // interrupt configuration parameters
    interrupt_setup.int_type       = PORT_INTERRUPT;                     // identifier to configure port interrupt
    interrupt_setup.int_handler    = test_irq_PTA4;                      // handling function
    interrupt_setup.int_priority   = PRIORITY_PORT_A_INT;                // interrupt priority level
    interrupt_setup.int_port       = PORTA;                              // the port that the interrupt input is on
    interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON);     // interrupt is to be falling edge sensitive
    fnConfigureInterrupt((void *)&interrupt_setup);                      // configure interrupt
}

static void test_nmi_PTA4(void)
{
    // toggle LED
}

extern void fnConfigureNMI(void)
{
    fnEnterNMI(test_nmi_PTA4);                                           // enter NMI handler and configure the pin as NMI
}

I don't know any details about whether PE generated code can.

Beware when the NMI pin is not disabled in that a '0' on the input at reset causes the NMI vector (at address 0x00000008) to be immediately taken and so there needs to be a handler that clears the interrupt and allows the processor to continue. This handling is automated in the uTasker project  so that such issues are not experienced.

Regards

Mark

Complete KL26 solutions, training and support:http://www.utasker.com/kinetis.html
Kinetis KL26:
http://www.utasker.com/kinetis/FRDM-KL26Z.html
http://www.utasker.com/kinetis/TEENSY_LC.html

0 Kudos