|
|
Getting started with .NET Micro Framework on the Freescale i.MXS
2007-04-10
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. 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 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:
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:
Next, update the GPIO mapping for the buttons by editing the ButtonPinMap class. The following lines are the code that needs changing:
Change this section of code to read as follows (the italic lines are the added code):
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:
After editing:
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:
![]() 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:
|