Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
990 Views

alt_irq_disable_all() not allowed in isr

Hello, 

 

Simple and general newbie question. I have inherited someones code which uses HAL irq legacy functions.  

I noticed from the API reference that alt_irq_disable_all() is not allowed to be called from ISRs but alt_irq_enable_all() 

is allowed.  

 

The code I inherited uses the alt_irq_disable_all() , alt_irq_enable_all() pair within ISRs. Finding a way to get rid of the  

disable call in the ISRs was going to be my next move. Since these functions are normally used as a pair, I just wanted to get 

confirmation from experts that yes using the disable call in an ISR should absolutely and always be avoided. 

 

This code has seemingly random failures, it seems this may be the culprit. 

 

Thanks!
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
46 Views

Interrupts and getting them right is a harder problem than it seems at first. In general, if you have a lot going on in a device driver interrupt routine you are doing it wrong.  

 

Some rules I follow: Make ISRs as small as possible. More than 10-20 lines is probably too big. Never disable interrupts within an interrupt routine. If you think you need to your interrupt priorities are probably wrong. Don't use coroutines in an ISR. Don't loop in an ISR. Never modify the same thing in both an ISR and in your main code, I.E. no linked lists. Never modify something in more than one ISR. 

 

If you follow these rules, you will have a much easier time of it. Some old school devs do way too much in interrupt routines. Their code always has weird infrequent and hard to track down bugs in it.
Altera_Forum
Honored Contributor I
46 Views

I cant think of a reason why alt_irq_disable_all() would not be allowed, while alt_irq_enable_all() would. All they are doing is conditional modifying the global interrupt enable. 

 

I'm guessing using those functions aren't the direct cause of your problem.