Shop OBEX P1 Docs P2 Docs Learn Events
SX/B PAGE Errors — Parallax Forums

SX/B PAGE Errors

heichheich Posts: 26
edited 2007-12-20 19:56 in General Discussion
Hi to everybody.

First of all i'll introduce myself. I'm Hector Garcia from Mexico(i appologize if i have a bad english), i do PC programming since almost 15 years.
I'm new to parallax programing; since I'm a VB programmer, SXB its being easy to me.

Now, i'm changing the code for a GPS Parallax Module, with a SX20 uC on it, using the open source provided from Parallax to the module.

My task is to add almost 150 fixed bytes in order to be sended at startup as
ASCII characters from the GPS module to another device connected to it, via the SIO pin.

I use SX Key IDE, SX/Blitz to program the chip, and the code is in SXB.

When i add those bytes - on DATA tables- plus the commands required to send the data,
and i call to assemble the code, i get an error regarding to the pagezise: "Adress exed memory limit" .

I now i made one of two situations: or i fullfilled the entire 2k memory of the uC, or i exeded the first PAGE with all the code on it.

Usually I do programming Microchip PIC's, and when i get those errors, i divide the code across page boundaries, using PAGESET command.

I read the faqs for SX Microcontroller, published on this forum by G

Comments

  • JonnyMacJonnyMac Posts: 9,217
    edited 2007-12-20 02:43
    You don't have to worry about page boundaries with SX/B. What may be happening -- and one can only speculate without seeing your code -- is that you are using a lot of native instructions (e.g. PAUSE) that each consume code space. You will always save space by wrapping any time-based SX/B instruction in a subroutine or function so that it only gets compiled (expanded to assembly code) one time.

    Comments and white space have no effect on program size.
  • heichheich Posts: 26
    edited 2007-12-20 03:26
    Hi John
    Thanks for your answer.
    Here is the code attached, my lines are all the DATAS after the Pgm_ID label. They're the ASCII commands required to set up a GPRS modem connection. (i've changed the server addres, and the Host IP addres ). My subroutines are between Get_Info and Get_Valid labels, plus a TX_STR routine (taked from SXB Reference Manual)
    to replace the original TX_BYTE routine

    JohnyMac said...

    What may be happening -- and one can only speculate without seeing your code -- is that you are using a lot of native instructions (e.g. PAUSE) that each consume code space

    In fact, there is a routine called WAIT_MS that i removed thinking that PAUSE would give me more space than.
    After reading your post i changed all those PAUSE commands to WAIT_MS calls, and it worked!

    The code is working, but i still have the Page trouble.

    I wish to know if there is a sample code somewhere to understand the page boundaries.
    And to know how much memory i am using.
    Perhaps this comment is useless, on Microchip MPLAB IDE there is a window called "Program Memory"
    wich allows to see the memory addreses used by program, and to determine the Page locations.
    Is on parallax tools something similar?

    Thanks, again
    Regards

    Hector
  • JonnyMacJonnyMac Posts: 9,217
    edited 2007-12-20 05:34
    Well, it looks like you have legitimately used most of the code space. There are are some redundancies that might help -- you seem to be looking for "GPRMC" in several places; why not just look once, parse out the data from that string, then make it available for the next request.

    Like you, I'm a customer, so I don't know what Parallax is doing vis-a-vis improvements to the SX-Key IDE.
  • JonnyMacJonnyMac Posts: 9,217
    edited 2007-12-20 05:44
    As you start to trim and clean things, here's a subroutine you can use to wait for a specific string:

    SUB WAIT_STR
      tmpW1 = __WPARAM12                            ' starting address of string
      
    Reset_Str:
      tmpW2 = tmpW1                                 ' copy start
      DO
        READINC tmpW2, tmpB2                        ' get char from string
        IF tmpB2 = 0 THEN EXIT                      ' if 0, we're done
        tmpB1 = RX_BYTE                             ' get char from stream
        IF tmpB1 <> tmpB2 THEN Reset_Str            ' if not equal, start again
      LOOP
      ENDSUB
    



    To use this subroutine your code would look like this:

    WAIT_STR "$GPRMC"
    

    Post Edited (JonnyMac) : 12/20/2007 5:50:25 AM GMT
  • heichheich Posts: 26
    edited 2007-12-20 14:58
    Thanks so much John.
    JonnyMac said...

    you seem to be looking for "GPRMC" in several places; why not just look once, parse out the data from that string, then make it available for the next request.

    Its true! i was letting more of the original code untouched, but, now that you tell me (and after another detailed reading to your N&B article), it seems that
    the code itself needs to be optimized, keeping the original logic, of course.

    I'm learning with every word i read. Now, i know that i have used almost all the space on the chip,
    there aren't page boundaries troubles -like in PICS- to worry about and,
    i should pay more attention to the readings of another articles, such your N&B, i see now that you did the same optimization regarding "GPRMC" string.
    I'll follow your recommendations.

    I did a tricky code meter, suggested on G
  • heichheich Posts: 26
    edited 2007-12-20 19:56
    Solved!!

    I followed your recommendations Jonn.
    I made a routine, based on yours, to wait for a string specified on a DATA table;
    after changing all the redundant "GPRMC" callings, I got 73 lines of NOPS free!!

    Also, i made another test, there was a single active lookup for "GPGGA" into Get_Sats soubroutine,
    i made a table with the string, and change the commands WAIT_FOR_GPS for a single call to my routine,
    with the table name as a parameter. It gave me 6 more lines than before!!.

    I put the result code attached, it's plenty of trash, but i think it could be useful for future reference (begginer thoughts)


    Thanks again!!
    Best Regards
Sign In or Register to comment.