Last active
September 2, 2018 10:51
-
-
Save Xhendos/36f9b96fcf7ef4e7895fd8dd4c4fb2d1 to your computer and use it in GitHub Desktop.
This is the hello world program for the interrupt availability in the TM4C1294NCPDT microcontroller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define GPIO_PORT_CGC_R (*((volatile unsigned long *) 0x400FE608)) | |
#define GPIO_PORTA_DIR_R (*((volatile unsigned long *) 0x40058400)) | |
#define GPIO_PORTA_IS_R (*((volatile unsigned long *) 0x40058404)) /* Interrupt sense */ | |
#define GPIO_PORTA_IBE_R (*((volatile unsigned long *) 0x40058408)) /* Interrupt both edges */ | |
#define GPIO_PORTA_IEV_R (*((volatile unsigned long *) 0x4005840C)) /* Interrupt event */ | |
#define GPIO_PORTA_IM_R (*((volatile unsigned long *) 0x40058410)) /* Interrupt mask */ | |
#define GPIO_PORTA_RIS_R (*((volatile unsigned long *) 0x40058414)) /* Raw interrupt status */ | |
#define GPIO_PORTA_MIS_R (*((volatile unsigned long *) 0x40058418)) /* Masked interrupt status */ | |
#define GPIO_PORTA_IC_R (*((volatile unsigned long *) 0x4005841C)) /* Interrupt clear */ | |
#define GPIO_PORTA_AFSEL_R (*((volatile unsigned long *) 0x40058420)) | |
#define GPIO_PORTA_DEN_R (*((volatile unsigned long *) 0x4005851C)) | |
#define GPIO_PORTA_DATA_R (*((volatile unsigned long *) 0x40058080)) /* NOTE: Only PA5 can be written */ | |
#define NVIC_EN0_R (*((volatile unsigned long *) 0xE000E100)) /* Write to enable interrupt */ | |
#define NVIC_DIS0_R (*((volatile unsigned long *) 0xE000E180)) /* Write to disable interrupt */ | |
#define NVIC_PEND0_R (*((volatile unsigned long *) 0xE000E200)) /* Set pending interrupt */ | |
#define NVIC_UNPEND0_R (*((volatile unsigned long *) 0xE000E280)) /* Clear pending interrupt */ | |
#define NVIC_ACTIVE0_R (*((volatile unsigned long *) 0xE000E300)) | |
#define NVIC_PRI0_R (*((volatile unsigned long *) 0xE000E400)) | |
#define SCB_APINT_R (*((volatile unsigned long *) 0xE000ED0C)) | |
void GPIOPortA_Handler(void) | |
{ | |
GPIO_PORTA_DATA_R ^= 0x20; /* Toggle the LED attached at PA5 */ | |
GPIO_PORTA_IC_R |= 0x10; /* Acknowledge the interrupt */ | |
} | |
int main(void) | |
{ | |
GPIO_PORT_CGC_R |= 0x01; /* Enable PORTA module */ | |
GPIO_PORTA_DIR_R &= ~0x10; /* PA4 is an input pin */ | |
GPIO_PORTA_AFSEL_R &= ~0x10; /* PA4 is not a special function pin */ | |
GPIO_PORTA_DEN_R |= 0x10; /* PA4 is a digital pin */ | |
GPIO_PORTA_DIR_R |= 0x20; /* PA5 is an output pin */ | |
GPIO_PORTA_AFSEL_R &= ~0x20; /* PA5 is not a special function pin */ | |
GPIO_PORTA_DEN_R |= 0x20; /* PA5 is a digital pin */ | |
GPIO_PORTA_IS_R &= ~0x10; /* PA4 is edge sensitive */ | |
GPIO_PORTA_IBE_R &= ~0x10; /* PA4 does not trigger on both edges (see GPIOIEV register) */ | |
GPIO_PORTA_IEV_R |= 0x10; /* PA4 triggers an interrupt on the rising edge */ | |
GPIO_PORTA_IC_R |= 0x10; /* Clear a pending interrupt for PA4. This is good practice */ | |
GPIO_PORTA_IM_R |= 0x10; /* Interrupt triggered by PA4 are sent to the interrupt controller */ | |
SCB_APINT_R |= 0x05FA0400; /* 3 bit group priority and no subpriority */ | |
NVIC_PRI0_R |= (0x01 << 5); /* Interrupts triggered by PA4 have the priority #1 */ | |
NVIC_EN0_R |= 0x01; /* Enable interrupts for the GPIO PORTA module */ | |
while(1) {} | |
return 0; | |
} | |
/* PA4 is input */ | |
/* PA5 is output */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment