This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Warning:multiple call to a segment

Hi
i have written a ISR for external intr 0 and from this routine i am calling other functions.
On compiling above routines i am getting following warning

Warning:Multiple call to segment
Caller1:?PR?ex0_ISR?main
Caller2:?C_C51STARTUP

(where ex0 is the name of isr given in file)
there was same warning for each function which i had called from isr
Can anybody give me the reason for this ?
and solution ?

Parents
  • If you call the same routine from the main code and an ISR you are treading on VERY THIN ice. The possibility exist that while this routine is ececuting in the main loop an interrupt will happen that executes the same routine. For "normal" routines the compiler does not "protect" intermediate variables and thus if that routine get interrupted in the middle and executed by the ISR all things awful can happen. A mechanism, declaring the routine reentrant, exist to take care of this, I, for one recommend not to use it, instead do not call routines from both non-ISR and ISR code. My recommendation against calling the same routine at two levels is maintainability based.

    Erik

Reply
  • If you call the same routine from the main code and an ISR you are treading on VERY THIN ice. The possibility exist that while this routine is ececuting in the main loop an interrupt will happen that executes the same routine. For "normal" routines the compiler does not "protect" intermediate variables and thus if that routine get interrupted in the middle and executed by the ISR all things awful can happen. A mechanism, declaring the routine reentrant, exist to take care of this, I, for one recommend not to use it, instead do not call routines from both non-ISR and ISR code. My recommendation against calling the same routine at two levels is maintainability based.

    Erik

Children
  • Erik is right: unlike "normal" 'C', C51 functions are not inherently reentrant.

    The linker is warning you that there is a possibility that the function might be called again from the interrupt while it is already executing in the non-interrupt code. Only you can tell whether this could actually ever happen in practice and, if it could, whether it would be safe...