Dear everyone: If non-reentrant funtion is interrupted ,will it cause error? In my non-reentrant funtion defined some local variables, if it is interrupted, non-reentrant funtion will not preserve local variables, It will cause error! How can I avoid this problem?
If non-reentrant funtion is interrupted ,will it cause error? NO. (if it did 99% of the code written with Keil would blow up). The function Reentrancy is only to be considered when a function is used by BOTH an interrupt and main Erk
It's not the non-reentrancy of that function that causes your (suspected/actual?) problem. This will only cause problems if that interrupt actually does re-enter that particular function of yours. If you want to do that, then the function *must* be flagged as reentrant.
Use another register bank for your interrupt service routine by "using X" command. void INT1 (void) interrupt 2 using 1-2 ^^^^^ { }