I am trying to expand on a working gamepad project to increase the number of GPIO buttons available but keep getting fault ISRs when I try to use port D GPIO.
I have minimized the project as shown below to highlight the issue.
Whenever execution gets to the ROM_GPIOPinRead() statement Tiva faults.
If I comment out the 2 lines that configure the USB pins [SysCtlGPIOAHBEnable();ROM_GPIOPinTypeUSBAnalog();] the GPIO read executes without issue (obviously USB doesn't enumerate though).
Thoughts?
int main()
{
volatile uint8_t D;
ROM_FPULazyStackingEnable();
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//Unlock the GPIO inputs which are locked
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= GPIO_PIN_7;
ROM_GPIODirModeSet(GPIO_PORTD_BASE, 0xcf, GPIO_DIR_MODE_IN);
ROM_GPIOPadConfigSet(GPIO_PORTD_BASE, 0xcf, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)));
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_AHB_BASE, GPIO_PIN_4 | GPIO_PIN_5);
while(1)
{
D = ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_0);
}
}