ECN Asia
  Mark as your homepage Bookmark us Print Subscription
               
Saturday, August 30, 2008
Home About Us Current Issue Archive RSS Free Subscription Trade Shows Media Kit Contact Us

Boards & Modules

Computers, Peripherals & Networking Devices

Digital Den

Electromechanical/Mechanical Devices

Embedded Systems & Networking

Integrated Circuits & Semiconductors

Microwave & RF Components

Optoelectronics & Displays

Packaging & Interconnects

Passive & Discrete Components

Power Sources & Conditioning Devices

Sensors & Actuators

Software

Test & Measurement

Search:
 
  Advanced Search
Product Info Search:
 
     
 
 
 
Issue > Jan 2008 > Cover Story
 
 
Ads by Google
 

Dot NET development for the rest of us


( 01 Jan 2008 )

by John Leier, Digi International

On a recent flight I talked with a software-engineering manager about the challenges of finding good embedded-system developers. She told me she has a team of 12 developers, but only three had proficiency with drivers, board-support packages, and boot-loaders. The other nine – all good application developers – lacked low-level coding experience. I asked if she had heard of the Microsoft .NET Micro Framework.



Microsoft’s .NET Micro Framework, in combination with the C# language and Microsoft’s Visual Studio tools, gives engineers and programmers more options for their embedded-system designs. A product team can reduce its design time because engineers no longer implement a boot-loader, drivers, or other low-level code. The .NET Micro Framework lets engineers who are new to embedded-system design jump right into coding without the need for special tools and a detailed understanding of processor and operating-system architectures.

The .NET Micro Framework has its roots at Microsoft Research where computer scientists aimed to simplify the development of small, low-power designs. They believed future electronic devices would use 32-bit processors, batteries, networks, and new protocols, such as Z-Wave and ZigBee. To design the growing number of networked embedded devices, the pool of developers – and their productivity – would have to increase dramatically.



The team wrote the .NET Micro Framework from scratch to address these concerns. The framework is not a cut-down version of older software or tools. Unlike Windows Embedded CE and other embedded operating systems, the .NET Micro Framework does not require a memory-management unit (MMU), so developers can use it on low-power and lower cost ARM7 processors, as well as ARM9, and Blackfin processors. The framework software requires only several hundred kbytes of RAM and flash/ROM. By comparison, a managed-code “environment” for Embedded CE needs about 10MB to 12MB. The smaller amount of memory required for a device that relies on the .NET application programming interfaces (APIs) leads to a lower-cost product.



The .NET Micro Framework provides a C# managed-code environment for application programming. I find the C# language easy to learn and use, and it can raise productivity above that available from C or C++ programmers. A managed-code environment means developers do not have to track down memory overwrites and mishandled pointers because these problems do not exist. However, garbage collection within C# code takes place in a non-deterministic fashion, so the developer cannot create real-time applications to run within the .NET Micro Framework.



Microsoft has integrated the .NET Micro Framework into its Visual Studio 2005 package, so programmers familiar with this software can quickly start on a project. In February 2007, Microsoft released Version 2 of the .NET Micro Framework for general embedded-application development. Digi International, Freescale, Embedded Fusion, and other companies offer hardware compatible with .NET Micro Framework, so developers can get a quick start with useful designs.



Microsoft first used the .NET Micro Framework in its Smart Personal Object Technology (SPOT) wristwatches. These watches – based on an ARM7TDMI processor – receive updates of news, sports, weather, and traffic on an FM sub-carrier signal. The SPOT-watch project provided a realistic test for the .NET Micro Framework, and it helped Microsoft’s researchers improve the framework software.



The architecture of the .NET Micro Framework comprises several pieces (Figure 1). A look at the layers from the top down shows what the framework provides for developers. Although the stack has many layers, developers find Microsoft’s .NET Micro Framework easy to learn and use. At the top of the stack, the developer or user application and libraries can be found. Typically, embedded-system developers write programs that interact with the framework only at this level.



The .NET Micro Framework offers only a subset of features available in Microsoft’s larger .NET Framework for standard desktop-PC and server applications. But the subset implements the functionality most applicable to embedded devices. This approach lets developers use existing code when practical, and it avoids the need for a larger base of embedded .NET Micro Framework code.



The Class Library Layer, often referred to as simply “libraries,” contains .NET and Windows Presentation Foundation (WPF) libraries. The class library included with the .NET Micro Framework supplies an object-oriented collection of reusable classes you can use to develop embedded applications. The C# libraries include, among others, capabilities for encryption, graphics, and access to SPI and I2C communication ports.



The Common Language Runtime (CLR) within the .NET Micro Framework provides the run-time environment needed by all application programs. The CLR manages memory, threading, code execution, garbage and exception handling, and other services. According to Microsoft, the CLR can perform approximately 15,000 calls/sec to managed methods in code written for an ARM7 processor with a 27.6MHz clock frequency.



