//------------------------------------------------------------------------------------------------------ // Lab4 - C and Interrupts // 1)Enalbe the interrupt for UART // 2)Go to sleep mode // 3)On interruption, echo back to the UART //------------------------------------------------------------------------------------------------------ #include #define AHB_LED_BASE 0x50000000 #define AHB_UART_BASE 0x51000000 #define NVIC_INT_ENABLE 0xE000E100 volatile static int counter=0x31; void UART_ISR() { char c; c=*(volatile unsigned char*) AHB_UART_BASE; //read a character from UART *(volatile unsigned char*) AHB_UART_BASE = c; //write the character to UART } ////////////////////////////////////////////////////////////////// // Main Function ////////////////////////////////////////////////////////////////// int main(void) { volatile int i; int delay = 400000; printf("\n\rWelcome to ARM LTD\n\r"); *(unsigned int*) NVIC_INT_ENABLE = 0x00000002; //Enable interrupts for UART *(volatile unsigned int*) AHB_LED_BASE = 0xAA; while(1){ // Do some processing before entering Sleep Mode *(volatile unsigned int*) AHB_LED_BASE = ~ *(volatile unsigned int*) AHB_LED_BASE; for(i=0;i