EMX – SD card reader June 2, 2010Posted by wesaday in Programming.
Tags: EMX, GHIElectronics
This is the first real use that I came up with for the EMX board and it would appear that many people have questions regarding the SD card reader capability of the EMX. An SD card would be a quick and easy way to increase the available memory for this primarily embedded system. You might need to save or read text files or log your application to help debug it, updating your application in the field, or other uses.
Create a new project in Visual Studio 2008. Use the Visual C#->Micro Framework->Window Application project template, give the project a meaningful name and click OK. One thing that I do not like about the template is that the Program.cs file contains the Main method and the window definition. I prefer to separate the functionality but if you want to leave it alone feel free. The only thing that you really need in your Main method is:
Program myApplication = new Program();// Start the application
I delete the rest of the stuff. Now to the MainWindow. I add a new class called MainWindow to the project. The MainWindow must inherit from Window. Add these using statements:
private PersistentStorage _sdcard;
private InterruptPort _sdDetect = new InterruptPort(GHIElectronics.NETMF.Hardware.EMX.Pin.IO36, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
Width = SystemMetrics.ScreenWidth;
Height = SystemMetrics.ScreenHeight;
Background = new SolidColorBrush(0x000000);
_sdDetect.OnInterrupt += OnSdInterrupt;
private void OnSdInterrupt(uint data1, uint data2, DateTime time)
if (data2 == 0)
_sdcard = new PersistentStorage("SD");
if (_sdcard != null)
private void GetFiles()
string files = Directory.GetFiles(VolumeInfo.GetVolumes().RootDirectory);
foreach (string s in files)
EMX – Hello world May 23, 2010Posted by wesaday in Programming.
Tags: EMX, GHIElectronics
Today we will explore the ever popular “Hello world” using the .NET Micro Framework and see it running in the Emulator. Since the Micro Framework is targeted for embedded systems, there is very limited support for controls. What support there is, is based on WPF but there are some differences.
When you install the Micro Framwork SDK it installs some new project templates into Visual Studio. We are going to use these templates to base our program on because creating a project from scratch in the Micro Framework is a bit of a pain. Fire up Visual Studio and create a new project using the Micro Framework Window Application template. In truth, it probably doesn’t matter if you choose the Console or Window template since we are going to delete everything and build it up step by step.
Click Ok and let the project get created. You should wind up with something like this:
The template files are all well and good but you should know exactly what the template contains and what it does. Select the Resources folder, GPIOButtonInputProvider.cs, Program,cs and Resources.resx file and delete them. That should pretty much wipe out everything, except for the references. Right click the project in the solution explorer, select Add and then click Class. Name the class Program and click Ok. This class is going to be the startup class. Add a public static Main method that returns void to the Program class and have Program derive from Application. Then add the following lines to the Main method:
Nothing to it right? The first line instantiates the Program class. The second line instantiates the MainWindow. The third line tells the program to run using win as the main window. The entire program class looks like this :
Now we need to add another class that will be our main window. Add a new class to the solution and call it MainWindow. MainWindow needs to derive from the Window class. Window is contained within the Microsoft.SPOT.Presentation namespace so add that using statement to the top of the file. Add a constructor for MainWindow and add these lines to it:
The first two lines setup the window width and height. The third line sets the background color to blue. Note that the hex values for color are backwards from RGB. The hex values are BGR.
Lines 5 – 10 are an intializer for the Text class. Text is the equivalent of a Label in Winforms or TextBlock in WPF. I guess if they named it same as in WPF then there wouldn’t be anything new to learn….
The Font for Text is set by getting the font from the resources. TextContent is the Text property. Then the horizontal and vertical alignments are set. In this case we are setting the text to be centered in the screen.
The last thing that we need to do is to add a Resource file to contain the font that we are going to be using. Right click the Project, select Add and then click New Item. Then select the Resources File to add. Once the file is created, click the Add Resource drop down and select Add Existing File. Browse to the .NET Micro Framework installation directory, default location is C:\Program Files\Microsoft >NET Micro Framework\v4.0. Open up the Fonts folder and select the small.tinyfnt file and click Ok. The default installation of the Framework only comes with two fonts. You solution should now look like this: You should be able to build your solution now.
Almost done. Now you want to see the result of all that work right? Remember this is for embedded systems. So what if you don’t have an embedded system to run it on? Or you have your system on order but have not go it yet? The Micro Framework comes with an emulator that you can use to run your program in. Click the Project menu item and select Properties. Select the .NET Micro Framework tab. On that page you will see a combo box labeled “Transport”. This is where you would select where to run your program. If you have Emulator already selected then you are good to go. Press F5 to start your program. Visual Studio will build and “deploy” the program to the emulator. And the final outcome should look like this:
EMX – updating the firmware May 12, 2010Posted by wesaday in Programming.
Tags: EMX, GHIElectronics
Working working with embedded systems may occasionally require you to update the firmware the runs the system. EMX takes advantage of the Midcrosoft Micro Framework .NET and being relatively new, the code tends to change fairly rapidly. When GHI Electronics distributes a new version of their SDK, you will probably want to update your system board to take advantage of bug fixes and new features.
Plug the EMX into an available USB port on your computer. The New Hardware Wizard should start if this is the first time that you have plugged the board in. When Windows finally figures out that it doesn’t know what the drivers would be, direct the wizard to the installation directory for the GHI Electronics SDK, by default C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\USB Drivers\GHI_NETMF_Interface.
Once you have done that, you have to put the EMX into the correct mode to update the firmware. Hold down the Up and Select buttons on the development board and press the Reset button.
Select USB from the Device combobox
Then click the Browse button and browse to the firmware directory for the development board, by default C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\EMX\Firmware, and select all of the .HEX files.
Click the Deploy button and wait until it has finished doing its thing and you are done!
Tags: EMX, GHIElectronics
The first thing that you have to do to get started using EMX from GHIElectronics, www.ghielectronics.com, is to go to http://www.microsoft.com/netmf/default.mspx and download the Micro Framework SDK and install it. Then go over to GHI Electronics, http://www.ghielectronics.com/product/129, and download and install the GHI SDK for NETMF. While you are there be sure to download their free ebook, “Beginners guide to NETMF”. You will of course need Visual Studio. As of this time VS 2008 is supported not VS 2010.
The first thing that you will probably want to do is to update the firmware on the development board. This is accomplished in two steps and involves placing the EMX board into two different operating modes.
Updating the bootloader
Plug the development board into an available USB port on your computer using the supplied USB cable. If the computer asks to install any device drivers, ignore that for now. To access the bootloader update mode, you would hold down the Up, Down and Select buttons on the development board as you power up the board or push the reset button. So patience is called for here. Unless you have teeny tiny fingers, it’s very difficult to hold all three buttons down at the same time. You know you have it when the screen does not display the boot up messages and is washed out with white.
If this is the first time that you have accessed this mode, the Hardware wizard should start up and want to install device drivers. The drivers you want to install at this time are located at C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\USB Drivers\GHI_Bootloader_Interface if you used the default location when you installed the GHI SDK. This driver allows you to connect to the board through the USB port using a terminal program. Once the driver is installed you are ready to go.
You need to use a terminal program to upload the new program to the processor. GHI reccommends Terra Term to use to upload the bootloader, you can download the program from their site. Personally, I have not had any success using Terra Term. I had heard that they have had problems with their 1K XModem protocol and I could never get it to work properly. I have used HyperTerminal that comes with Windows successfully. Start up your terminal program and connect to the EMX board. Hopefully you will be able to figure out which comport you need to use. Use 115200 8-N-1 and no flow control as your parameters.
Once you have connected, use the ‘E’ command to erase the memory. Note that you have to use upper case characters. Then press ‘Y’ to confirm the erase command. Wait until the board memory has been erased. While the erase is going on * characters are printed to the screen. They that stops you are ready to upload the new bootloader.
Press ‘X’ to begin the upload procedure. Again, remember upper case! The terminal program will start printing C characters to the screen indicating that the board is waiting for the upload. If you are using HyperTerminal, click the Transfer menu and Send File. Browse to the bootloader program to upload. In this case you want to go to C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\EMX\Firmware\TinyBooter and select the TinyBooter.GHI file. Be sure to select XModem 1K to use for the transfer. The transfer only takes a few seconds. After the transfer is complete, the board will reboot itself in preparation for the next step.
EMX embedded system May 1, 2010Posted by wesaday in Programming, Technology.
Tags: EMX, GHIElectronics
Found this really cool item from GHIElectonics, www.ghielectronics.com. They have a variety of items, I got the EMX. It’s a development board that utilizes the Microsoft .NET Micro Framework. Basically it’s .NET embedded on a chip. And since I am more and more working with hardware and embedded systems, I broke open the old piggy bank and bought one. The board comes with a bunch of connectors that are already wired up so you can pretty much get going right away. It has a ton of features that could be used for a bunch of different applications. The good news is that you can program and debug the processor using Visual Studio. The bad news is that you have to code everything by hand which isn’t really bad unless you are doing a user interface using the touch screen as the Micro Framework does not have an overabundance of support for user interface components. What support there is does support WPF elements. XAML is not supported though.