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.

adding a GPIO interrupt

I am adding an interrupt for a touch screen and am using the TM4C1294XL launch board.

I have connected the touch screen interrupt line to Port P5.

I added an hwi instance linking the interrupt to my handler function and set the interrupt number to 97. (Port P5)

My code follows the GPIO interrupt example and I changed the callback and enable functions as follows:

GPIO_SetCallback(GPIOTiva_PP_5, INT_GPIOTouch);   (INT_GPIOTouch is the handler of course)

GPIO_enableInt(GPIOTiva_PP_5);

It compiles fine but when the program gets to the enableInt function it crashes.

I tried adding GPIO_PP_5 | GPIO_CFG_IN_PU | GPIO_CFG_INT_FALLING, to the GPIO_PinConfig array in the EK_TM4C1294XL.c file but it didn't help.

Is there some other value that needs to be added?

  • Also, the error I get is E_alreadydefined: Hwi already defined: int#97
    But I don't see it defined anywhere.

    BTW: The TI-RTOS workshop series by Eric Wilbur is a must watch for anyone starting out with TI-RTOS. Thank you, Eric.
  • Hi Sam,

    What version of TI-RTOS are you using? Can you attach your project? We'll be able to debug much faster if we can see all the code and reproduce the problem.

    Thanks for the feedback about the workshop series.

    Todd
  • I didn't know how large a file I could attach so here is the Dropbox link to the entire workspace zip file.

    Using TI-RTOS for TivaC 2.14.4.31

    A lot of the code was copied from a non-RTOS version that did work on the same board.

     

  • Just realized a big error on my part. The value used in the GPIO_setCallback and GPIO_enableInt functions are an index into the GPIO_PinConfig array.

    I added GPIO_PP_5 | GPIO_CFG_IN_PU | GPIO_CFG_INT_FALLING to the array and added a name for that index and then used that index name in both GPIO functions.

    It does not crash when I enable the interrupt.

    Thanks for your help. I'll let you know how it works out.

    Sam
  • Okay. My joy didn't last long. I get past the GPIO_enableInt function but when BIOS_Start() runs I get the same error.
    E_alreadyDefined; Hwi already defined: int# 97
  • I went ahead and removed the hwi product from the project and now it runs without crashing.
    What am I missing? I thought I had to add the hwi instance to use hardware interrupts.

    I am very confused.
  • Hi Sam,

    We are glad that it is working now.

    The Hwi error you see is because the GPIO_init() tries to set-up the Hwi for the GPIO and an another instance of Hwi had been already set-up for this interrupt. If you using the TI-RTOS GPIO driver on TivaC, you do not need to set-up the Hwi for that GPIO pin with interrupts.

    Also, I see that you are using both TI-RTOS GPIO driver and the GPIO module from TivaC Driverlib. We recommend using the TI-RTOS GPIO driver for most cases as it is designed to be RTOS aware and it internally uses the Driverlib GPIO module. In other cases where you need additional functionality than that is provided by TI-RTOS GPIO driver, you can use the Driverlib GPIO module but make sure to make it RTOS aware.

    Vikram