Shop OBEX P1 Docs P2 Docs Learn Events
I have begun my Propeller 2 journey! — Parallax Forums

I have begun my Propeller 2 journey!

Hi All,

I have begun my Propeller 2 journey. I have a rather large project written in C (89000ish lines of code) and want to port it to the Propeller 2 chip. Which IDE is good for multi-file designs? I tried using Catalina Geany but cannot get the Propeller 2 development board to communicate with the IDE. I tried following the examples in the getting started document but had no luck. I started using the FlexProp IDE and I was able to connect to the development board and successfully did the Hello World and blinking led projects with no problem. I noticed the FlexProp IDE is simple and does not allow for a multi-file type of project or is that not true? I'm confused about which IDE I need to use for my project. Which one do you all recommend for large multi-file projects? I come from Keil MDK and Eclipse just to give a little bit of my background. I am comfortable with bare metal programming at the register level in C. I try to avoid assembly language if I can. The chips I have used are the PSOC 5, Nuvoton M481 series, STM32H723, and the EFINIX Sapphire RISCV multi-core SOC in an FPGA.

I thought about using SPIN2 but that might not work unless someone says differently. I need full control of unions and structs for bit field manipulation, c-type macros, bool data type etc. Does SPIN2 handle these? Is there a comparison from C syntax to the SPIN2 syntax document that I can use while learning if I do go the SPIN2 route? How hard is SPIN2 to learn?

I'm sure I will like working with the Propeller 2 chip but right now it is a little confusing to get going. Thank you all in advance for your help :-).

Thanks,

Eric Norton

«1345678

