Shop OBEX P1 Docs P2 Docs Learn Events
Starting out... IDE question with multiple spin files — Parallax Forums

Starting out... IDE question with multiple spin files

spinbobspinbob Posts: 27
edited 2013-04-25 15:48 in Propeller 1
Hi all, first post. :)
I am picking up a project from a previous designer, he is not available. I am learning to spin, I am a C programmer. In the Propeller Tool I see the spin files listed(10 of them) in the directory, I can click on them, compile them, no errors but I'm not sure how all this stuff fits together. I found the top object, when I compile it I see a sub-menu of floatmath.
Questions:
1) If the top object referenced another spin file would it show in the sub menu after a compile?

2) Can all of these be compiled and down loaded separatley?

3) Is there some kind of project file, I really don't know what files I need to make a complete project. Any thoughts here would be great.

Oh, I have about 10 hours into the manual so I know some stuff...

Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-09 09:16
    1) Probably not unless it's already there. The child object .spin files have to either be in the same directory as the top object or they have to be in the "library" directory as specified in the Propeller Tool's preferences.

    2) No. They're put together by the Propeller Tool to generate a single binary file which is then downloaded to the Propeller. This is sort of like linking C programs.

    3) No. The current Propeller Tool does not use project files. To produce a binary file, all you need are the .spin files. The process starts with the top object (.spin) file. Any object (.spin file) referenced by that in an OBJ declaration must be available either in the same directory or the "library" directory. Any objects referenced by those must be similarly available, etc.

    The beta version of the Propeller C compiler (see thread) includes a Spin compiler, uses project files, and supports programs consisting of C and Propeller assembly language or Spin (which includes an assembler). You can't combine C and Spin. Keep in mind that the C (like Spin) is interpreted and has an execution speed intermediate between Spin and Propeller native instructions.
  • spinbobspinbob Posts: 27
    edited 2013-04-09 09:56
    OK. I have all the spins in a dir. I tell the compiler the top obj., compile the top and it compiles successfully. I don't see a .bin file in the dir.
    Thanks
  • spinbobspinbob Posts: 27
    edited 2013-04-09 11:15
    I'll reply to my own thread, I need to click on "save binary" button on the object info dialog box.
    Thanks all
  • jazzedjazzed Posts: 11,803
    edited 2013-04-09 11:32
    Hi spinbob. Welcome to the forum.
  • spinbobspinbob Posts: 27
    edited 2013-04-09 14:36
    I guess I still dont get it. I can click on each spin file in the tool menu and compile each. How do I get them all to compile together?
    Thanks
  • jazzedjazzed Posts: 11,803
    edited 2013-04-09 14:47
    The OBJ section glues all the files together.

    Each Spin file specifies the other spin files it needs via the OBJ section.
    Using that idea, a Spin project is defined by the file rather than by a project list.
    A file is often called an object in spin ....

    Usually one file is considered the "top" file. The top file includes files that can include other files.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-04-09 14:55
    There are options in the compile menu:

    Compile Current - Compiles the currently opened Spin file (and any objects that it includes in the OBJ section)

    Compile Top - Compiles the file designated as the Top file (and any objects that it includes in the OBJ section)

    So, what you're looking for is "Compile Top", after choosing the appropriate Spin file as the top file. The Spin tool will compile it, and all other Spin files included by it, into a single binary. Think of the OBJ section as using an #include in C / C++, but instead of just including the header, you're including the full source, so it all gets compiled "inline".

    Jason
  • ElectrodudeElectrodude Posts: 1,658
    edited 2013-04-09 15:05
    You don't get a .bin or .eeprom file unless you explicitly ask for one (there's a button somewhere...). Pushing F10 compiles your project and loads it into the prop's RAM, and F11 does the same but also puts a copy in EEPROM. F9 is really only a compile checker (but probably internally makes a binary).

    electrodude
  • spinbobspinbob Posts: 27
    edited 2013-04-09 15:19
    I hear what your saying, as I look thru the files I see the OBJ section and see another object file listed. But, it doesn't look like there are enough assignments to get the job done. The one thing I did do that really has me confused; closed propeller tool, hightlighted all object files in Windows explorer and right clicked, clicked on "open with propeller tool" and all the files open and it compiled all the files by itself, then the object info box popped up on its own. This was a complete compile, I see all the hex together in one file and it' the right size. Now I can't get it to do that again. That was good, it shows me that I probably have the stuff.....
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-04-09 16:55
    When you do a "Compile Top", in the upper-left corner of the Spin IDE, you'll see a tree view representing all the objects that were compiled and who included them. If you simply choose each of the files you have, in turn, and "Compile Top", you should fairly quickly be able to identify the file that uses all the others.

    J
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-09 17:17
    It took me a while to work this out too. It is a tree structure and sometimes when you get a bunch of files from the object exchange, it is not entirely clear which is the top of the tree. My personal solution is to rename the top object as "main.spin" or a variant that starts with the word main eg "main_myTVdemo.spin".

    I'm still not entirely sure what "compile top" means in the IDE. I always use "compile current" on the program that I now have as the "main" program. Usually with F8 first to check there are no errors, then when it is error free, with F10 to download to ram, and then when it is really perfect, F11 to download to eeprom.
  • kuronekokuroneko Posts: 3,623
    edited 2013-04-09 18:21
    Dr_Acula wrote: »
    I'm still not entirely sure what "compile top" means in the IDE.
    PropTool help (F1), Spin Programming Tutorial > Spin Lesson 5 > The Top Object File (or search for top, first result)
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-09 18:47
    Thanks kuroneko. That explains it a bit more.

    I can see how it can be confusing though. I have a typical spin package which is a group of spin files. Unlike C, there is no project file. Keep all the files in the same directory. To find out which is the "top" file, sometimes it is necessary to open all the files and check for typical "starting" code, eg starting up other objects, though of course, objects can start objects which can start other objects, so to be really sure I find it best to open all of them.

    Once you have worked out which is the top object, click on F8 to compile and view the tree structure. But that tree structure doesn't appear in the top left corner of the screen until you do that first compile.

    So - assuming the top file really is the top file, everything should be ok.

    re spinbob
    But, it doesn't look like there are enough assignments to get the job done.

    what could be useful would be to take all the files in the directory, zip them up and post them here as an attachment. Click on 'go advanced' just below where you type and then upload the file. Then we can all do some screenshots and work through it.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-09 21:10
    Dr_Acula wrote: »
    I can see how it can be confusing though. I have a typical spin package which is a group of spin files. Unlike C, there is no project file. Keep all the files in the same directory. To find out which is the "top" file, sometimes it is necessary to open all the files and check for typical "starting" code ....

    I've always had that problem too!
  • dgatelydgately Posts: 1,630
    edited 2013-04-09 21:11
    spinbob wrote: »
    I guess I still dont get it. I can click on each spin file in the tool menu and compile each. How do I get them all to compile together?
    Thanks

    Just a thought...

    A quick walk through just a few of Parallax's provided tutorials may help you with getting that understanding. Coming from the world of C and other language programming, I didn't get the "loose" file organization of Propeller programming until I backed-up a bit and ran through several tutorials.

    Here's an example of one that might help: http://learn.parallax.com/node/82

    That puts you right into the middle of a small set of tutorials for the Propeller Board of Education, but explains the use of objects very well. You may want to go to the beginning of the thread there for a fresh start.

    The Propeller Spin Manual has excellent examples as well. I always keep it up & displayed in the background while I code: Web-PropellerManual-v1.2.pdf


    I hope this helps

    dgately
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-09 21:36
    jazzed said
    I've always had that problem too!

    ah, and you went and solved it with SimpleIDE, which does have project files. Life is good :)

    Which brings me to spinbob's comment
    I am picking up a project from a previous designer, he is not available. I am learning to spin, I am a C programmer. In the Propeller Tool I see the spin files listed(10 of them) in the directory, I can click on them, compile them, no errors but I'm not sure how all this stuff fits together. I found the top object, when I compile it I see a sub-menu of floatmath.

    If you are a C programmer, I wonder if there might be another solution.

    There are some very clever people over on the propgcc project. There is a neat IDE for C (SimpleIDE) and there is also a program spin2cpp which can convert pretty much any spin program to C. I tried to break it the other day with a very complicated spin program with objects by about 6 different authors, all with different programming styles, and it all compiled and ran. You can do each spin object separately, or you can give it the 'top' object and it sorts out all the dependencies automatically. Takes half a second to produce a pile of .h and .cpp files. Put these into SimpleIDE and tell it what board you have, and it will then produce a .side project file, and next time you just open the project file and it is one click to compile and download.

    If you are starting right at the beginning with spin and you are picking up someone else's design and you are a native C programmer, I wonder if it might be worth taking a look at C on the propeller? You could convert all the spin to C, and then the project could be in C from that point on.
  • spinbobspinbob Posts: 27
    edited 2013-04-24 20:34
    Thanks all... I have been making some ground on learning spin. I figured out all the object file problems, now I see the concept and I know what's missing. I will jump on the C converter as soon as I get all the hardware tested out.
    For new folks, I have some thoughts and I think they are close to true most all the time:)
    #1 Object files are created individually because of structure, each object can act like a complete program. Take one concept of a design, assign a cog, write some code, done. See #2
    #2 All the VAR variables are global in that object file only. If you want one object to tell another object file something then it has to be passed with a Call and/or Return concept.
    #3 Pay extra attention to using Repeat, it can get you stuck spinning its wheels doing nothing.
    #4 Rename the files downloaded something unique, if you make mods this is only way to know what files are yours.
    #5 If you want to compare .binary files; hop into DOS and use this FC /B "path File1" "path File2". You can do a FC /? for help.
  • cavelambcavelamb Posts: 720
    edited 2013-04-25 00:38
    spinbob wrote: »
    Thanks all... I have been making some ground on learning spin. I figured out all the object file problems, now I see the concept and I know what's missing. I will jump on the C converter as soon as I get all the hardware tested out.
    For new folks, I have some thoughts and I think they are close to true most all the time:)
    #1 Object files are created individually because of structure, each object can act like a complete program. Take one concept of a design, assign a cog, write some code, done. See #2
    #2 All the VAR variables are global in that object file only. If you want one object to tell another object file something then it has to be passed with a Call and/or Return concept.
    #3 Pay extra attention to using Repeat, it can get you stuck spinning its wheels doing nothing.
    #4 Rename the files downloaded something unique, if you make mods this is only way to know what files are yours.
    #5 If you want to compare .binary files; hop into DOS and use this FC /B "path File1" "path File2". You can do a FC /? for help.

    An experienced C programmer would obviously want to program in C.

    But the native language for the Propeller chip is SPIN.

    Stick with it a while and grow into it.
  • spinbobspinbob Posts: 27
    edited 2013-04-25 15:48
    cavelamb wrote: »
    An experienced C programmer would obviously want to program in C.

    But the native language for the Propeller chip is SPIN.

    Stick with it a while and grow into it.

    I agree, SPIN is a very powerful language and the 7 micros-in-one is cool.
    I do micro stuff(1000s of lines of code) for a living, if I have a bug in either a high level language or something unknown about the hardware then that can cause me total project failure. I can't bet my business on that, my code has to work. C is as high as I can safely go and troubleshoot. I do all Microchip stuff.
Sign In or Register to comment.