Starting out... IDE question with multiple spin files
spinbob
Posts: 27
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
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
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.
Thanks
Thanks all
Thanks
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.
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
electrodude
J
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.
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
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.
I've always had that problem too!
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
ah, and you went and solved it with SimpleIDE, which does have project files. Life is good
Which brings me to spinbob's comment
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.
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.
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.