Megawin 8051 OCD ICE User Manual Download Page 28

 

This document information is the intellectual property of Megawin Technology Co., Ltd.

                                                                                                                

 

28

 

 Megawin Technology Co., Ltd. 2014 All right reserved.           

 

                                                                                                                                                  

 

MEGAWIN

 

MAKE YOU WIN

 

8051 OCD ICE 

User Manual, v3.00 

The following example code shows how to use both on-chip XRAM and external RAM in an application. To view 
G_array1[  ],  select 

“Display  xdata  from  on-chip  XRAM”;  and  to  view  G_array2[  ],  select  “Display  xdata  from 

external RAM

”. 

 
Example of using both on-chip XRAM and external RAM 

 

unsigned char xdata G_array1[512] _at_ 0x0000;  // in 'xdata' space, will use on-chip XRAM 
unsigned char xdata G_array2[512] _at_ 0x0000;  // in 'xdata' space, will use ext. RAM 
unsigned int i; 
 

AUXR&=0xFD; //clear AUXR.1 for on-chip XRAM 
for (i=0; i<512; i++) G_array1[i]=0x5A;  // fill XRAM with 0x5A 

    

AUXR|=0x02; //set AUXR.1 for external RAM 
for (i=0; i<512; i++) G_array2[i]=0xA5;  // fill ext. RAM with 0xA5 

 

Note that there will be a linking warning listed below. However, it doesn

’t matter because we intentionally declare 

G_array1  and  G_array2  in  the  same  address  space.  In  fact,  we  access  to  the  different  physical  memory 
controlled by bit-1 of AUXR. 
 

 

 

7.3   Code Optimization and Source-Level Debugging 

 
As shown  in the following  source code, the C51 compiler  won

’t generate any machine code for “

L_var1=0x38;

” 

because  this  statement  becomes  meaningless  due  to  its  following  statement 

L_var1=0xC7;

”.  For  code 

optimization, 

L_var1=0x38;

”  will  be  optimized  out  unless  the  code  optimization  is  disabled  as  described  in 

Section 4.4

 

unsigned char L_var1; 

 

L_var1=0x38;  // ! Note: this statement may be optimized out by the C51 compiler 
L_var1=0xC7; 

 
So,  during  source-level  debugging, 

L_var1

  will  never  show 

0x38

  but  may  show  a  random  number  when  this 

statement is just executed. In fact, there in no machine code for this statement. The user should pay attention to 
it! 
 
Sometimes,  for  debugging  purpose,  the  user  may  disable  the  compiler

’s code  optimization. Note that once the 

compiler

’s  code  optimization  is  disabled,  there  may  be  some  linking  errors  which  won’t  occur  when  the  code 

optimization is enabled. For example, refer to the following linking error message, it means the variables you use 
exceed  the  RAM  an  MCU  has.  To  make  this  error  disappear,  the  only  way  is  to  enable  the  compiler

’s  code 

optimization to let the compiler make more efficient use of the RAM. 
 

 

 

Summary of Contents for 8051 OCD ICE

Page 1: ...ent information is the intellectual property of Megawin Technology Co Ltd 1 Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 Megawin 8051 OCD ICE U...

Page 2: ...Activate the dScope Debugger Function 12 5 2 Introduction to the Debugger Environment 13 5 2 1 Reset Run Halt Step Run to Cursor 14 5 2 2 Source Level Debugging 14 5 2 3 Breakpoint Setting 15 5 2 4 V...

Page 3: ...ility Description The all new Megawin 8051 OCD ICE is a powerful development tool for 8051 embedded system By adopting the Megawin proprietary OCD On Chip Debug technology this ICE provides on chip an...

Page 4: ...ore there is no need of a power adapter for it Hardware Connection Diagram Note Refer to Section 6 5 for more information OCD ICE Interface Pin Number Part No Package OCD_SCL OCD_SDA RST CLK MPC82G516...

Page 5: ...operty of Megawin Technology Co Ltd 5 Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 64 pin LQFP 34 35 33 N A MG82FG5Dxx 16 pin SOP 15 16 14 N A...

Page 6: ...se in the Keil 8051 IDE Software Activate the Setup exe in the folder Database Installer to open the Database Installer Application Program to install the Megawin Database into the Keil 8051 IDE softw...

Page 7: ...IN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 4 Keil IDE Setup Before using the dScope Debugger function of the Keil IDE the user should do some proper settings in the Keil IDE First open the Vision...

Page 8: ...nology Co Ltd 8 Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 4 1 Options Device Select the Megawin Device Database and the target part number 4...

