1 / 46

M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005. Overview.

steveevans
Download Presentation

M16C HEW4 Lab 2: M16C Tools Introduction (Version 5) Last Updated: 27 July 2005

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. M16C HEW4 Lab 2:M16C Tools Introduction(Version 5)Last Updated: 27 July 2005

  2. Overview The following is a brief introduction on how to develop and debug M16C programs using HEW4 (High- performance Embedded Workshop) and other Renesas software and hardware tools. The Lab is based on the M16C/Tiny family of Starter Kits. These kits include SKP16C26A, SKP16C28 and SKP16C29-CL.

  3. The HEW / ICD Development Process HEW Editor window SKP16C/Tiny Board M16C/Tiny MCU SIO UART1 1. Write programs using text editor User RAM RAM ICD Monitor RAM I/O Connector 5. Correct errors& repeat process User Flash Flash 2. HEW automates compile & link Monitor Flash Host PC USB 4. Debugging info sent back & forth 3. HEW sends the machine code to the M16C/Tiny SKP during downloads and uses the symbols for source level debugging Correct Errors .c .h .a30 .inc Project files HEW Build command Machine Code Builder: Error reporting Workspace and Source windows Absolute file “.x30” HEW Debugger NC30 Compiler AS30 Assembler LN30 Linker .r30 files Debug Symbols Options and Settings

  4. M16C/Tiny SKP Connectivity

  5. M16C/Tiny SKP Board Features • M16C/Tiny MCU’s • 20MHz Operating Frequency at 3.0V – 5V, 10MHz Operating Frequency at 2.7V – 5V • 32~96kB Flash ROM, 2kB x 2 Virtual EEPROM, and 2~8kB RAM • Up to 71 GPIO with 4 Key-on Wakeup Inputs • Up to 8 Timers plus a Watchdog Timer • Up to 24-channel 10-bit ADC • 2 DMAC • Up to 5 Serial IO’s (SIO’s) (supports I2C and SPI) • Voltage and Oscillation Failure Detection • Clock sources: Main (Xin), Sub (XCin), Internal R/C (ring) • Onboard Features • LED’s (3 User, 1 Power) • Removable 2-line x 8-character LCD • Pushbutton Switches (3 User, 1 Reset) • Thermistor and potentiometer on two A/D inputs • I/O available on Expansion Ports

  6. ICD (RTA-FoUSB-MON) The ICD (In-Circuit Debugger) provides power and a USB interface to the Host PC and communicates commands and data to and from the M16C/Tiny SKP board via a synchronous serial interface. As a debugging tool (during program debug), the ICD + HEW downloads a small kernel (or ROM Monitor) program with the user program to the M16C/Tiny SKP Board . This kernel provides a communication interface between the M16C/Tiny MCU and the ICD + HEW Debugger application on MCU status. While the kernel uses some resources of the M16C/Tiny, the operation of the ICD is transparent to the user’s program. As a programming tool, the ICD + Flash-over-USBTM(FoUSB) Programmer can be used to download user programs to the M16C/Tiny MCU on the SKP Board and many other Renesas’ flash MCU’s (the ICD will support other Renesas flash MCU’s by downloading an MCU Monitor Image (MMI) file for a particular MCU thru HEW or FoUSB Programmer). The ICD can be used with user’s target hardware providing the proper interface (details in RTA-FoUSB-MON manual, see www.renesas.com/skp ) NOTE: The kernel is only downloaded with the user program when Debugging but NOT when using the FoUSB Programmer.

  7. Development Tools HEW4 An Integrated Development Environment (IDE) that invokes all necessary software for building your project. Also communicates with the ROM Monitor Program (in flash on the MCU) for program debug NC30, NC30WA C-compiler. Conforms to ANSI C standards. If not registered within 60days, limits code size to 64k bytes and no support. AS30 Relocatable Assembler Supports structured assembly language and a wide variety of macro instructions. Included with NC30WA Flash-over-USB Programmer Flash programming software for Renesas Flash MCU’s.

  8. HEW IDE Overview HEW is an acronym for High-performance Embedded Workshop. When writing a microcontroller (or any computer) program, the program is usually split into multiple files to make it easier to read and understand. While exactly how the files are organized is up to the programmer, typically, the code is split up in a logical manner into various files (e.g. math functions in one file, serial port code in another, etc). After all the files in a project are compiled and assembled, a linker resolves the final address of the code within a single file. These steps can be tedious and repetitive. To make the process simple, we use an IntegratedDevelopment Environment (IDE) calledHEW.

  9. Lab 2 Hands on Section In this lab you will: • Open and build a project in HEW • Launch a Debug session and: • download your program into the SKP hardware, • set breakpoints, • Step through your code, and • open various debug windows. • Edit a project file, re-build, download, and run the program

  10. Start HEW • From the Windows Start menu, click onPrograms > Renesas > High-performance Embedded Workshop > High-performance Embedded Workshop

  11. Open a HEW Workspace • Select ‘Browse to another project workspace’ when the “Welcome!” dialog box appears. 2 1 • Click <OK>

  12. Open a HEW Workspace (cont.) • In the “Open Workspace” dialog box, Look in the ‘C:\Renesas\SKP16C26A\ Sample_Code\Tutor1’ folder. • Click on the Tutor1.hws file to select it. (The .hws file extension stands for HEW workspace file.) • Click <Open>

  13. Auto-Recovery Is this cool or what? PS. Do not expect to see this screen. I only saw it because I did not shut-down my machine correctly.

  14. The HEW Workspace Workspacewindow Editor window Output window Menu bar(Pull down menus) HEW should look like the figure below. Toolbars A file may, or may not, be open in the Editor Window!

  15. Workspace Window The Workspace Window has three tab windows: Projects, Templates, and Navigation. The Projects tab gives you the easiest way to open a file. Simply double click on the file and it will open in the Editor Window. Files are grouped by type (C, Assembly). Additionally, you can keep the dependent files together, or place them under the file that depends upon them. (We will look at this on the next page.)

  16. Workspace Window Lets change how dependent files are displayed. • Right-click within the Projects window • Select “Configure View…”. • Enable “Show dependencies under each file”. • Click <OK>Notice the .h files under main_tutor1.c?

  17. M16C Linkage Order The 1st code that the linker needs to see is the section information! If you configure the Project Window to show the files in time order, you will see the files in the order that they will be sent to the linker. If you go through the Tutor1 code in the order it will be linked, the first code that is linked defines the section information. (You will find it in the include file, sect30_26askp_tutor1.inc, starting on line 118.)

  18. Link Order(M16C Toolchain Version 5.30.02 and later) By default, HEW links the Project files in alphabetical order. BUT, when using M16C toolchain version 5.30.02 and HEW 4.0 (or latter), you have the ability to manually control the link order! We are going to cover how to manually control the linkage order in Lab 3. So lets go on to other issues…..

  19. HEW Tip When you first start using HEW, right click in every window and see what options are available to that window.Play with every option. See what they do.This method is usually faster than going to the Top Menu’s (Pull Down Menu’s).

  20. Editor (Source) Window Lets look at the Right Click options in the Editor Window. • Double click on the file main_tutor1.c in the project window. (This will bring the file up for editing in the Editor Window.) • Right-click within the Editor Window • Select 4. Right-click within the Editor Window. Notice some of the options are not available.

  21. HEW Toolbars Debug Toolbar1 Editor Toolbar2 Search Toolbar2 Version Control Toolbar2 Standard Toolbar Debug Run Toolbar1 Bookmarks Toolbar2 Templates Toolbar2 HEW is a powerful development environment with a lot of features and functionality. For this lab, the focus will be on features (i.e. Standard Toolbar) that will help you understand the M16C development process using HEW. • Notes: • M16C is supported by the Debug toolbars only on HEW 4.x and above. • See HEW user’s manual about these toolbars.

  22. Standard Toolbar Build File View Output2 Launch Slave HEW2 Current Debugger Session2 Build All Current Configuration2 View Workspace2 Stop Build Launch external Debugger • Build File – builds1 a specific file • Build – builds files that were modified since last build • Build All – builds the whole project regardless of whether there were modifications or not • Stop – stops a running build process • Current Configuration – build configuration (e.g. for debug, optimized, etc) • Current Debugger Session – debug session configuration • Launch Debugger – calls defined external debugger • Notes: • A ‘build’ means running certain files (e.g. source files) under some tools (e.g. compiler, linker) to produce an output file (i.e. X30 or MOT executable files for M16C) • See HEW Users Manual for details

  23. Build (re-build) Tutor1 Build All (re-build) Build • Let’s re-build the Tutor1 project into an executable module. This will re-compile and link all the source files. • Click the ‘Build All’ icon. • If any of the source files are modified, clicking the ‘Build’ icon will result in compiling only the modified files. (This makes generating the executable module faster.) • Status, errors, messages, etc during a build process are displayed in the Output window... • (Always perform a ‘Build All’ when the configuration has changed.)

  24. Output Window The major use of the Output window is to determine if any errors or warnings occurred during the build process. or The “0 Errors, 1 Warnings” OR “0 Errors, 0 Warnings”message will show up in this window when the build is finished. Remember, we are using the Evaluation Version of the Toolchain so after 60 days, the output from the linker will be limited to 64K and you will get a Warning Message informing you of the same. If errors had shown up during your build, you could have scrolled up to find the error message then double clicked on the message to bring up that line of code within the project.

  25. HEW Debugging: Overview HEW 4 integrates in-circuit Debugging. These features can be used to verify that the program we developed works exactly as we intended and when it does not, we can also use HEW to find out why. Breakpoints can be set in HEW to stop the program at certain points and verify registers, variables in memory, etc. The number of breakpoints will vary from MCU to MCU. For M16C/26A, /28 and /29 the maximum number of breakpoints is 6. HEW allows “step” execution in our program, which means the program executes on a per line basis (whether in source level or machine code level). Various windows in HEW allow us to see register values and memory locations As the debugging features of HEW are fully integrated with the IDE, edit, compiling and debugging can be done in the same window.

  26. HEW Debugger Exercise • In this part of the lab you will: • Download and run a program on the M16C/Tiny SKP board • General use of the Debugger including: a) Stepping b) Setting Breakpoints • Modify the program, rebuild, and run the updated program on the M16C/Tiny SKP board

  27. Connect Hardware Since you’ve just completed Lab 1, the SKP should be correctly connected to the Seminar Laptop. Just to verify that the hardware interface is ok, take a look at the blink rate of the yellow Status LED of the FoUSB. (Remember this from lab 1?) If the Status (Yellow) LED is blinking once a second the USB driver for the FoUSB is loaded and working correctly, proceed to the next page. BUT, if the Status LED is blinking three times a second, the FoUSB is not communicating with the Laptop. Disconnect the mini USB cable, wait a few seconds, and then plug it back in. If this does not work, please check Appendix. A Troubleshooting in the M16C/Tiny SKP user’s manual.

  28. HEW debugging example • Launch a debugging session by pulling down the menu in the “sessions” box and select M16C_R8C_FoUSB. 2 • When the Init Window comes up, Click the “Run Mode” tab

  29. RUN Mode (Just Some Notes) Run Mode: Set the mode in which you want the user program to run when executing Go or Come. With this debugger, the monitor program Periodically monitors the User Programs execution status to check whether the user program is halted by a break etc… This means the monitor program interrupts the CPU when executing the user program, and hence, the user program’s real-time capability is lost. To solve this problem, this debugger has two execution modes: Sampling Mode: The user program’s execution status is periodically monitored when executing Go or Come. (You will see updates to the variables in the HEW debugger while the user program is executing.) Free Run Mode: The user program’s execution status is NOT monitored while executing Go or Come. Use this mode for Real-Time capability!

  30. Debug Init Window (cont.) • Verify “SamplingMode” is selected. • Verify Sampling Period is set to 1000 m sec (Sample once a second) • Click on <OK> 1 2 3

  31. HEW Debug Session Step in: (execute 1 line of code) Open Windows: Registers RamMonitor Open ‘Init’ window Step over Memory Status I/O Step out Stop run Reset go Breakpoints Go free Go to cursor C Watch Display PC Go (run) Asm Watch Go to cursor Reset CPU Edit window has not changed, but more buttons are available in the toolbar.

  32. Download the executable file(with debugging information into the M16C/Tiny SKP Board) • In the project window, right click on Tutor.x30 file • Select ‘Download Module’… • Note: When you download code, the program counter is automatically reset to the address the reset vector points to.

  33. Download the executable file (Cont.) View options: Source Mix Disassembly • After the download, three columns areadded to the Editor Window. • Put a breakpoint on line 68. (Double click here. Where the Red Dot is.) • Add a few breakpoints at other points in the code.NOTE: You can only put a breakpoint where code exists. (Code exists when you see information in the Address Column.)Also, if you double click on a breakpoint (red dot), it will disable the breakpoint. Address Column Double clicking here changes pass count (# of times the program will go through this breakpoint before stopping)

  34. HEW Advanced Breakpoint Options • Click on the S/W Breakpoints icon. • Notice Breakpoint information can be saved and loaded between sessions! • Click <Delete All> • Click <OK> (to delete all breakpoints) • Click <Close>

  35. Running Downloaded Program 5 4 • Click on the ‘Reset Go’ icon to run the program. • Note: The ‘STOP’ icon turns red. • On the board, the LED’s D1, D2, and D3 blink sequentially. • Turn the analog potentiometer clockwise to increase the LED blink rate. • Turn the potentiometer counter-clockwise to decrease the LED blink rate. • Click on the ‘Stop’ icon to halt program execution. • Click on the ‘Register’ icon to open the register view.(You may have to adjust the size of this window bydragging it.)

  36. Program ‘Stepping’ • Click on the ‘Step in’ icon several times. • Look in the ‘Register Window’. Register values that are changed turn red.

  37. RAM Monitor Window • Click on the ‘RAM Monitor’ icon.(Icon with color in it!) • Inside the RAM Monitor Window, click on the ‘Base’ icon. • Verify that the Start address is set to 400. • Click <OK>.

  38. RAM Monitor Window The RAM Monitor displays the current value of the memory area shown in the window. Since we set the Run Mode to “Sampling Mode”, the monitor periodically samples the data viewed in the RAM monitor window and HEW updates the window with the sampled data. 2. Click on the ‘Go’ icon and watch as RAM data is updated. Notice that when data is updated, the color is changed to Red. Had we set the Run Mode to “Free Run”, the data inside the RAM Monitor Window would not be updated while the program is running. (Only after you pressed the STOP icon would HEW update the contents.) 3. Click the ‘STOP’ icon.

  39. Memory Window • Click on the ‘Memory’ icon. • If the “Display Address” Dialog box appears, enter: • Display Address = 400 • Scroll Start Address: Leave at 0 • Scroll end Address: Leave at 0FFFFF • Click <OK> • The ‘Memory Window’ displays the location and contents of memory. The main difference between the ‘Memory Window’ and the ‘RAM Monitor Window’ is the Memory Window DOES NOT update the data during program execution. You MUST stop the program, then HEW will update the contents. (Notice the different icons at the top of each Window.)

  40. C Watch Window • Go back to the ‘Editor Window’ and find line 91 in the file main_tutor1.c. • Left click on the variable ‘disp_cont’ (this makes sure your cursor is on the right spot for step 3). • Right click on the variable ‘disp_cont’ and in the pop up menu select ‘Add C Watch’. • The Watch Window will appear. (You may have to adjust the size to see useful information in this Window.) There are a lot of great options in this window. Take the time to look around! (Local, File, Global variables are also displayed here.)

  41. I/O Window • Click on the ‘I/O’ icon. • If, when the I/O Window is opened it contains useful information, skip to the next page, otherwiseyou will need to define the micro that you are dealing with.A) Right click in the I/O Window.B) Select “Load I/O File…”C) Select “Browse”D) Select “M16C26a.io”E) Click on <Open>F) Click on <OK> I/O Window when the micro is not defined!

  42. I/O Window • The I/O Window allows you to easily view peripheral register contents and monitor the status of your I/O port pins without setting up complicated watch variables or learning where the address is for each peripheral register. Also, the I/O structures are grouped together like A/D converter, or Timer A1.

  43. Modifying the Program • Return to the file main_tutor1.c in the Editor Window. • Scroll down until and find the function ‘ta1_irq’ (line 83). • Note: You can also find a function by clicking the ‘Navigation’ tab in the project window and double click on the function name. (HEW shortens the names in the tabs if the window is too small. You may only see ‘Navi’.) • Change line 87 to read: • “ta1 = (0x3FF – ad0);” • Save the revised file. • Build the project.

  44. Load (re-load) Modified Program • The HEW debugger will automatically detect that the program has been recompiled and ask if you wish to download again. • Click <Yes> • Click on the ‘Reset Go’ icon to run the new program. • Turn the analog potentiometer clockwise to decrease the LED blink rate. (This is the opposite of before.) • Turn the potentiometer counter-clockwise to increase the LED blink rate. • Click on the ‘Stop’ icon to halt program execution.

  45. Save the Session • To stop a debug session but leave HEW open (i.e. edit only), re-open the default session. • Click on the Session pull down menu and change it to “DefaultSession”.

  46. End of Lab 2 This is the end of lab 2. If you finished early and time permits, try using the ‘GO to Cursor’ and ‘Display PC’ buttons…

More Related