Other Parts Discussed in Thread: TM4C123GH6PGE
HI guyz i just started coding on TM4C123G board and my Micro controller is TM4C123GH6PGE. My aim is to use navigation switch for blinking led on board . I want to use Interrupt mechanism for this . Please find below the code which i wrote it compiles but doesn't run accordingly . Please share ur suggestion if you find any discrepancy in it .
/** MAIN FILE **/
#define LED_OFF ~(GPIO_PIN_2)
#define LED_ON GPIO_PIN_2
void GPIOMIntHandler()
{
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, LED_ON );
}
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOM ); //Enable peripheral for switch
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOG ); // Enable the peripheral for led
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2 ); // Configure led pin as output
GPIOPinTypeGPIOInput(GPIO_PORTM_BASE,GPIO_PIN_0); // Configure Pin 0 for switch as input
//Configuration of switch pin with weak pullup
GPIOPadConfigSet(GPIO_PORTM_BASE,GPIO_PIN_0,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
IntMasterEnable(); // enable processor interrupts
GPIOIntTypeSet(GPIO_PORTM_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE); //Interrupt on falling edge
IntPrioritySet(INT_GPIOM, 0x00); // Set the interrupt priority
GPIOIntClear(GPIO_PORTM_BASE,GPIO_PIN_0 ); //Clear any pending interrupt
GPIOIntEnable(GPIO_PORTM_BASE,GPIO_PIN_0 ); // Enable the specified interrupt
GPIOIntRegister(GPIO_PORTM_BASE,GPIOMIntHandler); // Interrupt (Confused over this line coz i have also marked the interrupt in css file)
while(1)
{
}
}
/***startup_css.c **/
this is just the snippet of css file where i had made relevant changes
//*****************************************************************************
//
// External declarations for the interrupt handlers used by the application.
//
//*****************************************************************************
extern void GPIOMIntHandler(void);
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000 or at the start of
// the program if located at a start address other than 0.
//
//*****************************************************************************
#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((uint32_t)&__STACK_TOP),
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
IntDefaultHandler, // The MPU fault handler
IntDefaultHandler, // The bus fault handler
GPIOMIntHandler, // GPIO Port M
}
Problem : The ISR never got hit even after pressing switch .
Please share ur views regarding this