Shop OBEX P1 Docs P2 Docs Learn Events
My memory is full !! — Parallax Forums

My memory is full !!

BTXBTX Posts: 674
edited 2008-07-08 21:08 in Propeller 1
Hi all.
I'm in a development process of application, and I've a problem.
Since I'll use a lot of objects, I need to declare them in the OBJ section, then in the main program, I'll call only one at a time.
But some of this objects declare some variables each as: obj1_some_var1[noparse][[/noparse]32_000]; obj2_some_var2[noparse][[/noparse]32_000]; obj3_some_var3[noparse][[/noparse]32_000].
So memory is not enough for all of them.

Question:
Is there anyway, to declare that 'vectors', into the main program, selecting only one of them with a "case" or similar. ??
Hope you understand my question... it is like a 'VAR' declare, on the fly.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.

Alberto.

Comments

  • TJHJTJHJ Posts: 243
    edited 2008-07-06 15:46
    Im not quite sure I grasp all of what your saying but Ill take a shot at it.


    Why redeclare your Var's on the fly? There is a physical limit to what you can have stored, either you lower your data,or ... ? if you were to redeclare your var data you wipe out your old data, so why not use the same 32_000 data block again instead of redeclaring it. I think this is how your describe your goal.

    What you may need to do would be increase your ram, if you were to add additional ram to your project, you could have a working block of 32000, data points in the Prop Ram. Then when you are done with them shift them out to your external ram. and shift new data into the 32_000 piece declared block in the prop. Pretty tricky to pull off in the end.

    I guess to really help you, I think we need know more about how/what you are trying to place with 32_000 data points, even as bytes you will have trouble loading that into a cog, exceeding the 2k limit.

    Just to confirm you are exceeding the ram limit in your variable for data points? Not in the cognew/ Coginit stack you are allocating for your new cogs? You might be allocating to much space for your new cogs, and this might allow you to free up some ram.

    Hope this helps,

    TJ
  • Jimmy W.Jimmy W. Posts: 112
    edited 2008-07-06 15:54
    you could make 1 stack and then instead of using named variables in the other objects you could
    use this at the beginning of the object

    varPtrLong1 = @stack
    varPtrLong2 = @stack+4
    varPtrLongArray [noparse][[/noparse] 2 ] = @stack+8,@stack+12, 'give it room for 2 longs
    varPtrByte1 = @stack+16
    varPtrByte2 = @stack+17
    varPtrByte3 = @stack+18
    varPtrByte4 = @stack+19


    then use the following in your code
    LONG[noparse][[/noparse]varPtrLong1]
    BYTE[noparse][[/noparse]varPtrByte2]
    LONG[noparse][[/noparse]varPtrLongArray [noparse][[/noparse] 2 ] ]
  • BTXBTX Posts: 674
    edited 2008-07-06 16:11
    OK TJ.
    I'll try to do a more simple example.
    First of all, I can't use an external RAM, so I need to do all with the pchip. (That's a limitation for my design).

    Suppose I've the following:

    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      tiles    = vga#xtiles * vga#ytiles
      tiles32  = tiles * 32
    
      tiles2    = vga2#xtiles * vga2#ytiles
      tiles232  = tiles2 * 32
    
    OBJ
    
      vga : "vga_512x384_bitmap"
      vga2: "vga_512x384_bitmap"
    
    
    VAR
    
      long  sync, pixels[noparse][[/noparse]tiles32], pixels2[noparse][[/noparse]tiles32]
      word  colors[noparse][[/noparse]tiles]
    
    
    



    Here clearly, is too much space reserved for variables, so it is not possible.
    But in my speacial case, I will choose for use either vga, OR vag2, not both at the same time, although they will should be have a different space for variables, so it is not possible for me to use the same "pixels" variable for both cases. (obviously, in that case, I could use the same 'pixels' vector for both, without any problem).

    So I need something that let's me to choose wich "VAR block to use" depending if an external jumper is attached to some pin or not.
    In that case: something like this "BAD" code.

    Case pin
      1: VAR long  pixels[noparse][[/noparse]tiles32]
      2: VAR long  pixels2[noparse][[/noparse]tiles32]
    



    Hope it is more clear now, take care, that it is NOT my real code, neither what I want to do, but it is the "same" example problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • Jimmy W.Jimmy W. Posts: 112
    edited 2008-07-06 16:32
    according to you example, a stack is exactly what you want, reread my above post and let me know if you have any questions, just define 1 large stack then reuse it for whatever you need
  • TJHJTJHJ Posts: 243
    edited 2008-07-06 16:40
    Will your jumper pin change only on start up? or will it be constantly changing eg. Asking for frame 1, from pixels, and then frame 2, from pixels2.


    One simple solution would be to do what Jimmy suggested using a enlarged stack and change the multiplier for what you are reading out it.

    Are you using a Proto Bord or just a raw prop chip? Depending on the life of product you could store the 2nd set of "Tiles" to the Upper 32k of the eprom and load back and forth there is a limited number of read writes... and some speed penalty, but with some slick coding you could be constantly loading and unloading 4-6 sets of tiles so that when the 1st is unloaded two more would be in the process of unloading, and per say the pixels 2 would be loaded.

    Honestly the simplest would be to break it into smaller stacks, compute 1/2 the screen then dump, then back again.


    If your pin would only be changed on start up and you want to make your code use a different set of data based on your jumper, maybe this just rename it.




    
    Var 
    Word Pixels, Pixels2, Data[noparse][[/noparse]Tiles32]
    
    Pub Main
      if ina[noparse][[/noparse]Jumper] == 1
        Pixels := @Data
      else
        Pixels2 := @Data
    
    
    



    So you would just be placing the location of your data stack, into the pixels var.

    Then to access it


    
    @Pixels[noparse][[/noparse]Tile]
    or 
    
    @Pixels2[noparse][[/noparse]Tile]
    
    
    
    



    If you are reading from one cog to another be aware to use the @@ to get the true address not just the internal cog address.
  • BTXBTX Posts: 674
    edited 2008-07-06 16:51
    @TJ & @Jimmy, thanks so much both for your support !.

    You both give me some ideas about how to do it... I'll have many days of programming in front of me, so I will try your suggests, se what happend, and then I'll return to this thread.
    Thanks again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • AleAle Posts: 2,363
    edited 2008-07-06 17:09
    The life is short, and the ROM is full.

    Alberto, try to use a pointer (defined as constant) and the ptr[noparse][[/noparse]idx] notation and for all of them to reside in the same place (or a variable). But they told you that smile.gif.

    Saludos
  • BTXBTX Posts: 674
    edited 2008-07-08 19:44
    Thanks Ale..

    But now I'm stoped again.
    I'm playing with the VGA_HiRes_Text driver, in the beggining of the code you can comment or uncomment some constants to change the final resolutions.
    I need to use the three posibilities, (1024x768),(800x600),(640x480), but I've no room to use three of this objects in my code.
    So, is there any way to choose differents 'CON values' from an external object ??? (like a auto comment-uncomment )

    Thanks in advance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • AleAle Posts: 2,363
    edited 2008-07-08 19:51
    There is no provision for conditional compiling :-(. What may work is that you have the 3 sets of constants in COG ram and some parameter (through the PAR register) that you pass at start time or run time that will configure again the driver. I think there is a bit of room in that driver, it may even work wink.gif. PM me if you need extra help.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-08 20:06
    BTX:· Looks like you need to use one of several different resolutions, but only one at a time.· Just allocate enough memory for the largest one and use a pointer to it.· If you need s smaller buffer then it's ok.

    Instead of constants, set up a variable that·replaces the constant and change it when needed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BTXBTX Posts: 674
    edited 2008-07-08 20:11
    Thanks Ale, & Ken.

    @Ken.
    Iti is exactly what I'm trying to do... but when I replace the constants with variables I get a lots of errors in the code....
    That code seems to be very well adapted for use the constants...I'm fried my brain.
    Remember that Chip wrote that code, such a programming guy !!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-08 20:57
    Usually when constants are used in PASM it is done with immediate addressing (#). If you change them to variables you need to remove the #'s. Perhaps this is part of the problem?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BTXBTX Posts: 674
    edited 2008-07-08 21:08
    Thanks so much Ken.. I'll try again. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
Sign In or Register to comment.