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++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

the program doesn't return from interrupt

Altera_Forum
Honored Contributor II
1,850 Views

I'm using the uart interrupt.  

when data is received trough the uart  

the program jump to perform the interrupt  

 

the problem is that the interrupt flag of the uart stays on  

and so the interrupt is perform again and again and doesn't return? 

 

is the responsibility of clearing the interrupt is mine? 

how do I clear the interrupt ?
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
634 Views

Are we talking SDK or HAL? 

 

HAL: 

By default, the HAL ISRs should handle all of the IRQ clearing activity. 

 

SDK: 

I'm honestly not sure what is handled and what isn't. I'm sure others will be able to answer this one though. 

 

If you're not using Nios II, then the latter case would apply. 

 

Also, how do you know that the UART is the cause of your problem? Have you set a breakpoint in your ISR to see if that's where the failure is happening? 

 

Cheers, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

i'm talking on HAL 

and i don't see that it clears the interrupt
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

I have set a breakpoint in the interrupt handler and so that it perform the handler routine. 

and then goes to check if there are other pending interrupt and return to perform the uart interrupt's handler routine again and again
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

Are you using your own interrupt handler or the one from the HAL? 

 

The HAL UART driver clears the interrupt in the function alt_avalon_uart_irq before processing it. 

 

But it is possible that if you're single stepping then the hardware will have interrupted again before you have stepped out of the interrupt routine. For example, if transmit interrupts are enabled then it will take a few ms to send the characters which have been queued up, but several tens of seconds for you to step out of the interrupt routine. 

 

One thing I notice when stepping through interrupt routines is that the timer interrupt is almost always set (since it takes more than 10ms for me to step a few times). I solve this by stepping out of alt_irq_handler using the step out button rather than one line at a time.
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

thanks wombat  

 

I'm using my own interrupt handler. where can I find the hal's handler ? 

it is true that I get interrupted by the timer , but the problem is that the uart interrupt doesn't get clear and so it is called again and again
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

ok found the Hal's handler it is in  

altera_avalon_uart.c
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

If you're using your own handler then you need to make sure the HALs one doesn't get installed as well. The easiest way to do this is to run your initialisation code from main, but make sure the first thing it does (before touching any registers etc) is to unregister the interrupt handler. 

 

Another way to do it (if you aren't replacing the whole initialisation scheme) would be to copy the UART files into your system library project and edit them there to replace the HAL code with your own.
0 Kudos
Altera_Forum
Honored Contributor II
634 Views

don't call fscanf or fgets from with in the interrupt handler

0 Kudos
Reply