Jump to content
Sign in to follow this  
cry_viem

gpio

Recommended Posts

hi everyone,i'm a newbie, i have a trouble when i code for interrupt pin pf0 to toggle led at pf2, it doesn't work when i press button, 

help me plz!, i use lm4f120xl, tks a lot, here r my code:

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"

void pressing(void)
{
	 GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,~GPIOPinRead(GPIO_PORTF_BASE,0xff));		// toggle led pf2
	 SysCtlDelay(16000);																			// anti-noise
}

void main(void)
{
	SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);			//  50MHz
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);												// enable port F
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_2);											//
	GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,0xff);
	//---------------interrupt configure----------------
	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);											// sw2
	GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_FALLING_EDGE);
	GPIOPortIntRegister(GPIO_PORTF_BASE, pressing);
	IntMasterEnable();
	while(1)
	{
		;
	}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×