Hi, Lisa
thank you for your reply.
i found these code on the internet.
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "inc/hw_ints.h"
#define SYS_CLOCK 50000000
#define KEY GPIO_PIN_4
#define RED_LED GPIO_PIN_1
#define BLUE_LED GPIO_PIN_2
#define GREEN_LED GPIO_PIN_3
long key_value = 0;
//**********************************************************************
//**********************************************************************
void main(void)
{
int i = 0;
long temp = 0;
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL |
SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,RED_LED | BLUE_LED | GREEN_LED);
GPIOPadConfigSet(GPIO_PORTF_BASE,RED_LED | BLUE_LED| GREEN_LED,
GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,KEY);
GPIOPadConfigSet(GPIO_PORTF_BASE,KEY,
GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTF_BASE,KEY,GPIO_RISING_EDGE);
GPIOPinIntEnable(GPIO_PORTF_BASE,KEY);
IntEnable(INT_GPIOF);
while(1)
{
if(key_value & KEY)
{
switch(i)
{
case 0:
temp =GPIOPinRead(GPIO_PORTF_BASE,RED_LED);
GPIOPinWrite(GPIO_PORTF_BASE,RED_LED,~temp);
key_value&= ~KEY;
i = 1;
break;
case 1:
temp =GPIOPinRead(GPIO_PORTF_BASE,BLUE_LED);
GPIOPinWrite(GPIO_PORTF_BASE,BLUE_LED,~temp);
key_value&= ~KEY;
i = 2;
break;
case 2:
temp =GPIOPinRead(GPIO_PORTF_BASE,GREEN_LED);
GPIOPinWrite(GPIO_PORTF_BASE,GREEN_LED,~temp);
key_value&= ~KEY;
i = 0;
break;
}
}
else
{
}
}
}
void KeyISR(void)
{
key_value = GPIOPinIntStatus(GPIO_PORTF_BASE,true);
GPIOPinIntClear(GPIO_PORTF_BASE,key_value);
SysCtlDelay(10 * (SYS_CLOCK / 3000));
}
above all are the codes.
thank you very much
best regards
Zhengwei LI