Other Parts Discussed in Thread: TMS320C6655
We are trying to use GPIO1 as an interrupt. We have been successful in usage as a GPIO pin but not yet as an interrupt.. Below is code being used to initialize GPIO port 1 parameters. Defining the port direction, rising edge interrupt enabling, bank enabling, etc … All of the boiler plate parameters we believe are needed to setup the interrupt for GPIO_1. Can you confirm GPIO 1 can be used as an interrupt?...Based on GPIO spec., all GPIO pins can be used. Please review code implementation below and provide feedback on what may be wrong.
Thanks,
James
*.cmd file contents
SECTIONS
{
.init_array > L2SRAM
.dstBufSet > L2SRAM
.csl_vect > L2SRAM
}
void GPIO01InterruptHandler (void *arg)
{
/* Clear the event ID. */
CSL_intcEventClear((CSL_IntcEventId)arg);
}
void SetGPIO01ISR(void)
{
CSL_IntcContext context;
CSL_IntcEventHandlerRecord EventRecord;
CSL_IntcEventHandlerRecord EventHandler[1];
CSL_IntcParam vectId;
CSL_IntcHandle gpioIntcHandle;
CSL_IntcObj gpioIntcObj;
CSL_IntcGlobalEnableState state;
CSL_GpioHandle GhGpio;
Uint8 inData;
int print_state;
//Config GPIO01 as input
GhGpio = CSL_GPIO_open (0); // Opens GPIO Instance 0
CSL_GPIO_setPinDirInput (GhGpio, 1); //set GPIO_1 to be input
//. Enable GPIO global interrupt ( BINTEN)
//GPIO user guide needs to be updated for BINTEN register that bit 0 is for Bank 0 (GPIO pins 15:0)
//and bit 1 is for Bank 1 (GPIO pins 31-16).
GhGpio->BINTEN = 0x01;
// Enable GPIO01 rising edge interrupt
CSL_GPIO_setRisingEdgeDetect(GhGpio, 1);
CSL_GPIO_bankInterruptEnable (GhGpio, 0);
/* INTC module initialization */
context.eventhandlerRecord = EventHandler;
context.numEvtEntries = 1;
if (CSL_intcInit(&context) != CSL_SOK)
printf ("CSL_intcInit fail\n");
/* Enable NMIs */
if (CSL_intcGlobalNmiEnable() != CSL_SOK)
printf ("CSL_intcGlobalNmiEnable fail\n");
/* Enable global interrupts */
if (CSL_intcGlobalEnable(&state) != CSL_SOK)
printf ("CSL_intcGlobalEnable fail\n");
/* Open INTC */
vectId = CSL_INTC_VECTID_4;
gpioIntcHandle = CSL_intcOpen(&gpioIntcObj, CSL_GEM_GPINTN, &vectId, NULL); //CSL_GEM_GPINTN
if (gpioIntcHandle == NULL)
printf ("gpioIntcHandle fail\n");
/* Bind ISR to Interrupt */
EventRecord.handler = (CSL_IntcEventHandler)&GPIO01InterruptHandler;
EventRecord.arg = (void *)CSL_GEM_GPINTN;
CSL_intcPlugEventHandler(gpioIntcHandle, &EventRecord);
/* Event Enable */
CSL_intcHwControl(gpioIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);
printf ("GPIO01 Interrupt Test Start\n");
print_state = 1;
while(1)
{
CSL_GPIO_getInputData (GhGpio, 1 , &inData);
if (inData == 1)
{
if (print_state == 1)
{
printf ("GPIO_1 State: High\n");
print_state = 0;
}
}
else
{
if (print_state == 0)
{
printf ("GPIO_1 State: Low\n");
print_state = 1;
}
}
}
}