#include "uart.h" #include "interrupts.h" /** @brief The undefined instruction interrupt handler If an undefined instruction is encountered, the CPU will start executing this function. Just trap here as a debug solution. */ void __attribute__((interrupt("UNDEF"))) undefined_instruction_vector(void) { uart_puts("Undefined instruction occured"); while( 1 ) { /* Do Nothing! */ } } void __attribute__((section(".interrupt_vectors.data"))) (*system_reentry_point) (void); void __attribute__((interrupt("ABORT"))) __attribute__((section(".interrupt_vectors.text"))) abort_handler(void) { uart_puts("nwm\r\n"); system_reentry_point(); } /* Here is your interrupt function */ void __attribute__((interrupt("IRQ"))) __attribute__((section(".interrupt_vectors.text"))) irq_handler(void) { /* You code goes here */ uart_puts("GOT INTERRUPT!\r\n"); local_timer_clr_reload_reg_t temp = { .IntClear = 1, .Reload = 1 }; QA7->TimerClearReload = temp; // Clear interrupt & reload } /* here is your main */ int enable_timer(void) { QA7->TimerRouting.Routing = LOCALTIMER_TO_CORE0_IRQ; // Route local timer IRQ to Core0 QA7->TimerControlStatus.ReloadValue = 100; // Timer period set QA7->TimerControlStatus.TimerEnable = 1; // Timer enabled QA7->TimerControlStatus.IntEnable = 1; // Timer IRQ enabled QA7->TimerClearReload.IntClear = 1; // Clear interrupt QA7->TimerClearReload.Reload = 1; // Reload now QA7->Core0TimerIntControl.nCNTPNSIRQ_IRQ = 1; // We are in NS EL1 so enable IRQ to core0 that level QA7->Core0TimerIntControl.nCNTPNSIRQ_FIQ = 0; // Make sure FIQ is zero uart_puts("Enabled Timer\r\n"); return(0); }