Shop OBEX P1 Docs P2 Docs Learn Events
SX/B error on Pass 2 - Address is not within lower half of memory page.... — Parallax Forums

SX/B error on Pass 2 - Address is not within lower half of memory page....

RobotWorkshopRobotWorkshop Posts: 2,307
edited 2008-03-22 19:17 in General Discussion
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.

Comments

  • BeanBean Posts: 8,129
    edited 2008-03-20 19:52
    You're subroutine declarations are too far down in memory (on the lower half).

    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

    ·
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2008-03-20 20:01
    I can definitely give that a try. So does that mean I can just move the whole body of the ISR toward the end of my program and just keep the beginning set aside for the initial definition of the interrupt routine, the declaration of all the subroutines, and the declarations of functions? Just looking for the best method of structuring SX/B programs going forward.

    Other than a few odd issues like this, programming the SX chips with SX/B has been great!

    Robert
  • BeanBean Posts: 8,129
    edited 2008-03-20 21:06
    Yep that is the best way to do it.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • Larry MolterLarry Molter Posts: 28
    edited 2008-03-22 19:17
    Oh, man. This is great! I had the same problem and ended up abandoning interrupts altogether. Now I understand.
Sign In or Register to comment.