GPIO pin as interrupt source

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

GPIO pin as interrupt source

1,382 Views
huishao2
Contributor IV

Hi-

The mode i am using is MK20DX256VMX7. I have a GPIO pin PTC8 initially set as input and interrupt source. If I change the pin later in code to toggling as code below, will it trigger interrupt?

   /* testing on PTC8: turn off the GPIO */
   PORT_PCR_REG(PORTC_BASE_PTR, 8) = PORT_PCR_MUX(0x01);
   GPIO_PDDR_REG(PTC_BASE_PTR) |= 1 << 8; // PTC8 as output
   GPIO_PDOR_REG(PTC_BASE_PTR) |= (1 << 8); // PTC8 in high level
   _time_delay(10);
   /* testing on PTC8: turn off the GPIO */
   PORT_PCR_REG(PORTC_BASE_PTR, 8) = PORT_PCR_MUX(0x01);
   GPIO_PDDR_REG(PTC_BASE_PTR) |= 1 << 8; // PTC8 as output
   GPIO_PDOR_REG(PTC_BASE_PTR) &= ~(1 << 8); // PTC8 in low level
   _time_delay(10)

thanks!

Hui

0 Kudos
Reply
4 Replies

907 Views
mjbcswitzerland
Specialist V

Hui

If you have a GPIO configured to generate an interrupt on a falling or rising edge (eg. PORTC_PCR8 is originally 0x000a0103 for falling edge sensitive interrupt with pull-up enabled) you can change its direction from input to output (in GPIOC_PDDR bit 0 to 1) and it will drive the value in GPIOC_PDOR to the pin.

At the same time each change of the pin value from '1' to '0' will still trigger the original falling edge interrupt.

This allows generating a port interrupt by controlling the value on a GPIO output pin.

Regards

Mark

907 Views
huishao2
Contributor IV

Hi Mark

Thanks a lot for your reply.

Hui

0 Kudos
Reply

907 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Hui,

Have you config the IRQC:

pastedImage_0.png

and config the corresponding interrupt vector table ?

Hope it helps

ALice

0 Kudos
Reply

907 Views
huishao2
Contributor IV

Hi Alice

Thank you so much for your help!

Hui

0 Kudos
Reply