This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

AT91SAM7S: nested interrupt function

Hi,

I want to add a function handling nested interrupts for the controller. Could you tell me the right position to add this function?

startup-file:

Undef_Handler   B       Undef_Handler
SWI_Handler     B       SWI_Handler
PAbt_Handler    B       PAbt_Handler
DAbt_Handler    B       DAbt_Handler
;IRQ_Handler     B       IRQ_Handler
IRQ_Handler     B       irq_fnct
FIQ_Handler     B       FIQ_Handler

irq_fnct

   //do some stuff - nested interrupt

I've add one breakpoint to the irq_fnct but it seems that the programm will not reach this part if a interupt occur.

I'm working with the atmel controller AT91SAM7S.

best regards
Peter

  • In order to use nested interrupts on an AT91SAM7S, you will need to re-enable interrupts somewhere (usually near the beginning) of the interrupt service routine.

  • I want to add a function handling nested interrupts for the controller

    why? what is the problem you are trying to solve?

  • If I understand you right, then I have to add this function at the beginning of all ISR. And I have to write this function in one of my c-files.

    I thought it would be possible to add this function in the startup file of the processor and if an interrupt occur the progamm counter will go to the addr of the IRQ_Handler (vector) and after that the irq_fnct will be executed...

    Undef_Handler   B       Undef_Handler
    SWI_Handler     B       SWI_Handler
    PAbt_Handler    B       PAbt_Handler
    DAbt_Handler    B       DAbt_Handler
    ;IRQ_Handler     B       IRQ_Handler
    IRQ_Handler     B       irq_fnct
    FIQ_Handler     B       FIQ_Handler
    
    irq_fnct
    
       //enable nested interrupt, change the mode
       //execute the ISR
       //disable interrupts and go back to usr mode
    
    
    

    I've seen a example of atmel using keil uvision (but with the GCC compiler) and they add the function (responsibel for adding the availability of using nested interrupts) to the IRQ_Handler (vector) in the startup file.

    best regards
    Peter

  • I've several different interrupts (ethernet, spi, system timer, usart, timer...). Therefore I want to add the ability for nested interrupts. I've found the general code in the arm architecture reference manual.

    best regards
    Peter

  • wait it a minute. having multiple interrupt source does not justify nesting them - are you aware of the possible downsides? think IRQ/FIQ stack space, for example, which is normally limited. In most cases, if your system cannot have it work done on time without nesting interrupts, you need to ask yourself a few questions.


  • wait it a minute. having multiple interrupt source does not justify nesting them - are you aware of the possible downsides? think IRQ/FIQ stack space, for example, which is normally limited.

    You can configurate the IRQ stack space in the startup file - or is there something I have to think about?

    In most cases, if your system cannot have it work done on time without nesting interrupts, you need to ask yourself a few questions.

    It's very easy that two interrupts IRQ can occur at nearly the same time. For example if a new ethernet frame recevied and a user interrupt (external - user pressed one button) or the system timer interrupt will occur.

  • Even if interrupts occur at nearly the same time, it is the job of the VIC to arbitrate. Are you working on a trully time-critical application? I'm currently working on a product that has an Ethernet connection, a USB connection, a continuously employed UART, a hardware timer generating interrupts and an LCD controller. all these are serviced well and concurrently without nested interrupts. If an LPC2478 (at 72[MHz]) can do that with time to spare, can't your processor...? Of course you can adjust stack sizes, but that consumes RAM that you might need for something else.


  • Even if interrupts occur at nearly the same time, it is the job of the VIC to arbitrate. Are you working on a trully time-critical application? I'm currently working on a product that has an Ethernet connection, a USB connection, a continuously employed UART, a hardware timer generating interrupts and an LCD controller. all these are serviced well and concurrently without nested interrupts.

    How did you organized your different interrupts? Do you work without an operating system?

    The current project I'm working on has also ethernet, uart, an tft with touch, as well as user inputs (buttons) - without any kind of O/S.

    Of course you can adjust stack sizes, but that consumes RAM that you might need for something else.
    That's right... but most of the code is executed in sdram and the stack is located in the internal sram.

  • Nested interrupts are meningful if you have a low-priority interrupt with long running time - then a higher-priority interrupt can jump in and get serviced before the processor returns to the slow interrupt.

    But best of all is to have no slow interrupts, i.e. making sure that even if all interrupts get trigged at the same time, the sum of the individual times will be less than your worst-case requirements. You may use the FIQ for one or possible multiple interrupts that are extremely time-critical.

    Your life will be way easier if you can just show that the total runtime of all possible interrupts is shorter than your worst-case requirements. As soon as you start with nested interrupts, you get into big troubles to matematically prove that your system can handle real-time - how do you analyze all possible combinations of nesting? And remember that with nesting, one interrupt source may interrupt another interrupt handler multiple times.

    Many times, it is better to have an interrupt just catch a character or set an event, and then use an RTOS to allocate time for a task to perform the actual work. This makes sure that you will not have any slow interrupts.

  • How did you organized your different interrupts? Do you work without an operating system?

    I happen to work with RTX, but an RTOS should not be a factor in the decision to use/avoid nested interrupts. some of my tasks wait for signals from interrupts, to do some later, heavy processing. In the end, you want to build a stable system. As Per mentioned, you cannot do that if you run risk of running out of stack space. Keep your interrupt service routines short. do heavier processing in your main loop (don't forget synchronization issues). if you work efficiently, that should suffice.

  • Nested interrupts are meningful if you have a low-priority interrupt with long running time - then a higher-priority interrupt can jump in and get serviced before the processor returns to the slow interrupt.

    Only one of my interupts (system timer - which will execute all 100ms) has a longer running time - e.g. controlling and deleting ARP caches, renewing the licence for dhcp. The way to set a lot of global variables for each event (e.g deleting arp cache) and poll them in the main routine, sounds a little bit unefficient to me.

    Therefore I want to enable nested interrupts to be able to handle all the other interrups if the system timer has also expired. The FIQ is not available for peripherial interrupts, but I'll test if it is possible to work priorites for each interrupt. Maybe that would work.

  • The way to set a lot of global variables for each event (e.g deleting arp cache) and poll them in the main routine, sounds a little bit unefficient to me.

    So you're betting your project on a known bitter, hard-to-do cure, against a vaguely perceived disease.

    In other words, your intended cure is causing worse problems than you have right now. So why pursue it, ignoring the advice you've come here to ask for?

  • The way to set a lot of global variables for each event (e.g deleting arp cache) and poll them in the main routine, sounds a little bit unefficient to me.

    Wouldn't you merely need one global variable, which tells the main routine "Do all the stuff that previously took place in the timer tick routine?"