|
|
This page will help you establish a simple test program to determine if your 912D60 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 912D60 is operational or not. Note: While this looks very similar to the test procedure for my other HC12 boards, be warned that the addresses used here are specific to the 68HC912D60. 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 WorldAll 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 /c1000 /v0400 /s0800 /m6812 > hello12.asm
' as12 hello12.asm > hello12.lst
'
include "regs12.lib"
main:
' Turn off the COP
' Note that the D60 has a bug in its design that requires us to leave
' the DISR bit alone
pokeb copctl,peekb(copctl) and $F8
' 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 $1000 (/c1000), this is the start of Flash EEPROM on the 912D60 Variable storage is starting at $0400 (/v0400), this is the default position for RAM. The Stack has been set to $0800 (/s0800), 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 912D60 board. Downloading the S19 fileTo download your code, you need to use a BDM12 interface pod or equivalent. Here is the instructions for running db12 to download your code.
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.
C:\sbasic>sbasic hello12.bas /c1000 /v0400 /s0800 /m6812 > hello12.asm C:\sbasic>as12 hello12.asm > hello12.lst C:\sbasic>db12 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 + CPU is running. Can't display registers! S>config freq 8 Frequency set to 8000000 HZ S>config reset 912d60 cputype set to 912d60 S>reset D: D4D4 X: 0034 Y: 0006 SP: FFFE PC: FFFF CR: D8 cvzNIhXS FFFF FF0000 LDS $0000 S>fload hello12.s19 Talker loading Talker Loaded FFFE S>reset D: 00FC X: 0BFC Y: FFFE SP: 0BF4 PC: 1000 CR: D8 cvzNIhXS 1000 CF0800 LDS #$0800 S>u 1003 CD07E0 LDY #$07E0 1006 061009 JMP $1009 1009 87 CLRA 100A D616 LDAB $0016 100C 8400 ANDA #$00 100E C4F8 ANDB #$F8 1010 5B16 STAB $0016 1012 CC001A LDD #$001A 1015 5CC0 STD $00C0 1017 CC000C LDD #$000C 101A 5BC3 STAB $00C3 101C 161046 JSR $1046 101F 161035 JSR $1035 S> At this point, you will need to connect the 912D60 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 9600 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 912D60, and the program should print out Hello World! Testing the Serial EEPROMThe 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: Object Code: I am not going to list the code here, but you are welcome to take a look. IMPORTANT: Compile so that code is at $1000, RAM is at $0400, stack is at $800 Set your terminal program to 9600, 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. |