Guide to MJB's SAM7 Firmware Framework


MJB's "SAM7 Firmware Framework" is a stand-alone application comprising a command-line interpreter (CLI) and target-resident debugging facilities. It runs on Atmel's AT91SAM7S-EK evaluation board and compatible hardware platforms. The firmware is intended to provide a basic framework upon which to develop user applications. It includes a primitive task scheduler, but a more versatile real-time kernel could be easily incorporated.

The firmware is based on various examples from Atmel's website, with MJB's 32-bit command-line user interface (CLI) added. The program is a mix of source code ported from both IAR and GNU-GCC examples obtained from Atmel's website, but is designed to be built using the GCC-ARM tool chain. It should be possible to build the firmware with the commercial IAR EWARM system, but this has not been verified. There would be some changes required in the interrupt service routine (ISR) constructs and in the assembler startup module, cstartup.s, to suit the IAR tool chain.

The SAM7 Example Framework supports the following on-chip peripherals:

PIT Generates a 1ms periodic "tick" interrupt for the kernel "task scheduler";
also provides a general-purpose milli-second timer.
DBGU Debug Port for command-line user interface (CLI) and/or "trace" output.
The DBGU is interrupt-driven for RX data.
PWM Demonstration of PWM channel usage for digital-to-analog conversion.
(PWM0 output on pin PA23 -- 4kHz with duty cycle sweep from .1% to 99.9%.)
TC0, TC1 Demonstration of Timer/Counter usage (LED flashing).
PIO General-purpose I/O (switches & LEDs), external IRQ modes (optional).
USART Serial comm's support, with DMA buffering (optional).
UDP USB CDC "Virtual UART" function library for USB-to-Serial applications;
The USB port can be used to access the CLI using a terminal emulator (e.g. "PuTTY).

If using the PIO in interrupt mode, the module "ext_irq.c" can be included in the project. If using the USART(s), the module "usart.c" can be included in the project.

The binary object file "sam7_test_flash.bin" can be loaded into the target board via the USB port, by means of the "SAM-BA" firmware download utility. (The SAM-BA Windows GUI application is available from Atmel's website.)

Version 2.2 changes and additions

This particular release (V2.2.108 object code) is built with the USB option for CLI access. 
The DBGU port is used for "trace" output. It shows the USB enumeration transactions and other traffic on the Control endpoint.

The USB CDC library was developed by MJB. It is well structured, richly annotated, and much simpler than Atmel's example USB "framework" code. A Windows host driver file is included. The driver information file may be modified to suit the developer's application. Students of electronics technology and I.T. will find this firmware helpful to implement a USB CDC project.

Installing the Windows driver

The Windows USB driver is "usbser.sys", normally included with Windows XP, and normally found in local directory C: \Windows\system32\drivers. The custom driver information file required for this firmware is "cdc6166.inf". This should be copied to local directory C: \Windows. The firmware has not been tested with Windows 7 or later.

When the board is first powered up with the SAM7 Debug firmware installed, Windows "Found New Hardware Wizard" should appear and prompt for these files. It's better not to let the wizard search automatically for a suitable driver. Browse to the location of each file when prompted (cdc6166.inf comes first). If the Wizard asks for a hardware device type or category, select "Ports".

If the driver installed properly, the Windows "Device Manager" will show a new device "SAM7-EK board" under "Ports (COM & LPT)". It will also show the port number of the virtual COM port assigned to the device. Use this port number when configuring HyperTerminal.

Using the command line interface (CLI) when configured for USB comm's

Connect the SAM7-EK board to the host PC before starting HyperTerminal.

A second terminal emulator, e.g. TeraTerm, can be used to access the debug port, with DBGU serial port settings: 38400Bd, n, 8, 1.

When the board is powered up and running, start Hyperterminal.

The SAM7-EK board USB port appears to the host as a "virtual COM port". From the File menu, select "Properties".  In the dialog box, in the field "Connect Using:", select the COM port assigned to the device. (This is usually the highest numbered virtual COM port, which will be COM5 or above on PCs having physical ports on COM1 thru COM4.) Other serial port settings (Baud rate, etc) are irrelevant for USB comm's, except for devices implementing a USB-to-Serial converter, or such like.

Click "OK" to close the "Properties" dialog box.

Next, click the "Call Connect" button (or select "Call/Connect" from the menu). With the HyperTerminal window active, hit [Enter] once or twice on your keyboard. The SAM7 Debug Monitor prompt should appear (:-->).

Click the "Disconnect" button in HyperTerminal before resetting or unplugging the board. Click the "Call Connect" button to resume communications. If HyperTerminal fails to respond, close it, reset the board, then open it again. In some cases, it might be necessary to reconfigure the COM port (as above).

CLI User Guide

To list available commands, enter "help" at the prompt. Commands and their arguments are separated by spaces. All commands, when entered with the switch '-h' or '?', will show command usage details (and do nothing else). Otherwise, a command which expects at least one argument, when entered without any, will also show command usage. In usage info, [ ] brackets mean optional, e.g. [<arg>]; braces enclose alternative options, e.g. { -x | -y }. The Backspace key can be used for simple line editing. Ctrl+X cancels a line. To recall a previously entered command, use Ctrl+R.

SAM7_Firmware_Guide.htm -- Copyright 2008-2015 Michael J. Bauer --