How to access the NVIC registers to activate the GPIO interrupts
#include<stdint.h>
#include<stdbool.h>
#include<hw_memmap.h>
#include<hw_types.h>
#include<SysCtl.h>
#include<hw_SysCtl.h>
#include<hw_gpio.h>
#include<gpio.h>
#include<tm4c123gh6pm.h>
#include<interrupt.h>
#include<hw_nvic.h>
#include<hw_ints.h>
void delay_ms(int del)
{
del=(SysCtlClockGet()/3.0)*del/1000.0;
SysCtlDelay(del);
}
void GPIOIntHandler(void)
{
if(HWREG(GPIO_PORTB_BASE + GPIO_O_RIS) ==~GPIO_PIN_2)
{HWREG(GPIO_PORTB_BASE + GPIO_O_ICR) =GPIO_PIN_2;
HWREG(GPIO_PORTE_BASE + (GPIO_O_DATA + (GPIO_PIN_3 << 2))) =GPIO_PIN_3;
delay_ms(1000);
HWREG(GPIO_PORTE_BASE + (GPIO_O_DATA + (GPIO_PIN_3 << 2))) =~GPIO_PIN_3;
delay_ms(1000);
}
}
void main()
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
HWREG(SYSCTL_RCGCGPIO)=SYSCTL_RCGCGPIO_R4|SYSCTL_RCGCGPIO_R1;
HWREG(GPIO_PORTE_BASE + GPIO_O_DIR) = GPIO_PIN_3;
HWREG(GPIO_PORTB_BASE + GPIO_O_DIR) = GPIO_PIN_2;
HWREG(GPIO_PORTE_BASE + GPIO_O_AFSEL) =~GPIO_PIN_3;
HWREG(GPIO_PORTB_BASE + GPIO_O_AFSEL) =~GPIO_PIN_2;
HWREG(GPIO_PORTE_BASE + GPIO_O_DEN) =GPIO_PIN_3;
HWREG(GPIO_PORTB_BASE + GPIO_O_DEN) =GPIO_PIN_2;
//HWREG(GPIO_PORTB_BASE + NVIC_EN0) =0x00000000;//ENABLE
//HWREG(GPIO_PORTB_BASE + GPIO_O_IM) =~GPIO_PIN_2;//DISABEL
HWREG(GPIO_PORTB_BASE + GPIO_O_IS) =~GPIO_PIN_2;//EDGE SELECT
HWREG(GPIO_PORTB_BASE + GPIO_O_IBE) =~GPIO_PIN_2;//EVNT TRIGR
HWREG(GPIO_PORTB_BASE + GPIO_O_IEV) =GPIO_PIN_2;//RAISING EDGE
//HWREG(GPIO_PORTB_BASE + GPIO_O_RIS) =GPIO_PIN_2;//intrrept ocr on pin
//HWREG(GPIO_PORTB_BASE + GPIO_O_MIS) =GPIO_PIN_2;
HWREG(GPIO_PORTB_BASE + GPIO_O_IM) =GPIO_PIN_2;//ENABLE
HWREG(GPIO_PORTB_BASE + NVIC_EN0) =0x00000002;//ENABLE
HWREG(GPIO_PORTB_BASE + NVIC_EN0_INT_M) =0x00000002;
while(1)
{
HWREG(GPIO_PORTB_BASE + (GPIO_O_DATA + (GPIO_PIN_2 << 2))) =~GPIO_PIN_2;
delay_ms(1000);
HWREG(GPIO_PORTB_BASE + (GPIO_O_DATA + (GPIO_PIN_2 << 2))) =GPIO_PIN_2;
delay_ms(1000);
}
}
above is my program.I am using a CCS compiler but it doesn't work plz inform me is there any mistake in my program.. i don't know how to access the NVIC registers is this a correct way to use those registers