Shop OBEX P1 Docs P2 Docs Learn Events
Prop C command reference — Parallax Forums

Prop C command reference

John KauffmanJohn Kauffman Posts: 653
edited 2013-10-06 11:04 in Propeller 1
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.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-10-04 10:04
    Do I just go to web and find general C syntax?

    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.
  • jazzedjazzed Posts: 11,803
    edited 2013-10-04 10:24
    What are some caveats of using SimpleIDE and Propeller-GCC?

    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.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2013-10-04 10:25
    Great, that answers it - just use any C reference already out there.

    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
  • photomankcphotomankc Posts: 943
    edited 2013-10-04 11:41
    By "C Commands" are you talking about things like:

    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
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2013-10-04 12:12
    I agree with the original poster. I'm having a hard time knowing what is in scope to use as part of prop c and what not to use. I have been running things in C++ mode to get attributes and objects- which don't seem to consume too much memory. That said, I don't use the C++ special library and don't even know what is in it. The prop C documentation is sort of all over the place, though Andy's tutorials are very good. The doxygen pages aren't super helpful.

    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.)
  • SRLMSRLM Posts: 5,045
    edited 2013-10-04 20:25
    I'll try to clarify a bit on the propellergcc/simpleide/standards question.

    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.
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2013-10-05 15:57
    Thanks for those references, Jazzed. The cprogramming.com site was especially useful for getting to the business end of how to make things work. I'm finding that the GCC works very well on the propeller, even in C++, as long as I stay way clear of stock GCC libraries and use the microcontroller specific ones instead. All the core language features seem to work.
  • Hal AlbachHal Albach Posts: 747
    edited 2013-10-06 11:04
    Any chance that this thread could be made "Sticky" so that it remains near the top? There is some really handy information here for us beginners in C.
Sign In or Register to comment.