The next lower level provides a Program Abstraction Layer (PAL) that can control hardware, but that operates independent of hardware in an embedded system. The PAL provides a defined middle layer between the managed code interfaces and the hardware-specific code. At the lowest level, directly above the processor and peripherals, the framework provides a Hardware Abstraction Layer (HAL) or provisions for a compatible operating system. Thus, the framework can communicate directly with the underlying hardware or it can serve as a host to an operating system, perhaps a real-time operating system (RTOS), which provides hardware services and extensions to the .NET Micro Framework. This could let an application run real-time tasks in an RTOS thread, while it runs the entire .NET Micro Framework in a separate thread of the RTOS.



Hardware vendors such as Digi and Freescale supply the lower-level drivers and CLR implemented in C++. Developers’ write application code in C# and link their code to the .NET Micro Framework “bootable” runtime. Because the framework provides a subset of the capabilities found in a complete operating system (OS), the framework does not require an overarching OS to manage an embedded system. Thus, developers refer to the .NET Micro Framework itself as a “bootable” runtime. In this case, bootable runtime refers to the .NET Micro Framework code that runs directly on the embedded hardware. That code provides boot-up support, interrupt handling, threading and process management, heap management, and other support functions that an OS would usually provide.1



A built-in hardware emulator for .NET Micro Framework offers developers a big advantage over other development tools. A hardware emulator lets a software team start to develop code right away, rather than wait until they have designed, built, and debugged prototype hardware. Users and vendors can use XML to extend the default emulator, so developers can create and debug an application without touching any hardware. Hardware vendors also can provide custom emulators that emulate their hardware, module, or processor. Of course, a large part of the fun is actually seeing an application run on real hardware.



GET TO WORKING CODE QUICKLY

The Connect ME module provides an example of a device you can program with the .NET Micro Framework. This embedded serial-to-Ethernet module includes an ARM7TDMI processor (55MHz), 2MB of NOR Flash, 8MB of SDRAM, and an Ethernet PHY/MAC in a compact RJ-45 connector package (Figure 2).



A host operating system, based on the Express Logic ThreadX embedded kernel supports the .NET Micro Framework in the module. The kernel includes a complete IPv4 network stack available to application code as a sockets interface.



Applications written for the .NET Micro Framework have access to all of the hardware-independent APIs, as well as to the hardware classes that the HAL supports. The HAL for a Connect ME module supports TCP/IP sockets, RS-232 serial communication, and general-purpose I/O ports.



TRY THIS AT HOME

Developers need only three steps to create and run an application that reads and writes to the general-purpose I/O ports. The steps that follow assume an Ethernet programming connection between a host development PC and the Connect ME module. In most cases, developers would use a Digi Connect ME Digi JumpStart Kit or similar baseboard for the Connect ME module:



Step 1. Double-click on Program.cs, the main module in the newly created project. Inside the C# Main() function, add the following lines:



InputPort MyInput = new

InputPort((Cpu.Pin)0,false,InputPort.ResistorMode.Disabled);



OutputPort MyOutput = new OutputPort((Cpu.Pin)1,false);



Within Visual Studio 2005, the Online help information for the InputPort class describes all the parameters. The first parameter – (Cpu.Pin)0 – specifies the first general-purpose I/O pin on the Connect ME module. As implemented by Microsoft, the second parameter – false – calls a glitch filter that can smooth spikes on input state changes. The Connect ME module does not use this parameter in its HAL and it will ignore any passed value. The last parameter – InputPort.ResistorMode.Disabled – lets the HAL configure inputs for one of three resistor modes; PullUp, PullDown, or Disabled. The Connect ME module also ignores this value, although the code example specifies Disabled.



The constructor for the OutputPort class only has two parameters: The GPIO pin to use – (Cpu.Pin)1 – and the initial state – false – for that output pin.



Step 2. To have the Connect ME module read the state of the input pin, simply assign it to a Boolean type.



bool InputState = MyInput.Read();



To write to the output, use the Write() method:



MyOutput.Write(true);



Step 3. To compile and deploy the application, select click on the "Start Debugging" button. The host PC will send your code to the flash memory on the Connect ME module via the Ethernet connection. Then the module will start your code from SDRAM. Debug output from your program comes from the module itself over an Ethernet debug connection to the Visual Studio Debug Output window.



The example shown illustrates all that is necessary to do to write, compile, deploy and debug a simple application that runs the .NET Micro Framework on an embedded target and manipulates GPIO pins. The .NET Micro Framework also offers an InterruptPort class, but the Connect ME module does not support this class through its I/O pins. Other hardware may provide an interrupt-input pin that the programmer can access through the InterruptPort class.



Similar classes, methods, and properties let developers easily control serial I/O ports and create socket servers and clients. The help documents within Visual Studio 2005 describe how to use commands so that even people without much C# experience can use them in an application.



To better understand how to apply the .NET Micro Framework, developers can use its emulator model at no charge, by downloading both the .NET Micro Framework Software Development Kit (SDK) and an evaluation version of Visual Studio 2005 from Microsoft. They also can purchase a development package such as the Digi Connect ME JumpStart kit (part number DC-ME-MF).



Reference

