M2IDE Users Manual V10 en
M2IDE Users Manual V10 en
SONiX reserves all of rights for further explanation on the improvements of reliability, functionality and design of the
following products. SONiX assumes no responsibility caused by the application and use of products or circuit covered in this
manual. SONiX’s products are not designed for the application in surgical implants, life sustaining, and other fields that the
failure of SONiX’s product may cause injury or death to individual. If SONiX’s products are used in the above mentioned
fields, even if these are resulted from the negligence in the product design and manufacturing by SONiX, the user shall
indemnify all costs, losses, and the attorneys' fees directly or indirectly generated from reasonable personal injury or death,
and ensure that SONiX and its employees, subsidiaries, affiliates and distributors have nothing to do with the above matters.
Content
MODIFICATION RECORDS........................................................................................................................................................... 2
CONTENT .......................................................................................................................................................................................... 3
PREFACE ............................................................................................................................................................................................ 4
CHAPTER 1 SYSTEM OVERVIEW AND INSTALLATION ....................................................................................................... 5
1.1 M2IDE INTRODUCTION ........................................................................................................................................................... 5
1.2 INSTALLATION ......................................................................................................................................................................... 5
1.2.1 System Configuration Requirements ........................................................................................................................... 5
1.2.2 Hardware Installation ................................................................................................................................................. 5
1.2.3 Software Installation ................................................................................................................................................... 7
CHAPTER 2 WINDOWS INTERFACE ........................................................................................................................................ 13
2.1 QUICK START ........................................................................................................................................................................ 13
2.2 MENU - FILE / EDIT / VIEW / DEBUG / AUXILIARY / WINDOWS / HELP OPTIONS..................................................................... 14
2.2.1 Start M2IDE System .................................................................................................................................................. 14
2.2.2 M2IDE Interface ....................................................................................................................................................... 16
2.2.3 File menu(File) .................................................................................................................................................... 19
2.2.4 Edit Menu(Edit) ................................................................................................................................................... 22
2.2.5 View Menu(View) ................................................................................................................................................. 26
2.2.6 Debug Menu(Debug) ........................................................................................................................................... 27
2.2.7 Utility Menu(Utility) ............................................................................................................................................ 31
2.2.8 Window Menu(Window) ....................................................................................................................................... 33
2.2.9 Help Menu(Help) ................................................................................................................................................. 34
2.2.10 Windows Management ............................................................................................................................................ 35
2.3 CREATE AND DEBUG APPLICATION PROGRAMS ..................................................................................................................... 38
2.3.1 Create a Project /New File ........................................................................................................................................ 38
2.3.2 Compiling and Linking of Program .......................................................................................................................... 44
2.3.3 Running and Debugging of Program ........................................................................................................................ 46
2.3.4 Compiling Option (Code Option) .............................................................................................................................. 51
2.3.5 Types of Project File ................................................................................................................................................. 52
2.4 HOW TO EMULATE LCD ........................................................................................................................................................ 53
CHAPTER 3 DEVELOPMENT LANGUAGE .............................................................................................................................. 54
3.1 INSTRUCTION SET .................................................................................................................................................................. 54
3.2 PSEUDO-INSTRUCTION ........................................................................................................................................................... 56
3.3 INCLUDE FILE ........................................................................................................................................................................ 57
3.4 MACRO.................................................................................................................................................................................. 58
3.5 CONDITIONAL COMPILATION CONTROL................................................................................................................................. 62
APPENDIX........................................................................................................................................................................................ 65
APPENDIX I COMPILER ERROR INFORAMTION DESCRIPTION ....................................................................................................... 65
APPENDIX II LIST OF MENU COMMANDS, TOOLS AND SHORTCUTS ............................................................................................. 69
APPENDIX III PSEUDO-INSTRUCTION LIST ................................................................................................................................... 72
APPENDIX IV FIGURE LIST .......................................................................................................................................................... 73
APPENDIX V. RELEVANT FAQ ..................................................................................................................................................... 75
Preface
For Sonix 8-bit micro-controller, the development system of SN8P2XXX series is adopted the on-line emulator (ICE),
while the software operating in PC is M2IDE or SN8 C Studio.
The user can login www.sonix.com.tw to download the latest installation file of M2IDE.
M2IDE Features:
Real-time emulation for program and command
Convenient application and installation
Universal windows interface
Support the operating platform of multi-source program file (a application item can contain more than one source
program file)
Support the software-simulating LCD emulation
1.2 Installation
1.2.1 System Configuration Requirements
Power Adapter
Emulator
Cable
Cable ICE EV-KIT Target Board
SONiX also provides UTP device, to convert Printer Port to USB Port;
In order to ensure the normal operation of M2IDE, the installation environment must meet the minimum configuration
requirements, and the conditions are as follows:
Windows 98/2000/ XP/ Vista operation system
32 MB available space of hard disk at least
32 MB space of memory at least
Before the hardware connection, please confirm the power supply of ICE is Off!
1. Connect SN8ICE 2K / SN8ICE_USB / SN8ICE 2K Plus on-line emulator with LPT port of PC via parallel port
cable;
The laptop user can use the tool of UTP provided by SONiX for connection;
SN8ICE 2K Plus II on-line emulator is connected with USB interface of PC via USB cable.
2. Select suitable LPT port;
3. Emulator together with DC power supply(it must use the specialized DC power supply) ;
4. After the development software M2IDE_Vxxx is installed, it can edit, compile or emulate program.
Please refer to SONiX's SN8ICE2K Easy GuideV1.0 for more information about emulator, the user can downloard from
internet.
Click “Next”, at that time an agreement dialog box will pop up (as shown in Figure 1-5), it asks the user to carefully
read the License agreement on software application, if you want to continue, the item “I agree to the terms of this license
agreement” must be selected.
Click “Next” again, the dialog box of installation configuration information will pop up, as shown in Figure 1-9, which
contains the relevant information about installation path and shortcut direction, if confirmed, you can click “Next”, at this
time the installation progress window will pop up, as shown in Figure 1-10.
Finally the window of installation completion will pop up, as shown in Figure 1-11, indicating that the program has
been successfully installed, and then click “Finish” to end the installation. At this time, you can see the shortcut icon of
M2IDE_V119 on the desktop, as shown in Figure 1-12, you can double click it to enter the integrated development
environment.
If it is the first time to use M2Asm, M2Asm will automatically open SN8Readme.txt and display the dialog box of
Welcome.
At every upgrade of M2IDE compiler, the information of new compiler will be added in SN8Readme.txt, before using
the compiler, you shall carefully read this specification.
If you do not want to show this image every time, you may select the small box in front of ―Don't show SN8Readme.txt
at next time‖ and then click OK.
In addition, you can also open SN8Readme.txt through the following methods:
1) To execute: Start/Programs /Sonix/M2IDE_V119/SN8Readme.txt;
2) View this file in the installation directory of compiler.
工具菜单栏
项目名称栏
快捷图标栏
编辑窗口
工程项目窗口
输出信息窗口
寄存器窗口
编辑窗口
调用和堆栈窗
口
输出信息窗
变量窗口 观察窗口
口
存储器窗口
状态栏
Figure 2-4. Debugging Interface
The brief descriptions of the role and function of various windows are in the following.
Menu bar
Menu bar is to provide a variety of operation menus, for example, creating project, editing, compiling program, linking
and debugging and so on.
Editing window
Editing window is to input and modify the program.
Status Bar
It is to display the current debugging state, including running and stopped state, and the current row of program.
The information displayed in status bar is helpful in the compiling and debugging phase of program. For example, in the
editing of program, to indicate the value of row and column, the data behind Ln means the current row of cursor, while Col
means the current column of cursor, (the two fields on the far right of status bar) shows the current position of cursor.
Indicate ―Simu ...‖ during compiling, and indicate ―ICE Run ...‖ in runtime, and indicate ―ICE Stop‖ when the
operation is stopped.
The user can click right key on the blank part of toolbar or status bar, to select ―Staus Bar‖ to display or close the status
bar.
Project window
Project window is divided into two pages, Fileview page shows the information of current project group; Infoview page
shows all the labels in the current project, and the program line can be marked, so it’s convenient to the user to debug the
program.
Output window
Output window is divided into five pages: Build, Debug, Log, Find in Files1 and Find in Files2.
Build page shows the information in the creation of project, including compiling, linking, checking, code size, warning,
error, and other information.
Note:
Checksum: the user can perform Checksum via the Writer, to determine whether the information to be programmed into
IC is correct.
IDE of SONiX is used to compile, after a successful compilation, some information about code will be given in the
output information bar of IDE.
If the user starts the encryption option ―Enable Security‖, after compilation it will generate two values of Checksum ---
EPROM Checksum and Security Checksum; otherwise it will generate only one Checksum --- EPROM Checksum;
EPROM Checksum refers to the Checksum value of user’s source code;
Security Checksum refers to the Checksum value of user’s code under the encryption mechanism of SONiX;
Debug page shows the number of instructions executed by the program, the execution time and other information. Find
in Files page is used to display all lists of a certain string in a specified file. Cyc: to indicate the instruction cycle to execute
instruction;
Cyc/Sec: program is stopped after running, the rate of program execution can be roughly estimated according to this
data;
Trace: to save the content of last executed 1024 instructions, press Ctrl + Shift + F11, to draw back the program and
observe.
Variables window
Variables window is to show the current variable changed during operation in AUTO status. It is same as the
observation window, to show the current value of variable, and the display formats of the two are the same, but it cannot be
set in the variables window. This window will be shown up in debugging mode. The user can select Debug Windows via the
View menu, after the drop-down menu is popped up, and then select Variables item to open or close the window (if the
window is not opened, to execute this command can open the window; if the window has been opened, to execute this
command can close the window). Generally, the window automatically displays the value of variable affected by the current
instruction and the next two instructions, it’s convenient to real-time track the variables in the current program.
The stack is increased hierarchy from 0 upwards, each stack-in operation make the number of stack layer to increase 1
(for example, CALL instruction or interrupt response, and each stack-out operation make the number of stack layer to
decrease 1 (RET or RETI instruction). The entry address of current stack is displayed in Stack window, the outermost layer is
shown in the lowest layer, and it will show $ 00000 if no stacks.
Calls and stack window is to display the use situation of stack and the address of stack-in subprogram or interrupted
subprogram in the current running state. The user can determine the calling situation of program according to such
information and further determine whether the current status is correct and there are any errors in calling.
Memory window
Memory window is to respectively display the current data and code in the data memory and program memory. The
memory window of most MCUs has three pages: RAM1, RAM2 and ROM pages. However, there are some exceptions, for
example, USB series MCUs have USB FIFO 0, USB FIFO 1, and SN8P2308 has LCD page, etc.
This window is only shown up in debugging. The user can click the button of ―Memory‖ on the toolbar, or select Debug
Windows via the View menu, after the drop-down menu is popped up and then select Memory to open or close the window.
Observation window
Observation window is to monitor the user-defined variables, namely to display the content of registers in data memory
RAM. To facilitate the observation, the variables can be classified into four different viewing pages: Watch1, Watch2,
Watch3 and Watch4.
Register window
Registers window is to display the registers and current value of variable defined by DS. The user can click the button
of ―Register‖ on the toolbar, or select Debug Windows via the View menu, after the drop-down menu is poped up, select
Regirster to open or close the window. This window is divided into three pages, namely, Reg, All and DS, Reg is to display
the most commonly used registers of system; All is to display all system registers; DS is to display the user-defined register
variables, as shown in Figure 2-5.
The functions of each menu are introduced in details in the following sections.
Note:
Examples:
If you want to open a . ASM file from the compiling interface, the steps are as follows:
Step 1: Open M2IDE (Figure 2-7);
Step 2: Press ―Alt + F‖ in the compiler interface (at that time it will be not affected whether Caps Lock is enabled or
not ) (After execution, it is shown in Figure 2-8).
Step 3: If the file is recently opened, it will be displayed in 1-9, then directly press the corresponding letter; if not, press
―O‖ key on the keyboard (after execution, it is shown in Figure 2-9);
Step 4: Select the file to be opened in computer.
Compared with using the mouse, to use the operation method of shortcut is more convenient and faster.
The following examples are to introduce how to use the Find command in the menu.
To search in the current file:
If you want to find a register with the name of R_keyin given by the user in the current file, the steps are as follows:
Step 1: Execute Edit ---> Find command, or press the shortcut icon to find, and a dialog box will pop up, as shown
in Figure 2-13;
Step 2: At that time you can find one by one in accordance with your needs (Find Next), or directly mark all lines with
the line mark of R_keyin (MaskAll), together with Prev BookMark, Next BookMark, Toggle BookMark, Clear BookMarks
and other operations to search.
After the execution of MaskAll, it is shown in Figure 2-14.
Find in Files:
Note:
There are two options in the pop-up dialog box of Find, Find in files and Replace:
Match whole word only and Match case
Of which,
Match whole word only means to completely match with the key letters and independently, otherwise the results are not
displayed;
Match case means to be same with the combination of key letters.
Note:
Step out command can only be used when the current stopping point is within the subprogram, otherwise it will cause
unpredictable result.
Breakpoints….:
If you want to use this command, you must set a breakpoint at first; the dialog box for the execution of this command
without breakpoint is as follows:
Figure 2-19 Breakpoints dialog box for the execution without breakpoint
After the breakpoint is set, the dialog box for the execution of this command is as follows:
If multiple breakpoints are set in file, you can select each breakpoint (Figure 2-21), and can choose the trigger mode
(Figure 2-22).
After the number of trigger is set, it will be shown as the following figure, taking 40 times as example:
Download……:
After downloading, the program can be run freely without the computer environment. After this command is used, it
will pop up a dialog box for file selection, as shown in the following figure, to select. SN8 file to be downloaded, and click
Open, and then it will pop up a success prompt box, as shown in the following figure, to prompt the user that the file is
successfully downloaded and MCU is free running.
Figure 2-24 Dialog box when the program is being downloaded to ICE
After the corresponding command is executed, it will pop-up the following dialog box:
Report:
Easy Writer:
After the command is executed, it will pop up an information box, as shown in Figure 2-30, click OK to enter the
programming interface of Easy Writer.
Figure 2-30 Prompt box after the execution of Easy Write command
LCD Simulator:
Please refer to 2.4 .
After the execution of each command, the figures are shown as follows:
Cascade:Set the cascading of windows;
2. Similarly, double-click the activity bar, the window will pop up at once, as shown in the figure:
3. Click right key on the blank of toolbar or status bar, you can select whether the corresponding window will be
displayed or not by the selection of Output, Watch, Variables, Registers, Memory, Workspace and so on in the
pop-up menu, as shown in Figure 2-39:
Figure 2-39 Right-click the blank of toolbar to choose to display or not display the window
As the above figure shows, the little black checkmark in front of name or to press the icon is to indicate that the window
is already opened.
The following is taken the creation of a new project file Test.PRJ for example, to introduce how to create an application
program in details.
Double-click the shortcut icon of M2Asm119 on the desktop, open the development environment, if it is the first time to
use M2Asm, M2Asm will automatically open SN8Readme.txt and show the Welcome dialog box, as shown in Figure 2-40.
Please select ―Don't show SN8Readme.txt at next time‖ on the dialog box and click the button of ―OK‖, so it will not show
SN8Readme.txt at next time when you open M2Asm. If it is not the first to use the development environment, when M2Asm
is started, it will open the last correctly processed project.
Close all files and projects, M2Asm interface is shown in Figure 2-41, you can see that the project window, edit area
and compiling information bar are empty, and a lot of buttons on the toolbar are in gray lock state.
If you want to build a project, at first you shall create a file to add project, click the button of ―New‖ on toolbar or ―File‖
on menu bar to pop up a menu, as shown in Figure 2-42, select the option of ―New‖, to successfully create a blank document,
and the default file name is SONIX1, and it will create multiple files with multiple use of ―New‖, and the file names are as
follows: SONIX2, SONIX3 and so on.
Use the item of ―File‖ on menu bar, the pop-up menu is shown in Figure 2-43, you can find that the menu at that time is
different from the one at idle time, select the option of ―Save‖, and a file saving dialog box will be popped up, as shown in
Figure 2-44.
So far we have successfully creatted the project Test.PRJ, and included the file Test.ASM in the project, but there is no
source file in this file. Next, please input the source code into this file. The text input method of M2Asm is almost same with
that of other text editors, it can input, delete, select, copy, and paste, and execute other basic text processing commands, and
the difference is that the different contents in edit box of assembly file are displayed in different colors (e.g. the
pseudo-instruction is in blue, and the note is in green).
Please note that at the beginning of the program it requires to use ―CHIP‖ pseudo-instruction to define the type of the
used chip, so that in the process of compiling the compiler will pop up different configuration dialog box, which will be
described in the section of Compiling, Linking and Debugging of Files in detail.
In the actual situation, a project contains multiple program files, the pseudo-instruction ―INCLUDE‖ is used to include
these files into the project, in the next compiling these included files will be automatically added into the project, please note
that these included files shall be saved in the same directory of the project as far as possible, otherwise when you are using
―INCLUDE‖, you are required to specify the path of the included file.
If the project is required to add the header file, you can click right on the folder ―Header Files‖ in the viewing window
of file, and the menu of Figure 2-46 will pop up, after the selection of ―Add Files to Folder‖, the file selection dialog box will
be shown up, as shown in Figure 2-47, select the header file to be added, click ―Open‖ to add the header file.
The following is to describe how to use ―INCLUDE‖ to specify the path of the included file.
When ―INCLUDE‖ is used to include a file, if the file is saved in the same directory of the project, its format is as
follows:
INCLUDE File Name
Examples:
INCLUDE led_premain.ASM
INCLUDE led_App.ASM
INCLUDE SN88X.H // Include the customized variable’s name
If the file is not saved in the same directory of the project, its format is as follows:
INCLUDE File path and File name
Examples:
INCLUDE USB_ISP\SN8_USB_ISP_EnC.lib
INCLUDE USB\SN8_USB_macro.h
INCLUDE sub \ Filename.ASM
INCLUDE C: \PROJECT.H // Include the customized macro
Of which USB_ISP, USB and sub are the folder under the directory of the project, SN8_USB_ISP_EnC.lib,
SN8_USB_macro.h and Filename.ASM file are included.
M2ASM is used the pseudo-instruction ―CHIP‖ in the program to define the type of chip, and used the different pop-up
configuration dialog boxes to configure the related attributes of chip. In Figure 2-48, it is the configuration dialog box for
SN8P2708A, but the options are in gray lock state, which can be activated by clicking ―Update Code Option‖, as shown in
Figure 2-49, then we can modify the configuration options, please refer to 2.3.4 Compiling Option (Code Option for the
function introduction of each option.
After the configuration is finished, click ―OK‖ to complete the compiling configuration, if the program is correct, the
configuration information (as shown in Figure 2-50) will be displayed behind the defining statement of chip type in the code.
In the actual situations, it’s hard to complete the compiling at one time. There are often some errors in the code,
resulting in the failure of compiling. For example, after the execution of compiling instruction, M2ASM will pop up the error
message prompt box as shown in Figure 2-51, in which it shows the wrong line, the number of warnings and errors.
Click ―OK‖ to eliminate the error message box, then the interface is shown in Figure 2-52, and it can be found that a
blue arrow is marked in front of the wrong statement. In the compiling information window, the error information of
compiling are listed, including the type and location of error, the information highlighted in blue is the error information of
the error indicated in the current editing box. The user can double-click the error information to display the current wrong
line, for example, we double-click the first error information, and then the first error information will be highlighted in blue,
and the blue arrow in the editing box will point to the first error statement.
After the modification of error, it shall re-compile, if it is successfully compiled, the content of compiling information
will be shown as Figure 2-53, in which it shows the checksum, the maximum ROMsize,the used size,the remain free size.
Debugging Commands
There are three methods to execute the debugging commands provided by M2IDE.
Method 1: In debugging mode, use the debugging tools menu (Debug) in M2ASM menu bar, after the debugging
commands menu is popped up, select the corresponding debugging command to execute the command;
Method 2: In debugging mode, click the icon of shortcut command in M2ASM toolbar, as shown in Figure 2-54, the
corresponding command also can be executed.
Method 3: Use the shortcut keys, and the shortcut keys are shown in Table 2-2. To skillfully use shortcut keys can
greatly improve the speed of debugging.
In the M2IDE, the system provides a variety of ways to run the program for the user, and the user can use the
corresponding command to achieve the full speed, single-step and other methods to run the program.
To continuously execute Step Into (single-step) command, you can see the continuous changes of variables in the
variable observation window, and the respective values are displayed. When the register or user-defined variable is changed,
the register or the variable value in the register window will be displayed in red. The array in register window is to only
display the address unit occupied by the array before the running of program, for the specific information of the array’s
member, you shall click sign ―+‖ in the front of the array to expand the array, as shown in Figure 2-59, you can see that there
Move the cursor to the beginning of the subprogram mnled, click the icon , at that time a red solid dot will shown up
in the front of the first instruction of mnled, indicating that a breakpoint is set at this instruction.
To execute Go (Run) command, the program will directly run to the breakpoint, as shown in Figure 2-60. In the
observation window you can find that the values changed in the recent program segment are displayed in red, to input the
names of two variables into the observation window, namely: ―rled_buf‖ and ―r500ms_cnt‖, you can be directly observe
their current values , as shown in Figure 2-61.
Figure 2-61 Directly observe the values of variables in the variable watch window
To execute Step Out (Jump out of a function) command, at that time you can find that the program is directly complete
the execution of subprogram and stopped at next statement of call instruction, as shown in Figure 2-62.
To execute Remove All Breakpoints (clear all breakpoints) command, you can see all breakpoints are removed.
To execute Go (Run) command again to make the program to run at full speed, you can see the interface as shown in
Figure 2-65, to repeat Go (Run) command to pause the operation of program.
In the above section, we have introduced the commonly used methods to debug program in M2IDE in details, the user
can flexibly apply a variety of tools and debugging commands, it’s the only way to faster and better write high-quality
programs.
Different chip declarations and different versions of the compiling software, Code Option has different options to choose.
The meanings of some options are as follows:
◆ Watchdog:
Always on-Watchdog Timer is always turned on;
Enable-Watchdog timer is enabled in normal and slow mode, and stopped in green and sleep mode;
Disable-Watchdog timer is turned off.
※ Note: When you select the option of “Always on”, the system will not enter sleep mode.
◆ Reset_Pin:
Pxx-Select the internal reset, meanwhile this pin is used as unidirectional input port Pxx;
Reset-select the external reset;
※ Note: When you select the internal reset, Pxx port is the unidirectional input port, and there is no internal pull-up resistor.
◆ High_Clk:
IHRC_16M- The chip oscillating source is adopted the internal 16M high-speed RC oscillation circuit;
Ext_RC- The chip oscillating source is adopted the external RC oscillator circuit;
32K_X'tal- The chip oscillating source is adopted the external low frequency crystal oscillator (e.g. 32.768KHz);
4M_X'tal- The chip oscillating source is adopted the external standard quartz oscillator or ceramic oscillator (Generally, 2M
~ 10MHz);
12M_X'tal- The chip oscillating source is adopted the external high-speed quartz oscillator or ceramic oscillator (Generally,
10MHz ~ 16MHz).
※ Note: IHRC_16M option is only available in such IC that internally integrated the high-speed RC oscillation circuit,
when this option is selected, the two pins (XIN/XOUT) will be used as general I/O.
◆ Fcpu:
Fosc/1- instruction cycle = 1 clock cycle;
Fosc/2- instruction cycle = 2 clock cycles;
Fosc/4- instruction cycle = 4 clock cycles;
Fosc/8- instruction cycle = 8 clock cycles;
Fosc/16- instruction cycle = 16 clock cycles;
※ Note: When Noise_Filter Enable or IHRC_16M is selected in Code Option, Fosc/1 and Fosc/2 in Fcpu option will be
automatically blocked.
◆ Noise_Filter:
enable-Enable the function of noise filtering.
disable- Disable the function of noise filtering.
※ Note: When the noise filtering function is turned on, it will enhance the anti-jamming capability of chip, meanwhile
Fosc/1 and Fosc/2 in Fcpu option will be automatically blocked.
◆ LVD:
LVD_L- When VDD is below 2.0V, LVD will reset the system;
LVD_M- When VDD is below 2.0V, LVD will reset the system and the 24-bit PFLAG register of LVD will be used as 2.4V
low voltage detector;
LVD_H- When VDD is below 2.4V, LVD will reset the system and the 36-bit PFLAG register if LVD will be used as 3.6V
low voltage detector;
LVD_MAX- When VDD is less than 3.6V, LVD will reset the system. (Individual models have such function, such as
SN8P2522)
◆ Rst_Length
No-No external reset debounce time;
128 * ILRC- The external reset debounce time is 128 * ILRC.
◆ Ext_OSC
6MHz- The chip oscillating source is selected 6MHz crystal oscillator/ceramic oscillator;
12MHz- The chip oscillating source is selected 12MHzcrystal oscillator/ceramic oscillator;
16MHz- The chip oscillating source is selected 16MHzcrystal oscillator/ceramic oscillator.
◆ Fslow
Flosc/2- In slow mode the clock is Flosc/2;
Flosc/4- In slow mode the clock is Flosc/4.
◆ Ext_Reset_Length
No- No external reset debounce delay time;
128 * ILRC- The external reset debounce delay time is 128 * ILRC.
◆ IHRC_Detect
Enable- Enable the function of IHRC detection;
Disable- Disable the function of IHRC detection.
Please refer to LCD_Simulator_Manual_V01_SC.pdf document under the installation directory of compiler for the
specific methods of LCD simulation;
Path: C: \ Sonix \ M2IDE_Vxxx \ LCD_Simulator_Manual_V01_EN.pdf
A :Accumulator ACC
M :A address unit in data memery RAM
I :Constant, it must be begun with symbol “#”,E.g:#0x1A, #V1
.b :Bit address, e.g.:the fifth bit of M unit of M.5 table data memery
d :Address of program memery ROM
(X:Y):Byte X and Y consists of a word (word),of which Y is the lower byte
(X:Y:Z):a 24 bits data composed by three 8 bits arrays: X、Y and Z array
Note: The instruction cycles are different in MCU of SONiX SN8P1000 Series and SN8P2000 series, it may be different with
the above table. However, the actual instructions of some MCU may be only a part of the above but not all, so the MCU
specification shall be prevail, this table is only to list and introduce the usage of each instruction.
3.2 Pseudo-instruction
Pseudo-instruction is the instruction to tell the assembler how to compile, it cannot control the operation of machine or
compiled into machine code, and it only can be recognized by the assembler and it is to guide the implementation of
compiling. The pseudo-instruction statement is relative to the instruction statement.
Instruction statement
Each instruction statement will generate the instruction code (i.e., object code) for MCU to execute when the source
code is compiling, so such statement is also called the executable statement. Each instruction statement indicates a basic
capability of MCU, for example, data transfer, add or subtract between two numbers, shift, etc., and this function will be
fulfilled during the running of target program (an ordered collection of instruction code), which is relied one CPU, memory,
I/O interface and other hardware to fulfill.
Pseudo-instruction statement
Pseudo-instruction statement is to guide the assembler how to compile program, so such statement is also called
command statement. For example, the pseudo-instruction statement in the source code is to tell the assembler how to
segment the program, which logic segments are the current segments in the program segment, and which segment register is
pointed to them, which data is defined, how to distribute the storage unit, and so on. For pseudo-instruction statement, except
the defined specific data will generate object code, the rest have no corresponding object code. Such commands functions of
pseudo-instruction statement are fulfilled by executing a segment of program when the assembler is compiling, but not
fulfilled when the target program is running.
INCLUDESTD:
Syntax: INCLUDESTD FILE
Description:
A program file is required after this command, and the path is fixed to the path of SN8ASM.EXE, the others can refer to
INCLUDE instruction. This command allows the user to easily access the system-provided macro files.
Example:
INCLUDESTD MACRO1.H // Include the commonly used macros of system
INCLUDESTD MACRO2.H // Include the commonly used macro files of system
INCLUDEBIN:
Syntax: INCLUDEBIN FILE
Description:
A BIN file is required after this command, if this program file is not in the directory of currently being compiled
program, the user shall specify the path for the file. The data unit of this file is WORD. If it is less than one WORD, it shall
be counted as one WORD.
Example:
INCLUDE SPEECH.BIN
INCLUDE C: \SOUND.SND
3.4 Macro
SONiX supports the following default macros, with which it’s more easily to write programs, the following macros are
defined in three files in the compiler directory: MACRO1.H, MACRO2.H and MACRO3.H.
Flag
Assembling Extended Qty of instruction after
Category mnemonic code format extended
Function CF DC Cycle
ZF
CLC B0BCLR FC 1 Clear C flag 0 – – 1
STC B0BSET FC 1 Set C flag 1 – – 1
C B0BSET
RSTWDT 1 Reset the watchdog counter – – – 1
O FWDRST
M EINT B0BSET fgie 1 Enable the global interrupt bit – – – 1
M DINT B0BCLR fgie 1 Disable the global interrupt bit – – – 1
A XOR A,
N NOT A 1 A←~A – – – 1
#0FFh
D XOR A,
NEG A #0FFh 2 A←–A – – – 2
ADD A, #1
B0BCLR FC
SHL memory RLCM 2 memory ←memory * 2 – – – 2
R memory
O B0BCLR FC
T SHR memory RRCM 2 memory ←memory / 2 – – – 2
A memory
T B0BCLR bit2
E Exhange the state between bit2 and
B2B bit1, bit2 B0BTS0 bit1 3 – – – 3
/ bit1
B0BSET bit2
S
RLCM mem FC ← mem.7
H ROL mem 4 – – – 4
B2B FC, mem.0 mem←mem * 2 + FC
I
RRCM mem FC ← mem.0
F ROR mem 4 – – – 4
T B2B FC, mem.7 Mem←mem / 2 +FC * 80h
RCR mem RRCM mem 1 another way to write – – – 1
RCL mem RLCM mem 1 another way to write – – – 1
B0BTS0 FZ
JZ address 2 If ZF == 1,then jump to address – – – 2
JMP address
B0BTS1 FZ
JNZ address 2 If ZF == 0,then jump to address – – – 2
B JMP address
R B0BTS0 FC
JC address 2 If CF == 1,then jump to address – – – 2
A JMP address
N B0BTS1 FC
JNC address 2 If CF == 0,then jump to address – – – 2
C JMP address
H B0BTS0 FDC
JDC address 2 If DCF == 1,then jump to address – – – 2
JMP address
B0BTS1 FDC
JNDC address 2 If DCF == 0,then jump to address – – – 2
JMP address
BTS0 bit
JB1 bit, addr 2 If bit == 1,then jump to addr – – – 2
JMP addr
BTS1 bit
JB0 bit, addr 2 If bit == 0,then jump to addr – – – 2
JMP addr
B DECMS mem mem ← mem –1 If mem != 0,then
R DJNZ mem, adr 2 – – – 2-3
JMP adr jump to adr
A
INCMS mem mem ← mem +1 If mem != 0,then
N IJNZ mem, adr 2 – – – 2-3
C JMP adr jump to adr
H CMPRS A, m
CJNE A, m, adr 2 If ACC != m,then jump to adr – – – 2-3
JMP adr
CMPRS A, m
CJE A, m, adr JMP $+2 3 If ACC == m,then jump to adr – – – 3-4
JMP adr
CMPRS A, m
If ACC >= m (Above Equal),then
CJAE A, m, adr B0BTS0 FC 3 – – – 3-4
jump to adr
JMP adr
CMPRS A, m
If m >= ACC (Above Equal),then
CJAE m, A, adr B0BTS1 FC 3 – – – 3-4
jump to adr
JMP adr
If ACC <= m (Below Equal),then
CJBE A, m, adr CJAE m, A, adr 3 – – – 3-4
jump to adr
If m <= ACC (Below Equal),then
CJBE m, A, adr CJAE A, m, adr 3 – – – 3-4
jump to adr
CJA A,m, adr CMPRS A, m 4 If ACC > m (Above),then jump to – – – 4-5
MACRO:
Syntax: NAME MACRO [PARA1[,PARE2,…] ]
…
ENDM
Description:
Using Macros can simplify the writing of programs and make the subprogram to shorten the length of program code. If
the macros and subprograms are well used, it may make the program to achieve the best state. The quantity of parameters of
macro cannot be exceeded 255, but the length is not limited, and it can be composed by A ~ Z, a ~ z, 0 ~ 9 and @ # _. $ and
so on, if the special characters are required, the symbols <> shall be used to separate the special characters. In addition, other
macros can also be nested in a macro, and the number of levels is not limited.
Example:
MOV_ MACRO ADDRESS, VALUE
MOV A, VALUE // Macro content
MOV ADDRESS, A
ENDM
EXPAND:
Syntax: Same as the above description: when there is error in compiling or it is in simulation, MACRO shall be used to
make the cursor to stop at the position of the called macro, to use EXPAND will make the cursor to stop inside the macro
instruction, which is conducive to check errors.
REPEAT:
Syntax: REPEAT COUNT
… ;REPEATED COMMAND
ENDM
Description:
REPEAT is to repeatedly execute a command. The number of repetitions is decided by COUNT. ENDM is to indicate
that this command segment is ended. REPEAT is to indicate the beginning of this command segment.
Example:
RRCM_1 MACRO MEMORY, VALUE
REPEAT VALUE
RLCM MEMORY
ENDM
ENDM
…
RRCM_ 0, 4 ;Shit the content of RAM[0] to right for 4 times
FOR:
Syntax: FOR PARAMETER, < PARAMETER 1, PARAMETER 2 …>
…
ENDM
Description:
FOR is used to repeatedly execute a segment of command. The number of repetitions is decided by the parameter in the
angle brackets, following the parameter sequence separated by commas, one parameter will replace the value of
PARAMETER at one time.
Example:
FORC:
Syntax: FORC PARAMETER, <WORD SERIAL>
… ; Command to be repeated
ENDM
Description:
FORC is used to repeatedly execute a segment of command. The number of repetitions is decided by the length of
character string in the angle brackets, following the character sequence of the string, one character will replace the value of
PARAMETER at one time.
Example:
FORC I, <012345>
M&I EQU I
ENDM
EXITM:
Syntax: EXITM
Description:
EXITM command is to make the macro expansion to end in advance, and it is often used when there is an error in the
macro.
Example:
MEM MACRO value
.IF value>=10
ERROR value must < 10
EXITM
.ENDIF
M&value EQU value
END
%
Syntax: %PARAM Description:In the macro, make the corresponding string to convert to numerical values. Example:
ERROR_ MACRO E1 E2 E3
ERROE E1 E2 E3
ENDM
TEMP = 10
ERROR_ TEMP IS %TEMP
After compiling, it will display the error information of TEMP IS 0XA.
!
Syntax: ! Character
The above example uses two levels of macro, and ―ENUM M‖ is expanded to:
FORC I, <012345>
M&I EQU I ; M0/1/2… EQU 0/1/2/…
ENDM
LOCAL
Symbol in macro to support the local. Example:
XXX MACRO
LOCAL XX1, XX2
JMP XX1
XX1:
JMP XX2
XX2:
NOP
ENDM
XXX can be called for multiple times, but XX1, XX2 cannot be repeatedly defined.
If you want to not omit the first parameter, you can rewrite as follows:
ADD2 MACRO A: REQ, B
DW A+B
ENDM
ADD 2,4 ; Error generating
And if you want to omit the second parameter and use the default value, you can rewrite as follows:
ADD2 MACRO A: REQ, B: =0; 或 B: =< expression >
DW A+B
ENDM
ADD2 4 ;DW 4+0
Example:
To avoid parameter blank, the following syntax can be used:
TEMP = 0
FOR I <ZERO ONE THREE>
IFNB <I>
I EQU TEMP
ENDIF
TEMP = TEMP+1
ENDM
To avoid. H file to be repeatedly loaded, the following syntax shall be used:
IFNDEF —TESTFILE— ;the beginning of loading program
—TESTFILE— EQU 1 ;program content
…
ENDIF ;end of program
Description: These conditional compilation commands are used to detect some special conditions, and can output an
error information to alert the user.
Example:
ECHO Here be compiled // The information will be displayed when it is compiling to this line
For the following macro definitions, we can change the way of expression.
ADD2 MACRO A: REQ, B: = <0>
DW A+B
ENDM
New expression:
ADD2 MACRO A, B
.ERRB <A>
IFB <B>
DW A
ELSE
DW A+B
ENDIF
ENDM
Obviously, this is not a good way, just a demonstration.
.LIST:
Syntax: .LIST
Description:
. LIST is used to include the source code under the LIST command into the list file, which is the default setting.
Example:
.LIST
… ;It will be shown in the list file
.NOLIST
.NOLIST:
Syntax: .NOLIST
Description:
. NOLIST is to disable the list function till another. LIST to open it.Example:
.NOLIST
… ;It will not be shown in the list file
.LIST
.LISTIF:
Syntax: .LISTIF
Description:
. LISTIF list is used to compile the commands, even if the command has not been compiled, these commands will be listed
.NOLISTIF:
Syntax: .NOLISTIF
Description:
. NOLISTIF is used to hide the instructions which have not been compiled, which is the default setting.
Example:
.NOLISTIF IF 0
… ; It will not be shown in the list file
ENDIF
.LISTMACRO:
Syntax: .LISTMACRO
Description:
. LISTMACRO is to list the command that can generate program code or data in a macro, which is the default setting.
Example:
.LIST MACRO TEMP =0
REPEAT 8
DW TEMP ; It will be shown in the list file
DEMP = TEMP+1 ; It will not be shown in the list file
ENDM
.NOLISTMACRO:
Syntax: .NOLISTMACRO
Description:
. NOLISTMACRO is to keep the code in macro away from expansion.
Example:
.NOLIST MACRO TEMP = 0
REPEAT 8
.LISTMACROALL:
Syntax: .LISTMACROALL
Description:
.LISTMACROALL is to list all instructions in a macro.
Example:
.LIST MACROALL TEMP = 0
REPEAT 8
DW TEMP ; It will be shown in the list file
DENP = TEMP+1 ; It will be shown in the list file
ENDM
Appendix
Appendix I Compiler Error Inforamtion Description
Table I-1 Error Information List
No. Name Prompt Meanings
1 Syntax_Error Syntax error happen !!! Syntax error
2 Detrop_SEnd Not Need ) but find !!! Existence of )
3 Miss_SStart Need ( but not find !!! Absence of (
4 Miss_SEnd Need ) but not find !!! Absence of )
5 Detrop_LEnd Not Need } but find !!! Existence of }
6 Miss_LEnd Need } but not find !!! Absence of }
7 Detrop_MarkEnd Not Need */ but find !!! Existence of '*/' symbol
8 Miss_MarkEnd Need */ but not find !!! Absence of '*/' symbol
9 Need_Space Need space to next symbol !!! Need space between symbols
10 Detrop_Space Not need space here !!! Not need space here
11 Detrop_Char Not need char here !!! Not need char here
12 Need_Value Here need a value !!! Absence of operational element
13 Bad_Value Invalide value !!! Invalide value
14 Bad_Char Need format 'X' here !!! Need char format' here
15 No_Bit Invalid bit operation !!! Invalid bit operation
16 Need_Bit Here need format : XX.bit !!! 'XX.bit' format is needed here
17 Need_Imm Here need format : #xx !!! '#XX' format is needed here
Here +-*/!~() HIGH/LOW/MID can't
18 No_Operator Operator +-*/!~() cannot access HIGH/MID/LOW
access !!!
19 Bad_HMLJ only Label$H/M/L/J can access !!! Only Label$H/M/L/J can access
20 Bad_HML only Label$H/M/L can access !!! Only Label$H/M/L can access
21 Attrib_Order_Error HIGH/MID/LOW must before -,!,~ !!! Operator -,!,~ must be in the front of HIGH/MID/LOW
22 Attrib_Repeat_Error HIGH/MID/LOW repeat too much !!! HIGH/MID/LOW repeat too much
23 Bad_String Expect \"string..\" here !!! Absence of sting here
24 UnAccess_Symbol Symbol not access here !!! Symbol cannot access here
25 Undef_Symbol Undefined Symbol !!! Undefined symbol
26 Unknow_Command Unknown Command !!! Unknown command
27 Over_0x100 The value must limit 0 - 0xFF !!! The value must be limited among 0x00 - 0xFF
28 Over_0x10000 The value must limit 0 - 0xFFFF !!! The value must be limited among 0x0000 - 0xFFFF
29 Over_Range The value over range !!! The value is over range
30 Over_Imm_Range The #nn value over range !!! #nn(Immediate value) is over range
The value (MM.b), MM value over
31 Over_Bit1_Range RAM value is over range
range !!!
32 Over_Bit2_Range The value (mm.B), B value over range !!! The Bit value of RAM is over range
The Code has overwrite from here, please
33 Code_OverWrite The Code will be overwritten from here, please check it
check it !!!
The Data has overwrite from here, please
34 Data_OverWrite The Data will be overwritten from here, please check it
check it !!!
35 Over_Code Over Program-Code Range !!! Over the range of User ROM Size
36 Over_Voice Over ROM Code Range !!! Over the range of ROM Size
37 Over_RAM Over RAM Range !!! Over the range of RAM Size
38 Jmp_Over JMP, CALL, ... command over range !!! JMP, CALL, ... instruction is over range
39 Over_OJump Over the JUMP range !!! Over the range of JUMP instruction
40 Play_Over PLAY command over range !!! PLAYinstruction is over range
The List buffer has over size, force disable
41 Over_List List buffer has been over the range, and force to disable list
list !!!
Over Stack, Please check your program for
42 Over_Stack Over Stack, please check program
loop-include !!!
Over TextEqu, Please check your program TextEqu Over, please check the definition of textequ in the
43 Over_TextEqu
for loop-textequ !!! program
Over Stack, Please check your program for
44 Over_Buf2 Over Stack, Please check the loop-macro in the program
loop-macro !!!
45 Buffer_Over Buffer over range to record data !!! Buffer is over the range of record data
46 Inter_Error Happen internal unknow error !!! Unknown internal error is happened
47 INI_Error .INI happen error, stop read !!! .INI file has error, stop reading
48 Source_Error Source error, stop compile !!! Source error, stop compiling
49 File_Null File not exist, stop compile !!! File is not existed, stop compiling
missing CHIP SNxxx at head of
50 No_Chip Absence of chip name declaration
program !!!
51 Chip_Fail Wrong device selection !!! Chip name declaration error
Utility Menu
TableⅡ-5 Utility Menu and Commands(Utility)
Window Menu
TableⅡ-6 Window Menu (Windows)
WindowsMenu Toolbar Shortcut key Description
Icon
Cascade Set the cascading of windows
Tile Set the tiling of windows
Arrange Icons Arrange Icons on the bottom of the window
1~9 Activate the selected target of window
Windows… Current window operation
Help Menu
TableⅡ-7 Help Menu(Help)
Chapter 1
No. Linkage No. Linkage
1 Figure 1-1 Emulation Connection Diagram 9 Figure 1-9. Installation Information
2 Figure 1-2 SN8ICE 2K Hardware Description 10 Figure 1-10. Installation Progress Window
3 Figure 1-3. Post-connection Diagram 11 Figure 1-11. Installation Completion
4 Figure 1-4. M2IDE Installation Guide Dialog Box 12 Figure 1-12. Shortcut Icon
5 Figure 1-5. M2IDE Installation Agreement Dialog Box 13 Figure 1-13. Start M2IDE System
6 Figure 1-6. Installation Path Selection Dialog Box 14 Figure 1-14. Uninstall M2IDE
Figure 1-15. Message Box of Successful Uninstalling
7 Figure 1-7. Window of View Path 15
8 Figure 1-8 Pop-up Shortcut Setting Window
Chapter 2
No. Linkage No. Linkage
Figure 2-1. Integrated Development
1 Environment
35 Figure 2-35 Help Menu
Figure 2-2. Open M2Asm Interface at First
2 Time 36 Figure 2-36 Activity bar of each window
Figure 2-14 Compiler interface after the Figure 2-48 Compiling Environment Setting Dialog
14 execution of MaskAll 48 Box
Figure 2-15 Information box to find in all
15 files 49 Figure 2-49 Setting Dialog Box in Active State
16 Figure 2-16 Replacement Information Box 50 Figure 2-50 Compiling Configuration Information
17 Figure 2-17 View Menu 51 Figure 2-51 Compiling Error Information Prompt Box
18 Figure 2-18 Debug Menu 52 Figure 2-52 Compiling Error Interface
Figure 2-19 Breakpoints dialog box for the Figure 2-53 Compiling Information Box after
19 execution without breakpoint 53 Successful Compilation
Figure 2-20 Dialog box for the execution
20 with breakpoint 54 Figure 2-54 Shortcut Command Icons
31 Figure 2-31 Window Menu 65 Figure 2-65 Interface of running at full speed
32 Figure 2-32 Windows cascading 66 Figure 2-66 Code Options
33 Figure 2-33 Windows tiling 67 Figure 2-67 LCD software simulation panel
34 Figure 2-34 Window
SONiX reserves all of rights for further explanation on the improvements of reliability,
functionality and design of the following products. SONiX assumes no responsibility caused by
the application and use of products or circuit covered in this manual. SONiX’s products are not
designed for the application in surgical implants, life sustaining, and other fields that the failure of
SONiX’s product may cause injury or death to individual. If SONiX’s products are used in the
above mentioned fields, even if these are resulted from the negligence in the product design and
manufacturing by SONiX, the user shall indemnify all costs, losses, and the attorneys' fees directly
or indirectly generated from reasonable personal injury or death, and ensure that SONiX and its
employees, subsidiaries, affiliates and distributors have nothing to do with the above matters.
Corporate Headquarters
10F-1, No.36, Taiyuan Street, Chupei City, Hsinchu, Taiwan
TEL: (886)3-5600-888
FAX: (886)3-5600-889
Taipei Office
15F-2, No.171 Song Ted Road, Taipei, Taiwan
TEL: (886)2-2759-1980
FAX: (886)2-2759-8180
Technical Supports
[email protected]