Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12616 Discussions

How to write jtag uart interrupt code ?

Honored Contributor II

I made a Nios II embedded system, which the jtag uart module interrupt connects with the inner interrupt controller inside the Nios II.  

I try to write a c program to implement the interrupt, so I checked but it looks like there are no demo code. Then I checked jtag uart driver and wrote code as following: 

# include "..\ddr3_test_bsp\HAL\inc\sys\alt_irq.h"# include "..\ddr3_test_bsp\drivers\inc\altera_avalon_jtag_uart.h" 


int main() 


altera_avalon_jtag_uart_state jtag_strc; // create the structure 

jtag_strc.base = JTAG_UART_BASE;  







My question is: inside the function "altera_avalon_jtag_uart_init()": 


alt_ic_isr_register(irq_controller_id, irq, altera_avalon_jtag_uart_irq, sp, NULL); 


But interrupt handler altera_avalon_jtag_uart_irq() is a fixed function. If when the interrupt happens, I want to call the custom function which I create by myself (e.g.: I want to light up a led or print something in console), how should I do?  


If someone can provide the reference code, it will be great. 


Thanks in advance.
0 Kudos
1 Reply
Honored Contributor II

There is nothing special about the JTAG UART and writing an interrupt handler for it would be the same as for any other device. 


It's a bit old, but this example is as good a starting point as any if you've never done that before: 


If you are trying to avoid cascading from your own ISR to the Altera HAL driver one, probably the easiest thing would be to clone the Altera HAL driver locally and modify it how you see fit.
0 Kudos