HardFault with NVIC_EnableIRQ(PORTA_IRQn) on PTA13

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

HardFault with NVIC_EnableIRQ(PORTA_IRQn) on PTA13

1,323 Views
brunoaguiam
Contributor I

Hello guys,

I am having some problems using GPIO interrupts, PORTA(PTA13), to work on a MKL33z128VHL4 with freeRTOS V9.0.0.

In debug everything seems to be fine, but when i'm not in debug,  the instruction NVIC_EnableIRQ(PORTA_IRQn);, send me to HardFault Handler. Is it a conflict with the operating system ??  I'm using to NMI_b pin like GPIOinput.

Some code associated to thath pin:

void BOARD_InitPins(void)
{

  /* This is a template function for pins configuration. Intentionally empty */
    CLOCK_EnableClock(kCLOCK_PortA);                               /* Port A Clock Gate Control: Clock enabled */

...

//    Config IO's

    PORT_SetPinMux(PORTA,4u, kPORT_MuxAsGpio);
    PORTA->PCR[4] = ((PORTA->PCR[4] &
        (~(PORT_PCR_PE_MASK | PORT_PCR_ISF_MASK)))     /* Mask bits to zero which are setting */
          | PORT_PCR_PE(0x00u)                         /* Pull Enable: Internal pullup or pulldown resistor is not enabled on the corresponding pin. */
        );

    PORTA->PCR[13] |= PORT_PCR_MUX(1) | PORT_PCR_SRE(0)|PORT_PCR_IRQC(0x0A)|PORT_PCR_PS(1); //config the interrupt pin PTA13

...

}

void configIO()
{
    GPIO_PinInit(PTA,4,&Input);
    GPIO_PinInit(PTA,5,&Output);
    GPIO_PinInit(PTA,12,&Output);
    GPIO_PinInit(PTA,13,&Input);

}

static void StartInt(void *pvParameters)
{

   NVIC_EnableIRQ(PORTA_IRQn); //(When execute this instruction hardFault may happen :S )


        vTaskDelete(NULL);
    }

}

   

int main(void) {
  /* Init board hardware. */
  BOARD_InitPins();
  BOARD_BootClockRUN();
  BOARD_InitDebugConsole();

  /* Add your code here */
  configIO();
  /* Create RTOS task */

...
  xTaskCreate(StartInt, "StartInt", configMINIMAL_STACK_SIZE, NULL, task_PRIORITY-2, NULL);
  xTaskCreate(task_LED, "Task_led", configMINIMAL_STACK_SIZE,NULL, task_PRIORITY-2,NULL); //other periodic task

  vTaskStartScheduler();


  for(;;) { /* Infinite loop to avoid leaving the main function */
    __asm("NOP"); /* something to use as a breakpoint stop while looping */
  }
}

I can't idetify this HardFault happens, since sometimes everything works fine.

I already try to execute NVIC_EnableIRQ(PORTA_IRQn); outside the task of FREERTOS, and happens to.

Can semeone help me.

Best Regards

0 Kudos
Reply
2 Replies

850 Views
brunoaguiam
Contributor I

I have the handler define to:

void PORTA_IRQHandler()
{

   if ((PORTA->ISFR >> 13) && 0x01) {...}

NVIC_ClearPendingIRQ(PORTA_IRQn);

}

0 Kudos
Reply

850 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Bruno,

Sorry for the later reply.

Have you checked the [gpio_input_interrupt] demo located at ..\SDK_2.2_FRDM-KL43Z\boards\frdmkl43z\driver_examples\gpio\input_interrupt folder.

It just make below modification to make PTA13 input interrupt works:

1> Modify BOARD_SW1_GPIO_PIN definition at <board.h>:

#define BOARD_SW1_GPIO_PIN 13U

2> Add below code to initialize PTA13 at <pin_mux.c>:

  PORT_SetPinConfig(PORTA, 13, &porta4_pin26_config);

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos
Reply