Link here

Getting to Know Your QCard Controller

Congratulations on your choice of the QCard Controller™, a compact Single Board Computer (SBC). This Chapter introduces the software and hardware features of the QCard Controller: the RTOS, choice of C or Forth programming languages, Freescale 68HC11 microcontroller, memory, serial communications, real-time clock, and I/O (Input/Output).

In this chapter you’ll learn:

  • All about the operating system and software features of the QCard Controller;
  • All of the hardware features of your controller; and,
  • How to configure various options on your controller.

Introducing the QCard Controller

To serve the needs of real-time control projects, modern embedded computers must have a set of complementary features including operating system software, device drivers, user interface, and expandable I/O. You’ll find the QCard Controller has a set of hardware and software that work together to simplify your product development cycle while bringing new capability to your instrument control designs.

The QCard™ packs a programmable computer, up to 1 megabyte of memory, communications, analog and digital I/O, and an expansion I/O bus onto a tiny low-cost board. This 2" x 2.5" single board computer is perfect for space-constrained applications and dramatically cuts the cost of data acquisition and control. It is ideal for machine automation, industrial control, robotics, handheld data acquisition, and scientific instrumentation.

The I/O-rich QCard hosts a 16 MHz Motorola 68HC11F1 microprocessor, 512K Flash and 128K RAM (expandable to 512K), and 320 bytes of EEPROM. On-board IO includes 8 digital I/O lines with counter/timer capabilities, 8 analog inputs, a fast synchronous SPI serial interface, and dual RS232/485 ports. An optional real-time clock tracks the calendar and time of day and battery backs the 128K RAM.

The QCard is easily programmable in C, Forth or Assembly using any PC. Built-in programming tools include an interactive debugger, a multitasking executive, and comprehensive device-driver libraries.

Convenient connectors allow for simple mechanical integration. The QCard can directly host up to 4 I/O expansion modules called WildCards™ that you can mix and match depending on your application. The easy to use WildCards stack onto the 24 pin WildCard connector on the QCard. A convenient PowerDock™ module includes an efficient switching power regulator and expands the WildCard bus to host up to 8 WildCards.

WildCards implement a wide variety of user interface, communications, data acquisition and control capabilities. Available WildCards include a Keypad/Display module, octal 12-bit D/A and 16-bit A/D converters, a 24-bit resolution analog data acquisition subsystem, Compact Flash card mass memory interface, fast buffered RS232/485 dual UART, high voltage/high current isolated I/O, and AC or DC solid state relays. You can select the WildCards that meet your needs to configure a cost-effective customized controller for your application.

The following subsections discuss the interdependent hardware and software aspects of your controller.


Real-Time Operating System (RTOS) and built-in function library

You wouldn’t want to have to load an operating system into your desktop computer each time you turn it on, and the same holds true for embedded computers. Importantly, all of Mosaic’s controllers incorporate a full-time, on-board operating system called QED-Forth. QED-Forth is an interactive programmable macro language encompassing a real-time operating system (RTOS), object oriented graphical user interface (GUI) toolkit, debugging environment, an assembler and math library for use within the Forth programming language, and a comprehensive set of pre-coded device drivers.

These built-in functions make it easy for you to get the most out of your board's computational and I/O capabilities. You can fully program the QCard Controller using only the QED-Forth programming language, or you can program it using only the C language – all of the operating system’s functions are accessible using either language.

This chapter describes how to program your QCard Controller using the Control-C programming language, and how to use the built-in functions. Another chapter is available if you prefer to program in the QED-Forth programming language. Function glossaries provide an in-depth description of every routine. The QCard Controller’s extensive embedded firmware reduces your time time-to-market – we’ve precoded hundreds of useful routines so you won’t have to.

The RTOS in onboard Flash memory also manages all required hardware initializations and automatically starts your application code. It provides warning of power failures so you can implement an orderly shutdown, and provides the run-time security feature of a watchdog (COP - computer operating properly) timer.

Programming is a snap using the interactive debugger and multitasking executive. The multitasker allows conceptually different functions of your application to run independently in different tasks while accomplishing their duties in a timely fashion.


