Prop C command reference
John Kauffman
Posts: 653
Where can I find a reference of C commands' syntax?
I've been searching through all options in SimpleIDE Help, the forums and the Learn C with Propeller learn site. Simple IDE Help seems to be only how use the IDE, not how to use the C commands. The help on GCC seems to talk about how the project is built, but not a list of commands & arguments
Do I just go to web and find general C syntax? I doubt all of them work on Prop.
Example of my current need: how to do a LookUp()?
Thanks.
I've been searching through all options in SimpleIDE Help, the forums and the Learn C with Propeller learn site. Simple IDE Help seems to be only how use the IDE, not how to use the C commands. The help on GCC seems to talk about how the project is built, but not a list of commands & arguments
Do I just go to web and find general C syntax? I doubt all of them work on Prop.
Example of my current need: how to do a LookUp()?
Thanks.
Comments
Yes.
Use this online book for a reference: http://publications.gbdirect.co.uk/c_book/
This is a friendly C programming web site: http://www.cprogramming.com/
There are dozens of online C tutorials.
Maybe you would find a C programming class useful.
Andy's tutorials are pretty good.
1. The SimpleIDE terminal requires some startup time. A one second delay is required before printing to the terminal. Propeller-GCC provides a terminal with propeller-load that does not need any delay.
2. Don't use C++ cout and other std:: namespace syntax as that will immediately create a 500KB program.
3. Use simpletext library string input and output functions print, scan, and variations. Using standard printf, scanf, and variations are possible on Propeller with Propeller-GCC, but it will grow quickly to fill all memory when using floating point (and the math library must be linked for floating point to work).
4. Using the file-system requires special initialization. Don't use fprintf with files since it suffers the same problems as using printf.
Andy's tutorials are tailored to guide users past these problems.
To clarify my understanding of the architecture, is this right?
There is some kind of defined "core" C implemented on all platforms, including the Prop. This is what would be covered in generic reference books. Then more commands specific to a given platform are in libraries. The commands specific for Prop platform are in the libraries that install with SimpleIDE and that are documented in several places like https://propsideworkspace.googlecode.com/hg-history/029efb9bf270758003c0a67571d1cbe4cc9986b5/Learn/Simple%20Libraries%20Index.html.
Is that right, in simple terms?
Much thanks for your patience. The tutorial is titled "Learn C with the Propeller" so I starting from zero to "Learn C." I need to get over various fundamental differences from ten years with PBASIC
pause();
pulseout();
pulsein();
high();
low();
If so look at the documentation in the SimpleIDE help menu on Simple Libraries. That's where the majority of such stuff is now defined. libsimpletools is a good place to start. The documentation is really quite good for that stuff.
There are a few things that are a little less well documented and come from some of the headers like propeller.h and cog.h. It's worth your time to look at those for some idea of what those things are doing:
Also see this site for more on the Libraries that are not in the SimpleLibires realm:
https://sites.google.com/site/propellergcc/documentation/libraries
It is easy to get tripped up wondering what works in arrays, what conversion flags work with simplelibrary print. Its just a lot of unknowns at this point. Otherwise, it has been fairly enjoyable to delve into C++ on the propeller. (The lack of library objects is a wee bit tough. - I've used spin2cpp, but wish I could just run a Spin object sometimes.)
PropellerGCC is standard C90 ANSI C, with a few minor exceptions documented here. It's also C++ compliant (I don't have a source for that). That means that whatever C/C++ program you write for it will be compilable. You can use pointers, arrays, casts, and anything else defined in the C/C++ standards. The caveat is that if you use the C/C++ standard libraries you may run into code size issues. If you somehow get it to run they'll operate as expected.
The only "extension" to the C/C++ languages is the addition of the Propeller.h file. This file describes and makes available a number of Propeller specific "commands". These can be used to get I/O pins, cogs, and so on.
In order to facilitate development, the PropellerGCC team has created a number of drivers (notably serial and SD) to help make development easier. These they have put behind standard C interface semantics, but it should be recognized that these are additions to the core, not a required component.
Finally, Andy Lindsay has developed a "simpletools" library for Parallax Education to help make certain features easier and more accessible. These include things like serial, SD, and PWM.
Through it all, everything is standard C/C++. Anything that you can do in the core languages is supported with PropGCC. There's very few gotcha's, and most of the ones that I know about are documented in the FAQ. Therefore, you can read a good book on the C or C++ and be able to work well with the language of your choice. After that, read Propeller.h and you'll be ready to use PropellerGCC to effectively create microcontroller applications.