MAX-IDE Simulator Users G

                        作者:fanxiaoxi 時間:2022-12-09

                      Abstract: This applicaTIon note provides useful references and describes how to use the MAX-IDE toolset to build applicaTIons for MAXQ? microcontrollers. It specifically explains how to use the MAX-IDE simulator.


                      The MAX-IDE is an easy-to-use Windows?-based development environment and tool set that gives designers software simulators, emulators and debugging capabiliTIes. Using MAX-IDE, developers can create embedded applications for the MAXQ microcontroller.


                      The MAX-IDE toolset provides the following features:

                      1. MAXQ assembler. For the MAXQ microcontroller instruction set, see Section 18.0 of the MAXQ Family User's Guide available for download.

                      2. Project manager

                      3. Text editor

                      4. Viewer for processor memory (utility ROM/code/data) and registers

                      5. Debugger with the ability to single-step and set breakpoints

                      6. Simulators for different MAXQ devices

                      7. Statistical reporting for machine cycles, execution time, and other parameters

                      The following files are installed as part of the installation:

                      1. GenericIDE.exe: This is a MAX-IDE executable that provides the Windows-based integrated development environment including the text editor, project manager, and debugger.

                      2. MAX-IDE.hlp: This file contains the MAX-IDE help information. Users can access the contents of this file through the MAX-IDE's help menu.

                      3. MaxQGS.dll: This is the DLL file for a MAXQ device simulator.

                      4. Macro.exe: This is the executable file for the macro preprocessor. The macro preprocessor takes the assembly source file as an input and converts equates to numeric values and macros to inline code.

                      5. MaxQAsm.exe: This is the MAXQ assembler. The assembler supports the complete instruction set of MAXQ. It takes the assembly source file (.asm) as an input and produces an Intel hex file (.hex) and a list file (.lst).

                      6. DallasAssembler.dll: This is the DLL file for the MAXQ assembler.

                      7. ROM files

                        1. romq10.hex: This is the Utility ROM file for MAXQ10.

                        2. romq20.hex: This is the Utility ROM file for MAXQ20.

                        3. romq30.hex: This is the Utility ROM file for MAXQ30.

                      8. SFR (special function register) configuration files:

                        1. maxq2000.xml: This is the SFR file for MAXQ2000

                        2. maxq3210.xml: This is the SFR file for MAXQ3210

                        3. maxq765x.xml: This is the SFR file for a MAXQ765x device

                      Getting Started with MAX-IDE

                      This section will help you build a simple assembly-language program using the MAX-IDE (ZIP). Follow these instructions to complete your first application for the MAXQ and simulate it using the MAX-IDE simulator. For future reference, see the Appendix for a helpful list of MAX-IDE commands.

                      Project Manager

                      Step 1: Choose Project→New Project from the menu. A new tab will open in the left side of the MAX-IDE's main window. This tab will be empty as there are no files in the project at present. Figure 1 shows the MAX-IDE main menu with project menu open.

                      Figure 1. MAX-IDE's initial screens used to create a project.

                      Step 2: Before proceeding with the project menu, you need to add files to this project. From the main menu create a new source file by choosing File→New File from the menu. This will open a new editor window with the title "Untitled 1." Enter the assembly code shown in Table 1 below. Alternatively, you can download the assembly code and add this file to the project, as explained in Step 4 below. Figure 2 shows the MAX-IDE with the project manager and editor windows open.

                      Figure 2. Use the project manager and editor windows to create a new file.

                      Step 3: Before adding this new file to the project, you need to save this file. Choose File→Save Untitled1 which opens the Save As dialog box. Create a new folder, MAXIDE, and save the file to the MAXIDE folder as hex_to_asc.asm.

                      Step 4: To add the source file that we just created to the project, choose Project→Add Files. This will open up the Open dialog box. Browse to the folder that you created in the previous step, and select hex_to_asc.asm file. You can also perform this operation by right clicking in the project window, and choosing Add Files from the pop-up window.

                      Note: Even if you created the source file in the IDE, it will not be part of the project until you add it to the project file

                      Step 5: To save the progress so far, choose Project→Save from the menu, which opens the Save As dialog box. Browse to the folder that you created earlier, and save the project as hextoasc.prj.

                      Step 6: Activate the simulator by choosing DEVICE→MAXQ Simulator, as shown in Figure 3.

                      Figure 3. The MAXQ Simulator is accessed from the Device menu.

                      The MAXQ Simulator supports MAXQ10, MAXQ20, and MAXQ30 devices.

                      To select the device, click on Device→Options, as illustrated in Figure 4.

                      Figure 4. The Options window asks you to choose a MAXQ device.

                      The drop-down menu in Figure 4 shows the available devices, which consist of specific MAXQ devices (e.g., MAXQ2000) and generic devices (e.g., MAXQ10—Generic for a MAXQ10 architecture). Note that when you choose a specific device like the MAXQ2000, the Processor is selected automatically. If, for example, the MAXQ2000 is selected, the MAXQ20 would be selected automatically as its processor. The user can also change the value for crystal frequency, ring frequency, and Timer2 clock. The other fields in this window are non editable.

                      For this article, we choose the MAXQ30-Generic for the device.

                      Step 7: There are two ways to compile the project: Make and Build All. Using the Project menu (see Figure 3), Make will compile only those files that changed since the last successful compile. Build All will always compile all the files.

                      For this application, press F7 or select Project→Make.

                      Step 8: If you entered the text exactly as in Table 1, you should get an error when you compile at the line

                      LCALL   Hex2Asc2

                      To point to the source of error, double click on the error line in the message window. Retype the line t LCALL Hex2Asc and recompile.

                      Table 1. hex_to_asc.asm: Converts Hex Data to Its Equivalent ASCII

                      ;example to explain the usage of MAX-IDESEGMENT   DATA      
                      ; DATA segment starts here
                      ; Default location = 00; Initialize Data memorych:     DB      0                           
                      ;holds ASCII value of upper HEX nibblech1:    DB      0                           
                      ;holds ASCII value of lower HEX nibblech2:    DB      0                           
                      ;holds HEX bytech3:    DB      0       SEGMENT CODE                  
                      ; CODE segment starts hereORG 0                                      
                      ; SET Absolute address of code = 0MAXQ30 EQU 3MAXQ20 EQU 2MAXQ10 EQU 1
                      ;Choose MAXQ to be MAXQ10, MAXQ20 or MAXQ 30 depending 
                      ;on the architecture you want to use.MAXQ EQU MAXQ30
                      ; This example is with MAXQ30IF(MAXQ=MAXQ30)#define data_pointer DP[0].b 
                      ; for maxq30 , the data pointer is specified to be in byte mode or word mode by using the 
                      ; notation DP[0].b or DP[0].w                                                   
                      #define data_pointer DP[0]MOVE DPC,
                      ; for maxq 20, the data pointer is specified to be in byte mode or word mode through the 
                      ; DPC register 
                      #define data_pointer DP[0]MOVE DPC,
                      #18h; for maxq 10, the data pointer is specified to be in byte mode or word mode through the 
                      ; DPC register ENDIFJUMP mainORG 20h                                  
                      ; SET Absolute address of code = 32 HEXHex2Asc:MOVE       
                      A[1], A[0]            
                      ; store the HEX value for future useMOVE       
                      DP[0], #ch2  MOVE       
                      @data_pointer, A[0]       
                      ; store the HEX value @ #ch2 locationMOVE       
                      A[0], A[1]             
                      ; Process upper nibbleMOVE       
                      AP,#0SRA4ADD #030h                    
                      ; value = value + '0'MOVE        
                      C, ??Hex2Asc_0
                      ; if value > '9', value=value + ('A' - '9') + 1ADD         
                      ; store ASCII value of upper HEX nibbleMOVE        
                      MOVE        A[0], A[1]           
                      ; process lower HEX nibbleAND         
                      ; if value > '9', value=value + ('A' - '9') + 1ADD         
                      DP[0], #ch1      
                      ;Store ASCII value of lower HEX nibbleMOVE       
                      @data_pointer, A[0]RETmain:MOVE       
                      A[0], #041h     
                      ; hex value to be converted to ASCIILCALL      Hex2Asc          
                      ; process the HEX valueSJUMP $                             
                      ; RUN foreverEND

                      The above source code is available at: (ZIP)

                      Step 9: Recompile the code by pressing F7 or selecting Project?Make. If compilation is successful, output files named hextoasc.hex and hextoasc_d.hex will be generated along with a list file. You are now ready to run the application.

                      Step 10: Before executing the application, set some break points to investigate the application's behavior. Click on the line number at the left edge of the editor window to set a breakpoint. The breakpoint will be indicated by a ? to the side of the number. Set a break point on the line below "main," and another at the subroutine, Hex2Asc. Press F5 to start the simulator. This will save the files (if not already saved) and compile the project. If the compilation is successful, the simulator will load the file and start running. When the simulator hits a break point, the program execution will pause at the current line, as indicated by highlighting of the current line and a → mark to the left of the margin.

                      Figure 5 shows the breakpoint and an instance of the application running.

                      Figure 5. The Debug Windows with the breakpoint indicated by the green arrow and line.

                      Step 11:Open up the registers window by clicking on Window→Show→Registers from the Window menu. Select SYSTEM from the Registers drop-down box to display the MAXQ core registers' contents. Observe that relevant registers are updated as you step through the execution. Try the commands step into, step over, step out, and run to cursor to become familiar with the MAX-IDE. Similarly, if your program is writing to the data memory and you want like to watch the data values, go to Window→Show→Memory, tab to "data" memory, and scroll down to the memory location to observe the values.

                      The above program converts the hex value supplied in the A [0] register to its equivalent ASCII value, and stores the ASCII values in the data memory addresses 0x00 and 0x02.

                      Execute the application for different values in the A [0], and observe their equivalent ASCII values in data memory addresses 0x00 and 0x02.

                      Refer back to Figure 4. A [0] is set to 0x41 HEX in the registers window; data memory location 0x00 and 0x02 are updated with 0x34 and 0x31 respectively, which are the ASCII equivalent of 0x41 hex.

                      Step 12: Open the Statistics window (Window→Show→Statistics). This action shows you the machine cycles and execution time (Figure 5).

                      Figure 6. The Statistics window lets you monitor machine cycles and execution time.


                      MAX-IDE, the MAXQ device simulator, can be used to develop and debug the MAXQ-based applications for the MAXQ10, MAXQ20, and MAXQ30 devices. The application developed with MAX-IDE is ready to run on the hardware.

                      Appendix: Table of MAX-IDE Useful Commands

                      File Menu
                      New File...Open a new text/source file.
                      Open File...Open an existing source file.
                      SaveSave the edited file.
                      Save As...Save the newly edited file and give it a name.
                      CloseClose the source file.
                      Print...Print the source file.
                      ExitExit from the IDE.
                      Project Menu
                      New ProjectCreate a new project.
                      Open ProjectOpen an existing project.
                      SaveSave the already opened project.
                      Save Project As...Save the newly created project and give it a name.
                      CloseClose the project.
                      Add Files...Add source files to the project.
                      Remove FileRemove the source file from the project.
                      MakeCompile the modified source file.
                      Build AllCompile all the source files in a project.
                      UndoUndo the latest changes.
                      CutDelete the selected text and keep it in clipboard.
                      CopyCopy the selected text into a clipboard.
                      PastePaste the text from clipboard to the position pointed to by buffer.
                      DeleteDelete the selected text.
                      Select AllSelect all the text in the editor.
                      FindFind the text in the source file.
                      Find NextFind the next occurrence of the text in a source file/project.
                      ReplaceReplace the text.
                      Find in FilesFind the text in the project directory.
                      Goto LineGo to the specified line in the source file.
                      Tab OptionsOption to select the tab options.
                      Convert Tabs to SpacesOption to convert the tabs to spaces.
                      Set Editor FontOption to set the text font.
                      Debug Menu
                      Toggle Break PointToggle a break point.
                      RunExecute the application.
                      PausePause the execution of application.
                      StopStop the application.
                      Step IntoSingle step execution. Step into the function and execute the current source line.
                      Step OverExecute the current source line.
                      Step OutExecute all the instructions of the present module and step out of the module.
                      Run To CursorExecute until the line pointed to by cursor.
                      High Level DebugNot applicable.
                      Low Level DebugNot applicable.
                      MakeCompile the modified source file.
                      Build AllCompile all the source files in a project.
                      Device Menu
                      MAXQ ICEEnables connection with Emulator.
                      MAXQ JTAGEnables connection with device through the JTAG.
                      MAXQ SimulatorEnables the Simulator.
                      LoadLoad the hex file into the loader.
                      OptionsDialog box for choosing the device and other device settings such as CPU frequency, ring frequency, and alternate clock for timer2.
                      Install DeviceInstall a specified MAXQ device DLL into the IDE.
                      Remove DeviceRemove the device from the list of devices.
                      Show→BreakpointsDisplay a list of break points in a project.
                      Show→Find in FilesDisplay a list of files where a specified text is found.
                      Show→MemoryDisplay memory window. Memory window contains Code, ROM and Data area.
                      Show→MessageDisplay message window.
                      Show→ProjectDisplay project window.
                      Show→RegisterDisplay register window.
                      Show→StatisticsDisplay statistics window.
                      ContentsDisplay the contents of a help file.
                      HelpDisplay the version of the IDE and its components.

                      關鍵詞: Micr MAXQ