Choice of programming languages

You can program the QCard Controller using either the ANSI-standard C language or Mosaic’s QED-Forth language [djs1]. In either language, you can supplement your high-level code with assembly code. Using either language, you have full access to all firmware functions.


The Control-C programming environment

Our Control-C™ cross-compiler was written by Fabius Software Systems and customized by Mosaic Industries to facilitate programming the QCard Controller in C. It is a full ANSI C compiler and macro pre-processor; it supports floating point math, structures and unions, and allows you to program in familiar C syntax. Extensive pre-coded library functions provide easy command of the controller’s digital I/O, A/D, serial ports, memory manager, multitasker, and much more.

Using the Windows™ environment on your PC, you can edit your C program in the supplied Mosaic IDE, and with a single mouse click you automatically compile, assemble and link your program, and generate an ASCII hex file ready for downloading. Clicking in the "Terminal" window and sending the download file to the controller completes the process: you can then type main from your terminal to execute your program. The interactive development environment also lets you examine and modify variables and array elements, and call individual functions in your program one at a time with arguments of your own choosing. This interactive environment greatly speeds the debugging process!


QED-Forth high level language

For those who prefer to program in FORTH, no external compiler is needed. You interact with the QED-Forth operating system (an RTOS, interpreter and compiler, all rolled into one) using your PC as a terminal. When programming in Forth you can use the Mosaic IDE (or you can use any other editor you prefer) to write your code and download the source code directly to the controller where it is compiled as it downloads. As we will see, even C programmers benefit greatly by the presence of the QED-Forth operating system, as the built-in Forth language provides a quick and easy way to interactively "talk to" your QED Board while debugging your C programs.


68HC11 assembly code

Both Control-C and QED-Forth include complete in-line assemblers that let you freely mix high level and assembly code. This is sometimes useful when creating specialized time-critical functions such as interrupt handlers.


Hardware functionality

The block diagram of Figure 1-1 provides a cogent summary of the hardware capabilities of the QCard Controller. Each of the hardware modules shown is described in the following sections.

Embedded Multitasking

Figure 1-1 The QCard Controller. The QCard directly hosts up to four WildCard I/O modules; mounted on a PowerDock it hosts up to eight WildCards.


Power requirements

The QCard requires a regulated +5 V supply and draws a maximum of 150 ma. It directly hosts up to four WildCards, each requiring a maximum of 100 ma. Some WildCards require an additional +8-26 V supply.

The QCard Controller optionally mounts on a PowerDock which provides a 1 amp 5 volt switching power supply, dual DB-9 serial connectors, a power jack, a master power switch, plus an additional WildCard header for hosting four additional WildCards. The serial connectors, jack and switch are designed for easy mounting to an instrument panel.


Freescale 68HC11 processor

The central block in Figure 11 represents the 68HC11F1 microcontroller. This chip integrates a central processing unit (CPU), communications, analog and digital I/O, timing capabilities, and memory. It provides the core capabilities of the QCard. In this document we will refer to the microcontroller chip as the 68HC11F1, the 68HC11, or simply the HC11.

The processor includes:

  • An 8 bit timer-controlled digital I/O port called PORTA. The timer functions include "input captures" that facilitate accurate measurement of pulse widths, "output compares" that make it easy to generate pulse trains and pulse-width modulated waveforms, and a pulse accumulator. These functions are backed up by interrupts that simplify real-time response to external events.
  • An 8 channel input port (called PORTE) on the processor that can be configured to read either analog or digital inputs. Analog inputs are converted to an 8 bit digital number by a built-in analog to digital (A/D) converter.
  • A built-in serial communications interface (SCI). The SCI is an asynchronous interface, meaning that there is no clock transmitted with the data. Using the SCI, the QCard Controller can transmit and receive data at standard baud rates to 19200 baud, and at non-standard intra-character rates as high as 250 Kbaud.
  • A serial peripheral interface (SPI) capable of data transfer rates up to 2 megabits per second. Many useful devices communicate via such a synchronous (clocked) serial interface. Multiple peripheral devices can communicate on this interface as long as each device has a unique chip select signal.
  • A watchdog timer that can be configured to reset the processor if the application program fails to execute properly.
  • A clock monitor available to reset the processor if the clock fails.
  • External interrupt request pins and a variety of interrupt functions for quick response to real-time events.
  • 512 bytes of nonvolatile, electrically erasable PROM (EEPROM). Of this, 192 bytes are used by the operating system and 320 bytes are available for your application. EEPROM provides a convenient way to store calibration constants and other information that must be periodically updated.
  • A 16 bit address bus and an 8 bit data bus. While the 68HC11’s native address space is 64 Kilobytes (equal to 65,536 bytes, and often written as 64K), the QCard Controller expands the addressable memory space to 1 Megabyte by effectively adding 5 "page" bits to the address bus. The memory architecture is optimized for fast execution, and the onboard operating system makes page changing transparent to the user. Once you set up your starting memory map, QED-Forth handles all of the details of accessing memory.

