Sunday, February 21, 2010

Running PC Utility for uCOS-II with Microsoft Windows Vista in 1 Hour

uCOS-II the Real-Time Kernel

uCOS-II is a small, yet powerful real-time operating system developed by Jean J. Labrosse and described in his book "MicroC/OS-II - The Real-Time-Kernel", Second Edition, published by CMP Books. The operating system is highly CPU independent and has been ported to numerous microprocessor platforms. The source code as provided together with the book and via the web site may be freely used for non-commercial applications and educational purposes. Licenses for commercial use are available too.

PC Utility for uCOS-II x86 Win32 Simulation

In a previous post, I managed to simulate uCOS-II with Windows Vista. The example used was a very simple one that used to display simple messages on the console. The next step was to create a PC utility to access some of the PC capabilities. By this, I am completing the simulation environment of uCOS-II on Windows Vista and making it similar to the environment described in uCOS-II books by J. Labrosse.

This utility is encapsulated in a file called PC.C and called from the test code. This utility uses the Windows console driver. Encapsulation allows users to easily adapt the code to a different compiler or a different design. The utility contains 3 types of services: character-based display, elapsed-time measurement, and miscellaneous.

Most of the previous tests of the PC Utility were never done, until writing this document, with Windows Vista. In this document, I will show how you can run a PC Utility used with Windows XP under Windows Vista.

Building the PC Utility

My starting point was a PC utility written by Prof. Werner Zimmermann. He used the windows console driver for character based display and some APIs for time measurements.

In addition, he had 3 examples similar to those described in Labrosse's book. I used examples 1, 2, and 3 written for VC as a starting point for my test applications.

To build this tutorial on your own, you need to download Zimmermann's Windows port of uCOS-II from here.

Steps to Build the PC utility

1. Extract the Zimmermann's port

2. Following the directory structure we made in the previous post referenced above, create a directory for the PC utility files as follows C:\Micrium\Software\Blocks\PC\OpenWatcomC-C++1.8

3. Copy PC.C and PC.H from Zimmermann's port to the created directory above

4. In PC.C, remove anything related to interrupts.

5. Build 3 different projects as described in the previous post. The new projects should include the newly added PC files and source codes of examples 1, 2, and 3 from the Zimmermann's port.

6. In each file called test.c, change the PC_DispChar calls to PC_DispStr. PC_DispChar is buggy for this port.

7. In any example where hooks are needed, do the necessary changes to include them in the uCOS-II original code.

8. Compile and run your 3 examples.

Figure 1: Open Watcom C-C++ 1.8 Project Structure

Figure 2: Example 1 Running with the PC Utility

Figure 3: Example 2 Running with the PC Utility

Figure 4: Example 3 Running with the PC Utility


  1. Thank you so much for posting this information, my embedded systems course is using this guide as a starting point for building at least one project this semester.

    I was wondering if you could explain why we need to remove the calls to interrupts from the pc.c file? Thanks so much.

  2. The port of uCOS-II, I am using and provided by Micrium, does not simulate external interrupts. The port developed by Zimmermann, the one who originally wrote the PC utility, simulates interrupts. To avoid compilation errors, I just removed them.

  3. Can you suggest any application with uCOS2 on mini2440 I am doing my project on uCOS2