i am using 6 ultrasonic modules 3 echo pins are on PB0,2,4 and three are on PD0,2,4
i need to enable the external interrupt on any pin and write the interrupt handler
i'm using code composer studio
here's
#include "tm4c123gh6pm.h"
void GPIO_init(void)
{
/*GPIO PB4 Configuration*/
SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R1 ; // Enable clock to PortB
SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R3 ; // Enable clock to PortD
GPIO_PORTB_DIR_R &= ~(FRONT_SENSOR_PIN); // make PB0 as input Echo for front sensor
GPIO_PORTB_DIR_R &= ~(RIGHT_SENSOR_PIN); // make PB2 as input Echo for Right sensor
GPIO_PORTB_DIR_R &= ~(LEFT_SENSOR_PIN); // make PB4 as input Echo for Left sensor
GPIO_PORTB_DIR_R &= ~(BACK_SENSOR_PIN); // make PD0 as input Echo for Back sensor
GPIO_PORTD_DIR_R &= ~(RIGHTCORNER_SENSOR_PIN); // make PD2 as input Echo for Right Corner sensor
GPIO_PORTD_DIR_R &= ~(LEFTCORNER_SENSOR_PIN); // make PD4 as input Echo for Left Corner sensor
GPIO_PORTB_DIR_R |= (FRONT_SENSOR_PIN)<<1; // make PB1 as output trigger for front sensor
GPIO_PORTB_DIR_R |= (RIGHT_SENSOR_PIN)<<1; // make PB3 as output trigger for Right sensor
GPIO_PORTB_DIR_R |= (LEFT_SENSOR_PIN)<<1; // make PB5 as output trigger for Left sensor
GPIO_PORTB_DIR_R |= (BACK_SENSOR_PIN)<<1; // make PD1 as output trigger for Back sensor
GPIO_PORTD_DIR_R |= (RIGHTCORNER_SENSOR_PIN)<<1; // make PD3 as input trigger for Right Corner sensor
GPIO_PORTD_DIR_R |= (LEFTCORNER_SENSOR_PIN)<<1; // make PD5 as input trigger for Left Corner sensor
GPIO_PORTB_DEN_R = 0x3F; // Digital enable to PB0,PB1,PB2,PB3,PB4,PB5 in PORTB
GPIO_PORTD_DEN_R = 0x3F; // Digital enable to PD0,PD1,PD2,PD3,PD4,PD5 in PORTD
GPIO_PORTB_IS_R &= ~((1<<0)|(1<<2)|(1<<4)); // make PB0, PB2, PB4 edge sensitive for interrupt
GPIO_PORTD_IS_R &= ~((1<<0)|(1<<2)|(1<<4)); // make PB0, PB2, PB4 edge sensitive for interrupt
GPIO_PORTB_IBE_R &= ~((1<<0)|(1<<2)|(1<<4)); // trigger is controlled by IBE
GPIO_PORTD_IBE_R &= ~((1<<0)|(1<<2)|(1<<4)); // trigger is controlled by IBE
GPIO_PORTB_IEV_R |= (1<<0)|(1<<2)|(1<<4); // rising edge trigger PB0,PB2,PB4
GPIO_PORTD_IEV_R |= (1<<0)|(1<<2)|(1<<4); // rising edge trigger PD0,PD2,PD4
GPIO_PORTB_ICR_R |= (1<<0)|(1<<2)|(1<<4); // Clear any prior interrupts
GPIO_PORTD_ICR_R |= (1<<0)|(1<<2)|(1<<4); // Clear any prior interrupts
GPIO_PORTB_IM_R |= (1<<0)|(1<<2)|(1<<4); // enable interrupt
GPIO_PORTD_IM_R |= (1<<0)|(1<<2)|(1<<4); // enable interrupt
NVIC_EN0_R =((1<<1)|(1<<3)); // enable IRQ0 for PORTB,PORTD
//how could i enable the global interrupt ??
//and how to deal with interrupt handler ??
}