Learning more about the 68HC11

The QCard Controller uses a new version of the 68HC11 microcontroller, called the 68HC11F1. Motorola’s M68HC11 Reference Manual and MC68HC11F1 Technical Data Manual are included with this documentation package as Adobe Acrobat Portable Document Format (*.pdf) files.

The M68HC11 Reference Manual thoroughly describes how to use microcontrollers of the 68HC11 variety, but it does not describe some of the enhanced features that appear in the F1 version. The MC68HC11F1 Technical Data Manual provides details of the operation of the F1.


Memory and mass memory

The QCard includes 512K Flash memory, 128K RAM (or 512K RAM with the expanded memory option), 512 bytes of EEPROM and an additional1K RAM (on the processor).

Of the 512K of Flash memory, 448K is available for your application program and data storage; the remainder is used by the operating system. Of the 129K (513K, with expanded memory option) of RAM, 125K (509K) is available for application program use.

Like PROM, Flash memory is nonvolatile. Thus it retains its contents even when power is removed, and provides an excellent location for storing program code. Simple write-cycles to the device do not modify the memory contents, so the program code is safe even if the processor "gets lost" and overwrites memory. But Flash memory is also re-programmable, and the Flash programming functions are present right in the QCard’s onboard software library.

You can also add 64 MBytes or more of removable mass memory by plugging in a Compact Flash WildCard module.


Measurement and control

The QCard Controller provides a total of 17 I/O channels, distributed among digital, analog and serial communications functions as shown in Table 1-1.

Table 1-1 I/O available on the QCard Controller

I/O Type
Digital 6 Timer-controlled inputs or outputs including 3 input-capture, 3 output-compare, and a pulse accumulator. (Two additional lines are available if the second serial port is not needed.)
Analog 8 8-bit 0-5 V analog inputs at up to 100kHz sampling rate
Serial 1 Serial 1: RS232/485 hardware UART at up to 19.2 KBaud
1 Serial 2: RS232 software UART at up to 4800 Baud
1 Synchronous Serial Peripheral Interface at 2 MBaud
17 Total I/O channels

For each of these I/O lines, pre-coded I/O drivers make it easy to do data acquisition, pulse width modulation, motor control, frequency measurement, data analysis, analog control, PID control, and communications. You may add any amount of additional I/O using WildCards.



Two serial ports and a fast synchronous serial peripheral interface (SPI) provide plenty of communi-cations capability. A hardware UART with single character buffer drives RS232 or RS485 protocols at up to 19.2 Kbaud (the default serial baud rate), and a software UART provides RS232 at up to 4800 baud. Onboard serial interface chips generate the logic levels necessary to implement either the RS232 or RS485 protocol. Two serial ports allow you to program through one while your instrument can still communicate with a third party through the other.

The RS485 communications port may be optionally terminated with a resistor or RC network. Pads are also included on the board for insertion of RS485 network bias resistors.

If you need greater speed or more ports, UART Wildcards plug directly into the QCard’s Wildcard module bus, each providing two more full-duplex RS232/422/485 buffered serial communication ports at up to 56 Kbaud.


Real-time clock