Page 9: ...MAKE YOU WIN 8051 OCD ICE User Manual v3 00 4 3 Options Output Enable the Debug Information It is necessary for creating an absolute OMF file for source level debugging 4 4 Options C51 Disable the cod...

Page 10: ...Megawin Technology Co Ltd 10 Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 4 5 Options Debug Select the Megawin On Chip Debug Driver And enable...

Page 11: ...reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 4 6 Options Utilities Always disable the Update Target before Debugging It is because we have enabled the Load Application at Startup shown...

Page 12: ...rt Debugging After the tasks described in Sections 2 3 and 4 have been done you can start debugging your Vision project 5 1 Activate the dScope Debugger Function After building the project suppose no...

Page 13: ...truction just executed Disassembly Window This window is the default window opened just when the debugger mode is entered It shows the source level code followed by its corresponding assembly code Wat...

Page 14: ...ursor Reset Run Halt Stop Step and Run to Cursor are the basic debug actions The user can easily invoke any of these actions by clicking the short cut buttons in the debugger GUI as shown below 5 2 2...

Page 15: ...to four breakpoints can be inserted simultaneously Insert Remove a Breakpoint Move the cursor to the front of the line and click the right key then click Insert Remove Breakpoint for toggling between...

Page 16: ...User Manual v3 00 5 2 4 View Edit the Contents of Peripherals SFRs There are many peripheral SFRs that don t belong to the registers shown in the Register Window To view or edit these registers select...

Page 17: ...IN 8051 OCD ICE User Manual v3 00 5 2 5 View Disassembly Window Disassembly Window displays source level code followed by its corresponding assembly To open this window select the View item on the mai...

Page 18: ...ogy Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 5 2 6 View Watch Window The Watch Window helps the user to check either local variables or global variables as sh...

Page 19: ...window select the View item on the main menu A pulled down sub menu will be displayed and then select Memory Window as shown below The available commands are 1 d 0x00 d 0xFF for data type 2 i 0x00 i 0...

Page 20: ...from the actual end product In addition because the programming data to be programmed to the target can be saved in the ICE adapter s non volatile storage this stand alone programmer is able to work w...

Page 21: ...Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 6 2 1 Update Programmer Step 1 Choose a MCU Part No If users open ICP application by clicking Menu...

Page 22: ...User Manual v3 00 Step 2 Click Load File and choose loading AP Code or IAP Data Load File can be clicked repeatedly to load different files While loading IAP Data users have to key in Address HEX and...

Page 23: ...ology Co Ltd 23 Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 Step 3 Click Insert ISP Code may choose to insert Megawin provided ISP code or Use...

Page 24: ...cument information is the intellectual property of Megawin Technology Co Ltd 24 Megawin Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 Step 4 H W Option...

Page 25: ...win Technology Co Ltd 2014 All right reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 Step 5 Click Update Programmer to download programming data to the ICE adapter Update Programmer funct...

Page 26: ...t reserved MEGAWIN MAKE YOU WIN 8051 OCD ICE User Manual v3 00 6 2 2 Update Target How to update the target Users may 1 click Update Target to program on line update referring to steps 1 through 4 of...

Page 27: ...6 is 1024 bytes with addresses 0x0000 to 0x03FF That is the address space of on chip XRAM overlaps that of the external data memory So there must be a control bit used to distinguish these two physica...

Page 28: ...cal memory controlled by bit 1 of AUXR 7 3 Code Optimization and Source Level Debugging As shown in the following source code the C51 compiler won t generate any machine code for L_var1 0x38 because t...

Page 29: ...e Debugger mode Requirement 1 The debugged chip must be in un locked state It is because if the debugged chip is locked the downloading of the user s application code in the dScope Debugger mode will...

Page 30: ...6 Error Message There will be an error message Error Target DLL has been cancelled Debugger aborted shown in following figure if 1 ICE adapter hardware fails or 2 Target MCU doesn t work for example n...

Page 31: ...he ICE adapter will be slowed down severely if it is connected to a host via a USB2 0 hub So to speed up the downloading when clicking dScope button to enter the debugger mode the user had better dire...

Page 32: ...ler 2010 05 21 V2 32 Support uVision4 2010 06 02 V2 33 Update IcpProgrammer exe in Database Installer 2010 08 25 V2 40 Supported MG84FG516 2011 05 02 V2 41 Update IcpProgrammer exe in Database Install...

Page 33: ...IcpProgrammer exe in Database Installer 2015 05 21 V2 92 Update IcpProgrammer exe in Database Installer 2015 05 22 V2 93 Update MegawinOCD dll in Database Installer 2015 08 24 V2 94 Update MegawinOCD...

Reviews: