|
|
This page will help you establish a simple test program to determine if your 812A4 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 812A4 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 68HC812A4. 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 /cF000 /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 $F000 (/cF000), this is the start of EEPROM on the 812A4 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 812A4 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 load 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 + D: 0000 X: F16C Y: 0BDF SP: 0BFD PC: F000 CR: D8 cvzNIhXS F000 CF0BFF LDS #$0BFF S>reset D: 0015 X: F16C Y: 0BDF SP: 0BFB PC: F000 CR: D8 cvzNIhXS F000 CF0BFF LDS #$0BFF S>config reset 812a4 cputype set to 812a4 S>load hello12.s19 FFFE S>reset D: 0015 X: F16C Y: 0BDF SP: 0BF7 PC: F000 CR: D8 cvzNIhXS F000 CF0BFF LDS #$0BFF S>u F003 CD0BDF LDY #$0BDF F006 06F009 JMP $F009 F009 CC0000 LDD #$0000 F00C 5B16 STAB $0016 F00E CC001A LDD #$001A F011 5CC0 STD $00C0 F013 CC000C LDD #$000C F016 5BC3 STAB $00C3 F018 16F042 JSR $F042 F01B 16F031 JSR $F031 F01E 0C4865 BSET 8,Y #$65 S>g R> At this point, you will need to connect the 812A4 X1 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 812A4, 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 $F000, 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. |