Hi guys I'm quite new to programming, and I'm trying to configure my LM4F232 microcontroller such that when I press the "UP" button, it'll produce a falling edge and hence stop my LED from blinking. Releasing the button will return the LED to its blinking state. However, my code does not seem to be working. Any help would be greatly appreciated.
from main.c
#include "C:\StellarisWare\inc\hw_memmap.h"
#include "C:\StellarisWare\inc\hw_types.h"
#include "C:\StellarisWare\driverlib\sysctl.h"
#include "driverlib/interrupt.h"
#include "C:\StellarisWare\driverlib\gpio.h"
void PortMIntHandler(void);
int iBlinkLEDFlag;
int main(void){
//Enables all interrupts to processor
IntMasterEnable();
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
//Enables Port G
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
//Enables Port M
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
//Enables interrupt for Pin 1 of Port M
GPIOPinIntEnable(GPIO_PORTM_BASE, GPIO_PIN_0);
//Sets pin's function
GPIOPinTypeGPIOInput(GPIO_PORTM_BASE,GPIO_PIN_0);
//Sets pin's type
GPIOIntTypeSet(GPIO_PORTM_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
while (1){
if (iBlinkLEDFlag == 1){
GPIOPinWrite(GPIO_PORTG_BASE,GPIO_PIN_2,0x04);
SysCtlDelay(400000);
GPIOPinWrite(GPIO_PORTG_BASE,GPIO_PIN_2,0x00);
SysCtlDelay(400000);
}
}
}
void PortMIntHandler(void)
{
iBlinkLEDFlag = GPIOPinRead(GPIO_PORTM_BASE, GPIO_PIN_1);
}
from startup.c
extern void PortMIntHandler(void);
PortMIntHandler, // GPIO Port M