This page provides links to a number of useful code examples for on the Wytec Dragon12 development board (freescale MC9S12DP256B/C) and/or the Wytec MiniDragon+ board.
HCS12 Serial Monitor -- Using Freescales HCS12 Serial Monitor on Wytec Dragon-12 boards
Protected programs -- Installing HCS12 Serial Monitor with protected user programs on the Dragon-12
SerMon on MiniDragon -- Installing HCS12 Serial Monitor with protected user programs on the MiniDragon+
RTMC9S12-Target -- A MATLAB/Simulink real-time target for MC9S12DP256 based systems
Laboratory handouts -- 8 introductory laboratory handouts
Lecture notes -- 8 introductory laboratory handouts
CodeWarrior Stationery -- A CodeWarrior stationery for the Dragon-12 with the HCS12 Serial Monitor
Example programs -- A collection of CodeWarrior sample projects for the MC9S12DP256 (C-language)
GNU gcc examples -- GNU gcc based examples (m6812-elf-gcc)
This link provides instructions for replacing the on-board monitor program DBug-12 by Motorolas HCS12 Serial Monitor. The latter is useful when working within the Metrowerks CodeWarrior IDE. The HCS12 Serial Monitor provides full access to CodeWarriors source level debugger Hi-Wave. A sample project (test_led) has also been included
This extension of the above project allows the installation of two ROM resident system programs which can be launched via the on-board switch SW7\2 of the Dragon12 board. SystemProgram1 provides a comprehensive self-assessment of the MC9S12DP256B/C this program uses features of a protective circuit board we have developed to safeguard our Dragon12 boards against the worst student abuse. The protective circuit board features two serially loaded D/A converters which are used to test the A/D converter unit of the microcontroller. The circuit diagrams as well as the PCB layout have been included with the documentation. SystemProgram2 simply displays the board ID on the LCD-display of the Dragon12. Both programs are in the protective area of Flash ROM (extended to 8 kByte); the total size of both programs must be less than 6 kByte. It is possible to extend this to a maximum of 14 kByte.
This is an adaptation of the above project for the MiniDragon+ board. Two ROM resident system programs can be launched via the on-board switches SW1 and SW2 of the MiniDragon+ board. At present, SystemProgram1 simply displays a 1 on the 7-segment display; SystemProgram2 displays a 2. Both programs are in the protective area of Flash ROM (extended to 8 kByte); the total size of both programs must be less than 6 kByte. It is possible to extend this to a maximum of 14 kByte.
This project opens the door to inexpensive rapid prototyping of real-time control systems on MC9S12DP256 based hardware. The present version works with MATLAB 6.5.1 (Release R13.1). A Simulink block diagram is turned into C-code using MathWorks Real-Time Workshop and Embedded Coder. The builder then calls upon Metrowerks CodeWarrior to compile the generated C-code into a real-time executable file which can be downloaded into the Flash ROM of the chip. Once installed, the real-time code can be controlled using Simulinks External Mode Interface. This fully integrates the target code and the initial model file. Target data is uploaded by a background task through the serial interface SCI1 and displayed through the regular Simulink block (e.g. Scope, Display, etc.). The model parameters of the Simulink model can be modified while the code is running. Every time a parameter is changed, Simulink updates the parameter record on the target. This on-the-fly parameter tuning capability makes it very easy to experiment with different controller settings. A number of hardware specific blocks have been provided to give access to the various hardware units of the microcontroller, e.g. both A/D converter units (ATD0, ATD1), the PWM unit, digital inputs and digital outputs as well as the two D/A converters on the protective circuit boards we use in our laboratory (Analog Devices, AD5311). User communication blocks allow the exchange of short user telegrams between the code running on the target and a second Simulink block diagram. The latter is completely independent of the target code. It allows the output of host-based Simulink models to be interfaced to the target. User communication blocks are useful in applications which rely on the download of high-level control data such as reference trajectories or information provided by a host-based vision system, etc. See the user manual (1.5 MB) for further details. A higher resolution version of this document can be downloaded here (3.4 MB).
The current release of this toolbox should be considered a beta release. A small number of known problems will still have to be addresses. The toolbox may also be ported to MATLAB 7.0 (R14) in the near future. Nevertheless, the present release runs reasonably well. At this stage, the Wytec Dragon-12 board as well as the MiniDragon+ can be targeted. The use of the toolbox on other target boards should be unproblematic. Most target specific parameters can be defined using the Real-Time Workshop options page (e.g. communication ports, supported baudrates, etc.). We will use this toolbox for undergraduate teaching in Mechatronics and Advanced Automatic Control as well as in a number of final year projects. Any feedback on what may still not work or what could be improved is highly valued and always welcome.
The following lab handouts have been written for and tested with the Dragon12 boards:
LMP6 The serial communication interface
The following lecture notes complement the above laboratory sessions. The make reference to the Infineon C167 microcontroller. However, all introduced topics can easily be transferred to Freescale 9S12 based systems (e.g. the Dragon-12). The accompanying programs can be run in simulation mode using the KEIL Integrated Development Environment mVision (3.0); a code-size limited evaluation version of this IDE can be downloaded from the KEIL web site.
The above programs are all based on the following CodeWarrior stationery:
The following sample programs accompany the above lab handouts:
Latest modifications and additions:
06/05/05 -- Fixed Pulse-Width Modulation program (didnt run properly at faster rates)
03/05/05 -- Fixed serial communication at low speeds (now works down to 300 bps)
28/03/05 -- Added sample programs to demonstrate the use of ring buffer based background communication
28/03/05 -- Added sample programs to demonstrate the use of the PWM unit
28/03/05 -- Added sample programs to demonstrate multi-channel A/D conversions
28/03/05 -- Updated all A/D based projects to use the corrected A/D complete conditions (CCF0 for single channel conversions)
17/02/05 -- IIC bus interface of all projects involving the D/A converters now actually clears the IBIF flag.
17/02/05 -- Stepper motor driver program (requires hardware driver circuit).
17/02/05 -- Sample project for the LCD module (code: Prof. Louis Bertrand, Durham University, Canada).
17/02/05 -- Serial communication routines for SCI1 now include support for signed and unsigned data types.
12/08/04 -- Serial communication tidied up both ports now work at all baud rates up to 115 kbps.
Frank Wornle ()
The University of Adelaide
School of Mechanical Engineering