Shop OBEX P1 Docs P2 Docs Learn Events
Newb to spin2 — Parallax Forums

Newb to spin2

I thought I would take a break from python coding. I dug out my p2 Edge setup, I installed spintools ide, and now I am completely lost.

It seems that every programming language has a "hello,world" example code. I tried to find a spin2 version, but no luck. So, where do start my spin2 beginners' journey.

Thanks
Ray

Comments

  • JonnyMacJonnyMac Posts: 9,709

    My template program for the P2 is a "Hello, World!"

    Like the P1, the P2 needs a library to talk with a terminal. When the P2 first showed up I wrote an article for Nuts & Volts. While a lot has been added to Spin2 (which is updatable, unlike Spin1 that is etched in the P1 silicon), this article is still valid and will help you get a start.
    -- https://www.nutsvolts.com/magazine/article/an-introduction-to-the-parallax-propeller-2

    In my opinion, Spin2 is simpler and nicer than Spin1. I just spent a month updating an old P1 project that is almost 4000 lines in the main file; I constantly was wishing I had P2 syntax. That said, Spin Tools is a great choice of environment. Marco is very responsive to user inputs and serval suggestions I made while working on that big project made it into the current release, and are making my life easier.

  • RsadeikaRsadeika Posts: 3,889

    Thanks Jon, I will see how far I get with this new stuff.

    Ray

  • RsadeikaRsadeika Posts: 3,889

    First impressions:

    Spin Tools is a very complex IDE. I was expecting a simple Load , Run commands. Maybe Spin Tools should have simple, easy to use version.

    I looked at the program that Jon provided; it is complex to me. I am sure that for Jon it is a very simple example program.

    This is going to take some time to figure out what is going on. I can see why some people would give up on spin2 and go with python. I will give it a good try.

    Ray

  • JonnyMacJonnyMac Posts: 9,709
    edited 2026-03-02 22:11

    Spin Tools is a very complex IDE. I was expecting a simple Load , Run commands.

    You're kidding, right?

    1 Open (Load) -- or use File / Open...
    2 Run -- or use Tools / Upload to RAM

    Maybe Spin Tools should have simple, easy to use version.

    It is easy now. And if I do say so, it takes a lot of nerve to ask for a "simpler" version of a program you haven't properly tried.

    My acting coach, the late Cliff Osmond, would say to you vis-à-vis your complaints:

    Don't suffer. Solve!
    Don't whine. Win!

    How? Instead of complaining, spend 15 or 20 minutes every day experimenting. In a week or two you'll be very comfortable with Spin Tools -- but only if you put in some effort.

    Spin Tools is created by Marco Maccaferri (a consultant / Propeller developer) for Propeller developers with a lot of input from those developers. He doesn't work for Parallax, and he doesn't charge anything for the tool. Many of us have sent him gifts through his Ko-fi account (https://ko-fi.com/maccasoft).

    If you'll take a breath and give yourself a bit of time with it, you'll appreciate everything that Marco has done. If there's anything to complain about, it's that Parallax didn't create a tool as full-featured as this for the Propeller years ago.

  • bob_g4bbybob_g4bby Posts: 560
    edited 2026-03-04 02:50

    I was in your position just after Christmas just gone, didn't know a thing about Spin2 - had done a little Assembly. Today, I'm pretty comfortable with programming in both - given that I have three essential references open on my other screen:-
    1. Spin2 Language Documentation
    2. Propeller 2 Assembly Language
    3. IRQsoft Propeller 2 Docs Just type an assembly language instruction to jump to a description, or click on the contents list.
    (1) and (2) are available as google docs, but I find them more useful as pdfs with a clickable contents strip down the left hand side (you may have to open that if it isn't showing). See the attached files. I use ctrl-f a lot.

    Why the Assembly Language documents if you want to program in Spin? Because many built-in methods are closely related to PASM instructions and the special hardware they support.

    The hardware manual will be very useful to start with.

    As for example code, the Obex is full of useful stuff. I'm currently using JonnyMac's I2C driver to talk with various external devices hooked onto the P2.

    Your enthusiasm will be boosted if you can 'make lights flash' even if you have nothing connected to the P2. Get going soon with the debug windows you can create with Spin Tools. They are all described in the Spin2 manual + look at some of the code I've been posting - they were all developed in Spin Tools as demos / test sets for the methods I am developing. It helps to see exactly what your code is doing by fitting debug statements - they are so useful, rather than guessing.

    Ask questions, but do post the code you're trying to get going. That way you'll get help pretty quickly.

    Happy "Spinning", bob

  • RsadeikaRsadeika Posts: 3,889

    I was not complaining, I forgot to add in "as compared to SimpleIDE". When spin2 became available, I was hoping that spin2 would be adapted to SimpleIDE, but that did not happen.

    Where is the spin2 commands manual, I looked around and could not find it. I found the P2 manuals, but no spin2 manual.

    I am sure that I will get the hang of using Spin Tools IDE.

    Ray

  • RsadeikaRsadeika Posts: 3,889

    I loaded Jon's example program, and I assume that if you want to run the program you use thye run command. When I do the run, I get "No configured external tools", what is that and how do I get around that.

    Ray

  • RaymanRayman Posts: 16,099

    No, that is for external tools...

    You want to use the icons below the menu, most everything is there...
    The blue play button is to upload to RAM and run.

    I usually do the bug icon which does the same, but with debug enabled...

  • RsadeikaRsadeika Posts: 3,889

    OK, so I got my first little program to compile and run. I am sort of figuring this Spin Tools IDE out.

    '' tet_led.spin2

    CON
    CLK_FREQ = 200_000_000
    MS_001 = CLK_FREQ / 1_000

    'VAR
    ' long stack1

    PUB main()
    dira[56] := 1

    repeat
        pintoggle(38)
        waitms(1000)
    
  • JonnyMacJonnyMac Posts: 9,709
    edited 2026-03-03 23:29

    With your file open (File / Open... from the menu, or folder icon from the toolbar), press Shift+F10 (or Shift + blue Play button) to run a program that uses terminal output (like my template). Spin Tools has its own compiler (which is always running so you are show errors as they happen), but you may wish to use an external compiler like PNut of FlexProp -- the Run menu allows the use of external tools, but they do require setup.

    As Ray points out, there is a different toolbar icon for the P2 debug windows. For simple strings, P2 debug is easy. For more complex outputs, P2 debug commands can be tricky. You've been warned. In Spin Tools, basic debug information is output to a console pane under the bottom of the edit window. This debug output can also be logged to a file.

    I forgot to add in "as compared to SimpleIDE

    In my opinion, SimpleIDE was developed for schoolchildren; Spin Tools -- which is not difficult after a few minutes exploration -- is a tool for developers. Still, you can make Spin Tools look "easy" by hiding some features. Go into the Preferences dialog and on the General section uncheck "Show object browser" and "Show file browser," and on the Editor section uncheck "Show outline." You'll end up with a display that looks like the attached image.

    1920 x 1040 - 69K
  • RsadeikaRsadeika Posts: 3,889

    I am trying to develop a term session, and I am having problems with the code snippet. When I try to compile it, Spin tools says program error and points to the term line. Not sure what is causing the error. The file is in the same dir as the test_term file.

    Ray

    '' test_term.spin2
    ''

    CON
    CLK_FREQ = 200_000_000
    MS_001 = CLK_FREQ / 1_000

    con {terminal}
    BR_TERM = 230_400

    obj
    term : "jm_fullduplexserial" ''This where it shows the error

    PUB main()
    term.tstart(BR_TERM)

  • JonnyMacJonnyMac Posts: 9,709
    edited 2026-03-03 22:42

    You probably don't have jm_fullduplexserial.spin2 in the P2 library. I don't use them, but Spin Tools defaults to libraries in its install location:

    Move jm_fullduplexserial.spin2 and jm_nstr.spin2 to the P2 library folder and try again. You should see a blue icon next to the name in the Object Browser (if you have it open -- and this is a good reason on why).

    The blue document icon tells you that the file is in a library folder; a yellow document icon tells you the file is in the project folder (these rules follow Propeller Tool).

    If you want to customize your library location (I use the consolidated Propeller Tool library) you need to point to that folder in the Spin1 and Spin2 sections of the the Preferences dialog.

  • JonnyMacJonnyMac Posts: 9,709
    edited 2026-03-04 03:25

    I am trying to develop a term session, and I am having problems with the code snippet.

    Before you get going you have to tell the P2 how fast to run. CLK_FREQ is a [user defined] constant. _clkfreq is the directive that actually sets the P2 speed. In my template I create CLK_FREQ so that I don't have to read the system variable clkfreq, and so I can derive MS_001 and US_001 constants for waitct() used in synchronized delays.

    This is why I gave you a template to start with.

Sign In or Register to comment.