NoICE Debugger

HC12 Tutorials

Running NoICE for the first time

Connecting to hardware

Compiling for debugging

Source-level debugging

 
Home Download Purchase Tutorials FAQ NoICE Help

HC12: Running NoICE for the First Time

In most cases, you will be debugging programs at source level, using symbols rather than addresses. However, as an introduction to NoICE we recommend that you get some experience with the user interface first.

The first time you run NoICE after installing it, a dialog will appear asking you to choose a method of communications. For this section of the tutorial, we select "Simulator". (Some NoICE target processors, such as Z80 and 6502, do not have a simulator option. For these, you may wish to select "Dummy Target". This will let you use many NoICE commands, but will not allow you to execute programs.)
Simulator setup dialog
  • If you need to come back to this dialog, select "Options" from the NoICE main menu, then select "Target Communications".

  • Interface: we have selected "68HC12 simulator"

  • Processor Type: whe simulator supports the standard HC12/HCS12 instruction set, and the extended instruction set of the S12X. In this example, we will use only HCS12 instructions.

  • Use PPAGE: the 68HC12 can use PPAGE memory paging to get beyond 64K. We won't use this feature in this example

  • Use Simulated UART: can't do printf unless you have a UART.

By default, the simulator places the UART at the addresses appropriate for most non-S 68HC12 parts, such as the A4, DT128 etc.

Our example will be for a MC9S12DP256, using SCI0 as the serial port, so these are not the correct addresses.

Consulting the datasheet for the MC9S12DP256, we find that SCI0 status register SCISR1 is at address 0xCC and data register SCIDRL is at address 0xCF. Change the addresses as indicated. The TxReady and RxReady masks are correct as is, since the SCI register layout is the same regardless of the location of the SCI.

The UART address is important during simulation only insofar as you will need to make sure that you compile for the correct target in a later section of the tutorial. Don't worry, we will remind you.


Press "OK" in the Target Communications dialog, and NoICE will show an initial display like that shown below. If you exit NoICE and come back in, you will return right here. Initial NoICE display using simulator

Unlike a real 68HC12, the simulator initializes all memory to zeros. Since the reset vector contains 0000, that is where PC starts out. NoICE disassembles from the PC, showing a bunch of BGND instructions - op-code zero.

When NoICE starts up, it will disassemble instructions beginning at the initial PC address. If you are using the serial monitor, PC will be set to whatever value the monitor sets it to. If you are using BDM or one of the other built-in interfaces, PC may be set to the contents of the reset vector, or it may contain a garbage value. You can disassemble at any address by selecting View, Disassemble At..., and entering an address. Or use the "U" command in the command edit box in the NoICE toolbar. To continue disassembly, just click in the disassembly window and press the PageDown key.


Memory Edit: Click on the "Memory" tab near the bottom of the NoICE screen. Enter the address 2000 and press the "Read" button or the Enter key. Memory View

NoICE will show the contents of memory in hex and ASCII. To change the contents of memory, click on a byte and type hex characters: 55, 66, 77 in the screenshot above. Changed bytes are shown in red.

To edit the ASCII, click on a character in the ASCII field and type the desired characters.

Values are written to the target as you change each byte. Note that the memory window may not be suitable for use on I/O addresses, as extra reads and writes of I/O locations may cause undesired actions.

In addition to the Memory tab, you can edit memory using the EDIT, IN, and OUT commands. EDIT is most useful in conjunction with symbols and datatypes. IN and OUT are designed for access to I/O devices.

NoICE help on the Memory View

NoICE help on EDIT

NoICE help on DUMP

NoICE help on IN and OUT


Disassembly: We can view our changes to memory in the disassembly window by either

Selecting "View", "Disassemble At..." from the menu
Disassemble At dialog
or Clicking in the edit box on the Toolbar and typing the command "U 2000" and either pressing the "OK" button or the Enter key.
Disassemble At commnad

Either way, the result is some not very useful instructions Disassembly


Mini-assembler:

You will normally develop your code using an assembler or compiler.

However, NoICE includes a simple assembler so that you can enter assembly programs directly into RAM. This is useful for patching programs, and for entering short test sequences.

Select "Memory", "Assemble...". Then enter the address and instructions. Let's try a simple example: a program that increments a register and loops.

You can press "Assemble" after entering each instruction, or just use the Enter key.

Assembly dialog

Use the disassembly feature to see the results of your handiwork.


Registers:

The top window of the NoICE screen shows the values of the processor registers.

You can click on a register to change its value. Or select "Processor", "Change Register...".

If you would rather type than click, you can avoid the dialog by typing

    R PC 2000
in the command edit box in the toolbar.
Change Register dialog

Note that the disassembly line at address 2000 shows a yellow arrow indicating that the PC points here.

Disassembly showing PC


Single-step:

Press the F11 function key, or click the Step Into button on the toolbar. PC changes to 2002, A changes to 5, and the PC arrow in the disassembly window moves.

Note that the PC and A are shown in red to indicate that they have changed.

After single-step

Press F11 again. PC changes to 2003, and A increments to 6. You can continue stepping around the loop until you get bored.


Breakpoints:

Double-click on the address (2005) to the left of the INX instruction. A red target appears, indicating a breakpoint.

Breakpoint set

Now press F5, or the "Go" button on the toolbar. The program stops almost immediately at the breakpoint. A has a value of 0, having incremented until overflow.

Breakpoint set

Press F5 or click Go again. The program again stops at the breakpoint, but X has incremented.

NoICE help on Breakpoints

Remove the breakpoint by double-clicking on address 2005. Press F5 or click Go to let the program run free.

Note that the Go button shows as pressed and the title bar shows "running".

Press the Go button again to stop the program. Or use the "Halt" command.

Run/Stop button in run state


Loading a hex File:

Of course, you would probably prefer to use a C compiler or at least a decent assembler. Our next step is to load a Motorola S-record file. You can get our sample here

Select "File", "Load..." from the menu, or press the "bit funnel" on the toolbar. Then select the file. Don't worry about any of the other settings in the dialog.

LOAD dialog

This file contains an S9 record that specifies the starting address.

  S9032000DC

When NoICE reads this record, it sets PC and disassembles from this location.

Some assemblers and compilers set the S9 address at zero. In this case, you will need to set PC yourself.

This is a more interesting bit of code to step around in.

NoICE help on loading files

Disassembly after LOAD


Continue the tutorial with Compiling for Debugging

Continue the tutorial with Connecting to hardware

NoICE help

 
   
NoICE Debugger Copyright 2006 by John Hartman Revised 26 Deceember 2006