Hello Guys,
I am programming a TM4C in Tiva-C using TI-RTOS 2.10.01 and I used the example project called gpiointerrupt, that configures the interrupts for the buttons on Tiva board . That´s OK and the example works fine.
But, my program is a little bit complicated andI have a task that starts more 2 tasks for controlling a socket connection with my server and the serial port. I am also configuring diferent ports on my project - PORT_M, PIN_2, PIN_3, PIN_4, PIN_5 and PIN_6 as my control buttons (PIN_2 is for future use).
I am doing all configurations according the example and, of course,
Please find below some extracts of my code.
// Enabling interrupts and callbacks in main.c GPIO_setupCallbacks(&buttonCallbacks); GPIO_enableInt(BUTTON_PM6, GPIO_INT_RISING);
// Board.h #define buttonCallbacks EK_TM4C1294XL_gpioPortMCallbacks
// EK_TM4C1294XL.h typedef enum EK_TM4C1294XL_GPIOName { BUTTON_PM6 = 0, BUTTON_PM3, BUTTON_PM5, BUTTON_PM4, BUTTON_PM2, BUTTON_PM_COUNT } EK_TM4C1294XL_GPIOName;
// EK_TM4C1294XL.c /* Callback functions for the GPIO interrupt example. */ void button1Callback(void); void button2Callback(void); void button3Callback(void); void button4Callback(void); void button5Callback(void); /* GPIO configuration structure */ const GPIO_HWAttrs gpioHWAttrs[BUTTON_PM_COUNT] = { {GPIO_PORTM_BASE, GPIO_PIN_6, GPIO_INPUT}, /* Botao 1 */ {GPIO_PORTM_BASE, GPIO_PIN_3, GPIO_INPUT}, /* Botao 2 */ {GPIO_PORTM_BASE, GPIO_PIN_5, GPIO_INPUT}, /* Botao 3 */ {GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_INPUT}, /* Botao 4 */ {GPIO_PORTM_BASE, GPIO_PIN_2, GPIO_INPUT} /* Botao Interno- Nao usado */ }; /* Memory for the GPIO module to construct a Hwi */ Hwi_Struct callbackPortMHwi; const GPIO_Callbacks EK_TM4C1294XL_gpioPortMCallbacks = { GPIO_PORTM_BASE, INT_GPIOM, &callbackPortMHwi, {button1Callback, button2Callback, button3Callback, button4Callback, button5Callback, NULL, NULL, NULL} }; const GPIO_Config GPIO_config[] = { {&gpioHWAttrs[0]}, {&gpioHWAttrs[1]}, {&gpioHWAttrs[2]}, {&gpioHWAttrs[3]}, {&gpioHWAttrs[4]}, {NULL}, };
// initGPIO() GPIOPinTypeGPIOInput(GPIO_PORTM_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6); GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
In the Interrupt function, for example, button1Callback, I am doing:
void button1Callback() { GPIO_clearInt(BUTTON_PM6); }
But when I press the button, I receive the following error on Console:
ti.sysbios.family.arm.m3.Hwi: line 1036: E_hardFault: FORCED ti.sysbios.family.arm.m3.Hwi: line 1148: E_usageFault: INVSTATE: Invalid EPSR and instruction combination Exception occurred in ISR thread at PC = 0x00000000. Core 0: Exception occurred in ThreadType_Hwi. Hwi name: {unknown-instance-name}, handle: 0x200250a0. Hwi stack base: 0x200264c8. Hwi stack size: 0x800. R0 = 0x00000000 R8 = 0x000223ac R1 = 0x00000001 R9 = 0x000223a4 R2 = 0x200262d8 R10 = 0x000223a8 R3 = 0x00000000 R11 = 0x00000000 R4 = 0x00000001 R12 = 0x00000000 R5 = 0x00000006 SP(R13) = 0x20026c58 R6 = 0x00021d8c LR(R14) = 0x0001cafb R7 = 0x000223b8 PC(R15) = 0x00000000 PSR = 0x60000058 ICSR = 0x00423003 MMFSR = 0x00 BFSR = 0x00 UFSR = 0x0002 HFSR = 0x40000000 DFSR = 0x0000000b MMAR = 0xe000ed34 BFAR = 0xe000ed38 AFSR = 0x00000000 Terminating execution...
I don't have a lot of experience with programming in TM4C and TiRTOS and I don't know how to implement this. The fact is that I need to have 4 buttons (5 in the future) and I need to know when one of theses buttons are pressed to take some action.
Any advice will be welcome.
Best Regards,
Leandro