AnsweredAssumed Answered

HardFault with NVIC_EnableIRQ(PORTA_IRQn) on PTA13

Question asked by Bruno Aguiam on Apr 28, 2017
Latest reply on May 3, 2017 by Hui_Ma

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()



static void StartInt(void *pvParameters)

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




int main(void) {
  /* Init board hardware. */


  /* Add your code here */
  /* 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




  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