Netburner Tutorial 2:

Using the GPIO Pins on the MOD5213

Keywords: Embedded Netburner Kit, Freescale DSP

                                                                                              *Photo taken from theNetburner Website (

The photo is the Netburner Development kit, which allows you to experiment with the Freescale Digital Signal Processor (DSP) and embedded DSP's in robotics applications. The big picture problem is finding a digital signal processor capable of taking on processor intensive tasks for unmanned aerial vehicles and humanoid robotics. Solving this partially or completely is important because these tutorials will explore the different architectures of DSP's, along with their capabilities. This tutorial shows you how to get started with embedded Netburner Development Kit, by creating a new project file, and using the pins for a general purpose use. It takes roughly one hour to complete.

Motivation and Audience

This tutorial's motivation is to explore the DSP architecture, and creating project files in the IDE. Readers of this tutorial assumes the reader has the following background and interests:

The rest of the tutorial is presented as follows:

Parts List and Sources

US-based vendors to obtain material to complete this tutorial is the Embedded Netburner Development Kit (the MOD5213), found here.

To complete this tutorial, you'll need the following items:

TABLE 1: Parts needed to build (fill in the blank)
Netburner Development Kit Netburner Inc.MOD5213 $99.001
USB to Serial Adapter*--------$10 and up 1 

 *If your computer does not have a 9 pin RS-232 Serial port, you will need to purchase a USB Adapter. They can be found almost anywhere on the internet, or in a computer store near you.


This section gives step-by-step instructions along with photos to get started with the Netburner kit by setting up the project for blinking an LED on the Demo Board using the IO PIN definition.


Building your first Netburner Project

    To start programming the Embedded Netburner MOD5213, open the Netburner EclipseŽ IDE by navigating to Start > Programs > Netburner NNDK > NBEclipse > and clicking on the NBEclipse Icon.  This will start the IDE.  Once the IDE is opened, go to File > New > and click the Project icon to make a new project.  The IDE will then open a window to select different projects with different configurations settings. 

    Once the AppWizard Windows opens up, navigate in the tree to Netburner > and highlight the managed Netburner Project (recommended).  This is recommended by Netburner, and myself, in that, when the main.cpp file (the main program source file) is saved, The IDE will automatically compile the project, and make it ready to be downloaded to the chip. Once the Managed Netburner Project is highlighted, click the Next button. 

    The next window will Prompt you for a project name, enter in PinIO_Class as the project name, as this project will be working with programming a pin as a GPIO (General Purpose IO Pin). 

    After the Project name is entered, select the default folder location check box.  This will make the default location for this project (any any other projects) under he directory C:\NBurn\NBEclipse\workspace.  Click the next button.  For the "Select Type of Project" window, click the next button.  There is nothing that has to be configured here.  The next window to be displayed is "Additional Project Settings" window.  There is also nothing that has to be configured here, so click the Next button.

    The next window will prompt for a project type.  Use the down arrow in the selection window to select "Netburner Device Executable - Non-Network Platform". Click the "Next" button.

    The final window displayed in the AppWizard window is the "Netburner Project Options" window.  In the drop-down menu, scroll down and click on the MOD5213 as the default platform.  You will see some of the check boxes in the lower half of the window unshade (they can now be clicked on and accessed), and click on the box to check "Serial Load".  This will allow loading the compiled program through the serial port. 

    Once the MOD5213 is selected as the target platform, and Serial Load is enabled, click the "Finish" button.  If you get a dialog error regarding building the project directory, just accept the change, and update the database.


Creating Your First Program in the Netburner IDE

    Once the project directory is built using the Netburner IDE, in the C/C++ Projects Tree window, navigate to the main.cpp file.  This is located under PinIO_Class > main.cpp.  Double Click on main.cpp.  As you can see, the Netburner IDE automatically builds most of the header files, although, not all of them. Click Here for my main.cpp code to see the code to blink the LED.  Notice that a line is included:

    #include <pins.h>  This include line takes advantage of the Pin Definition that was installed with the Netburner IDE.  This makes declaring the pins and setting the respective registers easier than competing DSP's.

Also, make a note that the RTOS, or Real-Time Operating System is already set up; all the user has to do is write the custom code inside the while(1) loop inside the UserMain function.

This demo code makes use of the RTOS, blinking an LED, and the Serial Debug window.  Once your code looks like the main.cpp file supplied here, save your main.cpp file by pressing [Control] [S] on the keyboard.  The Netburner IDE will then compile the main.cpp file into a .S19 file that the Freescale processor can interpret.  Open the Serial Debug Terminal using the MTTTY Icon in the IDE to launch the MTTTY Serial Debug Window.  Select the proper COM Port you are connected to, and click the connect button.  Back in the IDE, click the Run button, and switch back to the Serial Debug Window.  You should now see the Chip rebooted, and running the new code, debugging the state of the LED.   


The source code to to blink the LED is provided below:

To be compiled with the Netburner Eclipse IDE

    Note: This is only the main.cpp program, this does not include all of the necessary include files to compile for the PINIO_Class project. To get a copy of the main.cpp program, click here.

#include "predef.h"
#include <stdio.h>
#include <ctype.h>
#include <basictypes.h>
#include <serialirq.h>
#include <system.h>
#include <constants.h>
#include <ucos.h>
#include <SerialUpdate.h>
#include <pinconstant.h>
#include <pins.h> //------------------------> Add this .h file in the future to take advantage 
// of the Pin definition instead of writing the 
// registers manually.
extern "C" {
void UserMain(void * pd);

const char * AppName="PinIO_Class";

void UserMain(void * pd) {

	SimpleUart(0,SystemBaud); 		// Enable Serial port 0 at the system baudrate, 115,200 baud
	assign_stdio(0); 			// Assign the standard serial port to port 0
	OSChangePrio(MAIN_PRIO); 		// Set the User Main loop to a priority of 50 in the RTOS
	EnableSerialUpdate(); 			// Enable Serial Update via the "Run" Button in the IDE
	Pins[25].function( PIN25_GPIO ); 	// Set the function of Pin 25 to be a general purpose IO
	// This function call makes use of the pins.h include file in the beginning of the main.cpp code above.
	iprintf("Application started...\n");

	while (1) { 				// Loop indefinitely, 1 is always true.
		OSTimeDly( 1 * TICKS_PER_SECOND ); 	// Delay 1 second on the RTOS
		Pins[25].set(); 			// Set Pin 25 high using the pins.h function
		iprintf("\nLED ON... "); 		// Print a debug statement to indicate LED status
		OSTimeDly( 1 * TICKS_PER_SECOND ); 	// Delay 1 second on the RTOS
		Pins[25].clr(); 			// Clear Pin 25 using the pin.h function (sets pin 25 low
		iprintf("LED Off..."); 			// Print a debug statement to indicate LED status

Final Words

This tutorial's objective was to get acquainted with the Embedded Netburner Development kit and the Netburner Eclipse IDE by creating a project and blinking an LED on the Development Board, and programming a pin as a GPIO (General Purpose IO Pin) using the Netbburner pin class. 

Speculating future work, derived from this tutorial, includes more tutorials on programming with the chip using PWM, ADC, and serial communications to sensors.

Click here to email me