Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Polls  |  Forum  |  Directory

Keywords: Match:
Getting started with .NET Micro Framework on the Freescale i.MXS
by Alden Linn (Apr. 10, 2007)

Foreword: In this technical whitepaper, Microsoft .NET Micro Framework team member Alden Linn offers some practical tips for getting started with .NET MF using the i.MXS Development Kit from Freescale. Among the issues addressed are some differences between the actual hardware and the .NET MF emulator.

According to Microsoft, the .NET Micro Framework (.NET MF) is a natural extension of its embedded software product line, bringing the efficiency and reliability of a managed code environment to very small devices with tight constraints on cost, memory, processing resources, and/or power consumption. Additionally, .NET MF's integration with Visual Studio will optimize software development efficiency, by providing PC emulation capabilities and on-device debugging within the Visual Studio IDE. User interface development is supported with Windows Presentation Foundation.



Getting Started with .NET Micro Framework on the Freescale i.MXS

by Alden Linn


The Freescale i.MXS applications processor is a low-cost ARM-based platform for deploying software solutions developed with the Microsoft .NET Micro Framework. To develop applications for i.MXS, you need the i.MXS Development Kit, which is available from Freescale. In particular, the i.MXS USB device driver included in the i.MXS Development Kit must be installed on your computer before you can deploy applications to your i.MXS device. The Development Kit also includes a wealth of other information, including schematics, sample code, and a hardware emulator.

The i.MXS Development Kit is available as a downloadable ZIP file from the Freescale Web site.

You may want to run the samples included with the .NET Micro Framework on the i.MXS hardware to see how they behave and to better understand how to run your own applications on the platform. To do this, you must make some minor changes to the samples.

There are two key differences between the i.MXS hardware and the .NET Micro Framework emulator:
  • The i.MXS buttons are mapped to different General Purpose Input/Output (GPIO) pins than the emulator’s buttons. Thus, the i.MXS buttons will not be recognized when the samples are run.
  • The i.MXS buttons use a different resistor mode than the emulator’s do. This will cause the samples to throw an exception when you press an i.MXS button.
The following section of this article discusses the simple changes you need to make before you can run the Presentation sample solution on the i.MXS Development Kit hardware. For ease of development and testing, you can use conditional compilation so that your solution can be run either on the .NET Micro Framework emulator or on the i.MXS hardware. You can make similar changes to the other .NET Micro Framework samples and to your own code.

The last part of this article explains how to deploy solutions to the i.MXS device for testing. If you have previously deployed software to other platforms by means of USB, you are already familiar with the steps you’ll be using for your i.XMS deployments.

Changing the Code

Start by opening the Presentation sample solution, following these steps:
  1. On the Start menu, point to All Programs.
  2. Point to Microsoft .NET Micro Framework, then click Samples.
  3. Double-click the Presentation folder.
  4. Double-click the Presentation solution icon.
With the Presentation solution open, you can now edit the GPIOButtInputProvider.cs file.

Button Mapping

The i.MXS hardware uses GPIO pins numbered in the 40s for its button interface, whereas the .NET Micro Framework emulator uses pins 0 through 4. An added wrinkle is that the .NET Micro Framework Cpu.Pin enumeration includes only pins 0 through 15, which means that there is no pin named Cpu.Pin.GPIO_Pin40 (pin 40 is the Select button on the i.MXS hardware). Thus, you must represent the i.MXS pin numbers as integers in your C++ code, using the (Cpu.Pin) type casting syntax. In code, then, you would represent the i.MXS Select button as (Cpu.Pin)40.

To address the issue of the mapping between buttons and GPIO pins, first define a symbol to be used for the conditional code section. At the beginning of the file, add the following two lines of code:

// comment out next line when running on the emulator
#define RUN_ON_IMXS_HARDWARE

Next, update the GPIO mapping for the buttons by editing the ButtonPinMap class. The following lines are the code that needs changing:

// associate the buttons to the pins as setup in the emulator/hardware
m_buttonToPin[(Int32)Button.Select] = Cpu.Pin.GPIO_Pin3;
m_buttonToPin[(Int32)Button.Up] = Cpu.Pin.GPIO_Pin2;
m_buttonToPin[(Int32)Button.Down] = Cpu.Pin.GPIO_Pin4;
m_buttonToPin[(Int32)Button.Left] = Cpu.Pin.GPIO_Pin0;
m_buttonToPin[(Int32)Button.Right] = Cpu.Pin.GPIO_Pin1;

Change this section of code to read as follows (the italic lines are the added code):

// associate the buttons to the pins as setup in the emulator/hardware

