Examples

Here you will find instructions on how to run some of the included demo programs that came with SimpleIDE.  Each demo program is fully self-contained through the use of SimpleIDE's project feature (.side file).  Though we only cover a few examples here, the same process can be used on all included demo programs.  Don't forget to have your Propeller board attached to your computer.

More Examples

You can find more examples in on the PropellerGCC sites download page here.

Hello World Example
The Hello World example is a simple COGC program that can run on any Propeller based board that simply prints "Hello World" and an iteration number every 100 ms.  This example may automatically open the very first time you start SimpleIDE.  If it does not, under the "Project" menu, select "Open Project".  In the "Open Project" menu, navigate to SimpleIDE's demos folder.  Inside the demo folder, navigate into the "hello" folder and open the "hello.side" project file.  When the project is open, you should see a window that looks similar to the screenshot below, though without the red arrows and numbers.

  1. Select your Propeller board type.  Setting this particular option is not required for this example, but it is a good habit to get into to.  Selecting your Propeller board type lets the loader know which board you are using.  If your Propeller board is not listed, selecting the HUB type is a good generic option.
  2. Select the serial port that SimpleIDE should communicate with your Propeller board on.  If you attached your Propeller board to the computer after SimpleIDE was started, you may need to refresh the list.  To do this, click the "Rescan Serial Ports" button immediately to the right of the port selection dropdown menu.  Rescanning the serial ports attached to the computer should refresh the dropdown menu with all available serial ports.
  3. Click the blue "Play" button to compile the program, download it to your Propeller board, and automatically open the serial terminal to view program output.
Once you run the project with the console (click the blue "Play" button), you should see a window with output from your Propeller board appear.  It will look something like this:

  1. When you are done, close the project by click the "Save and Close Project" door icon.

LMM C Toggle Example
The LMM C Toggle example is a program that runs on the Propeller in LMM mode.  The program is a simple demonstration of how to do things on the Propeller that you would commonly do, such as: print to the terminal, control pins, launch a cog to run code independently, and share memory.  Open the project by selecting the "Open Project" option in the "Project" menu.  Navigate to the "toggle" directory in the demos folder and select the "lmm_c_toggle" directory.  Finally, select the "toggle.side" project file.  When the project is open, you should see a window that looks similar to the screenshot below, though without the red arrows and numbers.

  1. Select your Propeller board type.  Setting this particular option is not required for this example, but it is a good habit to get into to.  Selecting your Propeller board type lets the loader know which board you are using.  If your Propeller board is not listed, selecting the HUB type is a good generic option.
  2. Select the serial port that SimpleIDE should communicate with your Propeller board on.  If you attached your Propeller board to the computer after SimpleIDE was started, you may need to refresh the list.  To do this, click the "Rescan Serial Ports" button immediately to the right of the port selection dropdown menu.  Rescanning the serial ports attached to the computer should refresh the dropdown menu with all available serial ports.
  3. Click the blue "Play" button to compile the program, download it to your Propeller board, and automatically open the serial terminal to view program output.
Once you run the project with the console (click the blue "Play" button), you should see a window with output from your Propeller board appear.  It will look something like this:


Note: since there is no delay at the beginning of the program, some computers may miss the Propeller's output to the serial terminal before the serial terminal is open.  To see the output, program the Propeller board's EEPROM, start the terminal, and reset the Propeller board.  This way, the Propeller starts its program from scratch (the Propeller pulls the program from EEPROM) and prints to an already open serial terminal.

If you have LEDs or some other visual indicator wired to pins on the Propeller, you will see that the indicator toggles, increasing in frequency every 2 seconds.  In the code, notice how the main function's loop updates the "wait_time" variable while the do_toggle function's loop, which is running in another cog, uses the "wait_time" variable in its waitcnt command.
  1. When you are done, close the project by click the "Save and Close Project" door icon.

The Next Steps
Many other examples that demonstrate the things you can do with Propeller GCC are included in the demos folder.  Try running a few of them, study the code, and branch out into what C and C++ can offer you, the developer, on the Propeller!
Comments