Testing
Home Up Assembly Connections Operation Testing Documents

This page will help you establish a simple test program to determine if your 912B32 board is operational. For your first program, it would be preferrable if you tried this simple program. That will allow you to determine if your 912B32 is operational or not.

You should consider picking up a copy of SBASIC for the HC12. It is a simple version of the BASIC language that is free and known to work fairly well. You can find a copy by looking at http://www.seanet.com/~karllunt/sbasic.htm

Hello World

All good computers start with a hello world program. We are going to use a programming language called SBASIC to create, compile, and download a simple program that will determine if the serial port works. There are more complicated tests a little later.

If you don't want to mess around with getting SBASIC right now, you can find the pre-compiled version of this test program in hello12.s19. The original test file is in hello12.bas

'
' This simple basic program will print hello world to
' serial port 0
'
' Compile using
' sbasic hello12.bas /c8000 /v0800 /s0c00 /m6812 > hello12.asm
' as12 hello12.asm > hello12.lst
'
include "regs12.lib"

main:
        ' Turn off the COP
        pokeb copctl,0

        ' Enable serial port
        poke  sc0bdh, 26        ' Set for 19200 baud
        pokeb   sc0cr2,$0c      ' Enable transceiver

        print
	print "Hello World!"
	do
	loop

There are a few important things to point out about the above program. Compiling the sbasic program used a set of command line flags that I would like to point out.

The code starts at $8000 (/c8000), this is the start of Flash EEPROM on the 912b32

Variable storage is starting at $0800 (/v0800), this is the default position for RAM.

The Stack has been set to $0C00 (/s0c00), which is the end of RAM. The stack grows down.

I told the SBASIC compiler to output 68HC12 code (/m6812).

This should compile and generate a file called hello12.s19, which contains the object code for the 912B32 board.

Downloading the S19 file

To download your code, you need to use a BDM12 interface pod or equivalent. Here is the instructions for running db12 to download your code.

  1. Connect power to the POWER and regulated 12 volts to VPROG
  2. Connect your BDM12 interface pod to the 912B32 and to your PC's serial port
  3. Start db12.exe, which is the debugger.
  4. Use the config reset 912b32 command to set the debugger to the correct settings
  5. Use the reset command in db12 to stop the target board.
  6. Place the SW1 switch into PROG position
  7. Use the 'fload' command to load the .S19 file
  8. Use the 'reset' command to reset the cpu.
  9. Unassemble using the 'u' command. You should see 'real' instructions at the starting point.

At this point, you should have seen output looking something similar to the following. Note that the date of the debugger and some of the other values may be a little different before you issue the fload command.

db12 debugger (Apr  8 2001 at 18:21:27)
'help' will list commands
'quit' to exit
Connecting on COM1 at 115200 baud
Using RTS/CTS control. Firmware version 0x46 +
R>config reset 912b32
cputype set to 912b32
R>reset
D: 2100 X: 802A Y: 0BE0 SP: 0BFE PC: 8000 CR: F8 cvzNIHXS
8000 CF0C00           LDS   #$0C00
S>fload hello12.s19
Talker loading
Talker Loaded
FFFE
S>reset
D: 00FC X: 0BFC Y: FFFE SP: 0BF4 PC: 8000 CR: F8 cvzNIHXS
8000 CF0C00           LDS   #$0C00
S>u
8003 CD0BE0           LDY   #$0BE0
8006 068009           JMP   $8009
8009 CC0000           LDD   #$0000
800C 5B16             STAB  $0016
800E CC001A           LDD   #$001A
8011 5CC0             STD   $00C0
8013 CC000C           LDD   #$000C
8016 5BC3             STAB  $00C3
8018 168042           JSR   $8042
801B 168031           JSR   $8031
801E 0C4865           BSET  8,Y #$65
S>

At this point, you will need to connect the 912B32 SERIAL0 connector to a PC. If you have a second machine, you can connect it there. Otherwise, you may need to shut down db12.exe.

In either case, you will want to start Hyperterm or some other terminal program. Setup for 19200 on the baud rate. When you have done so (in Hyperterm, after setting the configuration, you may need to 'hang-up' then reconnect), you can press the reset button on the 912B32, and the program should print out Hello World!

Testing the Serial EEPROM

The next test program is written in Imagecraft C www.imagecraft.com/software

If you don't have Imagecraft C, you can just use the .S19 file I am providing.

Source Code:

sermem.h sermem.c memtest.c

Object Code:

memtest.s19

I am not going to list the code here, but you are welcome to take a look. Again, compile so that code is at $8000, RAM is at $0800, stack is at $C00

Set your terminal program to 19200, and let it run. It will do a three step test on the serial EEPROM, and also by running will tell you if the serial port is working correctly for output. You can also type 't' to run the full test, 'f' to run the Fill test, and 'd' to run the data test.