- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page