Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

the program doesn't return from interrupt

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 ?

8 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i'm talking on HAL

    and i don't see that it clears the interrupt
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.