|
CARM-LCP2292: Function calls from within ISRsNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Doug Paulsen Posted 27-Aug-2006 14:57 Toolset ARM |  CARM-LCP2292: Function calls from within ISRs Doug Paulsen Greetings: I'm desperately chasing obscure bugs in somebody else's code. I say this before I state that some of the ISR's are embarrassingly long, and have multiple calls to utility functions. In a knowledge base article (http://www.keil.com/support/docs/2910.htm), there is a warning that "it would be impossible to call other functions within the interrupt service routines". Since the code under scrutiny routinely does exactly this, how bad is it? It seems to me the compiler only saves registers used within the __isr routine, therefore any functions called from there may overwrite registers which may or may not be pushed and popped by the IRS itself. Is this correct, or do I worry to much (I'm getting desperate for a solution here...). Thanks, Doug | | Read-Only Author Mike Kleshov Posted 27-Aug-2006 15:48 Toolset ARM |  RE: CARM-LCP2292: Function calls from within ISRs Mike Kleshov From the knowledgebase article: Yes, it is required to switch the CPU into the User/System Mode. Otherwise it would be impossible to call other functions within the interrupt service routine. To be honest, I cannot see why it would be impossible to call other functions. They should work just fine. Maybe someone else in this forum can explain. If one of those functions happens to be non-reentrant you can run into obscure bugs. As usual, if there are variables shared between ISRs and normal code, special care must be taken when accessing them in normal code. Regards, - mike | | Read-Only Author Dan Henry Posted 27-Aug-2006 16:43 Toolset ARM |  RE: CARM-LCP2292: Function calls from within ISRs Dan Henry "... some of the ISR's are embarrassingly long, and have multiple calls to utility functions." What are these utility functions of which you speak? Are they C library functions or functions that somebody else wrote? If they are C library functions, note that not all library functions are reentrant, so if those non-reentrant functions are called from mainline code and ISRs, you could have a problem. The manual lists which library functions are reentrant: http://www.keil.com/support/man/docs/ca/ca_library.htm On the other hand, if somebody else wrote the utility functions and you have their source code, you should be able to judge for yourself whether or not they are reentrant. | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|