Shop OBEX P1 Docs P2 Docs Learn Events
memory map in sx48 with sx/b — Parallax Forums

memory map in sx48 with sx/b

stefstef Posts: 173
edited 2007-07-27 18:08 in General Discussion
Hi

Is thier a way to see how much memory a program is using and how much thier is left to program in a sx48 usinf SX/B??

My program is getting bigger and bigger and I'm still finding things I can do. So I'm programming and testing and compiling but I think at some point I will be stuck on memory. I'm now on 990 line's. They are not all code (I plase also comments in it and I think that is not compiles to the chip)
That is what I want to check now.

If the limit is reached. Can we add on memory by I2C???

Stef
·

Comments

  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-07-26 14:41
    Use Run>>Device to see home much flash is being used by your program. You can't add program memory to the SX, but you could move data to an external device.
  • stefstef Posts: 173
    edited 2007-07-26 15:09
    Hi

    I chek and see that is until D20 filled and from thier it is FFF. So it is untill FF8 adressed. That means I have used more than 2/3.

    I can't add any programmemory you tell me. So what if it is full and my program is not finisched?

    stef
  • BeanBean Posts: 8,129
    edited 2007-07-26 15:16
    stef,
    · Then you optimize the code for space.
    · Put anything that generates alot of code that is used more than once in a subroutine.
    · Find ways to change the code to MAKE is able to be put into subroutines.
    · Find other ways to do something that uses less code space.
    · Use some assembly if you need to.
    · I went though all of these when I was coding the SD Data Logger. In the end a start converting stuff to assembly just to save a couple instructions. It was that tight...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Teacher: What is the difference between ignorance and apathy ?
    Student: I don't know and I don't care
    Teacher: Correct !
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-07-26 15:56
    To Bean's point, you can save a lot of program memory with subroutines -- and by encapsulating "big" SX/B instructions into subroutines and functions. PAUSE, for example, can generate a bit of code and we use it all the time so it make sense to put it into a subroutine where the actual PAUSE instruction is only compiled once. This subroutine is in almost every one of my programs:

    ' Use: DELAY_MS mSecs
    ' -- delays program in milliseconds
    
    SUB DELAY_MS
      IF __PARAMCNT = 1 THEN
        tmpW1 = __PARAM1
      ELSE
        tmpW1 = __WPARAM12
      ENDIF
      PAUSE tmpW1
      ENDSUB
    



    The definition line for this subroutine is:

    DELAY_MS        SUB     1, 2                    ' delay in milliseconds
    



    Since I use these so much, I actually have them in external files so that I can put them into any program without copy-and-pasted. I've attached those files for you.

    Look for any SX/B instruction that it time-associated, things like PAUSE, PAUSEUS, SERIN, SEROUT, etc. -- these are all good candidates for encapsulation into a subroutine or function to reduce code space.
  • stefstef Posts: 173
    edited 2007-07-26 20:59
    Hi

    Thanks a lot for this good advice. I will continue my program and look for things I can put in subroutines. The project wil be a translator for dome commands. We are neding this to stear diffrend types of domes (like Pelco, bosch, ....) with one code. The problem is that I have a lot of fix data (stored under DATA) to use. That I can't put in a sub. It is different and it needs to be thier. The checksum is a calculation and is already in a sub. The serial in and out is also already in a sub.

    I 'm thinking. The program I can't put in extra mem (I2C connected). But the data (what is a lot) Can I put that in extra mem connected with I2C. Is it much slower then? That would free up a lot off space and the communication on I2C I can place in a sub.

    Does anyone has a ic type to use and ore some examples?



    stef
  • BeanBean Posts: 8,129
    edited 2007-07-26 21:59
    Stef,
    You cannot put program code externally, but if you have alot of data then you CAN put that in an external EEPROM and read it from there. That would be a good plan.

    How many bytes of data do you have ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Teacher: What is the difference between ignorance and apathy ?
    Student: I don't know and I don't care
    Teacher: Correct !
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-07-26 22:00
    I2C will be a bit slower than internal memory, but it may still work to your advantage. If the values you're pulling from the tables have the same offset (just the table changes based on the target device), you could put in a EEPROM for each device and use the device address feature of the I2C EEPROM to grab the desired value -- this would allow your program to support up to eight target devices with very simple code.

    I'm working with the 64K byte 24LC512 EEPROM today and have attached my routines (all tested and working) for you to use as you please.

    Note: In my program I'm just using a single EE so the slave ID byte is a constant; to implement the suggestion above the slave ID would need to be a variable.
  • stefstef Posts: 173
    edited 2007-07-27 14:14
    Hi

    thanks a lot. I will continue the programm.

    stef
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-07-27 16:21
    How do I incorporate this
    SUB DELAY_MS
      IF __PARAMCNT = 1 THEN
        tmpW1 = __PARAM1
      ELSE
        tmpW1 = __WPARAM12
      ENDIF
      PAUSE tmpW1
      ENDSUB
    

    into this --
    starter:
      TRIS_A = 0
      RA = $FF
      ' Using C.A. R-G LEDs.  1=OFF, 0=ON
    DO
      RA = $FD
      [color=red]PAUSE 500
    [/color]  
      RA = $FE
      [color=red]PAUSE 500[/color]
    LOOP 
    
  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-07-27 16:51
    It's easy -- see attached program (testing a two-lead, bi-color LED).
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-07-27 17:55
    O-I-C: The double-underscore isn't a triviality,·it makes __PARAM1 and __WPARAM12 bold.

    Comparing this with using PAUSE·ate·up·the same amount of space (Device >> Run), $7E.· Maybe I'll realize more savings with more PAUSEs.· I'll try it with some other stuff (like my 5x7 Demo·programs.)

    Update -- In one program where I had 4 PAUSEs, I went from $1CF down to $1C4 (cutting out·$0B, that's 1110.)


    Post Edited (PJ Allen) : 7/27/2007 7:01:15 PM GMT
  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-07-27 18:08
    Indeed you will -- every time you use PAUSE it is being expanded into a given number of assembly lines; when encapsulating that in a subroutine it only happens once; the more PAUSE statements you replace with DELAY_MS, the greater your code space savings will be.
Sign In or Register to comment.