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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...