Resources for embedded micro-controller firmware development

Simple real-time multi-tasking kernels
Support function libraries and Low-level I/O drivers
Adaptable to a wide variety of processors and embedded applications
On-chip peripheral support for
68HC12 family, 8051 & derivatives,
AT91SAM7S (ARM) | ATmega128 (AVR) | AT89C5131

USB developer resources
Atmel AT89C5131 | Maxim MAX3420E | Philips PDIUSBD12
USBTMC/USB488 Reference Design

Your comments and enquiries are welcome.


BERT: Basic Embedded Real-Time (operating system) for micro-controllers

What? ... Not another micro-controller RTOS?

Well, yes, there's a lot of them around and they all have their pros and cons. The "cons" are mostly related to licence requirements (i.e. expense) and/or unnecessary complexity (i.e. unwanted overheads on MCU speed and memory).
Most commercial RTOS's are overkill for the majority of micro-controller applications. I believe BERT is a good compromise for many purposes... It provides a tried-and-proven framework upon which to build customised firmware.

A processor-specific example is provided for the Motorola/Freescale HC12 processor family (68HC12, 68HC812, HCS12, etc), which should be easily adaptable to a variety of processors of similar architecture. Hardware-platform dependencies are (mostly) confined to a separate I/O code module which is intended to be modified or replaced to suit the target platform.
BERT code includes a full-featured command-line user interface (CLI) with resident debug monitor facilities, plus a control-surface user interface, plus generic support for EEPROM data storage.
For more details, see BERT Overview

BERT is freeware and is distributed as a suite of C source code modules.
Download BERT 'HC12 here (150KB zip file)

BERT CLI facility adapted to suit Mot. 68K family and other 32-bit MCUs...
Download 'CLI for 68K' extras (20K zip file)

BERT 68HC12 development system built from a salvaged prototype industrial control board.


ALERT: A Light Embedded Real-Time OS for Low-End Micro-controllers

Also on offer is a leaner offshoot of BERT designed to suit low-end MCU architectures such as Intel's 8051 and its many derivatives (e.g. AT89C51xx), Atmel 8-bit AVR, also Motorola 6805 and 6808 families, Microchip PIC, etc, all characterised by a limited amount of on-chip RAM. Modern C compilers can generate very efficient code for these low-end MCUs, so the developer is insulated somewhat from the limitations of the processor architecture.

ALERT is a smaller operating system, designed to reduce processor and memory overheads to a bare minimum. ALERT is easily adaptable to a variety of low-end MCUs. The code has been designed to get a small embedded application up and running with minimum effort. It provides a tried-and-proven framework upon which to build customised firmware.
For more details, see ALERT overview

Atmel AT89C5131 USB micro-controller Debug Monitor (based on ALERT)

An example ALERT application is provided for the Atmel AT89C5131 USB micro-controller. The code incorporates a command-line user interface (CLI) with resident "debug monitor" and a suite of OS functions to support various MCU resources, including on-chip UART, SPI, EEPROM and USB device controller. The CLI is accessible via the UART or USB port.
The USB device "stack" uses the Communications Device Class (CDC), implementing a "virtual UART". The function library is ideal for USB-to-Serial converter applications. Windows (2000/XP) incorporates a USB CDC driver, so the host PC application software can communicate with the device via a "Virtual COM port". HyperTerminal may be used for testing.

The sample firmware runs on Atmel's AT89STK-05 Evaluation Board. This can be cloned for a fraction of Atmel's original price, if you have the time and practical skills to do it yourself. Schematic and parts list are included in the download package.
Other third-party development boards are available... For example, see
www.futurlec.com.

Download ALERT / EVAL 'C5131 here (180KB zip file)

Having problems compiling or running eval_c5131 firmware?
Try the FAQ help page.

Experimenter Board for Atmel AT89C5131 USB Micro-controller


AT91SAM7S (ARM) Debug Monitor

The SAM7 Debug Monitor is a stand-alone firmware application comprising target-resident debugging facilities and demonstration routines. It runs on Atmel's AT91SAM7S-EK evaluation board and similar hardware platforms. The firmware provides a basic skeleton upon which to develop user applications. It incorporates a primitive task scheduler, but a more capable real-time kernel (e.g. BERT) can be easily imported. The program is a mix of source code ported from examples obtained from Atmel's website, with MJB's 32-bit command-line user interface (CLI) added. The firmware is built using the free GCC tools.

For details, see SAM7 Debug Monitor Overview and GNU/GCC Build Notes (also included in the download package).

Download AT91SAM7S Debug Monitor here (90KB zip file)


ATmega128 (AVR) Debug Monitor

