Other Parts Discussed in Thread: SYSBIOS, EK-TM4C1294XL
I don’t have a good way to test a IRQ at the moment so I want to ask a question about if this is the best way tor at least a good o go about programming a IRQ only pin D6 . On Port D, I have 2 input pins (D4 and D6)and I only want to interrupt on pin D6 and not D4. This questions is more of a code review question in nature.
I will be using a TM4C1294NCPDT with CCS ccs 6.1.2 and TIRTOS 2.16.0.08.
Below is the code I have so far:
#define PORT_D_IN_PINS (GPIO_PIN_4 + GPIO_PIN_6)
void initPort_D(void)
{
unsigned long port = GPIO_PORTD_BASE;
Hwi_Handle myHwi;
Hwi_Params hwiParams;
Error_Block eb;
SysCtlPeripheralEnable(port); // enable the port
SMALL_DELAY; // when SysCtlPeripheralEnable() is called, a small delay is needed before the device can be used.
// configure the inputs
ROM_GPIODirModeSet(port, PORT_D_IN_PINS, GPIO_DIR_MODE_IN);
MAP_GPIOPadConfigSet(port, PORT_D_IN_PINS, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
// define input IRQ on Pin D6
GPIOIntEnable(port, GPIO_INT_PIN_6); // from TivawareDoc enable the interrupt on pin 6
GPIOIntTypeSet(port, GPIO_INT_PIN_6, GPIO_FALLING_EDGE); // from TivawareDoc define the IRQ as falling edge
Error_init(&eb);
Hwi_Params_init(&hwiParams);
hwiParams.arg = 10; // pass function a argument of 10 just because….
hwiParams.enableInt = TRUE; // have the IRQ enabled by default.
myHwi = Hwi_create(INT_GPIOD_TM4C129, portD_IntHandler, &hwiParams, &eb); // associate the IRQ INT_GPIOD_TM4C129 (19) with the callback function portD_IntHandler() from the TI_RTOC 2.0 Doc
if(NULL == myHwi)
{
printf ("Error installing IRQ %d for port D\n", INT_GPIOD_TM4C129);
}
else
{
printf ("OK installing IRQ %d for port D\n", INT_GPIOD_TM4C129);
}
GPIO_enableInt(GPIO_INT_PIN_6); ); // shouldn’t be needed since the IRQ is enabled by hwiParams.enableInt = TRUE;
Hwi_enableInterrupt(INT_GPIOD_TM4C129); // shouldn’t be needed since the IRQ is enabled by hwiParams.enableInt = TRUE;
}
void portD_IntHandler(UArg arg)
{
static int intCounter=0;
System_printf("portD_IntHandler fied %d times\n", intCounter++);
}
It seems I’m mixing a bunch of high level calls like Hwi_create() from the BIOS User Guide and lower level calls GPIOIntEnable() and GPIOIntTypeSet () from TivaWare. Does this look like it will do what I want with having D4 being just a standard input pin I just read and pin D6 would be a input pin that generates a IRQ when it goes low? I don’t think I can get the fine control to configure only pin D6 to be a IRQ and D4 be just a input pin using the TI-RTOS API.
Thanks for any advice,
Doug