We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I call some sub-routine in ISR. And I mark the ISR as "using 1". But I find out this will lead to the error of parameters passing from ISR to the sub-routine. How come?
The problem is probably that the called function is assuming it will be called with the selected register bank set to something other than one. By default, the compiler will generate object code that accesses registers by using direct addressing. This is helpful in generating efficient code. For example, using direct addressing, it is possible to push the value of a register onto the stack using a single instruction:
PUSH AR0
... interrupt using 1 { functionone(); } void functionone (void) using 1 { } Erik
Erik, That is not the best way. Each function that has a using will save the PSW on the stack (which is a waste). Restoring the PSW from the stack destroys any return value of type bit. Using REGISTERBANK is simpler. For example:
#pragma REGISTERBANK(1) bit functionone(void) { return( 1 ); } void functiontwo( char c ) { ... } myISR interrupt n using 1 { if( functionone() ) functiontwo( 'c' ); }
You live and learn. Anyhow we both agree that a subroutine called from a routine/ISR using a given bank must "know" which bank to operate in. Erik