A battery-backed real time clock (RTC) may be optionally included. If so, the RTC’s battery also backs-up the 128K RAM. Note however that if the expanded memory option is chosen, providing 512K of RAM, then none of the RAM can be battery-backed, but the onboard battery still powers the RTC.


Extensible I/O including keypad and display

Need even more I/O? The QCard hosts Mosaic’s WildCards™, small I/O modules for sophisticated and dedicated I/O. Up to four WildCards can be stacked directly on the controller. If the QCard is mounted on a PowerDock, up to eight WildCards can be used simultaneously, four stacked on the QCard and four in a companion stack on the PowerDock. Available WildCards include:

  • A Keypad/Display module with a 4 line by 20 character LCD display and a 20 button keypad;
  • 16- or 24-bit resolution programmable gain A/D;
  • 12-bit D/A;
  • Compact flash mass memory;
  • Optically isolated AC or DC solid state relays;
  • Configurable general-purpose digital I/O;
  • Fast, buffered RS232, RS422 or RS485 communications interfaces; or,
  • High-voltage, high-current DC inputs and outputs.

Getting to know your hardware

QCard Starter Kit

If you purchased a QCard Controller Starter Kit, you should have received the following:

  1. A QCard Controller with 128K BBRAM and Real-Time Clock (Part No. QCC-RB);
  2. A wide version of the PowerDock (Part No. PDW);
  3. A 9-pin PC Serial Cable (Part No. PCC9-232);
  4. An 8-26 volt Power Supply (Part No. PS-8V)[djs2];
  5. A CD-ROM containing:
    • The Mosaic IDE including a TextPad source code editor and the Mosaic Terminal program;
    • The Control-C Compiler, integrated within the Mosaic IDE;
    • Program examples; and,
    • Motorola M68HC11 Reference Manual and MC68HC11F1 Technical Data Manual (Part No. MAN-HC11);
  6. A User’s Guide on how to use the Kernel Extension Manager for additional Wildcard Drivers.

If you are missing any of these items, please contact us immediately.


A tour of the headers and jumpers

Figure 12 shows a photo of the top side of the 2" x 2.5" QCard, and diagrams the positions of the headers and jumpers.

Embedded System Specifications

Figure 1-2 Headers and Jumpers on the QCard Controller.


Configuring jumpers on the QCard Controller

The actions of the configurable jumpers on the QCard Controller are summarized in Table 1-2. The jumpers are in order with J1 nearest the crystal and J4 nearest the reset switch.

Table 1-2 QCard Controller Jumper Summary.

Jumper Label Description
J1 Clean Puts the QCard Controller into special cleanup mode on the next power-up or reset. To return the QCard Controller to its pristine, right-from-the-factory condition, install this jumper, press the Reset Button, then remove the jumper.
J2 Term If installed with J3, provides RC termination for the RS-485 communications link on Serial 1 by connecting a 100 Ohm resistor in series with a 0.1 micro-Farad capacitor across the RS485 line.
J3 485 If installed, enables RS485 communication via Serial 1.
J4 Prot If installed, write protects memory page 0x0C. Useful for "bullet proofing" a kernel extension to enable firmware upgrades.

Power header

The QCard requires that a regulated +5VDC supply be connected either to the power header (H1), the field header (H2), or the WildCard module header (H3). If WildCards are mounted to the QCard some of them may additionally require that a greater DC voltage of +8 to +26 VDC, designated V+Raw, be applied to the power header. The power header also hosts pins used for JTAG programming of a CPLD on the board, but you will generally not need to use this facility. The following table provides the power header’s pinout:

H1: Power Header

Pin Signal
1 – V+RAW (+8 to +26 VDC)
2 – GND
3 – +5 VDC
4 – TDI for JTAG programming
5 – TMS for JTAG programming
6 – TCK for JTAG programming
7 – TDO for JTAG programming
Note: V+RAW is needed only if certain WildCards are used.
Pins 4-7 are generally not used.

Communications header hosts primary and secondary serial ports