Comments

  • You should go with Spin2, If your a good "C" programmer you should catch on quick.

  • The FlexProp IDE can't handle multiple files, but the FlexSpin/FlexCC compiler that it calls into does. So perhaps just use the editor you like the most and use the command line flexcc compiler. Though I'm not sure if that much code even fits into the 512K of RAM.

  • Don't forget to try the Spin tool

  • Though I'm not sure if that much code even fits into the 512K of RAM.

    My thoughts, too.

  • @DigitalBob said:
    You should go with Spin2, If your a good "C" programmer you should catch on quick.

    I will take a look at it and see how painful it is. I am pretty good with C but not the greatest..

  • @Wuerfel_21 said:
    The FlexProp IDE can't handle multiple files, but the FlexSpin/FlexCC compiler that it calls into does. So perhaps just use the editor you like the most and use the command line flexcc compiler. Though I'm not sure if that much code even fits into the 512K of RAM.

    Which editor can I use? I tried using VSC a while back with ESP32 stuff and hated it. Does Eclipse work? Does anybody have experience using Eclipse with FlexCC? When I compile the code on say for instance the STM32H723 device it takes about 136K of flash. There are a lot of comments in the code as I like to make sure I can pick back up where I left off if I have to drop what I am doing.

  • @DigitalBob said:
    Take a gander at the manual

    Thank you, I will take a look :-)

  • @JonnyMac said:

    Though I'm not sure if that much code even fits into the 512K of RAM.

    My thoughts, too.

    When I compile the code on say for instance the STM32H723 device it takes about 136K of flash. There are a lot of comments in the code as I like to make sure I can pick back up where I left off if I have to drop what I am doing.

  • @enorton said:

    @Wuerfel_21 said:
    The FlexProp IDE can't handle multiple files, but the FlexSpin/FlexCC compiler that it calls into does. So perhaps just use the editor you like the most and use the command line flexcc compiler. Though I'm not sure if that much code even fits into the 512K of RAM.

    Which editor can I use? I tried using VSC a while back with ESP32 stuff and hated it. Does Eclipse work?

    Literally any editor you want. Just take the one you like best. I use VS Code, but I almost never set up any of the IDE-like functionality, I just use the terminal window to call the compiler and loader (which you can steal out of FlexProp's install directory and put on PATH)

    Something like

    flexcc -2 file1.c file2.c file3.c -o program.binary
    loadp2 -pCOM8 program.binary
    

    which you can of course put into a batch file, which you could then in turn set up your IDE of choice to execute.

  • I will take a look at it and see how painful it is. I am pretty good with C but not the greatest..

    Just my opinion, of course, but I make most of my living writing Spin code for clients. It's a small, easy language. It doesn't have all the same features as C, but it was designed from the ground up to be multi-core which can be advantageous. Where the P2 shines is with its speed (even with interpreted Spin) and smart pin hardware. Of course, for critical elements PASM is available and quite friendly, even for people like me who don't use it all the time.

    Spin is different, yes, but a lot of fun if you give it a try.

  • RaymanRayman Posts: 13,900
    edited 2023-04-07 23:01

    Welcome @enorton !

    Seems everybody has their own opinion, but if doing C, I find Visual Studio Community absolutely the best.
    Take a look at the attached screenshot.

    I have multiple projects in one solution and can instantly search through all of them for anything.
    Doing this as "makefile" projects.

    VS actually compiles your code as you type it and can instantly show you mistakes.
    There's really nothing that compares, IMHO

    edit: Added better screenshot with actual code showing how it flags some FlexC specific things as errors with red squiggly.
    Also shows how you can search any way you want...

    1654 x 1241 - 202K
    1651 x 1239 - 208K
  • @JonnyMac said:

    I will take a look at it and see how painful it is. I am pretty good with C but not the greatest..

    Just my opinion, of course, but I make most of my living writing Spin code for clients. It's a small, easy language. It doesn't have all the same features as C, but it was designed from the ground up to be multi-core which can be advantageous. Where the P2 shines is with its speed (even with interpreted Spin) and smart pin hardware. Of course, for critical elements PASM is available and quite friendly, even for people like me who don't use it all the time.

    Spin is different, yes, but a lot of fun if you give it a try.

    Thank you Jon, I will take a look and make a decision soon :-)

  • RossHRossH Posts: 5,347

    @enorton said:
    Hi All,

    I tried using Catalina Geany but cannot get the Propeller 2 development board to communicate with the IDE.

    Hi Eric

    Catalina's Geany IDE doesn't have any special comms function - it just uses the payload loader, which is a command line utility. Some people reported issues with payload finding the wrong binary when executed from within Geany, but I thought I had sorted that out in the most recent release (5.8).

    If you want to give me a few more details of what you were seeing, I'll look into it.

    Using payload from the command line should always work, so you can use Geany as your file/project manager and compiler and then load the program from the command line until we find out what's going on.

    Ross.

  • @RossH said:

    @enorton said:
    Hi All,

    I tried using Catalina Geany but cannot get the Propeller 2 development board to communicate with the IDE.

    Hi Eric

    Catalina's Geany IDE doesn't have any special comms function - it just uses the payload loader, which is a command line utility. Some people reported issues with payload finding the wrong binary when executed from within Geany, but I thought I had sorted that out in the most recent release (5.8).

    If you want to give me a few more details of what you were seeing, I'll look into it.

    Using payload from the command line should always work, so you can use Geany as your file/project manager and compiler and then load the program from the command line until we find out what's going on.

    Ross.

    Hi Ross,

    Ok, well I bumped into a really weird issue a little while ago, and for whatever reason when I try to compile and build the project, I get this:

    Process failed (The system cannot find the file specified)

    Now when I go and run Catalina Geany in administrator mode it compiles and builds just fine BUT does not allow me to go into the properties (Project->Properties) to change things like -p2 etc. It is grayed out for some reason. Before when I launch the program from Windows start menu and compile the project it compiled and built fine. I am not sure if I messed something up or not.

    I would love to use Catalina because I can port my code over to it without heavy modification like moving to SPIN2 and it allows me to create a PROJECT which none of the other IDEs allow me to do which I find quite silly, to be honest. The project I am porting over is rather large and I need something I can use to get working on code stuff and not fiddling with IDE nightmares.

    Once we can figure out why the above is happening and fix it, I would like to address why the Propeller 2 chip is not able to communicate with the Catalina Geany software. I think I tried just about every command I could find and still no luck so not sure what is going on there. Any ideas are greatly appreciated!

    Thanks,

    Eric

  • RossHRossH Posts: 5,347

    @enorton said:

    Ok, well I bumped into a really weird issue a little while ago, and for whatever reason when I try to compile and build the project, I get this:
    ...
    Process failed (The system cannot find the file specified)

    This error message looks like Geany cannot find the Catalina compiler itself. Could be a path or permissions problem.

    First try this - run Geany as normal, but create a project from scratch in a "projects" subdirectory of your own Windows user directory (e.g. my initial base path for projects is "C:\Users\rossh\projects\"), and make sure you can compile a C file in there (e.g. copy "hello_world.c" from the demos folder). This is just to make sure that Geany itself and Catalina are installed ok.

    Then try your project again. Open it, then open the Project Properties window and post an image of it. Then try to compile again. If it still fails (which I expect it will) then start a Catalina Command Line window, and copy and paste the full compile message from Geany Compiler window to the Command Line window. It should have a part at the end saying something like " (in directory: ...)". Remove the "(in directory ...)" part, execute the rest and post the result.

    Ross.

  • bob_g4bbybob_g4bby Posts: 401
    edited 2023-04-08 09:40

    If the project is too large to fit when compiled normally, then compiling for bytecode in Flexprop might be useful, saving considerable space.

  • @RossH said:

    @enorton said:

    Ok, well I bumped into a really weird issue a little while ago, and for whatever reason when I try to compile and build the project, I get this:
    ...
    Process failed (The system cannot find the file specified)

    This error message looks like Geany cannot find the Catalina compiler itself. Could be a path or permissions problem.

    First try this - run Geany as normal, but create a project from scratch in a "projects" subdirectory of your own Windows user directory (e.g. my initial base path for projects is "C:\Users\rossh\projects\"), and make sure you can compile a C file in there (e.g. copy "hello_world.c" from the demos folder). This is just to make sure that Geany itself and Catalina are installed ok.

    Then try your project again. Open it, then open the Project Properties window and post an image of it. Then try to compile again. If it still fails (which I expect it will) then start a Catalina Command Line window, and copy and paste the full compile message from Geany Compiler window to the Command Line window. It should have a part at the end saying something like " (in directory: ...)". Remove the "(in directory ...)" part, execute the rest and post the result.

    Ross.

    Hi Ross,

    I was being stupid :-(. I'm still a spring chicken here so bear with me lol. I can now compile the project and access the project properties. What is very strange is I still need to open the program with administrator rights in order for it to compile and build which is weird. Is there a way to always use administrator rights when I open it from the start menu? If not, then no big deal.

    Is it possible to create a project and save it onto another drive? The reason why I ask is I use the C: drive as a programs-only drive and store projects and backup stuff on another drive just in case Windows has a fit and I need to reload it which seems to be often with all the stupid updates.

    How do I program the Propeller 2 chip from Catalina or is this a command line thing for now? Do you have screenshots of what I need to configure? I am really new to doing things this way. Please bear with me :-).

    Thanks,

    Eric

  • If your moving code over that is already C then using FlexC should be fine. I do all my programming in VSC. I love the code completion and syntax highlighting.

    FlexC can compile your code into a different directory or a different drive keeping it away from your source code.

    Building libraries and having them reference is a snap.

    I use several editors for different projects such as Eclipse for STM, Java, Maxim. or Arduino for ESP32, ESP8266 and Visual Studio for C#, or Android Studio for tablets.

    It's easy to integrate flexC into VSC so you can do everything from within VSC.

    Mike

  • @iseries said:
    If your moving code over that is already C then using FlexC should be fine. I do all my programming in VSC. I love the code completion and syntax highlighting.

    FlexC can compile your code into a different directory or a different drive keeping it away from your source code.

    Building libraries and having them reference is a snap.

    I use several editors for different projects such as Eclipse for STM, Java, Maxim. or Arduino for ESP32, ESP8266 and Visual Studio for C#, or Android Studio for tablets.

    It's easy to integrate flexC into VSC so you can do everything from within VSC.

    Mike

    How do you do this? Forgive me for being stupid in this regard. I come from Eclipse and Keil MDK and am not used to "makefile" and all this other weird stuff... I suppose VSC wouldn't be bad I just had a bad experience with it doing ESP32 coding in it and hated it. Surely there is a better way to do this... I am waiting for Ross to get back to me because his method seems to be the best so far because I can actually create a project and none of the other IDEs let you do that which is very annoying. I'm not going to place all my code in one file. That would be asking for trouble and spending most of my time searching through that one file would be a serious waste of time.

  • @enorton : what operating system are you using? I'm working on an update to FlexProp to add .side (simple project file) support, which should be ready soon. In the meantime, you don't have to keep all of your code in one file in FlexC, even when using the IDE. You can use __fromfile (or _IMPL, they are the same) directives in the header files to indicate which file contains the functions declared in that header, and the compiler will load them in automatically. See for example the samples/proplisp/ project; you can just load and compile either fibo.c or lisp.c, and the header file lisplib.h included by those will make sure the rest of the code will be linked in.

  • @ersmith said:
    @enorton : what operating system are you using? I'm working on an update to FlexProp to add .side (simple project file) support, which should be ready soon. In the meantime, you don't have to keep all of your code in one file in FlexC, even when using the IDE. You can use __fromfile (or _IMPL, they are the same) directives in the header files to indicate which file contains the functions declared in that header, and the compiler will load them in automatically. See for example the samples/proplisp/ project; you can just load and compile either fibo.c or lisp.c, and the header file lisplib.h included by those will make sure the rest of the code will be linked in.

    I use Windows 10... Is there a way in FlexProp where you can add the functionality so people can create a project? It would be preferable to do this in my opinion for people who like me come from Eclipse or Keil or other IDEs such as PSOC Creator etc. If this is not possible, why?

    The Propeller 2 chip looks really cool, and I am sure it is but not having an IDE that works for large designs is a bit worrisome. I am aware of SPIN, PASM, and BASIC but I just don't have the time to learn something new. Maybe when I have the time, I can do that but right now I have a deadline to meet and really need to start working with the chip instead of trying to figure out which IDE will work for C. I am so close to abandoning the Propeller 2 chip because the tools are not streamlined or ready for use yet. If someone can show me something that I can use for large designs and I can use C and program the chip through the IDE I will stick with the Propeller 2 chip. If not, I will be forced to set the Propeller 2 chip aside (maybe return the development board) and go with an XMOS device since the tools are already there and I can port over to their IDE which is Eclipse.

    Thanks,

    Eric

  • @RossH said:

    @enorton said:

    Ok, well I bumped into a really weird issue a little while ago, and for whatever reason when I try to compile and build the project, I get this:
    ...
    Process failed (The system cannot find the file specified)

    This error message looks like Geany cannot find the Catalina compiler itself. Could be a path or permissions problem.

    First try this - run Geany as normal, but create a project from scratch in a "projects" subdirectory of your own Windows user directory (e.g. my initial base path for projects is "C:\Users\rossh\projects\"), and make sure you can compile a C file in there (e.g. copy "hello_world.c" from the demos folder). This is just to make sure that Geany itself and Catalina are installed ok.

    Then try your project again. Open it, then open the Project Properties window and post an image of it. Then try to compile again. If it still fails (which I expect it will) then start a Catalina Command Line window, and copy and paste the full compile message from Geany Compiler window to the Command Line window. It should have a part at the end saying something like " (in directory: ...)". Remove the "(in directory ...)" part, execute the rest and post the result.

    Ross.

    Hi Ross,

    I figured out why it wouldn't communicate with the board. The com port was COM33 and didn't recognize it for some reason. Is there a limit to how high the com ports go? Anyway, I think I am good for now. Thank you for your help.

    Thanks,

    Eric

  • RossHRossH Posts: 5,347

    @enorton said:

    I can now compile the project and access the project properties. What is very strange is I still need to open the program with administrator rights in order for it to compile and build which is weird. Is there a way to always use administrator rights when I open it from the start menu? If not, then no big deal.

    You should not have to use administrator rights. Something is not right. If you can compile other projects, check the permissions on your project folder.

    Is it possible to create a project and save it onto another drive? The reason why I ask is I use the C: drive as a programs-only drive and store projects and backup stuff on another drive just in case Windows has a fit and I need to reload it which seems to be often with all the stupid updates.

    Yes - close all the project files, then in the project properties tab, set ./ as your base path. Note that's dot-slash, even on Windows, which normally uses backslash as the path separator. Then you can move the project folder anywhere.

    How do I program the Propeller 2 chip from Catalina or is this a command line thing for now? Do you have screenshots of what I need to configure? I am really new to doing things this way. Please bear with me :-).

    Catalina uses payload as its loader. You should be able to use this either from a Catalina command line or from within Geany (in Geany, you invoke payload via the Download and Execute or Download and Interact menu items on the Build menu). If this is not working, make sure your baud rate (in the project properties tab) is either blank, or is set to 230400. It may be set to 115200 by default for a new project. Also, make sure to Clean and Build the project with the -p2 option set, to make sure it builds a Propeller 2 binary, not a Propeller 1 file.

    Ross.

  • RossHRossH Posts: 5,347

    @enorton said:

    I figured out why it wouldn't communicate with the board. The com port was COM33 and didn't recognize it for some reason. Is there a limit to how high the com ports go? Anyway, I think I am good for now. Thank you for your help.

    Thanks,

    Eric

    Aha! Yes, payload only recognizes COM ports up to COM32 :(

    This was built into the serial port comms code I used - I can modify this in the next release if needed, but in the meantime just rename your serial port to use a lower COM number (if you have one available). You can do this using the Device Manager - right click on the serial port, then Properties->Advanced->COM Port Number

    Ross.

  • @RossH said:

    @enorton said:

    I figured out why it wouldn't communicate with the board. The com port was COM33 and didn't recognize it for some reason. Is there a limit to how high the com ports go? Anyway, I think I am good for now. Thank you for your help.

    Thanks,

    Eric

    Aha! Yes, payload only recognizes COM ports up to COM32 :(

    This was built into the serial port comms code I used - I can modify this in the next release if needed, but in the meantime just rename your serial port to use a lower COM number (if you have one available). You can do this using the Device Manager - right click on the serial port, then Properties->Advanced->COM Port Number

    Ross.

    Ahh ok well that makes sense and man I was one COM port number away from having success lol. Thanks for letting me know.

    Ok on to the nitty gritty stuff... I need these peripherals:

    1. Two serial ports at 115200 baud with interrupts if that is possible. Would one cog be used for serial communication? Would I even need interrupts if it is in its own cog/core? Do you have an example with functions I can see to implement two serial ports?
    2. I need three I2C peripherals. All three are relatively slow 100kHz. Do you have an example with functions?
    3. I need one SPI peripheral with four chip selects. Do you have an example with functions?
    4. One 32-bit timer with compare interrupt. Do you have an example with functions?
    5. 16 bit PWM output.

    How can I add these peripherals to my code in Catalina Geany?

    Since I am really new to all this where can I find the information on the above peripherals? I'm looking all over the place and there really isn't much information on any of it. I see a little bit of info on the serial and spi stuff but that is it. Do I need to design the peripherals myself? If there are functions for these peripherals, do I use "#includes" to add them to my design in Catalina Geany? I am very sorry but I feel like a complete idiot when it comes to this chip. I'm so new to all of this I am embarrassed to even be asking these questions :-(. As always you have been a great help and I am sorry for being such a pain.

    Thanks,

    Eric

  • RossHRossH Posts: 5,347

    @enorton said:

    I am so close to abandoning the Propeller 2 chip because the tools are not streamlined or ready for use yet. If someone can show me something that I can use for large designs and I can use C and program the chip through the IDE I will stick with the Propeller 2 chip. If not, I will be forced to set the Propeller 2 chip aside (maybe return the development board) and go with an XMOS device since the tools are already there and I can port over to their IDE which is Eclipse.

    I'm sure the XMOS is a very nice chip for some purposes, but it is not nearly as much fun as the Propeller :)

    Ross.

  • @RossH said:

    @enorton said:

    I am so close to abandoning the Propeller 2 chip because the tools are not streamlined or ready for use yet. If someone can show me something that I can use for large designs and I can use C and program the chip through the IDE I will stick with the Propeller 2 chip. If not, I will be forced to set the Propeller 2 chip aside (maybe return the development board) and go with an XMOS device since the tools are already there and I can port over to their IDE which is Eclipse.

    I'm sure the XMOS is a very nice chip for some purposes, but it is not nearly as much fun as the Propeller :)

    Ross.

    XMOS is expensive and I already bought the P2 dev board so it looks like I have to figure this out. I'm sure I will figure it all out it will just take hours of frustration and pulling my hair out lol. The joys of learning a new microcontroller...

  • @RossH said:

    @enorton said:

    I am so close to abandoning the Propeller 2 chip because the tools are not streamlined or ready for use yet. If someone can show me something that I can use for large designs and I can use C and program the chip through the IDE I will stick with the Propeller 2 chip. If not, I will be forced to set the Propeller 2 chip aside (maybe return the development board) and go with an XMOS device since the tools are already there and I can port over to their IDE which is Eclipse.

    I'm sure the XMOS is a very nice chip for some purposes, but it is not nearly as much fun as the Propeller :)

    Ross.

    How do I store the program in Flash on the dev board? Is there a command in the properties for this? I would like to eventually be able to store the program on the SD card so I can send a customer the new file and they can load it onto their SD card.

  • RossHRossH Posts: 5,347

    @enorton said:

    1. Two serial ports at 115200 baud with interrupts if that is possible. Would one cog be used for serial communication? Would I even need interrupts if it is in its own cog/core? Do you have an example with functions I can see to implement two serial ports?

    Catalina supports a 2 port serial plugin - this uses a cog. You probably won't need interrupts. In Catalina a 'plugin' is like a device driver that runs in a separate cog. Usually written in SPIN/PASM, although I generally rewrite the SPIN parts in C. There is a library to access the ports - libserial2.

    1. I need three I2C peripherals. All three are relatively slow 100kHz. Do you have an example with functions?

    I2C is fairly easy and at low speeds probably does not need a dedicated cog, just a few simple functions. There is a working example (to access an I2C EEPROM) in the port I did of the Simple Libraries. See https://forums.parallax.com/discussion/comment/1548142/#Comment_1548142

    1. I need one SPI peripheral with four chip selects. Do you have an example with functions?

    SPI covers a lot of ground. You'll have to be more specific. I suggest posting what you need to support in a separate thread - someone probably has some code that can be re-used.

    1. One 32-bit timer with compare interrupt. Do you have an example with functions?

    The Propeller is very good on clocks and timers. Also, Catalina has a real-time clock plugin plus all the usual C time functions. You'll need to be a bit more specific, but I'm sure either the Propeller itself, or Catalina, can do what you need.

    1. 16 bit PWM output.

    Check out the Propeller smartpin capabilities. They may already do what you need in just a few instructions.

    How can I add these peripherals to my code in Catalina Geany?

    Hard to be specific - some may need just a few inline PASM instructions (e.g. the smartpins), some may need a few new functions (e.g. the I2C), there may be an existing plugin (e.g. the 2 port serial) while others may need a new plugin (e.g. the SPI whatever).

    Nearly all Catalina's plugins stated life as independent SPIN/PASM code written by other people. If the code already exists somewhere, it can generally be turned into a plugin fairly easily. Read up on 'plugins' in the Catalina manual - they are most general purpose method, but each one consumes one or more cogs, and so they can be expensive.

    Ross.

Sign In or Register to comment.