#if RUN_ON_IMXS_HARDWARE
m_buttonToPin[(Int32)Button.Select] = (Cpu.Pin)40;
m_buttonToPin[(Int32)Button.Up] = (Cpu.Pin)43;
m_buttonToPin[(Int32)Button.Down] = (Cpu.Pin)42;
m_buttonToPin[(Int32)Button.Left] = (Cpu.Pin)48;
m_buttonToPin[(Int32)Button.Right] = (Cpu.Pin)44;
#else

m_buttonToPin[(Int32)Button.Select] = Cpu.Pin.GPIO_Pin3;
m_buttonToPin[(Int32)Button.Up] = Cpu.Pin.GPIO_Pin2;
m_buttonToPin[(Int32)Button.Down] = Cpu.Pin.GPIO_Pin4;
m_buttonToPin[(Int32)Button.Left] = Cpu.Pin.GPIO_Pin0;
m_buttonToPin[(Int32)Button.Right] = Cpu.Pin.GPIO_Pin1;
#endif

Resistor Mode

The sample code uses the PullDown resistor mode. However, the i.MXS reference platform requires the PullUp mode because the hardware does not have pull-down resistors. If you try to use the PullDown mode, an exception occurs when you press any of the i.MXS buttons.

Conveniently, the .NET Micro Framework emulator works correctly with either resistor mode, so you can just change the mode to PullUp. Conditional code is not needed in this case.

In the sample solution, locate the GpioButtonInputProvider constructor, and then change PullDown to PullUp, as shown in the following examples.

Before editing:

InterruptPort port = new InterruptPort(pin, true,
Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);

After editing:

InterruptPort port = new InterruptPort(pin, true,
Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);

These are the only code changes required for the Presentation solution.

Deploying a Solution

Deploying a software solution to the i.MXS hardware is even simpler than making the code changes. First, click Configuration Manager on the Build menu. Then make sure that the check box under Deploy is selected in the Configuration Manager dialog box, as shown in the following illustration.


Now edit the solution’s properties to run it on the i.MXS hardware, following these steps:
  1. On the Build menu, click Presentation Properties.
  2. Click the Micro Framework tab.
  3. Under Deployment, select USB in the Transport box.
  4. In the Device box, select the connected i.MXS device, as shown in the following screen shot.

If there are no i.MXS devices displayed in the Device box after you select USB in the Transport box, this usually means that the USB device driver is not installed on your computer. If you are sure that it is installed, check your USB connections.

Finally, click Deploy Solution on the Build menu to download your code to the i.MXS device.

Conclusion

Developing .NET Micro Framework solutions for the i.MXS platform is much like developing applications for other supported platforms. While some code changes are needed, they are few and minor. Using conditional compilation, you can make one version of the solution that works with both the i.MXS hardware and the .NET Micro Framework emulator. Why not download the i.MXS Development Kit today and try this for yourself?


Copyright (c) 2007 Microsoft Corp. All rights reserved. Reproduced by WindowsForDevices.com with permission. This article was originally published on the author's MSDN blog, here.



About the author: Alden Linn is an engineer on the .NET Micro Framework team at Microsoft and has been involved with the product for over 3 years.



Related stories:

(Click here for further information)


Windows XP for Embedded Applications
This white paper describes the benefits of using Windows XP when developing embedded applications.

A Manager's Guide to Selecting a Mobile Device Operating System
This white paper offers a comparative review of Microsoft Windows CE and Windows Mobile.

Visual Basic 6.0 to .NET Migration
This paper focuses on the methodology and techniques which Infosys (Microsoft Technology Center) has developed for migrating VB 6.0 Applications to .NET. Our approach ensures a smooth, cost effective, and efficient migration.

Mobile Device Security: Securing the Handheld, Securing the Enterprise
This whitepaper identifies security threats to corporate data on mobile devices and details how mobile devices can become a "backdoor" to the enterprise.

Mobile Device Security: The Eight Areas of Risk
It's common knowledge that adding mobile devices to your network increases security risks. There are multiple facets to mobile security, all of which should be paid close attention to. This E-Guide presents a more in depth look into the eight key areas of securing wireless devices.

Quality Assurance and .NET
This paper discusses best practices for functional, regression and load testing of .NET applications.

SCADA Security in Integrated Networks
As businesses leverage their SCADA systems by integrating them into the business networks, they must also assure the security of the SCADA system.

The Advantages of Small Form Factor HMI
HMIs have mutated and changed with new requirements, and they have become more flexible and capable. And while they've been doing that, they've become smaller and more useful.

