68HC11 Programmer's Reference Manual
Total Page:16
File Type:pdf, Size:1020Kb
68HC11 Programmer's Reference Manual Phillip Musumeci [email protected] November 1999 Version 1.7 Credits Engineer proofreading: Dr. Barbara La Scala; • Cross Assembler for 68HC11: Motorola; • University of Wollongong F1 system: Pete Dunster; and • Many different public domain software tools: many helpful users. • References 1. Gene H. Miller, \Microcomputer Engineering", Prentice Hall, Englewood Cliffs, NJ 07632, 1993. ISBN 0-13-584475-4. 2. Motorola, \HC11 | M68HC11 Reference Manual", Part number M68HC11RM/AD. 3. Frederick F. Driscoll, Robert F. Coughlin, Robert S. Villanucci, \Data acquisition and process control with the M68HC11 micro-controller", Merrill/Macmillan Inter- national, 1994. ISBN 002330555X 4. Joseph L. Jones and Anita M. Flynn, \Mobile Robots: Inspiration to Implementa- tion", A.K. Peters, Wellesley, Massachusetts, 1993. ISBN 1-56881-011-3. 5. P. Dunster, \F1 System Reference Manual", held in file F1V11DOC.PS in the archive ftp://mirriwinni.cse.rmit.edu.au/pub/UoW/f1v11doc.zip 6. P. Musumeci, \Introduction to Microprocessor Systems", lecture notes and data packs are available from http://mirriwinni.cse.rmit.edu.au/~phillip/intro2up Notes The latest release of this manual (PDF) is available from • http://mirriwinni.cse.rmit.edu.au/~phillip/intro2up. This document was prepared using the teTeX distribution of LATEX1, dvips, and • xdvi. The diagrams were processed using the graphicx and pdftex packages of LATEX, and the ps2pdf utility from ghostscript. The language aware editor xemacs was used to prepare input text before checking with ispell. A (Free)BSD computing environment has been employed. Feedback Please email reports of errors in this document or suggestions for its improvement to • [email protected]. c Phillip Musumeci, November 1999 1Feel the power of LATEX. i Contents 1 Introduction 1 1.1 Tools . 2 1.2 Command Entry . 3 1.3 Program preparation . 3 1.4 Setting up your assembly language tools . 4 1.4.1 Cross assembler | DOS . 4 1.4.2 Cross assembler | UNIX . 4 2 Software development cycle 5 2.1 Understand the problem . 5 2.2 Plan Structure of Program . 5 2.3 Data Structures . 5 2.4 Coding . 6 2.5 Assembling . 6 2.6 Downloading . 7 2.7 Target Machine Memory Map . 7 3 Object File Downloading 10 3.1 System = HC11 board + PC/DOS + kermit . 10 3.1.1 Procedure . 10 3.2 System = HC11 board + PC/DOS + procomm . 11 3.2.1 Procedure . 11 3.3 System = HC11 board + FreeBSD + X-windows + kermit . 11 3.4 Troubleshooting . 12 4 Assembler directives 14 4.1 Setting the Program Location Counter . 14 4.1.1 ORG | SET PROGRAM LOCATION COUNTER . 14 4.2 Setting Symbol and Label Values . 14 4.2.1 EQU | EQUATE SYMBOL TO A VALUE . 15 4.3 Memory Allocation . 15 4.3.1 RMB | RESERVE MEMORY BYTES . 15 4.3.2 FCC | FORM CONSTANT CHARACTER STRING . 15 4.3.3 FCB | FORM CONSTANT BYTE . 16 4.3.4 FDB | FORM DOUBLE BYTE CONSTANT . 16 4.3.5 FILL | FILL MEMORY . 16 4.3.6 BSZ | BLOCK STORAGE OF ZEROS . 16 4.3.7 ZMB | ZERO MEMORY BYTES (same as BSZ) . 16 4.4 Addressing Modes . 17 4.4.1 Register . 17 4.4.2 Zero Page and Absolute Addressing . 17 ii 4.4.3 Immediate . 17 4.4.4 Register Indirect (with offset) . 18 4.4.5 Bit Set/Clear . 18 4.4.6 Bit Test with Conditional Branch . 19 5 Assembler listing file format 20 A 68HC11 CPU Registers 22 B 68HC11 Instruction Set 23 C 68HC11 Vectors 27 C.1 Jump Vectors . 28 C.2 Buffalo Entry Points . 32 D Monitor Symbol Definitions 35 D.1 F1 symbols . 35 E Makefile Example 39 F Real{Time Interrupt Example 40 G Miscellaneous Information 43 G.1 RESET Bootup Code in BUFFALO ...................... 43 G.1.1 EVBU and BUFFALO .......................... 43 G.1.2 F1 and RMIT/CSE BUFFALO ...................... 43 G.2 Recovering from BULKALL with RMIT/CSE BUFFALO . 43 G.3 Enabling TRACE in BUFFALO ......................... 43 G.4 Setting A/D voltage range . 43 G.5 Mode setting for expanded mode . 44 G.6 Summary of Port Signals used by BUFFALO . 44 H 68HC11 Net Resources 45 I 68HC11 Overview 46 List of Tables 1 68HC11F1 system memory map. 8 2 EVBU 68HC11E9 system memory map. 9 iii 1 INTRODUCTION 1 1 Introduction There are a large number of 68HC11 devices and 68HC11 development systems available. It is possible for this generous choice to make initial use of a system confusing but fortunately, most of the low cost systems make use of the same monitor program, BUFFALO, which means that the programmer is presented with a common interface to the system and can make use of a common set of subroutine routines in the on-board BUFFALO ROM. Another characteristic of the 68HC11 family of devices, that they contain the same core set of internal peripherals, means users are presented with a fairly uniform piece of hardware to work with so confusion is avoided. Note that some recent devices now provide additional internal peripherals or have more flexible input/output ports. This document provides useful information for assembly language programmers who are just beginning to use a 68HC11-based µprocessor system. Code assembly and down- loading of object files is described for both UNIX and PC based software development environments, and a summary of assembler directives is provided. Appendices include a table of 68HC11 CPU instructions and a summary of important BUFFALO subroutine entry points and vectors. Where appropriate, specific information for the Motorola Universal Evaluation Board (EVBU) system and the University of Wollongong F1 system is given. The Motorola EVBU system supports a number of MC68HC11 variants including A8, E9, and 711E9 on a small PCB with a small prototyping area. These MC68HC11s have 512 bytes of EEPROM and 256 (A8) or 512 (E9,711E9) bytes of RAM. The A8 and E9 devices usually contain BUFFALO in ROM while the 711E9 contains EPROM that the user may program. Recently, the E series devices have had versions with larger EEPROM available, e.g. the 811E2 has 2K of EEPROM, while the A8 is no longer manufactured. The EVBU has an RS232 interface and a real time clock chip (MC68HC68T1) that is connected to the CPU via the serial peripheral bus. The Wollongong F1 system uses the MC68HC11F1FN device which contains similar internal peripherals to the A8 and E9 devices and the same amount of EEPROM but it has 0K bytes of internal ROM and 1K bytes of internal RAM. In this system, BUFFALO (and any other desired firmware) is stored in an external 32K EPROM. The board can also hold a 32K RAM device so tasks requiring additional storage are feasible. Much of the design of the system is in the public domain to assist the micro-controller enthusiast and the reference manual includes the complete circuit diagram and describes operation and construction of the CPU board plus the various configuration options (memory devices supported, etc). A list of part suppliers is included, with Australian and U.S.A. sources available for the (very) economical CPU PCB, a motor controller interface PCB, and a keypad and LCD module interface PCB. The various PCBs are relatively small and stack together in a compact manner suitable for mobile robot experiments. C language programming is also supported. Note that the F1 variant of the 68HC11 is available with clock frequencies of 8MHz (MC68HC11F1FN), 12MHz (MC68HC11F1FN3) and 16MHz (MC68HC11F1FN4) allowing a system \E" bus clock of 2MHz, 3MHz, and 4MHz respectively. Further details on this system may be obtained from the following sources: 1 INTRODUCTION 2 http://mirriwinni.cse.rmit.edu.au/~phillip/f1 • http://mirriwinni.cse.rmit.edu.au/~f1 • ftp://mirriwinni.cse.rmit.edu.au/pub/UoW • 1.1 Tools Many public domain tools exist for 68HC11 programmers, including: a 68HC11 assembler, as11, from Motorola; • a number of 68HC11 simulators, sim68hc11 by [email protected] and SIM68 by P. J. Fisch; • macro processors such as GNU m4 and GNU C cpp; and • C language support such as ICn a native C (subset) compiler (beta), and GNU gcc • 68HC11 port (no floats) by Otto Lind ([email protected]). Note that the as11 assembler and m4 macro processor are available for PC hosts (executa- bles) and UNIX hosts (source distribution). Section H lists internet sites from where the various tools may be obtained. In partic- ular, the ftp site ftp://mirriwinni.cse.rmit.edu.au/pub/uP/68HC11.local holds: zip archive files with names ending in .ZIP (uppercase) which contain copies of the tools • for PC hosts; files symbols.e9, symbols.f1w, symbols.f1p, and vectors which list symbols and • vectors for various 68HC11 systems; directory Sources which contains assembly language program examples, including file • memtest which is a basic memory test utility adapted from a Motorola 6800 monitor (the instructions for use are at the beginning of the source file); directory 68HC11 User Manual Examples which contains some assembly language pro- • gram examples distributed with the Motorola 68HC11 Reference Manual; directory buffalo-source which contains archives of the assembly language source and • hex files for various versions of the BUFFALO monitor program; and gzip{compressed tar archive file Motorola-8bit-asm-v2.09.tar.gz which is the source • for the cross assembler. A number of very economical tools are available for 68HC11 programmers, including: the HITECH integrated development systems | see http://www.hitech.com.au; • 1 INTRODUCTION 3 the ImageCraft C compiler (ICC), which runs under DOS and OS/2, provides a doc- • umented near ANSI C compiler, assembler, linker, and librarian; and the Dunfield Development Systems integrated development environment for the 68HC11 | for details, see file ftp://mirriwinni.cse.rmit.edu.au/pub/uP/FAQ/Microcontroller-primer+faq.