What command will stop the ISR and return to the main loop?
OK, “RETURN” seems to work. I was trying “EXIT” and “BREAK”.
In most dialects of C, you code nothing special. The compiler knows you declared the function as an ISR. It generates the correct code to restore used registers and pop the PC from the stack. Your ISR code must do the right thing to clear the interrupt cause, or there will be another immediate interrupt (a loop).sdisselhorst:
What command will stop the ISR and return to the main loop?
What I needed was a way to stop the ISR before it reached the end. Thanks!
sdisselhorst:
What I needed was a way to stop the ISR before it reached the end. Thanks!
use
if (condition) {
code here
}
else {
more code
}
}
} // end of ISR
just like you’d do in an ordinary function.
Using ```
return;
Why is that? Is that because return statements are effectively branch statements and you don't want to the program to get messy? Or is it something to do with processing time and how long you want to stay in the interrupt. Or did I totally miss the point.stevech:
Using ```
return;
Its just a coding standard that people claim makes code more readable but I highly disagree and think multiply returns is far more easy to follow.
Multiple return in many portion of code means:rrpilot:
Its just a coding standard that people claim makes code more readable but I highly disagree and think multiply returns is far more easy to follow.
-
poor conception
-
good conception but bad coding
-
hard to debug
-
hard to read for a majority of people
-
impossible to modify without unwanted side effects.
Angelo
poor conception
good conception but bad coding
hard to debug
hard to read for a majority of people
impossible to modify without unwanted side effects.
If you get a coder that writes messy code you are going to have these issues regardless. Every instance that is necessary to bail out of the function your going to need to surround your code with if…then…else statements. Now all is fine and dandy when you only have 1 or 2 conditions but even 2 if…then…else blocks starts to get messy. In my opinion it all comes down to organizing your code and using comments to explain flow.
I don’t mean to highjack this thread so I’ll stop there, it just cheeses me off when people say that if you use multiple returns your code is bad.
Multiple return() statements in one function makes code hard to debug. Quite like goto's. I use both, very sparingly. I prefer, in a deeply nested situation, to use a goto labelxx instead of a return(), as a rule. Usually the goto is due to an unexpected condition.rrpilot:
poor conception
good conception but bad coding
hard to debug
hard to read for a majority of people
impossible to modify without unwanted side effects.
If you get a coder that writes messy code you are going to have these issues regardless. Every instance that is necessary to bail out of the function your going to need to surround your code with if…then…else statements. Now all is fine and dandy when you only have 1 or 2 conditions but even 2 if…then…else blocks starts to get messy. In my opinion it all comes down to organizing your code and using comments to explain flow.
I don’t mean to highjack this thread so I’ll stop there, it just cheeses me off when people say that if you use multiple returns your code is bad.