9 Critical Requirements for Web Application Security
Learn why your Web applications expose dangerous security breaches and what’s required to effectively protect your Web applications and the sensitive information behind them.

 


Got a HOT tip?   please tell us!
Free weekly newsletter
Enter your email...
Click here for a profile of each sponsor:
PLATINUM SPONSORS
(Become a sponsor)

ADVERTISEMENT
(Advertise here)


Updated! The latest Windows-powered...

mobile phones!

other cool
gadgets

HOT TOPICS
Microsoft targets PNDs with new embedded OS
Microsoft tips .NET MF 3.0 highlights
Microsoft previews Windows Embedded Standard
Microsoft offers free Windows CE 6.0 textbook
Microsoft renames embedded operating systems
Microsoft unveils Windows Mobile 6.1
New Atom models target low-cost PCs
REFERENCE GUIDES
Windows Device Showcase
Intro to Windows Embedded
Intro to Shared Source
Real-time Windows Embedded
Windows Embedded books
Join our Windows Embedded discussion forums:
Windows XP Embedded
Windows CE
Windows Mobile


Windows Embedded developer newsgroups
Windows CE
XP Embedded
PocketPC
Smartphone

Microsoft's Windows Embedded resources
Embedded dev center
Mobile dev center
Windows CE tutorials
XP Embedded tutorials
Windows Embedded seminars
Windows Embedded application categories
3rd-party partners


BREAKING NEWS

• Superscalar ARM SoC runs Windows CE
• CE-based nav stack heads for CES
• Windows phone has dual displays
• Cortex-A8 SoC targets netbooks
• Palm "Nova" Linux set for CES debut?
• Editors' retrospective -- Windows-powered Devices in 2008
• Firefox mobile browser alphas released
• Box PC doubles as car computer
• Windows phone has dual active radios
• Windows PMP has dual-core CPU
• COM Express module sports Atom
• "Half-rack" network appliance runs Windows
• Cross-platform NAS runs Windows
• ARM to dominate MIDs?
• Toshiba launches first 512GB SSD


MOST POPULAR (last 90 days)
• "Netbook" uses Intel's Atom N270
• Windows CE takes on Linux in low-end netbooks
• HTC ups Touch resolution
• Microsoft unleashes new embedded OS
• Windows Mobile phone gets 800 x 480 display
• HTC spins WiMAX phone?
• Smart camera sports Atom
• Dual-core AMD netbook gets rave review
• Windows Mobile 7 "delayed"
• GPS phone uses new Marvell "Tavor" chip
MOST POPULAR (Classics from the vault)
Windows XP Embedded USB boot
Troubleshooting Windows XPe's blue screen "Stop 0x0000007B" error
Asus reveals $190 mini notebook
Windows Mobile 6 SDKs available for download
Windows Mobile VPN client plays with Cisco
HTC adds GPS to Windows Mobile Touch line
Microsoft unveils Windows Mobile 6.1
Guide to HTC's Windows Mobile smartphone platforms
• HTC releases Touch Diamond ROM upgrade
Customizing Windows XP Embedded thin clients

Also visit our sister sites:


Sign up for WindowsForDevices.com's...

news feed

Home  |  News  |  Articles  |  Polls  |  Forum  |  Directory  |  About  |  Contact
 

Ziff Davis Enterprise Home | Contact Us | Advertise | Link to Us | Reprints | Magazine Subscriptions | Newsletters
Tech RSS Feeds | White Papers | ROI Calculators | Tech Podcasts | Tech Video | VARs | Channel News

Baseline | Careers | Channel Insider | CIO Insight | DesktopLinux | DeviceForge | DevSource | eSeminars |
eWEEK | Enterprise Network Security | LinuxDevices | Linux Watch | Microsoft Watch | Mid-market | Networking | PDF Zone |
Publish | Security IT Hub | Strategic Partner | Web Buyer's Guide | Windows for Devices

Developer Shed | Dev Shed | ASP Free | Dev Articles | Dev Hardware | SEO Chat | Tutorialized | Scripts |
Code Walkers | Web Hosters | Dev Mechanic | Dev Archives | igrep

Use of this site is governed by our Terms of Service and Privacy Policy. Except where otherwise specified, the contents of this site are copyright © 1999-2008 Ziff Davis Enterprise Holdings Inc. All Rights Reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff Davis Enterprise is prohibited. Windows is a trademark or registered trademark of Microsoft Corporation in the United States and/or other countries and is used by WindowsForDevices under license from owner. All other marks are the property of their respective owners. WindowsForDevices is an independent publication not affiliated with Microsoft Corporation.