User`s manual

Dynamic C Users Manual digi.com 17
dialog box must be the same as the one the programming cable is connected to. (The Communications
dialog box is accessed via the Communications tab of the Options | Project Options menu.)
To check if you have the correct serial port, press <Ctrl+Y>. If the “BIOS successfully compiled …”
message does not display, choose a different serial port in the Communications dialog box until you
find the serial port you are plugged into. Dont change anything in this menu except the COM number.
The baud rate should be 115,200 bps and the stop bits should be 1.
3.1.1 Single Stepping
To experiment with single stepping, we will first compile DEMO1.C to the target without run-
ning it. This can be done by clicking the compile button on the task bar. This is the same as press-
ing F5. Both of this actions will compile according to the setting of “Default Compile Mode.”
(See “Default Compile Mode” in Chapter 14, for how to set this parameter.) Alternatively you may select
Compile | Compile to Target from the main menu.
After the program compiles a highlighted character (green) will appear at the first executable
statement of the program. Press the <F8> key to single step (or use the toolbar button). Each time
the <F8> key is pressed, the cursor will advance one statement. When you get to the statement:
for(j=0, j< ... , it becomes impractical to single step further because you would have to press
<F8> thousands of times. We will use this statement to illustrate watch expressions.
3.1.2 Watch Expression
Watch expressions may only be added, deleted or updated in run mode. To add a watch expres-
sion click on the toolbar button pictured here, or press <Ctrl+W> or choose “Add Watch” from
the Inspect menu. The Add Watch Expression popup box will appear. Type the lower case letter
“j” and click on either “Add” or “OK.” The former keeps the popup box open, the latter closes it. Either
way the Watches window appears. This is where information on watch expressions will be displayed. Now
continue single stepping. Each time you do, the watch expression (j) will be evaluated and printed in the
Watches window. Note how the value of “j” advances when the statement j++ is executed.
3.1.3 Breakpoint
Move the cursor to the start of the statement:
for (j=0; j<20000; j++);
To set a breakpoint on this statement, press <F2> or select “Toggle Breakpoint” from the Run menu. A red
highlight appears on the first character of the statement. To get the program running at full speed, press
<F9>. The program will advance until it hits the breakpoint. The breakpoint will start flashing both red and
green colors.
To remove the breakpoint, press <F2> or select “Toggle Breakpoint” on the Run menu. To continue pro-
gram execution, press <F9>. You will see the value of “i” displayed in the Stdio window repeatedly until
program execution is halted.
You can set breakpoints while the program is running by positioning the cursor to a statement and using
the <F2> key. If the execution thread hits the breakpoint, a breakpoint will take place. You can toggle the
breakpoint with the <F2> key and continue execution with the <F9> key.