Download presentation
Presentation is loading. Please wait.
Published byNickolas Powers Modified over 9 years ago
1
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose This training module provides an overview of debugging features in H8S Simulator. Objectives Understand how to use the Simulator. Explore various debugging features: CPU status, registers, memory, breakpoints, and stepping. Content 21 pages 3 questions Learning Time 35 minutes
2
© 2008, Renesas Technology America, Inc., All Rights Reserved 2 H8S Simulator What is a simulator? A software development tool that runs on a PC and substitutes for the MCU Represents the MCU architecture and operating instructions Advantages of a simulator Enables debugging when target hardware is not available Helps reduce overall embedded system development time H8S Simulator functions CPU instructions Memory access Register access Complementary HEW features Help make the H8S Simulator more “hardware-like” Include simulated I/O, Trigger, and TCL toolkit
3
© 2008, Renesas Technology America, Inc., All Rights Reserved 3 Before Debugging Session Begins 1.Begin Project Generation 2.Select the Target CPU 3.Set the Target System for Debugging Selecting this option automatically generates a simulator session
4
© 2008, Renesas Technology America, Inc., All Rights Reserved 4 /********************************************************/ /* TUTORIAL PROGRAM */ /********************************************************/ #include #include "string.h" #define NAME (short)0 #define AGE (short)1 #define ID (short)2 #define LENGTH 8 const char LED[]={0x12, 0x12, 0x11}; struct namelist { char name[LENGTH]; short age; long idcode; }; struct namelist section1[] = { "Naoko", 17, 1234, "Midori", 22, 8888, "Rie", 19, 7777, "Eri", 20, 9999, "Kyoko", 26, 3333, "", 0, 0 }; int count; void sort(); void main(void) { count = 0; for ( ; ; ){ sort(section1, NAME); count++; sort(section1, AGE); count++; sort(section1, ID); count++; } void sort(list, key) struct namelist list[]; short key; { short i,j,k; long min; char *name; struct namelist worklist; switch(key){ case NAME : for (i = 0 ; *list[i].name != 0 ; i++){ name = list[i].name; k = i; for (j = i+1 ; *list[j].name != 0 ; j++){ if (strcmp(list[j].name, name) < 0){ name = list[j].name; k = j; } worklist = list[i]; list[i] = list[k]; list[k] = worklist; } break; case AGE : for (i = 0 ; list[i].age != 0 ; i++){ min = list[i].age; k = i; for (j = i+1 ; list[j].age != 0 ; j++){ if (list[j].age < min){ min = list[j].age; k = j; } worklist = list[i]; list[i] = list[k]; list[k] = worklist; } break; case ID : for (i = 0 ; list[i].idcode != 0 ; i++){ min = list[i].idcode; k = i; for (j = i+1 ; list[j].idcode != 0 ; j++){ if (list[j].idcode < min){ min = list[j].idcode; k = j; } worklist = list[i]; list[i] = list[k]; list[k] = worklist; } break; } Example: Tutorial program with sorting routine is used for simulation Enter Code Initialization Main Sort Switch to Simulator session
5
© 2008, Renesas Technology America, Inc., All Rights Reserved 5 Basic Debugging ViewDebug
6
© 2008, Renesas Technology America, Inc., All Rights Reserved 6 Basic Debugging: View Menu ViewDebug Display assembly code View CPU registers View memory View peripheral registers View CPU status View simulated I/O View/configure simulated interrupts View/configure labels View/modify variables View/modify local variables
7
© 2008, Renesas Technology America, Inc., All Rights Reserved 7 Basic Debugging: Debug Menu ViewDebug Execute code Reset CPU and execute code Execute until PC reaches the cursor position Set PC value and execute Display PC value Step into deeper level Step to the next line Step out to the higher level Download into target
9
© 2008, Renesas Technology America, Inc., All Rights Reserved 9 Download Module 1. Right click and select “Download module” to load module into simulator target 2. After downloading, the Simulator displays starting address for each line of C code Download into target
10
© 2008, Renesas Technology America, Inc., All Rights Reserved 10 View Status 1. Select to view CPU status 2. Status window shows memory and downloaded module information
11
© 2008, Renesas Technology America, Inc., All Rights Reserved 11 Disassembly 1. Select “Disassembly” to view corresponding assembly code 2. Right-click on “Disassembly” and select “Set Address” to set the starting address 3. Enter “000800” and click OK
12
© 2008, Renesas Technology America, Inc., All Rights Reserved 12 View Assembly Instructions 4. Disassembly window shows assembly code, starting from address 000800 (“main” function)
13
© 2008, Renesas Technology America, Inc., All Rights Reserved 13 Registers Window 2. Register values can be edited directly in the Registers window 1. Select to open Registers window
14
© 2008, Renesas Technology America, Inc., All Rights Reserved 14 Watch Window 2. Right-click in Watch window and select “Add Watch” 3. Enter “section1” and click OK 4. View values of “section1” array in Watch window 1. Select to open Watch window
15
© 2008, Renesas Technology America, Inc., All Rights Reserved 15 Examine Memory Content 1. Select to view memory content 3. Memory window appears. (Values of “section1” won’t be updated until “Reset Go” is executed) 2. Enter address of “section1” (from Watch window)
16
© 2008, Renesas Technology America, Inc., All Rights Reserved 16 Set and View Breakpoints 1. Right-click on line, then select “Toggle Breakpoint” 3. Select to open Eventpoint window 4. See all breakpoints in program 2. Red dot appears
18
© 2008, Renesas Technology America, Inc., All Rights Reserved 18 Execute Program 1. Select “Reset Go” to begin executing program 2. Execution stops at breakpoint. (Yellow arrow indicates current position of program counter.) 3. Register values are updated in Registers window. (Program counter value corresponds to position marked by yellow arrow in Edit menu.) Program Counter stopped at Breakpoint
19
© 2008, Renesas Technology America, Inc., All Rights Reserved 19 Content of Memory Window 4. See values of “section1” array
20
© 2008, Renesas Technology America, Inc., All Rights Reserved 20 Stepping Through the Code HEW also supports flexible stepping, which is accessible from the “Step...” menu option. Three basic levels of stepping: Step In - Takes you deeper into function call - Moves PC to start of sub-function Step Over - Executes current line of source code, including all instructions in sub-function - Moves PC to next line Step Out - Lets you go back to next-higher level of code; i.e., return from the function call
21
© 2008, Renesas Technology America, Inc., All Rights Reserved 21 Step In 2. Arrow in Edit window shows program counter position at the beginning of the called function after stepping Example: 3. Registers window updates program counter value If source line does not call a function, a Step-In operation is the same as a Step-Over operation. 1. Select “Step In” to go deeper into function call
22
© 2008, Renesas Technology America, Inc., All Rights Reserved 22 Step Over 2. Arrow in Edit window shows program counter position after stepping 3. Registers window updates program counter value 1. Select “Step Over” to step to the next line Example: If source line does not call a function, a Step-In operation is the same as a Step-Over operation.
23
© 2008, Renesas Technology America, Inc., All Rights Reserved 23 Step Out 2. Arrow in Edit window shows program counter position at the next line of the calling function after stepping 1. Select “Step Out” to go back to next higher level of code Example: 3. Registers window updates program counter value Before Step Out After Step Out
24
© 2008, Renesas Technology America, Inc., All Rights Reserved 24 Track Variable in Watch Window 2. “Step Over” to next line 1. Add the variable “count” to Watch window 3. Value of “count” is updated in Watch window Breakpoint Program Counter
26
© 2008, Renesas Technology America, Inc., All Rights Reserved 26 Definition of a simulator Key features of H8S Simulator Using H8S features for debugging Course Summary Download a free evaluation copy of HEW at: www.renesas.com/hew
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.