KW36 Interrupt on PTC2 using SW3 Demo Board

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

KW36 Interrupt on PTC2 using SW3 Demo Board

1,278 Views
nedwards
Contributor I

I am new to the KW36

I am using the FDRM KW36 Demo Board

I have configured PTC2 to be an interrupt pin

I have enabled the interrupt -  EnableIRQ(PORTB_PORTC_IRQn);

I have defined the ISR - void PORTB_PORTC_IRQHandler(void)

But it does not work

Anny suggestions

 

0 Kudos
Reply
3 Replies

1,259 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi,

I am not sure if you are working on a simple project or if you are using a Bluetooth LE example.

 

However, you could look at the GPIO interrupt driver example.

\SDK_KW36\boards\frdmkw36\driver_examples\gpio\input_interrupt

Please look at the pin 18 configuration below.

  PORT_SetPinMux(PORTB, PIN18_IDX, kPORT_MuxAsGpio);         /* PORTB18 (pin 23) is configured as PTB18 */
  PORTB->PCR[18] = ((PORTB->PCR[18] &
    (~(PORT_PCR_PS_MASK | PORT_PCR_PE_MASK | PORT_PCR_SRE_MASK | PORT_PCR_ISF_MASK))) /* Mask bits to zero which are setting */
      | PORT_PCR_PS(0x01u)                                   /* Pull Select: 0x01u */
      | PORT_PCR_PE(0x01u)                                   /* Pull Enable: 0x01u */
      | PORT_PCR_SRE(0x01u)                                  /* Slew Rate Enable: 0x01u */
    );

Also, to enable the ISR.

    /* Init input switch GPIO. */
    PORT_SetPinInterruptConfig(BOARD_SW_PORT, BOARD_SW_GPIO_PIN, kPORT_InterruptFallingEdge);
    EnableIRQ(BOARD_SW_IRQ);
    GPIO_PinInit(BOARD_SW_GPIO, BOARD_SW_GPIO_PIN, &sw_config);

 

For the Bluetooth LE example look at the Keyboard.c file and look at the void KBD_Init( KBDFunction_t pfCallBackAdr )function, it is implementing the GPIO initialization and how is register the callback for the specific events.

 

Regards,

Mario

0 Kudos
Reply

1,274 Views
nedwards
Contributor I

I takes 30 seconds from pressing the button for the debug "Button Pressed" to appear on serial port

Why so slow ??

0 Kudos
Reply

1,274 Views
nedwards
Contributor I

I have written the following code

#include <stdio.h>
#include "fsl_debug_console.h"
#include "fsl_common.h"
#include "fsl_rtc.h"
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
char ButtonFlag = 0U;
void PORTB_PORTC_IRQHandler(void)
{
    ButtonFlag = 1U;
    GPIO_ClearPinsInterruptFlags(GPIOC, 4U);
}
int main(void)
{
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();
    EnableIRQ(PORTB_PORTC_IRQn);
    PRINTF("\r\nDemo running...\r\n");
    while (1)
    {
     if(1U == ButtonFlag)
     {
         PRINTF("Button Pressed\r\n");
         ButtonFlag = 0U;
     }
    }
0 Kudos
Reply