1 Thompson, Daniel and Colin Miller, “Microsoft’s .NET Micro Framework: Product Positioning and Technology Whitepaper:” http://download.microsoft.com/download/3/1/9/319f7469-70bd-4e7c-a6cc-e5ad96939af4/NET_Micro_Framework_Whitepaper_V_1.0.doc



For further reading

• Microsoft's .NET Micro Framework homepage: msdn.microsoft.com/embedded/netmf

• .NET Micro Framework SDK download - www.microsoft.com/downloads/details.aspx?familyid=32f5df20-6c95-4fe8-a76c-0ed56a839ad2&displaylang=en

• Trial versions of Visual Studio 2005 (The .NET Micro Framework requires the Standard, Professional, or Team version and will not work with Visual Studio Express.) www.microsoft.com/emea/msdn/visualstudio/enxu/getthetrials/

• For a list of Microsoft’s .NET Micro Framework Partners:

msdn2.microsoft.com/en-us/embedded/bb267307.aspx

• Digi Connect ME: www.digiembedded.com



About the author

John Leier is product manager of embedded software at Digi International. He has more than 15 years of software-engineering experience that include programming data-acquisition and control systems in C, Visual Basic, Delphi, and C#. For more information, contact Digi International, 11001 Bren Road East, Minnetonka, MN 55343; (877) 912-3444; www.digi.com.

Click here for Illustrations:



Figure 1, Figure 2, Figure 3, Figure 4, Figure 5



 

 
 
 
ADVERTISEMENT
 
 
 
Ads by Google
 
OUR SPONSOR
   
   
 
 
 
   
   
     
 
 
         
     
 
Related Articles
   
DVB cores for low-cost FPGA
Single-chip laser navigation system simplify mouse design, manufacturing
Has optical technology’s 13-year victory over Moore’s Law come to an end?
Low power platform meets next-generation multimedia apps
Ethernet switch enables auto-sensing
Development tool for 8- and 32-bit microcontrollers
Audio processor for mobile phones
SPICE-simulation tool suite features enhanced PWL
Tool kit for innovative SoC designs
Design suite offers breakthrough improvements in productivity
   
 
Business News
   
HP Completes $13.9bn Acquisition of EDS
FCI Develops Flip-Type ZIF Connector
Cable Configuration Design Tool
Magnetic Cylinder Sensor has Two Programmable Switching Points
CA Releases Wily Manager for CA SiteMinder
TDI opens new facility in China
Intersil Promotes Kent Chon to Vice President of Asia Pacific Sales
OTCS celebrates 10th anniversary in Singapore
Xbox 360 Teardown Highlights IBM’s Dominance in Next-Generation Consoles
NAND Continues to Set Records
   
  More News >>
 
     
     
 
         
 
 
     
         
 
spacer
Country Report
spacer
   
bullet

TAIWAN: Inductor technologies are developed independently

bullet

KOREA: Inductor manufacturers are highly competitive, but scarce

bullet

CHINA: World’s high-volume producer of transformer, coil and inductor

bullet

TAIWAN: Moderate but steady growth in LED market

bullet

KOREA: LED has a bright future in our homes

  more on country report >>
   
 
spacer
Our Sponsor
spacer
   
bullet
 
   
 
     
 
     
 
spacer
Features
spacer
   
bullet

DDR memories: Comparison and overview

bullet

Miniaturization in synchronous buck DC/DC applications employing DrMOS

bullet

SoC microcontrollers power portable medical device innovation

bullet

Part three: ESD protection

bullet

Switching power supplies go green

  more on features >>
   
 
Distribution
   

Value addition is the key in distribution

Distributors supply solutions, not just parts

Taiwan distributors compete by bolstering in-house R&D

“Nature of distribution is changing”

Top supply chain predictions in Asia Pacific for 2008

  more on distribution >>
   
 
     
         
 
 
     
         
 
Industry Focus
   

Ethernet adoption encourages open protocols

Managing Bluetooth profiles: A billion served

Enabling a true wireless multimedia home network

Bluetooth paves the way for truly wireless car interiors

Eliminating massive clock trees in SoC designs using GALS

  more on industry focus >>
   
 
Web Exclusives
   

Power-management solutions for telecom systems improve performance, cost, and size

Changing the network security playing field

WiMAX “personality pack” provides complete IEEE802.16 functionality

LED: A tiny light source with a bright future

SSDs: Carving a Niche in the Consumer and Enterprise Markets

  more on web exclusives >>
   
 
     
     
   
     
 
Semiconductors
   

Simulating the effect of blockers on data converter performance in wideband receivers

Decrease processor power consumption using a CPLD

Taking full advantage of new, low-power MCUs

Power train integration for 2007 and beyond: The true dawn of multi-chip modules

Wireless network options for industrial applications

  more on semiconductors >>
   
 
Field Applications
   

Test Equipment

Power Sources/Circuit Protection

Advanced Signal Processing Dramatically Improves Capability of Artificial Limbs

Voice Interface Technology for Hands-free Function in Automobiles

LXI: A Technology Leap for Test Instrumentation

  more on field applications >>
   
 
     
     
   
     
     
 
INDUSTRY LINKS
   
Photonics Association (Singapore)
bullet Singapore Industrial Automation Association (SIAA)