Assign a Serial Port as Stdio........................29 8.4.7 Assign a Serial Port as Stderr ........................30 8.4.8 Create a Serial File Pointer ........................30 GENERAL PURPOSE I/O AND THE NETBURNER PIN CLASS..............31 GPIO? ......................32 HICH SED AS ? ......................32...
Page 3
Task Stack Size............................. 40 11.1.2 System Clock Tick..........................40 11.1.3 Maximum Number of Tasks......................... 41 11.1.4 Task Priorities ............................41 11.1.5 Interrupt Driven Serial Ports ........................ 41 11.1.6 Building Applications Without the RTOS ................... 42 NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
The NetBurner Mod5213 development kit (NDK) includes: • A Freescale 5213 microprocessor based module (NetBurner Mod5213) • A development carrier board for the Mod5213 that includes a power regulator, 4 LED’s, reset switch, RS-232 level shifters and DB9 connectors. There are pad locations for optional CAN transceiver and real-time clock.
1.2.1 ColdFire 5213 Processor Block Diagram The NetBurner Mod5213 is based on the Freescale ColdFire 5213 microcontroller. A block diagram of the 5213 is shown below. The signal pins exposed on the Mod5213 come direct from the processor. GPIO UART...
Applying Power to the Mod5213 The Mod5213 has 2 power pins; one is a regulated 3.3VDC input, and the other is a 4.5 – 7.5 VDC input. You can power the Mod5213 using either pin, but do not connect power to both at the same time.
• Select the comm. port, 115,200k baud, and click on the Connect button in MTTTY • Press the reset button on the carrier board and verify you see the Mod5213 boot message in the MTTTY window. An example of the message is shown below.
LED writes. The remaining commands let you experiment with the GPIO functions of the Mod5213. Use the +/- keys to select a pin, then set the pin state to high, low, high impedance (disable drive), enable drive or read the state of the pin as an input.
/****************************************************************************** Mod5213 Factory Demo Program This program will illustrate how to implement multiple RTOS tasks, use the NetBurner Pin Class to control GPIO pins, initialize serial ports, and control the LEDs on the Mod5213 development kit carrier board. *****************************************************************************/ #include "predef.h"...
Page 10
Main Menu -----\r\n"); iprintf(" C to toggle enable/disable LED counting sequence\r\n"); iprintf("Pin Class Commands:\r\n"); iprintf(" +/- to select the Mod5213 pin number\r\n"); iprintf(" H/L to set the selected pin High/Low\r\n"); iprintf(" to set the selected pin to high impediance\r\n");...
Page 11
// Decrement the selected pin number pinn--; if(pinn <4) pinn=38; iprintf("pin# = %d\r\n",pinn); break; case 'C': case 'c': bLedSequenceEnable = !bLedSequenceEnable; if ( bLedSequenceEnable ) iprintf("\r\nLED sequence display enabled\r\n"); else iprintf("\r\nLED sequence display disabled\r\n"); break; NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
Page 12
'R': case 'r': Pins[pinn].function(pinx_GPIO); BOOL b = Pins[pinn]; if(b) iprintf("Pin[%d] = reads Hi\r\n",pinn); else iprintf("Pin[%d] = reads Low\r\n",pinn); break; case 'Z': case 'z': Pins[pinn].function(pinx_GPIO); Pins[pinn].hiz(); iprintf("Pin[%d] = Hiz\r\n",pinn); break; default: DisplayCommandMenu(); NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
Page 13
0, 1, 2. SimpleUart( 0, SystemBaud ); SimpleUart( 1, SystemBaud ); /* Enable NetBurner Smart Traps Utility */ EnableSmartTraps(); When UserMain() starts it is a very high priority. Once running, it is standard practice to reduce it to something lower. MAIN_PRIO is equal to a priority of 50.
Page 14
( 1 ) char c = getchar(); ProcessCommand( c ); NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
RS-232 serial communications. For example, you can run MTTTY and verify that you see the boot message when you press the reset button on the Mod5213 carrier board. To start the MTTTY serial terminal program, select Start -> Programs -> NetBurner NNDK ->...
Page 16
There is a project file already created for this example. In DevC++, click on File -> Open Project or File, and open the file named \nburn\examples\Mod5213\SimpleGPIO.dev. File names that end in .dev are DevC++ project files. Once you open the project, you should see the SimpleGPIO project in the Project Pane on the left as shown below.
Compile & Load command, you should see a quick progress bar as the file is downloaded into the device, then the boot message should appear on MTTTY as the Mod5213 reboots with the new application. One of the LED’s should now be blinking.
( 1 ) // Configure pin 25 as an output and set it to 0. This pin is connected // to a LED on the Mod5213 carrier board, so you can watch it blink. Pins[25] = 0; OSTimeDly( TICKS_PER_SECOND / 2 );...
Depending on your installed platform, a number of options can appear. In the dialog box above, multiple NetBurner platforms are installed, and the default platform supports networking. In our case we will rename the application name to NewApp5213, and change the platform to Mod5213. These changes will result in the dialog box below: NetBurner Mod5213 Programming Guide, Rev.
As you can see, the options are now Mod5213 specific. For this example, let’s just use the SerialLoad capability to enable flash updates through the serial port. Once the option is selected, click on the Create button to create the source code and project. You should now see a project and source window...
Even if you do not intend to use any C++ source code, it is recommended you use the .cpp file extensions to take advantage of the enhanced error and type checking. It will also enable you to use NetBurner APIs that do rely on C++. NetBurner Mod5213 Programming Guide, Rev. 1.0...
#include <utils.h> int n = 0; while ( 1 ) iprintf( “I am a Mod5213!\r\n” ); putleds( n++ ); OSTimeDly( TICKS_PER_SECOND ); Once you have made the changes, select Compile & Load (from the main menu, the icon under the main menu, or by pressing the F9 key).
RTOS or library calls like printf( ), to 40k bytes in applications that use the RTOS, stdio, and library calls like iprintf( ). Since the Mod5213 has 256k bytes of flash space, you have plenty of room! Typical SRAM usage can range from 1.5k bytes to 8k bytes for a full featured application with interrupt driven serial I/O with associated memory buffers.
7 How Serial Flash Downloads Work The serial flash download to the Mod5213 is a very useful tool. To enable this capability, your application must include the header file #include <SerialUpdate.h>, and call the function EnableSerialUpdate( ). The NetBurner application code will listen on all serial ports for incoming updates, and process the update if the proper command sequence is sent.
8 Polled and Interrupt Driven Serial Port Drivers Polled vs. Interrupt Driven The NetBurner API provides two types of serial interfaces for the Mod5213 onboard UARTs: polled and interrupt driven. You can switch between either mode easily just by changing an include file in your application;...
Page 26
SimpleUart( 0, SystemBaud ); assign_stdio( 0 ); iprintf( "Application started\r\n" ); while ( 1 ) if ( charavail( 0 ) ) // check for I/O on UART 0 char c = getchar(); OSTimeDly( TICKS_PER_SECOND ); NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
Compile or Compile & Load. The NetBurner Serial API The following sections describe the NetBurner Serial API calls. All these functions can be run in polled or interrupt driven mode by changing the include file as described earlier in this chapter. Each API call has the underlying polled and interrupt driven functions defined.
Interrupt version: Calls IRQ_getchar( ). Important: The polled version does not yield to the RTOS, so no lower priority task can run. The IRQ version will yield to the RTOS until a char is available. NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
This function will enable you to use stdio calls with the specified serial port, such as iprintf( ), printf( ), iscanf( ) and scanf( ). Polled version: Calls Polled_assign_stdio( ). Interrupt version: Calls IRQ_assign_stdio( ). NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
9 General Purpose I/O and the NetBurner Pin Class The pins on the two 20 pin headers on the Mod5213 consist mostly of signal pins that can be set to a special function or GPIO, two power pins and a ground pin. Each signal pin can be set to a special function or GPIO.
Note the descriptions in each of the fields above. They represent the actual definitions that can be used to configure each pin if you choose to use the NetBurner Pin Class. These definitions are located in the header file: \nburn\Mod5213\include\pinconstants.h.
( 1 ) // Configure pin 25 as an output and set it to 0. This pin is connected // to a LED on the Mod5213 carrier board, so you can watch it blink. Pins[25] = 0; OSTimeDly( TICKS_PER_SECOND / 2 );...
10 Analog to Digital Functions 10.1 Mod5213 A/D Capabilities The Mod5213 has two separate 12-bit A/D converters, each with their own sample and hold circuit. Each converter has 4 multiplexed analog inputs, providing 8 channels of analog input. The ColdFire 5213 processor on-board A/D features include: •...
A/D voltage reference low and voltage power ground. The A/D on the Mod5213 has its own power and ground connections, as well as a separate A/D voltage reference input in case you want to use a precision voltage reference. The Mod5213 development kit carrier board has two jumpers that can be used for development purposes: Connect VDDA to 3.3VDC...
10.6 A/D Example The Mod5213 A/D example is located in \nburn\examples\Mod5213\a2d. When you run the example you can view the A/D readings via the serial port and MTTTY. A MTTTY screen shot is shown below: NetBurner Mod5213 Programming Guide, Rev. 1.0...
"Hit any key to display A2D readings\r\n" ); char c = sgetchar( 0 ); // direct call to serial driver, not stdio for ( int i = 0; i < 8; i++ ) NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
11 NetBurner uC/OS RTOS The uC/OS is a very stable, fast and reliable operating system. The NetBurner implementation takes up very memory, and it can make applications much easier to code and maintain. In most cases applications will simply create a few tasks and pass messages between tasks, as in the factory demo program.
11.1.5 Interrupt Driven Serial Ports The interrupt driven serial port drivers use the RTOS. Interrupts on the Mod5213 are beyond the scope of this document. Basically you can have interrupt requests numbered from 0 – 7, and interrupt priority levels from 0 – 7 for each interrupt request. The serial port interrupt driver uses interrupt request level 3 for all three UARTs, with priorities set to 1 for UART 0 , 2 for UART 1 and 3 for UART 2.
RTOS. int main() SimpleUart( 0, 115200 ); EnableSerialUpdate(); writestring(0, "This application does not use the RTOS\r\n"); while(1); NetBurner Mod5213 Programming Guide, Rev. 1.0 Page...
Need help?
Do you have a question about the Mod5213 and is the answer not in the manual?
Questions and answers