SX/B error on Pass 2 - Address is not within lower half of memory page....
![RobotWorkshop](https://forums.parallax.com/uploads/userpics/915/nCTRZ4MIBWKDB.jpg)
On my latest program i've been having some issues where I keep getting an SX/B error on Pass 2 "Address xxx is not within lower half of memory page".
These errors are a bit frustrating to fix but I think I have a work around. Perhaps there is a better way to fix them but here is what worked for me.
I've got a program that does quite a bit of processing within the ISR routine. I can get everything done within the alloted interval setup for the ISR but there are quite a few instructions which makes the ISR longer than usual. What happened as it grew was that when I tried calling a subroutine (in particular RX_BYTE) I started getting these errors. If I cut out most of the ISR code the error disappears.
So, I moved out a large portion of the ISR code into its own subroutine after all the main program code that I can call from the ISR. That cleared up the error on pass 2 regarding calling RX_BYTE but then I would get that error on pass two with regards to the ISR code I wanted to call. Ouch!
As a work around for my workaround, I then created another subroutine right at the beginning of my program before the main routine. After the program starts and setups the ports it just jumps over this new subroutine to main. The new subroutine is just two lines. the first does a GOSUB to the extra ISR CODE and then a return. With that the errors all disappeared. I still have to test this new version on the real hardware but at least it compiles now.
BTW: dealing with these types of errors would be an excellent topic to cover in one of the upcoming SX/B books.
These errors are a bit frustrating to fix but I think I have a work around. Perhaps there is a better way to fix them but here is what worked for me.
I've got a program that does quite a bit of processing within the ISR routine. I can get everything done within the alloted interval setup for the ISR but there are quite a few instructions which makes the ISR longer than usual. What happened as it grew was that when I tried calling a subroutine (in particular RX_BYTE) I started getting these errors. If I cut out most of the ISR code the error disappears.
So, I moved out a large portion of the ISR code into its own subroutine after all the main program code that I can call from the ISR. That cleared up the error on pass 2 regarding calling RX_BYTE but then I would get that error on pass two with regards to the ISR code I wanted to call. Ouch!
As a work around for my workaround, I then created another subroutine right at the beginning of my program before the main routine. After the program starts and setups the ports it just jumps over this new subroutine to main. The new subroutine is just two lines. the first does a GOSUB to the extra ISR CODE and then a return. With that the errors all disappeared. I still have to test this new version on the real hardware but at least it compiles now.
BTW: dealing with these types of errors would be an excellent topic to cover in one of the upcoming SX/B books.
Comments
Make your interrupt routine jump over the subroutine declarations.
INTERRUPT
GOTO Int_Start
mySub SUB 2
Int_Start:
' INTERRUPT CODE HERE
RETURNINT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Other than a few odd issues like this, programming the SX chips with SX/B has been great!
Robert
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·