Hello,
I'm using Tiva Launchpad EK-TMC123GXL with Code Composer Studio v.6.0.0.00190. My intent is to trigger interrupts with the onboard buttons SW1 & SW2. By pressing SW1 I want the "blue" LED to turn on, and with SW2 the "red" LED to turn on. I have managed to turn on the "red" LED by pressing SW2, but for some reason the same does not happen for SW1. I read the following posts:
http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/332605/1159528.aspx#1159528
http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/336194.aspx
... but could not identify anything that would help me solve my problem.
My code is as follows:
1 - First I configure the system clock.
SysCtlClockSet (SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
2 - Then I configure the GPIO port and pins.
// Enable Peripheral Clocks
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
// Enable pin PF0/4 for GPIOInput
//First open the lock and select the bits we want to modify in the GPIO commit register.
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x1;
//Now modify the configuration of the pins that we unlocked.
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
// Enable pin PF1/2/3 for GPIOOutput
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
// Turn weak pull-ups on
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4 , GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
3 - I set up the interrupts and the start an infinate loop.
IntMasterEnable();
IntEnable(INT_GPIOF);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_INT_PIN_0 | GPIO_INT_PIN_4);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_BOTH_EDGES);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0 | GPIO_INT_PIN_4);
while(1)
{ }
4 - My ISR is the following.
void buttonIsr()
{
if (!GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0))
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0x02);
}
if (!GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_4))
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0x04);
}
SysCtlDelay(1000000);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2, 0x00);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
}
5 - I have added the ISR in the vector table in the "startup" code.
As I have already stated, the above code will result in flashing the "red" LED for a small amount of time (defined in "SysCtlDelay(1000000);") when I press SW2. However the same does not happen for SW1. In addition, when I put my finger on the PF4 pin on the J4 connector, the blue LED will flash. Finally, when I debug the whole thing in the "Memory Browser" I see the following:
PF0 in address 0x40025004 has a value 1 and if I press SW2 it goes to 0, which is what I would expect. However, PF4 in address 0x40025040 is always 0. It will switch to 1 only if I put my finger on pin PF4 of the J4 connector.
What am I missing here? Thank you in advance.