D-Bug12 Program Demo
 
In this page, we will learn how to load a program into the HCS12 and run it using DBug12. The program we will use is "demo2_hcs12.abs.s1" which you created in the hcs12 stationery tutorial .
 
   1. Power on and connect the Dragon12 board to your PC as in Lab 1 using Hyperterminal (make sure your hyperterminal settings are as in Lab 1). Hit the 'reset' button on the Dragon12 board and verify that the D-Bug12 prompt shows.
 
   2. At the D-Bug12 prompt, enter 'load' (without the quotes). The cursor will jump to a new line and just sit there. In the Hyperterminal menu, choose 'Transfer > Send Text File'. A new window opens up. At the top of the window is a 'Look In' box - browse until you reach the directory where "demo_hcs12.abs.s1" is stored. Choose 'All Files (*.*)' in the 'Files of Type' box, and click on "demo_hcs12.abs.s1" so that it is selected and shows in the 'File Name' box.
 
   3. One or more asterisks '*' will show on the cursor line. There is an asterisk for each ten S-records that are successfully transferred.
 
      > Aside: In some cases, D-Bug12 may complain about the record length being too long. This is caused by Code Warrior using a long S0 header that includes path information (see the assembly IDE example for how to remove S0 path settings in the burner when creating an S-record). Since we don't need the S0 header for the DBug12 loader, in such cases simply open the .s1 file in a text editor (Code Warrior, Notepad, etc.) and delete the first line of the file that begins with "S0". We only need the S1 records and S9 records for loading the program with D-Bug12. You might want to save the modified .s1 file under a different name if you have another program that needs the original file which has the S0 header/path info.
 
   4. You have now loaded the "demo_hcs12.abs.s1" program into the RAM of the HCS12, and the program starts at address $1000. Type 'asm $1000' and step through the lines of the program to see the actual machine code and assembly mnemonics. Type in 'md 2000' and note the contents of the memory there. The screenshot looks like:
 
      
 
 
      
   5. Type 'g $1000' to run the program. The program automatically hits a breakpoint and terminates. Note that accumulator A has the value 42 ($42) which is the sum of $24 and $18. Using the >md $2000 command, note that the contents of addresses $2000, $2001 and $2002 are $24, $18 and $42 respectively (remember - in D-Bug12 memory values are always displayed in hex so no leading '$' is shown in the display). Also note that the contents of Port B at address $0001 also has the value $42, which is displayed by the LEDs.
 
 
   6. A screen shot of the D-Bug12 output is shown below.      
 
      
 
      > Some of the values in your DBug12 screen may be different than that shown above, depending on what's in the uninitialized RAM locations (such as that at address $100A). However, the initialized areas of RAM containing program code and data should be the same as shown above.
 
      > Also, the screen shots above may be slightly different to what you see if you use the Rev.E code which was added to the demo2_hcs12.asm program (this is the code at the beginning of the program which takes Port J low to enable the Port B LEDs).
 
 
 
Loading Programs with D-bug12