How to diable NMI on a PIN to make it a GPIO

cancel
Showing results for 
Search instead for 
Did you mean: 

How to diable NMI on a PIN to make it a GPIO

80 Views
Contributor I

Hi 

I am working with FRDM-KE06Z.

I have few doubts . I am new to microcontroller programming. in the microcontroller I see that PTB4 is default a NMI pin. Actually I wanted to use it as a GPIO. How can I make that pin a GPIO. Which register I should look into?.

Also another question that I would like to write some value to the register PORT_FILTER0. 

I dont see the macro to access the register.

I found the address macro in MKE06Z4.h. like below

#define PORT_BASE (0x40049000u)
/** Peripheral PORT base pointer */
#define PORT ((PORT_Type *)PORT_BASE)
/** Array initializer of PORT peripheral base addresses */
#define PORT_BASE_ADDRS { PORT_BASE }
/** Array initializer of PORT peripheral base pointers */
#define PORT_BASE_PTRS { PORT }

In the main.c file I made a small function like below to write some data in to the register.

void Glitch_Filter(PORT_Type *base)
{
base-> IOFLT0 = 0x40020003;
}

Is that right?. 

1 Reply

14 Views
NXP TechSupport
NXP TechSupport

Hi Mohan, I hope you're doing well!

 

In chapter 10 of the KW06 Reference Manual there's a Pinout table describing the possible configuration for alternative functions of each pin, and from it, we can determine that to set the NMI pin to PTB4, we have to choose ALT0:

 pastedImage_1.png

This can be done by using the PORT_SetPinSelect function with the following arguments:

 

/* disable NMI function on pin 23 */
    PORT_SetPinSelect(kPORT_NMI, kPORT_NMI_OTHERS);

 

This function automatically disables the NMI and sets the alternative configuration based on priority (ALT0 being the least and ALT7 being the most prioritized). If no higher priority port is enabled, the pin will then be set as ALT0, with enables its functionality as PTB4.

 

Please let me know if you need any more information.

 

Best regards,

Sebastian