Tutorial, Creating source code – Motorola 68HC12BC32 User Manual

Page 5

Advertising
background image

5

TUTORIAL

This section was written to help you get started developing software with the CME-12B/BC
board. Be sure to read the rest of this manual as well as the documentation on the disk if you
need further information.

The following sections take you through the complete development cycle of a simple "hello
world" program, which sends the string "Hello World" to the serial port.

Creating source code

You can write source code for the CME-12B/BC board using any language that compiles to
Motorola 68HC12 instructions. Included on the software disk is a free Assembler and also a
freeware C compiler and Basic compiler.

You can write your source code using any ASCII text editor. You can use the free EDIT or
NOTEPAD programs that come with your computer. A better code editor can be downloaded
at: http://www.winedit.com. Once your source code is written and saved to a file, you can
assemble or compile it to a Motorola S-Record (hex) format. This type of output file usually
has a .MOT, .HEX or .S19 file extension and is in a format that can be read by the
programming utilities to be programmed into the CME-12B/BC board.

It's important to understand your development board's use of Memory and Addressing when
writing source code so you can locate your code at valid addresses. For example, when in
debug mode, you should put your program CODE in External RAM. In assembly language,
you do this with ORG statements in your source code. Any lines following an ORG statement
will begin at that ORG location, which is the first number following the word ORG, for example:
ORG $2000

.

You must start your DATA (or variables) in a RAM location unused by your program, for
example: ORG $1000. When finished debugging, you must change these ORG statements so
that your program is moved to a valid EEPROM area - somewhere after hex 8000. Do this by
putting an ORG $8000 in front of your Program CODE. Data may remain where it is or be
moved down to internal RAM starting at ORG $800. You must also program the STACK
register somewhere at the top of your available RAM, for example hex BFF. Do this with this
instruction as the first instruction in your program code: LDS #$0BFF.

A look at the example programs on the disk can make all of this clearer. If you're using a
compiler instead of an assembler, consult the compiler documentation for methods used to
locate your code and data.

Source code created to run under the D-bug12 monitor environment will be slightly different
than code written for stand-alone operation. The monitor contains interrupt and RESET
vectors that your code must provide when it's no longer running under the monitor. See the
Programming Flash EEPROM section for more information on this.

Advertising
This manual is related to the following products: