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++
12612 Discussions

UART stops working when interrupts are enabled

Honored Contributor II

Hi all, 


I have used the NIOS II environment for several years, but am at a loss at the following problem: The UART stops working (no more output) when I enable UART RX interrupts. I have tested it with both the JTAG UART and a regular UART routed to some pins on the FPGA. This has been working on previous designs, but I recently changed my PC and installed Quartus II 12.1 Build 177. Not sure if this is a version issue, but it sure is a weird behavior. Also note that I did step through in the debugger and the "alt_irq_register" function returned 0, meaning that it was successful. 


Here's the code that I'm using to enable the JTAG UART interrupt and register the ISR function: 


void JTAG_UART_init(){ printf("Enable interrupt\n"); IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(JTAG_UART_BASE, ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK); // enable interrupt printf("Register interrupt\n"); int a = alt_irq_register(JTAG_UART_IRQ,0,JTAG_UART_ISR); // setup handler printf("Initialize ringbuffer\n"); Ringbuffer_init(); } 


When I step through the code I get UART output right until where the IRQ is registered (setup handler), so I get the "Register interrupt" output, but not the "Initialize ringbuffer" message. Did anyone else run into this issue or have an idea what the issue could be? Any comments/feedback is highly appreciated. 



0 Kudos
1 Reply
Honored Contributor II


I did some more debugging and it turns out that as soon as the UART RX interrupt is enabled and its ISR function is registered, the ISR gets called over and over again, even though that there is nothing being received. 

What's strange here is that the code I'm using (see post above) is what I've been successfully using for a while and it is what I find online as well. The only change is that I'm now using a DE0 Nano board instead of a Cyclone III DSP development kit, but that should not matter as NIOS II is still the same. On the other hand, I'm using Quartus II 12.1 instead of the 11.1 version earlier. 


Some additional info: 

I am toggling an LED every time the ISR executes and it looks like a 1s on and 1s off blink when I run the code. When I send characters to the UART (which should trigger the ISR), I do see some extra blinks, meaning that the ISR is getting called upon UART receive. 

So the question remains: What causes the UART ISR to be triggered and why does that bring the UART transmit functionality to an immediate halt??? 


Any comments or insight is highly appreciated!!!
0 Kudos