Why long ISRs are so bad?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have seen many people in this forum telling that too much code in a ISR is not really a good idea. In my current project (commercial project) I have a long ISR which handles the menu of the device and calls the functions for all the settings, with no problems until now. Thats why I am so curious about why you don't like long ISRs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IF you cannot afford to have any interrupt events missed AND the time between successive interrupts from a source is less than the processing time in any interrupt, you will have a problem. In addition the delay to process an interrupt because of another may cause problems. The usual solution for multiple interrupts is to make sure each one is processed quickly. In your case it sounds like you only have one ISR and the time to process it is less than the space between successive interrupts.
HTH.
Dave Raymond

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply Dave.

Actually i have 2 ISRs. One from the uart receive, with which i receive large blocks of data, and one triggered from an external interrupt to enter a menu and modify them. Your answer was exactly what i was expecting to hear. I was just afraid if there is any problem I am unware of.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 'large block of data' received after a uart interrupt cant be much bigger than one byte can it? At 9600 baud, chars arrive about one per ms. If that menu processing takes longer than that, might miss chars.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The large block of data can be as much as 16 kilobytes and i receive it with up to 16 kilo interrupts. Until receiving an end of file statement the menu interrupt is disabled. The menu ISR actually can last up to several minutes (depending on the user of the device), but while this time there is no need for receiving data. The concept of the product is receive once, change many times, forward altered data much more times to another machine making it independed from the pc.