This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432E401Y: Gpiointerrupt callback function

Part Number: MSP432E401Y


Hi,

I am using the gpiointerrupt example for freertos and I am just trying to display something in addition to toggle the LED, however during the callback function gpioButtonFxn0(), I always block at Display_open. The code is below. I haven't changed anything else in the example file (other than import). If someone can give me insight as to why this is happening, that would be great. Thank you.

/*
 *  ======== gpioButtonFxn0 ========
 *  Callback function for the GPIO interrupt on Board_GPIO_BUTTON0.
 */
void gpioButtonFxn0(uint_least8_t index)
{
    /* Clear the GPIO interrupt and toggle an LED */
    Display_init();
    Display_Handle display = Display_open(Display_Type_UART, NULL);
    Display_printf(display, 0, 0, "Starting the i2ctmp007 example\n");
    GPIO_toggle(Board_GPIO_LED1);
}

  • Can you confirm where exactly within the "Display_open" does your code block by either clicking the suspend button or stepping through the code?
  • I think you are trying to do too much in an interrupt handler. You might be being bitten because interrupts are disabled.

    You should just set a flag and start up the display in a regular thread.
  • Mike -- It gets stuck at vPortEnterCritical() in freertos/portable/CCS/ARM_CM4F/port.c, at configASSERT(). Code is below.

    void vPortEnterCritical( void )
    {
    	portDISABLE_INTERRUPTS();
    	uxCriticalNesting++;
    
    	/* This is not the interrupt safe version of the enter critical function so
    	assert() if it is being called from an interrupt context.  Only API
    	functions that end in "FromISR" can be used in an interrupt.  Only assert if
    	the critical nesting count is 1 to protect against recursive calls if the
    	assert function also uses a critical section. */
    	if( uxCriticalNesting == 1 )
    	{
    		configASSERT( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) == 0 );
    	}
    }

  • Keith -- Why would it be too much? And if it is too much, I should just create a new thread that will print out what I want on the display?
  • Ryan,

    From the comment on the "vPortEnterCritical", it seems that you are not supposed to call it from an ISR.
    So, to Keith's point, you can create another task that opens the LCD (in its initialization section) and then pends on a semaphore to update the LCD. The ISR, then, would only need to post the LCD semaphore.
  • Great, that helps a lot. Thanks both of you.
  • In general, and *especially* for MCUs, interrupt handlers should take the following advice from "The Court Jester":


    Hubert Hawkins: I'd like to get in, get on with it, get it over with, and get out. Get it?

    Ravenhurst: Got it.

    Hubert Hawkins: Good.

**Attention** This is a public forum