Home
WicePlus C and Assembly User manual
Contents
1. lalx ee Toolbar sm 8 8 Document Bar a l rbank 0 412 24 78569 ap tebe 0 FF BF 2 23 Source Filis S M RIO FF RO 20 86 EF OF 423 Header Files 3 R12 02 R2PC 0000 3 List Files 7 Pas P 0 01 R3 0001 1000 e Page ban ia iiopage 1 814 01 R4 0010 1100 Sa Lon d RIS R5 00 RS 00 R5 00 R5 00 C5 EO ibrary Files 4 gt 5 Rie 81 R5 00 0 R6 DF R 00 Co FF C O o d INPS FR R7 40 FF C O prg um Rig 00 00 RB FF C 0 review Ims 7 t 8 8 C rievew Jta Labet e ERE RIO FF R 0 DC RO FF C9 0 aa is mor Ria FF RA 18 R FF RA 00 RA 0 16 mov RIB 00 RB 00 RB 00 RB 00 RB FF CB 0 17 mov 0 12 Ric 00 RC 68 00 cc 18 mov 0 13 RID 00 RD 10 RD 69 RD 0 CD 0 2 mov 514 8 RIE 0 RE 00 00 0 mov mro RIF 41 RF 00 CF 00 mov 0 16 22 mov 0 17 vn Stack 23 mov 0 18 lxi 24 mov 0 19 ES indow 5s
2. lt lt gt gt amp amp lt lt gt gt DS ELSE ELSEIF ELSEIFE gt END ENDIF ENDM ENDMOD ENDP EQU EXTERN IF IFE IFDEF IFNDEF INCLUDE m MODULE NOP PAGE ORG PROC PUBLIC b instructions mnemonics ADD AND BC BS CALL CLR COM COMA CONTR CONTW DAA DEC DECA DISI DJZ DJZA ENI INC INCA INT IOR IOW JBC JBS JMP JZ JZA LCALL LJMP MOV NOP OR RET RETI RETL RLC RLCA RRC RRCA SLEP SUB SWAP TBL WDTC XOR LCALL LPAGE PAGE BANK Some MCU don t have LCALL LJMP PAGE and BANK instructions users have to study the specific MCU spec 104 c Register names A WicePlus C amp Assembly User s Manual Chapter 5 Debugger source level debugger The following two steps show how to run the debug environment Step 1 Set breakpoint In the Debug menu only the Go function can enable the breakpoint function and the other items would disable it automatically during being executed Step 2 The available function of the Debugger menu includes Free Run Reset Into Step Over and to Cursor 5 1 Employ breakpoints a What is breakpoint Breakpoints are the combinations of addresses and pass counts A program should be stopped as one of the defined addresses matches with the contents of the program counter and its relative pas
3. 16 2 2 3 Ihe Special Register WIDUOW 22 2 24 The Cal Stack Hr 24 2 2 5 The General Registers Ram Bank Window 26 2 2 5 The Watch Window 28 2 2 7 Data RAM 34 228 LCD RAM WiNdOW Se 35 229 Output iu L Lu a E aa 39 2 3 WicePlus Menu Bar and its Commands 41 209 1 FIS CII ss ananas a hagas 41 2 32 Edit Men aus CHEN TEAM 42 23 3 View IVIGI uuu kaqyaqqastuyasasuyqaspuspasasashusyaqiusquqasqayqaqtapasaqk 46 2 3 4 47 2 3 9 Deb e Men 49 230 Tool MeH oer E E E N E 59 Option Ment a R 64 2 3 9 IDE M U 73 2 3 9 Window I 73 2 3 10 Help qa S 73 P a eosin 75 2 4 1 Toolbar Icons and Functions nta 75 ae WicePlus amp Assembly User s Manual 23 Document B ab raen Es UR EL EH A 77 2 6 Status c PE rc 71 PES 78 Chapter 3 Getting Started 79 S Hardware POWer uD
4. nasa 159 AJ Class assembler BETODS 160 A Class D Or u au nuy aun aaa 164 WicePlus C amp Assembly User s Manual e 7 A4 Class D 164 Appendix C Conversion Table 167 B 1 Conversion between C and Assembly Codes eese 167 Appendix C Frequently Asked Questions about Assembly FAQ 175 C 1 ICE can not connect to PC2 een eene ness ennt nnns 175 C 2 The connection from ICE to PC is successful but program dumping fails 175 If ICE memory is checked and the result of ICE memory is error 175 4 If users try to reconnect the same ICE from PC why does the execution become eyT aisuiek dte C dcr c 176 C 5 Why can t Step Into 176 6 Q If source files are located in Novell file server why is the program reassembled again yu yu nS D Qu uu 176 Appendix D Frequently Asked Questions About Tiny Compiler FAQ l 177 D 1 What is the maximum number of the function parameters 177 D 2 In a function what is the maximum depth of the function call 177
5. 94 4 5 Program TIER CU VCS 95 4 6 Conditional ass mDb_y uu a nu ua eeu eee 101 4 7 Reserved Won 104 Chapter 5 Debugger a source level debugger 105 3 I Employ breakpoints 105 3 2 Tod bus e matu c Qaya 106 WicePlus C amp Assembly User s Manual 5 Chapter 6 C Fundamental Elements 107 HU 66 TETTE 107 6 2 Reserved og ette Murat bcd 107 6 3 Preprocessor Directives DN MED PE QN I MR NS 108 6S NE IUD T 108 6 3 2 Og T 109 6 3 3 Hf else elif endif 110 63 4 FEL PAIGE 110 6 4 Literal Constants 111 6 4 1 Numere Constant 111 ur MAN m LI 111 6 43 Strine uu OE ES EERE y 111 65 Data I tr 112 6 0 ioo nee S euasit EE 113 6 7 Structure and LIDIGE dia a S 113 5 ATAY 114 09 PODMGT oo 115 6 0 Ot uyu uyu UU EM 115 6 10 1 Types of Supported Operators
6. 115 117 6 11 If else Statement TERM 117 6 12 Switch Statement ianiai 117 6 13 Whil 118 6 14 Doyle Statement ER 118 119 6 16 Break and Continue Statements 119 6 17 G t Statement NP NT 120 LOI tiere DENEN DOTT 120 6 18 1 Function Protolype iibi Bresse RUE 120 5 15 2 Function DefmilioI 121 Chapter 7 C Control Hardware Related Programming 122 TA Page a a an n 122 T2 UU Control Page 124 6 WicePlus C amp Assembly User s Manual T3 Ram Bank nan EE 125 126 7 5 Data LCD RAM Indirect Addressing 127 7 6 Allocating C Function to Program 1 128 7 1 Putting Data ROM uu Ra uei 129 7 8 Inline Assembler a E 130 KSA 130 7 8 2 Use of C Variable in the Inline Assembly 131 yn Mudo t 132 7 10 Interrupt Routine in TOL 132 7 10 1 Interrupt Save Procedure 133 710 2 Interr
7. B2 2X 2 3 dddddddddddd AX SS eee poc m mm Information Assume there is error message Error LNK1116 Can t allocate space for C Register pr0 at RPage O 0x10 which need 2 byte s Now have to adjust continuous 2 bytes space in 0 10 0 1 for it 7 2 Control Page iopage io variable name Q address iopage io control page gt Declare the variable at the register page it is located Users have to declare clearly that the io variable is located at which iopage though there is only one io control page Example io unsigned int myIOC1 00x05 iopage 0 myIOCl is at address 0x05 of io control page 0 io unsigned int myIOC2 00x05 iopage 1 myIOC2 is at address 0x05 of io control page 1 124 e WicePlus C amp Assembly User s Manual RO A V R1 TCG R2 PG R3 R4 0 1 iopage 0 ioage 1 5 IOC5 R6 IOC6 R7 IOC7 R8 IOC8 R9 IOC9 RA IOCA RB IOCB RG IOCC RD IOCD RE IOCE RF IOCF 7 3 Ram Bank variable name lt address gt bank bank number gt Declare the variable at which RAM bank it is located The bank number has to be indicated including variable is declare at at Bank 0 Example 1
8. M EDEYAN MPNE 79 3 2 Starting the WicePlus 79 SI Connect u L I A ea ots pH u ime didus 79 3 2 2 Code Option Dialog R 81 3 2 3 Accelerate Reading Registers Dialog 81 3 3 Create q New onses 81 3 4 Add and Remove Source Files from to ProjJect 83 3 4 1 Create and Add a New Source File for the Project 83 3 4 2 Add Existing Source Files to the New Project 84 3 4 3 Deleting Source Files from 85 3 5 Editing Source Files from Folder ProJect 85 3 5 1 Open Source File from Folder for Editing 85 3 5 2 Open Source File from Project for Editing 86 3 6 Compile th Projects cH 86 3 7 Dumping the Compiled Program to ICE 88 onusta 88 3 8 1 Breakpoints ctii NE 91 Chapter 4 Assemble and link 92 4 1 Assembler and linker process 92 4 2 Statement maana akna SS ayasa 92 94 4 4 Assembler arithmetic operations
9. 9 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 c2 50 co jo 0 0 0 Set Mapping Show Data Show Graph M Show Control 0 0 0 0 0 0 0 0 0 0 ofa ojn ole 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ooo gt lt lt lt lt lt lt lt D D O O O o sEc 0 sEGRange 0 31 Load File Swap Auto Increase 0 COM Range 0 Save File Fig 2 9 LCD RAM Window The LCD RAM window consisted of four sections as described below 1 Data Pane This pane displays the contents of the LCD RAM Cx denotes the LCD signal COM x Sx denotes LCD signal Segment x To modify the contents of the LCD RAM element double click on the selected element grid block The color of the elements will change from pink 1 to white 0 and vise versa Any related messages will be shown in the Output window Graphic Pane This pane displays the status of the loaded BMP graphic If no BMP graphic is loaded no display is shown Control Pane This pane controls the link between the BMP graphic and the data as well
10. are reserved for C Compiler d Uninitialized data D Initialized data b Uninitialized bit data B Initialized bit data Data Register Data 0123456789 ABCDEF 0123456789 ABCDEF 012345678 B 2x 0x00 dddbbbbbbbbb bb 0x00 B 3X 0 10 0 10 Bl2X 0x20 bbbbhbbhhbbhbh IND Data Bl3X 2X 3X B3 2X B3 3X Call Depth Depth Interrupt Function 3 14a Messages after compiling successful 3 7 Dumping the Compiled esee Save Project Close Project Program to ICE i Add Files to Project Delete files from project With the source files deprived of its errors and amp compile Alt F7 successfully compiled download your compiled E Rebuild al Alt F9 program to ICE using the Dump to ICE command es from Project drop down menu or its corresponding shortcut key Fig 3 15 Dump to ICE 3 8 Debugging a Project FS Free Run F10 4 Reset F6 With the compiled program successfully P Step Into E downloaded to ICE you are now ready to debug TP Step Over FB the files Be sure the ICE is properly connected P Step Out H Go
11. register page number gt The data type is used to declare a variable at a certain register page Users have to declare clearly which register page is including rpage 0 Example unsigned int myRegl 0 03 rpage 0 myRegl is at address 0x03 of register page 0 Although the specific register only have one register page the register page number cannot be ignored unsigned int myReg2 0 05 1 myTest is at address 0 05 of register page 1 the specific register have more than one register page user should point out in which register page th variable is located struct st nsigned int b0 nsigned int bl nsigned int b2 nsigned int b3 nsigned int b4 G G oG G G WicePlus C amp Assembly User s Manual WicePlus amp unsigned int 5 1 unsigned int 6 1 unsigned int b7 1 struct st myReg3 0x06 0 CONT RO A V R1 TCC R2 PC R3 R4 rpage 0 rpage 1 R5 IOC5 R6 IOC6 R7 IOC7 R8 IOC8 R9 IOC9 RA IOCA RB IOCB RC RD IOCD RE IOCE RF IOCF iopage 0 ioage 1 Declare variables in common registers 0x 10 0x 1F Example unsigned int uiR12 register 0x12 unsigned int uiRDD unsigned int uiR17 unsigned int uiR18 Q9 unsigned int uiR19 Q9 unsigned int uiR1A Q9 unsigned int uiR
12. 0 00002 DIZ oxic 0 00002 JMP 2 0 000020 BANK B 0 00002 MOV 0 27 0 00002 2856 LI LIE LIEIEIE ES EI ELC Osa OxDODO031 BC 0x03 D 0 000032 RLC Dx27 0 000033 Fig 9 2 Speed Up debug in C Step into F7 debug mode Please note some situations are right For example if the C code is ci in line 2856 so in Speed Up Debug after step into F7 line 2588 the value of ci will increase 1 9 2 View corresponding Assembly code in C environment After first dump code to ICE F3 in C environment users can press Assembly code like figure x After that during debugging users can see C and assembly code fully occupy in Edit window Users have to active and set focus on C file if you want to press any button in menu 156 o View Project v Special Register v General Registers Bank y Data Ram LCD Data Output v Watch Assembly Code Toolbars v Status Bar v Document Bar WicePlus C amp Assembly User s Manual Fig 9 3 Press Assembly code button in View estcode c oix 2850 722222272206 0042 MOV 0 29 2851 0043 1 1 3 2855 2852 01044 0x27 2853 0 7 0045 0 1 A 2854 0 4 0046 CLRA ci ci 3 0047 0 03 ci ci 4 0048 DJZ 0 1 0049 JMP 02 0050 BANK 00 0051 0x27 0
13. gt zs jx 7192 sub 21 al 78808 5 APJ 093 call sub_22 5 24 Source Files 094 E 22 7 sub 22 pec 097 call 23 cnet it 75098 nop 039 Tet E Map Files Library Files call sub 24 1059 call sub 25 sub 26 sub 27 T 8 2 5 5 Using Step by Step execution to change the values of the higher level stacks Currently WicePlus is unable to determine the correct stack level position at which the ICE stops This is due to the ICE hardware limitation which unable the WicePlus Call Stack window to display the correct stack level position properly However this does not affect the actual normal stack operation Also note that after completing the Go or FreeRun command execution if all stack level values in Call Stack window display the same value this could be caused by either the program has entered the first level of the call function or the program has not entered any function t all Under this condition it is not recommended to use the StepOut command Otherwise the program will jump to the first level address in the Call Stack window 2 2 5 General Registers Ram Bank Window gt 6 7 8 9 B IC D F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F
14. 0 00 4 51 5 Q6 nop nop Q8 nop Q9 inp 51 1 org Oxfff 2 jmp sl 3 org 0 00 4 51 5 nop Q5 no o rm nop jmp s1 54e WicePlus C amp Assembly User s Manual Breakpoint or Select this option to set breakpoints at or more address locations with counter number a Select the Breakpoint or option Breakpoint or b Enter the breakpoint address es and counter in the format breakpointAddress 1 breakpointAddress2 counter This means that a breakpoint is set at locations 0x01 0x02 and 0x04 with the counter set to 1 0x00 0X02 0X04 0X01 c Click OK to save the settings You should see the group breakpoints indicated in the Editor window or as shown in the figure example below org Oxfff jmp sl org 0 00 Breakpoint nest Select this option to set nested breakpoints consisting of groups of address locations with each group assigned with a counter number a Select the Breakpoint nest option Breakpoint nest WicePlus C amp Assembly User s Manual 55 b Enter the breakpoint address es and a counter in the format of breakpointAddress1 breakpointAddress2 counter The following figure shows an example with 0X00 0 01 0X03 0 02 This means that the program will run address 0x03 twice run address 0x00 only once and then terminate 000 0x01 0x03 0x02 c Click OK to save the
15. Address value 26 narrib 2 se AAAAA 0x20 Bit 1 at Bank 0 0x00 27 mov BBBBB 0x21 Bank 0 0x14 28 mov Ox1D a CCCCC 0x05 Register 0 29 mov 0 1 20000 0 05 Register 1 0x00 30 mov Ox1F a 0x10 0 05 Register 2 0x00 mov 0x20 a 66666 0x05 Register 3 32 mov 21 HHHHH 0x06 Control 0 xFF 2 mov III 0 06 Control 1 0x00 8 mov 3 T5 il T 5 Watch of Gen Register 2 3 4 5 6 7 5 lt 4 4 r j 3 3 5 je gg 9 B p JE B Bank Window Ej Ex FO 14 64 00 00 00 00 06 AB C4 00 00 86 00 DE 27 B DC 12 A2 00 Al BD 9 Al 02 78 00 BT 55 02 50 B8 13 B3 6D F2 BB BC 82 12 20 39 4C 76 9i BOL 85 E4 4C 6C E5 A7 60 6C Ad 21 22 90 C2 21 Data Bl X 29 08 02 1 OD 9A 52 FA D2 EB 41 DO 01 71 24 09 16 EB 90 RAM Window 11 C3 40 B E5 2C 03 10 3D 00 CC 40 42 D 4B 62 40 93 91 29 528 529 Output Window O Error a 0 User s Information X Find in Files Mesage Program Rom j Sia Status Bar Brom ROM Processed 100 14 Coll LCD Window Watch Window Fig 2 1 WicePlus Main Window Layout 12 WicePlus amp Assembly User s Manual 2 2 WicePlus Sub Windows The sub window may be displayed or hidden by clicking on the pertinent window commands from the View menu see Section 4 3 3 3 2 2 1 The
16. C ORE m RI 10 569 569 53 30 INC 0 11 D lem RIS 10 569 569 54 30 INC 0xi2 D C E IBI E10N5 692569 DT 55 30 INC 0x13 Be RI E10 569569 DT 56 i 30 INC 0x14 D ARE 10 569 569 57 10 568 569 Dr 58 Save 40 step use find dialog of output windows 1 Click right button of mouse and a menu popup 2 Select Find item Find 7 Match whole word only direction Cancel Match case up down Move with code line a Find Input a word you want to find out Find next Click the button to find next word which be matched Hotkey Alt N Cancel Cancel the dialog Up Find forward Hotkey Alt U Down Find backward Hotkey Alt D Match whole word only Match whole word only Hotkey Alt W Match case Match upper or lower case Hotkey Alt C Move with code line when select the matched line in trace log mark code line respond to the line in the trace log Hotkey Alt M Hot key work when dialog active When WicePlus active find forward Ctrl find backward Ctrl WicePlus C amp Assembly User s Manual Z 2 33 WicePlus Menu Bar and its Commands ve File Edit View Project Debug Tool Option IDE Window Help 2 3 1 ew en Ctri O ose Save Save As Gl Save All Ctrl S Open P
17. 96 WicePlus amp Assembly User s Manual org 0 10 0010 0 20 0011 inc 0 20 mov 0 20 f PROC definition of subroutine The directives make a program more readable Syntax label PROC statements ENDP Example PROC BC 0X04 6 BC 0X04 7 RET ENDP P S PROC and ENDP directives are only more readable of program So RET instruction must be existed in subroutine g INCLUDE Including another source files The instruction makes the program refined and readable INCLUDE function can include system default files and user s defined files a Include system default files example for EMC456 INC EMC32 INC Syntax INCLUDE filename Example INCLUDE lt EMC456 INC gt b Include user s defined files Syntax INCLUDE path file name Example INCLUDE C EMC TEST TEST456 INC The user s defined file must include full path and name P S Usually including file includes variable defined macro defined and subroutine defined h PUBLIC and EXTERN Defined scope of the global label is public or external Although the WICE software is project oriented a project can contain two or more files If the global label is referenced by another file the global label must be defined to PUBLIC in the defined file and must be defined to EXTERN in the referenced file PUBLIC Syntax PUBLIC lt label gt lt label gt EXTERN WicePlus C amp Asse
18. Find Ctl F 7 nop Find in Files 8 nop 3 jmp sl Ctrl F2 Shift FZ Clear All Ctrl shift F2 Go to bookmarked lines For example if you have previously bookmarked Lines 1 5 and 8 as shown in the sample figure below and want to return to the lines access Toggle command again The Previous Next and Clear All commands become active this time Click Previous to go upward to the bookmarked line previous to current position or directly press the shortcut keys SHIFT F2 Click Next to go downward to the bookmarked line next to current position or directly press the shortcut keys CTRL SHIFT F2 WicePlus C amp Assembly User s Manual e 19 Click Clear to remove all existing bookmarks org Oxfff jmp sl org 0 00 sl nop nop nop nop jmp sl Coon on I WN Index BookMarks Insert bookmarks with index numbers With indexed bookmarks you can directly access to the bookmarked line you wish to return to To insert bookmark place cursor on the selected command line then click Edit gt Index BookMarks gt Toggle BookMark x where is the 0 9 You can also directly press the shortcut keys CTRL x where x to be assigned index bookmark number 0 9 File Edit View Project Debug Tool Option IDE Window Help Undo Cu Redo Cut shift Delete B
19. aa_label macro num 1f gt 0 400 be 0x3 5 bs 0x3 5 else bc 03 6 be Dx3 5 endif endm org xfff jmp start org 0 0 start aa label bh label call bh label aa label jmp org 0 400 bh label inc 0x20 ret Examplel If omit org 0x400 bb label is an indefinite address before aa label macro expanded It will to show the error message error A037 The operand value can not be calculated FCALL MACRO addr IF faddr Ox400 5 0 400 LCALL addr ELSE CALL addr ENDIF ENDM FJMP MACRO addr IF 899 0 400 5 0 400 LJMP addr ELSE JMP addr ENDIF ENDM Example2 EM78P510N FCALL and are reserved words Those two words judge the program code over page or not WicePlus C amp Assembly User s Manual 99 FPAGE MACRO NUMB Example3 78 4475 IF NUMB FPAGE FCALL and FJMP are reserved BC 3 5 words Those words judge the program IMP code over page or not ELSEIF NUMB BS 0 3 5 0 3 6 ELSEIF NUMB BC Uz3 5 BS 0 3 6 ELSEIF NUMB BS 0 3 5 BS 0 3 6 ELSE ERROR ENDIF FJMP MACRO ADDRESS IF ADDRESS 0400 570x400 FPAGE ADDRESS 0X400 ENDIF JMP ADDRESS ENDM FCALL MACRO ADDRESS IF ADDRESS 0X4D0 5S 0X400 FPAGE ADDRESS 0X400 CALL ADDRESS FPAGE 6 0 400 ELSE CALL ADDRESS ENDIF ENDM k MACEXIT The instruction is only used in the macro defined instructions If the MACEXIT instructio
20. 0x14 AND 0xE0 OR 100 7 7 100 f f amp const 1 const 2 WicePlus C amp Assembly User s Manual MOV A 0x06 AND A const 1 OR A const 2 MOV 0x06 A 100 4 4 100 e 173 Arithmetic expression MOV A e 100 3 3 100 all variables are int ADD data type MOV f A MOV 100 3 3 100 SUB MOV 9 INC 100 1 1 100 DEC f 100 1 1 100 MOV A a 100 9 9 100 MOV 0X1C A MOV A b MOV 0X18 A CLRA L1 ADD A OX1C DJZ 0X18 JMP L1 MOV A MOV 100 11 11 100 MOV 0 1 MOV A b CLR 0x18 L1 SUB 0 1 0x03 0 INC 0 18 0x03 0 JMP 0x3BB MOV A 0x18 MOV c A Compound 100 2 2 100 assignment e ADD f A all variables are int SUB F f A data type AND 9 KOR f A OR f A BC 0x03 0 100 2 2 100 f 0 03 0 100 2 2 100 f 174 WicePlus amp Assembly User s Manual Frequently Asked Questions about Assembly FAQ C 1 Q ICE can not connect to A Please check the following steps Step 1 Check the power supply with output around the range of 17 23 voltages Step 2 Check the printer cable between ICE and PC Step 3 Check the oscillator on the hardware Step 4 From the Option menu choose ICE code option Check
21. ICE210N EM78P220N ICE210N 6 Assembler EP 3 4 Project Menu EM78P259N 1 259 EM78P31 1N 1 9 EM78P312N ICEB09N 1CE320N EM78P331N ICE330N EM78P342N ICE341N Fig 3 5 New Dialog Showing Project Tab for Creating New Project Derived from File Menu 3 Select Projects tab from the NEW dialog 4 Assign name for the new project in the Project Name box suffix prj will auto append to the filename 5 Locate the folder where you want to store the new project You may use the Browse icon to find the appropriate folder 6 Select the target microcontroller for your project from the Micro Controller list box 7 Click OK button after confirming all your choices and inputs The new project is created with the defined project name and microcontroller you have selected is displayed on top of the Project window Target Microcontroller i as Header Files ilename apj or cpj in C c3 List Files mode E C3 Map Files Library Files Fig 3 6 Project Window 82 WicePlus amp Assembly User s Manual am 3 4 and Remove Source Files from to Project You can either insert existing source files into the new or existing project create new ones with WicePlus text Editor and insert them into the project 3 4 1 Create and Add a New Source File for the Project If your source file is yet to be created you can take ad
22. Project Window There are two views in the Project Window 1 FileView Project Filename cpj in C mode The Project window holds the Source DUM Header List and Map files T ras Source Files Where mu testdt Source Files dt are the assembly source E a files that are added into the current project In C mode source file will be c file 403 Files Header Files h are the reference files C Library Files required source program Fig 2 2 Project Window FileView g J List Files st the list files Map File map the map file Library File bbj are the reference files required by source program The Title Bar of the Project window shows your current microcontroller and project filename 2 Label Function View gs MAIN C interrupt interrupt a EEPROM C WicePlus amp Assembly User s Manual e 13 Gn After performing a code dump WicePlus will automatically determines the functions from C code see figure above and labels from ASM code The result is displayed in the Label Function View mode of the Project window categorized by files To access the Label Function View window click the Label Function View tab at the bottom of the Project window To find the location of the displayed label or function in the file double click on a label or function WicePlus automatically
23. Psst 2 51 3 0 00 zu Select 4 51 Line Cth 5 nop 8 6 d Find nop Find in Files 8 nop Replace 51 BookMarks Index BookMarks Go To Index BookMarks Goto Bookmark O Go to Bookmark 1 Alti Go to Bookmark 2 Alt 2 Go Bookmark 3 3 Bookmark 4 Alt4 Bookmark 5 5 Goto Bookmark 6 8 FileView Go to Bookmark Goto Bookmark 8 8 x gt f Connecting Go to Bookmark 9 9 Add to Watch Watch the data change at the register locations in the Watch window during debugging After dumping project to ICE right click on a temporary register name followed by symbol and register page or ram bank or control register page as indicated in the example figure below From the resulting pop up menu click Add to Watch Then observe Register R11 being added into the Watch window Real time changes of the data during debugging can WicePlus C amp Assembly User s Manual e 21 observed from this window R10 0 10 0 Shift Delete Ctrl C Add to Token pool Last Position Next Position BookMarks Index BookMarks Go To Index BookMarks gt Add to Watch When right clicking on a temporary register name with double equal characters but without register page ram bank control register page
24. Short Variable shortVar1 0x1234 MOV A 90x34 MOV shortVar1 MOV 0 12 MOV shortVar1 1 A 100 4 4 100 shortVar2 shortVar1 MOV A shortVar1 MOV shortVar2 A MOV A shortVar1 1 MOV shortVar2 1 A 100 4 4 100 Long Variable longVar1 0x123456 MOV A 90x56 MOV longVar1 MOV A 0 34 MOV longVar1 1 MOV 0 12 MOV longVar1 2 100 6 6 100 longVar2 longVar1 MOV longVar1 MOV longVar2 MOV longVar1 1 MOV longVar2 1 MOV A longVar1 2 MOV longVar2 2 100 6 6 100 167 WicePlus C amp Assembly User s Manual loop for i 0 1 lt 5 i INC MOV A 0x05 SUB A 0x14 JBS 0x03 0 JMP L1 100 7 7 100 While statement while cnt 1 L1 MOV A cnt XOR A 0X01 JBS 0X03 2 JMP L1 100 4 4 100 Do while statement while cnt 1 MOV cnt MOV A 90x01 A 20x01 JBS 0x03 2 JMP L1 100 4 4 100 Do while statement do Var_c2 while var_c1 11 INC c2 0 7 c1 JMP L1 100 3 3 100 If else statement 168 o unsigned int cnt MOV cnt JBS 0x03 2 JMP ENDIF L1 MOV A 0X05 cnt JBC 0 03 0 JMP ENDIF 100 10 10 100 WicePlus C amp Assembly User s Manual Switch statement unsigned int cnt switch cnt
25. break default MOV A cnt MOV 0X14 A MOV 0 14 A 0x01 JBC 0X03 2 JMP case 2 MOV A 0X14 A 0X02 JBC 0X03 2 JMP case 2 MOV A 0X14 A 0X3 JBC 0X03 2 JMP case 3 JMP default Case 1 JMP ENDSWITCH Case 2 JMP ENDSWITCH Case 3 JMP ENDSWITCH Case 4 default ENDSWITCH 106 18 17 100 Function main int i i fun 3 return int fun int in return in 1 WicePlus amp Assembly User s Manual using EM78806B MOV 0x03 0 MOV in A CALL FUN MOV A 0x10 BANK 90 MOV 9 A FUN MOV A 0x14 BANK 0 MOV temp1 MOV A in MOV 0x14 A MOV 0X10 A MOV 0 01 ADD 0 10 MOV A temp1 MOV 0 14 136 19 14 100 e 169 Const array const int myConst 5 1 2 3 4 5 main int i i myConst 3 return using EM78569 MOV A 0x3D MOV 0x19 A MOV A 0x1F MOV O0x1A A PAGE 0 0 CALL 0x280 PAGE 90x00 BC 0x04 6 0x04 7 MOV 0 20 0X03 0 0x1A TBL PAGE 0 0 JMP Ox2FE MOV 0x19 TBL RETL 0x01 RETL 0x02 RETL 0x03 RETL 0x04 RETL 0x05 162 21 13 100 Register page 170 unsigned int mnyR5PO 90x05 0 unsigned int myR5P1 20x05 1 unsigned int myR5P2 90x05 2 myR5P0 0x12 myR5P1 0x34 myR5P2 0x56 using EM78P468N MOV A 0x1
26. member declaration specifiers member declaration specifier member declaration specifiers member declaration specifier The structure groups related data and each data in the structure can be accessed through a common name Unions are groups of variables that share the same memory space Example 1 struct st unsigned int 50 1 unsigned int 51 1 unsigned int b2 1 unsigned int 53 1 unsigned int b4 1 unsigned int b5 1 unsigned int b6 1 unsigned int b7 1 struct st 5 0 05 0 struct R5 is related to 0x05 rpage Example 2 struct tagSpeechInfo short rate long size SpeechInfo union tagTest char Test 2 long RWport Test 6 8 Array declarator array declarator array declarator constant expression array declarator constant expression Array is a collection of same type data and can be accessed with the same name 114 WicePlus amp Assembly User s Manual Example int arrayl 3 10 char port 4 const int myarr 2 0 11 0x22 0x11 0x22 will be put at program rom 6 9 Pointer declarator type qualifier list declarator A pointer is an index which holds the location of another data or a NULL constant types of pointer occupy 1 byte Example int pt 6 10 Operators 6 10 1 Types of Supported Operators The supported operators for the C expression are as follows Arithmetic operators Incr
27. 1 1 nsig nsig nsig nsig ned int myDatal 00x22 bank 0 myDatal is at address 0x22 of ram bank 0 ned int myData2 Q00x22 bank 1 myData2 is at address 0x22 of ram bank 1 ned short myshort 0 20 bank 0 myshort is at address 0x20 and 0x21 of ram bank 0 ned long myLong 00x24 bank 1 myLong is at address 0x24 0x27 of ram bank 1 WicePlus C amp Assembly User s Manual e 125 Bank 0 1 2 3 4 5 6 7 8 9 A B C D E 2X 3 myData1 B1_2X B1_3X 7 4 Bit Data Type bit lt variable name gt lt address gt bitsequence bank lt bank number gt rpage lt page number gt Bit data type occupies only one bit 126 WicePlus amp Assembly User s Manual Example bit myBitl location of myBitl is assigned by linker bit myBit2 0x03 rpage 0 if doesn t declare bit sequence the default location is at bit 0 Therefore myBit2 is at bit 0 of 0x03 of rpage 0 bit myBit3 0 04 5 1 myBit3 is at bit 5 of 0x04 rpage 1 bit myBit4 0 05 6 1 myBit4 is at 0x05 bit 6 of 1 bit myBit5 0 22 83 bank 1 myBit5 is at 0x22 bit 3 of ram bank 1 rpage 0 rpage1 0 oo3 myBit2 is at 0x03 bit 0 0x04 myBit3 is at 0x04 bit 5 0x05
28. 1 lt lt bit _asm iow port set_output P6CR 0x04 D 14 Q Does C Compiler support all assembly instruction A TCC2 supports all assembly instruction But some instructions have to implement by WicePlus C amp Assembly User s Manual e 179 the form of inline assembly Such TBRD TBWD 0 15 How clear all ram all banks A There two key points in this issue is to keep bit 5 R4 as 1 The other is to switch bank correctly But some IC uses a non global register to switch ram bank such as EM78P510N So users have to know the peculiar to avoid fault For example unsigned int IRO 0xO rpage 0 unsigned int RSR 0x4 rpage 0 unsigned int BRSR 0Ox5 rpage 0 unsigned int 1 0 11 rpage 0 1 0 1 lt 0 8 1 BRSR 1 For RSR 0xFF RSR gt 0xE0 RSR iRO 0 180 WicePlus C amp Assembly User s Manual Appendix option comparative table After the WicePlus model reduces staff the IC option comparative table Contains WicePlus2 2xxxx is new IC option before is the old IC option New IC option Old IC option EM78P132 78 155 EM78P211N 78 210 EM78P212N EM78P221N 78 220 EM78P222N EM78P258N 78 259 78 259 78 260 EM78P142 EM78P340N EM78P341N EM78P342N EM78P342N EM78P343N EM78P345N EM
29. Control Register Page RAM Bank Bank 0 C Call ID RAM Block 0 Step 3 Click the OK to add the selections into the Watch window NOTE The variables displayed in the Label Name list box of the Watch Dialog are the same variables without register page ram bank control register page that you have defined in the program code using the double equal characters Double clicking a variable name will add or clear the asterisk An asterisk prefixed to variable name indicates that the variable is selected Click OK to add the selected variable to the Watch window x Name Address Value 0x20 Bank 0 0x00 BB 0x3F Bank 0 Ox3F DD 0x06 Contral 0 OxFF 0x10 Register 0 0x07 EE 0x06 Control 1 0x40 2 Wach X Wah Method 2 Accessing Debug gt Add Label to Watch from menu bar Step 1 Select a register from the Editor window and from menu bar click Debug gt Add Label to Watch 30 e WicePlus C amp Assembly User s Manual Debug Tool Option IDE Window Help Free Run amp 3 Reset 9 Step Into P Step Over f Step Out Go To Cursor Continue step into 7 Run from Selected Line stop Debug F5 F10 F6 FZ F8 Ctrl F7 F4 Shift F7 Add Label to Watch Reset and Free Run Reset and Go Step 2 From the resulting Watch Dialog window select and double click a label name Then from the La
30. Reason The file can not be created Solution To check whether the disk is full or not and whether the system is stable or not error L008 Line number The machine address number exceeds ROM size number Reason The address of program address is over the ROM size Solution To reduce the program code error L009 No project file is active Reason No project is opened Solution To open or create a project error L010 No output window is found Reason Output window is not opened Solution To select View gt Output and then an output window displays Class D Debugger error error D001 The ICE memory is error Reason The SRAM in the ICE is error Solution To change the ICE SRAM error D002 CDS size number does not match the ROM size number Reason The CDS size is not the same as the ROM size Solution To check project microcontroller name whether it is the same as WICE system micro controller name or not WicePlus C amp Assembly User s Manual error 0003 The project type type name does not match ICE name ICE Reason The project micro controller name is not the same as WICE system microcontroller name Solution To create a new project or reconnect with another ICE error 0004 The line of file does not transfer to machine address Reason The program line is unable to assemble Solution To check the syntax of the program line error 00
31. 0 04 068 069 070 Fig 8 8 WicePlus supplies interrupt frame left and remark and add 0 15 save and restore right 8 5 Developing your project especially about interrupt Now we can write our c code to develop our product In the case we wake up MCU by port 6 Users can download the example from our Web http www emc com tw database Sa2 Gp Dt EM78P468C_Example zip file Emp7p468 pin wakeup c with Counter 1 underflow interrupt with interrupt vector OxC So we write some initial code and our interrupt service code like Fig 8 9 and Fig 8 10 Now we active one of c files and use Alt F7 to compile WicePlus C amp Assembly User s Manual e 151 the file to see if there is errors in the file Alt F7 just compile the active file During developing we use Alt F7 to compile c file one by one to save compiling time After no errors in all c files in the project occur we use rebuild Alt F9 to compile and link our object code and create execute file cds If rebuild succeeds C Compiler will report many important and useful messages in Information sheet in Output Window Fig 8 11 shows them 005 define ENI _asm eni 006 define SLEP _asm slep 007 define NOP _asm nop 008 define uchar unsigned char 009 void main 010 011 012 013 014 015 ctestl while 1 016 void ctestl 017 018 019 020 021 022 023 024 025 026 027 028 uchar
32. C CD 4 CO PO P EA Shortcut keys Step 1 Select the string you want to search from Edit window 44 7test ist 1 R10 0 10 1 00000 0010 R10 0 10 2 2011 R11 0 11 2 00000 0010 Rll 0 11 3 4 lnclude 447test 5 org Oxfff 6 DOFFF 1400 jmp s1 org 0 00 8 00000 sl 9 00000 0001 clr 0 11 10 00001 0002 clr 0x12 11 00002 s2 12 00002 0551 inc 11 13 00003 1855 80 55 14 00004 1855 0 55 15 00005 1855 0 55 16 010006 1855 0 55 17 00007 1855 0 55 18 010008 0552 inc 0 12 19 00009 1402 jmp 2 20 21 22 23 R10 0 10 D R10 0 10 0 R11 0 11 0 R11 0 11 D include 447test h org xfff jmp sl org 0 00 0 11 0 12 0 11 a 0x55 a 0x55 a 0x55 0 55 a 0x55 0 12 jmp 2 0 0 warning s 0 User Message s 4 WicePlus C amp Assembly User s Manual Step 2 search upward press the shortcut keys CTRL P To search downward press the shortcut keys CTRL N Ist 00000 0010 2011 00000 0010 OOFFF 1400 00000 00000 0001 10 00001 0002 11 00002 12 00002 0551 13 00003 1855 14 00004 1855 15 00005 1855 16 00006 1855 17 00007 1855 18 00008 0552 19 00009 1402 O CO CD 4 CO N N EA c WicePlus C amp Assembly User s Man
33. Clear Bookmarks clear all bookmarks Print print the active file Ctrl P About about assemble version and other information Assemble or Compile in C mode assemble or Compile the active file in the Editor window Alt F7 Rebuild All assemble or compile in mode all files in the project and link object files Alt F9 Go auto dump and execute program with the effect of the breakpoints F5 Free Run auto dump and execute program with the breakpoints ignored F10 Reset reset the ICE F6 Step Into auto dump and execute program step by step including subroutines F7 Step Over auto dump and execute program step by step excluding the subroutines F8 Step Out auto dump and execute program untilexit the subroutines Ctrl F7 Run to Cursor auto dump and execute program then stop at the cursor position while ignoring the breakpoint F4 Run from Selected Line To apply this function the start for next time will be located on caret Insert Remove Breakpoint insert remove toggle for breakpoints F9 Remove Breakpoints remove all breakpoints Trace Back After trace log is executed trace back will be acted The caret moves backward step by step from the last executed address to the address located before the current executed address Trace Forth After trace log is executed trace forth will be acted The caret moves forward step by step from the last executed address to the address which
34. Example Int 11 12 Short 51 52 53 Long 11 12 1 0 11 I2 0x22 S1 I1 12 gt change to 51 short I1 short I2 If forgot to add short before I1 and I2 the final result in S1 will be 1 byte only S1 0 1111 52 0 02 L1 S1 S2 gt change to 11 long 51 long 52 forgot to long before S1 and S2 the final result in L1 will be 2 bytes only Tiny C compiler uses two s compliment to perform mathematical negative signed declaration Example int abc unsigned int uir abc 0x18 Assume abc is allocated at 0x20 bank 1 Then in Ram bank window you will see E8 at that location 6 6 Enumeration enum identifier enum idenftifier enumeration list Zint value enum enumeration list Enumeration defines a series of named integer constants With the definition the integer constants are grouped together with a valid name For each name enumerated you can specify a distinct value Example enum tagLedGroup Ledoff LedOn LEDStatus 6 7 Structure and Union struct union type name struct union identifier struct union identifier member declaration list struct union member declaration list member declaration list WicePlus C amp Assembly User s Manual e 113 member declaration member declaration list member declaration member declaration member declaration specifiers declaration list
35. Select Tiny C Compiler version 2 Uncheck is a Debug option setting To set debugger variables options The option is divided into the following four blocks shown in Fig 2 17b Dialog Dumping code and checking Interrupt disable after break Default breakpoint counter Default break point counter 0 255 fi default value 0 then show counter dialog else not Show source code in trace log Step into macro instruction when Debugging Cancel Fig 2 17b Debugger option setting 64 WicePlus amp Assembly User s Manual Dumping codes and checking WicePlus will check the equipped memory of the hardware before dumping codes b Interrupt disabled after program stopped Interrupt is disabled as a breakpoint occurs It is used to avoid any interrupt occurred during updating screen because TCC and COUNTER2 would keep working even program is stopped Therefore the disabled interrupt must be active otherwise users cannot debug the program c Default breakpoint counter Please take Chapter 5 Debugger a source level debug as a reference d Show trace log in source program In the output window the contents of trace log are shown by default setting in the contents of disassembler If this function is chosen address source level breakpoint produced by the trace log address will appear in the output window e Setp into macro instruction when Debugging
36. Watch 151 v 1 2 3 s s s s c p E E 7 9 a B c p E 4 FF FF FF FF FF FF FF FF FF FF FF FF FF FF F FF FF FE _ FF FF FF FF z FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3 FF FF FF FF FR FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF L FF FF FF FF FF FF FF FF FF S Br 3X IEE EE EE EE EE EE EE EE EE EE EE E 8 X Information Find in Files Message La j ing al Dos NUM Fig 3 11 Editing Source File Directly from Project window Mew Open Project Close Project Add Files to Project Delete files from project With your source file s embedded into the project you are now ready to compile your project using the following commands from Project menu Alt F7 A t Fa Dump to ICE m Click Assemble or Compile command to Trace Log F2 compile the active file only generates 51 Dump cose Grer ark tosram m Click Rebuild All command to compile all files in Fig 3 12 Assemble amp Link the project regardless of whether they were modified not Rebuild All will generate objective bb list st file binary cds file WicePlus C amp Assembly User s Manual The compiled files are automatically saved in the same folder where your other source files are located Status of the assembly operation can be monitored fr
37. When this option check box is enabled click StepInto from the Debug menu to run the program instructions including the macro step by step To run the macro code in the background click StepOver F7 As a new feature you can disable check box to run the macro in the background regardless of whether you click StepInto F7 or StepOver F8 Please remember that the instruction line that is currently being executed will stop at the address location of the macro shaded in green This location will point to the first line of the macro code click StepInto F7 to execute the first macro instruction and then its stop at the second macro instruction shaded in green again Example test macro 2 nop 3 nop 4 endm 5 org 0 0 6 jmp main 7 main 8 nop 9 test 10 nop 11 jmp Per above code example if the program execution stops at Line 8 shaded in green on screen click StepInto F7 to execute Line 8 and then execution stops at Line 9 note that in previous WicePlus version it stops at Line 2 of the macro As Line 9 is actually linked to Line 2 address clicking StepInto F7 will execute the code at Line 2 and stops at Line 3 If you click StepOver F8 the program executes the complete macro instructions Line 2 amp Line 3 and stops at Line 10 WicePlus C amp Assembly User s Manual 65 b Accelerate Reading Registers Accelerate Reading Registers x Accelerate Reading Registers C Enable ins
38. delete here 0X15 0 15 1 0 15 0 15 1 0 17 0X18 1 0X15 0X15 1 0X16 0 16 1 0X15 0X16 1 b From the resulting Address Breakpoint dialog which displays all the existing blue breakpoints select the specific or range of breakpoint s to delete from the dialog c Click Delete to remove breakpoint 58 WicePlus amp Assembly User s Manual m 2 36 Tool Menu Connect Check ICE memory Get checksum from project Piggy back MIX format Pigay back Hi Lo format Clear all output mapping line Get Code 1FFF size Get TBL code position Compute execution time Move data frorn file to srarn Generate Approval Form Fig 2 16a Tool Menu Clear all output mapping line Get Code 1FFF size Get TBL code position Piggy back MIX2 format Compute Execution Time Move data from file to sram Speed Up Debug Generate Approval Form a Compute Execution Time Connect Define printer port connection with ICE default is 378H Check ICE Check available memory Memory from ICE Get Checksum Obtain checksum from the from Project compiled program Piggy back MI To create a MIX file used to Xformat write to EEPROM on a piggyback Piggy back Hi To create a couple of files Loformat with extension names of Hi and Lo which are used to write to EEPROM on a piggyback To clear program mapping lines from output window Get free code size Get TBL code position For EM78813 amp EM78815 If use or
39. error M007 The file filename has already existed in the project Reason The file has been included in the project Solution To stop trying to add the file into the project again h error M008 File filename can not be saved Reason The file can not be saved in the disk Solution To check whether the project is empty or not i error M009 The project filename is not the format of EMC project file Reason The content of the project is not the EMC project format WicePlus C amp Assembly User s Manual e 159 j A 2 160 o iim Solution To create a new project and add the file to project error M010 The file filename does not exist Reason The file can not be found in the directory Solution To check whether the file exists or not error M011 The File filename can not be opened Reason The file can not be opened by O S Solution To check whether the file is existed or not error M012 The file filename exceeds number k of the max size number k Reason The file size is over the maximum size of buffer which editor is allocated Solution To divide the file into two or more error M013 The copy size number exceeds number k of the max size number k Reason The size of copy is over the maximum size of copy buffer Solution To reduce content of the copy error M014 Memory can not be allocated Reason System can not allocate more memory to use Solution To clo
40. is on the list if syntax errors for instance occur during assembling Any message of class L is showed in the list if there are any linking errors occurred during a project built or rebuilt Any message of class D describes the errors of debugging program A 1 Class M main program errors a error M001 Numbers of opening editor windows are over limitation Reason Too many opening windows to open one more Solution To close some unused editor windows b error M002 Memory is not enough to allocate Editor Window Reason System has not enough memory to allocate editor window Solution To close some unused editor windows or unexecuted application programs in system c error M003 File filename is existed Reason The file name has been created already so the same one can not be created again Solution Rename and save again d error M004 File filename can not be created Reason The application is notified that the file cannot be created by O S Solution To check whether the disk is full or not and the system is stable or not e error M005 One project has been opened Reason If one project has been opened in WICE then users can not open another project Solution To close the opening project and then open another project f error M006 Project filename can not be created Reason The application is notified that the project cannot be created by O S Solution To check whether the project is empty or not 2
41. 264 SWAPA Ox1F 265 0 04 266 267 268 Fig 8 12 Save restore system correctly After save and restore hardware system and C system correctly we can debug or run our project 154 WicePlus amp Assembly User s Manual Chapter 9 Compiler debug tips 9 1 Speed Up Debug During in C environment User can press Speed Up Debug button to improve debugging speed with Step Into F7 Tool Connect Check ICE memory Ge checksum from project Ge Code 1FFF size Compute execution tine Mcve data from file tc sram Speed Up Debug Generate Approval Fom Fig 9 1 Speed Up Debug If users don t press Speed Up Debug button WicePlus runs Step Into function F7 by program counter PC to program counter PC just as in assembly environment But if Speed Up Debug pressed WicePlus run to at first assembly code address corresponding to a C source line except some call function For example blow C source is at the left and the corresponding assembly codes are at the right The next Step into F7 will run from program counter 0x29 to 0x30 in assembly code without stop corresponding to line 2855 in C code WicePlus C amp Assembly User s Manual 155 2854 4 2855 2856 1 1 4 2857 4 2858 3 2855 Nov 0x27 Oxodo0o0028 Nov Oxic 7 Oxdoo0029 CLRA z ADD
42. D 3 Q What is the maximum array dimension as well as maximum array element 177 D 4 Is there any error message when the code exceeds the ROM size 177 D 5 Q Ina high level interrupt subroutine can user allocate the address in the e g using page data type putting asm org before a subroutine etc 178 D 6 Is static used in the same way as in ANSI C 178 D 7 Is there any error message in case user defines too many variables in the const that exceeds ROM space ooi OR 178 D 8 How do I declare the variable in h file and using not only in one c file 178 D 9 Should I change any program page or bank 178 D 10 May I know how many stacks I have called 179 D 11 Does compiler just occupy 0x10 Ox1F general purpose ram 179 D 12 Does C compiler support this item such as EM78P510N 179 D 13 How do I use macro with variable 179 D 14 Does C Compiler support all assembly instruction 179 D 15 How can clear all ram in all banks 180 8 WicePlus amp Assembly User
43. D014 Can t find the breakpoint address of program line Reason The breakpoint line does not have program address Solution To redefine the breakpoint error 0015 The number of symbols is over number Reason Too many symbols are defined Solution To divide the program into two or more small programs error D016 Please dump program before adding label to watch Reason To dump program before adding label to watch Solution To dump program to ICE error D017 Trace log is empty Reason No more data is found in trace log WicePlus C amp Assembly User s Manual e 165 Solution Can not execute the operation r error 0018 No trace item in trace log Reason No more trace item is found in trace log Solution Can not execute the operation 166 WicePlus C amp Assembly User s Manual g Appendix B C Conversion Table B 1 Conversion between C and Assembly Codes The assembly code was generated by the WicePlus Conversion Rate Compilers Code Size General User s Code Size 100 C Statement Description Example Integer Variable intVar1 OxFF x Assembly Code MOV A 0xFF MOV intVar1 100 2 2 100 intVar2 intVar1 MOV A intVar1 MOV intVar2 A 100 2 2 100 Character Variable charVar1 OxFF MOV A Oxff MOV charVar1 100 2 2 100 charVar2 intVar1 MOV A 1 MOV charVar2 A 100 2 2 100
44. Fig 8 8 shows part of the frame Just only one main function can exist in C project Usually users don t need to modify save and restore about R4 R3 ACC or R5 in the file that WicePlus supplies But for safety reason we suggest users to check if these save or restore location are at the same ram bank In this case MCU EM78P468N hardware saves ACC and before execute interrupt service routine and restore these two registers when interrupt service routine is completely Reference to Sec 4 8 Interrupt EM78P468 8 Bit Microcontroller Product Specification So we just have to save and restore R4 into Ox1F For Ox1F is common register and belong to global field we don t need to switch ram bank We use swap instruction to avoid flag bit influenced If we save R4 to Ox3F in ram bank 3 we have to restore Ox3F in ram bank 3 to R4 If we backup incorrectly MCU may execute wrong PC program counter because R4 in 78 468 control program page We use inline assembly to do save and restore process Ref Sec 7 8 Inline Assembler Save and restore R3 R4 or R5 we call save and restore MCU hardware In addition to save and restore MCU hardware some of cases we have to save and restore C system Some calculations outside interrupt service routine in C compiler don t only use ACC or the declared register or ram but some of common registers 0x 10 1 And in interrupt service routine also uses these common registers We have to confi
45. ICE running 138 e WicePlus C amp Assembly User s Manual 7 11 Interrupt Routine 2 Interrupt Routine with TCC2 is easier than with Also it really reduces rom space In TCC2 to handle interrupts just three have to be taken into account and one is new 1 Interrupt Save Procedure the same as with the procedure to save some registers before executing a service routine Now many new IC save important register like ACC R3 or R4 as interrupt occurs and restore them before it quits interrupt service Also TCC2 can save and restore these registers that WicePlus supplies If not WicePlus will supplies these form when a new one file added in a new project If not only one interrupt vectors in one IC users have to save register 0x2 PC to ACC TCC2 use the value of PC to know which interrupt source 2 Interrupt Service Routine is the action to be taken for Interrupt Don t care how many interrupt vectors users have to write interrupts service code in it and use switch case or if else if to know which interrupt vector source is if need 3 Global Interrupt Vector Index variable IntVecIdx Users have to declare IntVecIdx as global integer like extern int IntVecIdx IntVecIdx will occupy 0x10 So users can t declare or use 0x10 anywhere in project Compiler doesn t tell you if you declare or use but it will run a wrong result WicePlus C amp Assembly User s Manual 9 139 140 7 1
46. P 125 call sub_30 25 0 gt 000 a 477 050009 050006 128 sub_30 257 0 gt 0003 128 11 sub_31 27 00003 En dis a 132 sub_31 133 no 90050003 134 ck 21777050003 gt BI i Fig 2 5 3 Return to an earlier level several levels of stack However note that all the subsequent stack levels still display 0 0003 When you perform a step by step execution F7 WicePlus will compare the last stack value with the stack value after the ret action to identify the current level position of the stack It then changes the value of the last stack level value from 0x0003 to 0x0000 see Figure 2 5 4 104 sub 24 105 call sub 25 ES EM78808 STETR APJ i 106 nop 107 iet 23 Header Files 108 sub_25 List Files 10 11 sub_26 3 stock lst 5110 Map Files m ret Z3 Library File 26 453 Library Files E ines ei nop 115 ret 118 sub 27 117 call sub 28 118 nop 119 ret roe 120 sub 28 25 0 0003 15 sub 29 267 00003 ee yee 0003 124 sub 29 05203 125 call sub 30 Fig 2 5 4 Using Step by Step F7 execution in WicePlus to change the last stack level value To set the values of the higher level of stacks to 0x0000 continue to perform Step by Step WicePlus C amp Assembly User s Manual 25 execution see Figure 2 5 5 This will not affect normal stack operation
47. To Cursor F4 to your computer Continue step into Shift F7 Run from Selected Line 20 Stay Debuc Full debugging commands are available from the Debug Menu shown with its corresponding 88 e WicePlus 2 Aceemhlv lleer e Manual Fig 3 16b Debugging Commands Drop Down Menu shortcut keys in the drop down menu at right number of the frequently used debugging icons are also available from the WicePlus Program Toolbar WicePlus C amp Assembly User s Manual 9 89 90 o F10 F6 F7 P F8 Ux Ctrl F7 XE F4 Fig 3 16a Toolbar for Debugging Commands Go Run program starting from the current program counter until breakpoint is matched and breakpoint address is executed Free Run Run program starting from the current program counter until the Stop button of the Stop Running dialog is clicked All defined breakpoints are ignored while the program is running Reset Perform hardware reset register contents are displayed with initial values ICE will return to its initial condition Step Into Execute instructions step by step with register contents updated at the same time If RAM of your computer is not enough don t push it continuously please Step Over Same as Step Into command see above but the CALL instruction is executed as Go command If RAM of your computer is not enough don t push it continuously please Step Out Run
48. as setting the COM SEG values for each graphic segment Pane Selection Bar You can select whether to display any or all of the three panes described above The following is the step by step procedure on how to load the graphic display and define their segment settings e 35 36 o 1 Click Import Graph button to load the BMP file The program will automatically convert the graphic file into black and white colors and determines which black pixels are linked together to establish segments 2 Click Set Mapping button and the black segments fades to gray to indicate that the system is now in Mapping Mode At the same time the Set Mapping button label changes to Done Click the Done button only after all mapping setting processes are completed 3 Define COM SEG values in the Control Pane and point at a segment to apply the value Observe the segment turns to blue color This indicates that the pointed segment is now active 0 sec o 4 Click the active segment to enter the Control Panel defined COM SEG values into the active segment The example shows the defined COM amp SEG values are 0 5 Move the pointer away from the segment and the segment turns into green This indicates that the system has already saved the COM SEG values for the particular segment 6 Then move the pointer to other segments and repeat the steps as described above to redefine and change thei
49. define the symbol error A011 The macro name macro name is redefined Reason The macro name is defined more than once Solution To change the macro name to isolate name error A012 The parameter name parameter name is the same as label Reason The parameter name is the same as label Solution To redefine the parameter name error A013 The parameter name parameter name is the same as another one Reason The parameter name must be different from another one in the macro definition Solution To redefine the parameter name error A014 The number of actual parameter does not match with formal parameter Reason The number of actual parameter is not matched with the number of formal parameter Solution To change the number of actual parameter or formal parameter error A015 The parameter number number does not exist WicePlus C amp Assembly User s Manual 161 Reason The position of actual parameter is not defined Solution To change the number of actual parameter p error A016 The external symbol symbol name is the same name as defined label Reason The external symbol name is the same as internal defined label Solution To redefine the internal defined label q error A017 Address of ORG is error Reason The address of ORG defined is error Solution To redefine the ORG address error A018 MACEXIT not be set outside macro Reason The MACEXIT instruction can
50. pinpoints to the pertinent location in the Editor window see Figure 2 2 1 At the same time WicePlus displays the search results in the Output window as illustrated in Figure 2 2 2 void main Figure 2 2 1 Searched Label Function Location Pinpointed in the Editor Window 1 gt for main MAIN C DOCUMENTS A MAIN C 48 void main 1 occurrence s found Figure 2 2 2 Search Results Simultaneously Displayed in the Qutput Window If after editing the code WicePlus is unable to locate the label function location in the Editor window the Output window will still display a word find result for your reference Supplement 31 3 Source Files Header Files 31 3 List Files 3 Map Files Library Files After you have opened or created a project click the H button of the selected folder to expand and browse its contents We WicePlus C amp Assembly User s Manual Project 78 4475 447 Source Files Header Files E 447 Properties 3 2 List Files T f 447test Delete Map Files Library Files Right click on a file in the Project window to display file shortcut menu Open Properties Delete The following describes the functions of the 3 commands in the shortcut menu Open Opens the selected file For example right click on 447test dt the file the
51. program starting from the current program counter until the RET RETI RETL instruction address is executed Go to cursor To execute from current program counter to the location where the cursor is anchored Run from Selected Line To apply this function the start for next time will be located on caret Toggle Breakpoint Click with cursor positioned on the line where a breakpoint is going to be set or removed Clear Breakpoints Remove all already set breakpoints Trace Back After trace log is executed trace back will be acted The caret moves backward step by step from the last executed address to the address located before the current executed address Trace Forth After trace log is executed trace forth will be acted The caret moves forward step by step from the last executed address to the address which trace back ever went through Stop Debug Stop Free Run or Go without break point During debugging the contents of Program Counter Registers and RAMs read and displayed each time the program is stopped to provide important interim information during program debugging WicePlus C amp Assembly User s Manual 3 8 1 Breakpoints Setting To assign a breakpoint position cursor on the line where a breakpoint is going to be set then double click Observe the line highlighted in brown You can also click on the 4m Insert Remove Breakpoint icon hand shap
52. project This time we have to check Empty File box in Create a New file sheet in New dialog 148 e WicePlus C amp Assembly User s Manual Create New File Projects l Add new file ject Empty File File Name escon File Location DAWICETESTM68 8 6 Add new second file head file to the proJect Type file name and press OK button WicePlus will create a new and empty c file Head file will be added to project by empty and don t care about Empty File check box Now we create project with some c files and one head file such as Fig 8 7 thesecond c head le h alx 001 void main 1129 EM78P468N test cpj 002 2 29 Source Files 003 E kkbbic re 5 4 006 void _intcall l void 0z03 low_int 0 8 007 13 List Files d 010 PAGE 0X0 011 012 013 void _intcall tcc void int 0 014 015 backup R4 016 _asm 07 018 SWAPA 0 04 018 MOV OxiF A 020 022 ZZbackup system 23 off 4 gt Fig 8 7 We create project with some c files and one head file WicePlus C amp Assembly User s Manual e 149 8 4 and interrupt save and service frame that WicePlus supplies 150
53. registers oe ov a Buf Compiler will switch bank auto a 0 10 oe nBuf 1 nBuf 2 nBuf 3 nBuf 4 ov np ov 0 1 oe ov a N ov 0x1 oe ov a 99 0 1 oe ov a 335333333 338 gt ov 0 1 switch bank users 136 WicePlus amp Assembly User s Manual Example 3 void intcall INTERRUPT3 l void 0x08 low int 0 backup R3 R4 R5 asm void _intcall INTERRUPT3 void int 0 long ans ans LongMult 0x1234 0 5678 long LongMult long a long b return a b multiple operation of long data type is NOT allowed Example 4 unsigned int IRBR 6 void abcd int 1 75 for 1 0 1 lt 6 1 for jJ 0 J lt 3 j IRBR i IRBR i gt gt 1 void _intcall INTERRUPT3 l void 0 08 low int 0 backup ACC R3 R4 R5 void _intcall INTERRUPT3 void int 0 WicePlus C amp Assembly User s Manual 137 WicePlus supply interrupt save procedure and interrupt service routine form in the file where the main function locates After building a new project users can adds a new file like below figure with main function and interrupt save procedure and interrupt service routine Please remember just one main function could be in a C project So next time when you want to add another new file in t
54. s Manual Total Rom 81 Used Rom Size 0155 3 Available Rom 81 3941 97 PERSE UE E UE Data Map z 0x10 xlF are reserved for C d Uninitialized data D Initialized data b Uninitialized bit data B Initialized bit data sassa Call Depth Depth Interrupt Function N Programst Y tec 1 Y tec Y _intO_1 Y _int0 Y inti 1 Y inti Y _counterl 1 Y counterl Y counterZ 1 Y _counter2 _highpulse_1 Y _highpulse x lowpulse 1 Y _lowpulse hd Port Port8 1 _Port6Port8 N main N ctestl N All Files Saved n 22 Col 15 cSt as pr Fig 8 11 Useful messages after rebuild all successfully Fig 8 11 tells us which common registers we must save and restore C char is located at 0x10 So we modify C system save and restore like Fig 8 12 WicePlus C amp Assembly User s Manual e 153 233 void _intcall counterl void int 3 234 235 backup R4 236 asm 237 238 SwAPA 0 04 239 MOV Ox1F A 240 241 ZZbackup system 242 asm 243 1 245 MOV A UX1U ZZDepend on WicePlus repor 246 MOV OX3C 1 A 247 248 249 Write your code inline assembly C here 250 251 ISR amp 0xf7 252 RS7 R57 253 restore C system 254 asm 255 256 Lean enc 0X3 257 A UXSC Depend on WicePlus repor 258 MOV 0 10 259 260 261 restore R4 262 asm 263 1
55. settings You should see the breakpoints indicated in the Editor window or as shown in the figure example below orq xfff 0 00 51 nop nop nop nop jmp 1 d Click Go command to see the steps and result of the code execution org Oxfff jmp sl org 0 00 51 Note 1 You can only set breakpoints after performing dump action If you try to set breakpoint without dumping a pop up message will display to prompt you to execute dump action x please dump Note Breakpoints solid blue dot created through the Address Break Point command as 56 WicePlus amp Assembly User s Manual explained above are Independent from the breakpoints solid red dot created individually by double clicking on the pointed address or by pressing F9 Since they do not conflict with each other the blue and red address breakpoints can co exist at the same time and at the same address location However the blue breakpoints has the priority over red ones when Go command is executed Hence any existing solid red dot breakpoints are ignored org Oxfff ES org 0 00 51 nop Onop nop jmp s1 Note 3 As the Address Breakpoints dialog created blue breakpoints has the priority over the individually created red breakpoints the solid red dots turns into hollow red circle when both types of breakpoints occupy the same address Once the blue address breakpoints are cleared the hollow red circle b
56. step over Exit CALL subroutines Step Out when execute Step Into into a CALL subroutines Run program starting from the current program counter up to the location where the cursor is anchored applies to ICE debug mode only To perform the function of Step into To apply this function the start for next time will be located on caret Stop Free Run or Go without breakpoint To add or delete variables from the watch window Shown as Fig 2 15b To reset the hardware and then execute the function of Free run To reset the hardware and then execute the function of Go depicted in Fig 2 15c Set or remove a breakpoint e 49 Show Breakpoints Clear All Breakpoints Address Break Point Clear All Address Break Point Trace Back Track Forth Label Name Select or cancel the label by double click it Label Types Control Register C RAM BankJ Call ID RAM l 1 Special 0 1 Page Gn Show all breakpoints set up data in the Output window Clear all breakpoints To define addresses to be breakpoints Shown as Fig 2 15d Clear all address breakpoint After trace log is executed trace back will be acted The caret moves backward step by step from the last executed address to the address located before the current executed address After trace log is executed trace forth will be acted The caret moves fo
57. the Watch Dialog will display instead See Section 2 2 5 Watch Window for further details 2 2 3 The Special Register Window MAS ped c The Special Register window shows changes it is SEHE HN sd por the updated contents of the registers wx me m j i um m and I O control register depending on FM 1111 1111 i the MCU type 815 FF R5 FF R5 FF FF 5 FF C5 FF m mo When closes the Windows will not s ee etre tte read to the hardware any concerns FF RA FF RA FF R FF R FF m a aa e this Windows s contents Except F ccmcc some special registers RID Binary RD FF CD FF RIE F v Hex RE FF FF RIF F Edit CF FF Fig 2 4 Special Register Window Supplement 22 WicePlus amp Assembly User s Manual To change a special register value double click on the selected value BD in the example figure below R16 FF R17 BD BED R18 Dit DU t With the existing value highlighted the new value 77 in the example figure below Observe the new value changes to red when you click anywhere within the Ram Bank window R16 FF R17 Kia R18 F6 Right clicking on the selected value will also generate a pop up menu containing commands for editing the selected register value R1A BE RiB FE 1 Binary R
58. the expression ii error A035 The operation operation name is not defined Reason The operation is not defined by WICE Solution To check the user menu of WICE jj error A036 The PUBLIC or EXTERN label label name must be address label Reason The label defined by PUBLIC or EXTERN instruction must be address label Solution To remove the public or extern variable kk error A037 The operand value can not be calculated Reason The format of the operand expression is not correct Solution To correct the expression of the operand error A038 The symbol symbol name is not extern symbol Reason The symbol is not defined as internal or external Solution To define the symbol mm error A039 The reference number is over number limitation Reason The reference number the PUBLIC or EXTERN instruction is over limitation Solution To divide the line into two or more nn error A040 The length of file name file name exceeds 256 Reason The length of file name is over 256 Solution To change the file name or directory oo Warning A050 The symbol length is exceed 32 Reason The length of variable is over 32 Solution To change the variable pp Warning A051 The number of message is over 500 Reason The number of message is over 500 Solution To reduce the number of message qq Warning A052 The number to express number Reason Transform negative number to hexad
59. the type of oscillator in the code option Step 5 If the problem still exists then check again with another PC Step 6 Repeat from Step 1 Step 7 If it is still not solved please call EMC 2 The connection from ICE to PC is successful but program dumping fails A Please check the following steps Step 1 From the Option menu choose ICE code option To check the type of oscillator in the code option Step 2 Please check whether the type of microcontroller is the same as that in hardware Q If ICE memory is checked and the result of ICE memory is error A Please check the following steps WicePlus C amp Assembly User s Manual e 175 Step 1 From the Option menu choose ICE code option To check the type of oscillator in the code option Step 2 Please check whether the type of microcontroller in software is the same as that in hardware Step 3 Please change ICE SRAM C 4 If users try to reconnect the same ICE from PC why does the execution become slower and slower The timing of communication between ICE and is stretched if the connection is tried again and again 5 Q Why can t Step Into be executed Please check whether the type of microcontroller in software is the same as that in hardware 6 If source files are located in Novell file server why is the program reassembled again at each execution time A tis because of the time di
60. to external SRAM is over 262 144 byte 256K byte you have to divide your binary file into two files and move your data two times For example now we have a 512K byte external SRAM a binary file named Big5 bin and its size is 393 216 byte 384K byte We want to move all content of the Big5 bin into external SRAM from the Data Begin address 131 072 So we have to divide the binary file into two files Big51 bin and the Big52 bin Their size is 262 144 byte 256K byte byte and 131 072 byte 128K byte 62 WicePlus amp Assembly User s Manual Then we set Data Begin Address as 131 072 Length as 262 144 Binary file name as Big51 bin to move data into external SRAM The data will be located from address 131 072 to address 393 215 After the previous process is finished we set Data Begin Address as 393 216 Length as 131 072 Binary file name as Big52 bin to move data into external SRAM again The data will be located from address 393 072 to address 524 287 after finishing the process You just have to do the moving data process only one time if you don t power off ICE or change any data in your binary file We suggest the user just do it one time one day Dump code to external SRAM If your program code is over 64K word now you press Dump to ICE F3 to dump program code to ICE After process and checking code under 64K word your code over 64K word will continue to be dump to external SRAM It will take about 45 seco
61. to install WicePlus because of the printer port driver DLPortIO you have to reboot your computer after installing WicePlus If you use USB ICE under Windows 9X you also need to reboot If it is not the first time to install WicePlus the setup program will uninstall the previous installation then install the new one During installing users cannot change the default install path When the operating system is searching the USB ICE hardware please make sure the power of ICE is set to ON You can see the EMC USB ICE by Device Manager of OS if the driver is installed and the ICE is connected correctly Action View 1 8 E Universal Serial Bus controllers a gt 1 4 ANSI Compatibility Compliance with the ANSI standard is limited to free standing C to accommodate the unique design characteristics of the 78 Series microcontrollers WicePlus C amp Assembly User s Manual 11 Chapter 2 WicePlus Interface 2 1 Overview WicePlus is a project oriented integrated development environment IDE system that is used to edit user application programs and generates emulation layout files for ELAN s EM78 series 8 bit microcontrollers Project Window Editor Window Special Registers Window Ina EMG ice Pn ppp AT Menu Bar ve Project Debug Tool Option IDE Window Help
62. trace back ever went through Stop Debug Stop Free Run or Go without break point WicePlus C amp Assembly User s Manual 2 5 Document Active wav b st dt EET test st f test h Fig 2 22 WicePlus Main Window Document Bar The Document bar displays the file icons representing each of the opened files in the Editor window Click the icon of the pertinent file that you wish to activate place in front of the Editor window to perform editing Highlighted filename is the active file function is similar with taskbar buttons under Windows To double cluck left button on the table in the Document bar to close active document 2 6 Status Bar Keyboard mode Cursor position Ready 28 615 DOS CAP NUM ICEeSA running indicator Text file OS format R W A WicePlus running indicator will be shown in the Status bar while your project is being compiled The Cursor position indicates the cursor location within the text Editor window R W flag indicates the active file Read Write status If Read only Read will display otherwise the field is empty Keyboard mode displays the status of the following keyboard keys m Insert key OVR is dimmed when overtype mode is off highlighted when on m Caps Lock key CAP is dimmed when uppercase character mode is off highlighted when on m Num Lock key NUM is dimmed when the numeric keypad c
63. watch window will sort by these three options automatically Now we illustrate sort by name 32 WicePlus amp Assembly User s Manual View Revise Window Size Base on Big window size when dock Base on Small window size when dock File Name in Project Window C File name with Path File Name Show Line Numbers ON OFF Tab Width 4 Show Ram Bank Inversely Show Data Ram Inversely iv Add defined label to watch automatically Sort by Address C Sort by Type Show Unreferenced variable Show defined label in Register Window Show Program Rom Cancel Step 2 variables with page location data from the Editor window are automatically formatted into labeled format as shown in the example below 01 Ox20 rhank 0 02 bh Dz3F rbank 0 03 OxlO rpage 0 04 dd Dz6 iopage 0 05 0 6 Step 3 After code dump the variables are automatically included in the Watch window WicePlus C amp Assembly User s Manual 933 rr 2 Name Address Value 0 20 Bank 0 0x00 BB Ox3F Bank 0 Ox3F 0x10 Register Dx07 DD 0x06 Control 0 DxFF L NWatch1 Wath2 A Wath 4 NOTE 1 remove a variable from the Watch window select the variable and press DELETE from the keyboard 2 If checked box Add defined label to watch automatically was checked labels added into watch window wil
64. zeroflag BS status 2 BC carryflag BS status 0 BC 0x3 2 BS R3 2 Examples of directives Examplel ORG 0X20 Example2 END Operands One or more operands separated by commas Comment Comments include line comment and block comment Line comment syntax preceded by a semi colon Example MOV 0 20 move constant value 32 to accumulator Block comment comment statements 4 3 Number type Type Expression 1 Expression 2 Expression 3 Decimal 0D lt digits gt lt digits gt D lt digits gt Hexadecimal 0X lt digits gt lt digits gt H Octal 0Q lt digits gt lt digits gt Q Binary OB lt digits gt lt digits gt B P S If first digit is A F or a f on hexadecimal expression 2 then users must add 0 to precedence of digits 4 4 Assembler arithmetic operations The arithmetic result must be calculated after assembler If the arithmetic expression can not be calculated on assembler time then display error message Meanwhile the arithmetic 94 WicePlus amp Assembly User s Manual expression can not support floating point so floating point number is self transferred to integer TRUE and FALSE TRUE is OxFF FALSE is 0x00 The following operators give a summary of the operators in order of priority a Parentheses and b Unary operators Logical NOT Complement Unary minus c Multiplication division modulo shift M
65. 0 MOV Ox1A A MOV 0x1B CALL INDIR MOV 0 MOV 0x1B A MOV A 90x05 MOV 0 18 MOV 0 00 MOV 0 19 MOV 0x01 MOV Ox1A A MOV 0x1B INDIR 146 35 24 100 4171 INDIR BC 0 05 0 MOV O0x1B A MOV 0 1 JBS 0x03 2 JMP 0 081 MOV 0 18 IOW 0 9 MOV 0x1B IOW 0 1 MOV 0 18 MOV 0x0A A MOV 0x1B MOV 0x0B A RET Bitwise operation f e amp d MOV A 100 3 3 100 all variables are f e Ad AND d unsigned int data f e d XOR A d type OR 94d MOV 9 f e COMA e 100 2 2 100 MOV f A f amp MOV A e 100 2 2 100 AND f e XOR A OR f A f e gt gt 1 100 3 3 100 0x03 0 RRCA e MOV f e lt lt 1 BC 0x03 0 100 3 3 100 RLCA e MOV f A gt gt 3 0 03 0 100 6 6 100 0 03 0 0 03 0 f lt lt 3 BC 0 03 0 100 6 6 100 RLC 0 03 0 RLC 0 03 0 RLC fo gt 4 SWAPA 0x06 100 3 3 100 AND 0x0F MOV 0x06 A f lt lt 4 SWAPA 0x06 100 3 3 100 AND 0xF0 MOV 0x06 A 172 WicePlus amp Assembly User s Manual SWAP 0x06 RRC 0x06 RRCA 0x06 AND A 90x03 MOV 0x06 A 100 5 5 100 SWAP 0x06 RLC 0x06 RLCA 0x06 AND 0 0 MOV 0 06 100 5 5 100 MOV A MOV 0x14 SWAP 0 14
66. 00 R6 DD R6 00 FF C6 00 RI 49 R7 FF R7 40 R7 00 C7 FF 00 RIS 2B R8 R8 0 0 FF 00 RIS 10 R9 00 REGISTI 72 00 09 FF C8 00 RIA 56 R 18 RA R 00 RA 00 00 RIB 40 RB D RB 00 RB 00 RB 00 CB FF CB 00 RIC 13 RC 100 RC DE 00 CC FF 00 RID 4i RD 100 RD RD 00 CD 00 A2 RE 00 RE 00 100 RIF 45 RF 00 CF 00 lx Name Address Type Value REGISTERRS 0x05 Register 1 0x00 WicePlus C amp Assembly User s Manual sub window of Output window d Environment setting To set WicePlus environment variable for example whether list file is created or not whether map file is created or not and the number of editor window Create List File Create Map File Recent File List 4 Recent Project List fa Following are for EM78815 Auto Dump Over 64K po hain rm Cnt 8 7 ow race Log Under Cancel Fig 2 17e Setting environment a Create List file If chosen the LIST file is created after a related project is assembled The LIST file includes line number address program code and source file b Create MAP file If chosen the related LIST file is created after a project is linked The MAP file includes public symbol name and address c Recent file list contains The number of recent closed file name can be saved in WICE The maximum number of editor window is 10 d Recent project list contains The number of recent closed p
67. 05 The breakpoint group number is over 64 Reason The breakpoint group number is over 64 Solution To remove the extra breakpoint groups error D006 The ICE is not connected to Reason The ICE is not connected to PC Solution To check power supply ICE crystal connected printer port and so on error D007 The printer port is not connected Reason The printer port is not connected Solution To check power supply connected parallel port and so on error D008 The number is invalid Reason The number is invalid Solution To rewrite the number expression error 0009 The number of messages is over number Reason The number of messages is over limit in output window Solution To reduce the message is defined by user example for MESSAGE instruction Warning D010 The address number does not match the source file Reason The program address does not match the source file line Solution To add the program source of the address or to check whether the crystal is normal or not Warning D011 Memory checked is error Reason The ICE SRAM memory is error Solution To change the ICE SRAM or to check whether the crystal is normal or not error D012 Syntax error Reason The syntax of source file has a severe error Solution To correct the source file error D013 Memory address number is error Reason The address of ICE SRAM is error Solution To change the ICE memory error
68. 052 ci ci 4 2856 0053 0 03 0 0054 RLC 0x27 0055 BC 0x03 0 0056 RLC 0x27 0057 ci ci 4 2857 c 0058 arn m mm cil c1 3 ZZe1 ci ciz3 m cis zcix5 citt ci 2865 222244777255 7226 2066 int Fig 9 4 Assembly code in C debug mode and focus on C file Users have to active and set focus on assembly file if you want to press StepInto StepOver StepOut Go FreeRun Reset GotoCursor insert Remove Breakpoint buttons 9 3 Watch Defined variable in Register Window Check Show defined label in Register window in view setting dialog after dumping those variables declared in register field will show in register window Registers name don t show in default but users define WicePlus C amp Assembly User s Manual e 157 CONT 00 R 14 01 00 R2PC 0035 R3 0001 1000 0001 0100 E 6F F9 co 00 co 40 OF 00 00 9 4 Reduce cods size some cases Define signed variable and unsigned variable not the same Use unsigned variable will reduce program code size 158 WicePlus amp Assembly User s Manual Appendix Assembly Error Message Error messages are categorized into the 4 classes which are class M class A class L and class D Any message of class M pops out when main program is executed incorrectly Any message of class
69. 1 1 Interrupt Save Procedure void intcall function name l void lt interrupt vector address gt low int interrupt vector number gt Interrupt save procedure format is the same as in But users have to write MOV A 0x2 first in inline assembly code 7 11 2 Interrupt Service Routine void intcall function name void int The interrupt vector number is skipped in TCC2 interrupt service routine and just one interrupt service routine function In example 1 not only one interrupt vector in EM78P510N write interrupt service each case relative to interrupt vector Users can mark case and interrupt save procedure if they aren t used In example 2 although just one interrupt vector in EM78569 users can t use 0x10 but don t declare IntVeclIdx In example 3 in EM78567 users can t use 0x10 but don t declare IntVecIdx Hardware don t save and restore and register Users have to note that some IC in restoring inline assembly use reti in the first line It tells compiler to restore automatically from this line Compiler will restore automatically after inline assembly if no reti Reti have to put the first order in restoring inline assembly 7 11 3 Reserved Common Registers Operation Compiler save common registers 0x1 1 0x1F compiler uses Note the use of reti in restoring inline assembly in some IC Example 1 EM78P510N Hardware save and restore ACC R3 and R5 interrupt actio
70. 1B 64 unsigned int uiR1C unsigned int uiR1D 0 0 10 0 12 0 16 0 17 0 18 0 19 Ox1A Ox1B Ox1C 0 1 0 declare uiR12 at common M x LM M gt gt C gt Register Data 012345678 D300 bdd 0520 IND Data Now there is a error message in Build sheet Output Window and we know which un used common registers character in Information sheet Output Window Error LNK1116 Can t allocate space for C Register ecx at RPage which need 4 byte s Error message LNK1116 tells us Compiler need 4 continuous bytes So we can t declare our variable at 0 12 or 0x16 Now we declare uiRDD at 0x1E instead 0x16 Unsigned int uiRDD 0 1 rpage 0 Now no more error message like LNK1116 shows and compiling succeed Character means C Compiler uses means data type occupied b means bit data type means unused RAM Data Register Data 01234856789 ABCDEF 01234856789 ABCDHEF 2 bddddddddddddddd 000 s b d d dd dddddddddddddddd oxid 25 d d d Q d d q d d d d dadd IND Data Bl 3X
71. 1D FE FF R3F D6 The following describes each of the menu commands Binary Changes the register value from hex to binary format If the value is already in binary this command is prefixed with a check mark R14 RIB 1111 1110 RIC Hex Change the register value from binary to hex format If the value is already in hex this command is prefixed with a check mark R1 FE RIC EF Edit Revise the existing register value This is the same as double clicking on the value as explained above However using this Edit function is preferable WicePlus C amp Assembly User s Manual 23 2 2 4 CallStack Window xi The CallStack window shows the Level Address updated contents of call stack 00 050000 This Windows s content responds the 01 050000 hardware actual content really When closes the Windows will not 03 00000 050000 to eg hardware any concerns 85 this Windows s contents D6 050000 07 050000 08 050000 09 050000 10 00000 11 0 0000 12 0 0000 13 0 0000 14 0 0000 15 0 0000 Supplement In general a stack does not have an initial value When you press F6 WicePlus resets all stack cells to 0x0000 Due to ICE hardware design constraint if a stack is full see Figure 2 5 1 during program execution and returns to the calling sub routine reading from the stack again will display the result as
72. 2 BS 0X03 6 MOV 0x05 A MOV A 0 34 BS 0 03 6 0 03 7 MOV 0x05 MOV A 0 56 0x03 6 0 03 7 MOV 0x05 WicePlus amp Assembly User s Manual 100 11 11 100 control page io unsigned int 6 90x06 0 io unsigned int mylO6P1 90x06 1 io unsigned int myIO7P1 90x07 1 mylO6PO 0x00 mylO6P1 OxFF mylO7P1 0x55 using EM78569 MOV A 0x00 BC 0x03 5 IOW 0 6 MOV 0 BS 0 03 5 IOW 0 6 MOV A 0 55 IOW 0 7 100 8 8 100 RAM bank unsigned int myData1 00x20 bank 0 unsigned int myData2 90x21 bank 0 unsigned int myData3 30x21 bank 1 myData1 1 myData2 2 myData3 3 using EM78569 MOV 0x01 0x04 6 BC 0x04 7 MOV 0 20 MOV 0x02 MOV 0x21 MOV 0x03 BS 0x04 6 0 04 7 MOV 0x21 100 10 10 100 Bit data type bit myBOR6PO 90 06 90 00 0 bit myB2R6PO 0x06 0x02 0 6 1 myB2R6P0 myBOR6P0 BS 0x06 0 0x06 2 JBC 0x06 0 BS 0x06 2 133 4 8 100 Indirect addressing indir unsigned myData1 00x30 ind 0 indir unsigned myData2 90x05 ind 1 myData1 0x55 myData2 OxAA WicePlus C amp Assembly User s Manual using EM78806B MOV A 90x55 MOV 0x1B A MOV A 0x30 MOV 0 18 MOV 0 00 MOV 0 19 MOV 0 0
73. 569N569 dt 13 09c3 09 0X3 0x7 D ER EC 8 iR E10 569x569 dt 14 0983 09 0x3 0x6 D NBC EC DEA 8 TRIER F10N569N569 dt 15 D Frequency 4 000000 MHz Instruction Cycles 10 Execution Times 250 000000 _Find in Files Message Program Rom Fig 2 16b3 The result of execution times in Information sub window 60 WicePlus amp Assembly User s Manual b Move data from file to Only foe 78815 use We support some functions in the new version WicePlus that is consistent with external 512K byte SRAM board Our purpose is to use external SRAM rather than flash The followings are the features of these new functions before detail descriptions 1 The user can move data from binary file to external SRAM 2 The user can use external SRAM to develop program when program s size over 64K word Following we ll introduce the details Please remember all we mention We suppose your connection is OK ready to debug your program and in your program you have to access data from external memory Now we replace external flash ram with external SRAM in developing process There are two important parts in our description Move data from binary file to external SRAM and Dump code to external SRAM Move your data from binary file to external SRAM 1 Reset F6 This is very import before you move data from binary file to external SRAM But not always to press reset menu before moving da
74. 78P346N EM78P346N EM78P347N 78 417 78 418 EM78P418N 78 419 785840 785840 EM78P5840N EM785841 WicePlus C amp Assembly User s Manual 181
75. C and R5 asm MOV 1 SWAPA 0 5 0 1 PAGE 80 0 144 WicePlus amp Assembly User s Manual Chapter 8 Tiny Compiler quickly In this chapter we ll introduce yours to control C compiler quickly Please execute WicePlus Users can double click WicePlus icon to do that 8 1 Create a new project i View Project Debug Tool Option IDE Window Help Fig 8 1 Main menu Click New in File Fig 8 2 or in Project Fig 8 3 popup menu from menu Fig 8 1 to call New dialog Fig 8 4 Then we can select folder and type project name Press OK button to create project Don t type extend file name WicePlus will add extend file name cpj for the project In this case we select EM78P468N for our target MCU during connection File Project 5 Open Ctrl O Open Close PEVE Close Save Ctlr Save As Edd Files to Project Save Delete files from project Open Project 52 Compile pave Project 1 IPRS Close Project Dump to ICE p Print Trace lag EY Print Preview Dump code aver 64K to sram Print Setup Fig 8 3 Project popup menu Recent Projects Exit Fig 8 2 File popup menu WicePlus C amp Assembly User s Manual e 145 test EM78P469N CESION EM78P510N ICE510N EM78367 CE367 q EM78369 ICE369 D WiceTest468 EM78805C ICE805C Fig 8 4 Use New dial
76. C low int 3 _ 0 2 void intcall Time2 l void OxOF low int 4 _ 0 2 void intcall 1 void 8 0x12 1ow int 5 _ 0 2 void _intcall UART 1 void 0 15 1 int 6 _ 0 2 void intcall SPI 1 0x18 1ow int 7 WicePlus C amp Assembly User s Manual _ 0 2 void _intcall LVD l void Ox1B low int 8 _ 0 2 Example 2 78569 Hardware save and restore ACC R3 and H5 interrupt action WicePlus will tell Compiler to save and restore R4 One interrupt vector void main _asm MOV 0 10 enable bit 4 CONTW void _intcall interrupt void int Write your code inline assembly here void _intcall interrupt l void 0x08 low_int 0 I asm PAGE 0 0 it s dangerous to skip this line Example 3 78567 Hardware doesn t save and restore any register and Compiler just can save and restore R3 and R4 One interrupt vector void _intcall interrupt void int Write your code inline assembly here restore ACC and R5 _ reti tell compiler to recover common registers her SWAPA 0 1 WicePlus C amp Assembly User s Manual e 143 MOV 0 5 SWAP 0 1 SWAPA 0 1 void _intcall interrupt l void 0x08 low_int 0 save AC
77. CES08N Location EM79P330N ICE230N EM78P331N 1CE330N DAWicePlus TestCode m EM79P342N ICE241N EM39F3490CE349 EM78P418N ICE418N Asemblr C EM78P4478 ICE447 78 4500 450 EM78P451 ICE451 78 4520 452 78 4580 458 EMTGPASOTCEAS EM78P468N ICE468 WicePlus C amp Assembly User s Manual e 147 Gm 8 2 Add a New C file to the project Call New dialog like sec 8 1 This time New dialog appears and switch automatically to Create a New File sheet in New dialog Fig 8 5 WicePlus will supplies basic Tiny C compiler main file and interrupt save procedure and interrupt service routine frame if select extend file name as c in left combo box and leave Empty File check box uncheck We ll introduce the frame later Add new file to project box checked is default Now type the file name for the first file to add into the project Don t type extend file name WicePlus will add extend file name automatically Press OK button to add the c first file to the project Create a New File Projects Source File Add new file to project EMC Header File h Empty Fil TCC2 Tiny C Compiler ver 2 we hope users create new project in TCC2 File Name File Location WICE TES T468 us Fig 8 5 Add the first c file with main and interrupt save procedure and service routine frame 8 3 Add a new second file or head file to the
78. DIRPORT6 and you have to write like below just only one c file like that io unsigned int DIRPORT6 90x06 iopage 0 D 9 Q Should change any program page or bank A If you just develop your program in C language you don t have to change any program page register page and ram bank and so on But If you use inline assembly in your program you have to save and restore about page or bank 178 WicePlus C amp Assembly User s Manual 0 10 May know how many stacks have called Yes In developed environment after compiling user know how function call depth in Information Output Window D 11 Q Does C compiler just occupy 0x10 0x1F general purpose ram A Well almost C compiler just occupies 0x10 0x1F general purpose register But If there are some arguments in call functions compiler will use some others ram in 0x20 0x3F bank 0 bank 3 So we suggest users use global variables to replace arguments in call function Users always have to note that there are some ram spaces used in interrupt save procedure and interrupt service procedure If you don t use these ram space again D 12 Q Does C compiler support this item such as EM78P510N A TCC2 supports all EM78 series IC except EM78x680 EM78x611 0 13 How do l use macro with variable A for example io unsigned int 0 06 1 0 define set_output port bit _asm ior port _asm and a
79. Dialog Command 2 Browse and select the file or multiple files you intend to insert into the new project 84 WicePlus amp Assembly User s Manual m 3 Click OK button after confirming your choice 3 4 3 Deleting Source Files from Project x xl 222 You may also click on the Delete Files from Project EN EM78569 test apj command from the Project Ea Source Files pull down menu to delete files testdt from project 3 EA Header Files List Files New A lest let 3 Map Files Save 53 Library Files Close Add Files to Project Delete files frorn project Fig 3 9a Deleting Project Files Directly from Assemble Alt F7 Project Window Rebuild All Alt F9 1 Trom the Project window select the Dump to ICE FS file s you wish to delete Then press the Trace Log F2 Delete key from your keyboard Dump code over 64K to sram 3 96 Deleting Project Files from Project menu 3 5 Editing Source Files from Folder Project 3 5 1 Open Source File from Folder for Editing You can also open an existing source file in the Editor window for a last minute editing before adding it into the new project To do this File Edit View Project 0 1 From the Menu bar click on File or Project New menu choose Open command from the Ga Open Ctr O resulting pull down menu Close 2 From the resulting Open dialog Fig 3 8b Fig 3 10 Open amp Edit Source abov
80. F FF FF FF FF FF FF FF FF FF FF FF a 99 39 gm 5 5 FF FF FF FF FF FF FF FF S389 99994 m E 2 6 General Registers Bank Window The General Registers Ram Bank window shows the updated contents of the common ram bank registers When closes the Windows will not read to the hardware any concerns this Windows s contents Supplement To change a general register value double click on the selected value EF in the example figure below 26 WicePlus amp Assembly User s Manual 33 5 EB DF FF FB 7 BF 7D FF FA F F5 EB F DF 55 E With the existing value highlighted key in the new value 33 in the example figure below I Observe the new value changes to red when you click anywhere within the WicePlus window Foon 33 33 B5 DF FF FB FF FA TT T nr rr Right clicking on the selected value will also generate a pop up menu containing commands for editing the selected register value The following describes each of the pop up menu commands Binary Changes the register value from hex to binary format If the value is already in binary this command is prefixed with a check mark 1 2 3 4 5 6 33 1110 1111 B5 DF BF 7D Hex Change the register value from binary to hex format If the value is already in hex this co
81. Plus Program Connect Dialog Once the program is started the main window of the program will initially display the Connect dialog to prompt you to set the proper connection between your existing target microcontroller and connecting port Filter Key in some desired IC s name for example 159 Micro Controller combo box will just contain these IC s name with 159 It makes select IC easily WicePlus version 2 6 or later supports this function WicePlus C amp Assembly User s Manual e 79 80 o Gn Micro Controller The device presented on the edit bar is one of the EM78XXX series Users can also select others by clicking the downward triangle icon on the right side of the edit bar Connecting Port You can choose LPT or USB for connecting port If USB ICE is not detected you cannot choose USB option The option will be disabled If the option is disabled and USB ICE has already been connected with PC Please check the Device Manager of OS and try under steps Turn off the ICE Disconnect the USB cable e Turn on the ICE Reconnect the USB cable Then please check if the USB option is enabled LPT Port Address The system will search automatically the address of the print port which is already connected with the hardware After the connection is successful WicePlus will also diagnose the hardware right away Default address is 378H Wait Times It depicts the I O response speed Increase the value for slower s
82. RUPT1_1 MOV A 0X12 MOV 0X13 0X39 0 14 0 38 WicePlus amp Assembly User s Manual Write your code inline assembly here restore C system _ BS 0X04 6 switch to ram Dbank 3 to restore correctly BS 0X04 7 MOV A 0X3C C system restore MOV 0X10 A MOV A 0X3B 0X11 0 12 0 39 MOV 0X13 MOV A 0X38 MOV 0X14 A restore ACC R3 R4 R5 following backup system _asm SWAPA OX3D Users have to confirm whether in ram bank 3 MOV 0 5 A or not If not have to switch to ram bank SWAPA OX3E 3 to restore correctly MOV 0X3 SWAPA MOV OX4 SWAP SWAPA 0X1F Example 2 int nBuf 5 void intcall INTERRUPT2 l void 00x08 low int 0 backup R3 R4 R5 asm switch bank by users WicePlus C amp Assembly User s Manual e 135 void _intcall 2 void int 0 asm save registers 0 10 Compiler will switch bank auto ov nBuf nBu 0 nBu 0 nBu r 0 nBu h rh X OV h 335333333 338 zs 4 do what you want to do interrupt occurred asm restore
83. WicePlus C amp Assembly For EM78 Series Microcontrollers USER S MANUAL ELAN MICROELECTRONICS CORP Nov 2008 Trademark Acknowledgments IBM is a registered trademark and PS 2 is a trademark of IBM Windows is a trademark of Microsoft Corporation ELAN and ELAN logo are trademarks of ELAN Microelectronics Corporation Copyright 2008 by ELAN Microelectronics Corporation All Rights Reserved Printed in Taiwan The contents of this User s Guide publication are subject to change without further notice ELAN Microelectronics assumes no responsibility concerning the accuracy adequacy or completeness of this publication ELAN Microelectronics makes no commitment to update or to keep current the information and material contained in this publication Such information and material may change to conform to each confirmed order In no event shall ELAN Microelectronics be made responsible for any claims attributed to errors omissions or other inaccuracies in the information or material contained in this publication ELAN Microelectronics shall not be liable for direct indirect special incidental or consequential damages arising from the use of such information or material The software WicePlus described in this publication is furnished under a license or nondisclosure agreement and may be used or copied only in accordance with the terms of such agreement ELAN Microelectronics products are not intende
84. a 1 Paste 2 3 org 0 00 Select All 4 51 Go to Line 5 6 Find Ctrl F 27 Find in Files 8 E Replace sl BookMarks Index BookMarks Clear All bookmarks To Index Book Marks Toggle Bookmark Toggle Bookmark1 Toggle Bookmark 2 Ctrl 2 Toggle Bookmark 3 Cte Toggle Bookmark 4 Ctrl 4 Toggle Bookmark 5 Ctrl 5 Toggle Bookmark6 Ctrl46 2 Toggle Bookmark Ae Toggle Bookmark 8 Ctrl 8 of Connecting LPT connected Toggle Bookmark 9 Ctr 9 The following figure shows an example when if you set index bookmark 1 at line 5 and index bookmark 2 at line 7 20 e WicePlus amp Assembly User s Manual org xfff jmp sl org 0 00 51 jmp sl oon I CO rS Go To Index BookMarks Go to a particular index bookmarked line From Menu bar click Edit gt Go To Index BookMark Then from the resulting submenu click on the index bookmark number you want access You can also directly press the shortcut keys ALT x where x the target index bookmark number 0 9 Ele Edit View Project Debug Tool Option IDE Window Help x3 Undo AltrBackspsce d e m cu Redo gt A d Cut Shift Delete Project E58 Cuv gale 1 org Oxfff a
85. a particular or all toolbars Furthermore you can create your own new unique toolbar which you can later Rename or Delete from this tab You can also add remove text labels to the toolbar buttons by clicking on the Show text labels check box 70 WicePlus amp Assembly User s Manual Keyboard tab Customize CHILO The Keyboard tab allows you to create remove shortcut keys for the commands of a selected command category The procedure is explained below A Creating a shortcut key After selecting a Category and Commands option from their respective boxes enter your custom shortcut key into the Press New Shortcut Key box WicePlus will auto detect whether the new shortcut key has already been assigned or not If it has already been assigned the pertinent command name with which the shortcut key is currently assigned will display under Assigned to field and you need to directly enter another shortcut key Otherwise Unassigned will display Then click Assign to apply If the Assigned to field displays it means the shortcut key you just entered is reserved for WicePlus internal use and is not user definable B Removing an existing shortcut key After selecting a Category and Commands option from their respective boxes the corresponding command shortcut key if available will appear in the Current Keys box Select the shortcut key and click Remove to delete C Restoring all shortcut k
86. alculator mode is off highlighted when on m Scroll Lock key SCRL is dimmed when cursor control mode is off highlighted when on WicePlus C amp Assembly User s Manual e 77 2 7 Hot Key e Ctrl Alt Shift G Big5 to GB Chinese Code Converter e Ctrl Alt Shift B GB to Big5 Chinese Code Converter e Ctrl Alt Shift Z Undo Converter documents with Chinese language 78 WicePlus amp Assembly User s Manual Chapter Getting Started 3 1 3 2 Hardware Power up With the 8 properly connected to target board and power source switch on ICE power and observe its red power LED lights up If the target board derives its power from ICE the yellow LED lights up as well Then launch your WicePlus IDE software when ICE and target board power up 15 confirmed to function normally Starting the WicePlus Program To start WicePlus Program click on the WicePlus icon from desktop or from Windows Start menu When starting from the Start menu click Programs then look for WicePlus group and click on WicePlus icon 3 2 1 Connect Dialog MCU selection x filter Filter ca Select MCU Micro Controller 785840 1 5840 ex p153 Connecting Port LPT USB Select connecting mode LPT Port Address 378H lt B o B LPT Port address memory condition setup Check ICE Memory Cancel Printer port speed Fig 3 1 Wice
87. ame move address of variable to ACC Example 1 asm Save procedure of and bank register mov 0 0 mov nbuf a mov a 0 04 mov Snbuf l a bs 0x03 7 bs 0x03 6 Switch to other rpages Restore procedure of rpage iopage and bank mov a nbuf register mov 0x03 a mov a nbuf 1 mov 0x04 int temp temp 0x03 we suppose temp is at 0x21 of bank 0 _asm mov a temp move value 0x03 to ACC _asm mov a temp move address 0x21 to ACC Example 3 unsigned int temp_a 0x20 bank 0 unsigned int temp_s 0x21 bank 0 define status 0x03 void main WicePlus C amp Assembly User s Manual e 131 asm mov temp a gt mov 0x20 mov status gt mov a 0x03 mov temp s gt mov 0x21 7 9 Using Macro You can use macro to control the MCU and shorten the program length Example define SetIO portnum var asm mov a var N asm iow portnum define SetReg reg 3 asm mov a 83 asm iow portnum macro SetReg will meet error for using constant as argument 7 10 Interrupt Routine in TCC1 To handle Interrupts two things have to be taken into account 1 Interrupt Save Procedure the procedure to save some registers before executing a service routine For instance ACC R3 should be saved in the 78 458 as Interrupts occur Only inline assembly is allowed under Interrupt Save Procedure 2 Interrupt Service R
88. ams can not define label name local label Reason The local label the preceding sign of label is can not be defined in the main and subroutine programs Solution To remove the local label from the main or subroutine program error A003 The syntax form should be operation operand operand Reason The syntax form of statements must be operation Solution To correct error of the line error A004 The label label name is redefined Reason The label is defined more than once Solution To redefine the label name error A005 The EQU syntax is label EQU operand Reason The EQU syntax is error Solution To correct error of the line error A006 The INCLUDE nest depth is over 256 Reason The maximum depth of using INCLUDE is 256 Solution To reduce the depth of INCLUDE error A007 The IF conditional expression is error Reason The expression of IF conditional is error Solution To correct the expression of IF conditional error A008 Attempt to divide by zero Reason The expression of number is divided by zero Solution To modify the expression error A009 The assembler does not support floating point Reason The assembler number system does not support floating point Solution To change the floating point to integer error A010 The symbol symbol name is not defined Reason The symbol is not defined Solution Please
89. ated by endif else can be used to provide an alternative compilation If necessary the program can use elif for an alternative compilation which should only be used for valid expressions Example fdefine RAM 30 fif RAM lt 10 define MAXVALUE 0 elif RAM lt 30 define MAXVALUE 10 else define MAXVALUE 30 endif 6 3 4 ifdef ifndef ifdef identifier ifndef identifier The ifdef directive is used for conditional compilation of definitions for the identifier The ifndef directive is used when conditionally compiling codes with the specified symbol not defined Both these two directives must be terminated by endif and can be optionally used with else Example define DEBUG 1 ifdef DEBUG define MAXVALUE 10 else define MAXVALUE 1000 endif WicePlus C amp Assembly User s Manual E 6 4 Literal Constants 6 4 1 Numeric Constant Decimal Default Hexadecimal constant Digit prefix with Binary digit Digit prefix with Numeric constants can be presented in decimal and hexadecimal depending on the prefix modifier Binary and octonary numerics are not supported Example 12 34 Decimal 5 OxB2 Hexadecimal 0610111001 Binary digit 6 4 2 Character Constant character Character constants are denoted by a single character enclosed by single quotes ANSI C Es
90. baa have entered Breakpoint or and Breakpoint nest syntax OXAAAA 0 Address 44 55 4 Address Counter Breakpoint group syntax The address breakpoint 0xLLLL 0xHHHH OxPP OXLLLL OXHHHH OxPP Low address High Address Counter format references WicePlus C amp Assembly User s Manual 53 Step 3 Select address breakpoint option Breakpoint group Breakpoint Breakpoint nest The following explains each of the options Breakpoint group Select this option to set a group of breakpoints in a range of address locations with a counter number a Select the Breakpoint group option m pm X b Specify a breakpoint group consisting of a start address end address and a breakpoint counter in the text box A breakpoint will be set to all addresses within the start and end address range The figure example below shows 0X01 0X04 0X01 which means breakpoints are set to all addresses between 0X01 and 0 04 and break counter is set to 1 thereby allowing a termination break on one passing 0 01 0 04 0 01 Click to save the settings You should see the group breakpoints indicated the Editor window or as shown in the figure example below The following shows an example xfff 3
91. bel Types options select the variable type to be displayed i e Special Register Control Register or RAM Bank Batch Dialog Step 3 Label Name BB CC DD Select or cancel the label by double click it Label Types C Special Register RO R1F Control Register C RAM Bank C Call ID RAM Page Y Bank 0 gt Block D Click to add the selections into the Watch window NOTE The variables displayed in the Label Name list box of the Watch Dialog are the same WicePlus C amp Assembly User s Manual Cancel 931 variables without register page ram bank control register page that you have defined in the program code using the double equal characters Double clicking a variable name will add or clear the asterisk An asterisk prefixed to variable name indicates that the variable is selected Click OK to add the selected variable to the Watch window x A Name Address Value 0x20 Bank 0 0 00 Bank 0 Ox3F 0x06 Control 0 0x10 Register 0 0x07 0x06 Control 1 0x40 Watchl 4 Watch2 Watch3 1 1 Method 3 Accessing Option gt View from menu bar Step 1 Click Option View Setting and from the resulting View Setting dialog select the Add defined label to watch automatically option There are three sort options in WicePlus version 2 6 or later Labels added into
92. bly keywords are shown in blue comments amp comments symbol are in green values are in brown and the rest are shown in black 16 WicePlus amp Assembly User s Manual R10 10 0 lnclude 447test h org xfff jmp sl org 0 00 51 0511 ir 0512 52 inc Oxil inc Oxi2 jmp 2 Right click anywhere within the Editor window to display the Edit shortcut menu Zut Shift Delete ER Ctrl C amp Paste Add to Token pool Last Position Next Position BookMarks Index BookMarks Go To Index BookMarks Add to Watch The following describes each command in the shortcut menu Cut Remove the selected text from current location and move paste it into another location First select the desired text range you want to move and then right click within the selected text With the shortcut menu on display click Cut command from the menu The selected text are then removed from the Editor window as shown in the figure below and temporarily stored in the clipboard Proceed to paste the text into your target location WicePlus C amp Assembly User s Manual e 17 LESe ell org xfff jmp sl Shift Delete Ctrl C Paste Add to Token pool Last Position Next Position The figure below shows the result after the cut operation include 447test h org xfff jmp sl org 0 00 Copy First select the
93. cape Sequences as shown below are treated as a single character ANSI C Escape Sequence V0 Null 00 Alert 07 W Backspace 08 V Form Feed 0C n New Line Carriage Return 00 X Horizontal Tab 09 W Vertical Tab 0B Backslash 5C Question Mark 3F Single Quote 27 Y Double Quote 22 Example 754 646 00 6 4 3 String Constant character list String constants are series of characters enclosed in double quotes and which have an implied null value 407 after the last character WicePlus C amp Assembly User s Manual e 111 Example 11 World Elan Micro 6 5 Data Type The size and range maximum and minimum values of the basic data type are as shown below Type Range Storage Size Byte void N A None signed char 128 127 1 unsigned char 0 255 1 signed int 128 127 1 unsigned int 0 255 1 signed short 32768 32767 2 unsigned short 0 65535 2 signed long 2147483648 2147483647 4 unsigned long 0 4294967295 4 bit 0 1 1 Bit When an arithmetic operator such as and 9 is used with different data types conversion of right aligned variables to left aligned data type is done before the operator takes effect We suggest users use the same data type to develop program 112 WicePlus amp Assembly User s Manual
94. ctions a high speed transmission and a stable system The WicePlus is project oriented IDE software The submenus of Editor Project manager Assembler and Debugger are included The main items of the Editor are find replace undo redo cut and paste The project manager has the function of inserting files to a project deleting files from a project and compiling a project The function of assembler includes include macro assembly arithmetic conditional assembly list files and map file Moreover the WicePlus also offers users a lot of friendly functions including block comment auto updated registers and real time line disassembler 1 2 System Requirements 1 2 1 Host Computer The EM78 Series C Compiler requires a host that meets the following specifications m IBM PC Pentium 100 or higher is recommended or compatible computers m Win2000 WinME NT or WinXP and Vista 32 m At least 40 MB or more free hard disk space 109 WicePlus amp Assembly User s Manual m Atleast 256MB of RAM 512MB more is recommended m Mouse and USB connectors are highly recommended 1 3 Software Installation The compiler is included in WicePlus the 78 Series Integrated Development Environment IDE When installing WicePlus the compiler will also be installed The drivers of ICE are included in WicePlus too If it is the first time
95. d for use in life support appliances devices or systems Use of ELAN Microelectronics product in such applications is not supported and is prohibited NO PART OF THIS PUBLICATION MAY BE REPRODUCED OR TRANSMITTED IN ANY FORM OR BY ANY MEANS WITHOUT THE EXPRESSED WRITTEN PERMISSION OF ELAN MICROELECTRONICS 2 WicePlus C amp Assembly User s Manual 2 Tiny Compiler version 2 distribution note 2008 07 10 From now we dogmatically call C Compiler which has been embedded in WicePlus for long time as TCC1 Tiny C Compiler version 1 or ELAN Tiny C Compiler version 1 TCC2 Tiny C Compiler version 2 or ELAN Tiny C Compiler version 2 is based on the TCC1 and improve it There are some difference between TCC1 and TCC2 For example 2 supports EM78P510N but not 2 supports TBRD instruction but TCC1 not Table below shows them For some reason we reserve TCC1 and TCC2 in the following distribution of WicePlus Actually users can just modify somewhere such as important register save and back up C system save and back up registers in interrupt function and notification reserve register 0 10 in proJects between TCC1 and TCC2 to develop their project But we don t suggest that Difference between and TCC2 TCCI TCC2 Reserve common register 0x10 for Compiler C system back up manual Auto interrupt function interrupt service functions All interru
96. dard Toolbar 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 SHH 9 Q Fig 2 21b WicePlus Main Window Build Toolbar Toolbar Icons and Functions Corresponding hot key is enclosed in parenthesis 1 2 10 11 12 13 14 15 16 m muy Open open an existing file Ctrl Save save current active document Ctrl S Save All save all document Cut remove the selected string to clipboard Shift Del Copy copy the selected string to clipboard Ctrl C Paste paste the string from clipboard Ctrl V Undo cancel the last editing action Alt Backspace Redo cancel the last undo restore the undone editing action Open Hide Workspace display hide toggle for Project window Open Hide Output display hide toggle for Output window Find find string from within entire active file Ctrl F Find Down find string from cursor position toward the end of file Find Up find string from cursor position toward the beginning of file Find from Files find string from inactive files Bookmark bookmark the line at cursor position Jump Down to Bookmark jump to next bookmark from cursor position toward the end of file WicePlus C amp Assembly User s Manual e 75 76 17 18 19 20 21 25 26 27 28 29 30 31 32 33 34 35 F Jump to Bookmark Jump to next bookmark from cursor position toward the beginning of file
97. desired text range you want to copy and then right click within the selected text With the shortcut menu on display click Copy command from the menu A copy of the selected text is then temporarily stored in the clipboard Proceed to paste the text into your target location sinclude 447test h org Oxfff jmp sl Cut ShifttDelete Add to Token pool Last Position Next Position Paste Insert the selected text that has been recently cut or copied into clipboard into the target location The following example shows the paste result of the text at the bottom shaded 18 WicePlus C amp Assembly User s Manual of same page in Editor window include 447test h org xfff jmp sl org 0x00 sl ely 11 ele Oxz12 52 0 11 0 12 jmp 52 Bookmarks Insert markers to specific lines that you may wish to return to at later time Step 1 To insert bookmark place cursor on the selected line then click Edit gt BookMarks gt Toggle from the Menu bar or directly press the shortcut keys CTRL F2 File Edit View Project Debug Tool Option IDE Window Help Step 2 is x3 Undo AlttBackspace m g B uw Cu Redo wx Cut Shitt Delete Copy Ctrl C 1 Paste 2 B 3 org 0 00 Select All 4 61 Go to Line 5 m 6
98. e That is users have to compile a time to know these message Character C in the line Ox10 means C compiler occupied in other functions Compiler will dynamic to use these in WicePlus 2 Register O123456789ABCDEF 01234 5678 8123456789 B ZX bddddddddddddddd 0x00 gt h ddaa 0 00 dde dos seem dddddddddddddddd 0x10 Ox T 51 2x mma H Bi3X Bl Call Depth Depth Interrupt Function TL Build Information Find in Fies X Mesage Trace log Forth _ 07 0157 Dos Example 1 Void intcall INTERRUPT1 l void 0 08 low int 0 backup ACC R3 R4 R5 _asm MOV OXIF SWAPA 0X4 BS 0X4 6 switch to ram bank 3 BS 0 4 7 MOV A SWAPA 0X3 MOV OX3E SWAPA 0 5 MOV OX3D PAGE 0 0 or Use BC to switch program page 0 if the MCU doesn t support page instruction void _intcall INTTERRUPT1 void int 0 backup C system 0 10 system backup OV OX3C save 0 10 0 14 to 0x3C 0X3B OX3A 0X39 0 11 0 38 in bank 3 because switch to ram OX3B bank 3 in intcall INTER
99. e click on the source file and the file is File from File Menu automatically opened in the Editor window WicePlus C amp Assembly User s Manual 85 Double click to open amp edit file CE k mr s Source file _ Name Address Type Value opened for editing 3 6 Compile the Project Save Project 86 o To edit source files that are already added into the Project see next Section 3 5 2 Open Source File from Project for Editing You can edit source files that are already inserted in the project To do so double click the source file you wish to edit from the Project window and the file will open in the Editor window pucri 732 connerte i Ble Edt View Project Debug Tool Option IDE Window Soo DAMAS S RA estamos ee s test zx 0x0 start EMTO569 3 mov a 80x02 zs kn waq 4 mov Dx20 a Qd 5 mov x21 a Header File R12 Mii 5 inc 0 20 7 0 21 3 M Laer fe 8 jmp start RI 16 Ro FF R FF EJ E FE FF FF FF Ris FF R5 FF FE FF F FF FF R9 FF RA FF aaa ae RIB FF RB FF E RIC FF RC FF RC RID FF RD FF RI RIE FF RE FF FF
100. e on the toolbar to set a breakpoint CM mec F T T m Fig 3 17 Active Source File with a Defined Breakpoint Likewise the defined breakpoint is cleared if you double click on it again or the hand icon is clicked the second time while the cursor positioned on the defined breakpoint To clear all existing breakpoints click Clear Breakpoints command from Debug menu WicePlus C amp Assembly User s Manual 91 Chapter 4 Assemble link 41 Assembler and linker process flow A AO dt or asm Including files i 7 B E List file Ast Ba Linker N gt Map file map Target file cds 4 22 Statement syntax label operation operand operand comment fields are not case sensitive and separated by space or tab Label The colon is optional and is followed by one or more spaces or tabs A label consists of the following characters A Z 7 0 9 92 WicePlus amp Assembly User s Manual but with some restrictions 0 9 must not be the first character of a name Only the first 31 characters are recognized To reserve colon is recommend to programmers because it could be more readable How to define label a zeroflag equ RXX YY 1 zeroflag R3 2 Ex2 status R3 b zeroflag 1 equ OxXX YY Ex1 zeroflag 0
101. ecimal rr Warning A053 The call jmp address is not over page Reason The target address and call or jmp instruction is in the same page ss Warning A054 s unreferenced variable Reason The variable not use in the project WicePlus C amp Assembly User s Manual e 163 4 164 Class L linker error error L001 Memory of stack type stack overflows Reason O S can not allocate extra memory Solution To close unused editor window or close unexecuted application error L002 The file file name can not be found Reason The file can not be found Solution To check whether the file exists or not error L003 The Object file format does not belong to EMC object file format Reason The object file format does not belong to EMC object file format Solution To reassemble the source file error L004 Symbol symbol name is not defined Reason The symbol is not defined Solution To define the symbol error L005 Public symbol symbol name is conflicted Reason The public symbol is defined more than once Solution To redefine the public symbol error L006 ROM address number is conflicted Reason The program address is conflicted with another Solution To use function of Edit gt Find menu to find the address in the list file then to update the address of the program position error L007 The file file name can not be created
102. ecomes solid again The red address breakpoints are applicable only when the blue ones are all cleared Note 4 To clear all blue breakpoints do either of the following From the menu click Debug gt Clear All Address Break Point Press the shortcut keys CTRL ATL WicePlus EM78P4 nected p447 dt File Edit View Project Debug Tool Option IDE Window Help 2 0 x 85 oo F5 f Free F10 e E D O Reet S vow p447 dt T8 Step Into F Project s m Step Over 5 23 78 4475 447 1 09 Step Out 2 29 Source Files H Go To Cursor F4 23 Header Files Continue step into ShifttF ma List Files X7 Run from Selected Line 8 447 Ast Files 9t Sapete 3 Library Files Add Label to Watch Reset and Free Run Reset and Go Run From 4 Toggle Breakpoint F9 Show All Breakpoints Ctr AI FO Clear All Breakpoints Ctrl F Address Break Point Clear Address Break Point Ctrl Alte A FibView lt Trace Back c gt Trece Forth x WicePlus C amp Assembly User s Manual e 57 5 clear individual range of blue breakpoints do the following a From the menu click Debug gt Address Break Point or press Alt A Address Breakpoint xi e You can also enter the specific or range of address breakpoint s you want to
103. ement and decrement operators Assignment operators Logical operators Bitwise operators Equality and relational operators Compound assignment operators The table below shows the detailed description of each of the operators Arithmetic Operators Symbol Function Expression addition expr1 expr2 WicePlus C amp Assembly User s Manual e 115 _ subtraction expr1 expr2 multiplication expr1 expr2 division expr1 expr2 modulo expr1 expr2 Increment Operators Symbol Function Expression T increase by 1 expr decrease by 1 expr Symbol Assignment Operators Function equal Expression expr1 expr2 Bitwise Operators Symbol Function Expression amp bitwise AND expri amp epxr2 bitwise OR expr1 expr2 bitwise gt gt right shift expr1 gt gt expr2 lt lt left shift expr1 lt lt expr2 bitwise expri expr2 Equality Relational and Logical Operators lt Less than expr lt expr X lt y lt Less than or equal expr lt expr X lt y gt Greater than expr gt expr X gt y gt Greater than or equal expr gt expr X gt y Equality expr expr X y l Inequality expr expr amp amp Logic AND expr amp amp expr amp amp y Logic x y Logic NOT lexpr Ix Com
104. ete Cancel Breakpoint or and Breakpoint nest syntax 0 OXAAAA Address 44 55 4 5 Address Counterj Breakpoint group syntax 0xLLLL 0 0 DXLLLL 0xHHHH 0xPP Low address High Address Counter Fig 2 15d Address breakpoint WicePlus C amp Assembly User s Manual The breakpoint method in this dialog is the address breakpoint which is contradictory to the source level breakpoint namely the source level breakpoint will be inefficient if you use address breakpoint at the same time Therefore if you choose Address breakpoint not active the method of the source level breakpoint will be effective 451 Address breakpoints include three types Group Nest which contradictory to each other However the set up syntax for OR and Nest 15 the same but it is different from Group s a Breakpoint Group There are 63 groups at most and each group has start address end address and pass count When any instruction is executed between start address and end address pass count will be deducted 1 As the pass count is equal to 0 the executing program is stopped at once All of groups are independent of each other b Breakpoint OR 63 groups are at most Each group is composed of several addresses and a pass count When any address is executed inside group pass count will ded
105. eys to their default settings Click Reset All to reset all command shortcut keys to the WicePlus default settings WicePlus C amp Assembly User s Manual e 71 adn To save your custom shortcut keys for future use e g when upgrading WicePlus D Saving Loading settings to a new version click Save to File to store the settings to a file with a KEY file extension You can simply click Load from file to re apply your custom shortcut keys into WicePlus d Option tab istomize Use the Option tab to set the size of the toolbar buttons and specify whether to display screen tips and shortcut keys where applicable when pointing at the button You can also set to display the WicePlus sub windows to look like that of Windows 2000 72 WicePlus amp Assembly User s Manual 2 38 IDE Menu C C Select C language editing v Assembly Assembly Select Assembly language editing Fig 2 18 IDE Menu 2 3 9 Window Menu New Window Open a new or split Editor New Window window Cascade Cascade Rearrange all Editor window Tile Vertical active files so that they appear Tile Horizontal overlapping in sequence with A their respective title bar fully Arrange Icons visible Tile Vertical opened Edit Windows ile Vertical Rearrange all opene itor windows vertically Fig 2 19 Window Menu Tile Horizontal Rearrange all opened Editor windows horizontally Arrange Icons Arrange all opened file filena
106. fference between PC and server Therefore it is better to locate all source files in one computer no matter that is network computer or local one 176 WicePlus amp Assembly User s Manual Appendix D Frequently Asked Questions About Tiny C Compiler FAQ 0 1 Q What is the maximum number of the function parameters A Itdepends on the RAM bank size about 32 or 31 bytes 0 2 Q ln a function what is the maximum depth of the function call A It depends on the hardware stack depth or size D 3 Q What is the maximum array dimension as well as maximum array element A Itdepends on the RAM bank size about 32 or 31 bytes 0 4 Q ls there any error message when the code exceeds the ROM size A Yes the linker will report an allocation error WicePlus C amp Assembly User s Manual e 177 0 5 Qt In a high level interrupt subroutine can user allocate the address in the ROM e g using data type putting asm org xxx before a subroutine etc This may cause unpredictable error 0 6 Q ls static used in the same way as in ANSI Yes 0 7 Q ls there any error message case user defines too many variables in the const that exceeds the ROM space A Yes the linker will report an allocation error D 8 Q How dol declare the variable in h file and using not only in one c file A for example declare in h file like that extern io unsigned int
107. formation for address breakpoint The Address Break Point command allows you to directly set a more complex breakpoints setup which can terminate at an address location Setting an Address Breakpoint Step 1 Open the Address Breakpoint dialog using one of the following methods WicePlus C amp Assembly User s Manual e From the menu bar click Debug gt Address Break Point e Press the shortcut keys ALT A Edit View Project Debug Tool Option IDE Window Help GEL So F5 F10 Ue e v By Sep Into TP Step Over 29 EM78P447S DAE Step Ont m Soue Files 0 F4 E Wpe 92043She 23 Header Files Continue step into Shift F 23 List Files X Run from Selected Line Map Files E Library Files Stop Debug Add Label to Watch Reset and Free Run Reset and Go Run From Mh Toggle Breakpoint F9 Show All Breakpoints Cte Alte F9 Clear Breakpoints Address Break Point Clear All Address Break Point Chit Alte Trace Back c Trace Forth Ctisk Step 2 The Address Breakpoint dialog displays as shown in the following figure Address breakpoint not active Function option C Breakpoint group Breakpoint or C Breakpoint nest Enter the address breakpoint in accordance with the format specified This box displays all the
108. gram execution Example This is a single line comment This is the comment line 1 This is the comment line 2 6 2 Reserved Words The reserved words for WicePlus C Compiler are made up of both the ANSI C conformity reserved words and the EM78 Series unique reserved words The following table summarizes all the applicable reserved words for this compiler ANSI Conformity Words const default goto switch typedef sizeof break do if short union extern case else int signed unsigned char enum long static void WicePlus C amp Assembly User s Manual e 107 continue for return struct while EM78 Series Unique Words indir ind page on off io iopage intcall rpage low int asm bit bank 6 3 Preprocessor Directives 108 o Preprocessor directives always begin with pound sign The directives are recognized and interpreted by the preprocessor in order to compile the source code properly 6 3 1 include include file name include lt file_name gt The preprocessor will search the working directory to find the file The preprocessor will search through the working directory first to look for the file If the file cannot be found in the working directory it will search the file from the directory specified by the environment variable EMC_INCLUDE include tells the preprocessor to add the con
109. h for i 0 i lt 10 i flag indata port if flag 0 continue outdata port WicePlus C amp Assembly User s Manual e 119 6 17 Goto Statement goto label label goto statement is used to Jump to any place of a function It is useful to skip from a deep loop Example for i 0 i lt 10 i for 3 0 j lt 100 344 for 0 lt 100 k flag crccheck buffer if flag 0 goto error outbuf buffer error clear up buffer 6 18 Function Function is the basic block of the C language It includes function prototype and function definition 6 18 1 Function Prototype return type lt function name parameter list A function prototype should be declared before the function can be called It contains the return value function name and parameter types Example Function Prototype unsigned char sum unsigned char a unsigned char b 120 e WicePlus C amp Assembly User s Manual 6 18 2 Function Definition return type lt function_name gt lt parameter_list gt statements Example Function unsigned char sum unsigned char a unsigned char b return a b WicePlus C amp Assembly User s Manual 121 Chapter 7 Control Hardware Related Programming 7 1 122 Register Page rpage variable name lt address gt
110. he address of program counter is over the program ROM size Solution To reduce the code size aa error A027 The assembler exceeds max pass number Reason The pass of assembler is over the maximum default pass Solution To check the assembler errors bb error A028 The operand number value dose not include the valid data Reason The operand value is invalid Solution To change the operand value cc error A029 The number address is conflicted Reason The program address is conflicted with another address Solution To use function of Edit gt Find menu to find the address in the list file then to update the address of the program position 162 e WicePlus C amp Assembly User s Manual dd error A030 The file file name can not be opened Reason The file can not be opened Solution To check whether the file exists or not ee error A031 The configure file read error Reason The format of the configuration file is not correct Solution To setup WICE software again ff error A032 The file file name can not be opened Reason The file can not be opened Solution To check whether the file exists or not gg error A033 The macro is not defined Reason The macro name is not defined Solution To define a new macro or change a macro name hh error A034 The expression can not be calculated Reason The format of the expression is not correct Solution To correct the format of
111. he project you have to check Empty file box mee Option IDE Window Help oa DRM R HAARALA S SEI D Q _ EE ACC 08 CONT BF RO FF RUTCC D 174 Rore Cie a Nov Fie Projet 5 1 Aad new fib to project DF RS 0 Ch FF C5 00 Empty Fie m3 0100 03 00 FF oc 0 pwa m King Adoress e Es DC 6 42 SD Bafa D B 5 oc 38 71 C2 3B 0 85 80 15 81 DO 11 C3 40 A2 1l EO 25 83 F2 A2 DO OC 02 6 22 AE 10 31 80 ad EF ie 07 45 6 60 AC z 08 9 9 H 94 57 X B i b ERGX E Ax s 30 81 Bi 48 12 co 92 97 02 94 99 L Buk Z Piromason 5 EndinFiks X Mesas X Rom 4 aca 6 There 1 very important difference about save and restore registers between Example 1 and Example 2 In example 2 compiler allots the locations where variable nBuf is So compiler identifies nBuf variables in inline assembly Compiler will check variables redefined or not In example 1 if users declare some variables at 0x38 0x39 0x3A Ox3B Ox3C bank 1 in other location the project compiler doesn t check reuse That s compiler can t report error But error will occur during
112. iginal 8 bit to fit 16 bit piggy back high byte in 8 bit piggy back will become low byte in 16 bit piggy back low byte in 8 bit piggy back will become high byte in 16 bit piggy back Compute the execution time between two breakpoints Shown as Fig 2 16b Only for EM78815 use Shown as Fig 2 16c Only for C Compiler use This function is not yet supported How to compute execution instruction time of ICE Step 1 To select frequency To see Fig 2 16b Step 2 To execute TraceBuffer F2 of WicePlus The result is in message window Step 3 The result of execution times is in information window WicePlus C amp Assembly User s Manual e 59 Compute execution time Set Frequency Fig 2 16b Set Frequency Compute executime time function Enable Disable Frequency of ICE 4 000000 MHz This frequency is used for calculating timing while execution Fig 2 16b1 Set Frequency TUT lem ERP LO S69 569 dt 16 gt JERR SCART BIER E10N569N562 dt 17 0050 09 Ox10 A Code Bus Disassembler File Name Line 1809 09 0x9 D ECRIRE 10 569 569 9 8 0963 09 0x3 0x7 D em TRI F10N569N569 dt 9 0883 09 0x3 0X6 D 7 8 RI F10N569N569 dt 10 0047 09 MOV 0 7 ARR 10 569 569 dt 11 0048 09 0 8 D em RIF 10N569N569 dt 12 0049 09 Ox9 A CDS AIBA E10
113. iles to Project Delete files from project Close amp compile Alt F7 Rebuild All Alt F9 Add Files to Dump to ICE F3 Project gt Trace Log F2 VO Delete Files from Project Fig 2 14a Project Menu Assemble or Compile in C mode Create a new project Open an existing project Save the active project together with all related files Close the active Project window Add the existing source file into project Remove source file from project To assemble or Compile the active file window If errors occur in the assembler or compiling time error messages will be shown in the output window otherwise 0 errors 0 warnings 0 users will be displayed Rebuild All To assemble or compile all files regardless of having been modified or not and link them to the opening project Dump to ICE Dump the program code to ICE Trace Log To refer an available history only when the function of Go Free Run or To Cursor in the debug menu is executed The maximum length of trace log is 8K words LPT connect The last record is next instruction without execute USB connect The last record is last instruction which has executed Dump code over 64K Only for EM78815 To dump the page range s tosram program code over 64K to the SRAM The SRAM must plug in the hardware Shown as Fig 2 14b WicePlus C amp Assembly User s Manual e 47 Dump code over 64
114. int x int y 00x33 page 1 myFun2 is put at 0x33 at ROM page 1 Progrom ROM Progrom ROM 0x033 0x33 of pageO 0 2222 Function befor allocation 0 433 0x33 1 0 0433 0x33 at 1 Function after allocation 7 7 Putting Data in ROM const lt variable name gt Some data cannot be altered during program execution Hence you need to store such data into the program ROM to save limited RAM space The Compiler uses TBL instruction to incorporate such data into the program ROM Example WicePlus C amp Assembly User s Manual e 129 const int myData 1 2 3 4 5 ll const char myString 2 3 Hi p myData myString 7 8 Inline Assembler The compiler has an in line assembler which allows you to enhance the functionality of your program 7 8 1 Reserved Word The reserved words for the inline assembler are _ des write assembly code here the assembly instructions in upper or lower case of the EM78 series supported 130 e WicePlus C amp Assembly User s Manual Example 2 7 8 2 Use of Variable in the Inline Assembly The Compiler allows you to access the C variable in the inline assembly as follows mov a variable name move variable value to ACC mov a lt variable n
115. ion Setting to see section 2 3 7 2007 07 25 1 Modify Correct about interrupt C system back up description in Example 1 page 124 2007 09 27 1 Fix C source code can t be written over column 512 2 Add Call Stack window supplement sec 2 2 4 page 26 3 Add Long Delay Time description sec 3 2 1 page 77 4 Add Step Over Macro description sec 2 3 7 page 62 2007 11 06 1 2 distribution note 2 TCC2 interrupt service routine sec 7 11 page 132 3 TCC2 menu sec 2 3 7 page 60 Add Format select Edit menu in C environment See page 38 2008 07 10 Add Q amp A in Appendix D Replace some pictures in sec 2 2 6 Add filter in connect dialog see sec 3 2 1 page 76 Use new code option dialog see sec 3 2 2 page 78 2008 10 13 Add LCD RAM Window to see section 2 2 8 Fix The content of Q 12 Appendix D Fix the lost of reti inline assembly in example 3 EM78567 sec 7 11 3 w 2008 11 20 WicePlus amp Assembly User s Manual Chapter 1 Introduction 1 1 Overview WicePlus 1 ICE integrated development environment IDE software on Windows 2000 or Windows for the 8 bit microcontrollers EM78series of Elan Microelectronics Corporation EMC The WicePlus has four main modules which are editor project assembler and debugger The aims of the WicePlus are to provide a friendly operation environment powerful fun
116. l Pane SEG value is automatically increased by 1 Note that only the value located at the value located Swap Auto Increase the right box will change in this box will change 5 Thus there is no need to manually change the Control COM SEG value when CS setting 0 1 value for the next segment Just directly click on the segment 6 Due to fact that SEG Range 15 set at 0 1 see Item 1 above the next or 3 segment you click cannot increase its COM 1 SEG 0 SEG value to 2 Therefore the system automatically allocates the auto increase Auto Increase 1 value of 1 to COM and sets the SEG value back to 0 7 Therefore all you need to do is 23 continuously click on the remaining um segments to set their COM SEG values n within the defined range gt OH In addition to above other convenient functions of the LCD window are also available and are describe below together with its respective notes 1 If you wish to automatically apply the SEG 1 COM Auto Increase value to COM instead of SEG click Swap button and observe SEG amp COM swaps positions Only the Valne located in this box will change Increase WicePlus C amp Assembly User s Manual e 37 38 e 2 After clicking Swap also observe that the system has at the same time switched 303 the po
117. l sort by these three 3 label placed in the end at Watch window when user manual operations in previous descriptions 4 To execute Dump F3 at C Mode AII global labels display at Information sub window of Output window 4 1 First field 1 the type of variable and page number 4 2 Second filed is the register s or Rom s address of variable 4 3 Third field is the name of variable REGISTER 0 0x0010 varRegisterl IO 0 0x0005 CONTROLO 05 IO 1 0x0006 CONTROL1 06 BANK 0 0x0020 varBank20 0 BANK 0 0x003F varBank3F_0 BANK 0 0x0021 varBank21_0 4 Build gt Information Find in Files gt Message 4 2 2 7 Data RAM Window S33 3339 9 4 a 33 og A359 959 35 9 999 9 g m Fig 2 8 Data RAM Window The Data RAM window 15 accessible only if RAM 1 available form the target microcontroller currently in use The Data RAM window shows the contents of the data RAM When closes the Windows will not read to the hardware any concerns this Windows s contents 34 WicePlus amp Assembly User s Manual WicePlus amp Assembly User s Manual 2 2 8 LCD RAM Window With the IC that supports LCD installed and in used open the LCD RAM window and increase the height of the LCD RAM window until the window looks as shown in Figure 2 9 When closes the Windows will not read to the hardware any concerns this Windows s contents 8
118. mbly User s Manual 97 98 e PUBLIC and instructions can defined place of a file which contains one or more PUBLIC or EXTERN instructions Syntax EXTERN lt label gt lt label gt Example A project contains two files one is TESTI DT the other is TEST2 DT TESTI DT org 0x00 Public start Extern loopl Start mov a 0x02 mov 0x20 a jmp loopl TEST2 DT org 0 100 Public loopl Extern start Loopl inc 0x20 jmp start The label of Start which is defined in the TESTI DT file and is referenced by the TEST2 DT file must be announced as PUBLIC in the TEST1 DT file and EXTERN in the TEST2 DT file The label of loop1 which is defined in the TEST2 DT file and is referenced by the TEST1 DT file has to be addressed as EXTERN in the TESTI DT file and PUBLIC in the TEST2 DT file VAR The instruction defines variable name in the assembly time so the value of variable is only changed in the assemble time Syntax Label VAR expression Example testvar 1 mov a test test var test 1 mov a test MACRO ENDM The instruction defines macro Syntax label MACRO parameters statements ENDM Example bankO macro bc0x04 6 WicePlus C amp Assembly User s Manual bc0x04 7 endm Attention The max number of macro is 32 Attention Those parameters must to be a definite address
119. mes in a single line formation minimized into multiple file icons at the bottom of the Editor window Close All Windows Close all opened files Show Select Window Dialog 2 3 10 Help Menu User Manual User Manual User Manual Content Index Example for C Only for C Compiler Search TETEA Content Open the WicePlus User s about Register ELAN Manual Fig 2 20a Help Menu Index Index from WicePlus User s Manual Search from WicePlus User s Manual Search Check New Check new version of WicePlus from Version WicePlus C amp Assembly User s Manual e 73 74 About Register ELAN 9 New version is announced 7 Please go to http vww emc com tw twn products asp np id l amp type flag 3T to download the latest version Do you want to link to WicePlus web site right now m Fig 2 20b check new version Shows the current version of WicePlus program and other information including a read me file on recent changes of the WicePlus C fios EMC C Compiler for ICE WicePlus Version 1 5061227 Copyright 2006 ELAN Microelectronics Inc All rights reserved Web http Avww emc com tw Fig 2 20c About Dialog To register to ELAN WicePlus C amp Assembly User s Manual 24 Toolbar 1 2 4 1 3 8 E 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 8 5 c mINAS WO e Fig 2 21a WicePlus Main Window Stan
120. mmand is prefixed with a check mark vale FF 33 FF F B5 EB DF FF FB Edit Revise the existing register value This is the same as double clicking on the value as explained above However using this Edit function is preferable WicePlus C amp Assembly User s Manual e 27 2 2 6 Watch Window x Al BB DD EE Address 0 20 x3F 0 06 0x06 0x10 N Watch1 Watch amp Wekh 0 0 00 Bank 0 Control 0 OxFF Control 1 0 40 Register 0 0 07 Fig 2 7 Watch Window In the Watch window you can add variables that are declared in assembly file The Watch window will show the defined variable information such as name contents bank and address Please reference to sec 4 2 for assembly code 02 nxin step to add variable to watch window TERE e i By Ctrl C 1 Reverse the variable in such case is aa pg Paste i Add to Token pool 2 Click right button of mouse and a menu popup T Last Position 3 Select Add to Watch item Supplement 10 BookMarks Index BookMarks Go To Index BookMarks Add to Watch To view real time change of the selected register values from the Watch window during debugging the register values have to be entered into Watch window To do so do one of the following three methods are available Method 1 Direc
121. n Not only one interrupt vector extern int IntVecIdx occupied 0 10 0 void _intcall AllInt void int switch IntVecIdx case 0x4 write interrupt vector 0x3 in this case break WicePlus C amp Assembly User s Manual case 0x7 write interrupt vector 0x6 in this case break case OxA write interrupt vector 0x9 in this case break case OxD write interrupt vector 0xC in this case break case 0x10 break case 0x13 break case 0x16 break case 0x19 break case 0 1 break User also can use if else if write interrupt write interrupt write interrupt write interrupt vector vector vector vector OxF in this case 0x12 in this case 0x15 in this case 0x18 in this case write interrupt vector 0x1B in this case if IntVecIdx 0x4 else if else if else if else if IntVecIdx 0x7 tVecIdx 0xA tVecIdx 0xD tVecIdx 0x10 WicePlus C amp Assembly User s Manual e 141 142 else if IntVecIdx 0x13 else if IntVecIdx 0x16 void intcall TCC l void 0x03 1ow int 0 asm MOV 0 2 using LUMP to interrupt service procedure void intcall ExtInt l void 0x06 1ow int 1 _ 0 2 void _intcall WatchTime_l void 0x09 1ow int 2 _ 0 2 void _intcall Timel l void O0Ox0
122. n is assembled then the rest instructions of macro not assembled Syntax MACEXIT Example Source test var 5 bankO macro bc 0x04 6 if test gt 4 macexit endif be 0x04 7 endm bankO 100 e WicePlus C amp Assembly User s Manual After assembler first column is address 0000 bc 0 04 6 Because test variable is equal to five the expression test gt 4 15 true and the macexit instruction is assembled Because macexit instruction is assembled the rest instructions of macro bc 0 04 7 not assembled 1 MESSAGE Display user defined message in the output window Syntax MESSAGE lt characters gt Example org 0x00 message set bank to 0 bc 0 04 6 bc 0 04 7 Display below message in the output window after assembler USER MESSAGE set bank to 0 Attention The max number of message is 500 m Current program counter value is used as an operand Examplel jmp jmp means that jump same line as dead loop Example2 bc 0x04 6 jmp 1 imp 1 means that jump back to bc 0x04 6 4 6 Conditional assembly a IF If the statement after expression is true then the following instructions are assembled until ELSEIF or ELSE or ENDIF Syntax IF expression lt statements1 gt ELSEIF lt expression gt lt statements2 gt ELSE lt statements3 gt ENDIF WicePlus C amp Assembl
123. n opens If the file is already opened no action is performed Properties Displays the complete path of the selected file The following figure shows the where the 447test dt file is located Filename DAEMCYC P447447test dt Delete Removes the selected file from the current Project Source Files folder If the file is still opened the program closes the file before removing it For example if you select to remove the 447test dt a confirmation dialog will display Click the Yes to remove the file from the ect otherwise click the No Do you want to remove 447test dt from the Project WicePlus C amp Assembly User s Manual e 15 2 2 2 The Editor Window 1 org 0 0 The Editor window is 2 start multi windowed editing tool mov 0 02 MR d mov 0 20 or creating viewing an mov 0 21 debugging source files inc 0x20 inc 0x21 jmp start OD OT um Fig 2 8 Editor Window The Editor s major features are m Unlimited file size m Multiple files can be opened and displayed at the same time W Insert overstrike mode for editing m Undo Redo m Clipboard support text can be cut copied moved and pasted onto the clipboard using a keystroke m Drag and drop text manipulation highlighted text can be dragged and dropped between any of the IDE windows Supplement The figure below shows a typical Editor window displaying contents of an opened source file 447test dt Assem
124. nd what Iff Match whole word only Direction Cancel C Down Match case Find what Enter the string you want to search Match whole word only Select this option to search string that matches the string as a whole word For example if you want to search for abc the function will not pick out words that has additional characters including spaces before or after the defined string such as 123 or Match case Select this option to match the string lowercase and uppercase characters exactly as they appear Direction Up search toward the top of the document Down search toward the bottom of the document Find Next Click this button to continue searching for the next match Matched string is highlighted The following figure shows an example where Find function activate the location where a WicePlus C amp Assembly User s Manual e 43 match is found and highlights the search string EE dt R10 0 10 0 R11 0 11 D org Oxfff jmp sl org 0 00 sl cir 11 eir 52 inc 11 0 55 0 55 0 55 0 55 mov 0 55 inc 0 12 jmp 2 Match case Method 2 Using the lnclude 447test h Find what mov Find Next Direction Cancel Ber ay C Up Down Warning s 0 User Message s sl clr elr s2 inc mov mov mov mov mov inc CO
125. nds to dump full of this part How many seconds it takes to dump external SRAM depends on your code size over 64K word You could enable the external code checking box in Environment setting Dialog Option menu We recommend you to enable external code checking box in first dumping and disable it after first dumping to save another about 40 seconds If you program code is less than 64K word it will not dump to external SRAM Shown as Fig 2 17e WicePlus C amp Assembly User s Manual e 63 iim 2 3 7 Option Menu ICE Cade Setting Font Debug Option Setting Dump ASPCM Variable Radix View Setting Environment setting ICT Customize v TCC2 Tiny C Compiler ver 2 Fig 2 17a Option Menu Dump ASPCM Variable Radix Accelerate Reading Registers View Setting Enviroment setting Customize TCC2 ICE Code Setting Set code option for the selected microcontroller Font Define font for Editor windows fonts for other windows are fixed Debug option set debugger variables setting options Shown as Fig 2 17b Dump to Data ROM Select between decimal or hex option Only for USB ICE When frequency over 1 6MHz read registers quickly To set WicePlus view variable Shown as Fig 2 17d To set WicePlus environment variable for example whether list file is created or not whether map file is created or not and the number of editor window Shown as Fig 2 17d Customize toolbars menus and accelerators
126. not be set outside the macro definition Solution To remove the MACEXIT instruction s error A019 Parameter must be string variable Reason The formal parameter must be defined as string Solution To change the formal parameter to string t error A020 Memory can not be allocated Reason O S can not allocate extra memory Solution To close the editor window which is not used currently or close application which is not used at present error A021 The source statements exceed number lines Reason The line number of source file is over the system default limit Solution To divide the program into two or more small programs v error A022 The tree is error because of parser error Reason The syntax of the program line is error Solution To rewrite the program line error A023 allocated memory type memory fault when memory is allocated Reason O S can not allocate extra memory Solution To close the editor window currently not used or close application currently not used x error A024 Setting assembler variable must be integer value Reason The result of expression in the right side of SET instruction must be integer Solution To change the expression y error A025 Address of ORG must be integer value Reason The address of ORG must be integer Solution To rewrite the address expression of instruction z error A026 The number address of PC is out of number ROM size Reason T
127. o to Line Move cursor to the defined line number within the active window Formation Formats the selection using smart Selection indent settings Only support C Find Find the defined strings in the active window Find in Files Find the defined string in the active and non active files Same as standard find and replace editing functions Replace Bookmark the line at cursor position bookmark the line at cursor position jump to next bookmark from cursor position toward the end of file jump to next bookmark from cursor position toward the beginning of file clear all bookmarks Clear all bookmarks or assign an index value 0 9 to the bookmarks in order to easily access jump them using the Go to Index Bookmarks command below Jump to bookmark with x index value Find function searches for a defined string in the Editor window Method 1 Accessing Edit gt Find from the menu bar Step 1 From menu bar click Edit gt Find Alternatively you can press the shortcut keys CTRL F 42 WicePlus amp Assembly User s Manual B Paste Select All Go to Line Ctrl G Formation Selection Alt FS Find Next Ctrl N fa Find Previous Ctrl P gi Find in Files Replace CtrltH BookMarks 2 Index BookMarks 2 Go To Index BookMarks Step 2 From the resulting dialog enter the string you want to find and its parameters Find x Fi
128. og to create a new C project Now target MCU and the project name we create appear in Project window Fig 8 5 M78P468N test cpj Fig 8 5 MCU and project name in Project window 146 WicePlus C amp Assembly User s Manual Supplement Create New File Projects Micro Controller Project EM78P259N ICE259 f EM78P311N CE809N EM78P312N ICE809N Location EM78P330N ICE330N EM78P3231N ICE230N D WicePlus TestCodet K EM78P342N ICE341N EM78P346N ICE345N Project Type EMT8P349 ICE349 EMT8P418N ICE418N Assemble EM78P4478 1CE447 EMT8P450 ICE450 TCC1 Tiny C dn ver 1 may EM78P451 ICE451 not RE EM78P510N Please PaK 78 452 1 452 A the ICC2 box a quit and enter 78 458 1 458 i 78 459 1 458 EM78P468N ICE468 TCC2 Tiny C Compiler ver 2 This dialog will show some information about C Compiler in the red line circle The information tells us now C Compiler is in Tiny C Compiler ver 1 and TCC1 doesn t support this IC such as EM78P510N Follow the information and check TCC2 check box C Compiler will switch to TCC2 Tiny C Compiler ver 2 Quit the dialog by clicking Cancel button then re enter the dialog WicePlus will scan TCC2 support the selected IC or not If support user can create a TCC2 project Create a New File Projects Micro Controller Project Name EM78P259N ICE259 a EM78P311N CE808N EM78P312N I
129. om the Output window as shown below In C mode rebuild All will generate objective o file assembly s file and binary cds fils CONTIEF Bl E Source Files 810 04 RO A V 10 04 Rit FF RUTCC RI2 D4 000 Pei Pe EG Rid 000 000 BO E Header Fies RI 0 RS 80 R600 8600 C6 FF C6 Ot R17 00 RT ED R740 870 C7 FF C7 OL R18 00 R3 BC Re OD RE OO CB FF C8 0 RIS 88 35 00 xS 00 8900 CO FF CO OL RIA 00 RA 18 RAFF RA OO Cao RIE 00 00 RB RBM RB CB FF CB OC RIC 00 RC 00 RCD CC FF cc t RID A6 00 RD DC RD D cD t RIE 00 ES RE D CE 00 n Name Address Type Value ST eS 8 P E F BUE FF 00 94 04 Ei 04 00 OO ee 00 EK 18 00 56 06 FE EC Ob 007 39 00 9 08 EF 25 10 19 96 30 96 Bi 53 84 D 3B EE DM sa Sp Dd Mi Em Er E LEE ee RE BER RE EE RE ER EE EE RE UE EE Fig 3 13 Output Window Showing Successful Compilation If error is detected during compilation pertinent error message will also display in the Output window with Build tag Double click on the error message to link to the sou
130. ooe myBit4 is at 0x05 bit 6 of 1 RAM Bank 0 1 2 3 4 5 1_2 1_3 myBit5 is at 0x22 71654312110 Pit 3 of RAM bank 1 7 5 Data LCD RAM Indirect Addressing indir variable name gt lt address gt ind ind number gt Declare the variable at which indirect data RAM or LCD ram is located The ind number has to be indicated if address is assigned WicePlus C amp Assembly User s Manual e 127 Gm If the MCU has Data RAM use ind 0 indirect RAM 0 If the MCU has an LCD RAM use ind 1 indirect RAM 1 Example indir int nDatal default is ind 0 so nDatal is at Data Ram indir int nData2 0x30 ind 0 nData2 is at Data Ram because using ind 0 indir int nData3 0 01 ind 1 nData3 is at LCD Ram because using ind 1 Data RAM LCD RAM 50 51 S2 3 54 55 x myData3 0x00 CO C1 C2 C3 C4 C5 C6 C7 0x30 7 6 Allocating C Function to Program ROM 128 e return value function name gt lt parameter list gt lt address gt page lt page numbers You can place function at the dedicated address of the program ROM and use page instruction to allocate which page in the program ROM you wish to assign WicePlus C amp Assembly User s Manual Example void myFunl int x int y 0x33 myFunl is put at 0x33 at ROM page 0 default page void myFun2
131. outine is the action to be taken for Interrupt 132 e WicePlus C amp Assembly User s Manual 7 10 1 Interrupt Save Procedure void intcall function name l void lt interrupt vector address gt low int interrupt vector number gt It should be noted that I for low level interrupt must be added after function name 7 10 2 Interrupt Service Routine void intcall function name void int interrupt vector number The interrupt vector number means that if there are many interrupt vectors in the the sequence 0 1 2 3 is provided to separate each interrupt vectors The compiler will automatically combine the saved procedure and the service routine in the interrupt vector number That is MCU will jump from interrupt save procedure to interrupt service procedure 7 10 3 Reserved Common Registers Operation Sixteen common registers 0x10 0x 1f are reserved for certain operation When an interrupt occurs it is strongly recommended that users to backup some common registers After Compiling WicePlus will tell users which registers have to backup from information window Output window In the picture below users can see there are five C characters in the line of 0x10 These positions are 0x10 0 11 0x12 0x13 0x14 So users have to save these 5 WicePlus C amp Assembly User s Manual e 133 134 common registers restore them in interrupt service routin
132. peed and decrease for faster speed Usually the value is bigger and the stability is better Check ICE Memory You may also enable this check box to check the condition of the ICE memory Long Delay Time When you are unable to connect your computer to ICE enable the Long Delay Time check box see figure above This will allow a longer handshaking time between your computer and ICE Click OK button when done Reconnection If a new hardware replaces the current one it is necessary to reconnect it with PC Please choose Connect from the Option main menu for reconnection Fig 3 1 would be popped out again It takes longer waiting time to communicate between PC and the hardware if the reconnection is done again and again under the same hardware environment Note With the Long Delay Time option enabled WicePlus handshaking mode with ICE reverts to previous version of WicePlus 1 v2 0 or versions released before July 16 2007 WicePlus C amp Assembly User s Manual 3 2 2 ERC 55 acts P55 IRC P55 08CO arts P55 Code Option Dialog MCIRC act P55 LXT Low Crystal ENWDTB Enable CLES 2clocks CYES lcycle ORKE O O o o ERC P55 OSCO acts OSCO IRC P55 08CO acts OSCO MCIRC act OSCO HXT High Crystal Disable 4clocks Zcycle using ICE self Target Power 3 3 Create a New Project WicePlus C amp Assembly User s Manual 81 Em Fig 3 2 WicePlu
133. pound Assignment Operators X y lt lt lt lt y lt lt X gt gt y gt gt x gt gt amp amp X amp y x y ylx yl x 116 WicePlus amp Assembly User s Manual 6 11 Priority Same Level Operators from Left To Right Highest gt unary type cast indirection amp address sizeof ios lt lt gt gt lt lt gt gt amp A amp amp 2 gt gt lt lt amp Lowest 6 10 2 Prefix of Operators If else Statement if expression statement else statement statement executes the block of codes associated with it when the evaluated condition is true It is optional to have an else block which will be executed when the evaluated condition is false Example if flag 1 timeout 1 flag 0 lse timeout 0 6 12 Switch Statement switch expression case const expr statements case const expr statements default statements WicePlus C amp Assembly User s Manual 4117 Switch statement is flexible to be set with multiple branches depending single evaluated value Example switch case 0 function0 break case 1 functionl break case 2 func
134. pt service coding scatter on corresponding in one function and using subroutine global varible Int VecIdx occupied 0 10 to know interrupt source So we suggest users not to use 0 10 Size 255 Constant array Max 2 Max 4 number in a program page 78 510 unavailable Available eKTP8733N unavailable Available EM78P220N unavailable Available EM78P210N unavailable Available TBRD instruction unavailable available Please reference to 7 11 Depend on IC feature Some IC just can contain one Please reference to IC s spec If you have any problems please contact myjian 9 emc com tw We will help you to solve your problems as soon as possible WicePlus C amp Assembly User s Manual Table of Contents Chapter 1 Introduction 10 MEER 0 10 1 2 System 10 1521 Host Computer oou ass a 10 1 5 Software u a fU bee ia mM 11 IE ANSI anqana au kasi usadas 11 Chapter 2 WicePlus Interface 12 12 2 2 WicePl s S b WiINdOWS s uu manaa 13 2 2 1 Project WIDUDW 13 2 2 2 Ue Bditot
135. r respective COM SEG values An automatic and faster way of re defining and setting of COM SEG values is explained in the next topic 7 After all segment values are set click Done the original Set Mapping button Then run the program to test the settings e g set some breakpoints and execute GO or use the Continue step into View the results and check for error E GG c c Am G cD The Step 6 above shows how to manually define and change the 5 values for each segment This method is okay if there are only a few segments involved However if a large number of segments are involved the task becomes complicated and time consuming The following steps explain a more efficient way of defining a large number of segment values WicePlus C amp Assembly User s Manual 1 From the Control Pane define the SEG Range as 0 1 and the COM Range as SEG Range 0 1 0 3 Consequently the segment values will be set according to these defined COM Range 0 3 ranges 2 Define COM SEG values to 0 and Auto 0 m SEG 0 Increase value to 1 Swap A Increase 1 3 Point to the segment where the 5 value 0 0 1 to be applied gt Click and you should see the segment set as 0 0 4 Observe that as soon as 0 0 value is 0 SEG entered on the segment the Contro
136. rce of error text line in the corresponding source file displayed in the Editor window If the corresponding source file is not currently opened it will open automatically Z Assembling Double click to p test2 569 test dt 2 error 033 macro is not defined or invalid instruction link to the source of error 1 0 Warningis 0 User s Fig 3 14 Output Window Showing Compilation Errors Modify source files to correct the errors and repeat assembling and linking operations In C mode there are many useful messages reported in Information sheet Output Window if compiling succeeds For example it tells users used rom size available rom size used ram data in figure used data register in figure IO control data in figure call depth and max call depth The most important message is the char in register data located 0 10 0x1F These C chars tell WicePlus C amp Assembly User s Manual e 87 programmer which and how many common registers to save and restore in interrupt service routine Please reference to sec 7 5 for the detail Fig 3 14a shows these messages So we can know that we have to save common register 0x10 and 0x11 when MCU just runs into interrupt service for C system and restore these two common registers before leaving interrupt Service Total Rom Size 24576 Used Rom Size 00221 0 Available Rom Size 24355 100 iind Data Map 0x10
137. rm these common registers value are the same before running into interrupt save procedure and leaving interrupt service routine So we have to save and restore these common registers correctly C compiler will tell us after compiling succeed Please see Sec 8 5 In the file frame we suppose 0 10 0 14 common registers have to save and restore Please remark these two backup C system and restore C system inline assembler code if need If C compiler tell us more common registers over 10 0 14 have to save and restore just add code like MOV A 0x15 and MOV 0 37 1 A after backup 0x14 in backup C system inline assembler and MOV A 0x37 1 and MOV 0x15 A after restore Ox 14 in restore C system inline assembler Users write interrupt service code between backup C system and restore C system such as Write your code inline assembly or C here in the case WicePlus C amp Assembly User s Manual 001 void main 001 poid main 002 002 003 003 004 004 005 005 006 void intcall tcc l void 0x03 1ow int 0 006 void 11 tcc l void 0 03 1 int 0 007 008 asm 008 asm 009 EM 010 eoxo 010 PAGE 0X0 O11 o 012 m 013 void 11 tcc void int 0 013 void _intcall tcc void int 0 014 o 015 backup R4 015 R4 015 aem 016 asm 017 d Un 018 SWAPA 0x04 SWARA 0204 019 MOV Dx1F A 019 MOV 1 020 020 021 021 022 ZZbackup
138. roject Save Project Close Project amp Print Print Preview Print Setup Recent Projects Exit Fig 2 11 2 File Menu WicePlus C amp Assembly User s Manual File Menu Fig 2 11 1 Menu Bar New Open Close Save Save As Save All Open Save Close Project Print Print Preview Print Setup Recent Files Recent Projects Exit Create a new project or source file Open an existing document or project Close the active document or project Save current active document Save current active document with new filename Save all opened documents Open Save Close the active project Print active file Preview printed format of active file Define printer settings View the record of the recently used file View the record of the recently used project Exit from WicePlus Program e 41 2 3 2 Edit Menu Select All Ctri A Go to Line Ctrl G Formation Selection Alt F8 d Find Ctrl F Find Next Ctrl N Find Previous Ctrl P gi Find in Files Replace Ctrl H BookMarks Index BookMarks Go To Index BaokMarks 2 2 12 Edit Menu Bookmarks Toggle Previous Next Clear All Index Bookmarks Go to Index Bookmarks Supplement Undo Cancel the last editing action Redo Cut Copy Paste Repeat the last editing action Same as standard function clipboard Select ALL Select all contents of the active window G
139. roject name can be saved in WICE The maximum number of editor window is 10 e Auto Dump Over 64K Only for EM78815 If chosen dump all program code to the hardware f External Code checking Only for EM78815 If chosen to check the action of dumping program or data to external rom g Show Trace Log Under 64K Only for EM78815 If chosen to refer inside 64K program code only when the function of Go Free or Go To Cursor in the debug menu is executed The maximum length of trace log is 8K words WicePlus C amp Assembly User s Manual e 69 e Customize The Customize dialog displays with four tabs as shown below Customize x Commands Toolbars Keyboard Options Categories Commands 5 Open Close Save 5 Save Manon ha Save An Description The following describes the function of each tab a Commands tab Select this tab to display all available commands under a selected category Then drag and drop a command into toolbars menu bar or into a drop down command menu from menu bar To restore default settings go to Toolbar tab and click Reset All CT 0x Commands Toolbars Keyboard Options Toolbars Reset Reset All Show text labels Close The Toolbars tab allows you to enable disable the Build and Standard toolbars but not the Menu Bar You can however Reset Reset All all toolbars to restore the default settings of
140. rward step by step from the last executed address to the address which trace back ever went through Page Bank Block Cancel Fig 2 15b Add label to watch Initial with 8k step log CurrentPC with 8k step log Initial with 4k 4k step log Fig 2 15c The sub function of Run from 50 WicePlus amp Assembly User s Manual a Initial with 8 Step log keep running program started from the initial address until breakpoints are hit The last 8K steps of execution history stored in the trace buffer b Current PC with SK Step log To keep running program started from current program counter until breakpoints are hit The last 8K steps of execution history are stored in the trace buffer the Initial with 4K 4K log To keep running program started from the initial address until breakpoints are hit last 8 steps of execution history that the breakpoint address should be middle are stored in the trace buffer d Current PC with 4K 4K log To keep running program started from the current program counter until breakpoints are hit The last 8K steps of execution history that the breakpoint address should be middle are stored in the trace buffer Address breakpoint not active C Breakpoint group C Breakpoint or Breakpoint nest a 0 09 0 1 0x11 0X20 0x01 0x11 0X1 0X12 0x1 0X13 0X1 0x11 0X41 0X20 0 1 0x11 0 1 0 20 0x1 Del
141. s Manual E Appendix E The IC option comparative table 181 Doc Version User s Manual Revision History Revision Description Date 1 0 User s Guide initial version 2007 01 03 1 1 Add new Dialog View setting Dialog to see section 2 3 7c Add Chinese Code Converter to see section 2 7 Add How to define label to see section 4 2 2007 02 01 Add USB ICE points for attention to see section 1 3 2 3 7 b 3 2 Add Find dialog of output window to see section 2 2 8 Add New Debug Menu Address Break Point to see 2 3 5 4 Add New item of View setting Dialog to see section 2 3 7c 1 2 3 1 2 3 2007 04 06 1 Add Step Out to see 2 3 5 2 4 3 8 2 Add sub window of Program ROM at Output Window to see 2 2 8 2007 05 08 1 4 New Menu 2007 05 31 2 0 Combine C and Assembly user manual 2007 06 05 2 1 Add To Grip Tiny C compiler quickly 2007 06 08 2 2 1 Add Label Function View to see section 2 2 1 2 Add Customize to see section 2 3 7e 2007 07 03 1 Users can declare variable in common registers 0x10 0x1F Please reference sec 7 1 2 Users can declare bit data type in local field Please reference sec 7 4 2007 07 12 1 stack View to see section 2 2 4 2 Add Formation Selection Only support C Mode to see section 2 3 2 3 Add Debug Opt
142. s Program Code Dialog The Code Option dialog is displayed next Check all items to confirm the actual status of the ICE and make appropriate changes as required Then click OK button Users have to study MCU s or ICE spec to select code option correctly otherwise it can t connect with ICE Users can enlarge or reduce the dialog s size by drag the edge WicePlus uses new code option dialog not only USB mode but printer port mode also in version 2 6 or later Note Not all of MCU have to set connect code option 3 2 3 Accelerate Reading Registers Dialog If you use USB ICE this dialog will pop up after setting code option Please ay Project refer to 2 3 7 b gt Open Close To create a new project you need to configure your project with the following steps 1 From the Menu bar click on File or Project menu and choose New command from the resulting pull down menu Fig 3 3 File Menu Open 2 The New dialog shown below will then display if you have clicked the New command from the File Save menu Otherwise New Project dialog will display s Add Files to Project Fig 3 5 if the New command is derived from Project menu S assemble Alt F7 Rebuild All Alt F9 Dump to ICE F3 Trace Log F2 Delete files from project Dump code over 64K to sram Project Name D es EM78P156N ICE456E Location I SN eM D WicePlus TestCode EM78P163N ICE163N
143. s count decreases to zero b How to set quick breakpoints Step1 Edit a general pass count From the Option main menu choose Debug option setting The dialog box of setting debug option appears Users can type a number from 1 to 255 as a pass count The default value is 1 Step2 Set breakpoints The first way is to move mouse cursor to a line where a breakpoint is going to be set and then double click by the right button To set breakpoint is completed as the background color of the clicked line turns into brown The other way is to move caret to a line and press the toggle breakpoint icon hand shape on the toolbar or choose Toggle Breakpoint from the Debug menu c How to set user defined breakpoints Step1 Set the contents of the pass count to 0 From the Option main menu choose Debug option setting The dialog box of setting debug option appears Users must reset the pass count to Zero WicePlus C amp Assembly User s Manual e 105 Step2 Set breakpoint Users can move mouse cursor to a line where a breakpoint is going to be set and then double click by the right button User should enter a suitable number for the pass count as the dialog box of set breakpoint counter appears To set breakpoint is completed as the background color of the clicked line turn to brown 5 2 To debug a project The contents of program counter registers and RAMS are read and displayed each time as program s
144. se unused editor windows or unexecuted application programs in system error M015 Over 250 characters of a line Reason The maximum number of characters is 250 at a line in editor Solution To divide a line into two or more error M016 The extension name of the active file filename is not dt or asm Reason In this action the extension name of the active file must be or ASM Solution To change the active file to another file with the extension name DT or ASM error M017 No file to be assembled Reason Can not find a file to be assembled Solution To select a file to be assembled error M018 Project file must be created Reason No project is available Solution To open or create a project error M019 The editor number is over the max editor number Reason The numbers of editors are limited Solution To close some of unused editor windows Error M020 No active editor window Reason The editor window is not selected now Solution To choose editor window Error M021 Text field must be input by characters Reason The text field can t be empty Solution To input character Class A assembler errors error A001 Can not find the filename file Reason The file can not be found in the directory WicePlus C amp Assembly User s Manual 0 Solution To check whether the file exists or not in the directory error A002 Main and subroutine progr
145. shown in Figure 2 5 2 This may also affect higher level sub routines as shown in Figure 2 5 3 v sackdt EF E C3 EM78808 STETR APJ EE Source Files 119 120 sub_28 8 stackat S Header Files call sub_29 ER 122 nop E List Files 123 ret B klst ea ns 124 eub 29 cp 125 call sub 30 Sy Library Files 126 nop 127 ret 8 FilView 128 sub_30 129 11 sub_31 130 131 132 sub 31 13 133 no Fig 2 5 1 All stack levels indicated the breakpoint setting 24 WicePlus amp Assembly User s Manual 120 sub 28 121 call sub 29 78808 5 i 122 nop T c pee 123 ret Header Files 124 sub 29 List Files 125 call sub 30 8 126 nop Map Files 127 ret amp Library Files 128 sub_30 129 call sub 31 130 mr rs 132 sub_31 133 nop 134 ret Fig 2 5 2 Return to the preceding stack level but note that the last next stack level still shows 0x0003 the value of the last stack level when all stack were full 111 ret 112 sub 26 113 E3 78808 5 Sy Source Files call sub 27 8 ei no E Header Files 115 PERDIET o List Files 116 sub_27 8 stack Ist 117 call sub_28 E Map Files re 120 sub 28 121 call sub 29 122 nop 123 ret Cay 124 sub_29 Level Address
146. single segment WicePlus C amp Assembly User s Manual 2 2 9 Output Window Fig 2 10 Output Window The Output window displays messages indicating the results including errors of the project compiling just performed such as assembler linker trace log history and debugging The window consists of four tab sub windows namely Build Information Find in Files Message and Program Rom where Build displays assembler linker related messages and trace logs Double click on the error message to link to the corresponding program text line where the source of error occurs The pertinent source file is automatically opened in the Editor window if it is not currently active Information displays debugging related ROM and RAM Bank memory usage information Find in Files allows you to find identical string selected from an active file in other active or inactive files in your folder Lines containing the identical string will display on the Output window complete with its source filename and directory Message displays the debugging related changes to the LCD RAM window Program Rom displays the content of program ROM after dump WicePlus C amp Assembly User s Manual 939 00030 055 00031 0550 00032 0551 00033 0552 00034 0553 00035 0554 0555 Save All Information Find in Files Message 30 INC OX1F D m DEI 6 NBI F10N 569x569 DT 52 30 INC 0x10 D
147. sitions of all values from db COM SEG to SEG COM on the set 02 segments Compare the figure at right to an in the one in 7 above and see the difference 3 After setting all the relative values to affected segments it is recommended you click Save File button to save the LCD Simulator Data File LCD Save File Otherwise when you want to use the program the next time you will need to define and set the values again 4 Since the LCD Simulator Data File already includes the imported graphic files you do not have to clock the Import Graphics button the next time Load File you want to use the saved LCD file Just click Load File button to load the data file 5 The program determines which black pixels are linked together to establish a segment However when 2 or more separate segments constitute non separable object or character e g i J integral segments should be assigned with the same COM SEG value Otherwise the program will assume that there are 2 or more separate segments agn 6 As stated above the program determines which black pixels are linked together to establish a segment However when 2 or more segments which are ought to be separate and set with different COM SEG values are somehow joint together at one point such graphic file should be modified to break up their link Otherwise the program will wrongly assumed that there is only one
148. system 022 ZZbackup system 023 asm 023 _asm 024 E 028 1 025 BANK 0X3 025 BANK 0X3 026 MOV 0 10 Depend on WicePlus repor 026 0 10 ZZDepend on WicePlus repor 027 MOV OX3C 1 A 027 OX3C 1 A 028 MOV A OX11 028 MOV 0 11 029 MOV OX3B 1 A 029 MOV OX3B 1 A 030 MOV 0 12 030 MOV 0 12 031 MOV 0 1 031 MOV 1 032 A 0X13 032 MOV A 0X13 033 MOV 0 39 1 033 MOV 0X39 1 A 034 MOV 0 14 034 MOV 0 14 035 MOV DX38 1 A 035 MOV 0 38 1 036 MOV A OX15 026 gt 037 MOV 0 37 1 038 x 038 y 039 040 040 Write your code inline assembly or C here 041 041 042 ZZ Write your code inline assembly or C here 042 restore C system 043 043 asm 044 C system 044 045 _asm 045 BANK 0X3 046 046 MOV 0 3 1 Depend on WicePlus repor 047 BANK 0X3 047 MOV 0 10 048 MOV 0 3 1 ZZDepend on WicePlus repor 048 MOV A 0X3B 1 049 MOV 0 10 049 MOV OX11 A 050 MOV A 0X3B 1 050 1 051 0 11 051 0 12 052 A 0X3A 1 052 0 39 1 053 0 12 053 MOV 0 13 054 MOV 0 39 1 054 MOV 0 38 1 055 0 13 055 0 14 056 MOV 0 38 1 056 057 0 14 057 058 0 37 1 058 059 MOV OX15 A 059 restore R4 060 060 _asm 061 061 062 062 SWAPA Ox1F 063 restore R4 063 MOV 0 04 064 asm 064 065 066 SWAPA Ox1F 067
149. ta from binary file to external SRAM You have to do this when you just connect ICE and do not reset F6 or not debug your program yet If you forget to do it what moving data from file to SRAM will fail We mean the user have to initialize the environment of ICE and Wice before moving binary data into external SRAM 2 Press Move data from file to SRAM in Tool menu 3 Select the binary file you want to operate and set the data begin address and length WicePlus C amp Assembly User s Manual e 61 SRAM FLASH Data Begin Address 131072 Length 131072 External Code Size Checking after dumping Binary file name DAWiceTest 81 5 Fang2 Big5 bin Note 1 unit of Begin Address and Length is byte 2 The Data Begin Address is reference to 0x0 of external memory cen Fig 2 16c Move data from file to sram Please read the notes before setting the Data Begin Address and Length After type the correct number and select the binary file press OK button to move your data You can check Checking after dumping box to verify data after finishing the process If it meets one of the bytes is error it will stop verifying External Code Size Edit will tell you how many bytes your program code over 64K word is So let your Data Begin Address bigger than External Code Size The maximum of the Data Begin Address is 524 288 512K byte and the Length 262 144 256K byte So if the data you want to move from binary file
150. tail about interrupt in sec 7 10 1 and 7 11 TCC2 Interrupt program 15 very easy to develop in TCC2 We suggest users use TCC2 instead of TCC1 01 void main 03 asm MOV A 0x10 CONTW 06 08 void _intcall interrupt void int 11 Write your code inline assembly or C here 13 14 15 void 11 interrupt l void 0 08 1 int 0 16 t 17 _asm PAGE 0 0 18 Please remember that C compiler Just accept one main function in a project If users want to add other new files after the first main file was add users can check Empty File to add a empty file 2 Please don t write code over column 512 especially in C mode or serious error will happen The limit in previous version is about column 256 3 4 2 Add Existing Source Files to the New Project If your source file is ready you can immediately insert it into your new project 1 From the Menu bar click on Project menu Choose Add Files to Project command from the resulting pull down menu and then the Open dialog is displayed duin RISE S Save BE 2 569 bp Close 569 new rmk dt 2 _ 8569 xmk t Add Files to Project Delete files frorn project e Assemble Alt F7 SRD Source Files dt asm Y J Rebuild All Alt F9 Dump to ICE F3 Trace Log F2 Dump code over 64K to sram Fig 3 8a Files to Project Fig 3 86 Open
151. temp abc 0x23 def 0x39 P6CR 0x80 P6PH 0x80 WDTCR 0x00 ZZ wdt disal temp PORT6 read por WUCR x d IMR 0x80 SLEP 030 031 092 152 ctest2 Fig 8 9 Write initial code z l 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 225 void _intcall counterl l void 0x0C low_int 3 asm PAGE 0 0 void _intcall counterl void int 3 hackup R4 _asm SWAPA 0 04 MOV Ox1F A nackup C system asm 1 BANK 0X3 MOV 0 10 MOV OX3C 1 A MOV 0 11 MOV OX3B 1 A MOV 0 12 MOV 1 MOV A 0X13 MOV 0 39 1 MOV 0 14 MOV 0 38 1 ZZ Write your code ISR amp Oxf7 gt RS7 R57 system restore 1 BANK 0X3 MOV A OX3C 1 MOV OX10 A MOV A OX3B 1 MOV 0 11 MOV A OX3A 1 MOV 0 12 MOV 0 39 1 MOV 0 13 MOV A OX36 1 MOV 0 14 ZZrestore R4 asm SWAPA Ox1F 0 04 1 ZZDepend WicePlus assembly here Depend on WicePlus repor Fig 8 10 Write interrupt service code in counter 1 interrupt right WicePlus C amp Assembly User
152. tents of a header file into the source program Example 1 include lt EM78 h finclude project h WicePlus C amp Assembly User s Manual include ad c may meet errors Example 2 unsigned int uaa include headfile h in include kkdr h in include pprr h in main in uaa 0x21 testl1 test2 test1 include pprr h extern unsigned int uaa void testl uaa 0x38 test2 uaa 0x43 extern unsigned int uaa void test2 uaa 0x29 6 3 2 H define in headfile h testcode c fi testcode c fi testcode c fi testcode c fi in kkdr h file kkdr c fil in kkdr c fil in kkdr c fil in pprr h fil in pprr c fil in pprr c fil 0 00 define identifier define identifier token list define identifier parameter list token list define identifier token list The define directive is used to define a string constant which will be substituted into source code by the preprocessor It makes the source program more legible 109 WicePlus C amp Assembly User s Manual 110 Example define MAXVAUE 10 define sqr2 y x x y y 6 3 3 if else elif endif if constant_expression else elif constant_expression endif The fif directive is used for conditional compilation It should be termin
153. tion2 break default funerror 6 13 While Statement while expression statement While statement will check the expression first if the expression is true it will then execute the statement Example while value 0 value count 6 14 Do while Statement 118 statement while expression Do while will first execute the statement and then check the expression If the expression remains true then it proceeds to the statement until the expression becomes FALSE Example WicePlus C amp Assembly User s Manual do value GO unt while value 0 6 15 For Statement for expr1 expr2 expr3 statement For statement is equivalent to the following statement 1 while expr2 I statement expr3 is executed first Normally 1 will be the initial condition While statement is executed in the same manner Example for i 0 i lt 10 1 value value i 6 16 Break and Continue Statements break continue The break statement exits from the innermost loop or switch block The continue statement on the other hand will skip the remaining part of the loop and jump to the next iteration of the loop Continue is useful in loop statements but it cannot be used in switch loops Example break exampl see switc
154. tly right click the selected register value from Editor window Step 1 Right click a register value or variable from the Editor window From the resulting pop up menu click Add To Watch command 28 WicePlus C amp Assembly User s Manual Ox20 rbank 0 x3F rbank 0 OxlO rpage 0 Ox6 iopage 0 05 1 06 Cut Shift Delete 5207 Copy Ctrl C 08 a Oacte ion n Add to Token pool 1 2 851 Pc suon 13 Next Position 14 15 BookMarks 2 Index BookMarks 18 Go Index BookMarks gt 18 If the selected value contains register page or ram bank or control register page as shown in the above example figure the register values is directly displayed in the Watch window see Section 2 2 2 Editor Window gt Add to Watch If it does not contain register page ram bank control register page see example below the Watch Dialog will display instead 01 aa Ox20 rhank 0 02 bb Dz3F rbank 0 03 0 10 0 04 dd Ox6 iopage 0 05 0 6 Step 2 From the Label Name box of Watch Dialog window select and double click a variable label name you wish to assign Then from the Label Types options select the variable type to be displayed i e Special Register Control Register or RAM Bank WicePlus C amp Assembly User s Manual e 29 Select or cancel the label by double click Label Types Special Register RO R1F
155. to sram Start Page is over 64 End Page is under 127 cone orar Start Page 64 Page 127 Fig 2 14b Dump code over 64K to sram 48 WicePlus amp Assembly User s Manual 2 3 5 Debug Menu Go FS Free Run F10 Reset F6 Step Into F7 P Step Over F8 Step Out Ctrl F7 Go To Cursor F4 Continue step into Shift F7 Run from Selected Line 2 Stop Debug Add Label to Watch Reset and Free Run Reset and Ga Run From gt 4 Toggle Breakpoint F9 Show All Breakpoints Ctrl Alt F9 di Clear All Breakpoints Ctrl F9 Address Break Point Alt 4 Clear All Address Break Point Ctrl Alt 4 lt a Trace Back Ctrl I Trace Forth Fig 2 15a Debug Menu Go to Cursor Continue step into Run from Selected Line Stop Debug Add Label to Watch Reset and Free Run Reset and Go Run From Toggle Breakpoint WicePlus C amp Assembly User s Manual Go Run program starting from the current program counter until a breakpoint is matched Free Run Run program starting from the current program counter until the OK button of the Stop Running dialog is clicked Reset Perform ICE reset register contents are displayed with initial values Step Into Execute instructions step by step with register contents updated simultaneously Step Over Execute instructions as Step Into see above but the CALL instruction will execute as
156. topped They provide programmers very important information during debugging program There are several useful functions as shown below in the Debug menu The function keys or hot keys are shown in the parentheses a b roan 106 o Go 5 Program runs from current program counter until breakpoint is satisfied and the breakpoint address is executed Free Run F10 Program runs from current program counter until the execution is stopped Meanwhile all defined breakpoints are ignored during running Reset F6 To reset ICE to the initial conditions Step Into F7 Single step execution Step Over F8 Single step execution and the subroutine skipped Step Out Ctrl F7 Program runs from current program counter until exit subroutine Go To Cursor F4 Executing from current PC to the location where the cursor is anchored WicePlus C amp Assembly User s Manual Chapter 6 C Fundamental Elements 6 1 Comments For a single line comment All data in the line after the comment symbol twin slash mark will be ignored For Multi line comments All data in the line located within the comment symbols slash mark asterisk will be ignored Comments are used to help you understand the program code It can be placed anywhere in the source program The compiler will ignore the comment part from the source code thus no extra memory is required in the pro
157. truction clock gt 2 MIPS Disable instruction clock lt 2 MIPS Fig 2 17c Accelerate Reading Registers When you use USB ICE and the frequency is over 2 MHz you can enable this capability But it is not 100 stable If you see some abnormal appearances try to disable this option Note If you choose IRC when you set the code option WicePlus may enable this option automatically according to the chosen frequency 66 WicePlus amp Assembly User s Manual pa c View setting To set WicePlus view variable Revise Window Size Base on Big window size when dock Base on Small window size when dock File Name Project Window C File name with Path File Name Show Line Numbers ON OFF Tab Width 4 Show Ram Bank Inversely Show Data Ram Inversely Add defined label to watch automatically Sort by Name Sort by Address Sort by Type Show Unreferenced variable Show defined label in Register Window Show Program Rom 1 Cancel Fig 2 17d WicePlus environment WicePlus C amp Assembly User s Manual g EM78569 test apj Soure Files 569 01 SN Header Files Sy List Files 569 Ist Map Files 3 Library Files a File name a zFF 0x20 a 0 20 b Column ala 0 RegisterRS Ox05 rpage 1 02 org 0x0 03 04 sl 5205 06 mov 07 mo
158. ual Error s Warning s R10 R10 R11 R11 inc org jmp org sl clr clr 52 inc mov mov mov mov inc User Message s 0 10 0 10 0 11 0 11 lude 44 xfff sl 0x00 0x11 0x12 0x11 0 55 a 0x55 a 0x55 a 0x55 a 0x55 0x12 jmp s2 rpage rpage rpage rpage 7test 45 46 o 2 3 3 View Menu I3 Project Project v Special Register 4 v General Registers Bank Special Registers v CallStack Data v Data Ram General Registers v LCD Data Bank TA Output v Watch CallStack Data Toolbars gt Data RAM v Status Bar v Document Bar Fig 2 13 View Menu LCD Data Output iim Show hide Project window Show hide Special Register window Show hide General Register Bank window Show hide CallStack window Show hide Data RAM window if supported by the target chip Show hide LCD Data window if supported by the target chip Show hide Output window Watch Show hide Watch window Assembly Code Only C Compiler use Show hide Assembly Code in from Editor window After first dump to ICE F3 press this button then assembly code will display with C source Toolbars Show hide Standard Build or both toolbars Status Bar Show hide Status bar Document Bar Show hide Document bar WicePlus C amp Assembly User s Manual 2 3 4 Project Menu New New Open Project Save Project pen Close Project Save Add F
159. uct 1 When the pass count is equal to 0 then a breakpoint is occurred of groups are independent of each other c Breakpoint Nest Assign some address location as groups and specify those groups as a nest of breakpoint The outer the later specified group must be first satisfied then the inner group will take effect Breakpoint nest and breakpoints of program line are exclusive In other words breakpoint nest is active then breakpoints of program line are inactive On the contrary if breakpoint nest is inactive then breakpoints of program line are active How to set breakpoint nest Step 1 Check the checkbox of Breakpoint nest Step 2 Input breakpoint address If address breakpoint is for 0x10 0x20 0x30 0x55 0x15 0x100 0x170 0x10 address location 0x10 0x20 0x30 are assigned to the same group Group 1 a breakpoint is attached to this group the associated pass count of this breakpoint is 0x55 Address location 0x15 0 100 0x170 are assigned to another group Group 2 a breakpoint is attached to this group the associated pass count of this breakpoint is 0x10 Step 3 Press OK button Step 4 To execute F5 comment Step 5 If the Group 2 must be satisfied pass count decrements to 0 then the Group 1 will take effect decrease its pass count on meeting the breakpoint condition As soon as all the groups are satisfied the execution is stopped at the breakpoint Supplement Supplementary in
160. ultiplication Division Zo Modulo Logical shift left gt gt Logical shift right d Addition arithmetic operators Addition Subtraction e Bit AND operator amp Bit AND f Bit and operators Bit OR A Bit XOR 2 Logical AND amp amp Logical AND h Logical OR Logical OR i Comparison equal not equal gt greater than lt less than gt greater than or equal to lt less than or equal to 4 5 Program directives a set value of program counter Syntax ORG expression Example org 0x200 b EQU or Duplicate definition constant value Syntax label EQU expression WicePlus C amp Assembly User s Manual 95 Example 1 20 0 20 Example 2 R20 0 20 Comment Line comment Syntax lt string gt Example this 15 the comment string Block comment Syntax strings Example this is block comment example including multi lines d end of the program ROM page which the EOP instruction belongs to Syntax EOP Example org 0 10 mov 0x20 A inc 0x20 eop inc 0x20 Result after assembling the first column is address org 0x10 0010 mov 0 20 0011 inc 0x20 eop 0400 inc 0x20 e END the end of program The rest of program code after END instruction won t be assembled Syntax END Example org 0 10 mov 0 20 inc 0x20 end mov 0 20 Result after assembling the first column is address
161. upt Service ROUNE a Eaa 133 7 10 3 Reserved Common Registers Operation 133 Interrupt Routine Im 139 7 11 1 Interrupt Save Procedure 140 7 11 2 Interrupt Service 140 7 11 3 Reserved Common Registers Operation 140 Chapter 8 To grip Tiny C Compiler quickly 145 Create anew EOI CL E 145 8 2 Add a New C file to the proJect a 148 8 3 Add a new second file or head file to the project 148 8 4 The main and interrupt save and service frame that WicePlus supplies 150 8 5 Developing your project especially about interrupt 151 Chapter 9 C Compiler debug tips 155 9 1 Speed Up Debug 155 9 2 View corresponding Assembly code in C environment 156 9 3 Watch Defined variable in Register 157 94 Reduce cods size in some 158 Appendix Assembly Error Message 159 A l Class NE main program errors
162. v 08 mov 09 mov 10 mov 11 mov 12 mov 13 mov 14 mov 15 mov 16 mov 17 mov 18 mov 19 mov 20 mov 21 mov 22 jmp 23 52 24 inc O25 inc 26 inc 27 inc 68 s2 0x20 0x21 0x22 0x23 c Tab Size customize tab size a 0 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 2 Dz2B 0 2 0 2 0 2 0 2 t o b pb n n o n n n n o s amp 23 Source Files 8 D est21569569 dt 2 Header Files List Files 8 D Mtest2 569 test Ist X Files X Library Files File name with path d Add defined label to watch automatic Enable after Dump Checked To add definite variables with rpage rbank iopage in Watch Window automatic e Show Unreferenced variable When build assemble code inspects the variable whether to have the use f Show defined label in Register Window Enable after Dump Checked Register s names are label name in Register Window If the label name s length over 6 Register name display front six char and tooltip display complete name Unchecked Register s names are initial name in Register Window g Show program Rom To show the program code at Program Rom a G 0xFF Ox20 a 0 0 0x20 a Column Off 4 CONT R 3F R0 1043 RI2 E7 R2PC 10000 RI3 06 R3 0001 1011 Pavel Pa Rid 9B R4 0001 1100 Ris OE R5 R5 100 R5 00 R5 00 C5 EO 16 38 R6 100 R6
163. vantage of the New dialog by clicking New command from the File menu to create your new source file and use the WicePlus text editor to compose its content 1 Click the File tab of the NEW dialog and select the type of source file you want to create from the EMC Source File list box i e dt default or c for C mode for assembly file for header file Add new file to project Empty F File Name testcode 3 File Location D WicePlus TestCode Fig 3 7 New Dialog Showing Project Tab for Creating New Source File 2 Check Add to Project check box default if you want to automatically add the new file into your project Otherwise clear the check box Assign a filename for the new source file in the File Name box 4 Locate the folder where you want to store the new source file in your disk You may use the Browse icon to find the appropriate folder 5 Click OK button after confirming your inputs You will be prompted to start writing the newly defined source file in the Editor window Note 1 1 C mode we recommend users to check Add new file to project to add the first c file in a new project WicePlus supplies main function and interrupt save procedure and interrupt service routine frame and some very important save and restore code in the file for users do develop project and write code WicePlus C amp Assembly User s Manual e 83 about Interrupt easily We describe the de
164. x3 2 Ex2 status 1 0 3 c zeroflag 2 equ zeroflag ZZ zeroflag 1 equ RXX YY Ex status 2 R3 zeroflag 2 Status 2 2 d zeroflag 3 equ zeroflag1 ZZ zeroflag equ 0xXX YY Ex status 3 0x3 zeroflag 3 Status 3 2 e Add label with rpage rbank iopage range and select Special Register RO R1F from Watch Dialog are the same rbank and select RAM bank from Watch Dialog are the same iopage and select Control Register from Watch Dialog are the same Ex status 3 Ox3 rpage 0 zeroflag 3 status 3 2 status 3 is already defined in rpage 0 temp 0x20 rbank 1 output Ox6 iopage 1 outputbit 2 0 6 2 output is already defined in iopagel Attention 0x3 rpage 0 gt Please don t type space around colon f To get Register or Bit information from label R Duplicate orlabel Ex zeroflag 0x3 2 mov a Zeroflag equal mov a 0x3 mov a zeroflag equal mov a 0 2 Attention This method only display to Watch Window automatic When use this variable must use register which defined by ICE specification to change register or bank page Operation An assembler instruction or directive Directives give the direction to the assembler Examples of instructions WicePlus C amp Assembly User s Manual 993 Example 1 0 20 Example 2 ADD 0 20 Example 3 zeroflag R3 2 status R3 carryflag status 0 org 0 0 jmp start start BC
165. y User s Manual 101 Example org 0x00 bank macro num if num bc 0x04 6 bc 0x04 7 elseif num bs 0 04 6 bc 0x04 7 elseif num bc 0x04 6 bs 0x04 7 elseif num 3 bs 0 04 6 bs 0 04 7 else message error bank num over max number endif endm b IFE If the statement after IFE expression is false then the following instructions are assembled until ELSEIFE or ELSE or ENDIF Syntax IFE lt expression gt lt statements1 gt ELSEIFE lt expression gt lt statements2 gt ELSE lt statements3 gt ENDIF IFDEF If the statement after IFDEF label is defined then the following instructions are assembled until ELSEIFDEF or ELSE or ENDIF Syntax IFDEF label lt statements1 gt ELSEIFDEF lt label gt lt statements2 gt ELSE lt statements3 gt ENDIF Example org 0x00 ice456 equ 456 ifdef ice456 be 0x04 6 be 0x04 7 endif 102 e WicePlus C amp Assembly User s Manual d IFNDEF If the statement after IFNDEF label is not defined then the following instructions are assembled until ELSEIFNDEF or ELSE or ENDIF Syntax IFNDEF label lt statements1 gt ELSEIFNDEF lt label gt lt statements2 gt ELSE lt statements3 gt ENDIF WicePlus C amp Assembly User s Manual e 103 4 7 Reserved word Note a directives operators
Download Pdf Manuals
Related Search
Related Contents
Betriebsanleitung eCrimp (97 43 E) Encore® Biotin Module Operating Instructions Dishwasher G 5670 G 5675 COMBUSTIBLE GAS DETECTOR - General Tools And Instruments Sony DWZ-B70HL Overview OMC UM JED MICROPROCESSORS PTY LTD Air-Conditioners PUHZ George Foreman GFSG80 Kitchen Grill User Manual Copyright © All rights reserved.
Failed to retrieve file