Shop OBEX P1 Docs P2 Docs Learn Events
Eeprom — Parallax Forums

Eeprom

K_onghenaK_onghena Posts: 2
edited 2010-08-15 08:23 in BASIC Stamp
Hello there,

I've recently bought a BS2P24 because the EEPROM size of my BS2 was to small for the program i had written. Unfortunately i get the same problem the BS2 editor tells me the EEPROM is full. But normally the BS2P24 has 8x2K EEPROM. How do i store my program or parts of it in the EEPROM i can't reach.

Thanks in advance!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-08-13 11:54
    The rom is set up as 8 blocks of 2k so you need to break your program into modules that can run independently. Others know more on this than I do and will probably be along soon to help.
  • MimewarMimewar Posts: 10
    edited 2010-08-13 12:16
    How can a program be broken up into seperate modules? I need this exact function!
  • Martin_HMartin_H Posts: 4,051
    edited 2010-08-13 17:30
    You use the run command to invoke the program in the alternate bank. I do this on my BS2e and I've posted one of my programs in reply 5 on this thread:

    http://forums.parallax.com/showthread.php?t=122032

    Once you get used to it the run command isn't hard to use, but it is not as easy as a flat memory model.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-13 17:54
    You actually have to break up your program into functional blocks in separate source files and modify the compiler directive at the beginning of each block to specify which bank the compiled source file gets loaded into. The separate compilations all have the same variables defined in the same order which is how the pieces communicate with each other. I'm sorry I don't have more details, but I don't have the documentation handy. There's a worked example of a multi-bank program in one of the Nuts and Volts Columns. You get to the Columns index by clicking on the Resources tab on the main Parallax webpage. Look for a Column about multi-bank programming.
  • rixterrixter Posts: 95
    edited 2010-08-13 19:19
    As was pointed out, you need to split up your program into "functional" blocks. Not all programs can be easily sliced up this way, but any program large enough not to fit in one slot can generally be broken down in some way. For example, I had a project that had one portion of the code in one slot to read in data from an external source and store in EEPROM. The second slot contained code to fetch the data from EEPROM and display on an LCD. You may be tempted to have subroutines off in separate slots, but this will create issues because jumping to another slot with the RUN command causes the first slot code to be "lost". You could devise a scheme where you saved variables off to memory before bouncing back and forth, but it's really difficult to return back into the middle of code after switching between slots. You're best off looking at your program and finding a way to break it down into components that can be separate from one another.

    Also remember that memory for data as accessed with the READ and WRITE commands is addressed in a different fashion in multi-slot BS2s. You must use the STORE command to specify which memory slot you are addressing the EEPROM. You can do this independent of which slot you are running your code in with the RUN command. There are a few examples of code out there that can "flatten" out the memory so it looks like it is all one contiguous piece of EEPROM. I did it by maintaining one NIB slot variable and two WORD variables.. one for the real memory location within the slot and one "virtual" memory location that was seen by the program as one contiguous block of memory. Basically a subroutine is called that converts a virtual memory location into a slot and real memory location within before every accessing of the EEPROM.

    Hope this helps some.

    Rick
  • K_onghenaK_onghena Posts: 2
    edited 2010-08-14 02:16
    Thx for the information!
    Does anyone know if the program will run much slower when it's split up?

    Grtz
  • Martin_HMartin_H Posts: 4,051
    edited 2010-08-14 06:01
    There's some overhead in cross bank calls, so I would assume it is slower than a GOSUB, but I think it is pretty quick compared to a pause for servo pulses. You should generally seek to group like functions together and minimize cross bank calls because the gosub call stack is lost. This makes code logic tricky.

    Some of the BS2 variants allow cross bank loading and storing to the EPROM which lets you save space in the main bank for code.
  • ForrestForrest Posts: 1,341
    edited 2010-08-14 09:54
    The BS2P24 is 3X faster than a BS2. You should read the Basic Stamp Syntax and Reference Manual for more info
    http://www.parallax.com/tabid/440/Default.aspx
  • LeonLeon Posts: 7,620
    edited 2010-08-14 11:15
    Switching banks on PICs is fast, it only takes one or two instructions.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-08-14 22:07
    On a BS2pe, the RUN n command to cross from one slot to another takes close to 630 microseconds. Compare that with a GOTO aaa, within one slot, which takes about 350 microseconds. The STORE n command, to point to a different slot for READs and WRITEs is fast, and takes about 95 microseconds.

    Speed of the BS2p is faster than the 'pe by a factor of 2.5.

    As has already been said, write the program in modules. I usually have a initialization and a user menu in slot 0, and it can branch to one or more other slots for user parameter setting and for services that are called on from a main menu. Then slot 1 is a main loop. It does do a dance to branch and return into other slots to handle certain devices like sensors and mass storage that have their own driver modules. The STORE command is useful for keeping data and parameters in other slots.
Sign In or Register to comment.