cry_viem 0 Posted June 23, 2014 Share Posted June 23, 2014 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) { ; } } Quote Link to post Share on other sites
Lyon 3 Posted June 23, 2014 Share Posted June 23, 2014 Hi, PF0 is the NMI pin (also PD7) so you must to unlock it first before using it. See how to here: http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/284566.aspx L cry_viem and bluehash 2 Quote Link to post Share on other sites
cry_viem 0 Posted June 23, 2014 Author Share Posted June 23, 2014 tks Lyon! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.