The primary serial port, designated Serial 1, can be configured for RS232 communication at standard rates up to 19,200 baud and nonstandard rates to 250,000 baud. The secondary serial port, Serial 2, which can be used for pe-ripheral devices such as a printer or a barcode reader, has a maximum baud rate of 4800 baud. Both serial ports bring out their transmit and receive pins to the communications header. The primary serial port can be jumper configured for RS485 operation; in that case the XCVR± pins are used. Pin 10 on the communications header provides access to the real time clock’s backup battery, +VBAT. If the QCard is mounted on a PowerDock the corresponding communications header on the PowerDock provides +5V instead of +VBAT on pin 10. Additionally, the PowerDock’s communications header does not contain the /MOD1.CS signal on pin 4, replacing it with digital ground (DGND) instead.

H4: Communications Header

Signal Pins Signal
/TxD1 – 1 2 – /RxD1
DGND – 3 4 – /MOD1.CS
RS485 XCVR- – 5 6 – RS485 XCVR+
/TxD2 – 7 8 – /RxD2
DGND – 9 10 – +VBAT
Note: This pinout differs from that of the PowerDock pinout:
on the PowerDock pin 4 is connected to DGND and pin 10 is connected to +5V.

Field header

The QCard’s field header provides access to all of its I/O and power signals, including its serial communications, analog inputs, and timer-controlled digital I/O lines. If convenient, you may power the QCard through this header’s power pins.

H2: Field Header

Signal Pins Signal
GND – 1 2 – +5V
AGND – 3 4 – V+RAW
/TxD1 (/TxD2) – 5 6 – /RxD1 (/RxD2)
XCVR- (/TxD2) – 7 8 – XCVR+ (/RxD2)
PA7 – 9 10 – PA6
PA5 – 11 12 – PA4
PA3 – 13 14 – PA2
PA1 – 15 16 – PA0
PE7 – 17 18 – PE6
PE5 – 19 20 – PE4
PE3 – 21 22 – PE2
PE1 – 23 24 – PE0
Note: Signals in parentheses indicate options configured
by installing appropriate zero ohm shorts on the board.

Wildcard I/O expansion interface

The QCard’s WildCard Port Header (identified as Port 0) allows you to mount up to four WildCards simultaneously on a single QCard at module addresses 0 through 3. If the QCard is mounted on a wide version of the PowerDock, the PowerDock provides an additional WildCard port (identified as Port 1) to accommodate up to four more stacked WildCards at module addresses 4 through 7. If a Keypad/Display Wildcard is installed, it must be configured as module number 0 so that kernel-resident software drivers can be used. The Wildcards mount onto the QCard and PowerDock via the 24-pin stackable go-through headers, with up to 4 Wildcards allowed per stack. Ribbon cabling is not allowed on the Wildcard bus, as it may compromise the integrity of the signals on the control bus. The 24-pin Wildcard headers provide the following signals:

H3: WildCard Port Header

Signal Pins Signal
GND – 1 2 – +5V
/IRQ – 3 4 – V+Raw
SEL1/XMIT- – 5 6 – SEL0/XMIT+
/RESET – 9 10 – SCK
/MOD.CS – 11 12 – 16 MHz
E – 13 14 – R/W
/OE – 15 16 – /WE
AD7 – 17 18 – AD6
AD5 – 19 20 – AD4
AD3 – 21 22 – AD2
AD1 – 23 24 – AD0
This page is about: 68HC11 Microcontroller Programming on 68HC11 Single Board Computer, Forth Language C Language Programmable 68HC11 Microcontroller Projects, Real Time Operating System RTOS, I/O Expansion Modules, Includes Analog Io, Digital Io, Timer Io, RS-232 and RS-485 Serial Communications, Built-in Function Library, Ideal for Data Acquisition, Measurement, and Control – Software and hardware interfacing a 68HC11(F1) microcontroller single board computer, programming real time operating system RTOS, C programming and Forth programming languages, Freescale 68HC11 microcontroller projects, using embedded computer memory, serial communications, real-time clock, and IO. extensible io, expansion io, embedded design platform, programming digital and analog I/O, input capture output compare, analog io, digital io, timer io, built-in function library, easily programmed, 68HC11 processor, real time control, flash, EEPROM, RAM, RS232, RS485, serial communications, SPI, PWM pulse width modulation, battery-backed real time clock