UM0036 User Manual ST Visual Develop (STVD) Introduction Welcome to ST Visual Develop (STVD). STVD is a powerful, integrated development environment for ST microcontrollers. This Windows-based environment provides interfaces for all phases of application development, from building and debugging your application, to programming your ST microcontroller. New features described in this document are not present in earlier versions of STVD.
Contents UM0036 Contents 1 2 3 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.1 Building and debugging applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.2 Programming your microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.3 Advanced debugging features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.4 Getting assistance . . . . . . . . . . . . . . . . . .
UM0036 Contents 3.7 4 3.6.2 Find in Files 1 & Find in Files 2 tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.6.3 Debug tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.6.4 Console tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Customizing your work environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 3.7.1 Customizing editor features . . . . . . . . . . . .
Contents UM0036 4.9 4.10 5 Raisonance C compiler tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 4.8.2 Raisonance Assembler tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 4.8.3 Raisonance C linker tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Customizing build settings for Metrowerks C toolset . . . . . . . . . . . . . . . 131 4.9.1 Metrowerks C Compiler tab . . . . . . . . . . . . . . . . . . . . . . . . . . .
UM0036 Contents 5.9 7 Setting counters and conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 5.8.4 Showing breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Data breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 5.9.1 Inserting data breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 5.9.2 Using the Data Breakpoints window . . . . . . . . . . . . . .
Contents UM0036 7.2 8 7.1.3 Ignoring option bytes (ICC only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 7.1.4 Configuring option byte settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Using breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 7.2.1 Software breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 7.2.2 Hardware breakpoints . . . . . . . . . . . . . . . . . . .
UM0036 10 Contents 9.2.3 Reading coverage and profiling results . . . . . . . . . . . . . . . . . . . . . . . . 272 9.2.4 Typical examples of use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 EMU3 emulator features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 10.1 10.2 Trace recording . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 10.1.1 Trace buffer fields . . . . . . . . . . . . . . . . . . .
Contents 12 UM0036 STM8 C tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 12.1 12.2 12.3 12.4 12.5 13 8/385 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 12.1.1 Install the toolset and configure the STVD . . . . . . . . . . . . . . . . . . . . . 333 12.1.2 Create a workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 12.1.
UM0036 Contents 13.4 Creating a folder to organize files in the project . . . . . . . . . . . . . . . . . . . 370 13.5 Project settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 13.6 Build a version for debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 13.7 Building a version for programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 Appendix A Product support . . . . . . . . . . . . . . . . . . . . .
List of tables UM0036 List of tables Table 1. Table 2. Table 3. Table 4. Table 5. Table 6. Table 7. Table 8. Table 9. Table 10. Table 11. Table 12. Table 13. Table 14. Table 15. Table 16. Table 17. Table 18. Table 19. Table 20. Table 21. Table 22. Table 23. Table 24. Table 25. Table 29. Table 30. Table 31. Table 32. Table 33. Table 34. Table 35. Table 36. Table 37. Table 38. Table 39. Table 40. Table 41. Table 42. Table 43. Table 44. Table 45. Table 46. Table 47. Table 48. Table 49. Table 50. Table 51.
UM0036 Table 52. Table 53. Table 54. Table 55. Table 56. Table 57. Table 58. Table 59. Table 60. Table 61. Table 62. Table 63. Table 64. Table 65. Table 66. Table 67. Table 68. Table 69. Table 70. Table 71. Table 72. Table 73. Table 74. Table 75. Table 76. Table 77. Table 78. Table 79. Table 80. Table 81. Table 82. Table 83. Table 84. Table 85. Table 86. Table 87. List of tables Metrowerks C compiler language options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List of figures UM0036 List of figures Figure 1. Figure 2. Figure 3. Figure 4. Figure 5. Figure 6. Figure 7. Figure 8. Figure 9. Figure 10. Figure 11. Figure 12. Figure 13. Figure 14. Figure 15. Figure 16. Figure 17. Figure 18. Figure 19. Figure 20. Figure 21. Figure 22. Figure 23. Figure 24. Figure 25. Figure 26. Figure 27. Figure 28. Figure 29. Figure 30. Figure 31. Figure 32. Figure 33. Figure 34. Figure 35. Figure 36. Figure 37. Figure 38. Figure 39. Figure 40. Figure 41. Figure 42. Figure 43.
UM0036 Figure 49. Figure 50. Figure 51. Figure 52. Figure 53. Figure 54. Figure 55. Figure 56. Figure 57. Figure 58. Figure 59. Figure 60. Figure 61. Figure 62. Figure 63. Figure 64. Figure 65. Figure 66. Figure 67. Figure 68. Figure 69. Figure 70. Figure 71. Figure 72. Figure 73. Figure 74. Figure 75. Figure 76. Figure 77. Figure 78. Figure 79. Figure 80. Figure 81. Figure 82. Figure 83. Figure 84. Figure 85. Figure 86. Figure 87. Figure 88. Figure 89. Figure 90. Figure 91. Figure 92. Figure 93. Figure 94.
List of figures Figure 101. Figure 102. Figure 103. Figure 104. Figure 105. Figure 106. Figure 107. Figure 108. Figure 109. Figure 110. Figure 111. Figure 112. Figure 113. Figure 114. Figure 115. Figure 116. Figure 117. Figure 118. Figure 119. Figure 120. Figure 121. Figure 122. Figure 123. Figure 124. Figure 125. Figure 126. Figure 127. Figure 128. Figure 129. Figure 130. Figure 131. Figure 132. Figure 133. Figure 134. Figure 135. Figure 136. Figure 137. Figure 138. Figure 139. Figure 140. Figure 141.
UM0036 Figure 153. Figure 154. Figure 155. Figure 156. Figure 157. Figure 158. Figure 159. Figure 160. Figure 161. Figure 162. Figure 163. Figure 164. Figure 165. Figure 166. Figure 167. Figure 168. Figure 169. Figure 170. Figure 171. Figure 172. Figure 173. Figure 174. Figure 175. Figure 176. Figure 177. Figure 178. Figure 179. Figure 180. Figure 181. Figure 182. Figure 183. Figure 184. Figure 185. Figure 186. Figure 187. Figure 188. Figure 189. Figure 190. Figure 191. Figure 192. Figure 193. Figure 194.
List of figures Figure 205. Figure 206. Figure 207. Figure 208. Figure 209. Figure 210. Figure 211. Figure 212. Figure 213. Figure 214. Figure 215. Figure 216. Figure 217. Figure 218. Figure 219. Figure 220. Figure 221. Figure 222. Figure 223. Figure 224. Figure 225. Figure 226. Figure 227. Figure 228. Figure 229. Figure 230. Figure 231. Figure 232. Figure 233. Figure 234. Figure 235. Figure 236. Figure 237. Figure 238. Figure 239. Figure 240. Figure 241. Figure 242. Figure 243. Figure 244. Figure 245.
UM0036 Figure 257. Figure 258. Figure 259. Figure 260. Figure 261. Figure 262. Figure 263. Figure 264. Figure 265. Figure 266. Figure 267. Figure 268. Figure 269. Figure 270. Figure 271. Figure 272. Figure 273. Figure 274. Figure 275. Figure 276. Figure 277. Figure 278. Figure 279. Figure 280. Figure 281. Figure 282. Figure 283. Figure 284. Figure 285. Figure 286. Figure 287. Figure 288. Figure 289. Figure 290. Figure 291. Figure 292. Figure 293. Figure 294. Figure 295. Figure 296. Figure 297. Figure 298.
Introduction 1 UM0036 Introduction This chapter summarizes the features that are detailed later in this manual. 1.1 Building and debugging applications For building your application, STVD supports ST Assembler-Linker, Cosmic C, Raisonance C and Metrowerks C toolsets. Its graphic interface provides easy access to a range of options when building your application for debugging or programming your microcontroller.
UM0036 1.2 Introduction Programming your microcontroller When you are ready to program your application to your microcontroller, STVD provides a programming interface based on ST Visual Programming (STVP) software which supports a complete range of hardware for in-circuit, in-situ and socket programming. Table 2.
Introduction Table 3.
UM0036 1.4 Introduction Getting assistance For more information, application notes, FAQs and software updates on all the ST microcontroller families, check out the CD-ROM or our web site: www.st.com. For assistance on all ST microcontroller subjects, or for help using your emulator, refer to Appendix A: Product support. 1.5 Associated documentation This manual is released with STVD version 4.0.1 and contains some features that are not present in earlier versions of STVD.
Introduction 1.6 UM0036 Conventions The following conventions are used in the documentation: ● Bold text highlights key terms and phrases, and is used when referring to names of dialog boxes and windows, as well as tabs and entry fields within windows or dialog boxes. ● Bold italic text denotes menu commands (or sequence of commands), options, buttons or checkboxes which you must click with your mouse in order to perform an action. ● The > symbol is used in a sequence of commands to mean “then”.
UM0036 2 Getting started with STVD Getting started with STVD Once you have installed and launched ST Visual Develop (STVD), the following section will provide you with information to help you get started building, debugging and programming your application to your target microcontroller. The following sections will explain how to: 2.1 ● Section 2.1: Set the toolset and path information ● Section 2.2: Create a workspace with a new project ● Section 2.3: Add source files (.asm, .c, .
Getting started with STVD Note: UM0036 Workspace files for previous versions of STVD (.wsp) can be opened in STVD 3.0 and later versions. For information on migrating your workspaces to the new workspace format, refer to Migrating old workspaces (STVD7 2.5.4 and prior versions) on page 71. With the Create Workspace with New Project wizard you can quickly and easily: 2.2.
UM0036 2.2.2 Getting started with STVD Create a project in your workspace Figure 2. New project window In the New Project window: 1. 2. Enter the name of your project in the Project Filename field. Type the pathname where you want to store it. By default, this is the pathname you entered for your workspace. 3. Select your toolset (ST Assembler/Linker, Cosmic C or Metrowerks C) from the Toolchain list box. 4.
Getting started with STVD Figure 3. Note: UM0036 MCU selection dialog box If necessary, you can change the MCU selection later in the MCU selection tab of the Project Settings window. RESULT A project file (.stp) and its associated folders have been created in your workspace and appear in the Workspace window. Depending on your toolset, the folders and files listed in Table 5 are created in your project by default. Figure 4.
UM0036 Getting started with STVD Table 5. Default files and folders for projects Project default Folders Files Source files ST Assembler Linker Cosmic C X X interupt_vector.c Metrowerks C Raisonance C X X vector.c X main.c X X X Include files X X X X External dependencies X X X X modm.h 2.3 X X Add source files (.asm, .c, .s) to your project Source files (.asm, .c, .s) contain the code for building your application. To add the application source files to your project: 1.
Getting started with STVD Figure 6. UM0036 Workspace window Caution: When building with ST Assembler Linker, your application source files may need to be assembled in a specific order. To change the order of the files, you need to disable the Add Sorted Elements option in the workspace contextual menu. For more information, refer to Ordering source files before assembly on page 88. 2.4 Build your application Once you have created your project, you are in the Build context by default.
UM0036 Getting started with STVD Figure 7. 3. Project configurations window To view the project settings that have been applied, select Project > Settings. The Project Settings window opens and you can view the options for your toolset’s Compiler, Assembler and Linker, among others. You can also customize these options. For more information about the available options for your toolset, refer to Section 4.5: Configuring project settings on page 84. 2.4.
Getting started with STVD 2.5 UM0036 Select and connect to your debug instrument STVD allows you to debug your application using the Simulator (software only), or a range of debug instruments (emulators and in-circuit debugging hardware). 1. Once you have built your application for debugging, select Debug Instrument > Target Settings. 2. In this window, use the Debug Instrument Selection list box to select your debugging hardware (emulator or other device), as shown in Figure 9.
UM0036 Getting started with STVD Figure 10. Debug instrument target port selection The SWIM debugger has two additional parameters to define the target connection: 1. Out of workspace, you can connect in Hot Plug mode, which means the microcontroller is not put under reset while initializing the connection. For more details on Hot Plug mode refer to Section 7.4: In-circuit debugging in hot plug mode (SWIM only). Figure 11. Hot Plug start debug option 2.
Getting started with STVD UM0036 Figure 12. Restart with SWIM off option 2.6 Debug your application In the Debug context, STVD provides access to the commands and windows that are specific to debugging applications, and that are specific to your debugging instrument. Select Debug > Start Debugging to change from the Build context to the Debug context. RESULT: The commands in the Build menu are no longer available.
UM0036 Getting started with STVD Figure 13. Programmer window From this window, you have interfaces that allow you to: ● Select your programming hardware and mode ● Identify files to be programmed to specific Memory areas ● Configure the option bytes for your Flash microcontroller ● Monitor the status while your application is being programmed to your microcontroller For a complete description of features, refer to Section 11: Program on page 325.
Your STVD graphical environment 3 UM0036 Your STVD graphical environment These sections describe the layout of STVD: the various menus, toolbars and status indicators that will help you, whether you are building, or debugging your application. In particular the following sections provide information about: 3.1 ● Section 3.1: The main application window ● Section 3.2: The main menus and their commands ● Section 3.3: View windows ● Section 3.4: Workspace window ● Section 3.
UM0036 Your STVD graphical environment Figure 14. Main application window Status bar The status bar in the lower frame of the STVD main application window contains useful information about editor attributes and debugger status. Editor attributes such as keyboard states (for example CAPS On/Off, Type Over On/Off) are shown in the center of the bar.
Your STVD graphical environment 3.2 UM0036 The main menus and their commands STVD’s menus provide a range of common commands for general activities such as opening projects, or loading, editing and saving files, as well as access to build and debug commands. File menu The File menu provides standard commands for managing workspace and text files, including: New, Open, Close, Close All, Save, Save as, Save All, Print and Recent.
UM0036 Your STVD graphical environment Table 6. Edit menu commands (continued) Command Description Complete Word Opens the auto completion pop-up for a list of context specific keywords to complete the word you are typing. Parameter Info Opens the parameter information pop-up to see the syntax for the ASM instruction that you are typing. View menu The commands in the View menu open the Workspace, Output and Instruction Breakpoint windows when you are in the Build or the Debug context.
Your STVD graphical environment UM0036 Build menu The Build menu contains the commands that allow you to set the configuration for building your application, and to start and stop the build. These commands, with the exception of Compile and Batch Build, apply to the active project in your workspace. Compile applies to the source file that you have selected in the Workspace window. Batch Build applies to the projects that you identify in the Batch Build window.
UM0036 Your STVD graphical environment Table 9. Tools menu commands Command Description Customize Allows you to specify functions to add to the Tools menu (see Adding custom commands on page 67).
Your STVD graphical environment Table 11. UM0036 Help menu commands (continued) Command Description Instruction Set Contents... Opens the Table of Contents of the Instruction Set online assembler reference pages. Generate Support File Opens the Generate Information File for Support window for outputting log files that you can send to support when seeking assistance after an application crash. For details about these features, refer to Help and support features on page 70.
UM0036 Your STVD graphical environment Table 12. View windows (continued) Command Description Instruction breakpoints window Provides an interface for activating and inactivating instruction breakpoints and applying conditions and counters to them (refer to Instruction breakpoints on page 183). Watch window Displays the current value of selected registers or variables in decimal, hexadecimal or binary format (refer to Watch window on page 191).
Your STVD graphical environment UM0036 Figure 16. Workspace window tabs The project file contains the target file name, the settings for building the project and the files needed to build the application. Files can be organized in sub-folders. By default, a new project contains three folders: Source files, Include files and Dependencies. To open the Workspace window, either click on the Workspace window icon toolbar or, from the main menu, select View>Workspace.
UM0036 Your STVD graphical environment Depending on the element that you select in the Workspace window (workspace, project, folder, file), you will also find in the contextual menu the commands listed in Table 14. Table 14. Window-specific contextual menu commands Command Description Workspace contextual menu Add new Project to Workspace Opens the New Project Wizard, which leads you through the process of setting up a new project in the current workspace (see Creating new projects on page 80).
Your STVD graphical environment UM0036 This section provides a description of Editor window features, including: ● Editor window contextual menu ● Editing features ● Customizing editor features For more information about using the Editor window during debugging, refer to Editor debug actions on page 169. The integrated Editor windows are client windows that float in the main application window (see Figure 14 on page 35).
UM0036 Your STVD graphical environment File display and editing features The Editor window has a number of advanced features to help you view, navigate and edit your C and Assembler source files. Many of these features can be configured and enabled/disabled in the Options window (Tools>Options). The following features are illustrated in Figure 18: 1. Margin controls and information including line numbers, line selection and enabling/disabling of instruction breakpoints (see Margin features). 2.
Your STVD graphical environment UM0036 File folding This feature allows you to hide or display sections of C source code. Folds are created automatically for comments and {} braces as you write your code. Figure 19. File folding display and controls Folds are indicated in the margin by a minus (-) symbol and a vertical line ending in a short horizontal leg (see 1 & 2, Figure 19). Folded/hidden sections of code are indicated by a plus (+) sign and an unbroken horizontal line (see 3, Figure 19).
UM0036 Your STVD graphical environment Figure 20. Left margin features Bookmarks are particularly useful when editing large files. Bookmarks set in the Editor margin permit easy navigation between marked lines in a source file. They also serve as references for other tasks such as setting advanced breakpoints and conducting performance analysis. The bookmark icon is a rectangular, blue icon in the left margin of the Editor window (see 1, Figure 21).
Your STVD graphical environment UM0036 Editor status bar information The status information for each file in the Editor window is preserved when the file is deselected (including cursor column/line position), and displayed when the file is reselected. The status bar is divided into seven sections reporting current attributes of the Editor window, plus two sections reporting the debugger status. A black keyword indicates the attribute is active. When the keyword is gray, the attribute is inactive.
UM0036 3.5.1 Your STVD graphical environment Editor window contextual menu By right-clicking in any Editor window, you can access the contextual menu with options and commands that are specific to the editor functions. Figure 24. Contextual menu edit commands In the Editor window, you have access to the basic editing commands: Cut, Copy, Paste, Open Document and Find.
Your STVD graphical environment Note: UM0036 To edit source files during a debugging session, ensure that the Read-only source files feature has been disabled. To do this, select Tools>Options and click on the Edit/Debug tab, then uncheck the Read-only source files option. Then click on Apply and OK. Note that while this allows you to modify the application source files, you must recompile the executable file so that your changes are taken into account when running the application.
UM0036 Your STVD graphical environment If you have just created a new Assembler source file, the parameter information feature is not available until you have saved the file with the appropriate file extension: *.asm, *.s, *.S or *.inc. Figure 26. Parameter information tip Indentation During text entry, auto-indent returns the cursor to the column in which the previous line of text starts, so that the indent of the base line is preserved in subsequent lines.
Your STVD graphical environment UM0036 Brace matching When viewing and navigating in source code, brace matching highlights matching opening and closing braces – {}, (), [], <>. If you highlight a brace with the cursor, then the matching brace is highlighted in the same color. If you press CTRL+E, or select Edit>Match Brace, then the cursor moves to the corresponding brace. Figure 28.
UM0036 Your STVD graphical environment Find You can select the string for a search by placing the cursor anywhere in the string, highlighting it or typing it directly in the search window. If you place the cursor to select the string, the string for the search is delimited by white space or any other non-alphabetic and non-numeric characters. On the other hand, when you select by highlighting a string, the full string of characters regardless of the type of characters appears in the Find window.
Your STVD graphical environment UM0036 Figure 31. Find/replace window In addition to common find options (Match whole word, Match case), the Replace dialog box allows you to search for patterns of characters using Regular expressions. Find in files The Find in Files command allows you to search for any string in any number of file types within a given source directory.
UM0036 Your STVD graphical environment The results of your search are displayed in the Output window, by default in the Find in Files 1 tab, or in the Find in Files 2 tab if you select the option Output to pane 2. Figure 34. Find in Files tabs Go to This command opens the Go To window, permitting a line in a source file to be defined as the target for the Go To action. Figure 35.
Your STVD graphical environment Table 16. Meta character UM0036 Regular expressions (continued) Use Example * X[A-B]* finds any occurrences of X and X followed by Matches zero or more occurrences of the one or more occurrences of the defined set (X, XA, XB, specified characters XAA, XAB, XBB, XAAA, XAAB, ...) ^ Beginning of line indicator (when it precedes a search string and is not enclosed by brackets) ^X[A-B] finds only the occurrences of XA and XB at the beginning of a line.
UM0036 Your STVD graphical environment The tabs located at the bottom of the Output window area are used to flip through the different views available in the window. These tabs include: ● Build tab and Tools tab ● Find in Files 1 & Find in Files 2 tabs ● Debug tab ● Console tab If you right-click the mouse in the Output window tabs a contextual menu appears specific to that tab. For example, the contextual menu for the Build and Tools tabs is shown in Figure 37. Figure 37.
Your STVD graphical environment UM0036 Figure 39. Parser error selection options Once a parser is selected, you can use the Parse Errors and Jump to File option (a checkmark indicates that it is enabled). This option allows you to automatically jump to the source of any errors found during the build process by: 3.6.2 ● Double-clicking on the error line in the Build tab.
UM0036 Your STVD graphical environment to enter commands directly. However, in Section 5.18: Online commands on page 199, you will find several basic online commands for reference. This command console (shown in Figure 41) displays online output and allows you to enter commands at the command prompt, marked by '–>'. Figure 41. Output window, Console tab Caution: Under normal circumstances, the workspace must not be opened or closed, or a Quit Debugger command issued, from within this window.
Your STVD graphical environment 3.7 UM0036 Customizing your work environment STVD offers a flexible working environment for developing your application with Options and Customize windows to help you tailor STVD to your needs. Figure 43. Options and Customize windows The Options window (Tools>Options) provides several tabs, listed in Table 17, that allow you to enable, disable and configure STVD features. Table 17.
UM0036 Your STVD graphical environment Table 17. Options window tabs (continued) Tab name Description Edit/Debug Enable and disable Editor features related to debugging and editing. Refer to Section 3.7.1: Customizing editor features on page 61. Styles/Languages Configure the language specific syntax highlighting. Refer to Section 3.7.1: Customizing editor features on page 61.
Your STVD graphical environment UM0036 Edit/Debug tab Use the Edit/Debug tab to enable/disable and configure editor features related to editing source files and debugging your application. The tab is divided into the following areas: ● Edit and print ● Word wrap ● Debug ● Long line ● Line ending Edit and Print allows you to access the editing and printing options described in Table 18. Table 18.
UM0036 Your STVD graphical environment Table 19. Word wrap options (continued) Option Show Wrap Symbol Description These checkboxes specify the position of the red arrow symbol indicating a wrapped line: Before wrap - symbol is at right edge of the window before the wrap. After wrap - symbol is on the left side of the window after the wrap. Near text - symbol is next to the last text symbol before the wrap. Debug allows you to access the debugging options described in Table 20. Table 20.
Your STVD graphical environment UM0036 When you open a file with end of line characters that are different from the default line character style (the Editor is set to Windows style by default), STVD warns you and asks if you want to change them to the default style. If your file is read-only, STVD warns you that the characters are different from the default, but cannot give you the option to change them.
UM0036 Your STVD graphical environment Table 23. Syntax highlighting options (continued) Option 3.7.2 Description Font and Size These fields allow you to select the font and the font size (in points) to be applied to all text items. To change this configuration you can select Text as the display item and the changes you make will be applied to all the display items where Use Default is checked.
Your STVD graphical environment UM0036 Moving toolbars Toolbars can be transformed to independent always-on-top windows, by placing them over (or in part over) the main application window or on the desktop outside the frame of the STVD main application window. In this floating form they may be relocated by mouse dragging on the window title bar or any unoccupied area in the window.
UM0036 Your STVD graphical environment Rearranging toolbar icons 1. From the main menu select Tools>Options. 2. Select the Commands tab and select a Category from the list (see Figure 47). The icons for commands in the selected category are displayed. 3. To add a button to a toolbar, drag an icon from the Buttons field to any toolbar. To remove a button from a toolbar, drag an icon off the toolbar. Figure 47. Options window, Commands tab 4. 3.7.
Your STVD graphical environment UM0036 For example, imagine that you want to add a command that would link directly to an external editor (such as Windows® Notepad): 1. From the main menu, select Tools>Customize to open the Customize dialog box (shown in Figure 49). 2. Click Add. 3. In the Menu Text field, enter the new command keyword, which appears in the Tools menu—for example, Ext. Editor. 4. In the Command field, enter or browse to the executable file for the custom command, notepad.
UM0036 Your STVD graphical environment 6. In the Initial Directory field, you can specify the directory from which you want the command to be initialized. You can type the directory, browse to it, or specify it using the argument list shown. In our example, Notepad is initialized from C:\temp\. 7. Finally, there are two other options that can be used with Win32 console applications (DOS applications) only.
Your STVD graphical environment UM0036 Figure 52. Tool description 3.9 Help and support features From the Help menu you can access a variety of STVD features that have been designed to help learn about and use its most advanced features. These features include: ● STVD Online Help and Tutorial— provides detail information on using STVD with supported debug instruments.
UM0036 Your STVD graphical environment – Start.log– Contains the target debug and STVD version information. Old information is overwritten with the most recent, each time you enter a debug session (Debug>Start Debugging). – error.log– Contains information about errors that are specific to your debug instrument. This information is cleared each time you enter a debug session (Debug>Start Debugging). – downloader.log– Contains information regarding the last update of your debug instrument's firmware.
Your STVD graphical environment Table 25.
UM0036 Table 27. Your STVD graphical environment Migration steps 3-5 Step STEP 3: In the General tab, confirm that the toolset paths correspond to the installation on your PC. Some paths depend on options specified in the project settings. Related information For Metrowerks users, the library path used corresponds to the output format set in the Compiler tab: • for Hiware format - lib\ST7c\lib, • for ELF/DWARF 2.0 format - lib\ST7c\lib.e20 You can specify the ELF/DWARF 2.
Your STVD graphical environment Table 28. UM0036 Migration steps 6 and 7 (continued) Step Related information Cosmic users can specify additional Object Library Modules and Library paths to include during linking. Select General in the Category list box and enter the pathnames in the provided fields. Cosmic users can choose to generate an automatic link script (.lkf) file for linking, or to use an existing .lkf file. Select Linker Input in the Category list box. To use an existing .
UM0036 4 Project creation and build Project creation and build STVD provides a build interface that allows you to control the building of your application for debugging or for programming to your target microcontroller. When you first open STVD, by default you are in the Build context. In this context, you will set up your workspace and project(s), configure project settings and build your application. The following sections provide information about the build interface, including: 4.1 ● Section 4.
Project creation and build UM0036 Toolset path information Upon installation, STVD will attempt to identify the toolsets and their paths. You can confirm or modify default path information for the supported toolsets by selecting Tools > Options (see Figure 54). The resulting Options window provides a Toolset tab that allows you to specify the Bin, Include and Library paths for your toolset on your host PC.
UM0036 Project creation and build Opening a .stw workspace To load a workspace (*.stw) created by STVD7 3.0 or later versions, select File > Open Workspace. The Open Workspace browse window will open. Locate the workspace file (.stw), highlight it, and then click on Open. The workspace will appear in the Workspace window, typically on the left side of STVD’s main window (see Figure 55). Figure 55. Workspace window Opening a .wsp workspace from STVD7 prior to version 3.
Project creation and build Note: UM0036 If a pop-up message appears indicating that your makefile was not found, click on OK and then check that your makefile is in the same directory as the .wsp that you are trying to open. 4. In the MCU Selection window, pick the target microcontroller for your application from the list, click on Select and then OK. 5. Select File > Save Workspace from the main menu bar. A workspace in .stw format is created in the working directory.
UM0036 Project creation and build Create a workspace by wrapping an executable You can create a workspace for an executable file (.abs, .elf, .hex, .s19) for debugging. However, during debugging you will only have access to the disassembled code and not the original source code. 1. To create your workspace, select the Wrap Executable icon and click on OK. A browse window opens. 2. Highlight the executable file that you want to use to create your workspace and click on Open.
Project creation and build 5. UM0036 Select the MCU for you application and then click on OK. Your workspace is created and named makefile_name.stw. The new workspace file appears in the Workspace window, typically on the left side of STVD’s main window. Your workspace contains a project with the makefile that you have identified and the External Dependencies folder.
UM0036 Project creation and build Add a project (.stp) to your workspace Click on the New Project icon and then OK. This launches the New Project wizard as shown in Figure 56. In this window you will enter all of the information required to create the project including: ● A project name in the Project Filename field. ● The path name where you want to store the project and the resulting files in the Project Location field. The path for the workspace is used by default.
Project creation and build UM0036 Create a project from an existing executable To create a project from an executable (.abs, .elf, .hex, .s19): 1. Select the Create from Executable icon and click on OK. You will receive an information message asking you if you want to create a project to wrap the executable. 2. Click on OK to continue. The New Project window opens. 3. Here enter a name for the project file (.stp) and the project location. By default, your project is named executable_filename.
UM0036 4.3.3 Project creation and build Adding and removing folders and files Projects contain the files that you will use to build your application. These can be organized in folders. By default, projects contain the following folders: ● Source Files — this folder contains the source files (.asm, .c, .s) that you identify for the building of your application. ● Include Files — this folder contains header files required to build your source code.
Project creation and build UM0036 saved as Build Configurations so that you can easily switch between two or more configurations. The name of each build configuration also corresponds to a folder in your project directory that is created automatically by STVD (for example, the Debug configuration corresponds to the Debug folder in your project directory).
UM0036 Project creation and build Some aspects of this interface are common to all toolsets, these common tabs are described in the following sections: ● General settings tab ● Debug settings tab ● MCU selection tab ● Pre-link settings tab ● Post-build settings tab Several tabs are specific to your toolset. STVD’s graphical interface adapts automatically to the toolset that you specify for your project in the General tab of the Project Settings window.
Project creation and build 4.5.2 UM0036 Debug settings tab This tab allows you to specify common settings for debugging your application. To access this tab, select Project > Settings to view the Project Settings window. Then click on the Debug tab. Here you can specify: ● the Executable that you want to debug. By default, STVD will look for the target file specified by the linker. However, you can also use the browse button to locate an executable file manually. ● the Debug working directory.
UM0036 Project creation and build The current microcontroller setting is displayed in the gray Selected MCU field at the bottom of the tab. The MCU field to the left displays a complete listing of supported microcontrollers. When you highlight an MCU name in the MCU field, colored indicators tell you which debug instruments support the highlighted MCU.
Project creation and build 4.6 UM0036 Customizing build settings for ST Assembler/Linker toolset The ST Assembler/Linker toolset builds your application from source code that is written in Assembler language. Building requires the following steps: ● Assembler: Translates assembler source code into objects and generates listings with relative addresses. ● Linker: Links objects from the source code and any included objects from libraries in a .cod file. ● OBSEND: Translates the .
UM0036 Project creation and build link and Post-Build) and three tabs that contain options and settings that are specific to ST Assembler/Linker toolset. This section provides details about configuring the options that are specific to the ST Assembler/Linker toolset. These options include: Note: ● ST ASM tab ● ST Link tab ● ST Post-Link tab For more details regarding options for this toolset, refer to the ST Assembler-Linker User Manual.
Project creation and build UM0036 Include paths The Include path field introduces the -I option in the command line. This option allows you to specify search paths for files to be included during assembly. To enter a path, start typing the path, or use the browse button to identify the path. When typing the path, the -I option is automatically added to the command line. To define a second path, type a semicolon (;) and then the second path. Again, the -I option is automatically added to the command line.
UM0036 Project creation and build The source file with the segment declarations (default is mapping.asm) is regenerated each time you build the application when the Auto feature is enabled. If you make changes to the file and Auto is enabled, your modifications will be overwritten when STVD updates the file based on the mapping in the Linker tab. This file must always be assembled first as the segment names are used in the other source files in your project.
Project creation and build Table 30. UM0036 Formats for OBSEND output Format Intel Hex (i) Description Intel hexadecimal format Intel Hex extended (ix) Intel hexadecimal format allowing 32 bit addressing Motorola S-record (s) 4.6.3 Motorola hexadecimal format with 16 bytes of data per line ST Post-Link tab The ST Post-Link tab allows you to view any instructions that entail post-link actions that result from the options or settings that you have made in the other tabs of the Project Settings window.
UM0036 4.7 Project creation and build Customizing build settings for Cosmic C toolsets The Project Settings window for building your application with the Cosmic C toolset contains five tabs that are common to all the toolsets (General, MCU selection, Debug, Prelink and Post-Build) and three tabs that contain options and settings that are specific to the Cosmic C compiler toolsets. This section provides details about configuring options that are specific to the Cosmic C toolset.
Project creation and build UM0036 Figure 62. Standard options To further customize options, select a category in the Category list box, or select Customize in a list box for a category of settings. The view in the tab will change to present more options (see Figure 63). You can enable or disable options by clicking on the check boxes. When you invoke an option, the change to the command line is immediately visible in the gray Command Line window at the bottom of the tab. Figure 63.
UM0036 4.7.1 Project creation and build Cosmic C compiler tab The C Compiler tab provides an interface for setting the options in the command line for the Cosmic C compiler for ST7 (cxst7) or for STM8 (cxstm8). The gray Command line field, displays all the changes to the command line as you make them. Figure 64. Cosmic C compiler general view The Category list box allows you to access a general view for easy access to standard settings and options.
Project creation and build UM0036 General settings for Cosmic toolset With the category set to General, you can access the following standard settings and options: ● Compiler memory models ● Debug information ● Optimizations ● Compiler messages display ● C language ● Listings ● Preprocessor definitions ● User-defined options Compiler memory models You can choose to compile your application according to one of the predefined memory models that can help you optimize your code’s size and perf
UM0036 Project creation and build Table 32.
Project creation and build UM0036 When the category is set to General, the standard optimization options for ST7 are: ● Default: The following optimizations are employed by default: – Uses registers a and x to hold the first argument of a function call if the function call does not return a structure and is a “char,” “short,” “int,” “pointer to” or an “array of” type function call. – Performs operations in 8-bit precision if the operands are 8-bit. – Eliminates unreachable code.
UM0036 Project creation and build Listings The Listing settings allow you to generate a listing file and log errors to a file. Listings are also used in generating jump tables when you optimize your code (see Customizing Cosmic C compiler optimizations on page 101. General, the standard Listing options are: ● None: Removes the -l option from the command line so no listing is generated. ● C and Assembly: Adds the -l option to the command line to generate a listing with the filename application.ls.
Project creation and build UM0036 Figure 65. Cosmic C debug information view In this tab view, you can choose from the optimization options described in Table 33. Table 33. Cosmic C compiler debug information options Option(1) Description Generate Debug Info (+debug) Produce complete debugging information that will allow you to take full advantage of STVD’s debugging features.
UM0036 Project creation and build Customizing Cosmic C compiler optimizations To further customize optimizations, select Customize from the list box. Alternatively, from the Category list box, select Optimizations. The view in the C Compiler tab changes to that shown in Figure 66. Figure 66. Cosmic C compiler optimizations view In this tab view, you can choose from the optimization options described in Table 34. Table 34.
Project creation and build Table 34. UM0036 Cosmic C compiler optimization options (continued) Option(1) Description Display removed/modified instruction statistics (-ov) Write a log of modifications to STDERR. This displays the number of removed instructions followed by the number of modified instructions. No Constant Propagation (-pcp) Introduces the -pcp option on the command line, which disables the constant propagation optimization.
UM0036 Project creation and build Figure 67. Cosmic C language view In this tab view, you can choose from the C language options described in Table 35. Table 35. Cosmic C compiler language options Option(1) Description Don’t make public symbols with Do not produce an xdef directive for the equate names absolute addresses (-gna) created for each C object declared with an absolute address. Enforce Type Checking (+strict) Instructs the compiler to enforce stronger type checking.
Project creation and build Table 35. UM0036 Cosmic C compiler language options (continued) Option(1) Description Interpret Plain char as Type unsigned char (-pu) Take a plain char to be of type unsigned char, not signed char. This also affects strings constants. Authorize Constant and Volatile Repetition (-pc99) Adds the -pc99 option to the command line, which enables the repetition of the const and volatile modifiers in the declaration either directly or indirectly in the typedef.
UM0036 Project creation and build Customizing Cosmic C compiler preprocessor definitions When the Category list box is set to Preprocessor, the view in the tab changes to that shown in Figure 69. In addition to adding preprocessor commands (-d), this view allows you to add include directories (-i). Figure 69. Cosmic C compiler preprocessor view When entering a Preprocessor definition (-d), you specify the name of a user-defined preprocessor symbol.
Project creation and build UM0036 Figure 70. Cosmic C compiler input view The input options are: ● Treat Source files as C files (-ec) ● Treat Source files as Assembler files (-es) Customizing Cosmic C compiler output options When the Category list box is set to Output, the view in the tab changes to that shown in Figure 70. This view allows to specify the options listed in Table 36. This view is not available with the ST7 C compiler versions under 4.4. Figure 71.
UM0036 Project creation and build Table 37. Cosmic C compiler output options Option(1) Description Far Library Calls (-gfl) (STM8 only) Adds -g to the command line to invoke the code generator with the fl option, which uses callf instructions for machine library calls. This is used in conjunction with memory models for large applications. This option is not available with the ST7 C compiler versions under 4.4.
Project creation and build UM0036 The Category list box allows you to access a general view for easy access to standard settings and options. You can also change the category to access views where you can customize settings in greater detail. In this list box you can choose from the following views: ● General: We recommend starting in the General settings for Cosmic Assembler view.
UM0036 Project creation and build Table 38. Cosmic Assembler debug options Option(1) Description Generate full (-xx) Generate debug information for any label defining code or data in the object files, that will allow you to take full advantage of STVD’s debugging features. Generate line (-x) Add only line debug information to the object file. This information provides the debugger the link between a line of source code and the beginning and end address of an instruction in the compiled application.
Project creation and build Table 40. UM0036 Cosmic Assembler listing options Option(1) Description Basic (-l) Generate a listing file. The name of the file is name_of_input_file.ls, unless you use the +l option to specify the name of the file. With errors on undefined symbols (-u) Produces an error message in the listing file for all occurrences of an undefined symbol. Generate error log file (+e*) Generates an assembler error log instead of displaying the error messages on screen. 1.
UM0036 Project creation and build General settings for Cosmic linker With the category set to General, you can access the following standard options: Output filename option Allows you to specify the name for the output file. By default, this field contains a macro that will specify the project source in .elf format. Std. libraries Select whether to use the Int or Float libraries by checking the appropriate box. If Int is checked, the builder inserts the standard integer library in the .lkf template.
Project creation and build UM0036 The Startup File list box allows you to choose to use one of the provided startup files. The list of startup files is different for the ST7 and STM8 toolsets. For a complete description of startup files, refer to the C Cross Compiler User’s Guide.
UM0036 Project creation and build , LIBRARY_FILES>, VECTOR_FILE>, DEFINED_VARIABLES>, If you want to stop STVD automatic update for one section, simply remove both BEGIN/END markers of this section.You may restore the mechanism later by restoring the markers. In Automatic mode, a configurable mapping is displayed in the Linker tab.
Project creation and build ● UM0036 Protect - Protects the selected code section from optimization. Adds the -k option to the selected item in the link script file. Code sections that you have applied protection to are displayed in red. Vector file name and Vector address By default, the filename is set to stm8_interrupt_vector.c for STM8. You can change the name of the interrupt vector file and also the interrupt vector table start address.
UM0036 Project creation and build Figure 76. Cosmic linker output view In this view, the options listed in Table 41 are available. Table 41. Cosmic linker output options Option(1) Description Generate Error File You can choose to generate an error file by checking this option, and entering the name for the error file in the field provided. By default, this option is not enabled. Generate Map File You can generate a map file by checking this option and entering a map file name in the field provided.
Project creation and build 4.8 UM0036 Customizing build settings for Raisonance C toolset The Project Settings window for building your application with the Raisonance C toolset contains five tabs that are common to all the toolsets (General, MCU selection, Debug, Prelink and Post-Build) and three tabs that contain options and settings that are specific to Raisonance. This section provides details about configuring options that are specific to the Raisonance toolset.
UM0036 Project creation and build Figure 77. Standard options To further customize options, select a category in the Category list box, or select Customize in a list box for a category of settings. The view in the tab will change to present more options (see Figure 78). You can enable or disable options by clicking on the check boxes. When you invoke an option, the change to the command line is immediately visible in the gray Command Line window at the bottom of the tab. Figure 78.
Project creation and build 4.8.1 UM0036 Raisonance C compiler tab The C Compiler tab provides an interface for setting the options in the command line for the Raisonance C compiler for ST7 and STM8. The options available on the C compiler tab view correspond to the microcontrollers that are selected on the MCU Selection tab view. The gray Command line field displays all the changes to the command line as you modify the settings in the graphical interface. Figure 79.
UM0036 Project creation and build General settings for the Raisonance toolset With the category set to General, you can access the following standard settings and options, as shown in Figure 79: ● C language ● Listings ● Optimizations ● Global variables ● Locals and parameters (disabled for STM8 microcontrollers) ● Generate debug info ● User-defined options ● Program model (STM8 only) C language The C language settings allow you to define the programming language styles to apply while comp
Project creation and build UM0036 When the category is set to General, the standard optimization options are: ● Default optimization: The following optimizations are employed by default and cannot be disabled: – Expressions are reduced to constants whenever possible – Internal data and bit access optimization – Jump optimization ● Speed optimization: When you select this option, the category displayed changes to Optimizations. A list of options for speed optimization is displayed.
UM0036 Project creation and build Customizing Raisonance C compiler optimizations On the C Compiler tab of the Project Settings window, in the Category field, select Optimizations to display the view shown in Figure 80. Alternatively, when the category is set to General, in the Optimizations field, select either Speed Optimization or Size Optimization. Figure 80.
Project creation and build Table 42. UM0036 Raisonance C compiler optimization options Description(1) Level 0 No optimization 1 – – – – – – – 2 Loop performance optimization 3 Peephole optimization Dead code elimination Overlayable data is identified for linker optimization Conditional jump optimization Complex move operations optimization Switch optimization Loop optimization Local and global sub-expression optimization 1.
UM0036 Project creation and build In the C Language field, you can choose: ● Default: compiler default language options ● Ansi Mode Restricted: automatically selects the ANSI-compliant mode ● Customize: the options available when you select this mode are described in Table 43. Table 43. Raisonance C compiler language options Description(1) Directive ENUMTYPE Defines whether enum variables are handled as char or int (char by default).
Project creation and build UM0036 From the Listings field, you can choose: ● None: all options are grayed out. ● Default listing: automatically selects the default options, see Listings on page 119. ● Preprocessor listing: automatically selects the option Generate a preprocessor listing file. ● Customize: displays a list of options that you can select individually. These options are described in Table 44. Table 44.
UM0036 Project creation and build Adding preprocessor definitions When entering a preprocessor definition, you must specify the name of a user-defined preprocessor symbol. The form of the definition is: DF(symbol[=value]) If the value is omitted, it is set to 1. When entering definitions, the DF option is automatically added to the command line as you type the symbol. When you enter several definitions, separate them with a space or a comma.
Project creation and build UM0036 The category list box gives you access to the following views: ● General, see General settings for Raisonance Assembler ● Listings, see Customizing Raisonance Assembler listings General settings for Raisonance Assembler When the category is set to General, the options available are identical to the preprocessor view of the C Compiler tab, already described in Customizing Raisonance C compiler preprocessor definitions on page 124.
UM0036 4.8.3 Project creation and build Raisonance C linker tab The Linker tab of the Project Settings window provides an interface for setting the options in the command line for the Raisonance C linker. The gray Command line field displays all the changes to the command line as you make them through the graphical interface. Figure 85.
Project creation and build UM0036 General settings for Raisonance linker When the category is set to General, you can access the following standard options: ● Output filename Allows you to specify the name for the output file. By default, this field contains a macro that specifies the project source in *.elf format. ● Object/Library modules Use this field to enter the names for custom libraries or object modules to include in the build. You do not need to specify standard libraries.
UM0036 Project creation and build Customizing Raisonance linker input settings On the Linker tab of the Project Settings window, in the Category field, select Input to display the view shown in Figure 86. Figure 86. Raisonance linker input view Note that variables are automatically allocated a memory location. For information on memory relocation directives, refer to the Raisonance ST7 Linker/Locator Manual.
Project creation and build UM0036 Figure 87. Raisonance linker output view The following options are available in this view: ● Generate map file You can generate a map file by checking this option and entering a map file name in the field provided. By default, this option is checked, and a map file is generated with the output path name and the extension .map. The available map file options are described in Table 46. By default, all options are turned on.
UM0036 4.9 Project creation and build Customizing build settings for Metrowerks C toolset The Project Settings window for building your application with the Metrowerks C toolset contains five tabs that are common to all the toolsets (General, MCU selection, Debug, Prelink and Post-Build) and three tabs that contain options and settings that are specific to Metrowerks. This section provides details about configuring options that are specific to the Metrowerks toolset.
Project creation and build UM0036 Using the Project Settings interface The tabs (C Compiler, Assembler and Linker) have a common interface that allows you to choose from standard configurations, customize options and view changes to the command line as you apply different options. When the Category list box is set to General, the tab provides check boxes and list boxes for easy access to commonly used options and configurations (see Figure 88). Figure 88.
UM0036 Project creation and build Figure 89. Customizing options 4.9.1 Metrowerks C Compiler tab The C Compiler tab provides an interface for setting the options in the command line for the Metrowerks C compiler. The gray Command line field displays all the changes to the command line as you make them. Figure 90.
Project creation and build UM0036 The Category list box provides a choice of standard options to choose from. For descriptions of standard options and information about further customizing them, refer to the category sections below: ● General: We recommend starting in the General settings for the Metrowerks toolset view.
UM0036 Project creation and build Message Display With the Category list box set to General, you can choose what types of messages to generate from the following options: ● Errors + Warnings: Introduces -W1 option in the command line, which suppresses the generation of information messages. ● Only Errors: Introduces -W2 option in the command line, which suppresses the generation of error and warning messages. ● Errors + Warnings + Info: No option in the command line.
Project creation and build UM0036 When the Category list box is set to General, the standard listing options are: ● C and Assembler Listing: Adds -Lasm option to the command line. The output is filename.lst. ● No Listing ● List of Include Files: Adds -Li option to the command line. The output is filename.inc. ● Preprocessor Output: Adds -Lp option to the command line, which generates a text file containing the preprocessor output. The output is filename.pre.
UM0036 Project creation and build User-defined options This field allows you to enter the command for an option that you have defined for the C compiler. The options that you type in these fields are immediately added to the command line below. For more information on creating user-defined options, refer to Metrowerks’ STMicroelectronics ST7 Compiler reference manual. Customizing Metrowerks compiler optimizations To further customize optimizations, select Customize from the Optimizations list box.
Project creation and build Table 48.
UM0036 Project creation and build Figure 92. Metrowerks C compiler input view In this view, you can choose from the optimization options listed in Table 49. Table 49. Metrowerks C compiler input options Option(1) Description Cut File Names to DOS Length (-!) This option cuts all file names to a length of 8 characters Include Files Only Once (-Pio) This option causes the compiler to ignore include files that have already been read once while compiling.
Project creation and build UM0036 Extra include files This field allows you to enter multiple files to include when compiling the application. You can type the file’s path name. When you begin typing, the -AddInclude= for this compiler option is automatically added to the command line. Separate multiple include files with a semi-colon (;). When you type the semi-colon to start a new entry, the -AddInclude= for the new entry is automatically added to the command line.
UM0036 Project creation and build Table 50. Metrowerks C compiler output options Option(1) Description Strip Path Info from Object Files (-NoPath) This option suppresses the generation of path information in the object files. Adds the -F2 option to the command line, which causes the compiler to generate object files in ELF/Dwarf 2.0 format. When not checked the compiler generates object files in ELF/Dwarf 2.0 Object File Format Hiware object file format (-Fh option in the command line).
Project creation and build UM0036 Figure 94. Metrowerks C compiler listing view In this view, you choose from the listing options summarized in Table 51. Table 51. Metrowerks C compiler listing options Option(1) Description Generate Assembler Include Files (-La) This option causes the compiler to generate an assembler include file when a pragma CREATE_ASM_LISTING occurs. The default output is filename.pre.
UM0036 Project creation and build Customizing Metrowerks C compiler language settings In the C Compiler tab, select C Language in the Category list box. The view in the C Compiler tab changes to that shown in Figure 95. Figure 95. Customizing C language view In this tab view, you can choose from the language options described in Table 52. Table 52.
Project creation and build UM0036 Figure 96. Metrowerks Assembler general view The Category list box allows you to access a general view for easy access to standard settings and options. You can also change the category to access views where you can customize settings in greater detail. In the Category list box, you can choose one on the following views: ● General: We recommend starting in the General settings for Metrowerks Assembler view.
UM0036 Project creation and build Message display With the category set to General, you can choose what types of messages the Assembler will generate. These are the same command line options as those used by the compiler. For a brief description of these options, refer to Message Display on page 135. Output With the category set to General, you can choose the format of the object file that the Assembler will generate. You can choose from: Note: ● ELF/DWARF 2.
Project creation and build UM0036 You can type the path name. When you begin typing, the -I for this compiler option is automatically added to the command line. Separate directory entries with a semi-colon (;). When you type the semi-colon to start a new entry, the -I for the new entry is automatically added to the command line. You can use the browse button to locate a directory.
UM0036 Project creation and build Table 53. Metrowerks assembler language options Option(1) Description Case Insensitivity on Label name (ELF/DAWRF) (-Ci) Switches off case sensitivity for label names. However, this is only used when generating directly the ELF/DWARF 2.0 Absolute file (-FA2 option). Refer to Output on page 145. Support for Structured Types (-Struct) Supports the definition and use of structured types for applications containing ANSI C and Assembly modules.
Project creation and build 4.9.3 UM0036 Metrowerks linker tab The Linker tab provides an interface for customizing the command line for the Metrowerks SmartLinker. The gray Command line window, displays all the changes to the command line as you make them. Figure 99. Metrowerks linker general view The Category list box allows you to access a general view for easy access to standard settings and options. You can also change the category to access views were you can customize settings in greater detail.
UM0036 Project creation and build Output filename options Allows you to specify the name for the output file. It appears in the command line preceded by the option -O. Optimizations The Optimization settings allow you to optimize your code once you have finished debugging your application, in order to make the final version more compact and faster.
Project creation and build UM0036 “Do not use environment” option (-NoEnv) This checkbox enables and disables the no environment option (-NoEnv) in the startup routine. This option can is specified independently for the C compiler (see Section 4.9.1: Metrowerks C Compiler tab on page 133) and the assembler (see Section 4.9.2: Metrowerks Assembler tab on page 143). When checked in the Linker tab, the -NoEnv option is applied to the linker command line.
UM0036 Project creation and build Customizing Metrowerks linker optimization settings To further customize optimizations, select Customize from the Optimizations list box. The view in the Linker tab changes to that shown in Figure 100. Figure 100. Metrowerks linker optimizations view In this view, you can choose from the optimization options listed in Table 54. Table 54.
Project creation and build Table 54. UM0036 Metrowerks linker optimization options (continued) Option(1) Description Priority is to minimize Code Size (-DistOptiCodeSize) Used in generation of ELF files only. Prioritizes optimum code size over fill optimization. Optimize Copy Down (-OCopyon) Used in generation of ELF files only. This optimization changes the copy down structure when space is limited.
UM0036 Project creation and build Table 55. Metrowerks linker output options Option(1) Description Link as ROM Library (-AsROMlib) The output objects are burned to ROM memory. Using this option is equivalent to specifying “AS ROM_LIB“ in the parameter file. Generate both S record and ABS file (-B -EnvSRECORD=s19) Results in the creation of an ABS file and an S record. By default the name for the S record is .sx. Generate Fixups in ABS file (-SFixups) Used in generation of ELF files only.
Project creation and build Note: UM0036 If you specified to output in Hiware format in the Compiler or Assembler tabs, you must specify a PRM script that is written for this output format in the Script Prm file name field. You cannot use the Auto option. When the Auto option is not checked, you have access to the Script Prm file name field. All other fields are grayed, as they pertain only to automatic generation of the parameter file.
UM0036 Project creation and build You can also modify the memory type for any segment. Right-click on the Type cell for any segment. The pull down menu in the Type cells of the mapping allows you to choose from: Note: ● READ_ONLY - ROM memory that cannot be modified during execution. ● READ_WRITE - Any memory that can be read and modified during execution. ● NO_INIT - Specifies any memory that is not to be initialized upon startup.
Project creation and build 4.10 UM0036 Configuring folder and file settings STVD’s folder and file settings allow you to configure a subset of project settings that are specific to certain folders and files in your project. Some files, such as header files in the dependencies folder do not have configurable settings. When the Project Settings window is open, access the settings for a file or folder by selecting it in the directory tree on the left side of the window.
UM0036 Project creation and build When settings are available you can configure the following: ● Always use custom build step: Checking this box allows you to access the Custom Build tab, where you can enter your own commands and options for building this file (see Section 4.10.2: Custom build tab on page 157). ● Exclude file from build: Checking this box will exclude this file or folder when you build your project. When you check this box, all other tabs disappear.Only the General tab is available.
Project creation and build 4.11 UM0036 Specifying dependencies between projects Because a project may use an element or object generated during the build of another project, STVD provides a Dependencies window that allows you to identify projects that are the source of dependencies for other projects. To define dependencies between two projects, both must be included in the workspace. To define project dependencies: 1. Select Project > Dependencies. The Project Dependencies window opens. 2.
UM0036 Project creation and build Table 57. Build commands Command Description Compile Compiles the C or Assembler source file that is in the active Editor window. You can compile a file even though the project it belongs to is not set to active. To compile a file, open the file in the Editor window. If it is already open, click on the Editor window that contains the file you want compile to ensure that it is active. The name of the selected source file will appear next to the Compile command.
Basic debugging features 5 UM0036 Basic debugging features Once you have built your application for debugging, you can choose your debugging instrument and enter the Debug context. In this context, STVD provides access to the debugging features that are supported by your debugging hardware or instrument. Because debugging instruments support different features, the commands and views that are available during debugging will vary based on your hardware configuration.
UM0036 5.1 Basic debugging features Selecting the debug instrument Your choice of target microcontroller and debugging hardware determine what features you will have access to when debugging. In the Debug Instrument Settings window you can: 5.1.1 ● Identify your debug instrument and the port it is connected to ● and Add communication ports Identify your debug instrument To identify your debug instrument for STVD: 1. Select Debug Instrument>Target Settings from the main menu bar. Figure 103.
Basic debugging features Table 58. UM0036 Debug instrument types (continued) Selection in STVD Applicable development tools STice If you are using the STice as a plain emulator. SWIM RLink If you are using the Raisonance RLink for in-circuit debugging over SWIM. SWIM STice If you are using the STice advanced emulation system in ICD configuration. 3.
UM0036 Basic debugging features Figure 104. Add an Ethernet connection For USB connections, either: ● Enter the number for the USB port (an integer between 1 and 128) in the Please Insert STMC ID field, to create an option that identifies a specific USB port (see Figure 105), ● or place a checkmark in the Automatic USB Connection Search checkbox to create a connection option that automatically searches all USB ports for your debug instrument (usb://usb). Figure 105. Add a USB connection 4.
Basic debugging features UM0036 This returns you to the Debug Instrument Settings window. The new connection option has been added to those in the Target Port Selection list box and the new option is selected automatically. 5.2 Configuring your target MCU From STVD, you can specify the configuration of your microcontroller’s memory and the behavior of its peripherals.
UM0036 Basic debugging features Table 59. Memory types (continued) Type Description Reserved This memory zone is reserved as on the microcontroller. It is not allocated to any use and is write protected. This memory type can be modified. Vectors This memory zone contains the user interrupt vectors zone. It is write protected. This memory type cannot be modified. Application This memory type is microcontroller-specific. You can add memory or peripheral resources on its hardware.
Basic debugging features UM0036 Figure 107. Specifying a new memory zone 5.2.2 On-chip peripherals The Options tab of the MCU Configuration window, allows you to configure your target device’s options and on-chip peripherals. All of the configurable options for your target microcontroller are listed in the Options column. Depending on the microcontroller selected, the configurable options and the default settings displayed in the Option column will change.
UM0036 5.3 Basic debugging features Running an application An application loaded into the STVD may be run using the commands available in the Debug menu. In the debugging process, commands in the Edit menu and the Editor's contextual menu are also frequently used. Typically, the source code for the loaded program will be viewed in an Editor window during debugging. Breakpoints may be set and removed, and run commands issued from within the Editor window.
Basic debugging features Table 60. UM0036 Debug menu run commands (continued) Command Description Step Over: To avoid single-stepping through functions that are not relevant to the debug operation. When a function call occurs, the command Step Over will cause the program to execute the function, update the program data displayed by STVD and stop at the next instruction line in the main program.
UM0036 5.3.3 Basic debugging features Program and STVD status bar display Figure 109. Debugger status on status bar ● ● 5.3.4 The left panel of the status bar shows the state of the loaded program. – Run/Stop indicates whether the loaded program is running or has been stopped. – Halted the microcontroller is executing the "Halt" instruction. – WFI the microcontroller is executing the "WFI" instruction.
Basic debugging features UM0036 For debugging, the Editor's active window may contain either a C-language or an Assembly language source file that constitutes a part of the application (and containing debug information). Debug icons are placed in the Editor debug margin. When the application is run, the Program Counter (PC) indicator is visible in the Editor window, indicating the current program line. You can set breakpoints at selected lines to halt program execution wherever you want.
UM0036 Basic debugging features Table 61. Editor contextual menu commands (continued) Command Description Run to cursor Runs the program from the current Program Counter location to the executable code corresponding to the cursor's current position in the program text. If a breakpoint is encountered before the cursor position, the execution stops at the breakpoint.
Basic debugging features 5.4.1 UM0036 Editor debug margin The left margin of an Editor window is a special area for placing debugging icons. Figure 111. Editor window margin icons and contextual menu The illustration shows several margin icons in place (breakpoints—active and disabled, bookmarks and the Program Counter) and shows the Editor's contextual menu open (rightclick on mouse to open the contextual menu). The Program Counter location is visible, showing the line at which the program has halted.
UM0036 Note: Basic debugging features A breakpoint and a bookmark may be placed together at the same position. ● Breakpoint icon : a round red dot symbol. Changes in a breakpoint icon's color indicate the following: – A red breakpoint dot means that breakpoint is enabled. – A grey breakpoint dot means that breakpoint is disabled. – A brown breakpoint dot (shown in Figure 112) means that STVD is uncertain about the position of the breakpoint.
Basic debugging features UM0036 Figure 113. Call Stack frame indicator This highlighted line is the source for the instruction found at the chosen call address (this means that the instruction pointed to by the value in the Call Stack, is indicated by the highlighted source line). The Program Counter indicator remains unchanged, as the program is still halted at the PC value. ● 5.4.2 Bookmark icon: a blue rectangular symbol. Bookmarks are an Editor function provided as an aid to text viewing.
UM0036 Basic debugging features Figure 114. QuickWatch window QuickWatch functions are: 5.5 ● Recalculate: Recalculates the value of the variable in the current context. ● Add Watch: This button adds the QuickWatch variable to the current page of the Watch window. ● Close: Closes the QuickWatch window. ● Display selection menu: The pull-down menu on the right of the window sets the display option; you can choose between Standard, Decimal, Hexadecimal, Unsigned, or Binary formats.
Basic debugging features UM0036 Figure 116. PC in editor window The Disassembly window provides a disassembly of the selected object file. Information given in the Disassembly window includes the source filename and source line number. These appear on a line by themselves in the Disassembly window, preceding the line of disassembled code.
UM0036 Basic debugging features Figure 117. Program halted at breakpoint Note: The information appearing in the Disassembly window is the result of direct disassembly of the object file, therefore the location of the program counter in the Disassembly window is not necessarily a reflection of its location in the current Edit window program.
Basic debugging features UM0036 This simply means that the PC is placed in the middle of an instruction, rather than at the beginning of the instruction, and so warns you that the PC location is not exactly where it appears in the Disassembly window. Similarly, a brown shaded circle, as shown below, indicates that a breakpoint has been placed, but that there is no way to associate this breakpoint with a particular instruction.
UM0036 Basic debugging features 1. Select the address (so that it is highlighted in blue) at which you want to begin your assembler instruction. Right-click the mouse. The contextual menu will open. 2. Select the Online Assembler option. A dialog box allowing you to change the assembly instruction at the selected address will open as shown in Figure 121. Figure 121. Online assembler dialog box 3.
Basic debugging features 4. UM0036 Click Assemble. The disassembly window will be refreshed as the new instruction is loaded into the memory, allowing you to modify the assembler instructions online while debugging. (Note that the application will not be permanently modified.) The Online Assembler dialog box will then show the next address (Oxf016, in our example) and by default enter the same instruction in the field. 5.
UM0036 Basic debugging features The search and edit options Find, Find Next and Replace may be used in the Memory window, to locate either hexadecimal or ASCII strings. Figure 124. Memory window 5.7.2 Viewing features The contents of the Memory window can be refreshed, reformatted, reloaded or modified using the options in the Memory contextual menu. This menu also provides window configuration options (Allow Docking, Hide, Float in Main Window).
Basic debugging features UM0036 Figure 126. Fill Memory dialog box Note: Memory may also be modified directly by typing over the values required. Care should be taken in this operation as the replacement values are written directly to memory. ● File: Allows access to two options: Save layout and Restore layout. Using these options, the contents of the Memory window can be saved to a file, or previously saved layouts can be restored from a file.
UM0036 Basic debugging features To restore a previously saved memory layout: a) Select File>Restore layout from the contextual menu. The Restore memory configuration dialog box opens as shown in Figure 128. Figure 128. Restore memory configuration dialog box b) 5.8 Browse for the memory file that you want to restore. Click Open. Instruction breakpoints Instruction breakpoints are markers that stop program execution when a specific instruction is reached.
Basic debugging features 5.8.2 UM0036 Viewing the instruction breakpoints To open the Instruction Breakpoints window, either click on the Instruction Breakpoints window icon in the View toolbar or from the main menu select View>Instruction Breakpoints. Figure 129. Instruction breakpoints window When a breakpoint is positioned, its specification appears in the Instruction Breakpoints window. From here, the breakpoint may be disabled/enabled or removed.
UM0036 Basic debugging features If a breakpoint is set at the beginning of function f, such that: ● The breakpoint condition is set as i<0 ● The breakpoint counter is set to 3 The counter will not be decremented until the condition becomes TRUE. The first time that i<0 is TRUE, the counter will be decremented from 3 to 2 The third time that i<0 is TRUE, the counter is decremented from 1 to 0, therefore the counter returns TRUE and the breakpoint is activated at the following iteration.
Basic debugging features UM0036 5.9 Data breakpoints Note: Data breakpoints are not available on the STVD EMU3 version. However, the equivalent functionality is provided using Advanced Breakpoints (see Section 10.2: Using advanced breakpoints on page 291). While instruction breakpoints allow you to stop the running of the application at a specific instruction line, data breakpoints interrupt the run when a data variable is either read or written.
UM0036 Basic debugging features Figure 131. Inserting write data breakpoint Note: Only read data breakpoints can be inserted this way for the Simulator and DVP versions. 5.9.2 Using the Data Breakpoints window You can track and control your data breakpoints using the Data Breakpoint window. To open this window, from the main menu, select View>Data Breakpoints. The data breakpoints window shows: ● A list of the variables for which a breakpoint has been assigned.
Basic debugging features UM0036 Figure 132. Data breakpoints window (EMU2) Figure 133. Data breakpoints window (DVP and Simulator) Below, we see the result when the program is run—the first breakpoint reached is when st0 equals 256.
UM0036 Basic debugging features Figure 134. Call stack window and interaction with other debug windows Now, if you want to step backwards through the call stack, entry by entry, simply double-click on the each entry of interest. Remember that they are numbered backwards in time, meaning that the larger the number, the farther back in the stack you are. In Figure 135, we decided to step backward in the call stack to look at the function call made just before we reached the current PC position.
Basic debugging features UM0036 Figure 135. Stepping backwards in call stack 5.11 Local variables window The Local Variables window shows a listing of program variables that are local to the functions that are active at any given time, as well as their values at particular points (such as enabled breakpoints) in the running of the program. To open the Local Variables window, either click on the Local Variables window icon in the View toolbar or, from the main menu, select View>Local Variables.
UM0036 5.12 Basic debugging features Watch window In addition to the Watch window description, this section provides information about: ● Expanding the display ● Modifying values ● Watch contextual menu To open the Watch window, select View>Watch. The Watch window displays the current value of selected program variables when the executable is stopped. Enter the variables that you want to monitor in the left-hand column of the window.
Basic debugging features UM0036 Modifying values Variable values can be modified directly in the Watch window. Double-click in the right-hand (Value) column to open the value for keyboard entry. The new value can be entered in Decimal or Hexadecimal. Note: Modifying values is only possible in the case of simple numerical values.
UM0036 Basic debugging features Interrupts (IT), and for the Simulator version only, the Simulator Time registers and the Simulator Instruction counter. An example of each is shown in the figures below. Figure 139. Concurrent IT registers Figure 140. Nested IT registers Figure 141. Simulator time registers (Simulator only) Figure 142.
Basic debugging features 5.14 UM0036 MSCI tools window When developing applications that use the ST7 Mass Storage Communication Interface (MSCI), STVD provides special views for EMU3 and ICD that display of the contents of the memory space and dissassembled code associated with this ST7 system. Caution: The memory space and registers for the MSCI peripheral are visible in the Memory window and the Core Registers window.
UM0036 Basic debugging features MSCI registers tab The MSCI Registers tab displays the MSCI internal registers memeory and the actual values of MSCI registers during application execution. Values of registers can be modified by selecting a bit and typing a new value. Symbolic display allows you to view the names of the various MSCI registers and their associated values in word format. To change the display, right-click to get the contextual menu and select Symbolic or Hexadecimal.
Basic debugging features UM0036 In the resulting listing, there are three fields: File, which is the filename in which the symbol was found; Symbol, which gives the name of the symbol (either function or variable); and Type, which specifies the type of the function or variable.
UM0036 Basic debugging features This allows you to check the value of the peripheral registers at any breakpoint in the debugging of the program. Figure 146. Peripheral registers window Peripheral registers contextual menu Using the Peripheral Registers contextual menu, you can access options for the window. Right-click the mouse while the cursor is in the window and the contextual menu shown in Figure 147 will appear. Figure 147.
Basic debugging features UM0036 Peripheral registers display options Using the display options in the contextual menu, you can customize the display format of information shown in the Peripheral Registers window: ● Display Item: You can choose to display the value of the selected Peripheral Register item in either hexadecimal, unsigned integer or binary format. ● Display All: You can choose to display all values of all Peripheral Register items in either hexadecimal, unsigned integer or binary format.
UM0036 5.18 Basic debugging features Online commands An online command is a single line of input that you can use to control the debugger (GDB) via the Console tab of the Output window. There is no limit on how long it can be. It starts with a command name, which is followed by arguments whose meaning depends on the command name. For example, the command step accepts an argument which is the number of times to step, as in 'step 5'. You can also use the step command with no arguments.
Basic debugging features 5.18.4 UM0036 The symbol-file command symbol-file filename [-readnow ] [ -mapped ] You can override the GDB two-stage strategy for reading symbol tables by using the -readnow option with any of the commands that load symbol table information, if you want to be sure GDB has the entire symbol table available.
UM0036 Basic debugging features Limitations are documented in the current STVD Release Notes. When possible, workaround procedures are provided to help minimize their impact on your project. The release notes will also inform you of the resolution of known limitations. Discrepancies between emulation hardware and your MCU’s behavior are provided in STVD’s Debugging discrepancies window.
Simulator features 6 UM0036 Simulator features In addition to debugging with emulation hardware and in-circuit debugging devices, STVD also allows you to debug your application while it runs on a software simulation of your target microcontroller. The Simulator is part of STVD and requires no additional emulation or in-circuit debugging hardware.
UM0036 Simulator features 4. To view/change the configuration settings, click on the Conf... button. The configuration setup window shown in Figure 151 is displayed. Here you can enable or disable the stack pointer control. Figure 151. Configuration setup window 5. 6.2 Click on OK when you have set up the stack control parameters as you want.
Simulator features UM0036 signal while your application is not running, the signal is taken into account, or the countdown for the delay begins as soon as you start running your application (Debug>Run). Signals are reset to their defaults when the application is restarted or when the MCU is reset. Trigger an analog or digital signal with a delay 1. Select View>I/O Stimulation from the main menu bar. The I/O Stimulation window opens, showing all I/O pins for your selected MCU. 2.
UM0036 Simulator features Trigger a periodic binary signal with or without a time delay 1. Select View>I/O Stimulation from the main menu bar. The I/O Stimulation window opens, showing all I/O pins for your selected MCU. 2. Click on the pin name to select it. 3. Double-click in the value field corresponding to the pin that you want to simulate a signal on. The I/O Stimulation dialog box opens. 4. Select Periodic. 5. Click on the radio button for VDD (1) or GND (0). 6.
Simulator features UM0036 Trigger a binary signal on-the-fly 1. Select View>I/O Stimulation from the main menu bar. The I/O Stimulation window opens, showing all I/O pins for your selected MCU. 2. Click on the pin name to select it. 3. Right-click in the value field corresponding to the pin that you want to simulate a signal on. 4. Select one of the values (GND = 0, VDD = 1) from the pop-up box. A pop-up box appears.
UM0036 Table 62. Simulator features Stimuli file syntax Signal Description Digital input signal Syntax pin pin_name -i digital_value time Example PIN PA1 -i 1 100 Description Input the value 1 on PA1, 100 CPU cycles after the start of the simulation. Because the signal is digital, the input value must be 1 or 0. Analog input signal Syntax pin pin_name -a analog_value time Example PIN PB1 -a 3.3 1020 Description Input the analog value 3.3 on PB1, 1020 CPU cycles after the start of the simulation.
Simulator features UM0036 format. Exported items can be quickly and easily imported into later simulations, facilitating comparison between different simulations of the running of your application. The Plotter selection window (Debug Instrument>Plotter Selection) provides the interface for choosing the simulated items for plotting. 6.3.1 Plotter selection window When you are in the debug context, access this window by selecting Debug Instrument>Plotter Selection.
UM0036 Simulator features 1. Click on an item to select it. 2. Click on Add Item, or double-click on the item that you want to add. The item is added to the Selected Item field. Items are listed in alphabetical order. To delete items, select an item or multiple items (use the SHIFT or CTRL keys) and click on Del Item, or drag the item(s) back to the Selectable Items field using your mouse. 3. Specify the treatment for unknown data types (Signed or Unsigned) by clicking on the appropriate radio button.
Simulator features UM0036 Figure 156.
UM0036 Simulator features Table 63. Tab contextual menu Tab Description Add New Tab Adds a new empty tab (no information is plotted) in the plotter window with a default name. Remove Active Tab Removes the active tab from the plotter window. The active tab is the tab whose contents are currently displayed in the Plotter window. Any tab can be removed, however one tab must always remain in the window. It is not possible to delete all of the tabs.
Simulator features UM0036 cannot be sorted or moved. They remain in their initial order with the first level item that contains them. You can also right-click to get the contextual menu, which provides access to the commands listed in Table 65. Table 65. Name column contextual menu Command Description Rename Changes the name of the selected item. You cannot rename an item to have the same name as another item in the tab.
UM0036 Simulator features Figure 157. No information to plot You can also right-click in the row for an item to get the contextual menu, which allows you to determine the display format for the value of the selected item. For integer values, you can select to display in Signed or Unsigned Decimal, Binary, Octal or Hexadecimal format. For float values, you can choose to display in Standard or Scientific format.
Simulator features Table 66. UM0036 Zoom commands Command Description Fit to Window Decreases the plot to fit into the display tab. Zoom mode Zoom in or out on an area that you select. When you select Zoom Mode, the mouse pointer changes to a magnifying glass. – Zoom In – (“+” in the magnifying glass) click and drag to define the area to enlarge. Zooms in to view the selected area. – Zoom Out – (“-” in the magnifying glass) Hold down CTRL, then click and drag to define the area.
UM0036 Simulator features The Previous / Next Change buttons allow you to navigate from one value change to another for the selected item. To use these commands, select an item and click on the Previous or Next change button on the tool bar. The blue Main Marker moves to the next or previous value change for the selected item. The Previous or Next button is not available (it is gray) if there isn’t a change in the value to go to.
Simulator features Table 68. UM0036 Plotter tab management commands Command Description In the Project Menu Add New Tab Adds a new empty tab (no items plotted) in the plotter window with a default name. Remove Active Tab Removes the active tab from the plotter window. The active tab is the tab whose contents are currently displayed in the Plotter window. Any tab can be removed, however one tab must always remain in the window. It is not possible to delete all of the tabs.
UM0036 Simulator features Modifying item display characteristics To improve the readability of your plot, you can modify the display characteristics including the item name, color, and size. If you have copied an item to another tab, the changes to the display properties of this item are only applied to it on the active display tab. Table 69. Item display controls Command Description Edit menu Rename Changes the name of the selected item.
Simulator features UM0036 the simulation (time=0). Entering a value a value greater than zero shifts the start point to the right of the start of the simulation (time=0). ● Time Scale – allows the re-scaling of the expression for an item. The default value is 1: no re-scaling. Entering a value less that 1 compresses the time scale so that the item’s value changes occur more rapidly. Entering a value greater than 1 extends the time scale so that the item’s value changes occur more slowly.
UM0036 Simulator features 2. Select the items you want to export. To select all the items in a display tab, place a checkmark next to the corresponding folder. Otherwise, place a checkmark next to each item or sub-item that you want to export. The items that you select are placed in the Selected field. The checkbox next to a folder or item is blue if any items or sub-items that they contain are selected for exporting. 3. Enter the time range that you want to export (optional).
Simulator features UM0036 Figure 160. Select items for printing 2. Select the items that you want to print. To select all the items in a display tab, place a checkmark next to the corresponding folder. Otherwise, place a checkmark next to each item or sub-item that you want to print. The items that you select are placed in the Selected field. The checkbox next to a folder or item is blue if any items or sub-items that they contain are selected for exporting. 3. 6.
UM0036 Simulator features Figure 161. Memory and Watch windows with Read/Write on the fly Note that when you scroll in the Memory Window, the newly visible memory entries turn bold, to show that they are being updated, then change back to normal, indicating that they are current and valid. When the Read/Write on the Fly option is active, the only time that the values shown in the Memory window may not be valid is during the direct editing of a memory value during the running of a program.
Simulator features UM0036 Create and load a stimuli file on page 206 to trigger a signal on an interrupt request pseudo pin. The IRQx pseudo pin corresponds to the interrupt request number x. Refer to the interrupt mapping table in the datasheet for your simulated microcontroller, to find the interrupt request number for the interrupt that you want to generate. As an example, Table 70 provides the interrupt mapping for the ST7LITE1xB family. Table 70.
UM0036 7 In-circuit debugging In-circuit debugging In-circuit debugging (ICD) allows you to debug an application in its final environment by communicating with the microcontroller.
In-circuit debugging UM0036 When you enter a debugging session, the SWIM entry sequence activates the communication channel on a single pin. You can then: ● control execution of your application through the debug module (step, break, abort) ● set software breakpoints by using a dedicated instruction ● use the advanced breakpoints offered by the debug module In-circuit debugging with SWIM offers the following advantages: 7.
UM0036 In-circuit debugging For more information about setting up this hardware connection for STice, refer to the STice advanced emulation system for ST microcontrollers User Manual (UM0406). 7.1.2 Selecting your MCU The ICD MCU configuration dialog box provides the interface for selecting your MCU and for configuring your MCU’s option bytes.
In-circuit debugging UM0036 STVD attempts to connect to the microcontroller on your application board. If the connection fails, an error message is displayed, and you must change your MCU selection. Caution: The MCU selection in the ICD MCU configuration window must match the MCU selected in your project settings. If it doesn’t, you must open the Project Settings window, select the appropriate MCU, and rebuild your application.
UM0036 In-circuit debugging Table 71.
In-circuit debugging UM0036 Figure 163. Setting the option byte values Note: After changing an option byte setting that is not compatible with ICD, the original setting is no longer visible in the Value field. Only settings that are compatible with ICD can be viewed and selected. You will have to use a programming tool if you need to change option byte settings to an ICD-incompatible setting. 7.
UM0036 Note: In-circuit debugging ST7 MCUs with XFlash memory do not allow software breakpoints in memory sector 0. This sector cannot be written to when the microcontroller is in USER mode. In some cases, the size of sector 0 can be configured. If this is the case, STVD requires sector 0 to be programmed to its minimum size. With the ICC protocol, software breakpoints are created by introducing a TRAP instruction, which causes the application to stop running.
In-circuit debugging 7.2.3 UM0036 Setting advanced breakpoints Depending on your target microcontroller and its debug modules, you can set advanced breakpoints to stop the execution of your application when specific conditions are met. To set an advanced breakpoint, open the Advanced Breakpoints window by selecting Debug Instrument>Advanced Breakpoints, or click on the Advanced Breakpoints icon - in the Emulator toolbar. Figure 164.
UM0036 In-circuit debugging Figure 165. Disable instruction breakpoints prompt Disable instruction breakpoints by clicking on the checkboxes next to them. Once you have disabled enough instruction breakpoints to free up a debug module, the advanced breakpoint settings will become available, as shown in Figure 164. Choose an advanced breakpoint from the list and define its settings in the Breakpoint conditions field. Breakpoint settings are described in Section 7.2.4: Advanced breakpoint options.
In-circuit debugging 7.2.4 UM0036 Advanced breakpoint options In each debug module tab, you can program the following breakpoints settings: ● Disable Advanced break. Advanced break function is off. ● Break on data value at a given address. You must specify: ● ● ● ● the type of data access (Write, Read, Read/Write) – the address – the data value Break on Opcode Fetch within address range. This option allows you to break on the occurrence of any Opcode Fetch within a specified address range.
UM0036 In-circuit debugging occurrence of a data access at a specified address. (The addresses specified for each instance can be different.) You must specify: ● ● 7.3 – the type of data access (Write, Read, Read/Write) – the address where the Opcode Fetch must occur – the address where the data access must occur Break on conditional stack write OR Opcode Fetch at given address.
In-circuit debugging UM0036 1. Power up the STice box/RLink/STLink, depending on the hardware that you are using. 2. Connect the SWIM cable between the STice box (or RLink or STLink) and the SWIM connector on your application board. 3. Select Debug Instrument>Target Settings from the main menu bar. 4. From the Debug Instrument Selection list box select SWIM RLink, SWIM STLink or SWIM STice depending on your hardware. 5. Enable the Hot Plug Start Debug checkbox. 6.
UM0036 In-circuit debugging TRAP instruction limitation (ICC only) The TRAP interrupt vector is reserved for the ICC monitor during debugging and TRAP instructions must not be used in the application. Peripheral limitation (ICC only) On some old devices, when the execution of your application is stopped from STVD while incircuit debugging, the peripherals (notably, the timers) are not frozen. Reset limitation The reset is not real-time.
In-circuit debugging Table 72. UM0036 Flash memory limitation on HDFlash devices (continued) Affected microcontrollers Address range of reserved memory zone ST7FLITES2/5 FF12-FFDF ST7FLITE02/5/9 FF12-FFDF SWIM debugger limitation While the microcontroller is executing either a "Halt", "WFI" or "WFE" instruction, or protected code, no core resource is accessible for the debugger.
UM0036 8 DVP and EMU2 (HDS2) emulator features DVP and EMU2 (HDS2) emulator features This section explains how to use the features that are specific to the ST7 DVP or EMU2 emulator, including: 8.1 ● Section 8.1: Working with output triggers ● Section 8.2: Using hardware events ● Section 8.3: Trace recording ● Section 8.4: Using hardware testing ● Section 8.5: Logical analyser (EMU2 emulators only) ● Section 8.6: Stack control window (DVP emulators) ● Section 8.
DVP and EMU2 (HDS2) emulator features UM0036 The EMU2 Emulator version and the DVP versions are slightly different in the way they use hardware events: ● For the EMU2 emulators, hardware events are used to control the trigger outputs (OUT1 or OUT2). ● For the DVP2 and DVP3 emulators, there are three types of hardware events that can be used to control either the trace recording or the trigger output: ● – Event On (EVT_ON): The address where the event begins.
UM0036 DVP and EMU2 (HDS2) emulator features From this contextual menu, you can: 8.2.2 ● Refresh: Updates the window. ● New Hardware Event: Adds a new hardware event. ● Enable/Disable Selected Hardware Event: If you select a specific hardware event, and then right-click to obtain the contextual menu, choosing this option disables the event. A disabled event is signaled by a gray circle in the Hardware event column.
DVP and EMU2 (HDS2) emulator features UM0036 Figure 169. Hardware event settings window for DVP2 If you are using a Development Kit, in the Hardware event setting dialog box, choose the kind of hardware event you want to set (either EVT_ON, EVT_OFF or EVT_HIT for DVP2 and DVP3, or FORCE_HIGH or FORCE_LOW for DVP1) and check the Enabled box. For more information, see Section 8.7 on page 255. 3.
UM0036 DVP and EMU2 (HDS2) emulator features Figure 171. Hardware events window (DVP2 emulators) – Right-click the mouse. The Editor contextual menu opens. Select Add Hardware Event. The Hardware events setting dialog box opens. Figure 172. Hardware events settings dialog box (EMU2 emulators) Figure 173. Hardware events settings dialog box (DVP2 emulators) You can change the event type using the drop down list.
DVP and EMU2 (HDS2) emulator features UM0036 To set a hardware event on a line of code 1. Open the Hardware Events window. 2. Open the relevant source file in the Editor and place the cursor in the line of code. 3. Right-click the mouse. The Editor contextual menu opens. 4. Select Go to Disassembly. The Disassembly window opens and the code address of the source code line is selected. 5. Drag and drop the code address from the Disassembly window to the Hardware Event window.
UM0036 DVP and EMU2 (HDS2) emulator features Figure 174. Trace contextual menu Show/hide columns Columns may be disabled if they not required and/or do not display any trace information for the particular trace situation. To activate/disable a column, select Column Display in the Trace contextual menu. This opens a list of all the columns available in the trace record. Figure 175 shows the Columns dialog box for the DVP version. Figure 175.
DVP and EMU2 (HDS2) emulator features UM0036 Move columns Columns may be also shifted right or left for convenience of use. Pick up the column header with the left mouse button and drag to the location required. Line filter Trace records may be filtered using the Trace Display Filter dialog box (see Figure 177).To open this window, select Filter Lines from the Trace window contextual menu. The line filter is used to restrict the trace display to the operation that you are interested in.
UM0036 DVP and EMU2 (HDS2) emulator features Figure 178. Save Trace Contents dialog box 8.3.2 Viewing trace contents The Trace window presents a table of nine or ten fields (plus the Symbol Bar) which together form a single trace record. At the left is the Symbol Bar (which has no column heading) followed in default order by Record / Address / Data / Hexadecimal / Disassembly / Symbolic / Memory, then the hardware-specific categories. For EMU2 emulator: Sig / S2 / Event. Figure 179.
DVP and EMU2 (HDS2) emulator features UM0036 Figure 179 and Figure 180 show all of the trace columns for each STVD version. You can preselect which of these columns are displayed (see Show/hide columns). The trace fields contain the following information: ● Note: Symbol Bar: This column contains icons such as source line markers bookmarks .
UM0036 DVP and EMU2 (HDS2) emulator features Figure 181. Hardware Test dialog box (DVP version) The Hardware Test dialog box shows a list of different tests that can be performed. Check the box for each test that you want to perform (they are all checked by default) and click Apply to start the hardware test. The hardware tests are performed one by one, and the results summarized in the dialog boxes. For example, the hardware test for the EMU2 Emulator appears as shown in Figure 182. Figure 182.
DVP and EMU2 (HDS2) emulator features 8.5 UM0036 Logical analyser (EMU2 emulators only) You can access the Logical Analyser window either by clicking on (the Logical Analyser icon) in the Tools toolbar, or from the main menu by selecting Tools>Logical Analyser. The Logical Analyser allows additional control over advanced breakpoints or the trace buffer.
UM0036 DVP and EMU2 (HDS2) emulator features If the condition you define with the Logical Analyser consists of a single event, when this event is met, the Logical Analyser either imposes a breakpoint, or stops recording the trace (depending on which functionality you activated). However, if your condition was made up of several events, the Logical Analyser notes that the first event occurred, and keeps checking for the occurrence of the other events.
DVP and EMU2 (HDS2) emulator features UM0036 set to 0 or 1 except in the case of the Read/Write signal, where for clarity's sake, you can choose between “R” or “W”. You may flag values on the following pins/signals: 6. – Four Analyser probe pins (located on the probe port on the front of the EMU2 emulator): AL0, AL1, AL2 and AL3. – A supplementary input/output pin, S2, located next to the probe cables on the front of the EMU2 emulator.
UM0036 DVP and EMU2 (HDS2) emulator features Figure 186. Event 1 as programmed 8.5.2 Advanced breaks using the logical analyser You can use Events as conditions by which to insert a break in the running of an application, by choosing the Advanced Break functionality from the drop-down list at the top of the window.
DVP and EMU2 (HDS2) emulator features UM0036 Figure 187. Defining an advanced breakpoint You can continue to apply break conditions using up to three events by way of the And fields. In the example shown in Figure 188, after Event 1 plus n1 cycles have occurred, followed by n2 occurrences of Event 2, a break in the execution of the application occurs. Figure 188. Defining an advanced breakpoint (continued) 8.5.
UM0036 DVP and EMU2 (HDS2) emulator features previous event condition recordings are completed (for example, Event 2 condition recording only starts when Event 1 condition recording is completed). To define conditions for trace buffer recording: 1. Open the Logical Analyser window. 2. Choose Trace Filtering from the drop-down list at the top of the window. 3. In the Record field, choose one of the three options (as shown in Figure 189): Figure 189.
DVP and EMU2 (HDS2) emulator features UM0036 Figure 190. Trace filtering event schematics 8.6 Stack control window (DVP emulators) The Stack Control window command allows you to set a specific stack address as either the stack overflow point or the stack underflow point. This means that if, during the course of debugging, the current SP value exceeds or falls beneath this address, the application is halted (provided that you check the Enable stop box in the Stack Control window). Figure 191.
UM0036 DVP and EMU2 (HDS2) emulator features Figure 192. Configuration setup window 5. Click on OK when you have set up the Stack Control parameters as you want. Note: If you do not want your Stack Control information to be saved in the workspace file, you must modify the default Configuration Setup options by clicking on the Conf... button. 8.
DVP and EMU2 (HDS2) emulator features UM0036 an external measurement instrument, such as an oscilloscope. When a user-defined hardware event occurs, an impulse (TTL level) is emitted or the level of the signal is changed, depending on the type of hardware event. For information on how to define hardware events, see Section 8.2: Using hardware events on page 237.
UM0036 DVP and EMU2 (HDS2) emulator features Figure 194. DVP1 trigger settings Working with trace filtering (DVP2 and DVP3 only) In the Trigger/Trace Settings window, if you click the Trace filtering enable option, the trace is filtered using the same hardware events that affect the trigger output, so that the trace recording mirrors the trigger output: ● EVT_ON hardware events start the trace recording.
STice features 9 UM0036 STice features The STice advanced emulation tool used in conjunction with STVD supports all of the features supported by the EMU3 emulator, except advanced breakpoints and performance analysis. Instead of performance analysis, it offers support for a comprehensive set of coverage and profiling features. In the STice features, there is a trace recording section dedicated to STM8 which is not supported by EMU3.
UM0036 STice features Figure 196. STice trace window Figure 196 shows most of the trace columns. You can preselect which of these columns are displayed (see Column display: Columns may be disabled if they not required and/or do not display any trace information for the particular trace situation. To activate/disable a column, select Column Display in the Trace contextual menu. This opens a list of all the columns available in the trace record.).
STice features UM0036 window (all others are hidden). The record number and timestamp are not recalculated when lines are removed from the display.. 260/385 – Decoding start: Indicates that the displayed instruction starts being decoded. – Interrupt handler: is displayed at the start of an interrupt handler. At the same time, the interrupt name is displayed in the Irq column. – Interrupted: is displayed when an instruction is interrupted.
UM0036 STice features wide. As a result, the read value may be 1, 2 or 3-bytes long. These data bytes are constants or part of constants accessed by the program. To simplify the data display, when data is read, the value of the data is shown only when it is valid, that is one cycle after the data request was made (if there is no stall). ● R event (Read event): It is the type of read event.
STice features UM0036 events when a Discontinuity message occurs between them. However, the relative time elapsed between two events occurring before the discontinuity, or two events occurring after the discontinuity can still be calculated and is valid. 9.1.2 ● Trace event: Start indicates that this is the first trace record after the trace has been switched on or after the program has stopped.
UM0036 STice features Figure 198. Trace Display Filter dialog box ● Filter lines: Trace records can be filtered using the Trace Display Filter dialog box (Figure 198). To open this window, select Filter Lines from the Trace window contextual menu. The line filter is used to restrict the trace display to the operation that you are interested in. Only the selected trace entries appear in the Trace window (all others are hidden).
STice features ● UM0036 Goto Source, Goto Disassembly: You may use these commands in the contextual menu to jump to either an editor window or the Disassembly window under the following conditions: – If you highlight an entry in the trace where the address is a line of source code, you can use the Goto Source command to jump to that line of code in the Editor window.
UM0036 STice features select Column Display in the Trace contextual menu. This opens a list of all the columns available in the trace record. Figure 200. Show/hide columns Columns may also be shifted right or left for convenience of use. Pick up the column header with the left mouse button and drag to the location required. The Trace window in Figure 201 has been set up to show only the Record, PC, Instr event, Hexa code, Disassembly, R addr, R value, R event, W addr, W value and W event columns.
STice features UM0036 window (via the BEM)—but doing so disables the Trace On/Off command in the Trace Contextual menu. 9.
UM0036 STice features There are three counter sizes: ● Small 15-bit occurrence counters with a maximum value of 32767 ● Large 30-bit occurrence counters with a maximum value of 1,073,741,823 ● 36-bit time counters enabling to record 22.9 minutes of execution with a 50 MHz time base Data occurrence counters are enabled when you select Data coverage and occurrence profiling. Code occurrence and time counters are enabled when you select Code coverage and profiling (see Section 9.2.
STice features UM0036 Figure 202. Data coverage and occurrence profiling settings window Figure 203.
UM0036 STice features 3. If you have selected Code coverage and profiling in the Time Profiling section, select the Time recording mode: – Instruction: Measures the time from the beginning of an instruction to the beginning of the next instruction, regardless of the time spent in subroutines. In the profiling results, all instructions are presented at the same level.
STice features UM0036 Figure 204. Code coverage and profiling settings window You can select the frequency of the profiler time counter from the following values: – 12.5 MHz – 25 MHz – 50 MHz (default) – 100 MHz It is advised to use a profiler frequency which is at least 3 times higher than the frequency of the microcontroller. To have more precision, increase the frequency of the profiler time counter.
UM0036 STice features have chosen two small counters to record read and write operations separately, the maximum value may be reached very quickly. Note: – Place a checkmark in the Stop after application reset checkbox in the General section, to stop the execution when a reset has occurred (due to watchdog, for example). In fact this option should always be checked unless your application should not be stopped, otherwise the time profiling results in the two subroutine modes will become erroneous.
STice features UM0036 1. In the main window, from the Debug Instrument menu, select Profiling Session Start. 2. Start execution of your application or continue execution if it is stopped at a breakpoint. 3. Continue application execution until it reaches the next breakpoint, or until the end of the program. You can have as many breakpoints as you like, and they should be placed anywhere that you wish to examine further in the program. 4.
UM0036 STice features ● Contextual percentage Indicates the time spent executing code in the function as a percentage of the total processing time for the containing object in the hierarchy of elements in your program. It may be a percentage of C lines, or functions, or the total. ● Percentage of total For a function, indicates the lines that are executed as a percentage of the total number of lines in the function. A value of zero indicates that the line was not executed.
STice features UM0036 It is possible to sort the columns according to alphabetical order for Function, Interrupt and Source file columns, and in numerical order for the other columns. The simplest way is to click on the header of the column you wish to sort. For example if you click on Time (ns), the lines will be sorted in ascending order according to the execution time. If you click again on Time (ns), the lines will be sorted in descending order.
UM0036 STice features ● Read (Yes/No) Indicates whether the variable was read or not. ● Write (Yes/No) Indicates whether the variable was written to or not. ● Read accesses Indicates the maximum number of byte accesses from the application for reading the variable or just the number of read accesses for a single byte. ● Write accesses Indicates the maximum number of byte accesses from the application for writing to the variable or just the number of write accesses for a single byte.
STice features UM0036 Figure 208. Data coverage and profiling analysis: source view The green spot in the margin identifies the lines of code that are executed. The left-hand side of the window displays the Functions/Instructions View. You can resize this part of the window or make it disappear completely by clicking on the partition and dragging it to a new position.
UM0036 Caution: STice features Code that is not executed because it is not properly covered in the validation test plan can be mistaken for dead code. Therefore, when you are running coverage tests to detect dead code, make sure that the lines that are not executed are not due to an oversight in the test plan before deleting them.
STice features UM0036 Figure 210. Source view of test suite Figure 211.
UM0036 STice features Detecting dead code When you run a coverage and profiling session, the areas of code that are not executed are associated with a gray icon on the Functions/Instructions View tab in the Coverage and Profiling Analysis window. There are two complementary methods for detecting dead code: ● By building the code. During the build, the linker removes any unused functions. This is a static analysis. ● By running a coverage and profiling session.
STice features UM0036 Optimizing variables Unused variables: The results of a coverage and profiling session can help you examine how you use variables in your code. First, it shows which variables are simply not used at all, and therefore can be removed. Unused variables are shown in gray on the Data View tab in the Coverage and Profiling Analysis window. Inadequate variable type: It also shows where you can more effectively replace a variable by another structure.
UM0036 STice features 4. Expand each code block in turn. Expand successively the most time-consuming functions and instructions to determine on which lines of code the most time is spent. Figure 214 shows how to expand the main function to locate the ComputeOutputValue call. This call accounts for approximately 91.12% of the processing time of the main function and 99.84% of the processing time of line 70. Figure 214.
STice features UM0036 Figure 216. Bottleneck detection: bottom level static unsigned int result=0; unsigned int Speed = 100; unsigned int computeOutputValue(void) { static const unsigned int SinTab[] = { (unsigned int) (MIN_SINUS_VALUE+0.500000*SINUS_AMPLITUDE), (unsigned int) (MIN_SINUS_VALUE+0.654508*SINUS_AMPLITUDE), (unsigned int) (MIN_SINUS_VALUE+0.793893*SINUS_AMPLITUDE), (unsigned int) (MIN_SINUS_VALUE+0.904508*SINUS_AMPLITUDE), (unsigned int) (MIN_SINUS_VALUE+0.
UM0036 STice features Assessing the performance of time-critical code Time-critical sections of code are those that are executed most often. Because interrupts occur frequently, they are a good example of time-critical code. Using the profiling feature, you can identify in your code the areas that are executed most frequently. Gains in these areas will lead to significant performance improvements.
EMU3 emulator features 10 UM0036 EMU3 emulator features This section explains how to use the features that are specific to the ST7-EMU3 emulator, including: 10.1 ● Section 10.1: Trace recording ● Section 10.2: Using advanced breakpoints ● Section 10.3: Programming trace recording ● Section 10.4: Using output triggers ● Section 10.5: Using analyzer input signals ● Section 10.6: Performance analysis ● Section 10.7: Read/write on the fly ● Section 10.
UM0036 EMU3 emulator features Figure 217. EMU3 trace window Figure 217 shows most of the trace columns. You can preselect which of these columns are displayed (see Column display). ● Note: Symbol Bar: This column contains icons such as source line markers ( ) and/or bookmarks. When a source line marker occurs, the fields described hereafter are used to display source line information such as the name of the source file, the line of source code, and the instruction call.
EMU3 emulator features UM0036 The event column serves chiefly to allow you to filter out the hardware cycles of interest using the Filter Lines option in the Trace contextual menu, described in Filter lines. 10.1.2 ● Hexadecimal: The instruction in hexadecimal format, if this is a Fetch instruction cycle. ● Disassembly: The instruction in assembly language mnemonics, if this is a Fetch instruction cycle.
UM0036 EMU3 emulator features Figure 218. Trace contextual menu Filter lines Trace records can be filtered using the Trace Display Filter dialog box (Figure 219). To open this window, select Filter Lines from the Trace window contextual menu. The line filter is used to restrict the trace display to the operation that you are interested in. Only the selected trace entries appear in the Trace window (all others are hidden).
EMU3 emulator features UM0036 Figure 219. Trace Display Filter dialog box ● Display Source Lines: This option includes the source line in the Trace information. The Address column contains the name of the source file and the source line content is displayed in the Disassembly window. ● Display event type cycles: Includes the recorded cycles in the trace information. When enabled, the microprocessor actions selected in the Trace Display Filter dialog box are included.
UM0036 EMU3 emulator features Previous Code Fetch, Next Code Fetch commands If you highlight a trace record of an opcode fetch, you can use the Previous Code Fetch and Next Code Fetch commands in the contextual menu to jump to, respectively, the previous or next opcode fetch records in the trace recording. Bookmarks Clicking on the Bookmarks commands lets you access the following commands: ● Toggle Bookmark: Allows you to place or remove a bookmark at any trace recording entry.
EMU3 emulator features UM0036 Figure 221. Show/hide columns Columns may also be shifted right or left for convenience of use. Pick up the column header with the left mouse button and drag to the location required. The Trace window in Figure 222 has been set up to show only the Record, Address, Data, Event, Disassembly and Hexadecimal columns. Figure 222. Customized trace window 10.1.
UM0036 EMU3 emulator features Figure 223. Setting timestamp clock The timestamp clock frequency determines the granularity of the timer—the inverse of the clock frequency (1/f) equals the period of each timer tick. In this dialog box, you can choose the timestamp clock you want to use. – Internal: Selects the emulator's internal 20 MHz timestamp clock (therefore the period of each timer tick equals 50 ns). – External: Selects a timestamp clock external to the MCU.
EMU3 emulator features UM0036 Actions that may be performed upon the occurrence of the defined event or sequence of events can be defined as: ● a break in the execution of the program (a breakpoint), ● the outputting of a waveform to one or both of the two output triggers, ● the enabling, or disabling of trace recording, ● the recording of a snapshot in the trace, ● continuing to another level of conditions, defined by another event or series of events, ● a set of the above actions.
UM0036 EMU3 emulator features Each level can incorporate up to four events. The level defines the relationship between these events (specific user-defined conditions) and the actions to be carried out by the debugger. A counter may also be set. Up to four levels can be combined to structure advanced breakpoint definitions. Each of the four levels has the structure (IF..THEN) (ELSE IF..THEN).
EMU3 emulator features UM0036 When you click on the IF button in the Programmable Level portion of the window, as shown in Figure 224, you are presented with the Combination window. It contains fields that allow you to define the conditions upon which you want certain action(s) to be taken. Proceed as follows: 1. First ask yourself: “What type of condition results in an action?”.
UM0036 EMU3 emulator features Figure 226. Defining Level 1, Event 1 An event may incorporate any of the following: Note: – A Memory Event. You may set an event on any of the following memory events: Any Memory Access, Memory Access with Data, Opcode Fetch, Opcode Fetch with Data, Stack Memory Access, DMA Memory access, IT Memory Access. A Memory Access event would be, for example, a read access of memory address 0xfd00. – One or more Other events.
EMU3 emulator features UM0036 Figure 227. Then window 9. Continue defining the level using the remaining Else If and Then commands in the same manner as described above. Remember that: – Else If conditions are only considered when the If conditions are not true at the end of one memory cycle. – If any of your Then actions include a Goto Level command, you must also define this level. 10.
UM0036 EMU3 emulator features Figure 228. Memory events An event may be defined as one of the following types of memory access: ● Any Memory Access: A specified memory address or range of addresses is accessed by a read or a write command. In the dialog box shown in Figure 229, you must specify two of the following fields: a start address (for the start of a range of addresses), an end address (the end of a range of addresses) or the length of the address range.
EMU3 emulator features UM0036 Figure 230. Memory Access with Data dialog box The dialog box at right is the same as for the Memory Access dialog box with the addition of a field to specify a data value or range. You must enter a First data value and then, in the drop-down box, specify whether you want to give a Data range, or specify Selected bits. If you select Data range, you will have to enter a Last data value (to complete the range).
UM0036 EMU3 emulator features Figure 231. Opcode Fetch dialog box ● Opcode Fetch with Data: An opcode fetch of a specified value or range (or specified bit mask) is carried out at a specified address, or within a specified range of addresses. The dialog box shown in Figure 232 is the same as for the Opcode Fetch dialog box with the addition of a field to specify a data value or range.
EMU3 emulator features UM0036 Figure 232. Opcode Fetch with Data dialog box Note: When Any Memory Access or Opcode Fetch is selected as the type of access, then any number of access events may be included in the list for that event. If Opcode Fetch with Data or Memory Access with Data are selected as the type of Memory Access, then only a single entry is allowed in the list for that event.
UM0036 EMU3 emulator features that shows how to specify a value with selected bits masked, is given in Section 10.5.1 on page 318. Note: Ignored means that the signal is not monitored as part of the event. 10.2.4 Enabling advanced breakpoints There is an Enable Configuration checkbox at the top left of the Advanced Breakpoints window, above the user configuration summary. This must be checked to activate the breakpoint program.
EMU3 emulator features UM0036 Figure 235. Advanced breakpoints configuration summary 10.2.7 Synoptic representation of advanced breakpoints The Synoptic window may be viewed by clicking on the Synoptic tab at the bottom of the window, or by clicking on “Synoptic” in the Configuration Summary. It illustrates the logical links programmed into the levels. The Synoptic graphic for a typical sequence is shown in Figure 236. Figure 236.
UM0036 EMU3 emulator features Programmed and unused levels are differentiated by color coding. The currently active Level is color-coded and indicated by an arrow. Links between levels are color-coded to differentiate between IF and ELSE IF logic. The Synoptic view is a block diagram of the four levels with the programmed logical links displayed graphically.
EMU3 emulator features UM0036 Figure 238. Configuration disabled 10.2.8 Saving and loading advanced breakpoints You can store the definition for your advanced breakpoint to a file (*.bem), which can be reloaded by any STVD project, providing that you are using the EMU3 emulator to debug the application. This will allow you to save time if you have to switch between advanced breakpoints while debugging your application.
UM0036 EMU3 emulator features 1. From the main menu, select Debug Instrument > Advanced Breakpoints. 2. In the Advanced Breakpoints window, click on the Level1 tab, then on the Event1 tab. 3. In the Memory Events area, select Any Memory Access from the drop down menu as shown in Figure 239. Figure 239. Programming the memory access The Memory Access dialog box opens. To define the memory zone, enter the starting address, 0x40, in the From Address field, and the end address, 0x47, in the To field.
EMU3 emulator features UM0036 Figure 241. Programming Then 6. Check the Enable Configuration box at the top left corner of the Advanced Breakpoints window (as shown in Figure 242) to enable the program. Click OK. Figure 242. Enabling the configuration Advanced breakpoint programming is now enabled. Table 73 provides a summary of steps.
UM0036 EMU3 emulator features Table 73. Advanced breakpoint programming summary Step Description START with TRACE ON or OFF LEVEL 1 IF (access at memory location [0x40-0x47]) THEN break; LEVEL 2-4 (empty) Example 2—Break on memory access with data masking This example is an elaboration of the previous example. In this case, we set a breakpoint on the reading or writing of a particular data value to a particular memory address or range of memory addresses.
EMU3 emulator features UM0036 Figure 243. Programming memory access with data 4. In the Level 1 tab, click Then and set the defined action as a breakpoint, as shown in Figure 244. Note the program is summarized in the Configuration Summary window on the left. Figure 244.
UM0036 EMU3 emulator features Table 75. Advanced breakpoints summary Step Description START with TRACE ON or OFF LEVEL 1: IF (opcode fetch at main.c*57) THEN Goto Level 2; LEVEL 2: IF (read at memory address 0x004014-0x004019) THEN break; LEVEL 3-4: (empty) The Configuration Summary of the Advanced Breakpoints window should appear as shown in Figure 245. Figure 245.
EMU3 emulator features UM0036 Example 1—Trace ON inside a function This example shows you how to program the Advanced Breakpoints window so that the trace is recorded only during the running of a particular program function. Imagine that you have a program called sample1.c, which calls the function my_lib at line 170 (as shown in Figure 246) and that you want to have the trace recorded while the program is executing that function. Figure 246. Calling function my_lib Proceed as follows: 1.
UM0036 EMU3 emulator features 1. Open the Advanced Breakpoints window. 2. Configure your Advanced Breakpoints window as summarized in the table below. Table 77. Advanced breakpoints summary Step Note: Description START with TRACE ON LEVEL 1: IF (opcode fetch at sample.c:164) THEN (Goto Level 2); LEVEL 2: IF (Counter (Trigger IN == 0) >= 128) THEN Break; LEVEL 3-4: (empty) The input trigger is used here to provide an event which is always true.
EMU3 emulator features UM0036 Example 5—Measuring long time periods between events The trace recording includes a Timestamp field, but the Timestamp's counter is only 30bits, while the maximum trace recording length is 256 Kbytes. This means that if you fill the trace buffer, the Timestamp counter is filled and automatically reset many, many times, and the Restart message appears in the Timestamp Event field each time the counter is reset.
UM0036 EMU3 emulator features 1. Open the Trace window. 2. Right-click the mouse in the Trace window and select Show/Hide Columns from the contextual menu. Ensure that you are able to view the Record, Event, Timestamp, Timestamp Event and TIN (Trigger Input) fields. 3. Go to the record in the Trace window that corresponds to the first event. This record should have Event 1 in the Event field and a value of 0xF in the TIN field.
EMU3 emulator features UM0036 Figure 247. Output trigger action modes Period of time between event provoking pulse action Pulse output trigger Pulse lasting one processor cycle 2nd toggle 4th toggle action action 6th toggle action Toggle output trigger 1st toggle action 3rd toggle action Set output low 5th toggle action Set output low Set output high/low Set output high 10.4.
UM0036 EMU3 emulator features Table 81. Advanced breakpoints summary Step Description START with TRACE ON or OFF LEVEL 1: IF (Enter IT) THEN (Trigger 1 Pulse); LEVEL 2-4: (empty) The Advanced Breakpoints window should appear as shown in Figure 248. Figure 248. Programmed window Example 2: Toggling a trigger output signal Suppose that you want the output trigger signal to be toggled (go from 0 to 1 or from 1 to 0) upon a certain conditional event.
EMU3 emulator features UM0036 Figure 249. Programming level 1 Example 3: Setting the trigger output high or low In the previous example, upon each occurrence of a specific event (an opcode fetch at sample.c, line 170) the trigger is toggled—meaning that the new trigger value is the opposite of the old trigger value. Toggling changes the relative value of the trigger. In this example, we show that we can also effectively toggle the trigger high or low using the set high and set low options.
UM0036 EMU3 emulator features Table 83. Advanced breakpoints summary Step Description START with TRACE ON or OFF LEVEL 1: IF (event 1: Probe input = Range of values, first=0x1, last=0xff) AND (not event 2: Opcode Fetch (Address) at sample.c:170) THEN (Trigger 1 High) AND (GoTo Level 2); ELSE IF (event 3: Input probe = 0x0) OR (event 4: Opcode Fetch (Address) at sample.c:170) THEN (Trigger 1 Low) LEVEL 2: IF (event 1: Opcode Fetch (Address) at sample.
EMU3 emulator features UM0036 Figure 251. Defining events using Analyzer probe signals As shown in Figure 251, you can provide a specific value (with or without bit masking) or a range of values (see Analyzer input examples). 10.5.1 Analyzer input examples Example 1- Specifying an Analyzer probe value with selected bits masked The Analyzer probe has an 8-bit input. Imagine that you want to specify an input value of 91 (5B in hexadecimal format). You can simply specify the value “91”.
UM0036 EMU3 emulator features Example 2—Setting an advanced breakpoint on an input probe value This program allows you to make the trace recording conditional on a specific input probe signal, and then record the trace until the trace buffer is full. Program the Advanced Breakpoints window as summarized below: Table 84.
EMU3 emulator features UM0036 Figure 253. Performance Analysis dialog box In this dialog box, you must specify the following: ● Disable breakpoints: this checkbox disables all current breakpoints during the test. ● Number of passes: the number of times that the specified sequence of code will be run for the test. ● Starting address: specifies the start address of the sample and the name of the module in which it is located.
UM0036 EMU3 emulator features number of passes executed are reset to zero and a new record is made, starting from the Program Counter location. ● Stop: stops program execution and shows performance analysis results to this point. When the program execution terminates, the Statistics tab opens automatically to display the results of the analysis. 10.6.3 Viewing results The Statistics tab (shown in Figure 254) sets out the numerical data resulting from the performance analysis.
EMU3 emulator features ● ● UM0036 Statistics for one pass through portion of code: These values concern timing data for the selected portion of code (between the chosen start-point and end-point). – Average time: Average time for a single passage between start- and end-points. – Minimum time: The most rapid timing recorded between the two points. – Maximum time: The slowest pass between the two points.
UM0036 10.7 EMU3 emulator features ● Show All modifies the scale of the graph to include the whole record in the visible area. ● Previous View restores the previous graph view (for example to zoom out after a Zoom In). ● Zoom In: left-click on the mouse to position a vertical marker on the graph. Two of these markers may be positioned (left-click in each case) and the view zoomed to the region between them using the Zoom In button.
EMU3 emulator features 10.8 UM0036 Performing automatic firmware updates Your emulation hardware contains programmable logic devices for the emulation of specific MCUs or families of MCUs. This firmware may need to be updated if you have changed the Target Emulation Board in your EMU3 probe, or if you have updated your version of STVD. STVD checks your emulator’s firmware each time you start a debug session, and updates them if older versions are detected.
UM0036 11 Program Program Once you have finished debugging your application and have built the final version, you can program it to your target microcontroller using STVD’s Programmer. This feature is based on ST Visual Programmer (STVP). It offers basic programming features and allows you to program your target microcontroller using a programming board or in-circuit programming (ICP) hardware. To access the Programmer, select Tools > Programmer from the main menu bar. The Programmer window opens.
Program UM0036 Depending on your target microcontroller you will be able to configure the following: ● The programming hardware and connection port ● The programming mode ● Protections ● Erase before programming option ● Unlock device In addition to these settings, the Run STVP button allows you to launch STVP, instead of using STVD’s Programmer. To exit the Programmer, click on Run STVP. STVD prompts you to confirm that you want to close the Programmer window and start an STVP session.
UM0036 Program ICP mode with Option Bytes Disabled is a safe programming mode that allows you to start your MCU while ignoring the current option byte values. This is to avoid start-up failures that result from option byte settings that are not compatible with the application configuration. For example, you can use it when the clock on your application board doesn't match the oscillator type specified by the MCU's option byte.
Program UM0036 Unlock device The Unlock Device option is only available for specific Flash devices. If you check this option, the programmer will unlock the microcontroller before starting any other programming activities (such as Erase, Blank check, Program, Verify). 11.2 Assigning files to memory areas When you program your microcontroller, only the memory areas that you select are programmed.
UM0036 Program 1. Select a memory area from the Memory Area list box. 2. Click on the Add button to open a browse window. 3. Select the file to be programmed to this memory area, then click on Open. The file is added to the Files field. “Program even if has empty file list” option If you don’t have a file to program to a memory area, you can still select it for programming by checking the Program even if has empty file list checkbox. This checkbox is only visible when the Files field is empty.
Program UM0036 1. Right-click in the option byte’s Description field to see the pop-up list of possible settings. 2. Click on the new setting in the pop-up list. The new setting for the option byte is displayed in the Description field. “Program even if default” option The Programmer only programs the Option Byte Area of memory if the settings indicated in the Option Bytes tab are different from the factory default settings.
UM0036 Program To start the programing sequence, click on the Start button. The Programmer connects to your target MCU and begins the programming sequence. During programming, the Summary and Outputs field displays any status messages and errors that result from the execution of the programming tasks.
STM8 C tutorial 12 UM0036 STM8 C tutorial The STM8 tutorial illustrates some of the main features of STVD by guiding you through the process of building and debugging a sample application in C language. Each procedure presented in this tutorial focuses on a functional aspect of the build and debug processes. Steps should be performed in the sequence in which they are presented; failure to do so can result in errors in the steps that follow.
UM0036 STM8 C tutorial Table 85. Tutorial sections and applicable debug instrument Section Debug instrument View execution All Perform memory mapping All View program execution history EMU3, STice Use read/write on-the-fly EMU3, STice, SWIM Set an advanced breakpoint EMU3 (and STice in the near future) Run a coverage and profiling session 12.
STM8 C tutorial 12.1.2 UM0036 Create a workspace Before you can build or debug an application with STVD, you must create a workspace to contain your project and its source files. A workspace can contain several projects. 1. In the main menu bar select File>New Workspace. 2. In the New Workspace window, click on the Create Empty Workspace icon and then OK. Figure 263. Workspace information 3. Enter a name in the Workspace filename field. 4.
UM0036 STM8 C tutorial 1. In the main menu bar, select Project>Add New Project to Workspace. 2. In the New Project window, click on the New Project icon and then OK. 3. Enter the name cosmic or raisonance in the Project Filename field, depending on your toolset. In future, if you have only one toolset you can choose a name more pertinent to your project application. 4. Enter the pathname where you want to store the project and the resulting files in the Project Location field.
STM8 C tutorial UM0036 Figure 265. MCU selection 8. Save your workspace; select File>Save Workspace. RESULT: .stp has been added to the workspace in the STVD Workspace window. By default the project contains folders called Source Files, Include Files and External Dependencies. These folders are used to organize your project within STVD. They do not exist in the working directory. The file main.c is added to the Source Files folder by default. With Cosmic the file mods0.
UM0036 STM8 C tutorial The working directory contains the following: ● ● Note: three files: main.c, and – for Cosmic: cosmic.stp, stm8_interrupt_vector.c – for Raisonance: raisonance.stp, R_stm8_interrupt_vector.c and two folders: Debug and Release. These folders are the default locations for storing your application and any intermediate files depending on whether you build using the Debug or Release configuration. The workspace view tree does not necessarily reflect the directory tree on the disk.
STM8 C tutorial UM0036 Figure 267. Project with source file and dependencies RESULT: Your project workspace now contains the application source code file. Any dependencies specified in the source code are displayed in the External Dependencies folder. The list of external dependencies is built by a dedicated call of the compiling toolset, after each modification of the project files list. The file main.c, which was automatically added by STVD, will be removed later. 12.1.
UM0036 12.2 STM8 C tutorial Build In this lesson you will learn how to configure project settings and build the application for debugging. Here, you will: 12.2.
STM8 C tutorial UM0036 Figure 268. Select the MCU 4. Click on the name of the MCU (STM8S208MB), then click on the Select button. The name of the MCU now appears in the Selected MCU field. 5. Edit the file mcuregs.h. As we changed to the STM8S MCU family, activate the definition of the STM8S_FAMILY constant and change the definition of the STM8L_FAMILY constant into a comment. 6. Changing the MCU part number may introduce differences in some peripheral register addresses.
UM0036 STM8 C tutorial Note that STVD automatically fills in the Additional include directories when you add files to your project. 2. Caution: Use the button on the right to browse /include. Note that the change only applies to the current build configuration (Debug in this case). When you make these changes do not forget to repeat them for all build configurations. Select Release build configuration and repeat the operation.
STM8 C tutorial UM0036 Figure 270. C compiler options for Cosmic 12.2.3 Change build settings for a specific file In addition to applying settings at the project level, you can also specify settings for a file. As described in an earlier step, we have included the file main.c as a reference for understanding STVD’s Project Settings interface. However, we do not want to include this file in the build. In this step we will exclude this file from the build, by applying a file level setting. 342/385 1.
UM0036 STM8 C tutorial Figure 271. Exclude the makefile from build Note: At the file level the Project Settings window only displays the tabs that pertain to the selected file. For example, the tabs for a selected C source file are General and C compiler. 3. Click on OK. RESULT: Project information file (*.stp) is updated. 12.2.4 Build the application Now, you can see the final result of the settings that we applied in the Project Settings window. To build the application: 1.
STM8 C tutorial 12.3 UM0036 Start debugging In this lesson you will learn how to start a debugging session and run the application. Here, you will: ● Start the debugging session ● Run and stop the application ● Step through the application Note: If you are already familiar with these basic features, feel free to go to the next lesson, Instruction breakpoints. 12.3.1 Start the debugging session Select the debug Instrument You must select a debug instrument before you can start debugging.
UM0036 STM8 C tutorial Activate a feature You can enable and disable some debug options. For this session we want to use the Watch Pop-up feature that allows us to see the current value of a variable in our source file. 1. From the main menu bar, select Tools>Options. 2. Click on the Edit/Debug tab in the Options window. 3. Place a checkmark in the box next to Enable watch pop-up, then click on OK. Figure 273. Activate the Watch Pop-up feature RESULT: The debug session has started.
STM8 C tutorial UM0036 1. If it is not already open, double-click on timer.c to open the source file in an Editor window. 2. Scroll to line 242 of the source code (timer.c) and click to place your cursor at the beginning of this line. You may use the Go to function of the contextual menu in the editor (right click) in order to navigate easily. 3. Select Debug>Run to Cursor. The application executes up to line 242 of the code.
UM0036 STM8 C tutorial Figure 275. Step over line 242 to line 243 12.4 1. Select Debug>Step Over to step over the reset_bug_count_down function. To view the current line of assembly code to be executed, see the Disassembly window 2. Select Debug>Step Into to step into main_loop. 3. Select Debug>Step Out to step out of init_timer (back to line 244). Instruction breakpoints An instruction breakpoint stops program execution when a specific instruction is reached.
STM8 C tutorial 12.4.1 UM0036 Set an instruction breakpoint 1. If it is not already open, double-click on timer.c to open the source file in an Editor window. 2. Select View>Instruction Breakpoints to open the Instruction breakpoints window. 3. In the Editor window, place the cursor on the nbOfTransitions variable (line 133) to view its current value. A pop-up box is displayed with the value. Figure 276. View the value of nbOfTransitions 4.
UM0036 STM8 C tutorial Figure 277. Instruction breakpoints 12.4.2 5. Select Debug>Continue to run the application from line 107 to the breakpoint. 6. Check the nbOfTransitions value in the pop-up. The variable nbOfTransitions =0. Set a counter on an instruction breakpoint 1. In the Instruction Breakpoints window double-click on the Counter field and enter 50. Figure 278. Setting counter 2. Click on Debug>Continue. 3.
STM8 C tutorial 12.4.3 UM0036 Set a condition on an instruction breakpoint 1. In the Instruction Breakpoints window double-click on the Condition field and enter nbOfTransitions ==60 at the flashing cursor. Figure 279. Setting condition 2. Click on Debug>Continue to continue execution of the application. 3. In the Editor window place the cursor over the nbOfTransitions variable. Its value is now 60. The program stopped after the condition was found to be true, that is nbOfTransitions ==60.
UM0036 12.5 STM8 C tutorial View execution In this lesson you will learn the STVD features that allow you to view the application instructions that have been executed by the debugger. Here, you will: 12.5.1 ● View calls to the stack ● View and change local variables ● View variables using the Watch, QuickWatch and Memory windows View calls to the stack 1. Select View>Call Stack to display the Call stack window.
STM8 C tutorial UM0036 Figure 282. QuickWatch window 7. 12.5.3 In the Editor window place the cursor over the count variable, a pop-up should appear indicating that its value is 3. View variables using the Watch, QuickWatch and Memory windows In this procedure you will learn how to use the Watch window, QuickWatch window and Memory window to inspect variables. The Watch window displays the current value of selected program variables when the executable is stopped.
UM0036 STM8 C tutorial Figure 284. Watch window 6. In the Editor window, click to place the cursor on line 123. 7. Click on Debug>Run To Cursor. 8. Select View>Memory to display the Memory window. 9. In the Memory window, set the start address to the address of the currentState variable (this address is displayed in the Watch window as shown above).
STM8 C tutorial UM0036 Figure 285. Memory and Watch windows 12. In the Watch window right-click to display the Watch window contextual menu, select Display All>Decimal to see the decimal value of currentState, this should correspond to the value displayed in the Memory window. 13. Select Debug>Step Over to step to line 133. 14. In the Editor window highlight nbOfTransitions with the cursor and use the left mouse button to drag and drop it to the Watch window.
UM0036 12.6 STM8 C tutorial Perform memory mapping Memory mapping is the process of defining which areas of memory can be accessed by the application and the type of access permitted, (for example, read only or read/write). This allows verification of the application’s use of memory, ensuring that only memory locations which will exist in the target controller are addressed. In this lesson you will learn how modify the default memory mapping.
STM8 C tutorial UM0036 Figure 287. MCU configuration 9. 12.7 Click on OK in the error message box. In the MCU Configuration window reset the memory area selected above to type: RAM. Advanced emulator features for EMU3 (ST7) and STice (STM8) In this lesson you will learn about using some of the STice emulators advanced features while debugging the sample application that you build in previous lessons.
UM0036 12.7.1 STM8 C tutorial View program execution history The Trace window is used to view the contents of the trace buffer. The Trace Buffer is a physical memory module in the emulator that records the hardware cycles that occur when a program is executed. 1. Select View>Trace to display the Trace window. 2. Right-click in the Trace window to open the contextual menu. Figure 288. Trace contextual menu Note: 3. Select Emulator commands>Clear Trace buffer. 4.
STM8 C tutorial UM0036 Figure 289. Saving trace contents The last 100 records are saved to file where they can be read using a text editor. 12.7.2 Use read/write on-the-fly When the Read/write on the fly option is selected, the Watch window and Memory window are continuously refreshed at one-second intervals and any changing values are displayed in bold type.
UM0036 STM8 C tutorial Figure 290. Memory and Watch windows 6. In the Editor window, locate the bugCountDown variable, select it and drag and drop it to the Watch window. 7. In the Editor window, locate the enableBug variable, select it and drag and drop it to the Watch window. 8. In the Watch window, double-click in the Value field of the enableBug variable and enter 1 at the flashing cursor. The bug is now enabled and the bug countdown begins. 9.
STM8 C tutorial 12.7.3 UM0036 Set an advanced breakpoint The Advanced Breakpoints window gives access to a powerful function based on a programmable multi-level logic Sequencer. Advanced breakpoints allow you to set simple or multi-level breakpoint conditions, in addition to controlling trace recording and trigger output. In this lesson, you will learn how to set a two level advanced breakpoint.
UM0036 STM8 C tutorial 6. The Configuration Summary field shows the logic structure, event definitions and actions to take for all the levels, this can be navigated using the navigation buttons ( ). Use the tabs at the bottom of the right-hand window to switch between the Synoptic and any of the four programmable levels: Level 1 to Level 4. The following diagram shows the settings for level 1. Figure 293. Setting advanced breakpoints 7. The Advanced Breakpoints window is configured as summarized below.
STM8 C tutorial UM0036 Table 86. Level Advanced breakpoint configuration (continued) Configuration summary How to configure it... IF (opcode fetch at timer.c:97) 1. Select Level 2 tab. 2. In First Event, select Event1 then click on the button [...] 3. In Memory Event, select Opcode Fetch then click on Add 4. In Opcode Fetch, select timer.c;97 then click OK. THEN (Goto Level 1); 1. Click on THEN and check Goto Level 1. LEVEL 2 LEVEL 3-4 (empty) 8.
UM0036 STM8 C tutorial 15. From the Trace contextual menu select Column Display... Click on Uncheck all, then check the following: Record, Address, Data, Event, Symbolic Disassembly, BEM. Click on OK. 16. Starting from the last record, find the record for which the BEM (Advanced breakpoints) description is “BEM l1 e3 else”. Select this record and select Previous Source from the Trace Contextual menu. Figure 295. Advanced breakpoint info in trace 17.
STM8 C tutorial UM0036 Figure 296. Setting up a performance analysis 4. Click on Apply and then Run. 5. When the program execution terminates, the Statistics tab opens automatically to display the results of the analysis. In addition, the Graphic tab provides a display of the results. 6. After viewing the performance analysis results click on Close. Figure 297.
UM0036 STM8 C tutorial To make the trap interrupt occur more frequently: 1. Restart the application. 2. Locate the state variable in the Editor window (line 132). 3. Place the cursor on the state variable. 4. Select Edit>QuickWatch to view it in the QuickWatch window. In the QuickWatch window change the timeoutValue value for elements 0, 1 and 2 of this array to a lower value (for example 200). Figure 298.
ST Assembler/Linker build tutorial 13 UM0036 ST Assembler/Linker build tutorial This build tutorial takes you through the steps of setting up workspaces, creating projects and building assembler source code into an application that can be debugged with STVD. Your objective in this tutorial is to build the provided source code in assembler language into an executable in Motorola S format for the ST72311N4. To do this, we have provided you with the following files: ● tim_rtc.
UM0036 ST Assembler/Linker build tutorial RESULT: The Workspace window now contains the workspace my_workspace.stw. Note, however, that in the Build menu, you do not have access to the build commands, because your workspace does not contain a project, yet. The working directory that you have identified now contains the file my_workspace.stw. 13.
ST Assembler/Linker build tutorial UM0036 To do this: 1. First, enter the name realtime in the Project Filename field 2. Enter the pathname to identify the directory where you want STVD to store your project in the Project Location field. By default, this will be the same as the working directory that you identified when you created your workspace. You can use the browse button to find a location if necessary. You can create a folder for your new project by clicking on the Create folder icon.
UM0036 ST Assembler/Linker build tutorial Adding source files to the project 1. Selecting Project>Insert Files Into Project from the main menu bar, this opens a browse window. 2. Select the following files: – st72311n4.asm – st72311n4.inc – tim_rtc.asm For standard installations of STVD these files are located at: C:\Program Files\STMicroelectronics\st_toolset\stvd\examples\tutorial_asm\ 3. Click on Open.
ST Assembler/Linker build tutorial UM0036 5. Drag the file st72311n4.inc to the Include Files folder. 6. You can save your workspace by selecting, File>Save Workspace. RESULT: Open the Project Settings window by selecting Project>Settings in the main menu bar. In the Project Settings window, select the Debug tab. The Source Directories field shows the pathnames that the ST Assembler Linker will use to locate your source files, tim_rtc.asm and st72311n4.asm. Now select the ST7 ASM tab.
UM0036 ST Assembler/Linker build tutorial The application source contains a routine under the #ifdef DEBUG_IT (lines 153-155 of tim_rtc.asm). When activated, this routine generates an output signal on the pin PFDR whenever a timer interrupt occurs. To activate this routine we will use the define option to assign a value other than zero to DEBUG_IT (When DEBUG_IT is zero the routine is ignored). To do this: 1. Select the ST7 ASM tab. 2. Type DEBUG_IT 1 in the Defines field. Figure 302.
ST Assembler/Linker build tutorial UM0036 Figure 303. Exclude file from build To do this: 1. In the field on the left side of the Project Settings window, click on the project to display all the folders it contains. 2. Click on the Obsolete folder that we created earlier in order to view the folder's contents 3. Select the tim_rtc.bat file, the Project Settings window changes to show only those tabs with settings that apply specifically to this file. 4.
UM0036 ST Assembler/Linker build tutorial RESULT: The commands invoked, error messages and warnings that occur during the build are displayed in the Build tab of the Output window. The Assembler is invoked for each of the .asm source files in the project. It is not invoked for the file that we excluded from the build (tim_rtc.bat). The Assembler command line is: asm -sym -li=$(IntermPath)$(InputName).lsr $(InputFile) $(ToolsetInc) obj=$(IntermPath)$(InputName).
ST Assembler/Linker build tutorial UM0036 Figure 304. Change the build configuration To change the build configuration: 1. From the main menu bar, select Build>Configurations. 2. In the Project Configurations window, the active project name is in the Project field. The current configuration is in bold type (Debug should be in bold type). 3. Select Release in the Configuration field and click on Set Active. 4. Click on Close.
UM0036 ST Assembler/Linker build tutorial Entering a user-defined command User-defined commands such as those applied in the Post-Build tab, can allow you to specify tasks to accomplish in addition to the typical build process. Such a task could be to copy a version of the final application to another directory. Figure 305. Enter a post build copy command To do this: 1. Create a new folder on your hard drive. For the purposes of this example, I created a file with the pathname C:\final. 2.
ST Assembler/Linker build tutorial 7. UM0036 Type a space then the pathname for the folder where you want to save the copy of the application file. The resulting command should be: cmd.exe /C copy $(OutputPath)$(TargetFName) c:\final In this command c:\final is the pathname for the folder to which the file will be copied. 8. Click on OK to apply the new settings and close the Project Settings window. 9. Now to build the release version of your application, select Build>Build from the main menu bar.
UM0036 Product support Appendix A Product support If you experience any problems with this product, or if you need spare parts or repairs, contact the distributor or the STMicroelectronics sales office where you purchased the product. Phone numbers for major sales regions are provided on the www.st.com web site. From the www.st.
Product support A.3 UM0036 Getting prepared before you call Collect the following information about the product before contacting STMicroelectronics or your distributor: 1. 378/385 Name of the company where you purchased the product. 2. Date of purchase. 3. Order Code: Refer to the side your emulators box. The order code will depend on the region in which is was ordered (for example, the UK, Continental Europe or the USA). 4.
UM0036 Revision history Revision history Table 87. Document revision history Date Revision Changes 1 Initial release. 1- Feb-2001 2 Added support of EMU3. 1-Aug-2001 2.3 Updated for improved version of Simulator. 1-Oct-2001 2.4 Updated for release of new emulators. 1-Sep-2002 2.5 Updated for simplified USB connection. Updated for In-Circuit Debugging with ST7-ICD (STMC). 1-Dec-2003 2.5.4 Updated with In-Circuit Debugging with EMU3. Added device Discrepancies window. 1-Apr-2004 3.
Revision history UM0036 Table 87. Document revision history (continued) Date Changes 6 Added section What’s new with STVD 4.0.1 on page 24. Deleted Section 6.4: Trace recording, now obsolete. Included information on Raisonance C compiler now supported by STVD7. Updated document format. 06-Mar-2008 7 Updated introduction to include information on STice and STM8 support. Updated Section 4: Project creation and build to include information on STM8 support. Added Section 9: STice features on page 258.
Index UM0036 Index A C advanced breakpoints . . . . . . . . . . . . . . . . . . .19 EMU3 analyzer input signals . . . . . . . . . . . . . . .317 configuration summary . . . . . . . . . . . . . . .301 creating . . . . . . . . . . . . . . . . . . . . . . . . . .292 defining levels . . . . . . . . . . . . . . . . . . . . .292 enabling . . . . . . . . . . . . . . . . . . . . . . . . . .301 examples . . . . . . . . . . . . . . . . . . . . . . . . .304 memory access event . . . . . . . . . . . . . . .
Index UM0036 between files . . . . . . . . . . . . . . . . . . . . . . . .157 between projects . . . . . . . . . . . . . . . . . . . . .158 directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85 intermediate . . . . . . . . . . . . . . . . . . . . .85, 157 output . . . . . . . . . . . . . . . . . . . . . . . . . .85, 157 documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . .22 for hardware configurations . . . . . . . . . . . . . .21 DVP emulator . . . . . . . . . .
Index UM0036 console . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58 go to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 program counter . . . . . . . . . . . . . . . . . . . . .170 H hardware events . . . . . . . . . . . . . . . . . . . . . . .237 hardware test . . . . . . . . . . . . . . . . . . . . . . . . .246 ICD limitations . . . . . . . . . . . . . . . . . . . . . . 235 memory map . . . . . . . . . . . . . . . . . . . . . . . 164 memory types . . . . . . . . . .
Index UM0036 S simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 read/write on the fly . . . . . . . . . . . . . . . . . . .220 software updates . . . . . . . . . . . . . . . . . . . . . .377 ST Assembler Linker . . . . . . . . . . . . . . . . . . . .88 assembler . . . . . . . . . . . . . . . . . . . . . . . . . . .89 linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90 project settings . . . . . . . . . . . . . . . . . . . . . . .88 stack . . . . . . . . . . . . . .
UM0036 Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST’s terms and conditions of sale.