Motorola MC9S12DP256, CML12S-DP256 manual Assembling source code, AS12 HELLO.ASM -L Hello

Page 6

C M L 1 2 S D P 2 5 6

0 7 / 1 7 / 0 2

It is important to understand the 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 locate the code 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 $4000. You must start your DATA (or variables) in a RAM location unused by your program, for example: ORG $1000.

In “debug mode” you’ll be using a debugger utility (Mon12, NoICE, etc) which will handle initialization, interrupts vectors (reset, timers, etc), and the STACK. When finished debugging, you must add code to your application to handle the initialization of the CPU, STACK and possibly the Interrupt vectors. Some initialization is required to set the bus frequency, bus mode, internal EEprom and Flash memory programming clock rates, and others, see the CML-INIT.ASM file for a sample. Set the stack at the top of your available internal RAM below the Ram interrupt vector table, for example $3F80, in assembly this would be LDS #$3F80. Also install the RESET vector address in the Auto Start area, see the chapter in this manual.

If you are applying a software development tool that also provides a BDM cable interface to the board, the monitor installed in the flash is not required. The BDM software tools may have the capability to erase and program the flash memory. If this is the case, you may develop code in the external ram memory or internal flash without applying the monitor resources. The MON12 S record is provided on the support CD to program into the flash if desired. The BDM will allow locating programs in memory and applying resources reserved for the monitors.

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 (MAP) your code, data and stack.

Assembling source code

An example program called “HELLO.ASM” is provided under the \EXAMPLES\CML12 directory of the CD and if you installed AxIDE, under that programs \EXAMPLE directory. You must use the example for the MCU type installed on the CML12Sxxx board. For example use the CML12S-DP256 example on the DP256 version board.

You can assemble source code by using the AxIDE "BUILD" button or command line tools under a DOS prompt by typing:

AS12 HELLO.ASM –L HELLO

Most compilers and assemblers allow many command line options so using a MAKE utility or batch file is recommended if you use this method. Run AS12 without any arguments to see all the options, or see the AS12.TXT file on the disk.

The utility software, AxIDE, provided with this board contains a simple interface to this assembler. Use it by selecting "Build" from its menu. This will prompt you for the file to be assembled. NOTE: You must select your board from the pull down menu first, or it may not build correctly.

6

Image 6
Contents CML12S-DP256 Contents Getting Started Support Software Installing the SoftwareBoard Startup Modc = Out, JP2 = do not care, see COM PortsTutorial Software DevelopmentCreating Source Code Assembling source code AS12 HELLO.ASM -L HelloRunning your application Programming HCS12 Flash EEprom AutoMON12 Operation MON12 operation notesMon12 Monitor Commands MON12 Interrupt SupportMovw #IRQSRV,VIRQ Noice Operation MON12 and Noice Memory MapBDM Operation AutostartClock frequency = 24MHz Memen ECSMode ModcAuto OFF / spare OscselJP1 and JP2 Ports and ConnectorsTB1 and J1 Power CUT-AWAY Options 1Mcuport Analog PortPCOM1 and PCOM2 BusportKeypad / Port H 6 connected and 7,8 connectedCAN-H Can PortPCOM2 pin connections CAN-LLcdport Connector P1 P4 HCS12 Header RingLcdport See the HC12 Technical Reference Manual for complete BDM PortTest Points Documentation of the BDMTroubleshooting Tips and Suggestions LCD Command and Character Codes CommandCode Delay MON12 Interrupt Table