This AVR Debug Monitor is a complete stand-alone program with a full-featured command-line user interface (CLI), similar to that provided in the 'BERT' operating system. The monitor makes a good starting point for the development of application firmware for the ATmega128 and similar AVR processors. A target-resident debug facility is particularly useful if you don't have access to a JTAG ICE debugging tool.

Download ATmega128 Debug Monitor here (20KB zip file)


ATmega128 (AVR) Bootloader Design Note

The Design Note provides essential information for the development of bootloader code to suit the ATmega128 and similar AVR processors. Included in the resource pack are source files and a customized XLINK linker command file.

Download ATmega128 Bootloader Design Pack here (20KB zip file)


USB Developer Resources

Introduction to USB

A very good introduction for novices can be found at... http://www.usbmadesimple.co.uk/

The application notes and FAQ file on Maxim's website - MAX3420E pages - provide some very helpful information for beginners... even if you are not using Maxim chips.

For heaps of sample source code and application notes on various USB device classes, Atmel's website is well worth a visit... even if you are not using Atmel chips. Go to the USB micro-controller related pages (AT90xxx AVR and AT91xxx ARM).

USB is not overly complicated at the device end, once you get your brain around the process of "enumeration" (i.e. standard "device requests" on the Control Endpoint, as described in Chapter 9 of the USB2.0 Specification). The major difficulty with USB, for developers, is to produce the host-side (Windows or Linux) driver software. Windows has "built-in" drivers for some USB device "classes", e.g. HID, CDC, MSD (Mass Storage), Audio, Video, etc, but there is no "general purpose" class. And you still have to create a "driver information file" (*.inf), which can be hard to get right!

Using a relatively simple driver information file (*.inf), the communications device class (CDC) allows your device to talk to the host PC via a "virtual COM port". This means that your USB device appears to your PC application software as a serial ("RS232") device, just like a physical COM port, but faster. This is probably the simplest method to implement a USB connection. You can use Hyper-Terminal to test your device, if the Bulk-In/Out data is encoded as printable ASCII chars. This is the scheme I chose to use for my Atmel AT89C5131 evaluation board firmware (Eval_C5131). Note: The maximum data transfer rate using USB CDC with a "virtual COM port" is about 1Mbit/sec. (This is a Windows driver limitation, not a USB limitation.)

