c8051f310 memory

2007-04-03
2013-03-12
  • c8051f310user

    c8051f310user - 2007-04-03

    I've reached the end of my available ram on the processor.  Is there a way I can reach additional ram without having to add memory?  Like within the SFR area or something.

     
    • Anonymous

      Anonymous - 2007-04-03

      I don't know about c8051f310, but I use c8051f331 and I guess it should be similar.

      One thing to check is whether you use bit variables. If you do, they will always start at address 0x20 (after all four register banks) and all other data will be placed after them. Unless you use all register banks, this is probably a waste of memory. If you use only a few bit variables, change them all to chars or unsigned chars and, as a result, all data will start just after the register bank(s) you really use. So for example if you use only one bank, data will start at 0x8 and you gain 0x20-0x8=24 bytes of memory (minus losses for the bit variables). If you use many bit variables, simply changing them to chars may not significantly improve your situation, but you might pack 8 bits into a byte to save more (at the cost of a bit more code and probably a bit speed loss).

      Another thing to check is whether you laid out your memory efficiently - whether your data, idata and stack segments have reasonable sizes compared to what you actually use and/or need. You might also move some less frequently accessed data into on-chip xdata memory (if the chip has one).

      Maybe if you carefully analyze your stack depth, you might cut down on stack size.

      Check all your arrays, maybe you can cut down on their size a bit here and there.

      Use overlay segment and local variables if possible.

      If you are really really short, you might change some of your functions not to use parameters but work with a small group of "general" global variables. It is not a good programming practice in terms of program readability or architecture in general, but this has gotten me out of some really tight places a few times, it also saves code space a bit.

      SFR area is most probably not the way to go, although I might be wrong. In any case, it most surely isn't much compatible with other c8051fxxx processors.

      Mlynki

       
    • Maarten Brock

      Maarten Brock - 2007-04-03

      On the C8051F310 you cannot add normal memory. It has no external memory bus.

      Which memory did you run out of? Data / idata / pdata / xdata?
      Which compiler options do you use?
      Are you using generic pointers?

       
    • Maarten Brock

      Maarten Brock - 2007-04-03

      Mlynki's statement about bit variables is only valid if you use an old compiler version or use --no-pack-iram.

      So which version of the compiler do you use?

       
    • Anonymous

      Anonymous - 2007-04-03

      I use old compiler version (2.5.0).

       
    • Anonymous

      Anonymous - 2007-04-03

      Sorry, actually 2.4.0, I only tried 2.5.0 but due to some backward (in)compatibility I stick to the older one for the present.
      Mlynki

       

Log in to post a comment.