Shop OBEX P1 Docs P2 Docs Learn Events
I want to start using C for P1. Where do I start? — Parallax Forums

I want to start using C for P1. Where do I start?

I have had a hard time trying to work with spin. I guess the general structure is so different that I can't stick to it. I am wanting to try C for P1, but I have no idea where to start. I remember that ersmith's IDE had access to a multi language compiler and I would like to use that compiler, but I have forgotten where to get his IDE. The other thing I would like to know is where I can find a few PropC tutorials.
«1

Comments

  • Clock LoopClock Loop Posts: 2,069
    edited 2020-10-27 03:11
    Parallax has actually invested quite a bit to teach prop c.
    I see more resources (overall) for prop c than spin.

    https://learn.parallax.com/tutorials/language/propeller-c

    They use simpleIDE. I also use simpleIDE for spin.
    I use simpleIDE to test out prop c programs, figure out how they work, and convert them to spin.
  • Clock LoopClock Loop Posts: 2,069
    edited 2020-10-27 03:24
    Also the SimpleIDE LEARN folder is CHOCK FULL of c examples.
    https://learn.parallax.com/tutorials/language/propeller-c/propeller-c-set-simpleide/update-your-learn-folder



    You can see all the learn folder examples online also.
    https://github.com/parallaxinc/Simple-Libraries/tree/master/Learn


    Also if you look at the libraries...
    https://github.com/parallaxinc/Simple-Libraries/tree/master/Learn/Simple Libraries
    You will see that each library folder has a HTML file for documentation, AND a SIDE file (for use with simpleIDE) so you can see an example on how to use that library.

    I wish they would convert the examples and the libraries to spin versions. (especially the library and its html help files)
  • I have had a hard time trying to work with spin. I guess the general structure is so different that I can't stick to it. I am wanting to try C for P1, but I have no idea where to start. I remember that ersmith's IDE had access to a multi language compiler and I would like to use that compiler, but I have forgotten where to get his IDE. The other thing I would like to know is where I can find a few PropC tutorials.

    Not to put you off considering C or anything else, but if you can't master something as simple as Spin, how are you going to fare with C?
  • I remember that ersmith's IDE had access to a multi language compiler and I would like to use that compiler, but I have forgotten where to get his IDE.

    —▷ https://github.com/totalspectrum/flexprop
    The other thing I would like to know is where I can find a few PropC tutorials.

    There are some examples...

    —▷ https://github.com/totalspectrum/flexprop/tree/master/samples

    ...but I don't know of a FlexC specific tutorial. Maybe digging in the compiler's doc directory is a start?

    —▷ https://github.com/totalspectrum/spin2cpp/tree/master/doc

    Some FastSpin examples hide in...

    —▷ https://forums.parallax.com/discussion/169141/testing-the-new-fastspin-assembly-spin-basic-and-c-for-p1/p1

    ...and in my signature but that messy heap of snippets hasn't been updated for a while.
  • RossHRossH Posts: 5,336
    Start with Eric's IDE by all means ... but when you are serious about C, try Catalina! :)
  • Thank you all!! Peter, that is a valid concern. However, the problem for me with spin lies not in complexity, but in the way the language is laid out. Not a bad language at all, and definitely suits the prop. I am trying for something more familiar, which c is somewhat familiar to me.
  • RossH wrote: »
    Start with Eric's IDE by all means ... but when you are serious about C, try Catalina! :)

    Of course he should. But why do you want the lad to try flying a plane he probably knows of from the movies?
    (A Catalina is in fact a PBY, a B24 on an amphib 's body and was the best answer to a difficult problem.)
  • Seriously though, your suggestion is a good one. Should I be so inclined I will indeed do that.
  • RossH wrote: »
    Start with Eric's IDE by all means ... but when you are serious about C, try Catalina! :)

    Well, if we're going to be snarky then if he's serious about C he should use a C compiler that's not 30 years out of date and he should use a command line like "real" C programmers do. So PropGCC is the only serious choice for him on P1. On P2 he's got LLVM and riscvp2 to choose from as "serious" choices.

    For a non-snarky answer, any of Catalina, FlexProp, and SimpleIDE will let you try out C programming on the Propeller. They all have their strengths and weaknesses, and it's worth trying all of them. Catalina is probably the easiest to use and has a debugger, but it's limited to C89 and produces slow code. SimpleIDE has good documentation from Parallax and much better performance than Catalina, but it's not really supported any more. FlexProp is somewhere in-between performance wise and has easy integration with Spin and BASIC, but it's based on a custom compiler and hence buggier than the others.

    C isn't a particularly good choice for the P1 given the limited memory, but it does work very well on P2.

  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2020-10-27 14:20
    ersmith wrote: »
    he should use a command line like "real" C programmers do.

    I do love the command line. Pray tell, does PropGCC compile spin and c or just c? (I need to be able to use the nrf24l01 object in the obex.) I’m going to take a crack at flexProp first of all.
  • ersmith wrote: »
    he should use a command line like "real" C programmers do.

    I do love the command line. Pray tell, does PropGCC compile spin and c or just c? (I need to be able to use the nrf24l01 object in the obex.) I’m going to take a crack at flexProp first of all.

    PropGCC handles only C and C++. There is a command line tool called spin2cpp that's basically the same compiler as flexspin and can convert Spin to C It's located at https://github.com/totalspectrum/spin2cpp. But if you're mixing Spin and C then I think FlexProp will be the easiest tool for you. The command line C compiler is "flexcc" and is found in the "bin" directory of the FlexProp distribution. You can also use "flexspin", that has openspin like command line arguments rather than C style ones, but all of the FlexProp tools can handle all of the languages.
  • I have been using SimpleIDE for many years now it does a great job. I don't do SPIN so for me it's a great fit.

    The other compilers are good, but the don't have a library function and don't have the extensive libraries that support all of the Parallax products they sell.

    In SimpleIDE you just add the library that contains the product you want to interface into and use those functions to address it. You don't have to know how it does it but if you want you can look at the source code for all the libraries and build your own. Each library function is also documented to tell you what functions are available and how to use them.

    In most cases I build my own library function and then just use it in my application. Can't do that with the other C compiler products.

    Mike
  • RossHRossH Posts: 5,336
    ersmith wrote: »
    RossH wrote: »
    Start with Eric's IDE by all means ... but when you are serious about C, try Catalina! :)

    Well, if we're going to be snarky then if he's serious about C he should use a C compiler that's not 30 years out of date and he should use a command line like "real" C programmers do. So PropGCC is the only serious choice for him on P1. On P2 he's got LLVM and riscvp2 to choose from as "serious" choices.

    For a non-snarky answer, any of Catalina, FlexProp, and SimpleIDE will let you try out C programming on the Propeller. They all have their strengths and weaknesses, and it's worth trying all of them. Catalina is probably the easiest to use and has a debugger, but it's limited to C89 and produces slow code. SimpleIDE has good documentation from Parallax and much better performance than Catalina, but it's not really supported any more. FlexProp is somewhere in-between performance wise and has easy integration with Spin and BASIC, but it's based on a custom compiler and hence buggier than the others.

    C isn't a particularly good choice for the P1 given the limited memory, but it does work very well on P2.

    I wasn't being snarky (but perhaps a bit cheeky!) - I was pointing out there are options. I think it is fair to say that Catalina has the most complete and comprehensive support for the unique facilities offered by the Propeller - both 1 and 2 - of any of the non-Spin options, so it really depends on what you want to achieve.

    However, you do raise an interesting point, which is what happened to gcc and SimpleIDE on the Propeller 1? I was away from Propeller development for a few years, and it seems that while it started out well, it then just petered out.

    Do you know why?
  • RossHRossH Posts: 5,336
    RossH wrote: »
    Start with Eric's IDE by all means ... but when you are serious about C, try Catalina! :)

    Of course he should. But why do you want the lad to try flying a plane he probably knows of from the movies?
    (A Catalina is in fact a PBY, a B24 on an amphib 's body and was the best answer to a difficult problem.)

    Catalina was named after the PBY - as the documentation says, it's a big, slow, “C”-going contraption ... powered by Propellers!
  • Catalina was named after the PBY - as the documentation says, it's a big, slow, “C”-going contraption ... powered by Propellers!
    Ross, I caught that in your docs and thought it was one of the wittier descriptions of a product ever. Thank you Sir!
  • Buck RogersBuck Rogers Posts: 2,160
    edited 2020-10-28 03:48
    @RossH and @pmrobert as you both recall I did indeed get involved with @RossH an interesting discussion regarding the PBY. To be honest I believe Consolidated name did name the first PBY who got pushed out of the builder shed after that channel island. (If the War did not happen she would have been used as a ferry plane for the services between those islands and the California mainland. That's just my opinion.)

    And yes it is indeed a witty description of a product.

    I have seen one of them, and she's the next to the most amazing aircraft ever built during that time period. The other was her sister, the B-24.

    But before we get involved in my other favorite hobby, historical aircraft and spacecraft, let's continue our discussion of C and the Prop.
    ---
    Mascot away.
  • I think FlexProp will give you the best C on P1 experience. Especially since you can just include Spin objects and call them directly from C, so it's super easy to include premade Spin objects written by the experts around here and use them from your C code.

    As for Spin vs C, Spin is simple and easy, except when you want to do something complex. It's lack of structures, and the way to arranges variables in memory make doing some things super cumbersome (like handling network packets that are packed). For P1, I mostly used PASM with a tiny bit of Spin glue, it's just easier in most cases for me. For P2, I haven't even used Spin2 at all beyond basic testing. I'm using C with inline PASM (as needed) and including other folks Spin2 objects when needed, and it's been great for me so far.

    The fact that we didn't get structures in Spin2 is a tragic omission, several of us asked for it and forum threads covered ways to do it, Chip even seemed keen on it at one point, but then just didn't do it. At least the P2 architecture makes it less painful (unaligned reads/writes, more instructions for manipulating bits/nibbles/bytes/words, etc.), but man it would have improved Spin2 usability for complex programs a HUGE amount to have structures.
  • RaymanRayman Posts: 13,805
    I think the options are all pretty good: PropGCC, Catalina C, FlexProp C.

    My guess is that PropGCC is the one that has been the most used.
    I think it was supported by Parallax a little bit at one point.
  • I recommend starting with SimpleIDE due to the many tutorials and extensive libraries for many Parallax products as well as the ability to make your own library functions.
    Tom
  • RossH wrote: »
    I think it is fair to say that Catalina has the most complete and comprehensive support for the unique facilities offered by the Propeller - both 1 and 2 - of any of the non-Spin options, so it really depends on what you want to achieve.

    You can say that, but that doesn't make it accurate! All of the major programming environments for the Propeller -- Spin, PropGCC, Catalina, Tachyon, FlexProp, PropBasic, etc. -- will allow you to do anything you want with the Propeller, so all of them have "complete and comprehensive" support. Each has its strengths and weaknesses. Any claim that one is "better" than the others is really just subjective, unless you narrowly focus on some particular metric like benchmark speed -- but that's such a narrow focus as to be mostly meaningless.
    However, you do raise an interesting point, which is what happened to gcc and SimpleIDE on the Propeller 1? I was away from Propeller development for a few years, and it seems that while it started out well, it then just petered out.

    I think it died when P2-Hot was shown to not be viable -- that was an enormous blow, and I don't think anyone had the enthusiasm to re-do all of the P2 work for the new architecture Chip created. P1 support kind of continued for a while, but Parallax has very limited resources and GCC isn't a particularly fun platform to work on. PropGCC was "good enough" for most users, so it didn't really get developed any further and the developers (myself included) drifted off to other things.
  • Wuerfel_21Wuerfel_21 Posts: 4,374
    edited 2020-10-28 21:40
    ersmith wrote: »
    RossH wrote: »
    I think it is fair to say that Catalina has the most complete and comprehensive support for the unique facilities offered by the Propeller - both 1 and 2 - of any of the non-Spin options, so it really depends on what you want to achieve.

    You can say that, but that doesn't make it accurate! All of the major programming environments for the Propeller -- Spin, PropGCC, Catalina, Tachyon, FlexProp, PropBasic, etc. -- will allow you to do anything you want with the Propeller, so all of them have "complete and comprehensive" support. Each has its strengths and weaknesses. Any claim that one is "better" than the others is really just subjective, unless you narrowly focus on some particular metric like benchmark speed -- but that's such a narrow focus as to be mostly meaningless.

    Eh, not quite - language features aside, some of them support memory saving techniques like CMM/bytecode, XMM/Overlays, enabling more complex programs.

    Also, while we're at it, what pointer widths do the C compilers use? LONG or WORD? (Obviously you could write a smart pointer in C++/PropGCC to get either width)
  • Wuerfel_21 wrote: »
    Eh, not quite - language features aside, some of them support memory saving techniques like CMM/bytecode, XMM/Overlays, enabling more complex programs...

    I agree, as I'm one of the few here working with XMM memory.

    I originally started with SimpleIDE, which was great for doing that which didn't require formatted printouts and other memory intensive stuff.

    Needing more memory to do such things, and seeing that PropGCC could support XMM, I attempted to migrate over to it, but could never get the repository to build under Ubuntu. Since I was going to write my own XMM driver, the rebuild was necessary, but this came to a quick halt when all attempts at rebuild failed.

    I finally moved over to Catalina and had great success with it. I was able to write my own XMM driver, build the required utilities, then compile and execute my XMM C program without hassles.

    Furthermore, the Catalina Multi-Memory Model support is really neat as I was able to write several functions running on different cogs using CMM, while my Primary program executed in XMM memory. The CMM and XMM programs can share variables using common memory within HubRam.

    As it stands right now Catalina appears to be working fine for what I have it doing, and its extensive documentation, examples, and ability to write and incorporate my own XMM driver has been greatly appreciated.

    I'm certainly open to any other C compiler that could support XMM memory while producing more efficient code than Catalina. I just don't see any other compiler that can do it.

    That's not a criticism of any other compiler, just an observation that one will need to weigh what features and capabilities will be required for any particular project when selecting a compiler.



  • RossHRossH Posts: 5,336
    ersmith wrote: »
    RossH wrote: »
    I think it is fair to say that Catalina has the most complete and comprehensive support for the unique facilities offered by the Propeller - both 1 and 2 - of any of the non-Spin options, so it really depends on what you want to achieve.

    You can say that, but that doesn't make it accurate! All of the major programming environments for the Propeller -- Spin, PropGCC, Catalina, Tachyon, FlexProp, PropBasic, etc. -- will allow you to do anything you want with the Propeller, so all of them have "complete and comprehensive" support. Each has its strengths and weaknesses. Any claim that one is "better" than the others is really just subjective, unless you narrowly focus on some particular metric like benchmark speed -- but that's such a narrow focus as to be mostly meaningless.
    I was specifically referring to support for multi-processing. Yes, all the options offer basic facilities - after all, these are built into the chip! - but none (as far as I know) are as comprehensive as Catalina's. Not even Spin. Propgcc a comes close second, because it has thread support, but it is not quite there for practical use. However, we probably should discuss this point elsewhere - it is not really relevant to this thread, and I agree it is subjective as to what importance you place on the various strengths and weaknesses of each offering.
    However, you do raise an interesting point, which is what happened to gcc and SimpleIDE on the Propeller 1? I was away from Propeller development for a few years, and it seems that while it started out well, it then just petered out.

    I think it died when P2-Hot was shown to not be viable -- that was an enormous blow, and I don't think anyone had the enthusiasm to re-do all of the P2 work for the new architecture Chip created. P1 support kind of continued for a while, but Parallax has very limited resources and GCC isn't a particularly fun platform to work on. PropGCC was "good enough" for most users, so it didn't really get developed any further and the developers (myself included) drifted off to other things.

    I have vaguely heard of the P2-Hot, but I don't know much about it. I seem to have missed that one entirely. Sounds like this may not have been a bad thing!

    Ross.
  • RossHRossH Posts: 5,336
    Wuerfel_21 wrote: »
    ersmith wrote: »
    RossH wrote: »
    I think it is fair to say that Catalina has the most complete and comprehensive support for the unique facilities offered by the Propeller - both 1 and 2 - of any of the non-Spin options, so it really depends on what you want to achieve.

    You can say that, but that doesn't make it accurate! All of the major programming environments for the Propeller -- Spin, PropGCC, Catalina, Tachyon, FlexProp, PropBasic, etc. -- will allow you to do anything you want with the Propeller, so all of them have "complete and comprehensive" support. Each has its strengths and weaknesses. Any claim that one is "better" than the others is really just subjective, unless you narrowly focus on some particular metric like benchmark speed -- but that's such a narrow focus as to be mostly meaningless.

    Eh, not quite - language features aside, some of them support memory saving techniques like CMM/bytecode, XMM/Overlays, enabling more complex programs.

    Also, while we're at it, what pointer widths do the C compilers use? LONG or WORD? (Obviously you could write a smart pointer in C++/PropGCC to get either width)

    Catalina uses LONGs in all modes, but in COMPACT mode addresses are limited to 24 bits.
  • Cluso99Cluso99 Posts: 18,066
    OT but a quick reply. The P2HOT was a power hungry monster although in the end probably was not much worse than what was expected in the final P2, and clock gating fixed that up significantly. Cog RAM was quad port resulting in 1 clock instructions, and hardware threading was built-in so you could have a cog running for example 4 threads by alternating each of 4 clocks to each thread in turn. In hindsight, P2Hot should have been built way back in 2014.
    forums.parallax.com/discussion/144199/propeller-ii-emulation-of-the-p2-on-fpga-boards-prop123-a7-a9-de0-nano-de2-115-etc/p1
  • "Where do I start." My suggestion, start with SimpleIDE.

    I have been using SimpleIDE since its inception, yes, it has some short comings, but it is the best suitable C for the P1. I have tried all of the available IDEs, that would be Catalina and FlexProp. Catalina is just not for me, I tried using it on numerous occasions, it just did not do it for me.

    FlexProp will be something I will be switching to, if and when I decide to start using the P2. FlexProp, IMO, is geared more for P2 than the P1, and it is still a work in progress.

    The reason I suggest SimpleIDE, simple, it has CMM, if that was not available, I probably would not be using it, as much. The other big feature, is the library file(s), it covers just about all of the modules that Parallax sells, that is the module drivers. Plus, the Learn forum still has some examples as to how to use the C drivers for the different modules. Plus, it has some documentation as how to make your own lib files, if you choose to do so. Plus...

    The only drawback with SimpleIDE, it has not been updated in a very long, long time. I think Parallax is giving up on it, which is a shame, I still will probably be using the P1, so I would like to see SimpleIDE, all distributions, get updated.

    Ray
  • RossHRossH Posts: 5,336
    Rsadeika wrote: »
    Catalina is just not for me, I tried using it on numerous occasions, it just did not do it for me.

    I'd be interested in hearing why not, and also if you have tried the new Geany-based IDE (included with the most recent Catalina releases). But in order not to derail this thread, perhaps we could take that discussion to the Catalina thread?
  • Isn't it obvious? He does not have the room he needs to park a PBY.

    Seriously, let's do what @RossH wants.
  • yetiyeti Posts: 818
    edited 2020-10-31 04:22
    I was heavily excited when PropGCC showed up, but it did not keep up with the current environments and is from hard to impossible to build on today's systems.

    Additionally the feature I was hoping to use a lot has kind of been dropped (XMM).

    FastSpin (the compiler hidden in FlexProp, I prefer to use it without GUI) brings back a lot of P1 fun with all 4 languages (PASM, Spin, BASIC, C) being easily mixable. No XMM yet, but lots of fun in other areas.

    You even can compile time critical stuff with FastSpin and mix it into bytecode-Spin (OpenSpin) main programs!
    —▷ https://forums.parallax.com/discussion/comment/1479292/#Comment_1479292
  • Finally got the chance to get FlexProp downloaded and I am loving it! C is definitely going to be a better fit for me, I think, and I may be able to get more Propeller projects done now!
Sign In or Register to comment.