For further information on CDC host driver implementation, download the App Note "AT91 USB CDC Driver Implementation" (document #6269A - Oct. 2006) from Atmel's website. Although intended for applications based on the AT91SAM series micro-controllers, the material is applicable to any USB CDC hardware platform.

Windows Vista is supposed to incorporate a new "device class" with generic support for Bulk data transfer. This holds the promise of being able to exchange data with a USB device from a Windows application, without needing a device-specific driver. Presumably, Vista supports "system calls" (via a function library in Visual Basic or C/C++) to "open", "read", "write", etc, a Bulk pipe in a selected USB peripheral. However, I have been unable to find details on this new "Bulk" device class, so I would be very grateful if anyone in the know could point me toward a source of futher information.

Another sure way to avoid developing host-side (Windows) USB driver software is to use the Test & Measurement Class (USBTMC) with a VISA API/driver (I/O library).

About USB Test & Measurement Class (USBTMC)

For many applications, the Test & Measurement Class (USBTMC) has distinct advantages over other USB device classes. In fact, its only shortfall is the absence of isochronous transfers which, for the majority of applications, won't be a concern. Although targetted towards instrumentation, as a replacement for the ageing "GPIB" (IEEE488 bus), the USBTMC protocol is very generalized and well suited to a broad range of applications requiring fast Bulk In and Bulk Out data transfer and (optionally) Interrupt In transfer. Yet, the TMC protocol is remarkably simple.

Perhaps the most compelling reason to use USBTMC is that you don't need to develop host-side driver software or driver information (.inf) scripts. Your host PC application software communicates with USBTMC devices via a third-party 'application program interface' (API). The API provides a library of standardized I/O functions designed to facilitate transfer data to and from compliant USBTMC devices. One such standard is "VISA" (Virtual Instrument Software Architecture).

A VISA API library is available from either National Instrument or Agilent Technologies. (These are free downloads -- refer to company websites.) The VISA API incorporates USBTMC host driver software. The driver detects and adapts itself automatically to each unique TMC device connected. Both the NI and Agilent VISA packages come with an interactive test utility which may be used to verify that a TMC device is communicating correctly with the host controller.

The VISA API library is provided in the form of a linkable object code file. These are available for both Windows and Linux. For a Windows host, application software can be developed in Visual Basic or Visual C/C++. National Instrument's VISA supports a variety of instrument communication interfaces in addition to USB, i.e. GPIB (IEEE488), Serial, PXI, etc, whereas Agilent Technologies' VISA installation is more compact.

If you're using VISA for personal or educational use, then you can download and use a VISA I/O library for free. The only disincentive for using a VISA API/driver is that the distribution package is rather large (about 210MB for NI-VISA, 70MB for Agilent!). Mercifully, the runtime objects are not nearly as big. (Note: If you are developing a commercial USBTMC product, there may be a licence fee applicable.)


USBTMC/USB488 Reference Design

Currently under development is a generic USBTMC device "reference design" (firmware example) intended to fulfill the following objectives:

  • Comply fully with the USBTMC/USB488 Specifications (Rev 1.0, 2003)
  • Implement all standard USBTMC/USB488 Class Requests
  • Conform to VISA (Virtual Instrument System Archietcture) host requirements
  • Provide a small example command set using the IEEE488.2 message protocol
  • Implement a minimal IEEE-compliant status reporting mechanism
  • Implement the USB488 standard remote/local (RL) state machine
  • Provide infrastructure for Service Request (SRQ) via Interrupt-In endpoint
  • Allow USB peripheral I/O to be interrupt-driven or polled (as a build option)

Initial target platforms will include Atmel AT91SAM7 (ARM7) with on-chip USB peripheral and ATmegaXXX (AVR) with Maxim MAX3420E USB peripheral controller. The example "application layer" and USBTMC "class layer" (source modules) will be designed to be independent of hardware platform, so the code can be more easily adapted to other platforms. The source code and supporting documentation will be of professional quality. This package will not be freeware.

*** Calling for expressions of interest from professional developers! ***

If you are interested in my "USBTMC Reference Design" (source code and documentation), please email me giving details of your requirements. Include in your email the general "application area", hardware platform and expected annual sales volume of your USBTMC product(s). Your response will influence the rate of development, availability, and price of the package!


Recommended Windows Utilities for USB Testing & Debugging

Microsoft USBView - USB Connection Viewer

USBView is a free utility from Microsoft which displays the USB connection tree and shows any USB devices connected, together with their configuration data (descriptors).  This is very useful for diagnosing USB enumeration problems, with or without the device driver installed on the host PC.  USBView runs under Windows 98, ME, 2000 and XP.
To obtain USBView, Google with "Microsoft USBView download"

USB Monitor from HHD Software Co.

USB Monitor is a Windows application that logs USB data transfers between the host and selected device(s). This is an excellent piece of software, well worth the small price asked (under us$40 for the 'lite' version). There's a trial version too.
To obtain USB Monitor, Google with "HHD software USB monitor"


USB Chip Review: Maxim MAX3420E USB Peripheral Controller

The MAX3420E is is a very well designed device. It uses a fast SPI connection to the micro-controller instead of a parallel bus. The chip has automatic recovery from bus errors. The register set is devoid of unnecessary complexity, which makes it a breeze to develop driver firmware. The chip is well supported with documentation available from Maxim's website. The datasheet is clear and comprehensive. The FAQ file demystifies and explains aspects of USB which novices often find intimidating. I had the MAX3420E up and running (enumerating) with an ATmega128 processor in a day.

Maxim's sample driver firmware gives you the essential "bare bones" requirements to get the device to enumerate. I have developed a more generalised firmware library which may be more easily customized to a particular application. The library provides essential "Chapter 9" (enumeration and standard device request) support, plus generic functions for endpoint read and write, status checking, etc. The architecture is well suited to applications using Bulk and/or Interrupt data transfer (e.g. USBTMC/USB488 class or "Virtual COM Port" CDC implementation). The library is adaptable to suit other USB peripheral controllers, by re-writing the low-level "hardware abstraction layer" (usbhal.c).

Download MJB's MAX3420E USB device firmware library


USB Chip Review: Philips PDIUSBD12 USB Peripheral Controller

My experience with the PDIUSBD12 has been disappointing. The datasheet is sparse and ambiguous. The chip seems to be very intolerant if driven even slightly outside of the specified parameters, which suggests the design is marginal. The 'D12 does not recover automatically from bus errors at the data link layer (e.g. sync, PID, CRC, etc), so the responsibility for error detection and retry is passed on to the driver firmware (where possible). Consequently, I would not recommend using the 'D12 in a new design. But if you do, be sure to follow the datasheet and accompanying FAQ sheet and App Notes very carefully.

Philips' PDIUSBD12 library code is unrefined and sparsely annotated. For the benefit of anyone who has decided to use the 'D12 in their design, my restructured and better annotated firmware library (C source code) is available for download here...

Download MJB's amended PDIUSBD12 firmware library


* Disclaimer *

Source code and other "intellectual property" offered as free downloads on this website are original works of M. J. Bauer, except where acknowledged to the contrary. Otherwise, any resemblance to prior art originated or developed by others is purely coincidental, or due to derivation from similar works or well-established art in the public domain. The author does not accept liability for any adverse consequence of the use of "intellectual property" copied from this site.

Last updated: June 2008