Shop OBEX P1 Docs P2 Docs Learn Events
Combining two source codes in one program — Parallax Forums

Combining two source codes in one program

propwellpropwell Posts: 87
edited 2009-11-02 16:54 in Propeller 1
Hi together,

i want to combine the codes of the Graphics Demo and Terry-Hitts OSD-Code in one program. With the mouse plugged in, you should be able to switch between these programs.

Unfortunately, the Propeller Tool tells me, that the memory limit exceeds...

Anyone an idea?

Thank you very much!

Comments

  • mctriviamctrivia Posts: 3,772
    edited 2009-10-26 18:51
    if your eeprom is larger you could store each into a 32k chunk of eeprom and use a bootloader to switch between them. See my bootloader object (http://obex.parallax.com/objects/473/) for how to do this. My code uses a 64k eeprom to load 1 image after seeing if a new image shoud be loaded from the card. you could rewrite to use a 128k eeprom and have a menu at start to chose from up to 3 images.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    24 bit LCD Breakout Board coming soon. $21.99 has backlight driver and touch sensitive decoder.
  • propwellpropwell Posts: 87
    edited 2009-10-27 08:27
    hi mctrivia, thanks for your help. unfortunately i have no chance to implement a SD-slot on my board. Isn't there any chance to just use a larger EEPROM? do i have to make changes in the Propeller-Tool or the source-code?

    Thanks,
    max
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-10-27 09:10
    I still don't understand exactly what you want. You talk about combining it in one program and then you say you want to switch between the programs.

    Is it necessary to switch with the mouse? Is it for a product or just for demo? If the answers are no/demo, then you could think about a hardware solution. Have another EEPROM in parallel to the existing one (I2C is a bus). Then you only need a switch and 2 resistors which alternately pull the adress-line of one or the other EEPROM to high. Switch EEPROM1 + reset and code in EEPROM1 is booted and runs / switch EEPROM2 + reset and code in EEPROM2 runs.
    Nice thing here .. the propeller tool works perfectly with this solution. Switch to the desired EEPROM and you can load any program into it. The other one is untouched.

    If you need a professional version, you can use a bigger EEPROM + an I2C driver written in PASM. (The I2C driver in PASM is important as you want to reload the whole HUB-RAM, which would overwrite SPIN code.) Then you can use the same technique as the FSRWfemto SD card driver (see Femto-Basic in ObEx) to restart the propeller with new code.
    But here you have the problem of putting·program 2 in the upper part of the EEPROM. That's not supported by the Propeller Tool.·
  • propwellpropwell Posts: 87
    edited 2009-10-27 09:13
    sorry if it didn't come clear: I want to have 1 program, which combines the functions of the previously 2 programs. But as i copy the 2 sourcecodes together, the memory-limit is exceeded.
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-10-27 09:26
    So how does the combination look like? Graphics demo is running and you can switch on/off OSD?

    What's the size of the resulting code? In other words how many longs do we need to save?

    A possibility to save memory is to put COG-code and SPIN-code in separate sections of the EEPROM ( the COG-code in the upper-part of EEPROM). The SPIN code can load the COG code into the graphics buffer and then start the COG with it one after another during initialization. 1st graphics driver, 2nd keyboard/mouse-driver, 3rd tv-driver, 4th whatever ......
    This saves up to 2kB per COG - which might be enough to have the SPIN code of both programs + graphics buffer in HUB-RAM.

    How to put PASM sections into upper EEPROM memory? Have a look at PASMStore (last post of this thread http://forums.parallax.com/forums/default.aspx?f=25&m=338494 )
  • propwellpropwell Posts: 87
    edited 2009-10-27 09:48
    Propeller Tool tells me that the memory is exceeded by 3222 longs! is that to much?
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-10-27 10:43
    How did you merge those two programs?

    Terry's code uses a slightly modified graphics driver. So with a plain merge of both codes you would have two different graphics drivers running - each with roundabout 3000 longs as screen buffer.
    So, first thing is to use the same graphics object in both. Then the propeller tool can optimize.

    Do you need the GPS driver?
    Do you need the serial driver?
    Do you need keyboard?

    Serial Recv Buffer Inverted and Serial Recv Buffer True seem to be verry equal. The minor differences could propably be handeled in the PASM, so that you only need one of the drivers and use it two times.

    In graphics.spin a lot of SPIN functions do the same thing - calling setcommand. Get rid of these functions and call setcommand directly.

    Get rid of all SPIN-functions that are not needed.

    Put all the drivers in upper EEPROM and use the graphics buffer to load them in the beginning.
  • propwellpropwell Posts: 87
    edited 2009-11-02 16:54
    Hi MagIO2,

    thank you for your answer!
    Yeah, i think the screenbuffers do much of the problem. Unfortunately, i don't know how to make them use the same buffers:
    The OSD-Code uses:
    VAR
      long bitmap[noparse][[/noparse]3072]   
      long screen[noparse][[/noparse]3072]
    
    


    and the graphics-one:
    CON
      ...
      _stack = ($3000 + $3000 + 100) >> 2   'accomodate display memory and stack
      ...  
      bitmap_base = $2000
      display_base = $5000
    
    VAR
      word  screen[noparse][[/noparse]x_tiles * y_tiles]    
    
    


    I can't really find anything, that they have in common! I don't need GPS, serial and keyboard, but without it, it still calls me the error.
    Maybe it's easier to understand my problems with my source codes.
    So i attached the 2 programs i want to combine!

    Thank you so much for your help!
    propwell
Sign In or Register to comment.