Home

eUIDE user guide v1.1

image

Contents

1. Syntax IFDEF lt label gt lt statements1 gt ELSEIFDEF lt label gt lt statements2 gt ELSE lt statements3 gt ENDIF Example org 0x00 ice456 equ 456 ifdef ice456 bc 0x04 6 be 0x04 7 endif 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 lt label gt lt statements1 gt ELSEIFNDEF lt label gt lt statements2 gt ELSE lt statements3 gt ENDIF EM78 Series IDE User s Guide 6BAssembler and Linker e 87 Chapter 4 4 7 Reserved Word 4 7 1 Directives Operators i lt lt gt gt amp amp amp lt lt gt gt DS ELSE ELSEIF ELSEIFDEF ELSEIFE ELSEIFNDEF END ENDIF ENDM ENDMOD ENDP EQU EXTERN IF IFE IFDEF IFNDEF INCLUDE MACRO MACEXIT MODULE NOP PAGE ORG PROC PUBLIC 4 7 2 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 LUMP MOV NOP OR RET RETI RETL RLC RLCA RRC RRCA SLEP SUB SWAP TBL WDTC XOR LCALL LPAGE PAGE BANK 88 e 6BAssembler and Linker EM78 Series IDE User s Guide gaci Chapter 4 4 8 Pseudo instruction The following pseudo instructions are supported for MCUs
2. The eUIDE offers a lot of friendly functions including block comment auto updated registers and real time line disassembler It is made up of four main modules namely the Editor Project Manager Assembler and Debugger with each module having their respective submenus E Editor provides editing functions for creating viewing and modifying the source files It supports Find Replace Undo Redo and Cut Copy Paste E Project Manager provides functions for inserting files into a projects deleting files from a projects and compiling of the project E Assembler support such functions as Include Macro Assembly Arithmetic Conditional Assembly List Files and Map File E Source Level Debugger provides source level debugging function on the target which is embedded on the UICE You can explore and analyze the status register and the memory contents of the EM78 series target with the eUIDE With its powerful features like multiple breakpoints real time modification of register contents and disassembly the UICE becomes an indispensable partner of eUIDE in offering a perfect development environment for EM78 Series microcontrollers EM78 Series IDE User s Guide Introduction e 1 Chapter 1 Menu Bar Toobar Document Bar Call Stack Window Document Bar Data RAM Window RAM Bank Window Output Window Status Bar 2 e Introduction E l Build A Information 4 Fead in Filles h 1 2 1 The eUIDE
3. b Interrupt disabled after break Interrupt is disabled when a breakpoint is encountered Itis used to avoid any interrupt from occurring when screen 1s updating as TCC2 COUNTERI1 and COUNTER2 will keep on working after program is stopped Therefore the disabled interrupt must remain active otherwise users cannot debug the program c Default breakpoint counter See Section 3 9 of Chapter 5 Debugging a Project for details d Show source code in trace log In the Output window the trace log 1s set by default to display the disassembler contents only If this function is enabled the address source level breakpoint generated by the trace log address will also appear in the Output window e Step into macro instruction when Debugging When this option is enabled click Debug gt StepInto F7 to run the program instructions including the macro step by step To run the macro code in the background click StepOver F8 As a new feature you can now disable this checkbox 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 macro address location 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 next macro instruction shaded in green again Example test macro nop nop endm org 0x0 j
4. 000320 055F INC OX1F gt AAS SCS m BURP 10 5 69569 DT 52 00031 0550 INC 0x10 MAET ar m UR LO 5 69 569 pT 53 00032 0551 INC 0X11 RAET a m a BARF 569569 DT 54 00033 0552 INC 0X12 RAET ar m a BRAF 569569 DT 55 00034 0553 INC 0X13 gt RUPE TC St m P1045 69 569 DT 56 00035 0554 INC oxi4 AR E Set eS ABE 104569 569 00 57 Se ee 00036 BS55 30 INC 0x15 n AAR Set m a Bakri 69 569 pr 5a Save Save All gt D Build Information Find in Files Message al o Figure 1 11b Finding a String from any of the Output Sub Windows The steps for initiating the Find dialog from Output window 1 From one of the Output sub windows right click within the widow A command popup menu then displays 2 From the pop up menu click Find command 3 The following Find dialog then displays Find l Match whole word only p direction _ Cancel l Match case l Move with code line C up down Figure 1 11c Find Dialog from Output Window Where Find Enter the word string you want to search Find Next Click this button to search the next matching string Hotkey Alt N Cancel Quit search and exit from the dialog Direction Up Search forward Hotkey Alt U Direction Down Search backward Hotkey Alt D Match whole word only Enable check box to find and match whole word only Hotkey Alt W Match case Select this option to match the string in lowercase or uppercase characters exactly
5. Clear all output mapping line Compute execution time Speed Up Debug Figure 2 12 Tool Menu Clear all output mapping line Get TBL code position Piggy back MIX2 format Compute Execution Time Move data from file to sram Speed Up Debug Get Checksum en Set proper connection between target IC amp connecting port Connect Check ICE Memory Check available memory from ICE Obtain checksum from the from Project compiled program Create a MIX file to write piggybacked into EEPROM Piggy back MIX format Piggy back Hi Lo format Create a couple of files with extension names H1 and Lo which are used to write piggybacked into EEPROM Clear program mapping lines from output window Obtain TBL code position Applicable to EM78813 amp EM78815 only If an original 8bit is used to piggyback and fit into 16bit the piggybacked high byte in 8bit will become low byte in piggybacked 16bit Calculate the execution time between two breakpoints See next section below Applicable only to EM78815 See details in the sub section below Section 2 1 6 2 For C Compiler use only 2 1 6 1 Computing Execution Time Follow the steps below in calculating execution instruction time of ICE 1 Click Compute Execution Time command then the following dialog displays Enter the required ICE frequency and instruction period and click OK button 44 e 2BThe eUIDE Commands Dialog
6. E Description stremp Compare the two strings s1 and s2 It returns an integer less than equal to or greater than zero if s1 is found to be less than matches or greater than s2 respectively strncmp Function is similar with the above except it only compares the first at most n characters of s1 and s2 E Return Value The stremp and strnemp functions return an integer less than equal to or greater than zero if s1 or the first n bytes thereof is found to be less than matches or greater than s2 respectively EM78 Series IDE User s Guide 24BC Standard Library e 171 Appendix F am F 6 6 Locate Character in String strchr strrchr E Synopsis include string h int Strchr char per int chr imc SLerche Char pur ant Chr E Description strchr Return a pointer to the first occurrence of the character chr in the ptr string strrchr Return a pointer to the last occurrence of the character chr in the ptr string E Return Value The strchr and strrehr functions return a pointer to the matched character or NULL if the character is not found E See Also strpbrk strstr strtok Sections F 6 8 F 6 9 amp F 6 11 respectively F 6 7 Search a String of a Specified Set of Characters strspn strcspn E Synopsis include string h int Stespm char sl char 52 Lit SErCspn char
7. Reason The symbol is not defined Solution Provide the required symbol definition 11 error A011 The macro name macro name has already been defined Reason Each macro name must be unique and cannot be defined more than once Solution Redefine with another macro name 136 e 14BAssembly Error Warning Messages EM78 Series IDE User s Guide 12 13 14 15 16 17 18 19 20 Appendix A error A012 The parameter name parameter name is identical with label Reason The parameter name and label must be unique to each other Solution Redefine the parameter name error A013 The same parameter name parameter name appears twice Reason Each parameter name in the macro definition must be unique and cannot be defined more than once Solution Redefine the redundant parameter name error A014 The number of actual parameter does not match with formal parameter Reason The number of actual parameter and the number of formal parameter does not match Solution Change the actual or formal parameter number to make them match with each other error A015 The parameter number number does not exist Reason The position of actual parameter is not defined Solution Define the actual position number of the actual parameter error A016 The external symbol symbol name has identical name with the defined label Reason The external symbol name and label must be un
8. is set E Return Value The asin function returns the arcsine in radians and the value is mathematically defined to be between PI 2 and PI 2 inclusive E Error Definition EDOM x is out of range E See Also sin cos tan acos atan atan2 Sections F 6 17 to F 6 19 amp F 6 21 to F 6 23 respectively 178 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F F 6 21 Arccosine Function acos E Synopsis include math h float acos float x E Description acos Calculate the arccosine of x the inverse value of cosine x If x falls outside the range of 1 to 1 acos fails and errno is set E Return Value The acos function returns the arccosine in radians and the value is mathematically defined to be between 0 and PI inclusive E Error Difinition EDOM x is out of range E See Also sin cos tan asin atan atan2 Sections F 6 17 to F 6 20 amp F 6 22 to F 6 23 respectively F 6 22 Arctangent Function atan E Synopsis tinclude math h float atan float x E Description 66 99 atan Valculate the arctangent of x the inverse value of tangent x E Return Value The atan function returns the arc tangent in radians and the value is mathematically defined to be between PI 2 and PI 2 inclusive E See Also sin cos tan asin acos atan2 Sections F 6 17 to F 6 21 amp F 6 23 respectively
9. Enable Disable Frequency of ICE 4 000000 MHz Fa Clocks for UICE Compute executime time function Instruction Period of ICE This frequency and Instruction period are used for calculating clocks and timing while execution canet Figure 2 13a Compute Execution Time Setup Dialog EM78 Series IDE User s Guide Chapter 2 2 Execute the Project gt Trace Log command or F2 The trace buffer info is then displayed in the Message tab sub window of Output window Code Disassembler File Name Line 1809 MOV A 0x9 D URRARTC RST a AUBRFLO S69 569 09 3 BC 0X3 0X7 AREA m BURR 1O S69 569 0883 BS 0x3 0x6 BURR AST RS Le AUBRF1O S69 569 0047 MOV 0X7 A ARI E RRR 1O 569 569 AR TB BURRFLO 569 569 FANRRAS TC ist eS AUR 104569569 AURIS TCT ARR 10 569 569 ANAL TC ist m S AUR 10 569 569 ANAS TCT ARR 10 569 569 0051 FEU ETA m ARP 10 5 69 569 dt 17 i Information Find in Files Message 4 ProgramRom 4 Figure 2 13b Compute Execution Time Trace Buffer Display from Message Tab Sub Window of Output Window 0048 MOV 0049 0963 I uvv vovvuvuvn 3 Then look for the execution time result from Information tab sub window of Output window Frequency 4 000000 MHz Instruction Cycles 10 Execution Times 250 00 nano ral mm i p a o m E Find in Fes Figure 2 13c Execution Time Result Displayed from Information Tab Sub Window of Output Wi
10. Figure 1 7h eUIDE View Setting Dialog EM78 Series IDE User s Guide Chapter 1 3 After code dump the variables are automatically included in the Watch window as illustrated in the sample below Name Address Type AA 0x20 Bank 0 BE Ox3F Bank 0 Ce 0x10 kegister U DD 0x06 Control 0 CE Watch Wa Waeks 7 UL Figure 1 7 Labeled Register Values Display in Watch Window 1 Field 2nd Field 3 Field N A A LSS UN UxOUULOvarkRegqister I UxHUUUS CONTROLO US 1 0x0006 CONTROL1 Ob 0 1 Oj 0x0020 varBank2U_U Uj UZUUSEF varBanksF_U 0 0z0021 varBank21 0 E a 5 Build Information Find in Files la Figure 1 7k Global Variables Display from Information Sub Window of Output Window EM78 Series IDE User s Guide Introduction e 19 Chapter 1 1 2 2 7 Data RAM Window FF FF FF FF FF FF FF FF ee aS ae 2 3 2 ea a a ee A Se a a a A ao a a ao a a a a A a a A a 2 A A ee O ao ee A oo ao a 3 2 Fo a a Figure 1 8 Data RAM Window with a Right Clicked Binary Value The Data RAM window is accessible only if RAM 1s available from the target microcontroller currently in use The Data RAM window shows the contents of the data RAM To change the data RAM values is the same as changing the special register values described in Section 1 2 2 3 Special Register Window Note that when the Data RAM window is closed it ceases to interact or read t
11. Open Project Open an existing project Save Project Save the active project together with all related files Close Project Close the active Project window Add Files to Add the existing source file into Project project Remove source file from project Assemble or compile the active file window If errors occur during assembly or compiling time error messages will be shown in the Output window Otherwise 0 errors O warnings O users will be displayed Assemble or compile the files that have been modi fied and link them to the currently opened project Assemble or compile all files regardless of having been modified or not and link them to the currently opened project Dump the program code to ICE Refers to available history only when either Go Free Run or Go To Cursor command from the Debug menu is executed The maximum length of trace log is 8K words Dump the page range program code of over 64K to the SRAM The SRAM must be plugged into the ICE hardware when executing this command See example in the following figure 2BThe eUIDE Commands e 35 Chapter 2 re 2 1 4 1 Executing Dump code over 64K to sram Command When the Dump code over 64K to sram command is executed the following dialog displays Enter 64 into the Start Page box and 127 into the End Page box Start Page 64 End Page 2 1 5 Debug Menu 44 Step Into P Step Over P Step Out H Go To Cu
12. The Address Break Point command allows you to directly set a more complex breakpoints setup which can terminate at an address location 1 Open the Address Breakpoint dialog Debug gt Address Break Point or apply shortcut keys ALT A 2 The Address Breakpoint dialog displays as shown in the following figure Address Breakpoint Address breakpoint not active C Breakpoint group C Breakpoint or Enter the address C Breakpoint nest breakpoint in the text box in accordance with the format specified below All the address breakpoints you have entered are displayed here Function options Cancel Breakpoint or and Breakpoint nest syntax The address breakpoint 0xAAAS 0xAAA4 0xPP OXAASA OXAAAA 0xPP format references Address Address Counter Address Address Counter Breakpoint group syntax 0xLLLL 0xHHHH 0xPP OXLLLL OXHHHH OxPP Low address High Address Counter Figure 2 11a Address Breakpoint Dialog with Descriptions of their Components 3 Select an address breakpoint option Breakpoint group Breakpoint or or Breakpoint nest as follows e Breakpoint group Select this option to set a group of breakpoints within a range of address locations with a counter number a Select the Breakpoint group option 40 e 2BThe eUIDE Commands EM78 Series IDE User s Guide a Chapter 2 b Specify a breakpoint group consisting of a 0x01 004 001 start address end address and a
13. c file only io unsigned int DIRPORT6 0x06 iopage 0 9 Q When should I change any program page or bank A If you are just developing your program in C language you do not have to change any program page register page ram bank and so on However if you are using inline assembly in your program you need to manually change save and restore page or bank 10 Q How do I know how many stacks I have called A In C development environment after compiling you can find the resulting function call depth status in the Information tab of Output window 11 Q Does the C compiler only occupies 0x10 0x1F of the general purpose ram A Well the C compiler generally occupies 0x10 0x1F of the general purpose register However 1f some arguments occur in call functions the compiler will use some others ram in 0x20 0x3F Bank 0 Bank 3 So it is suggested that you use global variables to replace arguments in call function Always take note that some ram spaces are used in the interrupt save procedure and interrupt service procedure if these ram spaces are not in used 12 Q Does the C compiler support EM78P510N A TCC2 supports all EM78 series ICs except EM78x680 and EM78x611 EM78 Series IDE User s Guide 18BFrequently Asked Questions FAQ e 157 Appendix C Py 13 Q How do I use macro with variable A Follow the example below 10 unsigned int P6CR 0x06 1opage 0 define set_output port bit _asm ior
14. f newline n carriage return r horizontal tab t and vertical tab v isupper Check for an uppercase letter isxdigit Check for a hexadecimal digits 1 e one of 0123456789abcd efABCDEF E Return Value The nonzero values are returned if the character c falls into the tested class otherwise a zero value is returned E See Also tolower toupper Section F 6 2 below EM78 Series IDE User s Guide 24BC Standard Library e 169 Appendix F en F 6 2 Convert Letter to Upper or Lower Case tolower toupper E Synopsis include ctype h char toupper int c char tolower int c E Description toupper converts the letter c to upper case if possible tolower converts the letter c to lower case if possible If c is not an unsigned character value or EOF the behavior of these functions is undefined E Return Value The value returned is that of the converted letter or c if the conversion was not successful E See Also isalpha Section F 6 1 F 6 3 Copy a String strcpy strncpy E Synopsis include string h int SEPCoy Char Co char 7 from int Shxenepy char tOo Char from int Give E Description strepy Copies the string pointed at by from including the terminating 0 character to the array pointed at by to The strings should not overlap and the destination string
15. focusing on either C or assembly code LCD Data Cutput Watch Assembly Code Toolbars statis Bar Document Bar Figure 7 7a Press Assembly Code Button in View EM78 Series IDE User s Guide Quick Workout on Tiny C Compiler e 129 Chapter 7 jinu festcode c 0 wn TEs T_bp dt MN A446 ALAA EOE EE EEE Moy 0x29 A MN 444 6S PSE SPE OP AA eCL Ci 3s 2099 2652 char Moy Ae Use 653 c1l Ux MOY xi 2 rood caa Ux4 CLEA 2855 ci ci 3 ADD A 0x03 o56 cil ci 4 DIZ 0x iC c gt 2857 JMF OxO025 Pti ati vi ciz3 E BANE fl 2059 CICI Caa MOY Qxze A o60 cl cisz3 rcleci 4d 2056 206 eisei25 Freri BC 0x03 0 Pti ifa i ELC Uxe 2063 26 BC 0x03 O eee eee ELC Uzer O 46 20 2S oo oo oo OPO PE i Soke ee di foo hob 41H a ae ee Figure 7 7b Assembly Code in C Debug Mode with C File in Focus You can activate and set focus C or assembly file to start debugging with such commands as Go Free Run Reset Step Into Step Over Step Out Go to Cursor and setting clearing breakpoints 7 7 3 Viewing Defined Variables in Register Window When the Show defined label in Register Window checkbox of View Setting dialog Option gt View Setting is enabled the variables defined in register field will display in the Register window after dumping Note that the register names do not appear by default but are users defined Register CONT 00 RO 14 01 RITEC 00 R2PC 0035 R3 0001 1000 R4 0001
16. to must be large enough to accommodate the copied string strncpy Function is similar with the above except that no more than n bytes of from are copied Thus if there is no null byte among the first n bytes of to the result will not be null terminated In the case where the length of from is less than that of n the remainder of to will be padded with nulls 170 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F E Return Value The strepy and strnepy functions return a pointer to the destination to string F 6 4 Link Two Strings strcat strncat E Synopsis include string h int StLEeCcat char to char irom int Strncal char to Char from 1nt Size E Description streat Append the from string to the to string overwriting the 0 character at the end of to and then add a terminating O character The strings should not overlap and the to string must have enough space to accommodate the result strncat Function is similar with the above except that only the first n characters of from are appended to to E Return Value The strceat and strncat functions return a pointer to the resulting to string F 6 5 Compare Two Strings strcmp strncmp E Synopsis 66 include string h int stromo char sil char 52 int straocmp char sl char s2 int len
17. with the constant byte c E Return Value The memset function returns a pointer to the memory area p1 F 6 17 Sine Function sin E Synopsis include math h float sian tloat x E Description sin Return the sine of x where x is given in radians E Return Value The sin function returns a value between 1 and 1 E See Also cos tan asin acos atan atan2 Sections F 6 18 to F 6 23 respectively F 6 18 Cosine Function cos E Synopsis include math h float cos float x E Description cos Return the cosine of x where x is given in radians E Return Value The cos function returns a value between 1 and 1 EM78 Series IDE User s Guide 24BC Standard Library e 177 Appendix F en sin tan asin acos atan atan2 Sections F 6 17 F 6 19 to F 6 23 respectively E See Also F 6 19 Tangent Function tan E Synopsis include math h float tan float x E Description tan Return the tangent of x where x is given in radians E See Also sin cos asin acos atan atan2 Sections F 6 17 F 6 18 amp F 6 20 to F 6 23 respectively F 6 20 Arcsine Function asin E Synopsis include math h float asin float x E Description asin Calculate the arcsine of x the inverse value of sine x If x falls outside the range of 1 to 1 asin fails and errno
18. Any related messages will be shown in the Output window 20 e Introduction EM78 Series IDE User s Guide Chapter 1 2 Graphic Pane This pane displays the status of the loaded BMP graphic Ifno BMP graphic is loaded no display is shown 3 Control Pane This pane controls the link between the BMP graphic and the data as well as setting the COM SEG values for each graphic segment 4 Pane Selection Bar You can select whether to display any or all of the three panes described above E Loading Graphic Display and Segment Settings The following is the step by step procedure on how to load the graphic display and define their segment settings 1 From the Control Pane click Import Graph button to load lt gt the BMP file The program will automatically convert the 7 graphic file into black and white colors and determines oe which black pixels are linked together to establish an segments 2 Click Set Mapping button and the black segments fades to a gt gray to indicate that the system is now in Mapping Mode 7 S At the same time the Set Mapping button label changes lt gt to Done Click the Done button only after all mapping A p T 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 o 8 blue color This indicates that the pointed segment is now E T active com 0 seG 0 4 Click o
19. FCALL and FJMP are ree reserved words These two words will HLUMBE determine whether the program code is Eb ee Paps over page or not Eke Ba a HUME Efe Se Brae Ee ee ares HUME Efe Se Bree att 4a FJIMP MACRO ADDRESS IF ADDRESS UX400 S O0 400 FPAGE ADDRESS Ux400 ENDIF JMP ADDRESS ENDOM FALL MACRO ADDRESS IF ADDRESS UX400 5 02400 FPAGE ADDRESS UA400 CALL ADDRESS FPAGE S Ox400 ELSE CALL ADDRESS ENDIF ENDM 84 e 6BAssembler and Linker EM78 Series IDE User s Guide oll Chapter 4 k MACEXIT this instruction is only used in the macro defined instructions If the MACEXIT instruction is assembled then the remaining macro instructions if any are 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 After assembly the first column is address 0000 be 0x04 6 Because the test variable is equal to five so the expression test gt 4 is true 9 and the macexit instruction is assembled Accordingly as macexit instruction is assembled the remaining macro instructions bc 0x04 7 1s not 9 9 9 9 assembled D MESSAGE display the user defined message in the Output window Syntax MESSAGE lt characters gt Example org 0x00 message set bank to 0 be 0x04 6 be 0x04 7 The user defined message see below 1s displayed in the Output window after assem
20. If you want to update all EEPROM data just click Refresh button on top left of the window All data are then updated 1 2 2 10 Output Window Figure 1 11a 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 from 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 See example below Message displays the debugging related changes to the LCD RAM window Program Rom displays the contents of program ROM after dump EM78 Series IDE User s Guide Introduction e 25 Chapter 1 E Executing Find Command from Output Window Right click to display pop up menu from a sub window and click Find
21. Solution Check power supply printer USB port connection etc error D008 The number is invalid Reason The number is invalid Solution Rewrite the number expression error D009 The number of messages is over number Reason The number of messages is over the Output window capacity Solution Decrease the number of defined messages such as MESSAGE instructions Warning D010 The address number does not match with the source file Reason The program address does not match with the source file line Solution Add the program source of the address or check whether the crystal is normal or not Warning D011 Memory checked is in error Reason The ICE SRAM memory is in error Solution Change the ICE SRAM or check whether the crystal is normal or not 142 e 14BAssembly Error Warning Messages EM78 Series IDE User s Guide 12 13 14 15 16 17 18 19 20 21 Appendix A error D012 Syntax error Reason The source file syntax has a severe error Solution Correct the source file error D013 Memory address number is in error Reason The address of ICE SRAM is in error Solution Change the ICE memory error D014 Cannot find the breakpoint address of program line Reason The breakpoint line does not have program address Solution Redefine the breakpoint error D015 The number of symbols is over number Reason The defined number of
22. re 5 5 Data Type The size and range maximum and minimum values of the basic data type are as shown below Type Storage Size Byte signed char 128 127 signed int 128 127 unsigned int signed short 32768 32767 unsigned short 0 65535 signed long 2147483648 2147483647 unsigned long 0 4294967295 bit float 1 175494351E 38F 3 3 402823466E 38F dJounie 1 175494351E 38F 3 3 402823466E 38F When an arithmetic operator such as and 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 you use the same data type to develop program Example int Il 122 Shore olp S2 S23 Long dal 12 Il 0x11 I2 0x22 S1 I1 I2 change to S1 short I1 short I2 If forgot to add short before Il and I2 the final result in 51 will be 1 byte only Sil 0x111 S2 0x02 L1 S1 S82 change to L1 long S1 long S2 7 I Torgot to ada long before Si and S2 the final result in L1 will be 2 bytes only EM78 Series IDE User s Guide 8BC Fundamental Elements e 97 Chapter 5 re Tiny C compiler uses two s compliment to perform mathematical negative signed declaration Example Assume abc 1s allocated at 0x20 Bank 1 Then from RAM Bank window you will see E8 being displayed at that locati
23. sl char S2 3 E Description strspn Calculate the length of the initial segment of s1 which consists entirely of characters in s2 string strespn Calculate the length of the initial segment of s1 which consists entirely of characters not found in s2 string 172 e 24BC Standard Library EM78 Series IDE User s Guide a Appendix F E Return Value The strspn function returns the number of characters in the initial segment of s1 which consists only of characters that match those of s2 string The strespn function returns the number of characters 1n the initial segment of s1 which consists of characters that do not match with the s2 string E See Also strpbrk strstr strtok Sections F 6 8 F 6 9 amp F 6 11 respectively F 6 8 Search a String of Any Set of Characters strpbrk E Synopsis include string h int Strpbrk char si char 62 E Description strpbrk Locate the first occurrence in s1 string of any of the characters stated in the s2 string E Return Value The strpbrkQ function returns a pointer to the character in s1 string that matches with the characters in s2 string Otherwise it returns a NULL if no such character is found E See Also strchr strspn strstr strtok Sections F 6 6 F 6 7 F 6 9 amp F 6 11 respectively F 6 9 Locate a Substring strstr E Synopsis include string h
24. 0010 R10 Ox10 rpa an example where the 2 2011 R11 Oxll rpa include 447test h 2 00000 0010 R11 Oxll rpad org Oxfff J l Find command found pH 4 include 447te arg 0x00 5 org Oxfff i sl 6 OOFFF 1400 jmp sl and highlights the string BUP 6 ae clr 0x12 8 00000 s1 which matches with the s2 9 00000 00D1 clr 0x11 l W B inc 0x11 10 00001 00D2 clr 0x12 TE 2 0x55 11 00002 s2 i search mov string mov a 0x55 12 00002 0551 ine 0x11 mov a 0x55 13 00003 1855 moy 4 0x55 mov a 0x55 14 00004 1855 mov 4 0x55 mov 4 0x55 15 00005 1855 mov a 0x55 inc 0x12 16 00006 1855 mov a 0x55 jmp s2 17 00007 1855 mov a 0x55 M Match whole word only p Direction Match case Up Down Warning s 0 User message Figure 2 4c An Example of Highlighted Matched String EM78 Series IDE User s Guide 2BThe eUIDE Commands e 33 Chapter 2 an 2 1 2 2 Executing Find Command with Shortcut Hotkeys 1 From the Find dialog enter the string you want to search 2 To search upward press the shortcut keys CTRL P 3 To search downward press the shortcut keys CTRL N 2 1 3 View Menu TA Project Special Register x General Registers Bank CallStack Data Data Ram LCD Data Pe Output Watch Assembly Code sre Only Source Window Ctrl Shift 5 Toolbars Status Bar Document Bar Figure 2 5 View Menu Assembly Code Only Source Window Toolbars Stat
25. 0x19 A MOV A 0x01 MOV 0x1A A MOV A 0x1B INDIR Indirect addressing myData1 0x55 myData2 OxAA INDIR BC 0x05 0 MOV 0x1B A MOV A 0x1A JBS 0x03 2 JMP 0x081 MOV A 0x18 IOW 0x9 MOV A 0x1B IOW OxA RET LCDRAM MOV A 0x18 MOV Ox0A A MOV A 0x1B MOV 0x0B A RET 150 e 16BC Conversion Table EM78 Series IDE User s Guide CD LAN Description C Statement Example Bitwise operation MOV A e all variables are AND A d unsigned int data XOR A d type OR A d MOV f A BC 0x03 0 RRCA e MOV f A BC 0x03 0 RLCA e MOV f A BC 0x03 0 RRC f BC 0x03 0 RRC f BC 0x03 0 RRC f BC 0x03 0 RLC f BC 0x03 0 RLC f BC 0x03 0 RLC f SWAPA 0x06 AND A 0x0F MOV 0x06 A SWAPA 0x06 AND A 0xF0 MOV 0x06 A SWAP 0x06 RRC 0x06 RRCA 0x06 AND A 0x03 MOV 0x06 A SWAP 0x06 RLC 0x06 RLCA 0x06 AND A 0xCO MOV 0x06 A EM78 Series IDE User s Guide Assembly Code Appendix B Conversion Rate Compilers Code Size General User s Code Size 100 100 3 3 100 f e COMA e 100 2 2 100 MOV f A MOV A e AND f A XOR f A OR f A 100 2 2 100 100 3 3 100 100 3 3 100 100 6 6 100 100 6 6 100 100 3 3 100 100 3 3 100 100 5 5 100 100 5 5 100 16BC Conversion Table e 151 Appendix B Description Ari
26. 7 1c ita Beas ave Project Le Save ctrl below click on the Project tab to select target MCU assign project filename and folder Then click Close Project Save As Gi Save All Add Files to Project Delete files from project Open Project oN lt 3 Assemble AIt F the C Option Button for C Save Project 8 Build Shifts alterS leers oe Compiler Project Type Click OK Figure 7 1b File amp Project Drop Down Menus button to create the project g J p New Create a New File Projects Micro Controller Assign a project filename no suffix required Froject Name In this particular case EM78P468N is selected as target MCU EM78P311NACE809N EM7SP312N ICE809N EMTSP230N ICE3230N EM78P331N CE330N EM78P342N ICE341N EM78P346N ICE345N EM78P349N ICE349N EM78P418N ICE418N M76P447N ICE447 EM76P4478 ICE447 EM7SP468N ICE468 EM78P469 ICE469 EM7SP507N ICE507N Location CADocuments and Settings 950 zal Project Type Library Output Assembler Normal eac C Library lib EM78 Series IDE User s Guide Figure 7 1c New Dialog Locate the folder to store the new project Click the C Option for C Compiler Project Quick Workout on Tiny C Compiler e 123 Chapter 7 Observe the new project is then created with the defined project name and micro controller you have selected displayed at the top of the Project wi
27. EM78 Series IDE User s Guide 24BC Standard Library e 179 Appendix F en F 6 23 Arctangent Function of Two Variables atan2 E Synopsis include math h float atan2 float y float x E Description atan2 Calculate the arctangent of the two variables x and y It is similar to calculating the arctangent of y x except that the signs of both arguments are used to determine the quadrant of the result E Return Value The atan2 function returns the result in radians which 1s between PI and PI inclusive E See Also sin cos tan asin acos atan Sections F 6 17 to F 6 21 amp F 6 22 respectively F 6 24 Hyperbolic Sine Function sinh E Synopsis include math h float sinh float x E Description sinh Return the hyperbolic sine of x which is defined mathematically as exp x exp x 2 E See Also cosh tanh Sections F 6 25 amp F 6 26 respectively F 6 25 Hyperbolic Cosine Function cosh E Synopsis includa math h float cosh float x E Description cosh Returns the hyperbolic cosine of x which is defined mathematically as exp x exp x 2 180 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F F 6 26 Hyperbolic Tangent Function tanh E Synopsis tinclude math h float tanh float x E Description tanh Return the hyperbolic tangent of x which is defined mathematically as sin
28. FF FF FF Bo3e FF F Emay bP FF FF FF FF FF FF FF FF FF FF B12 FF FY Hex FF FF FF FF FF FF FF FF FF FF FF B13 FF F pai FF FF FF FF FF FF FF FF FF FF FF B228 FF Freprreprrerr FF FF FF FF FF FF FF FF FF FF FF E B2_3E FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B3 28 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF Gi B33 FF FF FF FF FF FF FF FF FF FF FF EF FF FF FF FF al Figure 1 6a Ram Bank General Registers Window The Ram Bank General Registers window shows the updated contents of the common RAM bank registers When the RAM Bank window 1s closed it ceases to interact or read the hardware contents E Changing General Register Value Directly by Editing To change a special register value double click on the selected value EF in the example shown at left BF 7D YE FF Fo EB F DF Figure 1 6b Double Click on Selected Value EF in this Example New value turns red after clicking anywhere in the eUIDE window With the existing value highlighted key in the new value 33 in the example at left figure Observe the i i new value changes to red when you Figure 1 6c Key in New Value 33 in this Click anywhere within the eUIDE Example to Replace the window Selected Value TF 14 o Introduction M78 Series IDE User s Guide Chapter 1 E Switching General Register Value into Binary Hex Value Right click on the selected value a pop up menu containing commands for editing the selec
29. New Projeen oron Eni ee eer eee dee AddaNew C File tothe Projet ecien ii ne retin 7 4 Add a Second File or a New Header File to the Project 0 ee 7 5 The Main Interrupt Save and Service Routine Functions 7 6 Project Development with Interrupt eueeeeeeeeesseererrrrrerrerrrrrrrrren 7 7 Tips on C Compiler Debugging ccc ccccccccccsseceeeeeeceeeeeeeeeeeeeeeeeeeeeeees TeL SPee lur BJ DU 1 0 1S en rt oe re 7 7 2 View Corresponding Assembly Code in C Environment 7 7 3 Viewing Defined Variables in Register Window ccccccees 7 7 4 Reducing Codes Size in Some Cases cccccccccecccecceeeeeeeeeeeeeeeees APPENDIX A Assembly Error Warning Messages Ael MAROC CIC sched teeter uses betedtert yan eee ween ene eiee menue nw enetaeet A 2 Class M Main Program Errors Messages ccccccssssssssssseeseseeeeeeeeeeeeees A 3 Class A Assembler Errors Warnings Messages ssssssssssesseseseeeeees A 4 Class L Linker Error MeSSae 6S sc1ccescsessgundeveetinceusenadserssesdovssavesasesteceetce A 5 Class D Debugger Error Messages 000cceeesessessssssesssessssessesssseens B C Conversion Table B 1 Conversion between C and Assembly Codes cccccccssssssessseseeseeeeeeees EM78 Series IDE User s Guide Contents o Vii Contents C Frequently Asked Questions FAQ 155 CT 6 01 2 Uc 1o 0 8 hy geen pene on
30. Series IDE User s Guide 6BAssembler and Linker e 75 Chapter 4 ae 4 2 Statement Syntax label operation operand operand comment All 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 a z 0 9 but with some restrictions e 0 9 must not be the first character of a name e Only the first 31 characters are recognized e To reserve colon is recommend to programmers because it could be more readable 4 2 1 How to Define Label a zeroflag equ RXX YY Ex1 zeroflag R3 2 Ex2 status R3 b zeroflag 1 equ OxXX YY Exl zeroflag 1 0x3 2 Ex2 status 1 0x3 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 OxXX YY Ex status 3 0x3 zeroflag 3 Status 3 2 e Add label with rpage rbank iopage range and select Special Register RO RIF 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 76 e 6BAssembler and Linker EM78 Series IDE User s Guide a Chapter 4 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 10o
31. Source Files E stack dt 120 sub_28 3 Header Files 121 B E List Files 4 stack Ist Map Files lt q Library Files 122 123 24 sub_29 125 126 127 Z FileView 128 sub_30 129 130 131 132 sub_31 stack dt stack dt l Project 120 sub_28 111 ret 3 EM78808 STETR APJ sub_29 cy EM78808 STETR AP m sub_26 m npn E Source Files Soure Files Dii ca sub_ E stack dt 123 stack dt na Coe E 29 on rt ba ia 127 ret oan ek 118 g 42 Map Files 2 lt 4 Map Files 128 sub_30 on Library File 11 4 Library Files 129 eall sub 31 120 sub_28 130 no l 121 31 ee E FkView 122 132 sub_31 123 133 nop 124 sub_29 134 ret 125 126 127 128 sub_30 129 130 131 132 sub_31 133 134 Figure 1 5c Stack Level Returns to the Preceding Stack Figure 1 5d Stack Level Returns to an Earlier and Level See New Breakpoint Setting Several Levels of Stack 12 e Introduction EM78 Series IDE User s Guide Chapter 1 Note that the last next stack level still shows 0x0003 the value of the last stack level when all stack were full Note that all the subsequent stack levels still display 0x0003 E Step by Step Execution to Change Stack Values When you perform a step by 104 sub_24 step execution F7 eUIDE will Fs Tann STET API 106 nop compare the last stack value ain M sub25 on oe with the stack value after the o re
32. _lowpulse _Port Ports 1 _Port6Ports _main _ctestl _ctestz Function List vs Call relation Call Depth Function Call Depth 2 TL J Build Information Find i Files p Mesage Progam Rom Outprt Window Figure 7 5b Writing Interrupt Service Code in Counter 1 Interrupt IO Control usage status IK All Files Saved nC Dos T o Figure 7 5c Output Window Information Messages after Successful Rebuild All Execution 128 e Quick Workout on Tiny C Compiler EM78 Series IDE User s Guide oll Chapter 7 7 7 Tips on C Compiler Debugging 7 7 1 Speed up Debugging In C mode environment you can increase the speed of step by step debugging with Step Into F7 and Step Over F8 commands by selecting Gheck ICE memory the Speed Up Debug checkbox from Get checksum from project the Tool menu figure at right iggy back MIX format Note that this function is disabled when Piggy Back Hi Lo format debugging in Assembly mode Clear all output mapping line Tool Connect Ctr Shift c compute execution time Fal Speed Up Debug Figure 7 6 Speed Up Debug Command 7 7 2 View Corresponding Assembly Code in C Environment With the Assembly Code checkbox of View menu figure at right enabled the C source code and its corresponding assembly codes can be fully displayed special Register together in the Edit window see next General Resisters Bank Figure 7 7b Data Ram Debugging can be carried out by
33. are not intended 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 PANT ELAN MICROELECTRONICS CORPORATION Headquarters Hong Kong USA No 12 Innovation 1 Road Elan HK Microelectronics Elan Information Hsinchu Science Park Corporation Ltd Technology Group U S A Hsinchu TAIWAN 30076 Flat A 19F World Tech Centre 95 PO Box 601 Tel 886 3 563 9977 How Ming Street Kwun Tong Cupertino CA 95015 Fax 886 3 563 9966 Kowloon HONG KONG U S A webmaster emc com tw Tel 852 2723 3376 Tel 1 408 366 8225 http www emc com tw Fax 852 2723 7780 Fax 1 408 366 8225 Shenzhen Shanghai Elan Microelectronics Elan Microelectronics Shenzhen Ltd Shanghai Ltd 3F SSMEC Bldg Gaoxin S Ave I 34 First Fl 2 Bldg Shenzhen Hi tech Industrial Park Lane 122 Chunxiao Rd South Area Shenzhen Zhangjiang Hi Tech Park CHINA 518057 Shanghai CHINA 201203 Tel 86 755 2601 0565 Tel 86 21 5080 3866 Fax 86 755 2601 0500 Fax 86 21 5080 4600 elan sz elanic com cn elan sh elanic com cn au Contents Contents 1 Introduction 1 EE 205 a1 W ge en ne ee ee ee l 1 2 Intoducion to ceULDE Protasio E l 121 GUIDE Miim User Intet i Ce era n EN 2 1 2 2 eUIDE Sub Wind
34. as they appear Hotkey Alt C 26 e Introduction EM78 Series IDE User s Guide oll Chapter 1 Move with code line When this check box is enabled the Output window will indicate the search matched line in the trace log At the same time the corresponding trace log mark code line in the Editor window is highlighted Hotkey Alt M 1 2 3 eUIDE Menu Bar See Chapter 2 for details 1 2 4 ToolBar 1 2 3 4 5 6 7 8 9 10 11 12 13 1415 16 17 18 19 20 21 Figure 1 12a eUIDE Main Window Standard Toolbar _22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 Figure 1 12b eUIDE Main Window Build Toolbar 1 2 4 1 Toolbar Icons and its Functions and Hotkeys Corresponding hot key is enclosed in parenthesis Open open an existing file Ctrl O 2 Save save current active document Ctrl S 3 Save All save all document 4 Cut remove the selected string to clipboard Shift Del Copy copy the selected string to clipboard Ctrl C 6 Paste paste the string from clipboard Ctrl V 7 Undo cancel the last editing action Alt Backspace g Redo cancel the last undo 1 e restore the undone editing eae action Ctrl Y EM78 Series IDE User s Guide Introduction e 27 Chapter 1 28 e Introduction 10 11 12 13 14 15 16 17 18 19 20 21 22 eilse a ae lle elle a 29 30 eae en Open Hide Workspace display hid
35. contents are displayed with F6 EM78 Series IDE User s Guide 4BGetting Started e 71 Chapter 3 ae H Step Into Auto dump and execute instructions step by step including subroutines with register contents updated at F7 the same time If the RAM of your computer is full do not click command continuously Step Over Same as Step Into command see above but excluding i subroutines and the CALL instruction is executed as Go F8 command If the RAM of your computer is full do not click command continuously Step Out Auto dump and run program starting from the current program counter until the RET RETI RETL instruction address is executed O ma o TI N Go to Cursor Auto dump and execute from current program counter to the location where the cursor is positioned with breakpoints ignored Run from Selected Line Start running command from the line where the cursor is positioned Toggle Breakpoint Click command with cursor positioned on the line If line is set with breakpoint it will be removed Otherwise breakpoint is set Clear All Breakpoints Remove all existing breakpoints Trace Back After trace log is executed trace the log backward step by step from the last executed address to the address located before the current executed address bottom to top Trace Forth After trace log is executed retrace the log forward step by step from the last executed addres
36. e 17 Chapter 1 re E Accessing Option gt View Command from Menu Bar Variable without page location data not labeled 18 e Introduction Mass Selection by Labeling 1 From Menu Bar click Option gt View Setting see figure at right From the resulting View Setting dialog select the Add defined label to watch automatically option see Figure 1 7i below There are three sorting options in eUIDE Version 2 6 or later Labels added into Watch window will be sorted automatically according to the selected sorting option sample figure shows sort by name option selected Then Click OK button 2 All variables with page location data are automati cally formatted into labeled format in the Editor window as shown in the example below z OU rbank EaF irbank Figure 1 7i Labeled Format of Variables with Page Location Data Font Debug Option Setting Dump ASPCM Environment setting Customize Figure 1 7g Option Pull Down Menu from eUIDE Menu Bar Rewise Window Size Base on Big window size when dock C Base on Small window size when dock File Name in Project Window C File name with Path File Name Show Line Numbers ON C OFF Tab Width 4 7 w Add defined label to watch automatically C Sort by Address C Sort by Type Show Unreferenced variable Show defined label in Register Window Cancel Show Program Rom
37. h int memcmp void sl void s2 int m1 E Description memcmp Compare the first n bytes between the memory areas s1 and s2 It returns an integer less than equal to or greater than zero if s1 is found to be less than to match or greater than s2 respectively E Return Value The mememp function returns an integer less than equal to or greater than zero if the first n bytes of s1 is found to be less than to match or be greater than the first n bytes of s2 respectively E See Also strcmp strncmp Sections F 6 5 F 6 15 Scan Memory for a Specified Character memchr E Synopsis include string h int memchr void p int n int v E Description memchr Scan the first n bytes of the memory area pointed to by p for the character n The first byte to match n interpreted as an unsigned character stops the operation E Return Value The memchr functions return a pointer to the matched byte or return a NULL if the character is not found in the given memory area E See Also strspn strpbrk strstr Sections F 6 7 F 6 8 amp F 6 9 respectively 176 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F F 6 16 Fill Memory with a Constant Byte memset E Synopsis include stringen int memset void pl int c int n E Description memset Fill the first n bytes of the memory area pointed to by p1
38. int SLEStr char sl char B2 E Description strstr Find the first occurrence of the s2 substring in the s1 string The terminating 0 character is not compared EM78 Series IDE User s Guide 24BC Standard Library e 173 Appendix F an The strstr function returns a pointer to the beginning of the substring that matches with the characters in s1 string Otherwise it returns a NULL if no such substring is found E Return Value E See Also strchr strspn strpbrk strtok Sections F 6 6 F 6 7 F 6 8 amp F 6 11 respectively F 6 10 Calculate the Length of a String strlen E Synopsis include string h int strl en char s E Description strlen Calculate the length of the s string excluding the terminating 0 character E Return Value 6699 The strlen function returns the number of characters in s string F 6 11 Extract Tokens from Strings strtok E Synopsis include string h int StCrCoOk char sl char sZ E Description strtok Used to parse the s1 string into tokens The first call to strtokQ should have the s1 string as its first argument Subsequent calls should have the first argument set to NULL Each call returns a pointer to the next token or NULL when no more tokens are found If a token ends with a delimiter this delimiting character is overwritten with a 0 and a pointer to
39. math h float ceil float x E Description ceil Round up x to the nearest integer E Return Value The rounded integer value is returned If x is integral or infinite x itself is returned E Errors No errors other than EDOM and ERANGE can occur If x is NaN then NaN is returned and errno may be set to EDOM E See Also floor Section F 6 30 182 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F F 6 30 Largest Integral Value Not Greater than Argument floor E Synopsis include math h float floor float x E Description floor Round down x to the nearest integer E Return Value Return the rounded integer value If x is integral or infinite x itself is returned E Errors No errors other than EDOM and ERANGE can occur If x is NaN then NaN is returned and errno may be set to EDOM E See Also ceil Section F 6 29 F 6 31 Absolute Value of Floating Point Number fabs E Synopsis tinclude math h float fabs float x E Description Fabs Return the absolute value of the floating point number x E See Also ceil floor abs Sections F 6 29 F 6 30 amp F 6 38 respectively EM78 Series IDE User s Guide 24BC Standard Library e 183 Appendix F en F 6 32 Multiply Floating Point Number by Integral Power of 2 Idexp E Synopsis include math h float Idexp f
40. page Users have to declare clearly which register page including rpage 0 the variable is declared with Example unsigned int myRegl 0x03 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 0x05 rpage 1 myTest is at address 0x05 of register page 1 If the specific register have more than one register page user should point out in which register page the variable is located struct St EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 107 Chapter 6 unsigned int b0 unsigned int bl unsigned int b2 unsigned int b3 unsigned int b4 unsigned int bod unsigned int b6 unsigned int b7 by struct st myReg3 0x06 rpage 0 CONT RO A V R1 TCC R2 PC R3 R4 rpage 0 rpage 1 lopage 0 ioage 1 R5 R6 R7 R8 R9 RA RB RC RD RE RF Declare variables in common registers 0x10 0x1F Example unsigned int uiR12 0x12 rpage 0 declare uiR12 at common register 0x12 unsigned int uiRDD Oxl6 rpage unsigned int uiR17 0x17 rpage unsigned int uiR18 amp 0x18 rpage unsigned int uiR19 0x19 rpage unsigned int uiR1A OxlA rpage unsigned int uiR1B Ox1lB rpage unsigned int uiRI1C OxlC rpage Oo DO DO DO DW DW DW unsigned int uiR1D OxlD rpage 108 e 10BC Control Hardware Related Programming EM78 Series IDE Use
41. port 5 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 7 Of J lt 1007 JFF for k Of k lt 1008 Ker flag crccheck buffer if flag 0 goto error outbuf buffer error Ciear up buffer EM78 Series IDE User s Guide 8BC Fundamental Elements e 105 Chapter 5 5 18 Function Function is the basic block of the C language It includes function prototype and function definition 5 18 1 Function Prototype lt return_type gt lt function_name gt lt parameter_list gt 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 5 18 2 Function Definition lt return_type gt lt function_name gt lt parameter_list gt statements Example Function Content unsigned char sum unsigned char a unsigned char b return atb 106 e 8BC Fundamental Elements EM78 Series IDE User s Guide iz Chapter 6 Chapter 6 C Control Hardware Related Programming 6 1 Register Page rpage lt variable name gt lt address gt rpage lt register page number gt The data type is used to declare a variable at a certain register
42. port _asm and a 1 lt lt bit _asm iow port set_output P6CR 0x04 14 Q Does C Compiler supports all assembly instruction A TCC2 supports all assembly instruction However some instructions have to be implemented in inline assembly format such as MUL TBRD TBWD and MOV R R 15 Q How can I clear all ram in all banks A There are two key points in this issue One is to keep Bit 5 R4 as 1 The other point is to switch the bank correctly But some ICs use a non global register to switch ram bank such as EM78P510N So users need to understand its particular characteristics to avoid error For example unsigned int i1 R0 0x0 rpage 0 unsigned int RSR 0x4 rpage 0 unsigned int BRSR O0x5 rpage 0 unsigned int 1 0xll rpage 0 for i 0 i lt 0x8 i BRSR 1 For RSR OxPFF RSR gt 0xE0 RSR 1RO 0O 158 e 18BFrequently Asked Questions FAQ EM78 Series IDE User s Guide au Appendix C C 4 Contacting ELAN FAE For customer service assistance on UICE hardware or UIDE software problems please contact ELAN FAE engineer at following address ELAN NC Be FF tr BE ZS MICROELECTRONICS CORPORATION RIT EARRA Bea iE No 12 Innovation 1 Rd Rake 3 E Hsinchu Science Park ie Hsinchu City Taiwan 3076 FE 14 009 86 755 2601 0565 TEL 886 3 5639977 WHE http www emc com tw http www emc com tw EM78 Series IDE User s Guide 18BFrequently Asked Questions FAQ e 159 Appen
43. public or external Although the eUIDE 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 Syntax EXTERN lt label gt lt label gt EM78 Series IDE User s Guide 6BAssembler and Linker e 81 Chapter 4 an PUBLIC and EXTERN instructions can be defined at any location of a file that contains one or more PUBLIC or EXTERN instructions Example A project contains two files one is TEST1 DT the other is TEST2 DT TEST1 DT org 0x00 Public start Extern loop1 Start mov a 0x02 mov 0x20 a jmp TEST2 DT org 0x100 Public loop loop1 Extern start Loopl inc 0x20 jmp start The label of Start which is defined in the TEST1 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 TEST1 DT file and PUBLIC in the TEST2 DT file i VAR The instruction defines variable name during assembly time so the value of variable is only changed during the assembly time Syntax Label VAR
44. some very special registers which is read internally Aaa 39 39945 aaa 3S 2S mein eee A A Figure 1 4a An Example of Special Register Window Displaying Updated Registers E Changing Special Register Value Directly by Editing To change a special register value double click on the selected value BD in the example shown at left Figure 1 4b Double Click on Selected Value BD in this Example 10 e Introduction EM78 Series IDE User s Guide Chapter 1 re With the existing value highlighted key in the new value 77 in the example at left figure Observe the new value changes to red when you Figure 1 4c Key in New Value 77 in this click anywhere within the Special Example to Replace the Register window Selected Value New value turns red after clicking anywhere in the Special Register window E Switching Special Register Value into Binary Hex Value R14 BE Right click on the selected value a AATE RIB FE ee pop up menu containing commands for selected value is editing the selected register value will already in hex 3 display The following describes each of the menu commands Figure 1 4d Right Click on the Selected Value to Display the Binary Binary Switches the register value Hex Edit Commands from hex to binary format If the value is already in binary this command is prefixed sida with a check mark Ric EF Hex Switches the register value Figur
45. taiea N T NE 178 F6 20 Arcsine Function ASi scerosresccinci creirien Ee sE EEEE 178 F 6 21 Arccosine Function ACOS ccccceesseececceceeeeeeeeeeaaaaaeeeseeseeeceeeeeeeeeeeeaaaaaas 179 F622 Arctncont FUNC MON dla sece E EREE 179 F 6 23 Arctangent Function of Two Variables atan2 ccccccseeesesseeeeeeeeeees 180 F 6 24 Hyperbolic Sine Function sinh cccceeceeeeeeeneeesnsensssncssnsssnsnseees 180 F 6 25 Hyperbolic Cosine Function COSD cc0ccceeseseeeseessssesssesssssssssseeeeees 180 F 6 26 Hyperbolic Tangent Function tanh cccceeeeesessssesessssessssssssseseeeeeees 181 F 6 27 Exponential Logarithmic and Power Functions exp log log10 pow 181 F 6 28 Square Root Function sqrt cccccccccsssssssesecccccececeeeseeecccseeeeaaeeeseeeceess 182 F 6 29 Ceiling Function Smallest Integral Value Not Less Than Aro ume nt Ceil esesten en E E EE 182 F 6 30 Largest Integral Value Not Greater than Argument floot 0008 183 F 6 31 Absolute Value of Floating Point Number fabs ccccseeeeeeeeees 183 F 6 32 Multiply Floating Point Number by Integral Power of 2 Idexp 184 F 6 33 Convert Floating Point Number to Fractional and Integral Components ISX easier a naa ai iai 184 F 6 34 Extract Signed Integral and Fractional Values from Floating Point Number mod uu eee eeeeeeeeeeeeeeeeeeseesssesseeeeeeeens 185 F 6 35 Con
46. the long line into two or more lines error M016 Active file filename has a wrong extension name not dt or asm Reason Active file filename extension must be dt or asm Solution Change file with proper filename extension dt or asm error M017 File to be assembled not found Reason Cannot find the file to be assembled Solution Select and provide a file to be assembled error M018 Project file must be created Reason No project is available Solution Open or create a project error M019 Number of opened Editor windows exceeds limit Reason Number of opened Editor windows have reached maximum limit Opening a new one is prohibited Solution Close some of the opened files error M020 No active Editor window Reason The Editor window is not currently selected Solution Select Editor window error M021 Text field must be input with characters Reason The text field cannot be empty Solution Input characters A Assembler Errors Warnings Messages error A001 Cannot find the filename file Reason The file cannot be found in the directory Solution Check whether the file actually exists in the directory error A002 Main and subroutine programs cannot define the label name local label Reason The local label preceded by a dollar sign cannot be defined in the main and subroutine programs Solution Remove the local label from the
47. the next character is saved for the next call to strtok The delimiter string s2 may be different for each call 174 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F E Return Value The strtok function returns a pointer to the next token or a NULL 1f there are no more tokens E See Also strchr strspn strpbrk strstr Sections F 6 6 F 6 7 F 6 8 amp F 6 9 respectively F 6 12 Copy Memory Area memcpy E Synopsis include string h int memcpy void dl void sly int nn E Description memcpy Copy n bytes from memory area s1 to memory area d1 The memory areas should not overlap Use memmove 3 if the memory areas do overlapped see Section 6 13 below E Return Value The memepy function returns a pointer to d1 E See Also strcpy strncpy memmove Sections F 6 3 amp F 6 13 respectively F 6 13 Copy Memory Area memmove E Synopsis include string h int memmove void dl void sl int n E Description memmove Copy n bytes from memory area s1 to memory area d1 The memory areas may overlap E Return Value The memmove function returns a pointer to d1 E See Also strcpy strncpy memcpy Sections F 6 3 amp F 6 12 respectively EM78 Series IDE User s Guide 24BC Standard Library e 175 Appendix F en F 6 14 Compare Memory Areas memcmp E Synopsis include string
48. they were modified or not Figure 3 10a Compilation Commands Note that in Asssembly mode Build and from Project Menu Rebuild All commands will generate objective bbj file list Lst file and binary cds file In C mode both commands will generate objective o file assembly s file and binary cds file 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 from the Output window as shown below Assembling fee binking s OG Erreoriari 0 Warnings 0 Beers d gt Buld 4 Infomation Find in Files Mesage Checking ROM Processed 100 Figure 3 10b Output Window Showing Successful Compilation EM78 Series IDE User s Guide 4BGetting Started e 69 Chapter 3 Double click to link to the source of error re 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 source 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 be opened automatically P testzZ 569 test dt 2 error AO33 The macro is not defined or invalid instruction i Errorfs O Warningis 0 Userfs gt Build 4 Information Find in Files Message _ Figure
49. windows fonts for other windows are fixed View Setting Environment setting Debug Option Set debugger variables options In ICT Setting the dialog shown in Figure 2 16 Customize b elow Figure 2 15 Option Menu Dump ASPCM Dump to Data ROM Accelerate Applies only to USBICE Read Reading Registers registers quickly when frequency is over 2MHz as explained in Section 2 1 7 2 below View Setting Set the eUIDE window view variables as explained in Section 2 1 7 3 below Environment setting Set eUIDE environment variable e g whether list map file is to be created or not and the number of Editor windows to display as explained in Section 2 1 7 4 below ICT Execute ICE test Customize Customize toolbars menus and accelerators See Section 2 1 7 5 below for details 2 1 7 1 Debug Option Setting Set the debugger variables options with the following dialog The options are divided into four blocks as illustrated below Dialog w Dumping code and checking Interrupt disable after break Default breakpoint counter Default break point counter 0 255 i lf default value 0 then show counter dialog else not Show source code in trace log M Step into macro instruction when Debugging Cancel Figure 2 16 Debug Option Setting Command Dialog 48 e 2BThe eUIDE Commands EM78 Series IDE User s Guide Chapter 2 a Dumping codes and checking eUIDE will check the hardware memory before dumping codes
50. 0 3 Consequently the segment values COM R 0 3 will be set according to these defined ERSE ranges 2 Define COM SEG values to 0 and Auto Increase value to 1 3 Point to the segment where the COM SEG value 0 0 is to be applied Click and you should see the segment set as 0 0 4 Observe that as soon as the 0 0 value 1s entered on the segment the Control Pane SEG value is set to Auto Increase by 1 Note that only the value located at the right box SEG value in this case will swap Auto Increase Only the value located in this box will change change 5 Thus there is no need to manually change a gt the COM SEG value when setting 0 1 i i value for the next segment Just directly lt gt click on the segment and the next SEG i value is Auto Increased by 1 om 22 e Introduction EM78 Series IDE User s Guide Chapter 1 6 Due to the fact that the SEG Range is set at 0 1 see Item 1 above the next or 3rd segment you click cannot increase its SEG value to 2 Hence the system automatically allocates the auto increase value of 1 to COM and sets the SEG value back to 0 7 Consequently all you need to do is to SA continuously click on the remaining fh an segments to set their COM SEG values f un within the defined range OF E Other Convenient Functions of the LCD RAM Window In addition to the above other convenient funct
51. 0100 R5 EO wk6 6F uR FO uR E wuR9 CO wRA 00 RE CO RE Ja RD 0F RE oo RF oo Figure 7 8 Register Window Showing Defined Variables 130 e Quick Workout on Tiny C Compiler EM78 Series IDE User s Guide Chapter 7 7 7 4 Reducing Codes Size in Some Cases The defined signed variables and unsigned variables are not the same Using unsigned variable in some particular cases could help in reducing program code SIZe EM78 Series IDE User s Guide Quick Workout on Tiny C Compiler e 131 Chapter 7 132 e Quick Workout on Tiny C Compiler EM78 Series IDE User s Guide CO PAZI Appendix A Appendix A Assembly Error Warning Messages A 1 Introduction Error messages which are displayed in the Build tab of Output window are categorized into 4 classes 1 e Class M Class A Class L and Class D Where Class M error message pops out when the main program is executed incorrectly Class A error message appears on the list when syntax is in errors e g error occurs during assembling Class L error message shows up on the list if a linking errors occurs during a project Build or Rebuild All command execution Class D error message describes the errors of debugging program A 2 Class M Main Program Errors Messages 1 error M001 Number of opened Editor windows exceeds limit Reason Number of opened Editor windows have reached maximum limit Opening a new one 1s prohibite
52. 136 19 14 100 int i i fun 3 return MOV A 0x03 BANK 0 MOV in A CALL FUN MOV A 0x10 BANK 0 MOV i A int fun int in RET return in 1 FUN MOV A 0x14 BANK 0 MOV temp1 A MOV A in MOV 0x14 A MOV 0X10 A MOV A 0X01 ADD 0X10 A MOV A temp1 MOV 0X14 A RET EM78 Series IDE User s Guide 16BC Conversion Table e 147 Appendix B C Statement Description Example Const array const int myConsi 5 1 2 3 4 5 main int i i myConst 3 return Register page unsigned int myR5P0 O0x05 rpage 0 unsigned int myR5P 1 O0x05 rpage 1 unsigned int myR5P2 0x05 rpage 2 myR5P0 0x12 myR5P1 0x34 myR5P2 0x56 148 e 16BC Conversion Table Conversion Rate Compilers Code Size General User s Code Size 100 162 21 13 100 Assembly Code using EM78569 MOV A 0x3D MOV 0x19 A MOV A 0x1F MOV Ox1A A PAGE 0x0F CALL 0x280 PAGE 0x00 BC 0x04 6 BC 0x04 7 MOV 0x20 A BC 0X03 0 RLCA 0x1A TBL PAGE 0x0F JMP Ox2FE MOV A 0x19 TBL RETL 0x01 RETL 0x02 RETL 0x03 RETL 0x04 RETL 0x05 using EM78P468N MOV A 0x12 BS 0X03 6 MOV 0x05 A 100 11 11 100 MOV A 0x34 BS 0x03 6 BC 0x03 7 MOV 0x05 A MOV A 0x56 BC 0x03 6 BS 0x03 7 MOV 0x05 A EM78 Series IDE User s Guide Description I O control page RAM bank Bit data type C Statement Example io unsigne
53. 3 10c 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 the Output window s Information tab if compiling succeeds For example it tells you the 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 characters C in register data location 0x 0 0Ox1 F These C characters tell programmer which and how many common registers to save and restore in interrupt service routine Refer to Section 6 1 Register Page rpage for further details Figure below shows these messages which advice you to save common register 0x10 and 0x11 when MCU has just ran into interrupt service for C system and restore these two common registers before leaving interrupt service Rom Size 24576 Rom Size 00221 O8 Rom Size 24355 100 Ox1lF are reserved for Uninitialized data Initialized data Uninitialized bit data Initialized bit data IO Data 012345 67 8 IND Data Call Depth Interrupt Function Figure 3 10d Output Window Messages after Compiling Successfully 70 e 4BGetting Started EM78 Series IDE User s Guide CO LAN Chapter 3 3 8 Dumping the Compiled Program to ICE Project Wizard With the source files deprived of its errors and successfully com
54. 3 7b Insert Files into Project Dialog Dump to ICE Fa Trace Log Fa Dump code ower 64k to sram Figure 3 7a Add Files to Project Command of Project Menu EM78 Series IDE User s Guide 4BGetting Started e 67 Chapter 3 ae 2 Browse and select the source file or multiple files you intend to insert into the new project 3 Click OK button to insert file into your new project after confirming your selection 3 5 3 Deleting Source Files from Project From the Project window select the file s you wish to delete Then press the Delete key from your keyboard or click Project gt Delete Files from Project Project Wizard Mew 3 EM78569 test apj sovrce Files E testdt Header Files 7 d ls ay Open Project Save Project Close Project Add Files to Project ea List Piles Alt F Shift Alt Fo Rebuild All Alt F9 Map Files E3 Library Files Duma to ICE Fs Trace Log F2 Figure 3 8a Deleting Source Files Directly from Project Window Figure 3 8b Deleting Project Files from Project Menu 3 6 Editing Source Files from Folder Project 3 6 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 1 Click File gt Open command 2 From the resulting Insert Files into Project dialog Figure 3 7b above select and click on the source file
55. C Conversion Table e 145 Appendix B Description For loop While statement Do while statement Do while statement if else statement C Statement Example for i 0 i lt 5 i while cnt 1 while cnt 1 do Var_c2 while var_c1 unsigned int cnt 146 e 16BC Conversion Table Conversion Rate Assembly Code Compiler s Code Size General User s Code Size 100 CLR i 100 7 7 100 INC i MOV A 0x05 SUB A 0x14 JBS 0x03 0 JMP L1 100 4 4 100 MOV A cnt XOR A 0X01 JBS 0X03 2 JMP L1 100 4 4 100 MOV A cnt MOV A 0x01 XOR A 0x01 JBS 0x03 2 JMP L1 L1 100 3 3 100 INC var_c2 DJZ var_c1 JMP L1 MOV A cnt 100 10 10 100 JBS 0x03 2 JMP ENDIF L1 MOV A 0X05 SUB A cnt JBC 0x03 0 JMP ENDIF EM78 Series IDE User s Guide F LAN Description C Statement Example Switch statement unsigned int cnt switch cnt break break default Appendix B Conversion Rate Compilers Code Size General User s Code Size 100 106 18 17 100 Assembly Code MOV A cnt MOV 0X14 A MOV A 0X14 XOR A 0x01 JBC 0X03 2 JMP case 2 MOV A 0X14 XOR A 0X02 JBC 0X03 2 JMP case 2 MOV A 0X14 XOR 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 using EM78806B Function main
56. Debug Tool Option IDE Window Help Figure 2 1 eUIDE Menu Bar 2 1 1 File Menu New New fa Open Ctrl C Close Open lal Save Ctrles Save 4s Close G Save All Save pen Project Save Project Save As Close Project Save All Print Print Preview Open Save Close Project Print Setup Print Recent Projects Print Preview Exit Print Setup Figure 2 2 File Menu Recent Files Recent Projects Exit EM78 Series IDE User s Guide Create a new project or source file see Section 3 4 1 for details 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 opened file s View the record of the recently opened project Exit from eUIDE Program 2BThe eUIDE Commands e 31 Chapter 2 2 1 2 Edit Menu Select All Ctrl s Go to Line Ctrl G Formation Selection Alt F8 di Find Ctrl F g Find Next Ctr A Find Previous Ctrl P lea Find in Files Replace Ctrl H BookMarks Index BookMarks Go To Index BookMarks Figure 2 3a Edit Menu Find Previous Find in Files Replace Bookmarks Toggle Bookmark 4 Previous Bookmark H Next Bookmark Clear All Bookmarks Figure 2 3b Bookmarks Sub M
57. EM78 Series Wiifey eyexve line i 2 E gt INTEGRATED DEVELOPMENT ENVIRONMENT USER S GE ELAN MICROELECTRONICS CORP May 2010 Trademark Acknowledgments IBM 1s 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 2009 2010 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 Microelec tronics 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 eUIDE 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
58. IG void ctestl 017 018 019 020 021 022 023 024 025 026 027 028 uchar temp abc 0x23 def 0x39 P6CR 0x60 P6PH 0x80 WDTCR 0x00 temp PORT6 ENI WUCR O0x0d IMR 0x60 029 SLEP 030 031 etest2 _asmfeni _asm slep _asm nop unsigned char 47 47 wat disal read por Lr Z AE re void _intcall ALLInt void int switch IntVecIdx case 0x4 ISR s OxF7 Write interrupt service code here RS7 R57 break case Ux f fWrite your code inline assembly or C here break case Oxd f fWrite your code inline assembly or C here break case OxD f fWrite your code inline assembly or C here break void _inteall tee _ l void fa OxO3 low_ int 0 _asm MOV 4 0x2 032 Figure 7 5a Writing Initial Code PAGE ROXO void _intcall intO l void a OxO6 low_int 1 _asm MOV A 0x2 Register usage status 0x10 need to be saved amp restored Rom Size 4096 Rom Size 0155 3 Rom Size 3941 97 Data Map Ox1lF are reserved for C Compiler Total Program ROM Used usage status ciara Register or RAM usage data type Uninitialized data Initialized data Uninitialized bit data Initialized bit data RAM data usage status Call Depth Depth Interrupt Function ProgramsStart _teec_l _tee _int0_1 _int0 _intl_1 inel _counterl 1 _counterl _counter2z 1 _counter2 _highpulse 1 _highpulse _lowpulse 1
59. In Example 3 with EM78567 you also cannot use 0x10 nor declare IntVecIdx as the hardware has only a single interrupt vector Moreover the MCU cannot auto save nor restore register too You have to note that some MCUs require reti instruction in the first line to tell compiler to restore inline assembly right after the reti line Without reti the compiler will automatically restore inline assembly at the end of the Interrupt Service Routine function reti must be placed as the first order in restoring inline assembly 6 10 3 Reserved Common Registers Operation Compiler saves the common registers 0x1 1 0x1F which the Compiler uses Note the usage of reti instruction in restoring inline assembly in some MCUs see Example 3 below Example 1 EM78P510N This MCU saves and restores ACC R3 and R5 during interrupt execution Note that this particular MCU has more than one interrupt vectors extern int IntVecIdx occupied 0x10 rpage 0 void _intcall AllInt void int switch IntVecIdx case 0x4 write interrupt vector 0x3 in this case break 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 O0xC in this case break case 0x10 write interrupt vector OxF in this case break case 0x13 fwrite interrupt vector OUxi2 an this case break case 0x16 write interrupt vector 0x15 in this
60. Project 3 4 1 Using the Project Wizard Project gt Project Wizard The project wizard consists of several dialogs which will walk you through a step by step setting up of your project Step1 Select a controller Step2 Select controller Code Option Step3 Create a new project Set Project Name and Type Step4 Add a new file or an existing file to your project Step5 Summary 60 e 4BGetting Started EM78 Series IDE User s Guide Chapter 3 Step 1 Select a controller Select a controller for your project from the list the click Next button Step 1 Select a controller EM78P1410CE143 aa g N EM78P1420CE341H S0x8 EMTSP143 1CE143 aCe EM7SP1534 1CE1539 3248 EMIEE1SSc1CE1 Sos aoe EM7SP 1 54N 1CE159 Mees EM7SP1541N ICE159 Or S TEMTEP15S6EL ICE4565 and exit Wizard m79P1S6N CE456B EM7SP1 57N ICE456E After setup is done EM ePlooN UEL OY click this button to avec CE1O3N ICEIGANY go to next step EM7SP2IONACEZION TCTHTODANOR TO EC OATS g g v ones a 0009 nn on on on on un 45 S55 S53 5555 Tee SSS SSS Click this button to return to previous step Figure 3 4a Project Wizard Step 1 of 5 Dialog Step 2 Set controller Code Option If the controller does not require Code Option setup skip this dialog Step 2 Select EM 8PT535 ICE1535 Code Option Ep met up Time 18 ms e 4 High Crystal Internal EC RESETENABLE Dis
61. SI standard 1s limited to free standing C to accommodate the unique design characteristics of the EM78 Series microcontrollers 3 2 Hardware Power up With the ICE properly connected to target board PC and power source switch on ICE power and observe its red power LED lights up Ifthe target board derives its power from ICE the yellow LED lights up as well Then launch your eUIDE IDE software when ICE and target board power up is confirmed to function normally 3 3 Starting the eUIDE Program To start eUIDE Program click on the eUIDE icon from desktop or from Windows Start menu When starting from the Start menu click Programs then look for eUIDE group and click on eUIDE icon 3 3 1 Connect Dialog A MCU selection 1 filter Select MCU Filter Micro Controller M 8P468N ICE 468 Select connecting mode ex p153 Connecting Port USE C LR LPT Port address Check ICE memory __ WO Wait Times a l Long Delay Time ae condition option Check ICE Memory Printer port Figure 3 2 eUIDE Program Connect Dialog 58 e 4BGetting Started EM78 Series IDE User s Guide Chapter 3 Once the program is started the main window of the program will initially display the Connect dialog figure above to prompt you to set the proper connection between your existing target microcontroller and connecting port Where Filter Key in the last 3 digits of the desired target IC for example 159 The Micr
62. _Add to Watch adi at shortcut keys CTRL x where x Toggle Bookmark 4 Cit 4 Toggle Bookmark 5 Ctrl Toggle Bookmark 6 Ctri 6 Toggle Bookmark 7 Ctrl 7 Toggle Bookmark 8 Ctri 8 Toggle Bookmark 9 Ctrl 9 to be assigned index number 0 9 Figure 1 31 An Example of Lines Book marked at Lines 1 5 amp 8 8 e Introduction EM78 Series IDE User s Guide The figure at right shows bookmarked Lines 5 amp 7 are embedded with Index amp 7 respectively Chapter 1 Figure 1 3 An Example of Indexed Book Markes at Lines 1 amp 7 Go To Index BookMarks Go to a particular index bookmarked line From shortcut menu click Go To Cut Shift Delete Copy Ctrl C Index BookMarks Then from the Paste Ctrl V resulting submenu click on the Previous Position indexed bookmark number you want BookMarks access You can also directly press the Index BookMarks b Go To Index BookMarks gt Go to Bookmark 0 Alt 0 Go to Bookmark 1 Alt 1 Go to Bookmark 2 Alt 2 shortcut keys ALT x where x 57eur aiota to Bookmark 4 4 the target bookmark index Number 0 9 Go to Bookmark 6 Alt 6 Go to Bookmark 7 Alt 7 Go to Bookmark 8 Alt 8 Go to Bookmark 9 Alt 9 Figure 1 3k An Example of Accessing Indexed Bookmark Line 5 Go to Label of Find the location of the displayed label or function in the EM78 Series IDE User s Guide file eUIDE will automatically pinpoi
63. able Using ICE Disable OC Target Power WATCHDOG EC OUT C C E e C a Figure 3 4b Project Wizard Step 2 of 5 Dialog EM78 Series IDE User s Guide 4BGetting Started e 61 Chapter 3 Selecting Create a project Step 3 Create a new project Set Project Name and Type with file option and clicking on Next button will directly The controller is EMT8P349N CE249N jump to the next step Step 4 Add a new file or Project Setting an existing file to your Project Name project see below A Create an empty project Asm Test A l Location Selecting Create an empty project option and CABM 78 Test 1534 clicking on Next button will directly jump to Summary Project Type Library Output dialog Step 5 Acembler Nonnal eds Gie C Library ib Figure 3 4c Project Wizard Step 3 of 5 Dialog Enter a project name browse or create folder to save the new project and the project type ASM or C for your new project To set the directory o Type in the path to an existing directory or to a new directory and click the Next button You will be prompted directly to Step 4 to enter the directory o Click to browse to an existing directory or to one level above where you wish to place a new directory Otherwise complete the path if you are creating a new directory and then click Next You will be prompted to create the directory if it does not exist E To
64. activate and place in front of the Editor window to perform editing Highlighted filename is the active file function is similar with taskbar buttons under Windows Double clicking on opened file icon in the Document bar will close the active document EM78 Series IDE User s Guide Introduction e 29 Chapter 1 en DOS _ OVR CaP NUM SSCRL_ R W flag 1 2 4 3 Status Bar Keyboard mode Cursor position o Li 8 Col 5 Text file OS format Running indicator Figure 1 14 eUIDE Main Window Status Bar A eUIDE 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 Num Lock key NUM is dimmed when the numeric keypad calculator mode is off highlighted when on Scroll Lock key SCRL is dimmed when cursor control mode is off highlighted when on 30 e Introduction EM78 Series IDE User s Guide Gen Chapter 2 Chapter 2 The eUIDE Commands 2 1 eUIDE Menu Bar and its Menu Commands a Fille Edit View Project
65. address has no code Reason The target address of jump instruction has no code D Debugger Error Messages error D001 The ICE memory is in error Reason The ICE SRAM is in error Solution Change the ICE SRAM error D002 CDS size number does not match with ROM size number Reason The CDS size is not the same as the ROM size Solution Check the project target microcontroller type to see whether it is the same type as the eUICE system defined microcontroller EM78 Series IDE User s Guide 14BAssembly Error Warning Messages e 141 Appendix A 3 10 11 en error D003 The project MCU type type name does not match with ICE name ICE Reason The project target MCU is not compatible with the eUICE system development tool MCU Solution Create a new project or change to compatible ICE error D004 A line from the file does not convert to machine address Reason The program line failed to assemble Solution Check the syntax of the program line for error error D005 The breakpoint group number is over 64 Reason The breakpoint group number is over 64 Solution Remove the extra breakpoint groups error D006 The ICE is not properly connected to PC Reason Interface between ICE and PC failed Solution Check power supply ICE crystal printer port USB connection etc error D007 The printer USB port is not connected Reason The printer USB port is not connected
66. aggdgadgadgadga A amp amp te Address Type Value REGISTERRS 0x05 Register 1 0x00 Figure 2 18d View Setting Showing the Appended Definite Variable roage Displayed in the Watch Window e Show Unreferenced variable when enabled the build assemble code will check and determine whether the variables were utilized or not EM78 Series IDE User s Guide 2BThe eUIDE Commands e 51 Chapter 2 f Show defined label in Register Window Enable after Dump When enabled Register name are displayed as label name in the Register Window Ifthe label name length is over 6 characters Register name will display the first six characters and tooltip displays complete name When disabled the Register name will appear as initial name in the Register Window g Show program Rom show the program code in the Program Rom sub window of Output window 2 1 7 4 Environment Setting Set the eUIDE environment variables e g whether LIST MAP file is to be created or Create Map File not and the number of Editor windows to display Recent File List Recent Project List a Create List file If selected the LIST file is created after Following are for EM78815 the related project is Iver G assembled The LIST file will include line number address program code and source file 2 Cancel b Create MAP file If enabled the related LIST file is created after linking to a project The MAP fil
67. am 6 8 1 Reserved Word The reserved words for the inline assembler are _asm sate write assembly code here All the assembly instructions in upper or lower case of the EM78 series are supported EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 115 Chapter 6 6 8 2 Use of C Variable in the Inline Assembly The Compiler allows you to access the C variable in the inline assembly as follows mov a lt variable name gt move variable value to ACC mov a lt variable name gt move address of variable to ACC Example 1 asm Save procedure of rpage iopage and bank register mov a 0x3 mov snbuf a mov a 0x04 mov snbuft l a be 0203 7 bs 0x03 6 Switch to other rpages Restore procedure of rpage iopage and bank mov a register mov 0x03 a mov a snbuf 1 mov 0x04 a 116 e 10BC Control Hardware Related Programming EM78 Series IDE User s Guide Chapter 6 Example 2 int temp temp 0x03 assume temp is at 0x21 of bank 0 _asm mov a Stemp move value 0x03 to ACC _asm mov a stemp Ji MOVe address Cx7i to ACC Example 3 unsigned int temp_a 0x20 bank 0 unsigned int temp_s 0x21 bank 0 define status 0x03 void main _ asm mov tempa a gt mov 0x20 a mov a status gt mov a 0x03 mov temp_s a gt mov 0x21 a 6 9 Using Macro You can use macro to control the MCU and shorten the program length Exampl
68. ancel Figure 3 6a New Dialog Showing Create a New File Tab for Creating a New Source File 2 Select Add to Project check box default if you want to automatically add the new file into your project Otherwise clear the check box 3 Assign a filename for the new source file in the File Name text 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 66 e 4BGetting Started EM78 Series IDE User s Guide Chapter 3 void main _asm MOV A 0x10 void _intcall interrupt void int Write your code inline assembly or C here _intcall interrupt_l void Ox06 low_int QO _asm PAGE 0x0 Figure 3 6b Typical Interrupt Function 3 5 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 gt Add Files to Project The Insert Files into Project dialog is then displayed STED O 569 ef 23 569_bp_rmkdt E 569_new_rmk dt 3 569_rmk dt Eltesteode asm New Open Save Close Add Files to Project Delete files tom project RAB bat IRAT Source Files dt asm AYA j a2 Assemble Alt F7 3 Altera Figure
69. and RAND MAX srand Set its argument as the seed for a new sequence of pseudo random integers to be returned by rand These sequences can be repeated by calling srand with the same seed value If no seed value is provided the rand function is automatically seeded with a value of 1 E Return Value The rand function returns a value between 0 and RAND MAX The srand returns no value 186 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F F 6 38 Compute the Absolute Value of an Integer abs labs E Synopsis include stdlib h Int abe ane J long labs long int J E Description Coe 99 abs Compute the absolute value of the integer argument J 66 99 labs Compute the absolute value of the argument J with the appropriate integer type for the function E Return Value Return the absolute value of the integer argument with the appropriate integer type for such function E See Also ceil floor fabs Sections F 6 29 to F 6 31 respectively F 7 Application Notes E The EM78 C Standard Library is applicable only to c project The EM78 C support 24 bits float double type Float double type 1 sign bit 7 bits exponent 15 bits mantissa Because the mantissa s bit resolution 1s reduced the precision will be downgraded E You must take precautions of possible problems on float overflow and underflow EM78 Series IDE User s Guide 24BC Stand
70. apter 1 re E Interacting with Editor Window The figure below shows a typical Editor window displaying contents of an opened source file 447test dt Assembly keywords are shown in blue comments amp comments symbol are in green values are in brown and the rest are shown in black RIO Uxll rpayge rineclude 44 test h org gfff jmp sl org 0x00 sl ele Delt elt Uziz gai ing Pel me Uziz jmp sz Figure 1 3b Editor Window Displaying Contents of an Opened Source File 447test Dt Right click anywhere within the Editor window to display an Edit shortcut menu shown at right exclusive for Editor window application ay Cut Shift Delete Copy Ctrl Ey Paste Ctrl Note that most of the shortcut menu commands are also available from the Edit menu of Menu Previous Position Bar Each command in the shortcut menu functions as BookMarks follows Index BookMarks Cut Removes the selected text from current Go To Index BookMarks location and move paste it into another Go to Label location 4dd to Watch First select the desired text range you want to move and then right click within Figure 1 3c Edit Shortcut Menu the selected text With the shortcut menu fOr EGHOR WINGOW on display click Cut command from the menu The selected text are then removed from the Editor window as demonstrated in the following figures and temporarily stored in the clipboard Proceed to paste the text i
71. ard Library e 187 Appendix F an E To avoid space from overflowing when using ram do not make the float expression too complex For example Float x y z result Result x 3 5 y z 5 3 The above float expression may cause the ram space to overflow Suggest to revise expression as follows Float x y x tmp result Result x 3 5 Result y Result z Result 5 3 188 e 24BC Standard Library EM78 Series IDE User s Guide
72. b window may be displayed or hidden by clicking on the pertinent window commands from the View menu see Section 2 1 3 1 2 2 1 Project Window The Project Window consisted of two view modes namely File View mode and Label Function View mode E File View Mode The Title Bar of the Project window shows your current microcontroller and project filename Project Filename apj or cpj in C mode l The Project window holds the Source E N a lt EM78p468N gt C Header List and Map files Target 3Source Files Microcontroller A TestReg DT Where Header Files Source Files dt List Files A TestReg 1st are the assembly source files that are added SLibrary Files into the current project In C mode source amp Map Files file will be c file Header Files ive are the reference files required by source Figure 1 2a Project Window in program File View List Files st are the list files Map File map are the map file Library File bbj are the reference files required by source program After you have opened or created a project click on the selected folder to expand and browse its contents Then right click on the selected file to display its shortcut pop up menu Click on the selected Right click on the selected folder to expand and file to display its shortcut browse its contents pop up menu Project Figure 1 2b Accessing the Supporting Files from Projec
73. bly USER MESSAGE set bank to 0 EM78 Series IDE User s Guide 6BAssembler and Linker e 85 Chapter 4 en m current program counter value is used as an operand Examplel jmp imp means to jump at same line as dead loop Example2 be 0x04 6 jmp 1 imp 1 means to jump back to be 0x04 6 4 6 Conditional Assembly a IF Ifthe statement after IF expression is true then the following instructions are assembled until ELSEIF or ELSE or ENDIF Syntax IF lt expression gt lt statements1 gt ELSEIF lt expression gt lt statements2 gt ELSE lt statements3 gt ENDIF Example org 0x00 bank macro num if num 0 bc 0x04 6 be 0x04 7 elseif num 1 bs 0x04 6 be 0x04 7 elseif num bc 0x04 6 bs 0x04 7 elseif num bs 0x04 6 bs 0x04 7 else message error bank num over max number endif endm 86 e 6BAssembler and Linker EM78 Series IDE User s Guide oll Chapter 4 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 c IFDEF If the statement after IFDEF label is defined then the following instructions are assembled until ELSEIFDEF or ELSE or ENDIF
74. breakpoint counter in the text box A breakpoint will be set to all addresses within the specified start and end address range The figure example below shows 0X01 0X04 OX01 which means breakpoints are set to all addresses between OXO1 and 0x04 and break counter is set at 1 thereby allowing a termination break on one passing c Click OK button to save the settings You should see the group breakpoints indicated in the Editor window or as shown in the example figure at right d Click Go command Debug gt Go to see the steps and result of the code execution as shown in the figure at right e Breakpoint or Select this option to set breakpoints at one or more address locations with a counter number a Select the Breakpoint or option Breakpoint or b Enter the breakpoint address es and counter in the format breakpointAddress1 0x00 0x02 0X04 0 01 breakpointAddress2 counter This means that a breakpoint will be set at locations 0x01 0x02 and 0x04 with the counter set to 1 c Click OK button to save the settings You should see the group breakpoints indicated in the Editor window or as shown in the example figure at right EM78 Series IDE User s Guide 2BThe eUIDE Commands e 41 Chapter 2 d Click Go command Debug gt Go to see the steps and result of the code execution as shown in the figure at right e Breakpoint nest Select this option to set ne
75. case break case 0x19 write interrupt vector 0x18 in this case break EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 119 Chapter 6 re case Ox1C write interrupt vector O0x1B in this case break User also can use if else if if IntVecIdx 0x4 else if IntVecIdx 0x7 else if IntVecIdx 0xA else if IntVecIdx 0xD else if IntVecIdx 0x13 j else if IntVecIdx 0x10 f else if IntVecIdx 0x16 i void intcall TCC Livoid 0x03 low int 0 n A 0x2 using LJMP to interrupt service procedure ae santcall ExtInt 1 void 0x06 low_ int 1 T Apka J oe intcall WatchTime_l void Ox09 low_int 2 a A 0X2 a _intcall Timel_l void 0x0C low_int 3 o ApUk2 T a intcall Time2 l1 void Ox0OF low_int 4 Seana yin Op aaa ar RT _intcall ADC_1 void 0x12 low_int 5 n A 0X2 a intcall UART_1l void 0Ox15 low_int 6 Sento A 0X2 a _imtcall SPI 1 void Oxle low_int 7 E A 0X2 aa _intcall LVD l void Ox1B low_int 8 No A 0X2 120 e 10BC Control Hardware Related Programming EM78 Series IDE User s Guide Chapter 6 Example 2 EM78569 Note that this particular MCU has only one interrupt vector This MCU saves and restores ACC R3 and R5 during interrupt execution eUIDE will tell Compiler to save and restore R4 void main _asm MOV A 0x10 enable bit 4 CONT CONTW void _intcall int
76. cetc eee 34 Me POPE CRIN Ci a E E EAA torent sanentces 35 2 1 4 1 Executing Dump code over 64K to sram Command 36 EM78 Series IDE User s Guide e iii Contents 2 1 5 Debug Menu 2 1 5 1 Run From Command Sub Menu Function Description 38 2 1 5 2 Address Breakpoint Dialog Function Description 38 DO TOC N spices satec gussets ancien E rsactceutsatbaedasteaguovseas 44 2 1 6 1 Computing Execution Time cccccccccceceececeeeeeeeeeeeeeeeeesseeeees 44 2 1 6 2 Moving Data from File to SRAM Applicable to EM78815 omly ccccccccccccccccceeceeceeeeeeeeeeeseeeeeeeeees 45 AET OPON M 01 eee ar AA ner eee re ere mene eee reer nner eee 48 26741 Debug Option Setting ince dosscrencncnctecoteeeseenaesonestoononeeecsedeemeatensatesaces 48 214 12 Accelerate Reading RegistenS seseris nre 50 Meh VIC E a T E EAE E EE 50 BM TO NGS CU NNO a E E 52 Baka OA a E E E 53 DN WOW N e E siectsecues toa soevessaeeasuyscencsies 55 AP Ue os 10 98 12 a ee ve ee 56 3 Getting Started 57 A I Vy a E E E nace oee toast ace haetcarens 57 Dalek SyS E REGE MINS e E EE 57 Dal DONNA e a aO ea ES 57 ILI ANS Compa biiy eeens eR a E ae ai RRi 58 o E ATC Fr OW CID E E EEE T 58 3 Sarine the eUIDE Programi eee ne nn a E E 58 a Ca e ol B11 6 e E E A 58 Sad KCO O ea noc esteceniencanedalGasac eaencneosaonueieneaneosioses 59 332 Code 0 510 18D U1 3 oe een een ne eni E OSEN er
77. ck the Select an existing ae eer ne File button The Insert Files E cTest cml pj E CTest_new_rmk dt E test2 into Project dialog figure at a gt right will open The default filename SS folder will display in the File ticsctype EEN l O E Location text box as shown in the Figure 3 4d above Figure 3 4e Insert Files into Project Dialog EM78 Series IDE User s Guide 4BGetting Started e 63 Chapter 3 Step 5 Summary The File Name is Tet 53 4 Create generally pro twill generate lies bbp file Let let file binary Mods file after build project Figure 3 4f Project Wizard Summary Dialog Double check the summarized setup information on the Summary dialog If further correction is needed click Back button to return to the particular dialog you need to change the setting Otherwise click Finish button to complete the new project creation 3 4 2 Using the New Command File Project gt New To create a new project with the New command from the Project menu follow the following steps 1 From the Menu bar click File or Project and choose New command from the resulting pull down menu see figure at right 2 The New dialog under Projects tab shown below for will then display after clicking the New command from the File menu or Project menu 64 e 4BGetting Started EM78 Series IDE User s Guide Chapter 3 S
78. conform to ELAN object file format Reason The object file format does not agree with ELAN object file format Solution Reassemble the source file 4 error L004 Symbol symbol name is not defined Reason The symbol is not defined Solution Define the symbol 140 e 14BAssembly Error Warning Messages EM78 Series IDE User s Guide 10 11 A 5 Class l Appendix A error L005 Public symbol symbol name is in conflict Reason The public symbol is defined more than once Solution Redefine the public symbol error L006 ROM address number is in conflict Reason The program address is in conflict with another address Solution From Menu Bar click Edit gt Find to find the other conflicting address in the list file then update the address of the program position error L007 The file filename cannot be created Reason The file cannot be created Solution Check whether the disk is full or whether the system is unstable error L008 Line number The machine address number exceeds ROM size number Reason The program address size exceeds the ROM size Solution Decrease the program code size error L009 No project file is active Reason No project is opened Solution Open or create a project error L010 No Output window is found Reason Output window is not opened Solution Click View gt Output to display the Output window Warning L020 The target
79. d E 2 Assembly Library The Assembly library can only use absolute addressing Because of the assembly assembler limitation it cannot relocate the addresses You have to write org OxXXX clearly in front of the assembly source file when writing assembly library But you do not need to write the address definition when you use the pseudo instructions XCALL XJMP instead of all CALL JMP instructions in the assembly library source codes EM78 Series IDE User s Guide 22BLibrary Application Notes e 163 Appendix E 164 e 22BLibrary Application Notes EM78 Series IDE User s Guide Appendix F Wan Appendix F C Standard Library F 1 Character Class Tests ctype h F 2 String Functions string h EM78 Series IDE User s Guide 24BC Standard Library e 165 Appendix F am F 3 Mathematical Functions math h F 4 Utility Functions stdlib h 166 e 24BC Standard Library EM78 Series IDE User s Guide k m Appendix F F 5 Others F 5 1 Variable Argument Lists stdarg h F 5 2 Limits limits h and float h E limits h define the following symbols EM78 Series IDE User s Guide 24BC Standard Library e 167 Appendix F ram E float h define the following symbols F 6 Manual of Functions F 6 1 Character Classification Routines isalnum isalpha iscnitrl isdigit isgraph islower isprint ispunct isspace
80. d Solution Close some of the opened files 2 error M002 Memory not enough to accommodate Editor Window Reason Remaining system memory size inadequate to meet Editor window requirement Solution Close opened files or application programs that are idle 3 error MOO3 File filename already existed Reason The filename has already been created and cannot be created again Solution Rename and save again 4 error M004 File filename cannot be created Reason The application is notified that the file cannot be created by O S Solution Check whether the disk is full or whether the system is stable or otherwise EM78 Series IDE User s Guide 14BAssembly Error Warning Messages e 133 Appendix A Gan Reason Only one opened project is allowed at a time by eUIDE 5 error M005 A project is currently opened Solution Close the existing project before opening another one 6 error M006 Project filename cannot be created Reason The application is notified that the project cannot be created by O S Solution Check whether the project is empty or not 7 error M007 The file filename already existed in the project Reason The file has been included in the project Solution Stop trying to add the file into the project 8 error M008 File filename cannot be saved Reason The file cannot be saved in the disk Solution Check whether the project is empty or no
81. d then process to move Big52 bin into external SRAM by setting Data Begin Address as 393 216 Length at 131 072 and the Big5 bin folder as Binary file name The moved data will be located from address 393 072 to address 524 287 It is highly recommended to complete moving partitioned data in one successive process E Dump Code to External SRAM If your program code is over 64K words click Project gt Dump to ICE F3 to dump program code to ICE eUIDE will process and check code that is under 64K words If your program code is less than 64K words eUIDE will not process dumping to external SRAM as discussed in Section 2 1 7 4 If your code is over 64K words eUIDE will dump the code into external SRAM It usually takes about 45 seconds to completely dump the code of 64K words Actual dumping time is dependent on the code size over and above the 64K words You can enable the External Code checking checkbox in Environment setting Dialog see Section 2 1 7 4 to check dumping process and result It is highly recommended to enable the External Code checking option during the first dumping and disable it when repeating to dump the same file to save another about 40 seconds EM78 Series IDE User s Guide 2BThe eUIDE Commands e 47 Chapter 2 re 2 1 7 Option Menu ICE Code Setting ICE Code Setting Set code option for the selected Font microcontroller Debug Option Setting A e Font Define font for Editor
82. d One Header File EM78 Series IDE User s Guide Quick Workout on Tiny C Compiler e 125 Chapter 7 ae 7 5 The Main Interrupt Save and Service Routine Functions The following Figure 7 4 shows part of the service routine Only one main function can exist in a C mode project Usually you do not need to modify the saved and restored R4 R3 ACC or R5 registers in the file that eUIDE supplies However for precautionary reason it is recommended that you check whether the saved or restored locations are at the same ram bank In this particular example case MCU EM78P468N hardware saves the ACC and R3 registers before executing the interrupt service routine and restores them when the interrupt service routine is completed Refer to EM7SP468 8 Bit Microcontroller Product Specification So R4 need to be saved and restored by eUIDE C compiler Inline assembly is used to perform save and restore processes refer to Section 6 8 Inline Assembler Saving and restoring of ACC R3 R4 or R5 means saving and restoring the MCU hardware In addition to saving and restoring MCU hardware in some cases you also need to save and restore C system Some calculations outside interrupt service routine in C Compiler do not only use ACC the declared register or ram They also use some of the common registers 0x10 0x1F as well The interrupt service routine also uses these common registers You need to confirm that these common re
83. d error Reason The format of the configuration file 1s not correct Solution Setup eUIDE software again error A032 The file filename cannot be opened Reason The file cannot be opened Solution Check whether the file actually exists or misplaced error A033 The macro is not defined Reason The macro name is not defined Solution Define a new macro or change a macro name error A034 The expression cannot be calculated Reason The format of the expression is in error Solution Modify expression to correct the format error A035 The operation operation name is not defined Reason The operation is not defined by eUIDE Solution Check the eUIDE user menu error A036 The PUBLIC or EXTERN label label name must be address label Reason The label defined by PUBLIC or EXTERN instruction is not an address label as required Solution Remove the PUBLIC or EXTERN instruction error A037 The operand value cannot be calculated Reason The operand expression format is not correct Solution Correct the operand expression error A038 The symbol symbol name is not extern symbol Reason The symbol is not defined as internal or external as required Solution Redefine the symbol accordingly error A039 The reference number is over the number limit Reason The reference number in the PUBLIC or EXTERN instruction is over maximum limit Solution Pa
84. d fractional part each of 66 99 which has the same sign as x The integral part is stored in y E Return Value The modf function returns the fractional part of x E See Also Idexp frexp Section F 6 32 amp F 6 33 respectively F 6 35 Convert a String to a Float atof E Synopsis fineclude stdlaiby h itlo at atori char nptr E Description atof Convert the initial portion of the string pointed at by nptr to float The behaviour is the same as SCrtCoditnptr Char NULL except that atof does not detect errors E Return Value The converted value E See Also atoi atoll Sections F 6 36 EM78 Series IDE User s Guide 24BC Standard Library e 185 Appendix F en F 6 36 Convert a String to an Integer atoi atol E Synopsis Finclude stdlib h ine 2coOL char se long atol char s 7 E Description atoi Convert the initial portion of the string pointed at by s to int However atoi does not detect errors atol Behave the same way as atoi except that they convert the initial portion of the string to their return type of long E Return Value The converted value E See Also atof Sections F 6 35 F 6 37 Random Number Generator rand srand E Synopsis include stdlib h int rand void void srand unsigned int seed E Description rand Return a pseudo random integer between 0
85. d int mylO6P0 O0x06 rpage 0 io unsigned int mylO6P1 Ox06 rpage 1 io unsigned int mylO7P1 0x07 rpage 1 mylO6P0 0x00 mylO6P1 OxFF mylO7P1 0x55 unsigned int myData1 0x20 bank 0 unsigned int myData2 0x21 bank 0 unsigned int myData3 0x21 bank 1 myData1 1 myData2 2 myDatas3 3 bit myBOR6PO0 0x06 0x00 rpage 0 bit myB2R6P0 0x06 0x02 rpage 0 myBOR6P0 1 myB2R6P0 myBOR6P0 EM78 Series IDE User s Guide Assembly Code using EM78569 MOV A 0x00 BC 0x03 5 IOW 0x6 MOV A 0xFF BS 0x03 5 IOW 0x6 MOV A 0x55 IOW 0x7 using EM78569 MOV A 0x01 BC 0x04 6 BC 0x04 7 MOV 0x20 A MOV A 0x02 MOV 0x21 A MOV A 0x03 BS 0x04 6 BC 0x04 7 MOV 0x21 A BS 0x06 0 BC 0x06 2 JBC 0x06 0 BS 0x06 2 Appendix B Conversion Rate Compilers Code Size General User s Code Size 100 100 8 8 100 100 10 10 100 133 4 3 100 16BC Conversion Table e 149 Appendix B yT Conversion Rate Assembly Code Compilers Code Size General User s Code Size 100 146 35 24 100 C Statement Description Example indir unsigned myData1 0x30 ind 0 indir unsigned myData2 Ox05 ind 1 using EM78 amp 806B MOV A 0x55 MOV 0x1B A MOV A 0x30 MOV 0x18 A MOV A 0x00 MOV 0x19 A MOV A 0x00 MOV 0x1A A MOV A 0x1B CALL INDIR MOV A 0xAA MOV 0x1B A MOV A 0x05 MOV 0x18 A MOV A 0x00 MOV
86. ded Global Interrupt Vector Index variable IntVecIdx declare IntVecIdx as global integer e g extern int IntVecIdx and IntVecIdx will occupy 0x10 Therefore you cannot declare or use 0x10 anywhere in project If you try to use 0x10 the Compiler will not be able to warn you but the program will run into wrong result 6 10 1 Interrupt Save Procedure void _intcall lt function name gt _I void lt interrupt vector address gt low_int lt interrupt vector number gt You have to write MOV A 0x2 first in the inline assembly code see Example 1 below 6 10 2 Interrupt Service Routine void _intcall lt function name gt void int The lt interrupt vector number gt is skipped in TCC2 interrupt service routine as there is only one interrupt service routine function available The Example below shows EM78P510N has more than one interrupt vectors With this MCU you can write interrupt service routine code in each case relative to interrupt vector The case and interrupt save procedure that are not going to be used can be marked accordingly 118 e 10BC Control Hardware Related Programming EM78 Series IDE User s Guide Chapter 6 In Example 2 EM78569 is shown without employing 0x10 and declaring IntVecIdx as the MCU has only a single interrupt vector However the hardware is able to auto save and restores registers ACC R3 amp R5 The TCC2 C Compiler auto saves R4
87. dix C 160 e 18BFrequently Asked Questions FAQ EM78 Series IDE User s Guide au Appendix D Appendix D UICE Hardware Description D 1 UICE USB and its Major Components Functions SPS PEE 5 a s a a oO e Figure D 1 EM78 Series UICE Main Board EM78 Series IDE User s Guide 20BUICE Hardware Description e 161 Appendix D Component Function USB B type connector connects to PC DC power adaptor connector and switch supports all ICE power needs ROMLESS program data bus connector connects to ROMLESS board Power select jumper Close system will work in 5V Open system will support 3 3V OEO ROMLESS program address bus and relative control signal connector connects to ROMLESS board C8051 ISP port connects to PC through C8051 ISP download cable to update UICE firmware System power LED display UICE free run LED display D 2 Special Note on eUIDE Software and UIT660N eUIDE version 1 00 13 and later supports UIT660N It does NOT support IT660N eUIDE version 1 00 12 and previous versions supports IT660N It does not work on UIT660N 162 e 2OBUICE Hardware Description EM78 Series IDE User s Guide a Appendix E Appendix E Library Application Notes E 1 C Library The C library cannot be called by the assembly project At the same time the assembly library cannot be called by the C project Because of the linker limitation this function cannot be provide
88. e define SetIO portnum var asm mov a var asm iow portnum define SetReg reg 3 asm mov a 3 asm iow portnum Macro SetReg will encounter error if constant is used as argument EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 117 Chapter 6 ae 6 10 Interrupt Routine In TCC2 the following three factors have to be taken into account in handling interrupts 1 Interrupt Save Procedure the procedure to save some registers before 2 3 executing a service routine Many new MCUs are now designed to save the important registers like ACC R3 R4 or R5 as interrupt occurs and restore them before it quits interrupt service Moreover TCC2 C Compiler under eUIDE can also saves and restore these registers In case both MCU and TCC2 do not provide the said registers eUIDE will automatically supply them when a new template file 1s added into the new project An MCU provides more than one interrupt vectors To determine which interrupt is in use you have to save the Register 0x2 PC to ACC The TCC2 will then use the PC value to determine which interrupt vector source is being utilized Interrupt Service Routine is the act taken to perform an interrupt You need not care how many interrupt vectors there are You only need to write the interrupts service code in the routine and switch case or if else if to determine which interrupt vector source is nee
89. e ee without Register Page Watch Dialog Displays Leese Label Name Select or cancel the label by double click it Label Types C Special Register R0 R1F Page 1 Control Register Bank C Call ID RAM Block 0 OK Cancel Figure 1 7d eUIDE Watch Dialog C RAM Bank EM78 Series IDE User s Guide Chapter 1 3 Click the OK button to add and display the selections into the Watch window as shown below Name Address Type Bank 0 Bank 0 Control uj sz TL Dagi 0x06 Controli Te Fatch AA Ux20 BE Ux sk UxUb Figure 1 7e Selected Register Value ee Displayed in Watch Window E Accessing Debug gt Add Label to Watch Command from Menu Bar 1 Select a register from the 2 Editor window and from Menu Bar click Debug gt Add Label to Watch From the resulting Watch Dialog select and double click a label name see Figure 1 7d above Then from the Label Types options select the variable type to be displayed 1 e Special Register Control Register RAM Bank or Call ID RAM FS F10 FG F7 FS Ctrl F Go To Cursor F4 Continue step into SHit F Run from Selected Line p Stop Add Label to Watch Reset and Free Run Reset and Go eUIDE Menu Bar 3 Click the OK button to add and display the selections into the Watch window as shown in Figure 1 7e above EM78 Series IDE User s Guide Introduction
90. e 1 4e Click Hex Command to from binary to hex format If Switch Binary Register Value the value is already in hex into Hex and Vise Versa this command is prefixed with a check mark v Edit This command auto selects the clicked value and allows you to change the value by editing This is the same as double clicking on the value as explained above However using this Edit command function is preferable EM78 Series IDE User s Guide Introduction e 11 Chapter 1 re 1 2 2 4 Call Stack Window The Call Stack window shows the updated L contents of call stack which indicate the actual evel Addvess hard ae oo ox0000 ardware content pi Ox0000 When the Call Stack window is closed it ceases 02 00000 to interact or read the hardware contents Os Os 000 04 Ox0000 E Reading Stack Level 05 0x000 o 06 0000 In general a stack does not have an initial value 07 ox0000 When you press F6 eUIDE resets all stack cells US Ox0000 to 0x0000 Due to ICE hardware design poms E constraint if a stack is full during program 10 Ox0000 l RTTA execution as shown in the figure below and i onio returns to the calling sub routine Reading the 13 Ox0000 stack level again will display the result as shown 14 Ox0000 in Figure 1 5c This may also affect l3 Ox0000 higher level sub routines as shown in Figure Figure 1 5a Call Stack Window 1 5d 4t stack dt 117 yj EM78808 STETR APJ 2 43
91. e 60 3 3 3 Accelerate Reading Registers Dialog 0 0 ccccceeeseeeecsecsetsesereeeeeeeeeees 60 es aes eae Fah og Sn er ee 60 3 4 1 Using the Project Wizard Project gt Project Wizard ccceecseeeceeeeeees 60 3 4 2 Using the New Command File Project gt New ccccccccccccccsessssseeeeeeeeens 64 3 5 Add and Remove Source Files from to Project c cc cccsesssssssssseeessessssssesssssseeeees 66 3 5 1 Create and Add a New Source File for the Project cccceeeseeeeeeeeees 66 3 5 2 Add Existing Source Files to the New Project ccccccccccccccccsceceeeeeeeeeeeeeees 67 25 5 Deleting Source Piles Tron Projeti eisereen ecteameels 68 ive EM78 Series IDE User s Guide Gen 3 6 Editing Source Files from Folder Project ccccccccccecceeeeeees 3 6 1 Open Source File from Folder for Editing 3 6 2 Open Source File from Project for Editing zT Compile ihe og 6 8 eee ee ne 3 8 Dumping the Compiled Program to ICE eee id Denoo ana ONC eaan ER E 39 1 Breakpoints Seting soresssesssrrsscssstereke srok osis sre re rr eruen osast 4 Assembler and Linker 4 1 Assembler and Linker Process FIOW c ccccccascacccceecesceess AD Glave Me lil VAX a E mets 4 2 1 How to Define Label cece ccc cccaccacceccecceccescesceeces oo ND E a re ee ee eee 4 4 Assembler Arithmetic Operation ccccccccccsseeeessessseeeeeeees AS PEO Stat DOCV G S eea
92. e Checking after dumping external memory checkbox to verify data after Cancel finishing the process When a byte in error is encountered verification SRAM Dialog process is aborted Figure 2 14 Move data from file to The External Code Size box shows how many bytes your program code 1s over 64K words So allow your Data Begin Address to be larger than External Code Size The maximum Data Begin Address is 524 288 512K byte and the Length is 262 144 256K byte So if the data you want to move from binary file to external SRAM 1s over 262 144 byte 256K byte you have to partition your binary file into two files and move your data twice Example Assuming you have a 512K byte external SRAM a binary file with filename Big5 bin and its size is 393 216 byte 384K byte and want to move all the contents of Big5 bin into external SRAM from the Data Begin Address 131 072 The file being over 256K byte is partitioned into two files e g Bigs 1 bin and Big52 bin with sizes of 262 144 byte 256K byte byte and 131 072 byte 128K byte respectively 46 e 2BThe eUIDE Commands EM78 Series IDE User s Guide Chapter 2 First move Big5 bin data into external SRAM by setting Data Begin Address at 131 072 Length at 262 144 and the Big51 bin folder as Binary file name The moved data will be located from address 131 072 to address 393 215 When Big5 bin data transfer is complete
93. e re oe re ne eer CZ FAO om mn E Ci ei cee C 4 Contacting ELAN FAE 00 cc ccssssssssssseseeeeeeeecceeeeeessseeceeesssseseeeeeeeeceeeeeesaaaaaoas D UICE Hardware Description 161 D 1 UICE USB and its Major Components Functions ccccceesssseseeeeeeseeseeseeeeens D 2 Special Note on eUIDE Software and UITO60N ec eeeeeeeeeeceeeeeeaeeeees E Library Application Notes 163 FD Ea ay assests E eo eese esd asec en seseeeesdaeseeeduaee EZA D 01 0 a eee ee eee eee eee eee nee F C Standard Library 165 ol Characier Class ests COPED ariere ETE F2 5ming TF ICTS sing I noren eree ET EENE Fo Mathematical Functions Matki serrera ie a N F 4 Utility Functions stdlib h oo cece eeeeeeeeessesessssssssssssssssssssssssssseesessssssseeseeeeeeees Fo OOP a EEA E A E EAE E EA F 5 1 Variable Argument Lists stdarg h s c cv eveceseeresectencorseeenneevesmeapsuaeewencinenee E52 Limits mits h and Hoat oa sess cots neon ccesse x coeemntenacesnee sions aesaa masse enesian FO PV MAT aN OCON S o AE EAE tage E N EE F 6 1 Character Classification Routines isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper 1SXdigit 0 F 6 2 Convert Letter to Upper or Lower Case tolower touppet 005 FOS COPY a mino SECO y SODY siiin iaee E NE antes teases F 6 4 Link Two Strings strcat strneat ccc cceeeeeeesseessssssseesesssssssssesssseese
94. e toggle for Project window Open Hide Output display hide toggle for Output window Only Source Window maximize editor window Ctrl Shift S Find find string from within the entire active file Ctrl F Find Next find string from cursor position toward the end of file Ctrl N Find Previous find string from cursor position toward the beginning of file Ctrl P Find in Files find string from inactive files Toggle Bookmark apply remove bookmark on the line where cursor is positioned Ctrl F2 Go to Next Bookmark jump to the next bookmark from cursor position toward the end of file Go to Previous Bookmark jump to the next bookmark from cursor position toward the beginning of file Ctrl F2 Clear All Bookmarks clear all bookmarks Ctrl Shift F2 Print print the active file About about eUIDE version and other information Assemble or Compile in C mode assemble or Compile the active file in the Editor window Alt F7 Build assemble or compile in C mode the modified files in the project and link object files Shift Alt F9 Rebuild All assemble or compile in C 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 a
95. e will include public symbol name and address Figure 2 19 Environment Setting Command Dialog c Recent File List The number of recently closed filenames to be saved in the ICE The maximum number of sub editor windows that can be accommodated is 10 d Recent Project List The number of recently closed project names to be saved in the ICE The maximum number of sub editor windows that can be accommodated is 10 e Auto Dump Over 64K For EM78815 only If checkbox is enabled all program codes are dumped into the hardware f External Code checking For EM78815 only If selected the process of dumping program or data to external SRAM is monitored and checked g Show Trace Log Under 64K For EM78815 only If enabled eUIDE will check the 64K program code when Go Free Run or Go To Cursor command from Debug menu is executed The maximum length of trace log is 8K words 52 e 2BThe eUIDE Commands EM78 Series IDE User s Guide Chapter 2 2 1 7 5 Customize The Customize dialog displays with four tabs as shown at right 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 Figure 2 20a Customize Command Dialog Showing Command Tab menu from menu bar To restore default settings go to Toolbar tab and click Reset All b Too
96. eausosvaqseneccseene canes 103 ed DONDE a E E E E E E N E 104 A P eE a sat ceaeg sncatcce av etec ua declaaclocog sagnuasedecencosteceteoedaccteesaeensesncecet 104 5 16 Break and Contine Statements sisi ienien ne E a EEE EE 105 Dede Goto Statement eiennenn riea a EERE E EAE Eaa 105 I T a a A A E E A E A A E E 106 IL TACO TOON E ea E EE 106 SO Func non De HMO seie E arr tactadiade teaser uncon 106 C Control Hardware Related Programming 107 CE Reone Pae DIE heera E e e e E r e E Ee 107 C2 LOCODE EE O e E A ae 109 e e E A E E E A E A a scednoneeoreceuntees 110 aA PDA T e a A E me ee eee ee 111 63 Daw LOD RAM Tdire ct Address 100 os oaccccecsecceteccecceietecasivazecasdezcatacieteand atte ealaaiees 112 6 6 Allocating C Function to Program ROM ccccccccccssssssseeeeeeeceeeeeeeeeeeeeeaaaas 113 C Pone Data RON oce E E E E EET 114 Co TCA D e E A 115 Co REENE E N O e E E E E 115 6 8 2 Use of C Variable in the Inline Assembly cc ccccccceeceeeeeeeeeeeeeeeeees 116 C9 URRE MIO eee erent een tener A EEEE rt ertr rer teen tt tet eT 117 EM78 Series IDE User s Guide Gen CAO TG U0 GR OUI asec ares toe ase eevedee E ease uetedeh ors sennesaeqedurepeseaenaers 6 10 1 Interrupt Save Procedure aneemia en ee 6 10 2 Interrupt Sty 1Ce ROU NG sascissaceccdancdsassatuancapecnansassecteaweeetcateiets 6 10 3 Reserved Common Registers Operation cccccccssssesseeeeeeeeees 7 Quick Workout on Tiny C Compiler Fede E E E A E EA T2 Cee a
97. eck again with another PC Repeat from Step 1 If it is still not solved please call ELAN 2 Q The connection from ICE to PC is successful but program dumping fails A Please check the following steps Step 1 Step 2 Click Option gt ICE Code Setting Then check the type of oscillator in the code option Check whether the type of MCU selected in software is the same as that in hardware 3 Q After checking ICE memory and found memory is in error A Please check the following steps Step 1 Step 2 Step 3 EM78 Series IDE User s Guide Click Option gt ICE Code Setting Then check the type of oscillator in the code option Check whether the type of MCU selected in software is the same with that in hardware Change ICE SRAM 18BFrequently Asked Questions FAQ e 155 Appendix C an When trying to reconnect the same ICE with PC why does the execution become slower and slower The communication timing between ICE and PC is stretched when you repeat the connection several times Why Step Into will not execute Check whether the type of MCU selected in software is the same with that in hardware If the source files are located in Novell file server why does the program is reassembled again at each execution It is caused by the time difference between the PC and server It is therefore recommended to locate all source files in the local disk of you
98. ed label to watch automatically Sort by Name C Sort by Address C Sort by Type Show Unreferenced variable l Show defined label in Register Window Cancel Figure 2 18a View Setting Command Dialog Show Program Rom 50 e 2BThe eUIDE Commands EM78 Series IDE User s Guide Chapter 2 a File Name in Project Window qJ EM78569 test apj EM78569 D West215694test apj 3 Source Files 3 Source Files LEY 569 01 E DAtest2 5601569 at ga Header Files E3 Header Files 3 List Files 3 List Files 2 569 E DiMtest2 569 test Ist Map Files Map Files E Library Files EJ Library Files Figure 2 18b View Setting Showing Differences between File Name Left vs File name with Path Right Options b Show Line Numbers 6 0xFF 4 0xFF 0xzz20 0z20 a 0x0 4 agi DEANA Ox20 al Figure 2 18c View Setting Showing Differences between Column On Left vs Column Off Right Options c Tab Width customize tab size d Add defined label to watch automatically Enable after Dump When checkbox is enabled definite variables are automatically appended with rpage rbank iopage when displayed in Watch Window I RegisterRS Ox05 rpage 1 02 org 0x0 BF 10 13 TCC 4E 2PC 0000 0001 1011 Pagel Page 0001 1100 00 R5 00 R5 00 R6 00 R6 R 40 R8 00 REGISTE 72 R FF RB 00 RC DE RC RD EQ C oR SS NS we We By RS SE ow Be wr Br oN Bt oN goaoggag
99. eeeees F 6 5 Compare Two Strings strcmp StrnCMp cccccceeseesseeeeeeeeeceeeeeeeeeeeeeaaaas F 6 6 Locate Character in String strchr strrchr ceeeeeeeeeesesssesseseseeeeeeeees F 6 7 Search a String of a Specified Set of Characters strspn strcspn F 6 8 Search a String of Any Set of Characters strpbrk cccccseeeeeeeeeees F69 Located SUDS ie oS S00 osn sescsossncesseshnnesscanasinedasengeeh caucersesseserancectersedecee F 6 10 Calculate the Length of a String strlen ce eeceeeseeeeceeeceeeeeeeeeeeaaeas viii e EM78 Series IDE User s Guide Gen EM78 Series IDE User s Guide Contents F 6 11 Extract Tokens from Strings strt0k 0 cccccssssssseseesessssssssseseeseeeeens 174 F 6 12 Copy Memory Area memcpy eessesssseeeeressssssssesrerssessssssreessssssseseeess 175 F 6 13 Copy Memory Area MOMMOVE cccccccccceeceeeeeeseeeeeeeeeeeaeeeseeeeeeeeeeeaas 175 F 6 14 Compare Memory Areas MeEMCMD cccccccsseessseeeeecceceessseeeeeeeeesees 176 F 6 15 Scan Memory for a Specified Character MeMCcht cccccccceceeeeeeeeeees 176 F 6 16 Fill Memory with a Constant Byte memset ccccccecceeceeeeeeeeeeeees 177 F 6 17 Sime Function S10 cccccsssseesssessssssesseessssseseessesseseesseeesesseesseseeeeens 177 Gls Cosine AC OT COS ere see eer wesw eed E 177 FOI FanGemt Function
100. ement will first check the expression If the expression is true it will then execute the statement Example while value 0 value count t EM78 Series IDE User s Guide 8BC Fundamental Elements e 103 Chapter 5 5 14 Do while Statement do 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 next statement until the expression becomes FALSE Example do value count t while value 0 5 15 For Statement For statement is equivalent to the following statement exprl while expr2 statement expr3 exprl is executed first Normally expr1 will be the initial condition While statement is executed in the same manner Example for i 0 i lt 10 itt value value 1 104 e 8BC Fundamental Elements EM78 Series IDE User s Guide FA Chapter 5 5 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 switch for i 0 i lt 10 i flag indata port if flag 0 continue outdatd
101. enu Index Bookmarks Go to Index Bookmarks i Supported in C Project only Submenu from Bookmarks command 32 e 2BThe eUIDE Commands re Undo Cancel the last editing action Redo Repeat the last editing action Cut Copy Paste Same as standard clipboard function Select ALL Select all contents of the active window Go to Line Move cursor to the defined line number within the active window Formation Formats the selection using smart Selection indent settings Find Find the defined string in the active window Find Next Find the defined string toward the bottom of the active window Find the defined string toward the top of the active window Find the defined string in the active and non active files Same as standard find and replace editing functions Bookmark the line at cursor position Toggle Bookmark the line at cursor position Previous Jump to next bookmark from cursor position toward the end of file Next Jump to next bookmark from cursor position toward the beginning of file Clear All 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 EM78 Series IDE User s Guide Chapter 2 2 1 2 1 Executing Find Command from Edit Menu 1 From menu bar click Edit gt Find Alternatively you can press the s
102. er time then error message will display At the same time the arithmetic expression cannot 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 78 e 6BAssembler and Linker EM78 Series IDE User s Guide Chapter 4 c Multiplication division modulo shift s Multiplication Division Modulo lt lt Logical shift left gt gt Logical shift right d Addition arithmetic operators Addition Subtraction e Bit AND operator amp Bit AND f BitOR and XOR operators Bit OR Bit XOR g 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 ORG set value of program counter Syntax ORG lt expression gt Example org 0x200 b EQU or Duplicate definition constant value Syntax lt label gt EQU lt expression gt Example 1 R20 equ 0x20 Example 2 R20 0x20 EM78 Series IDE User s Guide 6BAssembler and Linker e 79 an c Comment Line comment Syntax lt string gt Example this is the comment string Block comment Syntax lt strings gt Example thi
103. er variable setting must be an integer value Reason The result of expression in the right side of SET instruction must be an integer Solution Change the expression error A025 ORG address must be an integer value Reason The address of ORG must be an integer Solution Rewrite the address expression of ORG instruction error A026 The PC number address is over the number ROM size Reason The program counter address exceeds the program ROM size Solution Check program for error error A027 The assembler exceeds max pass number Reason The assembler pass is over the maximum default pass Solution Check the assembler for error error A028 The operand number value does not include the valid data Reason The operand value is invalid Solution Change the operand value error A029 The number address is in conflict Reason The program address is in conflict with another address Solution From Menu Bar click Edit gt Find to find the other conflicting address in the list file then update the address of the program position 138 e 14BAssembly Error Warning Messages EM78 Series IDE User s Guide 30 31 32 33 34 35 36 37 38 39 Appendix A error A030 The file filename cannot be opened Reason The file cannot be opened Solution Check whether the file actually exists or misplaced error A031 The file configuration rea
104. errupt void ant Write your code inline assembly or C here void _intcall interrupt_l void 0x087low int 0 _asm PAGE 0x0 it s dangerous to skip this line Example 3 EM78567 This particular MCU has only one interrupt vector The hardware does not save nor restore any register and Compiler just can save and restore R3 and R4 void _intcall interrupt void int Write your code inline assembly or C here restore ACC and R5 asm reti tell compiler to recover common registers here SWAPA OXIE MOV OX5 A SWAP OXI1F SWAPA OXI1F VOLO inteall ianterrupt_i void Ux0so low int 0 save ACC and RS asm MOV OX1F A SWAPA OX5 MOV OX1E A PAGE 0XO EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 121 Chapter 6 122 e 10BC Control Hardware Related Programming EM78 Series IDE User s Guide Py Chapter 7 Chapter 7 Quick Workout on Tiny C Compiler 7 1 Introduction This chapter introduces you to a quick way of understanding and controlling C Compiler Execute eUIDE by double clicking the eUIDE icon 7 2 Create a New Project at ElK Edi viewCErojecD Debug Tool Option IDE Window Help Figure 7 1a eUIDE Menu Bar From Menu Bar click File gt New or Project gt New to call the New New dialog Figure 7 Ic Then nen File Project Project Wizard Ctrl 0 M c Open Froject from the New dialog Figure
105. f a new ICE replaces the current one it is necessary to reconnect it with PC Click Tool gt Connect to reconnect The Connect dialog Figure 3 2 above will pop out again It will take a longer waiting time to establish communi cation between the PC and hardware during reconnection under the same hardware environment EM78 Series IDE User s Guide 4BGetting Started e 59 Chapter 3 3 3 2 Code Option Dialog Code Option ERC P55 08CO acts P55 ERC P55 08C0 acts OSCO IRC P55 08CO acts P55 IRC P55 08CO acts OSCO MCIRC act P55 LET Low Crystal MCIRC act OSCO HET High Crystal ENWDTB Enable Disable CLES 2clocks 4clocks mORBMO 9 9 5 CYES leyele 2cycle Target Power using ICE self Cancel Figure 3 3 eUIDE Code Option 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 You need to get acquainted with MCU or ICE specifications to able to select code option correctly Otherwise proper connection cannot be achieve with ICE You can enlarge or reduce the dialog s size by dragging its edges This dialog applies to both USB and printer port modes 3 3 3 Accelerate Reading Registers Dialog If you are using USB ICE the Accelerate Reading Registers Dialog dialog will pop up after setting code option Refer to Section 2 1 7 2 Accelerate Reading Registers for details 3 4 Create a New
106. fier The ifndef directive is used when the conditional compiling codes of the specified symbol is 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 5 4 Literal Constants 5 4 1 Numeric Constant Decimal Default Hexadecimal constant Digit prefix with 0x Binary digit Digit prefix with 0b 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 Ox5A OxB2 Hexadecimal ObLOLELOOL 77 Dinary digi EM78 Series IDE User s Guide 8BC Fundamental Elements e 95 Chapter 5 5 4 2 Character Constant Character constants are denoted by a single character enclosed by single quotes ANSI C Escape Sequences as shown below are treated as a single character ANSI C Escape Sequence Escape Character Meaning Hexadecimal o e i oe S e OD Ooo ea S e S Example a 4 Der oar x00 5 4 3 String Constant character _list String constants are series of characters enclosed in double quotes and which have an implied null value 0 after the last character Example Hello World Elan Micro 96 e 8BC Fundamental Elements EM78 Series IDE User s Guide Chapter 5
107. ges of 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 E Right Clicking the Selected Register Value Directly from Editor Window 1 Right click a register value or variable from the Editor window From the resulting pop up menu click Add To Watch command If the selected value contains register page or ram bank or control register page as shown in the right figure the register value is directly displayed in the Watch window see Section 1 2 2 2 Editor Window gt Add to Watch If the selected value does not contain register page ram bank control register page as shown in the figure below the Watch Dialog see Figure 1 7d below will display instead O rbank 0 rhank rpage 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 1 e Special Register Control Register RAM Bank or Call ID RAM see figure at right 2 rhank rhank Next Position BookMarks Index BookMarks Go To Index BookMarks Add to Watch Figure 1 7b Select amp Right Click Register Value ee with Register Page Register Page from Editor Window Pop Up Menu then Displays Figure 1 7c Select amp Right Click Register Valu
108. gisters value are the same before running them into interrupt save procedure and leaving interrupt service routine That is to say you have to be sure to save and restore these common registers correctly The C Compiler will display its compiling result in the Output window Suppose the 0x10 0x14 common registers in the following example have to be saved and restored apply remarks into these two backup C systems You can restore the C system inline assembler code by removing the remarks if needed If the C Compiler needs more common registers to save and restore over and above 0x10 0x14 you only need to add codes e g MOV A Ox 5 and MOV 0x37 1 A after saving 0x14 in the backed up C system inline assembler Likewise add MOV A 0x37 1 and MOV 0x15 A after restoring 0x14 in restore C system inline assembler You can write interrupt service code between backup C systems and restore C system e g Write your code inline assembly or C here as shown in the following example 126 e Quick Workout on Tiny C Compiler EM78 Series IDE User s Guide Chapter 7 extern int IntVecIdx occupied OxlO irpage O woid maint t of wold _intcall ALLInt void do int i switch IntVecIdx case Une A Write your code inline assembly or C here break case Ox 2i Urcite your code inline assembly or C here break case Ox 2i rite your code inline assembly or C here break case OxD t
109. h x cosh x E See Also sinh cosh Sections F 6 24 amp F 6 25 respectively F 6 27 Exponential Logarithmic and Power Functions exp log log10 pow E Synopsis include math h float exp float x float LOogtrLoat x float loglO float x float pow float x float y E Description exp Return the value of e the base of natural logarithms raised to the power of x log Return the natural logarithm of x log10 Return the base 10 logarithm of x pow Return the value of x raised to the power of y E Errors Definitions The log and log100 functions return the following errors e EDOM The argument x is negative e ERANGE The argument x is zero The log of zero is not defined The pow function returns the following error e EDOM _ The argument x is negative and y is not an integral value This would result in a complex number E See Also sqrt Section F 6 28 EM78 Series IDE User s Guide 24BC Standard Library e 181 Appendix F en F 6 28 Square Root Function sqrt E Synopsis include math h float sgrt float x E Description sqrt Return the non negative square root of x if x is negative it fails and sets errno to EDOM E Errors Definition EDOM x is negative F 6 29 Ceiling Function Smallest Integral Value Not Less Than Argument ceil E Synopsis include
110. he file Reason The file cannot be found in the directory Solution Execute Rebuild All command 24 error D024 No file exists in filename project Reason The project is empty Solution Add file into project 144 e 14BAssembly Error Warning Messages EM78 Series IDE User s Guide F olan Appendix B Appendix B C Conversion Table B 1 Conversion between C and Assembly Codes The assembly code was generated by the eUIDE Conversion Rate Assembly Code Compiler s Code Size General User s Code Size 100 Integer Variable intVar1 OxFF MOV A 0xFF 100 2 2 100 MOV intVar1 A intVar2 intVar1 MOV A intVar1 100 2 2 100 MOV intVar2 A Character Variable charVar1 OxFF MOV A Oxff 100 2 2 100 MOV charVar1 A charVar2 intVar1 MOV A charVar1 100 2 2 100 MOV charVar2 A Short Variable shortVar1 0x1234 MOV A 0x34 100 4 4 100 MOV shortVar1 A MOV a 0x12 MOV shortVar1 1 A shortVar2 shortVar1 MOV A shortVar1 100 4 4 100 MOV shortVar2 A MOV A shortVar1 1 MOV shortVar2 1 A Long Variable longVar1 0x123456 MOV A 0x56 100 6 6 100 MOV longVar1 A MOV A 0x34 MOV longVar1 1 A MOV A 0x12 MOV longVar1 2 A longVar2 longVar1 MOV A longVar1 100 6 6 100 MOV longVar2 A MOV A longVar1 1 MOV longVar2 1 A MOV A longVar1 2 MOV longVar2 2 A C Statement Example Description EM78 Series IDE User s Guide 16B
111. he hardware contents 1 2 2 8 LCD RAM Window With the EM78 Series IC that supports LCD installed and in used open the LCD RAM window Drag a corner to increase the size of the LCD RAM window until the window looks as shown in the following figure Note that when the LCD RAM window is closed it ceases to interact or read the hardware contents 50 S1 52 S3 S4 S5 S6 S 58 S9 510 511 512 513 514 515 16 517 518 519 520 521 522 23 524 525 26 527 28 S29 S30 S31 coo 0 0 0 O0 O0 0 Q 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 o 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 O0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 oO 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Data Pane Graphic Pane a a a a a a C c o e e e e e e import Graph com 0 seG 0 SEGRange 0 31 Load File Control Pane si Set Mapping Swap Auto Increase 0 COM Range 0 3 Save File lt a V Show Data M Show Graph M Show Control gt Pane Selection Bar Figure 1 9 LCD RAM Window The LCD RAM window consisted of four sections as detailed 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 elements double click on the selected element grid block The color of the selected element will change from pink 1 to white 0 and vise versa
112. hortcut keys CTRL F 2 From the resulting dialog enter the string you a ance want to find and its parameters Select All Ctrl A Go to Line Ctrl G Formation Selection Alt F8 Find what AE amp T Match whole word only Se now Cancel ge Find next Ctrl Match case a Find Previous Ctrl laa Find in Files Figure 2 4b Find Dialog from Edith Menu Replace Ctr H Where BookMarks Index BookMarks Go To Index BookMarks Find what Enter the word string you want to search Figure 2 4a Find Command Find Next Click this button to search the next from Edit Menu matching string Matched string is highlighted 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 string that has additional characters including spaces before or after the defined string such as 123abc or abced Match case Select this option to match the string in lowercase or uppercase characters exactly as they appear Direction Up Search toward the top of the document Direction Down Search toward the bottom of the document Cancel Quit search and exit from the dialog 16 00008 0552 inc 0x12 r att O 2 jmp s2 Find what mov Find Next __Cancel__ Wi 44 7test at i The figure at right shows R10 0x10 rpage 0 1 2010 R10 Ox1l0 rpa R11 Oxll rpage 0 1 00000
113. i Write your code finline assembly or C here break H f woid _intcall tee _1 void i E 0x03 low_ int O asmi MOY A One PAGE BOXO f I void inteall intO lfyvoid E OxO06 low int 1 i asmi MOY A One PAGE OxdO i I Figure 7 4 eUIDE Provides C Main amp Interrupt Frame template 7 6 Project Development with Interrupt The following example shows how to write C code in your product development In the example the MCU in awaken by Port 6 with Counter 1 underflow interrupt with interrupt vector OxC So you need to write some initial codes and your interrupt service code as shown Figures 7 Sa amp 7 5b Then activate one of C files and use Alt F7 to compile the file to see if errors exist in the file The Alt F7 will merely compile the active file During development use Alt F7 to compile the C files one by one to save compilation time After no error status is verified in all C files in the project use Rebuild All Alt F9 command to compile and link the object code then create execution file cds If Rebuild All is successfully executed C Compiler will report many important and useful messages in the Information tab of the Output window Figure 7 5c below EM78 Series IDE User s Guide Quick Workout on Tiny C Compiler e 127 Chapter 7 005 define ENI 006 define SLEP O07 define NOP 008 define uchar O08 void main 010 011 012 013 014 015 etestl1 while 1 O
114. iew 3 1 1 System Requirements The EM78 Series eUIDE 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 m At least 256MB of RAM 512MB or more is recommended m Mouse and USB connectors are highly recommended 3 1 2 Software Installation The eUIDE compiler and ICE driver are is included in eUIDE program package When installing the eUIDE the compiler is also automatically installed If this 1s your first time to install the eUIDE program you need to reboot your computer after eUIDE installation is completed because of the printer port driver DLPortIO If you use USB ICE under Windows 9X you also need to reboot If it is not the first time to install eUIDE 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 ELAN USB ICE through the OS Device Manager if the driver is installed and the ICE is connected correctly EM78 Series IDE User s Guide 4BGetting Started e 57 Chapter 3 ri c Device Manager view sw t SSSI Figure 3 1 OS Device Manager Confirming ICE Installation 3 1 3 ANSI Compatibility Compliance with the AN
115. ions of the LCD RAM window are also available and are describe below together with its respective notes 1 Ifyou wish to automatically apply the Auto Increase value to COM instead of SEG click Swap button and observe SEG amp COM swaps positions Only the value located in this box will change 2 After clicking Swap also observe that the system has at the same time switched the positions of all values from COM SEG to SEG COM on the previously set segments Compare the figure at right to the one in Item 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 setting into LCD Simulator Save File Data File LCD 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 click the Import Graphics button the Load File next time you want to use the saved LCD file Just click Load File button to load the data file EM78 Series IDE User s Guide Introduction e 23 Chapter 1 5 6 1 2 2 9 EEPROM Window Click Refresh button to restore updating amp reading of all EEPROM data Click row header to disable and exclude row data from updating amp reading Click again to restore The program determines which black pixels are linked together to e
116. ique to each other Solution Redefine the internal defined label error A017 Address of ORG is in error Reason The defined ORG address is in error Solution Redefine the ORG with proper address error A018 MACEXIT cannot be set outside macro Reason The MACEXIT instruction cannot be set outside the macro definition Solution Remove the MACEXIT instruction error A019 Parameter must be a string variable Reason The formal parameter must be defined as string Solution Change the formal parameter to string error A020 Memory cannot be allocated Reason O S cannot allocate extra memory Solution Close opened Editor windows or applications that are currently redundant EM78 Series IDE User s Guide 14BAssembly Error Warning Messages e 137 Appendix A 21 22 29 24 25 26 27 28 29 en error A021 The source statements exceed by number lines Reason The line number of source file is over the system default limit Solution Split the program into two or more small programs error A022 The tree is in error because of parsing error Reason The program syntax line is in error Solution Rewrite the program line error A023 allocated memory type memory is faulty when memory is allocated Reason O S cannot allocate extra memory Solution Close active Editor windows or applications that are currently redundant error A024 Assembl
117. 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 eUIDE Main User Interface Project Window Editor Window Special Registers Window Ema e Gene TERDI a Far Evi iin oject Debug Tool Dpi me me mea DAMARA Rares ST Cent ahr 28 ea or er fer 44666 2O lirbank O bbhbbb Oxzi rbank 0 ras a BF cacec Ox0Sirpage 0 20 06 ddddd Ox0S rpage 1 ae i FEFFE Ox0S rpagi 2 i on Ox0Sirpage J are E EA i RLS 4 HO TOON Prg P1iiai Ux067i i Rl T gird 100 Waga Orel RID RS On g i oo Tdd s 0x2 RIT m jo Arg Ox z i an 18 fi oo 10 w A Utlb A Oxi a r I1 ha Oxib e Oxe Sr Bank 0 0x00 Ox1C a epee Barihyl Daid Ox10 a coos Registeeri iat Ox 1E a ooooo Register 1 Ci Ux 1F 8 3 Use FFFFF Register Lai 0x20 EIE EEIE Registers Lata Uxz1l amp lel contrahi Oa F Ox2e 66 Control 1 woo ae a oe w m BEF Al FE EB HG K rF 7 rn i I i Pi BI amp Aa Zi W W C l 695 e ae ow OM FE 4 IO Of 71 ua oO Gf 90 15 3 3 BOS E 03 E cca 42 D aD 6b ad a Sl2 E I3 suir E 16 a Ki o Kil 0 0 o g 0 0 o O Brroeris War ingisi 0 User s LCD RAM Window Watch Window bez ROM Protest LOOSE Figure 1 1 eUIDE Main Window Layout EM78 Series IDE User s Guide Chapter 1 1 2 2 eUIDE Sub Windows The su
118. isupper isxdigit E Synopsis include ctype h Ine Dsalnum int C Inti salpha int c int iscntrlL int c ine tSadLgoOLe ine C int isgraph int c 1 1 1 int 1slower int c int c int int int 1supper int c int Ss xXdiCGLe int Char tolower int o int LSprint int ispunct ee AM AM M ee 1 int isspace 168 e 24BC Standard Library EM78 Series IDE User s Guide Appendix F E Description The following functions check whether c which must have the value of an unsigned character or EOF falls into a certain character type according to its current location isalnum Check for an alphanumeric character It is equivalent to isalpha c isdigit c isalpha Check for an alphabetic character in the standard C location It is equivalent to isupper c islower c In some locations there may be additional characters for which isalpha is true letters which are neither upper case nor lower case iscntrl Check for a control character isdigit Check for a digit O through 9 isgraph Check for any printable character except space islower Check for a lower case character isprint Check for any printable character including space ispunct Check for any printable character which is not a space nor an alphanumeric character isspace Check for white space characters In the C and POSIX locations these are space form feed
119. kea New File Projects o Contol Project Name EM7SFSSSiLCE660N ES AsmTest 78ME11E S611 2RN G1 20 CELT RSy Location Close CAEM78TestC1 534 SESA Propst Iype Library Output Figure 3 3 5a File Menu S Asembler S Nomal cds K Oc O Library 1 TE Rojec EM78P156N CE456E Project Wizard EM78P157N ICE456E EM78P159NCE159 a New EM7SP163N CE163N No wo wo i TI j EM78P141 CE143 EM Le eh pacer EM76P143 ICE143 SM eee SEES SP1 EM PIAN IETS EM76P1541N ICE159 EM78P156EL ICE456E Open Project Save Project Close SNS Figure 3 5c New Dialog Showing Project Tab for Creating New Figure 3 5b Project Menu Project 3 Select Projects tab from the NEW dialog 4 Assign a name for the new project in the Project Name text box suffix apj for ASM mode or cpj for C mode will auto append to 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 library output of your project Normal Project or Library Project 7 Then select the proper type of your project C for C Compiler Project or Assembler for Assembly Project 8 Select the target microcontroller for your project from the Micro Controller list box 9 Click OK button after confirming all your selection and inputs The new project is then created with the defined projec
120. lbars tab 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 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 Figure 2 206 Customize Command Dialog Showing Toolbar Tab EM78 Series IDE User s Guide 2BThe eUIDE Commands e 53 Chapter 2 c Keyboard tab Customize The Keyboard tab allows Commands Tool you to create remove the shortcut keys for the commands of a selected command category The procedure is explained below New Open Project E JET Open 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 eUIDE will auto detect and determine 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 button to apply Figure 2 20c Customize Command Dialog Showing Keyboard Tab Removing an e
121. le extern unsigned int uaa fii KKOP C Tile void testl1 J in kkdr c file uaa 0x38 testZ uaa 0x43 test Jit pprr h File extern unsigned int uaa fii POLIC TLIE void test2 74n pori C Ille uaa 0x29 EM78 Series IDE User s Guide 8BC Fundamental Elements e 93 Chapter 5 5 3 2 define 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 clear and logical Example define MAXVAUE 10 Oefine sqrZ2 x y x x y y 5 3 3 if else elif endif if constant_expression else elif constant_expression endif The if directive is used for conditional compilation It should be terminated 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 define RAM 30 if RAM lt 10 define MAXVALUE 0 eliff RAM lt 30 define MAXVALUE 10 else define MAXVALUE 30 endif 94 e 8BC Fundamental Elements EM78 Series IDE User s Guide Chapter 5 5 3 4 ifdef ifndef ifdef identifier ifndef identifier The ifdef directive is used for conditional compilation of definitions for the identi
122. loat x int pw2 E Description Idexp Return the result of multiplying the floating point number x by 2 raised to the power exponent F 6 33 Convert Floating Point Number to Fractional and Integral Components frexp E Synopsis include math h float frexp float x int pw2 E Description frexp Split the number x into a normalized fraction and an exponent and store them in pw2 E Return Value 66 99 The frexp function returns the normalized fraction If the argument x is not zero the normalized fraction is x times a power of two and is always in the range of 1 2 inclusive to 1 exclusive If x is zero then the normalized fraction is zero and zero is stored in pw2 E Example include stdio h include math h include float h int main float d 2500 int e float f frexp d amp e printf frexp g amp e d f f FLI RADIX e di return Us This program prints frexp 2560 amp e 0 625 0 625 2 12 2560 ao 7 29 184 e 24BC Standard Library EM78 Series IDE User s Guide a Appendix F E See Also Idexp modf Section F 6 32 amp F 6 34 respectively F 6 34 Extract Signed Integral and Fractional Values from Floating Point Number modf E Synopsis include math h float MOoadr t Loar x float y 7 E Description modf Split the argument x into an integral part an
123. lt expression gt Example 82 e 6BAssembler and Linker test var mov a test test var test l mov a test EM78 Series IDE User s Guide oll Chapter 4 j MACRO ENDM The instruction defines macro Syntax lt label gt MACRO lt parameters gt Statements ENDM Example bankO macro bc 0x04 6 be 0x04 7 endm aa_label macro num Examplel if num gt Ux400 be Ox3 6 If org 0x400 is omitted the following he 03 5 conditions will result else l be Ox3 6 a The required aa_ label macro be 0x3 5 parameter num becomes unknown endif Hence macro cannot expand endm E b As macro fails all its instructions arg Oxfff cannot be implemented jmp start ory Ux Start aa label bh lahel call bh label aa label jmp org Ux40u bh label ine gz20 ret EM78 Series IDE User s Guide c The error message error A037 The operand value cannot be calculated will then display To prevent the above error address org 0x400 should be added before bb_ label 6BAssembler and Linker e 83 Chapter 4 PCALL MACRO addr Example2 EM78P510N IF faddr Ox400 l Ox400 LCALL addr FCALL and FJMP are reserved words ELSE These two words will determine whether CALL addr the program code exceeds page or not ENDIF ENDM FIMP MACRO addr IF faddr Uxd00 S Ux400 LIMP addr EESE JMP addr EMDIF FPAGE MACRO NUME Example3 EM78P447S IF NUME a FPAGE
124. main or subroutine program EM78 Series IDE User s Guide 14BAssembly Error Warning Messages e 135 Appendix A en Reason The syntax format of the statements did not follow the operation operand operand format 3 error A003 The syntax format should be operation operand operand Solution Correct the syntax error by abiding to the proper format 4 error A004 The label label name has already been defined Reason Each label must be unique and cannot be defined more than once Solution Redefine with another label name 5 error A005 The EQU syntax is label EQU operand Reason The EQU syntax is in error Solution Correct error with the proper syntax 6 error A006 The INCLUDE nest depth is over 256 Reason The maximum depth for using INCLUDE is 256 Solution Reduce the depth of INCLUDE 7 error A007 The IF conditional expression is in error Reason The expression of IF conditional is in error Solution To correct the expression of IF conditional 8 error A008 Attempt is made to divide by zero Reason The expression where number is divided by zero is invalid Solution Modify the expression 9 error A009 The assembler does not support floating point number Reason Expression with floating point number is not supported Solution Change the floating point into integer number 10 error A010 The symbol symbol name is not defined
125. mp main main nop test nop 11 jmp SS oa Se E p lt 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 the previous eUIDE version it stops at Line 2 of the macro EM78 Series IDE User s Guide 2BThe eUIDE Commands e 49 Chapter 2 re 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 2 1 7 2 Accelerate Reading Registers Accelerate Reading Registers Accelerate Reading Registers C Enable instruction clock gt 2 MIPS Disable instruction clock lt 2 MIPS Figure 2 17 Accelerate Reading Registers Command Dialog When you use USB ICE and the frequency is over 2 MHz you can enable this capability But itis not 100 stable If you see some abnormal appearances try to disable this option 2 1 7 3 View Setting Set the eUIDE window view eerie l Base on Big window size when dock variables or properties C Base on Small window size when dock Revise Window Size File Name in Project Window C File name with Path File Name Show Line Numbers i OWN C OFF Tab Width 4 l Show Ram Bank Inversely Show Data Ham Inversely lf Add defin
126. n the active segment to enter the Control Panel gt defined COM SEG values into the segment The example shows the defined COM amp SEG values are 0 T T 5 Move the pointer away from the segment and the segment a turns into green This indicates that the system has already 00 saved the COM SEG values for the particular segment p T EM78 Series IDE User s Guide Introduction e 21 Chapter 1 6 Then move the pointer to other segments and repeat the steps described above to redefine and change the COM SEG values of the remaining segments 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 a Set Mapping button Then run the program to test the 7 settings e g set some breakpoints and execute GO or lt gt use the Continue step into View the results and check i for error E More Efficient Way of Re Defining COM SEG Values The Step 6 above shows how to manually define and change the COM SEG values for each segment This method is okay 1f 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 1 From the Control Pane define the SEG Range as 0 1 and the COM Range as SEG Range o 1
127. nction View EM78 Series IDE User s Guide Chapter 1 mid main To find the location of the displayed label or f function in the file double click on a label or function The eUIDE will automatically bg tle irel ae ee pinpoint to the pertinent location in the Editor Function Location Pinpointed in the in Window as illustrated at left At the same time Editor Window eUIDE will display the search results in the Output window as illustrated in Figure 1 2g below Searching for main in MAIN C D My DOCUMENTS AA AMAIN C 48 void maint i ogzcurrencels found Figure 1 2g Simultaneous Search Results Display in the Output Window If after editing the code eUIDE is unable to locate the label function location in the Editor window the Output window will display a message providing a reason for not finding the searched item 1 2 2 2 Editor Window The Editor window is a multi windowed editing tool for creating viewing and debugging source files Figure 1 3a Editor Window Its major editing features are m Unlimited file size m Multiple files can be opened and displayed at the same time m 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 EM78 Series IDE User s Guide Introduction e 5 Ch
128. ndow Project E iD Project Filename cpf auto appended for C mode Target Microcontroller Figure 7 1d Project Window Showing Target MCU amp Project Filename 7 3 Add a New C File to the Project To add a new C file to the project open New dialog New or Project gt New This time the New dialog will appear with Create a New File tab automatically selected Figure 7 2 below eUIDE will auto provide a template with the basic Tiny C Compiler main file interrupt save procedure and interrupt service routine functions see Section 7 5 below for details when the Source File c is selected in the left list box and the Empty File checkbox is disabled The Add new file to project checkbox is enabled by default Now enter a filename for the first new file to be added into the File Name text box no suffix required as eUIDE will append proper suffix automatically Press OK button to add the first C file into the project Create a New File Projects ELAN Source File c IW Add new file to project Select Source File c p eee eae Do not enable Empty File Name File checkbox File Location Suffix c will auto append Figure 7 2 Adding the First New C File with Main Interrupt Save Procedure and Service Routine Frame Functions 124 e Quick Workout on Tiny C Compiler EM78 Series IDE User s Guide re Chapter 7 7 4 Adda Second File or a New Header File to
129. ndow 2 1 6 2 Moving Data from File to SRAM Applicable to EM78815 only The eUIDE supports moving data to external 512K byte SRAM board which allows the use external SRAM as a replacement for the slower flash With this new feature you can move data from binary file to external SRAM and use external SRAM to develop program with program size of over 64K words With your hardware properly connected and ready to debug your program access the data from external memory Now replace external flash ram with external SRAM Then move of data from binary file to external SRAM and dump code to external SRAM as further discussed in the following pages EM78 Series IDE User s Guide 2BThe eUIDE Commands e 45 Chapter 2 E Move Data from Binary File to External SRAM 1 Execute Debug gt Reset F6 2 Click Tool gt Move data from file to SRAM command 3 When the resulting dialog right oa figure appears browse for the Data Begin Address 13107200 Binary file name you want to Eendag 131072 operate and enter the Data Begin dermal Oot SiE o Address and Length into their M Checking after dumping respective text boxes Binary file name Be sure to read the notes at the DAWiceTest 15 Fang2 Big5 bin bottom of dialog and then press OK Note 1 The unit of Begin Add d Length is byte button to move your data You may e unit of Begin ress and Length is byte 2 The Data Begin Address is reference to 0x0 of enable th
130. no E E AG Conditional Assembly seecnesicicnineia A R O a N E E E 4T Direchves OpEratOTS xcsincuasapasdacnmsanesosreenantaavenemceans 4 7 2 Instructions MNeCMONICS cccccsceccececcccececscecescecescecs 4 8 Pseudo INStruction ccccccecceccccecceccccesceccecsceccecesceceececceceecs 5 C Fundamental Elements A OMS ONS r aicesiecaseegeseuossasqeaciecsesssaensteeedsesiayecsasrsaniaeeenn WA RE CV ANOU ee E ee 5 3 Preprocessor Directives ccccccccsssseeeeecceceeeeeeseseeeccceeeeeaaeeeees Io r O E Ioe U a A AE E EA E 5 3 3 if else elif endif oo cc ee cecccsececsssecessesevecsenes Sak der 0 1 G16 lt eee eee eens en eee eS 54 Literal Constants inassieccccassccssaworcacsgaczoossonsaneqoasiucesauesnoeseaoieorsionss Sa NEC ON A e O 5 4 2 Character Constant eeeeeeeeeeeesseeeereessrrererreeessrrrerrreesss ec Pee E LC ONSI oE E EE EM78 Series IDE User s Guide Contents Contents 6 Vi e o AA Te scat rec A a E ta rasa EEA E EAEE A A E E 97 DO Pa a 0 a E E N E A A E 98 S omuc an O e a E 98 NE a E EE E E E E EE E EE 99 Bie PON E ere E eee ee ee 100 O ONTO S aa E E E T TA EO 100 5 10 1 Types of Supported Operators 0 0 ceesssssssssseeeeeccecceeeeeeeeeeaaaeeeeseeseeeeees 100 5 10 2 Prefix of OPCrAOIS t onkcstecatevacentadacdavadasastoentandissbaveeontelansavedsssietouniesdincdasserste 102 MIE E E E E E AEA EAEE 102 DZ AUC Hy e E o E E ET ETETE 103 SA N E T N e S E E mad
131. nt at the pertinent location in the Editor window see Figure 1 2f Section 1 2 2 1 At the same time eUIDE displays the search results in the Output window as illustrated in Figure l 28 Introduction e 9 Chapter 1 PZ 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 Spee name followed by symbol and sate register page or ram bank or control register page as indicated in the example figure at right From the aie resulting pop up menu click Add to cai cama Watch Then observe Register R11 BookMarks being added into the Watch window index BookMarks Real time changes of the data during Go To Index BookMarks debugging can be observed from this window When right clicking on a temporary es E E E E Figure 1 3 An Example of Adding Register 8 ick tal R11 into the Watch Window characters but without register page ram bank control register page the Watch Dialog will display instead See Section 1 2 2 6 Watch Window for further details 1 2 2 3 Special Register Window SOREN The Special Register window shows nae adtere the updated contents of the registers changes it is S and also that of the I O control shown in red Cea aan O O O register depending on the MCU type 6 FF RE E A in use When the Special Register window is closed it ceases to interact or read the hardware contents except for
132. nto your target location 6 e Introduction EM78 Series IDE User s Guide Copy Paste Previous Position BookMarks Chapter 1 rlLNelLug E org UxfEE jmp sl ore x Figure 1 3d An Example of a Cut Command Operation First select the 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 Insert the selected text that has been recently cut or copied into clipboard into the target location The figure at right shows an example of a paste result framed at the bottom of the same page in the Editor window include 44 test h org UWerir jmp sl hift Delete Cot GA Paste Ctl Y Add to Token pool Last Position Nest Postion Figure 1 3e An Example of a Cut Command Operation sl Ox00 eir Well Clr ele inc OUxil inc Uxle jmp sz Figure 1 3f An Example of a Paste Command Operation EM78 Series IDE User s Guide Introduction e 7 Chapter 1 re BookMarks Insert markers to specific lines that you may wish to return to at later time 1 Select a line then from amp Cut Shift Delete Copy Ctrl C shortcut menu click Paste TER BookMarks gt Toggle Previous Position from the Menu bar or ATE ae directly press the
133. o Controller combo box will display all EM78 series ICs having 159 as its last part number digits thus speeding up the search for your target IC Micro Controller The IC part number shown on the combo box is one of the EM78 series Select your target IC by clicking on the combo box arrow Connecting Port Select the proper connecting port LPT or USB for your ICE If USB ICE is not installed you cannot select the USB option as the option will be disabled However if the USB option is disabled and you have the USB ICE connected with PC go to your OS Device Manager and try the following steps 1 Turn off the ICE 2 Disconnect the USB cable 3 Turn on the ICE 4 Reconnect the USB cable 5 Then check if the USB option is enabled LPT Port Address The system will automatically detect the printer port address default 1s 378H which 1s already connected with the hardware After the connection is successful eUIDE will also diagnose the hardware right away I O Wait Times It depicts the I O response speed Increase the value for slower speed and decrease for faster speed Usually the bigger the value the better is the stability Check ICE Memory You may enable this check box to check the ICE memory condition Long Delay Time When you are unable to connect your computer to ICE enable this check box This will allow a longer handshaking time between your computer and ICE Click OK button when done 3 3 1 1 Reconnection I
134. ogramming EM78 Series IDE User s Guide Chapter 6 Data RAM LCD RAM S0 S1 2 S3 455 0x00 0x30 lt return value gt lt function name gt lt parameter list gt lt address gt page lt page number gt You can place C 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 Example void myFu ni int x int y 00x3 myFunl is placed at 0x33 of ROM page 0 default page v id myFunZ int x Ime y Q0X33 page 1 myFun2 is placed at 0x33 of ROM page 1 EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 113 Chapter 6 Progrom ROM 0x033 0x222 0x33 of page0 0x433 0x0433 0x33 of page 0x33 at page1 6 7 Putting Data in ROM 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 the TBL instruction to incorporate such data into the program ROM Function befo allocation Function after allocation Example const Int myDatall i 2 3 z DI const char myString 2 3 WH 4 m j AA ABC n 114 e 10BC Control Hardware Related Programming EM78 Series IDE User s Guide Chapter 6 Program ROM myString 6 8 Inline Assembler The compiler has an in line assembler which allows you to enhance the functionality of your progr
135. ommand is executed Hence any existing solid red dot breakpoints are ignored 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 becomes solid again The red address breakpoints are applicable only when the blue ones are all cleared To clear all blue breakpoints do either of the following e From the menu click Debug gt Clear All Address Break Point e Press the shortcut keys CTRL ATL A To clear individual or a range of blue breakpoints do the following a From the menu click Debug gt Address Break Point or press Alt A b From the resulting Address Breakpoint dialog figure below which displays all the existing blue breakpoints select the specific or range of breakpoint s to delete from the dialog c Click Delete button to remove the selected breakpoint Address Breakpoint You can also enter the specific or range of address breakpoint s you want to delete here Figure 2 11b Address Breakpoint Dialog with Selected Individual or a Range of Blue Breakpoints to be Cleared EM78 Series IDE User s Guide 2BThe eUIDE Commands e 43 hapter 2 2 1 6 Tool Menu Connect Ctrl Shitt C Check ICE memory Get checksum from project Piggy back Hi Lo format
136. on int abc unsigned int uir abc 0x18 5 6 Enumeration enum identifier enum idenftifier enumeration list int_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 5 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 member declaration member declaration list member declaration member declaration member declaration specifiers declaration list member declaration specifiers member declaration specifier member declaration specifiers member declaration specifier The structure group 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 98 e 8BC Fundamental Elements EM78 Series IDE User s Guide Chapter 5 Example 1 struct st unsigned int bO Ne unsigned int bl e Ne unsigned int b2 unsigned int b3 e unsigned int b4 e unsigned int bod Ne unsigned int b6 e e PrP RPP PB e unsigned int b7 by struct st R5 0x05 rpage 0 struct R5 is related to 0x05 rpage 0 Exam
137. owWs eeesseeeeeseeesssccrrrressssrrrrerrressssrrtterressssserrerresesssereerreeessse 3 Eeee 2 106 0 a E EEA EEA E 3 beaa Lar WDOWA E 5 1 223 Special Resister WiNdOW asiavedsesissadeesbasdbaysiesivercbevelsessseadecsbeeseaceeas 10 1 2 2 4 Call Stack Window eeeeeeeeseeeeeeeseessrrrrrreessssrrrrressessrsrrrrreesssssereerees 12 1 2 2 5 RAM Bank General Registers WindOW ccccccceeeeeeeeeeeeeeeees 14 D2 VU Wy MON aes spect recesses Gets anectene See en tense Geena tenes 15 122 7 Dia RAM WANG OW eccna e E 20 1 2 2 8 LCD RAM WindoW seeseeeeessseeessesserrrssssrrersssssrerrsssereresssereresssseeres 20 Wee FEFROM WOW eene secession senesced 24 R20 CUO VV 1 OW seene A A mere ucamtac es 25 Me SUIDE Moni Bi ota sates aoatcssassentasalosseatessenn EE aaaeeceeuseseeeetaasecss 27 1 2 4 ToolBar cc ccccccccccccccccccesseeccccceeeececcccceueseecceseuunseeccessuuesecesessuueeeeceeesauneeess 27 1 2 4 1 Toolbar Icons and its Functions and HotkeyS cccccccceceeeeeeees 21 L242 Document Baboso Ra EA 29 Fee SE D E E 30 2 The eUIDE Commands 31 2 1 eUIDE Menu Bar and its Menu Commands ee eeeeesesessessesssessssssssssssssssseeseeens 31 ZLE PO M A e E E E uesueessoeu 31 a ECN T A N E A 32 2 1 2 1 Executing Find Command from Edit Menu ccceccceeeeeeees 33 2 1 2 2 Executing Find Command with Shortcut Hotkeys 34 Do NMC W NE sea steer se trnarse sec sey ener as ane oot eas eachee posses ee
138. page outputbit 2 0x6 2 output is already defined in iopagel nome soenan naiean f Derive Register or Bit information from label R Duplicate _ or label __B Ex zeroflag 0x3 2 mov a zeroflag R equal mov a 0x3 mov a zeroflag B equal mov a 0x2 Operation An assembler instruction or directive Directives give the direction to the assembler Instruction examples Example 1 MOV A 0X20 Example 2 ADD A 0X20 Example 3 zeroflag R3 2 status R3 carryflag status 0 org 0x0 jmp start start BC zeroflag BS status 2 BC carryflag BS status 0 BC 0x3 2 BS R3 2 Examples of directives Examplel ORG 0X20 Example2 END EM78 Series IDE User s Guide 6BAssembler and Linker e 77 Chapter 4 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 A 0X20 3 move constant value 32 to accumulator Block comment comment statements 4 3 Number Type Expression 1 Expression 2 Expression 3 Decimal OD lt digits gt lt digits gt D lt digits gt Hexadecimal OX 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 4 4 Assembler Arithmetic Operation The arithmetic result must be calculated after assembler If the arithmetic expression cannot be calculated on assembl
139. piled download your compiled program to ICE by clicking Project gt Dump to ICE or its corresponding shortcut key F3 Mew Open Project Save Project Close Project Add Files to Project Delete files from project a2 Assemble ALLE Shift Alt F9 Rebuild All Alt F9 Trace Log Figure 3 11 Dump to ICE Command 3 9 Debugging a Project With the compiled program successfully downloaded to ICE you are now ready to debug the files Be sure the ICE is properly connected to your computer Full debugging commands are available from the Debug Menu shown with its corresponding shortcut keys in the drop down menu at right A number of the frequently used debugging icons are also available from the eUIDE Program Toolbar from Project Menu Go t Free Run 4 Reset 4 Step Into TP Step Over P Step Out CtrltF Go To Cursor F4 Continue step into Shift F7 Run from Selected Line Stop Fig 3 12a Debugging Commands Drop Down Menu Go Auto dump and run program starting from the current program counter until breakpoint is matched and breakpoint address is F5 executed Free Run Auto dump and run program starting from the current program counter until the Stop button of the Stop Running F10 dialog 1s clicked All defined breakpoints are ignored while the program is running initial values ICE will return to its initial condition Reset Perform hardware reset register
140. ple 2 struct tagSpeechIinfo short rate long size SpeechiInfo union tagTest cher Test 2 gt long RWport t Leste 5 8 Array declarator array declarator array declarator constant expression array declarator constant expression An Array is a collection of same type data and can be accessed with the same name Example int arrayl 3 10 char port 4 const int myarr 2 0x11 Ox2Z2 7 0xll 0X22 will De put at program rom EM78 Series IDE User s Guide 8BC Fundamental Elements e 99 Chapter 5 re 5 9 Pointer declarator type qualifier list declarator A pointer is an index which holds the location of another data or a NULL constant All types of pointer occupy 1 byte Example InG pC 5 10 Operators 5 10 1 Types of Supported Operators The supported operators for the C expression are as follows m Arithmetic operators Increment 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 Oo subtraction ooe Arithmetic Operators Symbol Function Expression 100 e 8BC Fundamental Elements EM78 Series IDE User s Guide Chapter 5 Arithmetic Operators Symbol Function Expression bitwise AND expri amp epxr2 bitwise OR e
141. r s Guide a Chapter 6 6 2 I O Control Page iopage Declare the variable at the register page position You have to clearly declare at which iopage the io variable is located in spite of the fact that there is only one io control page Example io unsigned int myIOCl1 0x05 iopage U myIOC1l is at address 0x05 of io control page 0 io unsigned int myIOC2 0x05 iopage 1 myIOC2 is at address 0x05 of io control page 1 rpage 0 rpage 1 iopage 0 ioage 1 EM78 Series IDE User s Guide 10BC Control Hardware Related Programming e 109 Chapter 6 ae 6 3 Ram Bank lt variable name gt lt address gt bank lt bank numbers Declare the variable at which RAM bank it is located The lt bank number gt has to be indicated including the variable that is declared at Bank 0 Example unsigned int myDatal 0x22 bank 0 myDatal is at address 0x22 of ram bank 0 unsigned int myData2 0x22 bank 1 myData2 is at address 0x22 of ram bank 1 unsigned short myshort 0x20 bank 1 myshort is at address 0x20 and 0x21 of ram bank 1 unsigned long myLong 0x24 bank 1 myLong is at address 0x24 0x27 of ram bank 1 RAM Bank BO 2x tay ft tt C S S S S f BO_3X ar E l Bl2x a a aK E a ee B1 3X BL oe wey SS SS Se myshort 110 e 10BC Control Hardware Related Programming EM78 Series IDE User s Guide 6 4 Bit Data Type bit lt
142. r computer Whether you are connected to network or not does not matter C 2 FAQ on Tiny C Compiler 1 Q It depends on the RAM bank size about 32 or 31 bytes O gt gt O gt 0O gt QO gt What is the maximum number of the function parameters In a function what is the maximum depth of the function call It depends on the hardware stack depth or size What is the maximum array dimension as well as maximum array element It depends on the RAM bank size about 32 or 31 bytes Is there any error message when the code exceeds the ROM size Yes the linker will report an allocation error In a high level interrupt subroutine can I allocate the address in the ROM e g using page data type putting asm org xxx before a subroutine etc No This may cause unpredictable error Is static used in the same way as in ANSI C Yes 156 e 18BFrequently Asked Questions FAQ EM78 Series IDE User s Guide Appendix C 7 Q Is there any error message in case I define too many variables in the const that exceeds the ROM space A Yes the linker will report an allocation error 8 Q How do I declare the variable in file and use such variable in several c files A Declare an h file variable as shown in the following example extern io unsigned int DIRPORT6 Then in c file write the variable as shown below you need to write in just one
143. reakpoint is set at the same time Therefore if you Select the Address Delete Cancel Breakpoint or and Breakpoint nest syntax OxAAAA OxAAAA 0xPP OXAAAA OXAAAA OxPP breakpoint not active Address Address Counter Address Address Counter Breakpoint group syntax option the source level 0xLLLL 0xHHHH 0xPP 0XLLLL 0XHHHH 0xPP breakpoint will become Low_address High _Address Counter effective Figure 2 10 Address Breakpoint Dialog from Address Break Point Command 38 e 2BThe eUIDE Commands EM78 Series IDE User s Guide Chapter 2 There are three types of address breakpoints Group OR and Nest which are contradictory to each other However the setup syntax for OR and Nest is the same but different from Group Breakpoint Group 63 groups are available at most and each group has Start Breakpoint OR Breakpoint Nest EM78 Series IDE User s Guide Address End Address and Pass Count When any instruction 1s executed between Start Address and End Address the Pass Count is deducted by 1 When the Pass Count is equal to 0 the executing program is stopped at once Each of the 63 groups is independent from each other 63 groups are available at most and each group 1s composed of several addresses and a Pass Count When an address is executed within a group Pass Count is deducted by 1 When the Pass Count is equal to 0 a breakpoint occur
144. rsor Continue step into S Run from Selected Line Stop Add Label to Watch Reset and Free Run Reset and Go Run From dh Toggle Breakpoint Show All Breakpoints dh Clear All Breakpoints lt 3 Trace Back c gt Trace Forth Fo F10 Fo Fr Fe Ctrl F F4 Shift F7 FQ Ctrl 4lt Fo Ctrl Fo Ctrl Ctrl k Figure 2 8 Debug Menu 36 e 2BThe eUIDE Commands 127 Cancel Free Run Reset Step Into Step Over Figure 2 7 Dump code over 64K to sram Dialog Run program starting from the current program counter until a breakpoint is matched Run program starting from the current program counter until the OK button of the Stop Running dialog is clicked Perform ICE reset register contents are displayed with initial values Execute the instructions step by step with register contents updated simultaneously Execute instructions as Step Into see above but the CALL instruction will execute as step over EM78 Series IDE User s Guide ol Step Out Go to Cursor Continue step into Run from Selected Line Stop Add Label to Watch Reset and Free Run Reset and Go Run From Toggle Breakpoint Show All Breakpoints Clear All Breakpoints Address Breakpoint Clear All Address Breakpoints Value Breakpoint Trace Back Trace Forth EM78 Series IDE User s Guide Chapter 2 Exit CALL subroutines while executing Step Into in CALL subroutines Run program s
145. rtition the instruction into two or more lines EM78 Series IDE User s Guide 14BAssembly Error Warning Messages e 139 Appendix A Gan 40 error A040 The length of filename filename exceeds 256 Reason The filename length of over 256 Solution Revise the filename or directory 41 Warning A050 The symbol length exceeds 32 Reason The length of the variable is over 32 Solution Change the variable length to within limit 42 Warning A051 The number of messages is over 500 Reason The number of messages exceeds 500 Solution Decrease the number of the messages to within 500 43 Warning A052 Use the number to express number Reason Transform the negative number to hexadecimal 44 Warning A053 The target address of Icall or Ijmp instruction is not over page number K Reason The target address and call or jmp instruction is located in the same page 45 Warning A054 label name unreferenced variable Reason The variable not applicable with the project A 4 Class L Linker Error Messages 1 error L001 Memory of stack type stack overflows Reason O S cannot allocate extra memory Solution Close idle Editor window or close inactive application 2 error L002 The file filename cannot be found Reason The file cannot be found Solution Check whether the file actually exists or missing 3 error L003 The Object file format does not
146. rved words for this compiler ANSI C Conformity Words we do e ston union extem if Cerar enum org sae wid Feontue for reun stuct while O EM78 Series Unique Words Pio topage mean page owm asm bt i bank 5 3 Preprocessor Directives Preprocessor directives always begin with a pound sign The directives are recognized and interpreted by the preprocessor in order to compile the source code properly 5 3 1 include include file name The preprocessor will search the working directory to find the file include lt file_name gt 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 ELAN TCC INCLUDE include tells the preprocessor to add the contents of a header file into the source program 92 e 8BC Fundamental Elements EM78 Series IDE User s Guide Chapter 5 Example 1 include lt EM78 h gt include project h include ad c It may meet errors Example 2 unsigned int uaa 7dan headtile p Frinclude headtile h J 7in tesi codec Tite include kkdr h i in testcode c file inclu ude porr h J jin testcode c file main Z in CeSECOde cC file uaa 0x21 testi testZ 3 testi j J an kkdr h file include pprr h jin KkarscC fi
147. s Each of the 63 groups is independent from each other Assign some address location as groups and specify those groups as a Breakpoint Nest The outer the later specified group must be satisfied first before the inner group can take effect The Breakpoint Nest and breakpoints of program line are contradictory In other words if Breakpoint Nest is active then the program line breakpoints become inactive and vise versa e Breakpoint Nest Setup 1 With reference to Figure 2 10 above enable the Breakpoint nest checkbox 2 Input breakpoint address If the address breakpoint 1s for 0x10 0x20 0x30 0x55 0x15 0x100 0x170 0x10 address location 0x10 0x20 amp 0x30 are assigned to the same group Group 1 A breakpoint is attached to this group and the associated Pass Count of this breakpoint is 0x55 Address locations 0x15 0x100 amp 0x170 are assigned to another group Group 2 A breakpoint is attached to this group and the associated Pass Count of this breakpoint is 0x10 3 Click OK button 4 Execute Go F5 command from Debug menu 2BThe eUIDE Commands e 39 Chapter 2 re 5 Ifthe 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 E Using Address Break Point in Defining a More Complex Breakpoints
148. s is block comment example including multi lines d EOP end of the program ROM page with which the EOP instruction is belong to Syntax EOP Example org 0x10 mov Ox20 A inc 0x20 eop inc 0x20 Result after assembling the first column is address org 0x10 0010 mov 0x20 A 0011 inc 0x20 eop 0400 inc 0x20 e END the end of program The rest of the program code after END instruction will not be assembled Syntax END Example org 0x10 mov 0x20 a inc 0x20 end moy 0x20 a Result after assembling the first column is address org 0x10 0010 moy 0x20 a 0011 inc 0x20 end mov 0x20 a 80 e 6BAssembler and Linker EM78 Series IDE User s Guide oll Chapter 4 f PROC ENDP definition of subroutine The directives make the program more comprehensible Syntax lt label gt PROC lt statements gt ENDP Example BANKO PROC BC 0X04 6 BC 0X04 7 RET ENDP g INCLUDE include other source files The instruction makes the program more refined and clear INCLUDE function can include system default files and user defined files 1 Include system default files e g EMC456 INC EMC32 INC Syntax INCLUDE lt filename gt Example INCLUDE lt EMC456 INC gt 2 Include user defined files Syntax INCLUDE file path file name Example INCLUDE C EMC TEST TEST456 INC The user defined file must include full folder path and filename h PUBLIC and EXTERN The defined scope of the global label is
149. s to the address where Trace Back was started top to bottom l e ale S zl Stop Stop Free Run or Go with breakpoint ignored e 2 During debugging the contents of Program Counter Registers and RAMs are read and displayed each time the program is stopped to provide important interim information during program debugging 72 e 4BGetting Started EM78 Series IDE User s Guide Chapter 3 3 9 1 Breakpoints Setting Breakpoint 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 green With cursor positioned on the line you can also click on the K Insert Remove Breakpoint icon hand shape on the toolbar to set a breakpoint or press F9 Likewise the defined break point is cleared if you double click on it again or the hand icon is clicked the second time while the cursor is positioned on the defined breakpoint To clear all existing breakpoints click Clear All Breakpoints command from Debug menu Breakpoint EM78 Series IDE User s Guide 4BGetting Started e 73 Chapter 3 74 e 4BGetting Started EM78 Series IDE User s Guide ol Chapter 4 Chapter 4 Assembler and Linker 4 1 Assembler and Linker Process Flow Including files EASM EASM EASM a Ti cs T List file Ist N N N RN Target file cds Figure 4 1 Assembler and Linker Process Flow Chart EM78
150. scade Rearrange all Editor window Re Windows Tile Vertical Rearrange all opened Editor F windows vertically Figure 2 21 Window e i gu Maan Tile Horizontal Rearrange all opened Editor windows horizontally Arrange Icons Arrange all opened file filenames in a single line formation minimized into multiple file icons at the bottom of the Editor window Close All Close all opened files Windows Show Select Window Dialog EM78 Series IDE User s Guide 2BThe eUIDE Commands e 55 Chapter 2 re 2 1 9 Help Menu User Manual User Manual Open the eUIDE User s Manual Check New Version About Check New Check new version of eUIDE from Register ELAN Version ELAN About Shows the current version of eUIDE program and other information including a read me file on recent changes of the eUIDE Figure 2 22a Help Menu About Shows the current version of eUIDE program and other information including a ReadMe file on recent changes of the eUIDE About eUIDE ELAN C Compiler for ICE View What s New eVIDE Version 1 00 12 Copyright 2009 ELAN Microelectronics Inc All rights reserved Web http Avww emc com tw Figure 2 22b About Command Dialog Register ELAN On line registration with ELAN Update USB Glue Update USB UICE firmware if necessary Firmware 56 e 2BThe eUIDE Commands EM78 Series IDE User s Guide a Chapter 3 Chapter 3 Getting Started 3 1 Overv
151. set Project Type o Click ASM option button to create an Assembly language project o Click C option button to create a C language project E To set Library Output Oo Select Normal cds from Library Output pane to create a general project It will generate objective bbj file list Ist file binary cds file after project is created with Build command Oo Select Library lib to create a library project It will generate objective bbj file list Ist file library lib file after project is created with Build command 62 e 4BGetting Started EM78 Series IDE User s Guide Chapter 3 Step A Add a new file or an existing file to your project Create a new file File Name Testl 53 File Location CAEM78TestlC153 C Select an existing file elect File Figure 3 4d Project Wizard Step 4 of 5 Dialog E To Create a new empty file Enable the Create a new file button and type a filename in the File Name text box A file with the defined filename will be created and save in the folder location as defined in the File Location text box E To Select an existing file p Insert Files into Project If you already have an Look in EM78Test C153 amp existing file that you would crest E cTest_bp bbj i f CTest i CTest_bp dt like to add to the new project ficrest Ist IE crest _bp Ist ore 2 cTest mi E CTest_b _rmk dt cli
152. shortcut Saar eae eae keys CTRL F2 Go To Index BookMarks Next Bookmark Clear All Bookmarks Ctrl Shift F2 2 Then go to the bookmarked lines For example ifyou Ademetch o have previously book Figure 1 3g An Example of a BookMarks Command marked Lines 1 5 and 8 Execution 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 aoe Oey 2 jmp sl bookmarked line previous to the current 3 arg OxO0 position or directly press the shortcut A si keys SHIFT F2 nap ne Click Next to go downward to the 7 ane bookmarked line next to the current 8 nop position or directly press the shortcut J jmp sl keys CTRL SHIFT F2 Click Clear All to remove all existing 94 1 3 An Example of Lines Book bookmarks marked at Lines 1 5 amp 8 Index BookMarks Embed bookmarks with index numbers With indexed bookmarks you can directly access to the bookmarked line you wish to return to To embed index number into existing H aphia Copy Ctrl C bookmarks place cursor on the Paste Ctrl V selected bookmarked line then click Previous Position Index BookMarks gt Toggle ere l BookMarks x where x is the 0 Clear All Index Bookmarks 9 EO TUON EEEE Toggle Bookmark O Ctri 0 Toggle Bookmark 1 Ctri 1 Toggle Bookmark 2 Ctri 2 You can also directly press the _
153. stablish a segment However when 2 or more separate segments constitute a non separable object or character e g i J all integral segments should be assigned with the same COM SEG value Otherwise the program will assume that there are 2 or more separate segments 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 separated 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 incorrectly assume that there is only one single segment Figure 1 10 EEPROM Window Showing Rows 30 amp 40 Disabled The EEPROM window is accessible only if EEPROM is available from the target microcontroller currently in use The EEPROM window shows the contents of the data EEPROM Note that when the EEPROM window is closed it ceases to interact or read the hardware contents 24 e Introduction EM78 Series IDE User s Guide Chapter 1 Reading all EEPROM data is time consuming It needs almost 8 seconds to read 256 bytes To minimize reading time you can disable the EEPROM data that you do not need to read by clicking the row header of each row that you do not wish to read The disabled rows will have their data dimmed and are excluded from updating process To restore updating to the disabled rows click the row header
154. sted breakpoints consis ting of groups of address locations with each group assigned with a counter number a Select the Breakpoint nest option b Enter the breakpoint address es and a counter in the format of breakpointAddress1 000 0401 0 0 35 0402 breakpointAddress2 counter The figure at right shows an example with OX00 0X01 0X03 OX02 This means that the program will run address 0x03 twice run address 0x00 only once and then terminate c Click OK button to save the settings You should see the breakpoints indicated in the Editor window or as shown in the figure at right d Click Go command Debug gt Go to see the steps and result of the code execution as shown in the figure at right 42 e 2BThe eUIDE Commands EM78 Series IDE User s Guide Chapter 2 NOTES 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 Breakpoints solid blue dot created through the Address Break Point command as 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 the red ones when Go c
155. symbols exceeds limit Solution Partition the program into two or more small programs error D016 Dump program before adding label to watch Reason Program has to be dumped first before adding label to watch Solution Dump program to ICE then add label to watch error D017 Trace log is empty Reason No data found during Trace Log F2 operation Solution Stop executing the Trace Log operation error D018 No trace item in trace log Reason No data found during Trace Log F2 operation Solution Stop executing the Trace Log operation error D019 Stack overflow The stack number number exceeds the max number number Reason The stack went over the hardware design capacity Solution Decrease the number of calls error D020 The file filename does not exist Reason The file cannot be found in the directory Solution Check whether the file exists or not Warning D021 External Memory is in error Reason The external ICE SRAM memory is in error Solution Change the external ICE SRAM or check whether the crystal is normal or not EM78 Series IDE User s Guide 14BAssembly Error Warning Messages e 143 Appendix A en 22 error D022 File filename was modified by user Can t read anymore Please Rebuild All Reason The file has been modified Solution Execute Rebuild All command 23 error D023 File filename does not exist Execute Rebuild All to generate t
156. t 9 error M009 The project filename does not conform with ELAN project file format Reason The project content is not of ELAN project format Solution Create a new project file 10 error M010 The file filename does not exist Reason The file cannot be found in the directory Solution Check whether the file exists or not 11 error M011 The file filename cannot be opened Reason The file cannot be opened by O S Solution Check whether the file actually exists or not 12 error M012 The file filename size is over number k of the max limit of number k Reason The file size is over the maximum size of buffer with which the Editor window is allocated Solution Partition the file into two or more segments 13 error M013 The copy size number exceeds by number k over the max size of number k Reason The copy size exceeds the maximum size of the copy buffer Solution Decrease the segment size of the copy content 14 error M014 Memory cannot be allocated Reason System cannot allocate more memory for further use Solution Close Editor windows or application programs that are idle 134 e 14BAssembly Error Warning Messages EM78 Series IDE User s Guide Appendix A 15 error M015 Line is over 250 characters 16 17 18 19 20 21 A 3 Class Reason The Editor window can only accommodate a maximum of 250 characters per line Solution Split
157. t action to identify the EE current level position of the i sub_27 H stack It then changes the value 13 noe T of the last stack level value from i ee 0x0003 to 0x0000 as indicated iat sub_29 7 in the figure at right 127 cet To set the values of the higher Figure 1 5e Using Step by Step F7 Execution to stacks level to 0x0000 continue Change the Last Stack Level Value to perform Step by Step execution This will not affect the normal stack operation as indicated in the figure below ed stack dt Project PE 082 sub_21 j EM78808 STETR APJ a sub_22 H 2 Source Files ane E stack dt l E Header Files O36 sub_22 H E List Files 097 sub_23 A stack Ist 098 al 099 100 sub_23 101 102 103 4 sub_ 74 105 106 107 108 sub_25 109 110 111 I2 sub_26 4 Map Files Library Files Figure 1 5f Executing Step by Step to Change the Values of the Higher Level Stacks Currently eUIDE remains unable to determine the correct stack level position at which the ICE stops This is due to the ICE hardware limitation which unable the eUIDE Call Stack window to properly display the correct stack level position However this does not affect whatsoever the actual normal stack operation EM78 Series IDE User s Guide Introduction e 13 Chapter 1 1 2 2 5 RAM Bank General Registers Window __ o r_2 2 a 5 Je a e 9 a fe fc o e IF BO 2 FF FElFE OFF OER FF FF FF FF FF FF FF FF
158. t Window EM78 Series IDE User s Guide Introduction e 3 Chapter 1 4 e Introduction re The following explains the functions of the 3 commands in the pop up menu Open Opens the selected file For example right clicking on 447test dt the file then opens If the file is already opened no action is performed Properties Displays the complete path of the selected file or as illustrated in the following figure which shows where the 447test dt file is located Filename gt DAEMCUC P44 44 Test dt Figure 1 2c An Example of a Complete Path of the 447test dt File 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 file a confirmation dialog will display Click the Yes to remove the file from the project Otherwise click No ELAN IDE Figure 1 2d Removing a File from Project Source Files Dialog E Label Function View Mode To access the Label Function View window click the Label Function View tab at the bottom of the Project window After performing a code dump eUIDE will automatically determines the gt functions from C code see figure at left and labels from ASM code The _ result is then displayed in the Label Function View mode of the Project window categorized by files Figure 1 2e Project Window in Label Fu
159. t name and micro controller you have selected is displayed at the top of the Project window Project Filename apj for ASM mode or es cpj for C mode Target Ea test dt Microcontroller Header Files List Files E test lst lt 3 Map Files E3 Library Files Figure 3 5d Project Window Showing Target IC amp Project Filename EM78 Series IDE User s Guide 4BGetting Started e 65 Chapter 3 ae 3 5 Add and Remove Source Files from to Project You can either insert existing source files into the new or existing project or create new ones with eUIDE text Editor and insert them into the project 3 5 1 Create and Add a New Source File for the Project If your source file 1s yet to be created you can take advantage of the New dialog by clicking NEW command from the File or Project menu to create your new source file and use the eUIDE text editor to compose its content 1 From the New dialog click the Create a New File tab and select the type of source file you want to create from the EMC Source File list box 1 e dt default for Asm mode or c for C mode for assembly file h for header file Hew i 2 Create a New File Projects ELAN Source Alef d amen file to project ELAN Header Filet h 1 ELAN Source Filet asm Empty File ELAN Header Filet inc ELAN Header Filet mac ELAN Header Filet dey SLAN Header File46q File Name estcode 3 File Location F TEMP eUIDEV1 ONIC468 4 5 C
160. tPc with Sk step log Program is kept running starting from the Initial with 4k 4k step log initial address until a breakpoint is matched Only the last 8K steps of execu tion history are stored in the trace buffer CurrentPe with 4k 4k step log Figure 2 9 Run From Command Sub Menu Current PC with 8K Step log Program is kept running starting from the current program counter until a breakpoint is matched Only the last 8K steps of execution history are stored in the trace buffer Initial with 4K 4K log Program is kept running starting from the initial address until a breakpoint is matched Only the last 8K steps of execution history 4K steps before and 4K steps after the matched breakpoint are stored in the trace buffer Current PC with 4K 4K log Program is kept running starting from the current program counter until a breakpoint is matched Only the last 8K steps of execution history 4K steps before and 4K steps after the matched breakpoint are stored in the trace buffer 2 1 5 2 Address Breakpoint Dialog Function Description The breakpoint set up Pa method in this dialog IS to Address breakpoint not active use an address breakpoint Mae al a C Breakpoint or that contradicts with the C Breakpoint nest source level breakpoint o 1 e the source level 0x09 0x1 0x11 0x20 0x01 breakpoint will be 0x11 0Xx1 0x12 0 1 0X13 0X1 x 0x11 0x1 0x20 0x1 ineffective if an address yak pee mit b
161. tarting from the current program counter up to the location where the cursor is anchored applies to ICE debug mode only Perform Step into command function non stop Start running command from the line where the cursor 1s located Stop Free Run or Go command execution without matching breakpoint Add or delete variables from the Watch window See details in Section 1 2 2 6 Watch Window Reset hardware ICE and then execute the Free Run command function Reset hardware ICE and then execute the Go command function See Section 2 1 5 2 below for the resulting sub menu and its functions Set or remove a breakpoint Show all breakpoints setup data in the Output window Clear all breakpoints Define addresses for the breakpoints See Section 2 1 5 3 below for the resulting sub menu and its functions Clear all address breakpoints TCC R3 value breakpoint for PC Peripheral IC Trace the executed trace log backward from the last executed address to the address before the current executed address The highlighted address moves backward step by step each time the command is clicked Retrace the trace log address forward top to bottom or at reverse direction of Trace Back command Applicable only after Trace Back command is performed 2BThe eUIDE Commands e 37 Chapter 2 re 2 1 5 1 Run From Command Sub Menu Function Description Where Sa Initial with Sk step log Initial with 8K Step log Curren
162. ted register value will display Check mark denotes selected value is already in hex B2 90 Fi FF 76 FD The following describes each of the menu commands Figure 1 6d Right Click on the Selected Value to Display the Binary Hex Edit Binary Switches the register NANAS value from hex to binary format If the value is already in binary this command is prefixed with a check mark v Figure 1 6e Click Hex Command to Switch Hex Binary Register Value into Hex and Vise Versa Switches the register value from binary to hex format Ifthe value is already in hex this command is prefixed with a check mark Edit This command auto selects the clicked value and allows you to change the value by editing This is the same as double clicking on the value as explained above However using this Edit command function is preferable 1 2 2 6 Watch Window i al Name Address Type AA 0x20 Bank Uj BE Ux sF Bank 0 DD 0x06 Control 0 EE Ux Control 1 EE Ux lu Register U THN Maton Wath Wak A Figure 1 7a Watch Window With 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 Refer to Section 4 2 Statement Syntax for more details on assembly codes EM78 Series IDE User s Guide Introduction e 15 Chapter 1 16 e Introduction am To view real time chan
163. that have LJMP LCALL instructions AET ge Instruction If label is in current page XCALL will ACALE XCALL Label he GALL otherwise it will be LCALL CALL OR LCALL If label is in current page XJMP will AIME XJMP Label be JMP otherwise it will be LUMP YMP or LUMP Syntax Note Equivalent Instruction EM78 Series IDE User s Guide 6BAssembler and Linker e 89 Chapter 4 90 e 6BAssembler and Linker EM78 Series IDE User s Guide a Chapter 5 Chapter 5 C Fundamental Elements 5 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 segment of the source code thus no extra memory is required in the program execution Example This is a single line comment ri This is the comment line 1 This is the comment dine 2 7 7 EM78 Series IDE User s Guide 8BC Fundamental Elements e 91 Chapter 5 tm 5 2 Reserved Words The reserved words for eUIDE 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 rese
164. the Project To add a new second C file to the project call New dialog again This time you have to enable the Empty File checkbox in the Create a New file tab Enable Empty File checkbox if Source File c is selected otherwise don t care Create a New File Projects ELAN Source File c ELAN Header File h V Add new file to project Empty File File Name ithesecond File Location F TEMP eUIDEV1 0 IC468 Figure 7 3a Adding a New Second File or Head File to the Project Enter a filename without suffix and click OK button The eUIDE will create a new and empty C file or Header file if Header File h is selected in the left list box as show in the figure above The following shows an example of a project template with a number of C files and one header file kkbbic thesecond c headfile h som on EM78P468H test cpj source Files kkbbic 2 thesecond c Header Files 2 headfile h List Files TEST Ist OO void main 002 003 004 005 O06 void _intceall tec_l void Ox03 low_int 0 O07 008 _asm 009 010 PAGE 0X0 011 012 O13 void _intcall tec void int 0 014 015 backup R4 016 _asm 017 018 SWAPA 0x04 019 MOV Ox1F A 020 021 022 backup C system 23 asm Figure 7 3b An Example of a Created Project Template with Two C Files an
165. thmetic expression all variables are int data type 152 e 16BC Conversion Table C Statement Assembly Code MOV 0x14 A AND A 0xE0 MOV 0x1C A SUB 0x1C A MOV A 0x18 yT Conversion Rate Compilers Code Size General User s Code Size 100 100 7 7 100 100 4 4 100 100 3 3 100 100 3 3 100 100 1 1 100 100 1 1 100 100 9 9 100 100 11 11 100 EM78 Series IDE User s Guide Description Compound assignment all variables are int data type EM78 Series IDE User s Guide Appendix B C Statement Conversion Rate Example Assembly Code Compiler s Code Size General User s Code Size 100 A e 100 2 2 100 f A f A f A f A OR f A BC 0x03 0 100 2 2 100 BC 0x03 0 100 2 2 100 16BC Conversion Table e 153 Appendix B 154 e 16BC Conversion Table EM78 Series IDE User s Guide Gn Appendix C Appendix C Frequently Asked Questions FAQ C 1 FAQ on Assembly 1 Q ICE cannot connect to PC A Please check the following steps Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Check the power supply with output around the voltage range of 17 23V Check the printer USB cable between ICE and PC Check the oscillator on the hardware From the Option menu choose ICE code option Check the type of oscillator in the code option If the problem still exists then ch
166. us Bar Document Bar Supported in C Project only 34 e 2BThe eUIDE Commands Project Show hide Project window Special Registers Show hide Special Register window General Registers Show hide General Register Bank Bank window Call Stack Data Show hide Call Stack window Data RAM Show hide Data RAM window if supported by the target chip LCD Data Show hide LCD Data window if supported by the target chip Output Show hide Output window Watch Show hide Watch window Show hide Assembly Code 1n from Editor window After first dump to ICE F3 enable this checkbox to display assembly code with C source Maximize the Editor window Show hide Standard Build or both toolbars Show hide Status bar Show hide Document bar EM78 Series IDE User s Guide Chapter 2 2 1 4 Project Menu Project Wizard Mew Open Project Save Project Close Project Add Files to Project Delete files from project Alt F Shift Alt Fo Rebuild All Alt F9 Dump to ICE F3 Trace Log F2 Figure 2 6 Project Menu Delete Files from Project Assemble or Compile under C Project Build Rebuild All Dump to ICE Trace Log Dump code over 64K to sram This command applies to EM78815 only EM78 Series IDE User s Guide Project Wizard Create a new project with step by step dialog see Section 3 4 1 for details New Create a new project with New dialog see Section 3 4 2 for details
167. uto dump and execute program step by step excluding the subroutines F8 Step Out auto dump and execute program until exit from subroutines Ctrl F7 EM78 Series IDE User s Guide Chapter 1 31 Go to Cursor auto dump and execute program then stop at the cursor position while ignoring the breakpoint F4 32 Run from Selected Line Start running command from the line meses where the cursor is located 33 Toggle Breakpoint insert remove toggle for breakpoints F9 34 Clear All Breakpoints remove all breakpoints Trace Back Trace the executed trace log backward from the last 35 executed address to the address before the current executed address Trace Forth Retrace the trace log address forward top to 36 bottom or at reverse direction of Trace Back command 37 Stop Stop Free Run or Go without break point E Chinese Characters Code Conversion Hotkeys Applicable to eUIDE source files written and used in Chinese speaking areas 1 Ctrl Alt Shift G Convert Traditional Chinese Big5 to Simplified Chinese GB 2 Ctrl Alt Shift B Convert Simplified Chinese GB to Traditional Chinese Big5 3 Ctrl Alt Shift Z Undo the last conversion 1 2 4 2 Document Bar EM foPa4 _EsT INT C 1i Emrand4 xx h Figure 1 13 eUIDE 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
168. variable name gt Chapter 6 Bit data type occupies only one bit Example bic myBitly bit MyBitZ 0x03 bit myBit3 0x04 bit myBit4 0x05 bit mMyBits 008x22 EM78 Series IDE User s Guide rpage 0 5 rpage 1 6 rpage 1 3 gt bank 1 vi I ta ae a location of myBitl is assigned by linker if doesn t declare bit sequence the default location is at bit 0 Therefore myBit2 is at bit O of 0x03 of rpage U myBit3s is at bit 5 of 0x04 rpage 1 myBit4 is at 0x05 bit 6 of rpage 1 myBitS 26 20 0x22 Dit 3 OF ram bank 1 10BC Control Hardware Related Programming e 111 Chapter 6 myBit2 is at 0x03 bit 0 myBit3 is at 0x04 bit 5 myBit4 is at 0x05 bit 6 of rpage 1 RAM Bank a s4 gt l myBit5 is at 0x22 bit 3 of RAM bank 1 6 5 Data LCD RAM Indirect Addressing Declare the variable at which indirect data RAM or LCD ram is located The lt ind number gt has to be indicated if address is assigned 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 7 de faulre is ind 0 s0 nDatal 15 at Data Ram indir int nData2 00x30 ind 0 nData2 is at Data Ram because ind 0 is used indir int mDatcas COx0L ind 1 Ji NDACAS 18 at LCD Ram because ind 1 is used 112 e 10BC Control Hardware Related Pr
169. vert a String to a Float atof cc ccccccccsssssssssssssseeeeeceeeeeeeeeesaaeeees 185 F 6 36 Convert a String to an Integer atoi atol oo eecccceeeeececeeeeeeeeeeeaeaaaes 186 F 6 37 Random Number Generator rand srand 0 0 0 eee eeecesecceecccessceesecensecs 186 F 6 38 Compute the Absolute Value of an Integer abs labs eee 187 E7 Application INOUCS oen ASE E E EEE 187 e ix Contents User s Manual Revision History Doc Version Revision Description Date User s Guide Initial Preliminary Version 2009 07 08 User s Guide Initial Official Version 2009 11 11 2010 05 06 0 1 Modified amp added new info to Section 3 4 Create a New Project Added Appendix F C Standard Library Xe EM78 Series IDE User s Guide au Chapter 1 Chapter 1 Introduction 1 1 Overview The EM78 Series Integrated Development Environment is a project oriented development tool for ELAN s EM78 Series microcontrollers It comprises of the UICE development in circuit emulator and the eUIDE software tool 1 2 Introduction to eUIDE Program The eUIDE is a Windows 2000 or Windows XP based program for UICE development in circuit emulator that is used in the development of EM78 Series 8 bit microcontrollers of ELAN The aims of the eUIDE are to provide a friendly operation environment powerful functions a high speed transmission and a stable system during development of the microcontrollers
170. xisting 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 you want to remove and click Remove button to delete Restoring all shortcut keys to their default settings Click Reset All button to reset all command shortcut keys back to the eUIDE default settings Saving Loading settings To save your custom shortcut keys for future use e g when upgrading eUIDE to a new version click Save to File button to store the settings to a file with a KEY file extension After installing a new version of eUIDE you can simply click Load from file button to re apply your custom shortcut keys into the new eUIDE 54 e 2BThe eUIDE Commands EM78 Series IDE User s Guide au Chapter 2 Option tab Customize Figure 2 20d Customize Command Dialog Showing Option Tab 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 eUIDE sub windows to look like that of Windows 2000 2 1 8 Window Menu New Window New Window Open a new or split Editor window E Cascade ae BS active files so that they will ES Tile Horizontal appear overlapping in sequence Arrange Icons with their respective title bar Close all fully visible Ca
171. xpr1 expr2 gt gt right shift expr1 gt gt expr2 lt lt left shift expr1 lt lt expr2 A bitwise XOR expr1 expr2 Equality Relational and Logical Operators Function Expression Example a8 lt lt gt gt Compound Assignment Operators Function Example Key EM78 Series IDE User s Guide 8BC Fundamental Elements e 101 Chapter 5 5 10 2 Prefix of Operators Priority Same Level Operators from Left To Right Highest L gt unary unary type cast indirection amp address sizeof 8 gt gt lt lt 5 11 if else Statement if expression statement else statement If statement executes the block of codes associated with it when the evaluated condition is true It 1s optional to have an else block is executed when the evaluated condition 1s false Example if flag 1 timeout 1 flag 0 else timeout 0 102 e 8BC Fundamental Elements EM78 Series IDE User s Guide Chapter 5 re 5 12 Switch Statement switch expression case const expr statements case const expr statements default statements Switch statement is flexible to be set with multiple branches depending on a single evaluated value Example Switch I case 0 function0 break case 1 functionl break case 2 functionZ break default funerror 5 13 While Statement While stat
172. you want to edit The file is automatically opened in the Editor window To edit source files that are already added into the Project see next Section 68 e 4BGetting Started EM78 Series IDE User s Guide Double click to open amp edit a file Source file opened for editing Chapter 3 3 6 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 ajx Tl org 0x0 2 start 3 mow a 0x02 4 mov Ox20 a 5 mov Ox21 a 6 inc 0x20 7 i Sy EM78569 test apj Sq Source Files testdt 3 Header Files EJ List Files J Map Files 4 Library File ine Uzzi jmp start Figure 3 9 Editing Source File Directly from Project Window 3 Compile the Project Broject Weard With your source file s embedded into the NEW project you are now ready to compile your Soa project using the following commands from Project menu Save Project Close Project Add Files to Project m Click Assemble or Compile command to Delete files from project compile the active file only generates st 4 m Click Build command to compile the files Shift Alt FS Rebuild All AIt F9 modified in the project they were modified Dump to ICE Trace Log m Click Rebuild All command to compile all files in the project regardless of whether

Download Pdf Manuals

image

Related Search

Related Contents

AWS888 French r10    Enlogic EN1113 power distribution unit PDU  Typ/Type 9172 Ex i Relaismodul I.S. Relay Module  Untitled - F5 Networks Inc.  Manual de Usuario Kalley K-OPAL4LE y K  T2424zA LCD Monitor User`s Guide  取扱説明書 - 第一電波工業  Hoja de Seguridad - Fresenius Medical Care  da monofolha  

Copyright © All rights reserved.
Failed to retrieve file