User Tools

Site Tools




MOACON Studio is the integrated development environment software needed to develop for the MOACON. It can be downloaded from the Comfile Technology website at

MOACON Studio features a C compiler, source editor, RS-232 communication, USB downloading and debugging, and more. The source editor features syntax highlighting, command completion, and context sensitive help making learning, developing, and testing MOACON software projects a truly productive and enjoyable experience.

By just clicking the “Run” ()icon MOACON Studio compiles and downloads the current MOACON project to the CPU module where it begins executing immediately.

Once downloaded, the MOACON can be disconnected from the PC and the MOACON will execute the compiled code as a standalone program. The program will be retained in the CPU module's flash memory even if the MOACON is powered off.

When powered back on, the MOACON will immediately begin executing the downloaded program. A new program can be downloaded from MOACON Studio at any time, replacing any existing program in the CPU module's flash memory.

MOACON Studio feature

MOACON Studio is the integrated software development environment used to program the MOACON. The image below describes the main window.

1. Source Editor – Text editor for source code.
2. Project View – Displays a list of all files in the current project.
3. Help Window – Shows command syntax and other documentation as you type in the source editor.
4. Debug Terminal – Output window for debugging messages.
5. Output Window – Shows compiler messages, download messages, and more.

Creating a Project

To create a project in MOACON Studio, choose “Project” > “New Project…” from the main menu.

From the “New Project” dialog that appears, create or browse to an empty folder. The folder's name will become the project's name. When the project is created a [ProjectName].csp file will be created in this folder; this is the MOACON Studio project file. In the example above, a file named MyProject.csp will be created in the folder “C:\Moacon Studio\Projects\MyProject”.

After creating a new project, the project will open in MOACON Studio and create a default [ProjectName].c file. In the example above, for project “MyProject” a default MyProject.c file was created.

1. Project Root – The root of the project. Source files will appear as children of this root.

2. Default .c File – The default source file. New source files can be created and added to the project.The source files do not have to reside in the project folder.

3. Open File Tabs – Any file open for editing will appear as a tab in the Source Editor Window.

#include "moacon500.h"       //Device Declaration
void cmain(void)             //Program's Entry Point

The #include “moacon500.h” statement is a device declaration statement used to include code that is specific to the model of the CPU module – in this case the DP-CPU500. It should be included at the top of the main source file.

cmain is the program's entry point (i.e. the first function the program calls when it is executed). Note that in most C programs, the program's entry point is usually called main, but for the MOACON, it is cmain.

Compiling and Executing a Project

In this section we will create a very simple MOACON project, download it to the MOACON, and execute it. The famous “Hello World” program will be used to illustrate the procedure.

1. Create a new project called “HelloWorld”.

#include "moacon500.h"
void cmain(void)
   //Repeat Forever
      //Print "Hello World" to the debug console
      printf("Hello World\r\n");

2. Enter the code above in the HelloWorld.c source file. The while(1) code block will execute forever without exiting. The printf statement will print “Hello World” to the Debug Terminal. The carriage return (\r) and new line (\n) will ensure each “Hello Word” gets printed on a new line.

3. With the MOACON powered on, and connected to the PC via USB, click the “Run” icon ( ).

4. MOACON Studio will compile the program and download it to the MOACON.

5. The MOACON will begin executing the program immediately.Output from the programs printf statement will be displayed in the Debug Terminal.

Note that the program is not running on the PC, it is running on the MOACON. If you disconnect the MOACON from the PC, there will be no output in the Debug Terminal.

Compiler Errors

Often during development, syntax errors and other errors can prevent a program from being compiled.

#include "moacon500.h"
void cmain(void)
   //Repeat Forever
      //Print "Hello World" to the debug console
      printf("Hello World\r\n") //ERROR: No semicolon

For example, in the source above, there is no semicolon after the printf statement. This is a syntax error in C.

When the compiler encounters such an error, a message will be displayed in the output window. You can double-click the message in the output window, and the source editor will scroll to the line with the error.

Adding Source Files to a Project

A project can contain many source files, and may be necessary to keep a large project organized. Follow the procedure below to add source files to a project.

1. Choose “File” > “New File” from the menu. A new source file called “Textx” will appear in the source editor.

2. Enter some code.

3. Save the file (“File” > “Save File”), and give it a new name.

4. The file has now been saved, but is not yet part of the project. Choose “Project” > “Add Files To Project” from the menu.

5. Browse to the file to add, and click the “Open” button.

6. The new file will then appear in the Project View window. At this point, if you compile the project, all source files will be compiled.

7. Choose “Project” > “Save Project” from the menu to save your changes to the current project.

moacon/moacon_studio.txt · Last modified: 2016/04/14 11:03 (external edit)