Community
cancel
Showing results for 
Search instead for 
Did you mean: 
DRaja2
Beginner
820 Views

UART interrupt using alt_ic_isr_register

I am trying to write a simple interrupt service routine for UART. MY code is as follows:

in main function:

 alt_ic_isr_register(UART_0_IRQ_INTERRUPT_CONTROLLER_ID,

       UART_0_IRQ,

 &receive_data,

 uart_capture_ptr,

 0x0);

 

 

ISR function

static void receive_data(void* context)

{

 // put new char into buffer from UART

 volatile int *uart_capture_ptr = (volatile int*) context;

 // Store the value in the Buttons edge capture register in *context.

 *uart_capture_ptr = IORD_8DIRECT(UART_0_BASE, 0x0);

 // Reset the Buttons edge capture register.

 IOWR_16DIRECT(PIO_0_BASE, 0, (alt_16)uart_capture_ptr);

 

}

 

The program builds but seems to terminate upon the initialisation of the isr (i.e whilst executing the alt_ic_isr_register function). Does anyone know why this is the case and how I should fix it?

0 Kudos
1 Reply
GuaBin_N_Intel
Employee
179 Views

Please see an example of interrupt initialization and ISR service for PIO https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/nios2/n2sw_nii52006.pdf, pg8-16 & 8-17. To confirm where it fails, try to print out the return code of "alt_ic_isr_register".