Home
uM-FPU V3 IDE User Manual
Contents
1. Enable Busy Ready Status on OUT1 Juse PIC format IEEE 754 is default Idle Mode Power Saving Enable Sleep Mode Power Saving Enabled Interface Mode CS pin selects interface default 12C interface CS pin ignored SPI interface CS pin used as chip select DC Address CS Auto Start Mode IF CS pin is Low at Reset Disable Debug CO call Function 0 Restore Default Settings Select the Debug Window and click the Clear button above the Debug Trace to clear the trace area Now run the tutorial1 bs2 program that you developed in the previous tutorial An instruction trace will be displayed in the Debug Trace area After the program stops running click the Read Registers button to update the Register Display String Buffer and Status Scroll up to the beginning of the Debug Trace Micromega Corporation 19 uM FPU V3 IDE User Manual The Debug Window should look as follows CT uM FPU V3 IDE tutoriali fpu Output Debug Functions Serial 1 0 Tutorial 2 Debugging FPU Code SEES F2754D2D4650 52056332E31 2E3200 0104 SBOAOF 29 SBO3ES 2E LF3F F220322E3537 3500 O10B 2004 3602 1F3F F220352E3135 3000 010C SE 29 2405 1F3F F231362E3137 3900 010D 5E 29 240A 2404 String Length 6 VERSION READSTR uM FPU 3 1 2 SELECTA Radius LOADWORD 2575 FSETO LOADWORD 1000 FDI O FTOA 63 READSTR 2 575 SELECTA Diame
2. GetDiameter SHIFTOUT FpuOut FpuClk MSBFIRST FCALL GetDiameter format 63 GOSUB Print FloatFormat GetCircumference SHIFTOUT FpuOut FpuClk MSBFIRST FCALL GetCircumference DEBUG CR Circumference format 63 GOSUB Print FloatFormat GetArea SHIFTOUT FpuOut FpuClk MSBFIRST FCALL GetArea DEBUG CR Area i format 63 GOSUB Print FloatFormat areaIn ROUND area Micromega Corporation 25 uM FPU V3 IDE User Manual Tutorial 3 Programming FPU Flash Memory SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA 0 LEFT FSET Area ROUND RIGHT FIX GOSUB Fpu Wait SHIFTOUT FpuOut FpuClk MSBFIRST LREADWORD SHIFTIN Fpuln FpuClk MSBPRE areaIn HIGHBYTE arealn LOWBYTE DEBUG CR Arealn DEC Arealn END Micromega Corporation 26 uM FPU V3 IDE User Manual Tutorial 3 Programming FPU Flash Memory Save the IDE source file as tutorial2 fpu and save the BASIC Stamp program tutorial2 bs2 then run the program The following output should be displayed in the terminal window uM FPU V3 1 2 J in Radius Diameter zl i ip Circumference Area Arealn Done uM FPU V3 1 2 J Li UN int unt oun in J J tin tn tn tn Radius Diameter J Circumference J Area Arealn Done Since calling an undefined functions has no effect register A remains unchanged after the Radius calculation and the same value prints out for each Print Format call
3. Further Information The following documents are also available uM FPU V3 Datasheet provides hardware details and specifications uM FPU V3 Instruction Reference provides detailed descriptions of each instruction Check the Micromega website at www micromegacorp com for up to date information Micromega Corporation 1 Revised 2012 12 19 Installing and Connecting Table of Contents nii eis ii tel aia tothe au oe a 1 Mam FG did 2 A AAAA 1 Folin elle WE 1 Bie elN ole ue EE 1 Programming Flash Memory EE 1 F riher liiloimallo sai os EE 1 EI ell Of ein d Mee a a r E 2 Installing the UM FPU V3 IDE Software rnennnnennnnnnnnannnnnnannnnnnnnnnnnnnnnnnanennnnnnnannnnnnnnnanaa 5 CONNECTING tothe uM FPU V3 CHIP cssinisieonesnidiivesinseincininedesnannniuwabsnadinniaunadestannndesinounteliesbsnauluniuwnadbawananil 5 Connectuon RT Ee el eesncsnesisssene ii ea Ea E Eiei aeai Eana 5 Overview of uM FPU V3 IDE User Interface nnnnnnnennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn anne nnnnnnnnnee 6 PONCE NINO e ime a i i 6 HUUL VMA OM Se A aa rer ere ala ee a 7 DEDUG lee 8 Functions VV IC ER 9 Seral VO la feel EEN 9 Tutorial 1 Compiling FPU Code scssssssscssssssnssssesenecncenscecnscnscsensonscnenecneonscseasansessasausonsnsaussnssseaeanes 10 Compiling UM FPU VI TT 10 Starting the UM FPU V3 IDE TEE 11 Sale a omple EGUAHON meenesii oa a E a al i 11 SAMAGA ASS ren ee eee eee ee ce eee E ee ee ee 12 Dano TEE
4. PRINT_STRING Define instructions to print text string PRINT_STRING lt string gt Default empty string Parameters string Example PRINT STRING lt DEBUG string gt Description This command defines the instruction sequence to print text string A lt carriage return gt and lt linefeed gt is appended to the end of the output READ BYTE Define instructions to read 8 bit value READ_BYTE lt string gt Default empty string Parameters none Example READ BYTE lt name fpu readByte gt Description This command defines the instruction seguence to use to read an 8 bit value A lt carriage return gt and lt linefeed gt is appended to the end of the output READ DELAY Define instructions for read delay READ DELAY lt string gt Default empty string Parameters none Example READ DELAY lt call fpu readDelay gt Description This command defines the instruction seguence to be used to wait for the read delay A lt carriage return gt and lt linefeed gt is appended to the end of the output READ LONG Defines command to read 32 bit value READ_LONG lt string gt Default empty string Parameters none Example READ LONG lt name fpu readLong gt Micromega Corporation 69 uM FPU V3 IDE User Manual Reference Guide Target Description File Description This command defines the instruction sequence to use to read a 32 bit value A lt carriage return gt and lt linefeed gt is append
5. 2401 FMUL 1 2401 FMUL 1 1F3F FTOA 63 F232302E3833 READSTR 20 831 3100 The Trace button toggles the trace mode on and off Clicking the Clear button above the Debug Trace window will clear the contents of the Debug Trace window Breakpoints Breakpoints can be inserted into a program using the BREAK instruction or initiated manually with the Stop button Breakpoints occur after the next FPU instruction finishes executing When a breakpoint occurs the last FPU instruction executed before the breakpoint is displayed followed by the break message and the register display is updated Register values are displayed in red if the value has changed since the last time the display was updated or black if the value is unchanged 5E LOADPI BREAK The Go Stop and Step buttons are enabled or disabled depending on the current state of execution The Go button is used to continue execution and is enabled at Reset or after a breakpoint occurs The Stop button is used to stop execution after the next FPU instruction is executed If the uM FPU is idle when the Stop button is pressed the breakpoint will not occur until the next uM FPU instruction is executed If the FPU is already at a breakpoint Micromega Corporation 49 uM FPU V3 IDE User Manual Reference Guide Debugger then the Stop button will be disabled The Step button is used to single step through instructions with a new breakpoint occurring after each instruction The Register Pa
6. FpuClk MSBFIRST SELECTA Area LOADPI FSETO FMUL Radius FMUL Radius Done DEBUG CR Done CR END program PIC26057 AC SS scar uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code Starting the uM FPU V3 IDE Start the uM FPU V3 IDE program The program will open to an empty Source Window with the filename set to untitled Since we are using the Basic Stamp for this tutorial use the Target Menu to select BASIC Stamp SPI The Connection Status is shown at the lower left of the window A connection is not required to use the compiler it s only required for debugging and programming Entering a Simple Equation The uM FPU V3 IDE has predefined names for the registers in the FPU FO F1 F2 F127 specifies registers 0 through 127 and that the register contains a floating point value LO L1 L2 4127 specifies registers O through 127 and that the register contains a long integer U0 U1 U2 U127 specifies registers O through 127 and that the register contains an unsigned long integer Using these pre defined names you can enter a simple equation directly To add the floating point values in register 1 and register 2 and store the result in register 1 you can enter the following equation Fl Fl F2 The Source Window should look as follows m uM FPU V3 IDE File Edit Debug Functions Tools Help untitled Output Debug Functions Serial I O Target BASIC Stamp SPI v Fl F
7. READ LONG READ FLOAT uM FPU V3 IDE User Manual Reference Guide Target Description File REGISTER DEFINITION PRINT LONG BYTE DEFINITION PRINT FPUSTRING WORD DEFINITION PRINT NEWLINE LONG DEFINITION PRINT STRING FLOAT DEFINITION RESERVED PREFIX PRINT FLOAT RESERVED WORD A detailed description of each command is provided at the end of the section Reviewing the Sample File To better understand target description files we ll take a closer look at the sample target description file shown at the start of this section In order to be recognized as a target description file the first line of the file must contain the TARGET NAME command It specifies the name of the target as it will appear in the Target Menu of the Source Window TARGET NAME lt Generic C compiler gt The next section defines the maximum output line length number of bytes per write statement and prefix characters for comments and hex values MAX LENGTH lt 80 gt maximum line length of 80 characters MAX WRITE lt 6 gt maximum of 6 bytes per write statement TAB SPACING lt 4 gt use lt tab gt characters 4 character per tab COMMENT PREFIX lt gt comments have prefix SOURCE PREFIX lt t gt source code has lt tab gt prefix HEX FORMAT lt 0x byte gt hex values have 0x prefix STRING HEX FORMAT lt x byte gt hex string characters have x prefix The next two commands specify the format for writing out bytes The WRITE command uses three
8. a file save dialog will be displayed Save As menu item displays a file save dialog and allows a new filename to be specified Exit menu item causes the IDE to guit If a source file is open and has been changed since the last time it was saved you will first be prompted to save the source file Edit Menu Undo Ctrl 2Z Redo Ctrl Shift 2 Cut Ctrl X Copy Ctrl C Clear Select All cCtri 4 Comment cCtri Find Ctrl F Find Next F3 Replace Ctrl H Undo menu item cancels the last edit in the Source Window Micromega Corporation 28 uM FPU V3 IDE User Manual Reference Guide Menus and Dialogs Redo menu item restores the edit cancelled by the last Undo Cut menu item removes the selected text from the Source Window Copy menu item copies the selected text from the Source Window to the clipboard Paste menu item pastes the text in the clipboard to the current selection point in the Source Window Clear menu item deletes the selected text from the Source Window Select All menu item selects all of the text in the current text field Comment menu item is used to add a semi colon as the first character of every currently selected line in the Source Window This provides a way to quickly comment out a block of code If all of the lines currently selected have a semi colon as the first character the menu item changes to Uncomment Uncomment menu item removes the semi colon from the start of all selected lines Find menu it
9. 3 Calculations 23 uM FPU V3 IDE User Manual Tutorial 3 Programming FPU Flash Memory Compile and Review the Functions Click the Compile button In the Output Window the function code is displayed comments that show the uM FPU assembler code that was generated This is the code that will be programmed to the FPU function GetDiameter Diameter Radius 2 SELECTA 11 FSET 10 i FMULI 2 The Functions Window should look as follows uM FPU V3 IDE File Edit Debug Functions Tools Help New Function 3 Get4rea SELECTA 13 Read Stored Functions LOADPI FSETO FMUL 10 FMUL 10 Program Functions Overwrite Stored Functions Always Confirm with User Never l Stored Function 3 COM4 57600 8 N 1 Compiled successfully for BASIC Stamp SPI The Function List shows that three functions have been defined The New Function Code displays the FPU instructions for the selected function The Stored Function Code displays the FPU instructions for the function stored on the FPU If no function has previously been programmed the Stored Function Code will be empty You can see the code for a different function by selecting it in the Function List Storing the Functions Make sure that the Overwrite Stored Functions preference is set to Always as shown in the figure above Click the Program Functions button to program the functions into Flash memory on the FPU A status dialog will be displayed as the functi
10. IDE User Interface will compile the code for the target selected by the Target Menu If an error occurs during compile then an error message will be displayed as the Status Message All error messages are displayed in red Output Window The Output Window is automatically displayed if the compile is successful The status message will show that the compile was successful All normal status messages are displayed in blue Output Tab Button Bar Compiler Output Window wu EDU V3 IDE File Edit Debug Functions Took Help tutorial1 fpu uM FPU Register Definitions Radius uH FPU Diameter uM FPU Circumference uH FPU uM FPU Variable Definitions distance Word signed word variable areaiIn Word word variable Generated Code distance Word Microcontroller variable definitions arealIn Word Radius F10 FPU register definitions Diameter equ Fll Circumference equ Fl2 Area equ Fl3 Radius distance 1000 Calculations SHIFTOUT Fpu0ut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSETO LOADWORD 03 SES FDIVO Diameter Radius 2 SHIFTOUT Fuurt FpuClk MSBFIRST SELECTA Diameter FSET Radius FMULI 2 Circumference PI Diameter SHIFTOUT Fuurt FpuClk MSBFIRST SELECTA Circumference LOADPI FSETO FMUL Diameter Area PI Radius Radius SHIFTOUT Fpudut FpuClk MSBFIRST SELECTA Area LOADPI FSETO FMUL Radius FMUL Radius COM4 576
11. LDEC cnt BRA GT loop endasm For Statement Psuedocode for cnt startValue to endValue sum sum l next Assembler Code asm SELECTA cnt LSET startValue loop SELECTA sum FADDI 1 LINC cnt LCMP2 cnt endValue BRA LT loop endasm String Arguments Reference Guide Assembler set loop counter to 20 sum sum 1 decrement loop counter repeat until done set loop counter to start value sum sum 1 increment loop counter check for end value repeat until done Several options are provided for assembler instructions that reguire a string argument The simplest form is to use a string constant The assembler will automatically add a zero terminator as reguired STRSET test Special characters can be entered using a backslash followed by two hexadecimal digits STRSET linel 0OD 0Aline2 add carriage return linefeed between linel and line2 The assembler will also form a string by concatenating multiple string and byte constants STROET Wanel 157 102 ane An empty string can be specified in two ways STRSET STRSET 0 Micromega Corporation 46 results in the same string as above empty string uM FPU V3 IDE User Manual Reference Guide Assembler Table Instructions The TABLE FTABLE LTABLE and POLY instructions are only valid inside functions These instructions specify a count of the number of additional arguments and the additional arguments are added us
12. LDIVI 100 Program Functions 0007 FLOAT 0008 LEFT Overwrite Stored Functions 0009 STRFIND always 0000 STRDEC 000D STRDEC Confirm with User 000E READVAR 15 Never 0010 STRSEL 128 7 0013 STRTOF 0014 FSETO 0015 FDIVI 60 NNI RTAHT Stored Function 7 read from FPU gt LEFT STRFIELD 129 STRTOL LSETO LDIVI 100 FLOAT LEFT STRFIND STRDEC STRDEC READVAR 15 STRSEL 128 7 STRTOF FSETO FDIVI 60 RTGHT COM4 57600 8 N 1 Compiled successfully for BASIC Stamp SPI Connection Status Status Message Stored Function Code The Function List provides information about each function defined by the compiler and stored on the FPU The New Function Code displays the FPU instructions for compiled functions and the Stored Function Code displays the FPU instructions for functions stored on the FPU The Read Stored Functions button is used to read the functions currently stored on the FPU and the Program Functions button is used to program new functions to the uM FPU V3 chip Serial I O Window The Serial O Window shows a trace of the serial data exchanged between the IDE and the uM FPU V3 chip It s provided mainly for diagnostic purposes Micromega Corporation 9 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code Tutorial 1 Compiling FPU Code This tutorial takes you through the process of compiling uM FPU V3 code for a few simple examples Various IDE features
13. Step and Conditional Breakpoints ceceesseeeeeeeeeeeeneeeeseneenesensenenees 52 PAULO Step Conditions RI e ie ET 52 Break on tot feiren EE 53 oy aro 2 a Oh Oy RR Ree t aaa EE 53 Break Oli Ot n annae aaa aadel daa aaa a ina a eran 54 Break ele EE ue EE 54 BREAK eg e EE 54 Bie AKON Et ee E 56 Reference Guide Programming Flash Memory ccccssscssseeeeeeeeseeeeeeeeeaseeeeseeeagsueeeeeeaaeeeeesseeaaens 57 FPUNCUON AT a1 8 0 EE 57 Reference Guide Setting UM FPU V3 Parameters cessesseeseeseeeneeeeeeeseneeneseneeneeeesenseneneesenenaees 59 El SE B 21 6 e EE 59 Micromega Corporation 3 uM FPU V3 IDE User Manual Installing and Connecting Giele e NEE 59 Ileese nie E e NE A E E E ee E S E S E ee ee 59 Use PIC Format IEEE 754 1S Gebeess eege eege eege aaa taa ESS 59 Idle Mode Fees deed dee deed dee Seege 60 interlace MOGAE lt isustacashcatscccteataceahamencccmecnnnesuadiacceseeradanvcmiudnsaeebensamanbecnadastedss a mameena aiea 60 26 AAAHESG EE 60 Ato ta d ee 60 Resiore REI rue CT 60 Reference Guide Target Description File cecsesseeeeeseeeneeneeneeeneeneeeeseneeneseneoneseesensonesansoneaaess 61 EE 62 Elsa eea 62 Beil Elei 62 Reviewing the Sample Filo seiccsicsctcctsetecassestontite toccetapennieedidecesSecneseeeenteasasienactcntgoeceettesbabestecsedneens 63 Reserved WOOS EE 65 Target Desoriptl n COMMANGS AAA 66 Micromega Corporation 4 uM FPU V3 IDE User Manual Installing and
14. and a set of predefined target description files are included with the IDE The system target files are installed and loaded from the following folder Program Files Micromega uM FPU V3 IDE rxxx Target Files where rxxx is the IDE software revision number User target files are loaded from the following folder My Documents Micromega Target Files Users can create their own target description files Target files are text files that can be created and edited with any text editor The file should then be copied to the user target folder to be loaded when the IDE starts The target file contains a series of commands to define how the compiler will generate code for a particular target To be recognized by the IDE as a target description file the first line of the file must contain the TARGET NAME command A sample target description file is shown below TARGET NAME lt Generic C compiler gt This file defines code generation for a C compiler MAX LENGTH lt 80 gt MAX WRITE lt 6 gt TAB SPACING lt 4 gt COMMENT PREFIX lt gt SOURCE PREFIX lt t gt HEX FORMAT lt 0x byte gt STRING HEX FORMAT lt x byte gt WRITE lt t fpu_write nl byte gt WRITE BYTE FORMAT lt byte gt WRITE WORD lt t fpu_ writeWord word gt WRITE LONG lt t fpu writeLong long gt WRITE FLOAT lt t fpu writeFloat float gt WRITE STRING lt t fpu writeChar string gt WAIT lt t fpu_wait gt READ B
15. are introduced as we go through the tutorial For a more complete description of specific features see the the Reference Guide sections later in this document This tutorial uses the BASIC Stamp with a SPI interface as the target If you re working with a different microcontroller or compiler the procedures are the same but the output code for the selected target will be different The figure below shows the process of developing FPU code using the IDE Compiling uM FPU V3 code uM FPU V3 IDE tutorial1 fpu Microcontroller Development Tool tutorial1 bs2 distance VAR Word arealn VAR Word Microcontroller variable definitions Radius equ F10 Diameter equ F11 FPU register definitions uM FPU Register Definitions Circumference equ F12 10 uM FPU register Area equ F13 Diameter 11 uM FPU register Circumference 12 uM FPU register Radius distance 1000 Calculations 13 uM FPU register Diameter Radius 2 Circumference PI Diameter Variable Definitions Area PI Radius Radius distance word signed word variable arealn Word signed word variable compile Output window DEBUG CR umfpuV3 spi CR GOSUB Fpu Reset reset the FPU hardware uM FPU Register Definitions 10 uM FPU register IF status lt gt SyncChar THEN Diameter 11 uM FPU register DEBUG uM FPU not detected Circumference 12 uM FPU register END 13 uM FPU register ELSE GOSUB Print Version Variable Definitions DEB
16. each time the Auto Step button is pressed Auto Step Conditions Dialog Auto Step Conditions Break on Instruction d Instruction Break on FCALL DW Function lt any Function gt break on call break on return Break on Count d Instruction Count Break on Register Change a Registers Break on Expression oO Break on String LI equals v String Selection Always display this dialog before Auto Step Clear Break Conditions Micromega Corporation 52 uM FPU V3 IDE User Manual Reference Guide Auto Step and Conditional Breakpoints Break on Instruction This condition causes a breakpoint when a particular instruction is executed The instruction is specified using assembler format as shown below Break on Instruction Instruction SELECTA v The opcode can be selected from a pop up menu Break on Instruction d Instruction ADCSCALE ADCTRIG ADCWAIT ALOADX ASIN ATAN or the opcode can be typed in the field An auto complete feature is provided to assist in typing the opcode Break on Instruction Instruction sel v SELECTA SELECTMA SELECTME SELECTMC SELECT Break on FCALL This condition causes a breakpoint when a user defined function is called or when it returns Break on FCALL Function 6 drawLineGraph Ka break on call break on return The function is selected from a pop up menu The menu has all of the function
17. lt tab gt character or t and tn parameters can be used to align the output to particular character positions They can be inserted into any of the output commands The lt tab gt character and t parameter will insert lt space gt characters until the next character position is a multiple of the value specified by the TAB SPACING command If the value specified by TAB SPACING is positive only spaces are used to move to the next tab position If the value is negative then both lt space gt and lt tab gt used to move to the next tab position The tn parameter will insert characters until the character position equals the value specified If the output is already at a position greater than the character position specified a single lt space gt or lt tab gt will be output Commands A target description file only needs to contain those commands that are necessary to define the output for a particular target There are default values for many of the commands The available commands are as follows TARGET NAME MAX LENGTH MAX WRITE TAB SPACING DECIMAL FORMAT HEX FORMAT STRING HEX FORMAT OPCODE PREFIX COMMENT PREFIX SOURCE PREFIX SEPARATOR CONTINUATION START WRITE TRANSFER START READ TRANSFER STOP TRANSFER WALT Micromega Corporation 62 WRITE WRITE BYTE FORMAT WRITE WORD FORMAT WRITE LONG FORMAT WRITE FLOAT FORMAT WRITE STRING FORMAT WRITE BYTE WRITE WORD WRITE LONG WRITE STRING READ DELAY READ BYTE READ WORD
18. maximum clock speed should be 14 74 MHz The clock source is stored in Flash memory as part of the device configuration bits The clock selection indicates the clock source to use at power up If the selected clock source can t be validated at power up the uM FPU V3 1 chip will fall back to an internal clock speed of 1 8425 MHz The available clock speeds and clock sources are selected by entering one of the following values 29 48 MHz internal oscillator default maximum for 5V operating voltage 14 74 MHz internal oscillator maximum for 3 3V operating voltage 7 37 MHz internal oscillator maximum for 2 7V operating voltage 1 8425 MHz internal oscillator 29 4912 MHz external 7 3728 MHz crystal 20 0 MHz external 10 0 MHz crystal 10 0 MHz external 10 0 MHz crystal Micromega Corporation 34 uM FPU V3 IDE User Manual Reference Guide Menus and Dialogs It may be necessary to power the chip off and back on before the new clock source will take effect since some clock sources use an internal PLL that only resets at power up Help Menu uM FPU V3 IDE User Manual uM FPU 3 IDE Compiler uM FPU V3 1 Instruction Set uM FPU 3 1 Datasheet Micromega Website Application Notes About uM FPU 3 IDE uM FPU V3 IDE User Manual uM FPU V3 IDE Compiler uM FPU V3 1 Instruction Set and uM FPU V3 1 Datasheet menu items display documentation files using the default PDF viewer The IDE will open the files on the Micromega website using
19. numbers If functions have been defined in the current source file and compiled the function name is also displayed in the menu The special item lt any function gt can also be selected to cause a breakpoint on any function call Micromega Corporation 53 uM FPU V3 IDE User Manual Reference Guide Auto Step and Conditional Breakpoints Break on FCALL Function gany function zany Function gt 0 getID 1 getDistance 2 getLocation 3 getLatLong 4 radiansToDM S readNMEA 6 parseGPRMC 7 NMEA Degrees 8 9 10 Break on Count This condition causes a breakpoint after a specified number of instructions has executed Break on Count Instruction Count 100 Break on Register Change This condition causes a breakpoint when the value changes in one of the specified registers Break on Register Change Registers 1 3 10 20 2 Multiple registers can be specified separated by commas A register can be specified as e a single register value e g 1 e arange of register values e g 3 10 which selects registers 3 through 10 e an array of register values e g 20 2 which selects two registers starting at registers 20 If register names have been defined in the current source file and compiled the names can also be used Break on Expression This condition causes a breakpoint whenever the expression is true Break on Expression lati al lilo a The left side of the expression must be a regis
20. parameters The t will be replaced by a lt tab gt character The n1 is replaced by the number of bytes in the write statement or the empty string if the write statement has only one byte The byte argument is replaced by up to six bytes set by MAX WRITE The format for the byte value is determined by the WRITE BYTE FORMAT command and is just the value itself with no additional prefix or suffix WRITE lt t fpu_write nl byte gt WRITE BYTE FORMAT lt byte gt An example of the output generated by these commands is as follows fpu write2 SELECTA temp fpu write CLRA Next are the commands for writing out word long float and string values In this example each of these are defined to use a separate function call In other cases the values could be output using the WRITE command by defining a a format command instead of a separate function call i e WRITE WORD FORMAT instead of WRITE WORD WRITE WORD lt t fpu writeWord word gt WRITE LONG lt t fpu writeLong long gt Micromega Corporation 63 uM FPU V3 IDE User Manual Reference Guide Target Description File WRITE FLOAT lt t fpu writeFloat float gt WRITE STRING lt t fpu_writeChar string gt An example of the output generated by these commands is as follows fpu writeWord 1000 fpu writeLong value fpu writeLong 100 25 fpu writeString Result The WAIT command specifies the function to call to wait for the FPU ready statu
21. the default web browser Micromega Website menu item opens the Micromega website using the default web browser Application Notes menu item opens the application notes page on the Micromega website using the default web browser About uM FPU V3 IDE menu item displays a dialog with product identification release version and release date of the uM FPU IDE software Micromega Corporation 35 uM FPU V3 IDE User Manual Reference Guide Compiler Reference Guide Compiler The uM FPU V3 IDE provides a compiler for generating uM FPU V3 code for either a target microcontroller or for user defined functions that are stored in Flash memory on the FPU The Source Window has a built in editor for entering the source code The source code contains symbol definitions and math equations that will be converted to FPU instructions by the compiler The output format is customized to the correct syntax for the target microcontroller User defined functions can be programmed to Flash memory on the uM FPU V3 chip Symbol definitions can include FPU registers variables and constants Math equations can use long integer or floating point values and can contain defined symbols math operators functions and parentheses The compiler also supports an in line assembler for entering FPU instructions directly Order of Evaluation Math equations are evaluated by the IDE from left to right with no operator precedence F1 F2 F3 F4 results in F1 being set to
22. the value of F2 added to F3 then multiplied by F4 Parentheses must be used to change the order of operations Fl F2 F3 F4 results in F1 being set to the value of F2 added to the value of F3 multiplied by F4 Multiple constant values entered one after another are automatically reduced to a single constant in the expression Fl F2 5 2 results in F1 being set to the value F2 multiplied by 2 5 If you don t want constants to be reduced you need to use parentheses The familiar expression for converting temperature from Celsius to Fahrenheit would be entered as Fl F2 9 5 32 If no parentheses were used in the above equation the equation would be calculated as F2 multiplied by 33 8 which is incorrect The code generator often adds one level of parenthesis so parentheses in math equations should only be nested up to seven levels deep including the parentheses used for functions Comments Comments can be added to any line of source code Comments are preceded by an apostrophe semi colon or double slash characters All text after the comment prefix to the end of line is considered a comment all text after an apostrophe to the end of line is a comment gt all text after a semi colon to the end of line is a comment all text after a double slash to the end of line is a comment Symbol Names Symbol names must begin with an alphabetic character followed by any number of alphanumeric characters or the underscore c
23. uM FPU V3 IDE User Manual Reference Guide Auto Step and Conditional Breakpoints Reference Guide Auto Step and Conditional Breakpoints The Auto Step feature provides a means to automatically single step through FPU instructions This feature in conjunction with Auto Step Conditions can be used to implement conditional breakpoints Conditional breakpoints stop instruction execution when one of the specified conditions occur Breakpoints can be set for a variety of conditions including when a particular instruction 1s executed when a user defined functions is called when a specified number of instructions have been executed when a register value changes or matches a particular expression or when a string comparison matches a particular condition Multiple conditions can be specified and a breakpoint will occur when any of the conditions is met Conditional breakpoints are only active when the Auto Step operation is used They are not active when the Go or Step operation is used Instruction execution is much slower using Auto Step since an internal breakpoint occurs for each instruction and the debug trace and register data are checked for Auto Step Conditions Auto Step is activated by clicking the Auto Step button or selecting the Debug gt Auto Step menu item Auto Step Conditions are set by right clicking the Auto Step button or selecting the Debug gt Auto Step Conditions menu item The Auto Step Conditions can also be set to appear
24. will go to sleep when idle and the chip is not selected This mode is only active if the interface mode is SPI with the CS pin used as a chip select Interface Mode By default the CS pin on the uM FPU V3 chip is read at Reset to determine if the SPI or C interface is to be used The interface mode parameter can be used to force selection of SPI or PC at Reset ignoring the CS pin or to specify SPI mode with the CS pin acting as a chip select Note Most of the SPI support software currently supplied by Micromega assumes that no chip select is used If the chip select option is enabled you must ensure that the CS pin is being handled properly If SPI is used without chip select the CS pin must be tied low I2C Address By default the PC address used by the uM FPU V3 chip is C8 hexadecimal or 1100100x binary If the default address conflicts with another PC device or if multiple uM FPU V3 chips are used on the same DC bus the address can be changed to any other valid I C address The address is entered as an 8 bit hexadecimal number with the lower bit ignored A value of 00 will select the default C8 address Auto Start Mode A user defined function can be called and Debug Mode can be disabled when the FPU is Reset If the Disable Debug option is selected Debug Mode will be disabled at Reset This is useful if the SERIN and SEROUT pins are being used for other purposes e g GPS input LCD output and prevents the RESET message from b
25. 00 8 N 1 Compiled successfully for BASIC Stamp SPI Connection Status Status Message If the code was generated for a target microcontroller the Select All and Copy buttons can be used to copy the code from the window so it can be pasted into the microcontroller program Alternatively the code can be copy and pasted a section at a time by doing a text selection and using the Copy button The Remove Source button can be used to remove the source code lines that are included as comments Micromega Corporation 7 uM FPU V3 IDE User Manual Overview of UM FPU V3 IDE User Interface Debug Window The Debug Window is used for debugging It displays the instruction trace reset and breakpoint information and the contents of the FPU registers string buffer and status value Register Display Debug Trace Button Bar Selected Name Hex Value Formatted Value uM FPU V3 IDE Sele File Edit Debug Functions Tools Help _tutoriall fpu Output Debug Functions Serial I O to top Registers 40490FDB 3 141593 VERSION F2754D2D4650 READSTR uM FPU V3 1 2 52056332E31 2E3200 0104 SELECTA Radius LOADWORD O FSETO LOADWORD 1000 FDIVO SELECTA Diameter FSET Radius FMULI 2 SELECTA Circumference LOADPI FSETO FMUL Diameter SELECTA Area LOADPI FSETO FMUL Radius FMUL Radius FFFFFFF NaN String Selection 0 13 Status 00 COM4 57600 8 N 1 Connection Status String Buffer
26. 12 Calculating le TICE 12 Copying Code to your Main PFOGFAM ME 13 KHAN E LAS ate tlie ee te cc a naa a a Aaa ee aia 15 Calculating Diameter Circumference and Area nn nennnrnnnnnnnnennnnnennnnnnannnnnennnnnnn enne 15 Copy Revised Code to the Main Program 4 mida iti rjad ea ek imal 16 Running tne Revised 8070 182 11 EE 18 Saving tie Sources TEE 18 Tutorial 2 Debugging FPU Code ennrennonannannennanannnoenannennsnonnnnnennnnannenesnennannsnennnnnneananes 19 Making the Connection eege 19 Tracing Werder 19 BLG ee ln eee eee ace ee A ect ee eee ere ere ee ee 20 SING le SISO PING a ae E MA Ma t 21 Tutorial 3 Programming FPU Flash Memory mnneenennnennnnnnnnnennnnnnnnnnnnnnnnnnnnnnnnanennnnnnmanea 22 Making the We len METSSEA A ert te eer ete ee ee ee 22 Defining FUNCIONS aa a iu a a aa i ai 22 Callino Diaen 22 Modifying th Code for le EE 23 Compile dnd Review the ln Leute EE 24 GENEE all a 811 4 seer ne nen ene ner A a a a eee 24 PRUE VEN Me LOOK al EE 25 Reference Guide Menus and Dialogs eensnnstununutsnun usu ndk una n tu nuna t nn nu dan annan nandu nam 28 Pile ME e 28 EGIL ER EE 28 Denu Wile 9 Vertes ee ee UMA 30 PUTCO CEA 31 10015 Tu BEE 33 Help MENU eee eect ee ee ee ee ee ee ee ee oe 35 Reference Guide Compiler scsssssssssssssssssssssnssnssnssssensenssnsenssnsensensensensensesenssnssssnsenssnssnssnssnsenss 36 Doer Oi UO som sam
27. 2 Copy the uM FPU Register Definitions and Variable Definitions from the Output Window and paste in the Basic Stamp program in the main definitions section Copy the Generated Code from the Output Window and paste in the Basic Stamp program after the Main label Since we don t actually have the sensor described we ll enter a test value at the start of the program Add the following line immediately after the Main label distance 2575 To print the result add the following lines immediately after the code you copied DEBUG CR Radius GOSUB Print Float Micromega Corporation 13 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code The main section of your BASIC Stamp program should look as follows EE uM FPU Register Definitions Radius CON 10 uM FPU register Variable Definitions distance VAR Word signed word variable initialization Reset DEBUG CR umfpuV3 spi CR GOSUB Fpu_ Reset reset the FPU hardware IF status lt gt SyncChar THEN check for synchronization DEBUG uM FPU not detected END ELSE GOSUB Print Version display the uM FPU version number DEBUG CR ENDIF main routine Main distance 2575 Generated Code distance VAR Word
28. Connecting Installing the uM FPU V3 IDE Software The uM FPU V3 IDE software can be downloaded from the Micromega website at http www micromegacorp com ide v3 bm The download is called UM FPU V3 IDE xxx zip where xxx is the release number e g 328 Double click or unzip the file then open the folder and run the installer called UM FPU V3 IDE setup exe The software is installed in the Program Flles gt Micromega folder and the Start Menu entry is Micromega Connecting to the uM FPU V3 chip Compiling can be done without a serial connection but a serial connection between the computer running the IDE and the uM FPU V3 chip is required for debugging and programming For recent computers the easiest way to add a serial connection is using a USB to Serial adapter Older computers with serial ports or USB to RS 232 adapters require a level converter e g MAX232 The uM FPU V3 chip requires a non inverted serial interface operating at the same voltage as the FPU 1 e if the FPU is operating at 5V the serial interface must be a 5V interface Examples of suitable USB to Serial adapters include Sparkfun FTDI Basic Breakout 5V http www sparkfun com Parallax USB2SER Development Tool http www parallax com Connection Diagram PC running uM FPU V3 IDE OI lt uM FPU V3 1 MCLR ANO AN1 CS EXTIN Microcontroller OSC Board OSC2 SEROUT SERIN Micromega Corporation 5 uM FPU V3 IDE User Man
29. EE E EE eT EE EET EEE EEE E EEE ETE e eee EERE ET SERRE EERE EERE EERE EERE EERE EERE EEE EERE EEE EE EEE EERE EEE EEE EEE EE EEE EEE EEE EE EERE EEE EERE EEE EEE EERE EE EEE EEE EE EEE ESET EEE EEE EEE EE EEE EE EEE Eee EEE EEE EE EEE EEE EEE EEE Ee Ee EE Eee eee reer KEERATA 2 575 LG ene 1076153549 asss Circumferenc Unsiqned 1076153549 EZ A BIS ALGA aaa 41464553 20 83072 n RIA TFFFFFFF MaM Register names are automatically set from the register definitions in the source file Registers can often have several different names assigned If you click on the register name a pop up menu is displayed showing all of the names for that register If you select a different name the display will be updated to show that name Registers Read Registers A BU ceumutntntatntntntntatnta 40490FDB 3 141593 n A KASE RL tmpl N tmp Leg a ch R a parami en W Re errr li na TTT NM The current register values are automatically updated after every breakpoint The Read Registers button can also be used to manually force an update of the register values Register values are displayed in red if the value has changed since the last time the display was updated or black if the value is unchanged Error messages lt data error gt The IDE communicates with the uM FPU V3 chip using a serial connection If the IDE detects an error in the data received from the FPU the data error message is displayed in the Debug Trace Th
30. ET Radius FMULI 2 DEBUG CR Diameter 2 format 63 GOSUB Print FloatFormat Circumference PI Diameter SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Circumference LOADPI FSETO FMUL Diameter DEBUG CR Circumference format 63 GOSUB Print FloatFormat Area PI Radius Radius SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Area LOADPI FSET0 FMUL Radius FMUL Radius DEBUG CR Area S format 63 GOSUB Print FloatFormat arealn Area arealn Area SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA 0 LOAD Area FIX GOSUB Fpu Wait SHIFTOUT FpuOut FpuClk MSBFIRST LREADWORD SHIFTIN Fpuln FpuClk MSBPRE areaIn HIGHBYTE arealn LOWBYTE Micromega Corporation 17 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code DEBUG CR Arealn DEC Arealn END Running the Revised Program Run the BASIC Stamp program The following output should be displayed in the terminal window um fpuV53 spi uM FPU V3 1 Z Padius Diameter Circumferenc Area Arealn Done Area is displayed as 20 831 but arealn is displayed as 20 This is because when a floating point number is converted to a long integer it is truncated not rounded If you prefer the value to be rounded then use the ROUND function before converting the number In the FPU source file replace arealn Area with areaIn ROUND area Compile the FPU code copy and paste the new code to the BASIC Stamp program R
31. FFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF Memory Map Legend Function Header Data Function Code Micromega Corporation SP Poe FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF M Seles Data Slot 0 Float Long Unsigned Hex 1 065189e 37 2112816021 2182151275 8210FC6B User Defined Function Slot 0 0000 READVAR 16 0002 BRA NZ 000C 0005 STRSEL 0 127 0008 READVAR 16 0004 RET Z 000C COPYO 3 000E SELECTA 3 0010 READVAR 15 0019 READVAR 17 0016 LCMPI 32 001D BRA NZ 0028 Close 32 UM FPU V3 IDE User Manual Reference Guide Menus and Dialogs The EEPROM Memory Map dialog displays the contents of EEPROM memory The 32 bit value contained in each slot of the memory map is displayed as a hexadecimal value Slots that may contain user defined functions are displayed with a green background for the function header and a blue background for the remainder of the function code Function headers are identified by looking at the first byte and using that value as an index to another byte that must be 0x80 the RET instruction It s possible for slots with the right configuration of data to be shown in the memory map as a user defined function without actually being one When a slot is selected by clicking on the EEPROM
32. FloatFormat statements for each of the calculated values Radius Diameter Circumference and Area We ll use the Print FloatFormat with format 63 to display the floating point values in a field six characters wide with digits to the right of the decimal point DEBUG CR Radius S format 63 GOSUB Print FloatFormat The main section of your BASIC Stamp program should look as follows uM FPU Register Definitions Radius CON 10 uM FPU register Diameter CON 11 uM FPU register Circumference CON 12 uM FPU register Area CON 13 uM FPU register Micromega Corporation 16 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code distance VAR Word signed word variable arealn VAR Word signed word variable initialization Reset GOSUB Fpu Reset reset the FPU hardware IF status lt gt SyncChar THEN DEBUG uM FPU not detected END ELSE GOSUB Print Version display the uM FPU version number DEBUG CR ENDIF ooooooooo main routine Main distance 2575 Radius distance 1000 SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSET0 LOADWORD 03 SES FDIVO DEBUG CR Radius S format 63 GOSUB Print FloatFormat Diameter Radius 2 SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Diameter FS
33. M EQU F2 Z EQU F3 FUNCTION 1 Hypotenuse function definition Z SQRT X X Y Y END X Valuel Y Value2 Hypotenuse call function Hypotenuse Function calls can be nested up to 16 levels deep Function Prototypes To ensure that the function being called is already defined function prototypes can be included at the start of the program By placing prototypes at the top of the source code functions can be defined and called in any order since the function values are known Function prototypes are defined using the FUNC operator which assigns a symbol name to a function number You can assign the function number explicitly or use the character to assign the next unused function number GetDiameter func 1 GetDiameter is function 1 GetCircumference func S GetCircumference is function 2 GetArea func S GetArea is function 3 Global Symbols vs Local Symbols All symbols defined at the top of the source file outside of any function are global symbols and can be used by any source code that follows Symbols that are defined inside a function are local symbols and can only be used within that function tmp1 equ Fl global symbol definition function samplel tmp2 equ F2 local symbol definition SELECTA tmp1 both tmpl and tmp2 are defined inside the function FSET tmp2 Micromega Corporation 40 uM FPU V3 IDE User Manual Reference Guide Compiler end only tmpl is defined outside the function Assembler Code The IDE
34. NT_FLOAT lt string gt Default empty string Parameters byte Example PRINT FLOAT lt format byte GOSUB PRINT FLOAT gt Description This command defines the instruction seguence to print a 32 bit floating point value A lt carriage return gt and lt linefeed gt is appended to the end of the output PRINT FPUSTRING Define instructions to print FPU string PRINT_FPUSTRING lt string gt Default empty string Parameters none Example PRINT FPUSTRING lt GOSUB PRINT FPUSTRING gt Description This command defines the instruction sequence to print FPU string A lt carriage return gt and lt linefeed gt is appended to the end of the output PRINT_LONG Define instructions to print long value PRINT_LONG lt string gt Default empty string Parameters byte Example PRINT FLOAT lt format byte GOSUB PRINT LONG gt Description This command defines the instruction sequence to print a 32 bit integer value A lt carriage return gt and lt linefeed gt is appended to the end of the output Micromega Corporation 68 uM FPU V3 IDE User Manual Reference Guide Target Description File PRINT NEWLINE Define instructions to print new line PRINT_NEWLINE lt string gt Default empty string Parameters none Example PRINT NEWLINE lt DEBUG CR gt Description This command defines the instruction sequence to print a new line A lt carriage return gt and lt linefeed gt is appended to the end of the output
35. PZ MZ INF FIN PINF MINE NAN TRUE FALSE Labels greater than greater than or equal plus zero minus zero infinity finite plus infinity minus infinity Not a Number always true always false 70 71 73 C8 CO E8 EA 44 00 FF Reference Guide Assembler N 0 S 0 Z 0 special case N 0 S 0 Z 1 N 0 S5 1 Z 1 I 1 N 0 I 0 N 0 I 1 N 0 S 0 I 1 N 0 S 1 N 1 special case special case Labels must be at the start of a source code line and must begin with an underscore character followed by a number or by a seguence of alphanumeric characters terminated by a colon Labels are local symbols and are only valid in the function they are defined in The same label could be used in different functions Lg loop wait Using Branch Instructions and Labels The following examples demonstrate the use of branch instructions and labels Psuedocode and the corresponding FPU assembler code are shown for each example If Statement Psuedocode if tmp lt 10 sum sum l else sum sum 10 end if Assembler Code asm SELECTA tmp FCMPI 10 BRA GE _1 SELECTA sum FADDI 1 BRA 2 SELECTA sum FMULI 10 a endasm Repeat Statement Psuedocode repeat 10 times Micromega Corporation 45 if tmp lt 10 sum sum 1 else sum sum 10 endif uM FPU V3 IDE User Manual sum sum l Assembler Code asm SELECTA cnt LSETI 20 loop SELECTA sum FADDI 1
36. RITE command SEPARATOR lt string gt Default comma and space Parameters none Example SEPARATOR lt gt Description This command sets the separator character used between items in write_command SOURCE_PREFIX Set indent for the start of a comment line SOURCE_PREFIX lt string gt Default semi colon Parameters none Example SOURCE PREFIX lt gt Description This command sets the prefix that s added to source code lines that are copied as comments included with the generated code The correct string must be specified for a valid comment START READ TRANSFER Define instructions for start of a read transfer START READ lt sfring gt Default empty String Parameters none Example START READ lt CALL START READ gt Description This command defines the instruction seguence used to start a read transfer Some implementations will not require this command A lt carriage return gt and lt linefeed gt is appended to the end of the output START WRITE TRANSFER Define instructions for start of a write transfer START WRITE c lt string gt Default empty string Parameters none Example START WRITE lt CALL START WRITE gt Description This command defines the instruction sequence used to start a write transfer Some implementations will not require this command A lt carriage return gt and lt linefeed gt character is appended to the end of the output STOP_TRANSFER Define instructions f
37. Radius equ F10 Radius distance 1000 SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSET0 LOADWORD 03 SES FDIVO DEBUG CR Radius GOSUB Print Float Done DEBUG CR Done CR END Micromega Corporation 14 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code Running the Program Run the BASIC Stamp program The following output should be displayed in the terminal window um fpuV3 spi uM FPU V3 1 2 Radius 2 575 Done Calculating Diameter Circumference and Area Now that we have the initial program let s add the calculations for diameter circumference and area Add the following register definitions in the start of the tutorial1 fpu Diameter equ F11 Circumference equ F12 Area equ F13 The area of a circle is twice the radius so we add the following line to calculate diameter Diameter Radius 2 The circumference of a circle is equal to the value pi GO times the diameter The IDE has a pre defined name for x called PI so you can simple enter the following line to calculate circumference Circumference PI Diameter The area of a circle is equal to pi st times radius squared The POWER function could use to calculate radius to the power of 2 but for squared values it s easier and more efficient to simply multiply the value by itself Enter the following line to calculate the area Area PI Radius Radius Finally
38. Status Message Status Byte The Debug Trace displays messages and instruction traces The Reset message includes a time stamp is displayed whenever a hardware or software reset occurs Instruction tracing will only occur if tracing is enabled This can be enabled at Reset by setting the Trace on Reset option in the Functions gt Set Parameters dialog or at any time by by sending the TRACEON instruction The Register Display shows the value of all registers Register values that have changed since the last update are shown in red The String Buffer displays the FPU string buffer and string selection and the Status Byte shows the FPU status byte and status bit indicators The Register Display String Buffer and Status Byte are only updated automatically at breakpoints They can be updated manually using the Read Registers button Micromega Corporation 8 uM FPU V3 IDE User Manual Overview of UM FPU V3 IDE User Interface Functions Window The Functions Window shows the function code for all new functions and stored functions It also can be used to program the functions into Flash memory on the FPU Function List Name New Size Stored Size Compare New Function Code Button Bar uM FPU V3 IDE Sele File Edit Debug Functidas Tools Help GCdistance Fpu Output Debyg Functions Serial 1 0 Function List New Function 7 NMEA Degrees Name stored 0000 LEFT A Read Stored Functions 0001 STRFIELD 129 0003 STRTOL 0004 LSETO A 0005
39. The AreaIn value is displayed as 65535 because the value of Area is NaN so Arealnis returned as 1 This completes the tutorial on storing user defined functions With the information gained from this tutorial and more detailed information in the reference section you should be able to use the IDE to define your own functions and program them to Flash on the uM FPU V3 chip Micromega Corporation 27 uM FPU V3 IDE User Manual Reference Guide Menus and Dialogs Reference Guide Menus and Dialogs File Menu New Ctrl N Open Chrl O Open Recent gt Save Ctrl 5 Save As Ctrl Shift 5 Exit Ctrl O New menu item creates a new source file and sets the name to untitled If a previous source file is open and has been changed since the last time it was saved you will first be prompted to save the previous source file Open menu item opens an existing source file using the file open dialog If a previous source file is open and has been changed since the last time it was saved you will first be prompted to save the previous source file Open Recent menu item provides a sub menu that lists up to ten source files that were recently saved Selecting a source file from the sub menu will open the file If a previous source file is open and has been changed since the last time it was saved you will first be prompted to save the previous source file Save menu item saves the source file If the source file has not been previously saved
40. U Code To experiment with breakpoints add the following statement to the tutoriall bs2 program immediately after the Main label SHIFTOUT FpuOut FpuClk MSBFIRST BREAK Run the tutoriall bs2 program again A breakpoint occurs immediately after printing the version string By examining the Debug Window you can see the following e the debug trace shows the Reset message and a trace for all previously executed instructions e the debug trace shows the BREAK message in red e the version string is displayed in the string buffer e the AX beside register 0 shows that it s currently selected as register A and register X e register O is displayed in red to indicate it has a new value e the value in register O is the version code e all other registers are NaN Not a Number Single Stepping By single stepping through the FPU code you can see exactly what s happening The following example steps through a few instructions Click the Step button or type the Enter button to single step The Debug Window will change as follows e the debug trace shows the SELECTA Radius instruction and the BREAK message e the A beside register 10 shows that it s now selected as register A e register 0 is displayed in black since it hasn t changed since the last breakpoint e To experiment with breakpoints and single stepping add the following line to your program at a spot that you want a breakpoint to occur at Click the Step button or type t
41. UG CR distance Word signed word variable ENDIF signed word variable check for synchronization display the uM FPU version number arealn Word Initialize Generated Code distance Word Microcontroller variable definitions arealn Word Insert initialization code here Radius equ F10 Diameter F11 Circumference equ F12 Area equ F13 FPU register definitions Radius distance 1000 Calculations SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSET0 LOADWORD 03 SES FDIVO Diameter Radius 2 SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Diameter FSET Radius FMULI 2 Circumference PI Diameter SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Circumference LOADPI FSETO FMUL Diameter Area PI Radius Radius SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Area LOADPI FSETO FMUL Radius FMUL Radius Steps Copy generated code to microcontroller program e Compile microcontroller program Create FPU source code file Compile the FPU code Program the microcontroller Micromega Corporation SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSETO LOADWORD 03 SE8 FDIVO SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Diameter FSET Radius FMULI 2 SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Circumference LOADPI FSETO FMUL Diameter SHIFTOUT FpuOut
42. YTE lt t name READ WORD lt t name fpu readWord gt READ LONG lt t name fpu readLong gt READ FLOAT lt t name fpu readFloat gt fpu read gt REGISTER DEFINITION lt define name t register gt BYTE DEFINITION lt int name gt WORD DEFINITION lt long name gt LONG DEFINITION lt int32 name gt FLOAT DEFINITION lt float name gt PRINT FLOAT lt t print float byte t print CRLF gt PRINT LONG lt t print long byte t print CRLF gt PRINT FPUSTRING lt t print fpuString READSTR t print CRLF gt Micromega Corporation 61 uM FPU V3 IDE User Manual Reference Guide Target Description File PRINT NEWLINE lt t print CRLF gt PRINT STRING lt t printf string t print CRLF gt Syntax The general format of a command 1s as follows COMMAND lt ARGUMENT gt The name of the command is specified first followed by an equal sign and the argument surrounded by lt gt characters The following command defines the target name TARGET NAME lt Generic C compiler gt Arguments can extend over multiple lines and have replaceable parameters Parameters are special keywords surrounded by characters The following command specifies how to write a 16 bit word value to the FPU The byte parameter is replaced by the actual value when the code is generated WRITE WORD lt lda byte jsr fpu write lda byte 1 jsr fpu_write gt Tab Spacing The
43. ace on Reset option in the Functions gt Set Parameters dialog Micromega Corporation 48 uM FPU V3 IDE User Manual Reference Guide Debugger or at any time by sending the TRACEON instruction The Register Display shows the value of all registers Register values that have changed since the last update are shown in red The String Buffer displays the FPU string buffer and string selection and the Status Byte shows the FPU status byte and status bit indicators The Register Display String Buffer and Status Byte are only updated automatically at breakpoints They can be updated manually using the Read Registers button The Go Stop Step and Trace buttons at the top left control the breakpoint and trace features and the connection status is displayed at the lower left of the window Trace Buffer The scrolling window on the left of the debug window displays the debug trace output When a Reset occurs a message is displayed showing the date and time of the Reset RESET 2006 11 28 13 19 31 Tracing is turned off at Reset unless the Trace on Reset parameter has been set Tracing can be controlled by the program using the TRACEON and TRACEOFF instructions or manually with the Trace button If tracing is enabled all FPU instructions are displayed as they are executed The opcode and data bytes are displayed on the left and the FPU instructions are displayed on the right in assembler format TRACE ON 0104 SELECTA 4 5E LOADPI 29 FSETO
44. and lt linefeed gt is appended to the end of the output COMMENT_PREFIX Set the prefix for comments COMMENT_PREFIX lt string gt Default semi colon Parameters none Example COMMENT PREFIX lt gt Description This command defines the prefix characters used before a comment CONTINUATION Define line continuation for WRITE command CONTINUATION lt string gt Default empty string Parameters none Example CONTINUATION lt _ gt Description This command sets the continuation sequence used for continuing the WRITE command instructions on multiple lines If the CONTINUATION command is set to an empty string no line continuation is allowed DECIMAL_FORMAT Set the prefix for decimal numbers DECIMAL_FORMAT lt string gt Default empty string Parameters byte Example DECIMAL FORMAT lt byte gt Description This command sets the prefix character for decimal numbers Micromega Corporation 66 uM FPU V3 IDE User Manual Reference Guide Target Description File FLOAT_DEFINITION Define float variable definition FLOAT_DEFINITION lt string gt Default empty string Parameters name Example FLOAT DEFINITION lt float name gt Description This command defines the instruction sequence used to define a 32 bit floating point variable A lt carriage return gt and lt linefeed gt is appended to the end of the output HEX_FORMAT Set the prefix for hexadecimal numbers HEX_FORMAT lt string gt Defau
45. ber GetDiameter func 1 GetCircumference func gt GetArea func gt If a function prototype has been defined the t FUNCTION directive just uses pre defined name FUNCTION GetDiameter Calling Functions Functions are called by entering an ampersand before the function name or number in the source code e g GetDiameter Micromega Corporation 22 uM FPU V3 IDE User Manual Tutorial 3 Programming FPU Flash Memory Modifying the Code for Functions Open the source file called tutorial1 fpu that you saved in the first tutorial Add a function prototype for the three functions called GetDiameter GetCircumference and GetArea Add a FUNCTION directive before the diameter circumference and area calculations and add an END directive after the area calculation Move the radius calculation to after the function definitions and add a call to the three functions The source code will now look as follows distance VAR Word arealn VAR Word Radius equ F10 Diameter equ F11 Circumference equ F12 Area equ F13 GetDiameter func GetCircumference func GetArea func function GetDiameter Diameter Radius function GetCircumference Circumference PI Diameter function GetArea Area PI Radius Radius end Radius distance areaIn ROUND area 2 1000 Micromega Corporation oP dE Microcontroller variable definitions FPU register definitions Function prototypes Function 1 Function 2 Function
46. bler or ASM multiple lines of assembler SELECTA 1 LOADPI FSET ENDASM Assembler Instructions All assembler instructions start with an opcode followed by any required arguments if any separated by commas Opcode names and symbol names may be entered in uppercase or lowercase they are not case sensitive The following table summarizes the syntax for each instruction and the required arguments Please refer to the uM FPU V3 1 Instruction Set document for a more detailed description of the instructions NOP FMUL reg COS SELECTA reg FDIV reg TAN SELECTX reg FDIVR reg ASIN CLR reg FPOW reg ACOS CLRA FCMP reg ATAN CLRX FSETO ATAN2 reg CLRO FADDO DEGREES COPY reg reg FSUBO RADIANS COPYA reg FSUBRO FMOD reg COPYX reg FMULO FLOOR LOAD reg FDIVO CEIL LOADA FDIVRO ROUND LOADX FPOWO FMIN reg ALOADX FCMPO FMAX reg XSAVE reg FSETI bb FCNV bb XSAVEA FADDI bb FMAC reg reg COPY0 reg FSUBI bb FMSC reg reg COPYI bb reg FSUBRI bb LOADBYTE bb SWAP reg reg FMULI bb LOADUBYTE bb SWAPA reg FDIVI bb LOADWORD wwww LEFT FDIVRI bb LOADUWORD wwww RIGHT FPOWI bb LOADE FWRITE reg floatval FCMPI bb LOADPI FWRITEA floatval FSTATUS reg LOADCON bval FWRITEX floatval FSTATUSA FLOAT FWRITEO floatval FCMP2 reg reg FIX FREAD FNEG FIXR FREADA FABS FRAC FREADX FINV FSPLIT FREADO SORT SELECTMA reg bb bb ATOF string ROOT reg SELECTMB reg bb bb FTOA bb LOG SELECTMC reg bb bb FSET re
47. compiler converts regular math equations in the source code into the required uM FPU V3 instructions for performing the calculation Some capabilities of the uM FPU V3 chip are not accessible using the compiler or in some cases it may be possible to write more optimized code using assembler Assembler code can be entered by enclosing it with the ASM and ENDASM directives See the next section entitled Reference Guide Assembler for more details on assembler code ASM start of assembler SELECTA 1 LOADPI assembler code FSETO FDIVI 2 ENDASM end of assembler Wait Code The uM FPU V3 chip has a 256 byte instruction buffer If the instructions and data in a calculation exceed 256 bytes the buffer could overflow so the program must wait for the buffer to empty at least every 256 bytes The code generated by the IDE accounts for this and will insert a wait sequence as required Read operations automatically generate a wait sequence so in many applications no additional wait sequences are required Micromega Corporation 41 uM FPU V3 IDE User Manual Reference Guide Assembler Reference Guide Assembler Assembler code can be entered by enclosing it with the ASM and ENDASM directives Multiple instructions can be entered on a single line and an instruction can span more than one line but each element of an instruction e g a number or string must be on a single line For example ASM SELECTA 1 LOADPI FSET ENDASM single line of assem
48. defined register names Microcontroller variables are defined using the VAR operator For example the following statements define TOTAL as a floating point value in register 1 and COUNT as a byte variable on the microcontroller TOTAL EQU Fl COUNT VAR BYTE The following statement would generate code to read the value of COUNT from the microcontroller convert it to floating point and add it to the TOTAL register TOTAL TOTAL COUNT Sample Project Suppose we have a distance measuring device that returns a number of pulses proportional to distance It measures distance from 0 to 30 inches and returns 1000 pulses per inch We intend to use this device to measure the radius of a circle then calculate the diameter circumference and area using the FPU The results are displayed in units of inches to three decimal places Calculating Radius The number of pulses returned by the distance measuring device ranges from 0 to 30000 30 inches x 1000 pulses per inch so we will need to use a word variable to store the value on the microcontroller Since results will be displayed in inches wel divide the distance value by 1000 once it s loaded to the FPU chip Create a new source file using the File gt New menu item and enter the following code distance VAR word Radius EQU F10 Radius distance 1000 The Source window should look as follows CT uM FPU V3 IDE File Edit Debug Functions Tools Help untitled Output Debug Fu
49. defines the instruction sequence used to output a 16 bit value A lt carriage return gt and lt linefeed gt is appended to the end of the output WRITE WORD FORMAT Define 16 bit value format for WRITE command WRITE WORDz c lt string gt Default empty string Parameters byte word Examples WRITE WORD lt word 16 gt WRITE WORD lt byte lt lt 8 byte gt Description This command defines the syntax for writing a 16 bit value using the WRITE command WRITE_STRING Define instructions to write string value WRITE_STRING lt string gt Default empty string Parameters none Example WRITE STRING lt call fpu_writeString string gt Description This command defines the instruction sequence used to output a zero terminated string value A lt carriage return gt and lt linefeed gt is appended to the end of the output WRITE_STRING_FORMAT Define write string format for WRITE command Micromega Corporation 74 uM FPU V3 IDE User Manual Reference Guide Target Description File WRITE_STRING lt string gt Default empty string Parameters none Example WRITE STRING lt string gt Description This command defines the syntax for writing a a zero terminated string using the WRITE command Micromega Corporation 75 uM FPU V3 IDE User Manual
50. e defined using the VAR or EQU operator and one of the following keywords BYTE 8 bit signed integer value UBYTE 8 bit unsigned integer value WORD 16 bit signed integer value UWORD 16 bit unsigned integer value LONG 32 bit signed integer value ULONG 32 bit unsigned integer value FLOAT 32 bit floating point value count EQU BYTE sensorInput EQU UWORD lastAngle EQU FLOAT When microcontroller variables are used in expressions the IDE generates the necessary code to transfer the value between the microcontroller and the FPU For example the following input would generate code to load degreesC from the microcontroller convert it to floating point multiply it by 1 8 then add 32 degreesC EQU BYTE degreesF EQU F10 degreesF degreesC 9 5 32 Special syntax for PICAXE When writing code for the PICAXE variable definitions must include the PICAXE register used for the variable degreesC EOU BYTE b3 degreesF EOU UWORD w0 Math Operators The following math operators can be used for Float Long and Unsigned data types Plus Micromega Corporation 38 uM FPU V3 IDE User Manual Reference Guide Compiler Minus Multiply Divide 55751702 Math Functions The following math functions are provided Each of the functions uses an FPU instruction of the same name ABS MOD MIN and MAX use the FABS FMOD FMIN FMAX instructions for floating point data types and the LABS LDIV remainder LMIN LMAX instructions for Long or Un
51. ed to the end of the output READ WORD Defines instructions to read 16 bit value READ_WORD lt string gt Default empty string Parameters none Example READ WORD lt name fpu readWord gt Description This command defines the instruction seguence to use to read a 16 bit value A lt carriage return gt and lt linefeed gt 1s appended to the end of the output REGISTER DEFINITION Define register definition REGISTER DEFINITION lt sfring gt Default empty string Parameters name register Example REGISTER DEFINITION lt define name register gt Description This command defines the instruction sequence used to define a register constant A lt carriage return gt and lt linefeed gt is appended to the end of the output RESERVED_PREFIX Define prefix for reserved words RESERVED_PREFIX lt string gt Default H F and underscore Parameters none Example RESERVED PREFIX lt FPU gt Description This command defines the prefix to add to reserved words in order to make them unique RESERVED_WORD Define reserved word RESERVED_WORD lt string gt Default empty string Parameters none Example RESERVED WORD lt SIN gt Description This command defines a reserved word Multiple RESERVED_WORD commands can be used with each command specifying one reserved word Micromega Corporation 70 uM FPU V3 IDE User Manual Reference Guide Target Description File SEPARATOR Define separator character for W
52. eing sent to the SEROUT pin at Reset If the Call Function option is selected the specified function will be called at Reset These options are only checked if the CS pin is Low at Reset If both the CS pin and SERIN pin are High at Reset the auto start function is not called and Debug Mode will always be entered This provides a way to override the auto start mode once it is set To use auto start with an I C interface the interface mode bits must be set to PC as described above It s recommended that the interface be set to SPI or PC using the interface bits whenever auto start mode is used so that the CS pin can be used to enable or disable the auto start mode Restore Default Settings This button restores the parameters to the following default settings Break on Reset not enabled Trace on Reset not enabled Enable Busy Ready Status on OUT1 not enabled Use PIC format IEEE 754 is default not enabled Idle Mode Power Saving enabled No Sleep Mode Power Saving not enabled Interface Mode CS pin selects interface default lC address C8 Auto Start Mode gt Disable Debug not enabled Auto Start Mode gt Call Function not enabled Micromega Corporation 60 uM FPU V3 IDE User Manual Reference Guide Target Description File Reference Guide Target Description File Target description files are used to customize the compiler output for a specific microcontroller development language The IDE supports a wide range of microcontrollers
53. em brings up the Find Dialog Find hat Replace With Replace Search Conditions From top From cursor Match case Replace Next Replace Al Close The Find dialog is a moveable dialog and can be placed alongside the Source Window and left open when multiple find and replace operations are done The Find What field specified the string to search for and the Replace With field specifies the string to replace it with If the From top search condition is selected the search starts from the top of the window The search condition will automatically change to From cursor on the first successful match If the From cursor search conditions is selected the search starts from the current cursor position When the Match case option is selected the search is case sensitive The following special characters can be used in the Find or Replace strings Nt for a tab character Xx for end of line and XN for backslash The Find Next button searches the Source Window for the next match The Replace button replaces the matched string The matching text is highlighted on the first button press and replaced by the Replace With string on the next button press The Replace All button replaces all occurrences of the Find What string with the Replace With string The Close button closes the Find dialog Find Next menu item finds the next match based on the current search conditions in the Find dialog Replace menu item brings up the F
54. et Trace on Reset If this option is selected debug tracing is turned on at Reset Use PIC Format IEEE 754 is default If this option is selected the PIC format will be used for reading and writing floating point values The uM FPU V3 chip uses floating point values that conform to the IEEE 754 32 bit floating point standard This is also the default format for reading and writing floating point values in FPU instructions An alternate PIC format is often used by PICmicro compilers If this option is selected floating point values are automatically translated between the PIC format and the IEEE 754 format whenever values are read from the FPU or written to the FPU and the microcontroller program can use the PIC format The IEEEMODE and PICMODE instructions can also be used to dynamically change the format For additional information regarding the IEEEMODE and PICMODE instructions see the uM FPU V3 Instruction Reference Micromega Corporation 59 uM FPU V3 IDE User Manual Reference Guide Setting uM FPU V3 Parameters Note The IDE code generator currently only generates code for the default IEEE 754 format If the PIC format is used you will need to fix the data values in the code generated for FWRITE FWRITEA FWRITEX and FWRITEO instructions Idle Mode Power Saving Enable If this option is selected the uM FPU V3 chip will go into a low power mode when idle Sleep Mode Power Saving Enabled If this option is selected the uM FPU V3 chip
55. firm with User 000E READVAR 15 O Never 0010 STRSEL 126 7 0013 STRTOF 0014 FSETO 0015 FDIVI 60 NNI DICHT CH Stored Function 7 lt read from FPU gt LEFT SIRFIELD 129 STRTOL LSETO LDIVI 100 FLOAT LEFT STRFIND 7 7 STRDEC STRDEC READVAR 15 STRSEL 126 7 STRTOF FSETO FDIVI 60 RTGHT COM4 57600 8 N 1 Compiled successfully for BASIC Stamp SPI Connection Status Status Message Stored Function Code The Function List provides information about each function defined by the compiler and stored on the FPU The Name column in the Function List displays the name of all functions defined in the source file The New column shows the size in bytes of the functions defined in the source file and the Stored column displays the size in bytes of functions currently stored on the FPU if the functions have been read The column displays Yes if the new and stored functions are the same or No if they are different Micromega Corporation 57 uM FPU V3 IDE User Manual Reference Guide Programming Flash Memory The New Function Code displays the FPU instructions for compiled functions and the Stored Function Code displays the FPU instructions for functions stored on the FPU The function to be displayed is selected by selecting one of the functions in the Function List The Read Stored Functions button is used to read the functions currently stored on the FPU and update the Function List The Program F
56. g LOG10 LOADMA bb bb FADD reg EXP LOADMB bb bb FSUB reg EXP10 LOADMC bb bb FSUBR reg SIN MOP bb Micromega Corporation 42 uM FPU V3 IDE User Manual Reference Guide Assembler LOADIND reg LSUBO ADCSCALE bb SAVEIND reg LMULO ADCLONG bb INDA reg LDIVO ADCLOAD bb INDX reg LCMPO ADCWAIT FCALL fnum LUDIVO TIMESET EECALL fnum LUCMPO TIMELONG RET LTSTO TICKLONG BRA label LSETI bb EESAVE reg bb BRA cc _label LADDI bb EESAVEA bb JMP label LSUBI bb ELOAD reg bb JMP cc _label LMULI bb ELOADA bb TABLE bb LDIVI bb EEWRITE bb FTABLE bb LCMPI bb EXTSET LTABLE bb LUDIVI bb EXTLONG POLY bb LUCMPI bb EXTWALT GOTO reg LTSTI bb STRSET string LWRITE reg longval LSTATUS reg STRSEL bb bb LWRITEA longval LSTATUSA STRINS string LWRITEX longval LCMP2 reg reg STRCMP string LWRITEO longval LUCMP2 reg reg STRFIND string LREAD LNEG STRFCHR string LREADA LABS STRFIELD bb LREADX LINC reg STRTOF LREADO LDEC reg STRTOL LREADBYTE LNOT READSEL LREADWORD LAND reg SYNC ATOL string LOR reg READSTATUS LTOA bb LXOR reg READSTR LSET reg LSHIFT reg VERSION LADD reg LMIN reg IEEEMODE LSUB reg LMAX reg PICMODE LMUL reg LONGBYTE bb CHECKSUM LDIV reg LONGUBYTE bb BREAK LCMP reg LONGWORD wwww TRACEOFF LUDIV reg LONGUWORD wwww TRACEON LUCMP reg LONGCON bb TRACESTR string LTST reg SETOUT bb TRACEREG reg LSETO ADCMODE bb READVAR bb LADDO ADCTRIG RESET Where reg re
57. gister number 0 127 fnum Flash function number 0 63 bb 8 bit value WWWW 16 bit value label address label cc condition code Z EQ NZ NE LT LE GT GE PZ MZ INF FIN PINF MINF NAN TRUE FALSE floatval floating point value longval long integer value string ASCII string Assembler Directives The following directives can be used to define byte word long and float values BYTE bb WORD wwww LONG longval 8 bit byte value 16 bit word value long integer value FLOAT floatval floating point value Micromega Corporation 43 uM FPU V3 IDE User Manual Reference Guide Assembler POLY 3 POLY instruction with coefficients 0 0000028 0 0405 4 0 float 2 8E 6 float 0 0405 float 4 0 The following directives generate code to print to a terminal window e g the built in terminal window of the target microcontroller IDE The commands used for output are defined in the target description file PRINT FLOAT format print floating point value if no format specified 0 is assumed PRINT LONG format print integer value if no format specified 0 is assumed PRINT FPUSTRING print FPU string PRINT STRING string print string constant PRINT NEWLINE print new line e g carriage return linefeed Symbol Definitions AIl symbols that have been defined by the compiler can be used by the assembler code angle EQU F10 symbol definition asm SELECTA angle symbol used by assembler instruction endasm Branch and Return Instruc
58. haracter Symbol names can be defined for FPU registers constants microcontroller variables and functions They are not case sensitive Here are some examples getDistance latitudel NMEA Degrees Micromega Corporation 36 uM FPU V3 IDE User Manual Reference Guide Compiler Register Data Types The 32 bit FPU registers can be defined for Float Long or Unsigned data types Float 32 bit IEEE 754 format Long 32 bit signed integer Unsigned 32 bit unsigned integer Pre defined Register Names The uM FPU V3 chip has 128 FPU registers The following register names are pre defined FO F1 F2 F127 specifies that register 0 to 127 contains a Float data type LO L1 L2 L127 specifies that register 0 to 127 contains a Long data type U0 U1 U2 U127 specifies that register 0 to 127 contains an Unsigned data type User defined Register Names User defined names can be assigned to registers with the EQU operator The user defined register name on the left of the EQU operator is set to the value of the pre defined register name on the right For example reg0 EOU FO tmp1 EQU Fl Y EQU F10 X EQU F11 Radius EQU F12 shoulderPulseRate EQU L13 Decimal Constants Decimal constants are represented as a sequence of decimal digits without commas spaces or periods with optional or prefix 120 53 100000 207 Hexadecimal Constants Hexadecimal constants must have a Ox or prefix and are represented as a sequence of hexadecimal digits wit
59. he Enter button to single step The Debug Window will change as follows e the debug trace shows the LOADWORD 2575 instruction and the BREAK message e the A beside register 10 shows that it s now selected as register A e register 0 is displayed in red since it has a new value e the value in register 0 is 2575 0 Click the Step button or type the Enter button to single step The Debug Window will change as follows e the debug trace shows the FSETO instruction and the BREAK message e register 0 is displayed in black since it hasn t changed since the last breakpoint e register 10 is displayed in red since it has a new value e the value in register 10 is 2575 0 To continue normal execution click the Go button You can experiment further by moving the BREAK instruction to another point in your program or by adding multiple breakpoints More advanced single step capabilities are available using the Auto Step button See the section entitled Reference Guide Debugging uM FPU V3 Code for more information This completes the tutorial on debugging uM FPU V3 code With the information gained from this tutorial and more detailed information from the reference section you should now be able to use the IDE to debug your own programs Micromega Corporation 21 uM FPU V3 IDE User Manual Tutorial 3 Programming FPU Flash Memory Tutorial 3 Programming FPU Flash Memory User defined functions and parameter bytes can be programmed in Flash memo
60. hout commas spaces or periods The hexadecimal digits and prefix can be upper or lower case 55 OxFF SFFFF 0x13 Floating Point Constants Floating point constants consist of an optional or prefix decimal integer decimal point decimal fraction e or E and a signed integer exponent Only the decimal integer is required the other fields are optional If the e or E is used an integer exponent must follow 1 0 53 1E6 1 5e 3 Pre defined Constants PI constant value for pi 3 1415926 E constant value for e 2 7182818 User defined Constants User defined constants can be defined with the CON or EOU operator The user defined constant on the left of the CON or EOU operator is set to the value of the constant expression on the right The compiler simplifies constant Micromega Corporation 37 uM FPU V3 IDE User Manual Reference Guide Compiler expressions to a single constant value For example e g Length CON 4 75 Pi2 CON PI 2 or Length EQU 4 75 Pi2 EQU PI 2 String Constants A string constant is enclosed in double quote characters Special characters can be entered using a backslash followed by two hexadecimal digits The backslash and double quote characters can be entered by preceding them with a backslash String Constant Actual String sample sample string2 0D 0A string2 lt carriage return gt lt linefeed gt EE 5 3 this one this one Microcontroller Variables Microcontroller variables ar
61. ind Dialog Micromega Corporation 29 uM FPU V3 IDE User Manual Reference Guide Menus and Dialogs Debug Menu Select Port Stop Go F6 Step F7 Auto Step FS Auto Step Conditions Ctrl F8 Turn Trace On Ctrl T Read Registers Read Version Read Checksum Select Port menu item is used to display the Port Setup dialog which is used to select the serial communications port Port Setup Serial Port COM3 Baud Rate Data Bits Parity Stop Bits Cancel Go Stop and Step menu items have the same function as the Go Stop and Step buttons in the Debug Window Turn Trace On and Turn Trace Off menu items have the same function as the Trace button in the Debug Window Auto Step Conditions menu item brings up the Auto Step Conditions dialog See the section entitled Reference Guide Auto Step and Conditional Breakpoints for more details Auto Step menu item continues execution in auto step mode See the section entitled Reference Guide Auto Step and Conditional Breakpoints for more details Read Registers menu item has the same function as the Read Registers button in the Debug Window Read Version menu item will display the version of the FPU in the Debug Trace Read Checksum menu item will display the checksum of the FPU in the Debug Trace Micromega Corporation 30 uM FPU V3 IDE User Manual Reference Guide Menus and Dialogs Functions Menu Functions Select Port Read Stored Functions Program Fu
62. ing the FLOAT or LONG directives TABLE 4 load value from table FLOAT 10 0 FLOAT 20 0 FLOAT 50 0 FLOAT 100 0 POLY 3 POLY instruction with coefficients 0 0000028 0 0405 4 0 float 2 8E 6 float 0 0405 float 4 0 MOP Instruction The IDE doesn t provide high level support for matrix operations they must be specified using assembler There are predefined symbols for the matrix operations that can be used with the MOP instruction For example the following instructions initialize all elements of a 2x2 matrix to 1 0 asm SELECTMA 10 2 2 LOADBYTE 1 MOP SCALAR SET endasm A list of the predefined symbols for matrix operations are as follows 0 SCALAR SET St SUM 1 SCALAR ADD 22 AVE 2 SCALAR SUB 23 MIN 3 SCALAR SUBR 24 MAX 4 SCALAR MUL 25 COPYAB 5 SCALAR DIV 26 COPYAC 6 SCALAR DIVR 27 COPYBA 7 SCALAR POW 28 COPYBC 8 EWISE SET 29 COPYCA 9 EWISE ADD 30 COPYCB 10 EWISE SUB 31 DETERM 11 EWISE SUBR 32 INVERSE 12 EWISE MUL 33 ILOADRA 13 EWISE DIV 34 ILOADRB 14 EWISE DIVR 35 ILOADRC 15 EWISE POW 36 ILOADBA 16 MULTIPLY 37 ILOADCA 17 IDENTITY 38 ISAVEAR 18 DIAGONAL 39 ISAVEAB 19 TRANSPOSE 40 ISAVEAC 20 COUNT Micromega Corporation 47 uM FPU V3 IDE User Manual Reference Guide Debugger Reference Guide Debugger Utilizing the built in debug monitor on the uM FPU V3 chip the IDE provides a high level interface for debugging programs that use the uM FPU V3 floating point coprocessor It suppor
63. ion sequence used to output an 8 bit value A lt carriage return gt and lt linefeed gt is appended to the end of the output WRITE_BYTE_FORMAT Define 8 bit value format for WRITE command WRITE_BYTE_FORMAT lt string gt Default empty string Parameters byte Example WRITE BYTE FORMAT lt byte gt Description This command defines the syntax for writing an 8 bit value using the WRITE command WRITE_LONG Define instructions to write 32 bit value WRITE_LONG lt string gt Default empty string Parameters none Example WRITE LONG lt call fpu writelong long gt Micromega Corporation 73 uM FPU V3 IDE User Manual Reference Guide Target Description File Description This command defines the instruction sequence used to output a 32 bit value A lt carriage return gt and lt linefeed gt is appended to the end of the output WRITE LONG FORMAT Define 32 bit value format for WRITE command WRITE LONG lt stfring gt Default empty string Parameters none Examples WRITE LONG lt byte lt lt 24 byte lt lt 16 byte lt lt 8 byte gt WRITE LONG lt word 1 word 2 gt WRITE LONG lt long gt Description This command defines the syntax for writing a 32 bit value using the WRITE command WRITE WORD Define instructions to write 16 bit value WRITE_WORD lt string gt Default empty string Parameters none Example WRITE WORD lt call fpu writeWord word gt Description This command
64. is can sometimes occur immediately before a Reset if the reset interrupts a trace operation in progress This situation can be ignored If it occurs at other times it indicates a problem with the serial communications The trace in the Serial I O window can Micromega Corporation 50 uM FPU V3 IDE User Manual Reference Guide Debugger be reviewed and may help determine the source of the problem lt trace suppressed gt In certain circumstances the FPU is capable of sending data faster than the PC can handle it If this occurs the trace suppressed message is displayed and the IDE attempts to recover by suppressing data resynchronizing and continuing This situation should not normally occur but can occur if excessive amounts of trace data are being produced such as tracing a user defined function that is looping To avoid this situation the TRACEOFF and TRACEON instructions can be used to selectively disable tracing lt trace limit xx gt The IDE will retain up to 100 000 characters in the Debug Trace This is normally more than sufficient for tracing and debugging The Debug Trace buffer can be cleared with the Clear button If the buffer is exceeded the first portion will be deleted and the trace limit message displayed in its place The trace limit messages are numbered sequentially This message does not necessarily indicate an error unless it occurs in conjunction with one of the messages described above Micromega Corporation 51
65. l F2 Notice that the status line at the bottom of the window now reads Input modified since last compile This lets you know that you must compile to generate up to date output code Click the Compile button If the compile is successful the Output Window will be displayed and the status message will be Compiled successfully for BASIC Stamp SPI If an error is detected an error message will be displayed in red If you get an error message check that your input matches the Source Window above then click the Compile button again The Output Window should look as follows wu EDU V3 IDE File Edit Debug Functions Tools Help untitled Output Debug Functions Serial I O Fl Fl F2 SHIFTOUT Fpudut FpuClk MSBFIRST SELECTA 1 FADD 2 The expression F1 F1 F2 has been translated into BASIC Stamp code The code selects FPU register 1 as register A then adds the value of register 2 to register A You ve successfully compiled your first compile If you want to see the code generated for a different target go back to the Source Window and select a different target from the Target Menu Micromega Corporation 11 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code Defining Names Math expressions can be easier to read when meaningful names are used The IDE allows you to define names for FPU registers microcontroller variables and constants Registers are defined using the EQU operator and one of the pre
66. lt dollar sign Parameters byte Example HEX FORMAT lt 0x byte gt Description This command sets the prefix character for hexadecimal numbers LONG_DEFINITION Define long variable definition LONG_DEFINITION lt string gt Default empty string Parameters none Example LONG DEFINITION lt long name gt Description This command defines the instruction sequence used to define a 32 bit integer variable A lt carriage return gt and lt linefeed gt is appended to the end of the output MAX_LENGTH Set maximum length of write instruction MAX_LENGTH lt length gt Default 80 Parameters none Example MAX LENGTH lt 90 gt Description This command defines the maximum length of a source line MAX_WRITE Set maximum number of bytes in write instruction MAX_WRITE lt n gt Default 1 Parameters none Example MAX WRITE lt 8 gt Description This command defines the maximum number of bytes in a write command Micromega Corporation 67 uM FPU V3 IDE User Manual Reference Guide Target Description File OPCODE_PREFIX Set the prefix for opcodes in WRITE command OPCODE_PREFIX lt string gt Default empty string Parameters none Example OPCODE PREFIX lt FPU gt Description This command sets the prefix for opcodes used in write_command It can be used in conjunction with a symbol definition file to ensure unique names for the opcode constants PRINT_FLOAT Define instructions to print float value PRI
67. memory map the 32 bit value of the selected slot is displayed in the upper right field in floating point long integer unsigned integer and hexadecimal format If the slot is also identified as part of a user defined function the disassembled code for the function is displayed in the lower right field Clear Flash Memory menu item will clear all of the user defined functions from Flash memory on the uM FPU V3 chip A dialog will be displayed requesting confirmation before the functions are cleared from memory Set Parameters menu item is used to set the FPU parameter bytes See the section entitled Reference Guide Setting uM FPU V3 Parameters for more details Tools Menu Tools Show Main Window Show Number Converter Set Clock Speed Show Main Window menu item is used to bring the main IDE window to the front Show Number Converter menu item is used to bring the Number Converter window to the front The number converter provides a quick way to convert numbers between various 32 bit formats Floating point decimal and hexadecimal numbers are supported The Auto Float Decimal and Hexadecimal buttons above the Input field determine how the input is interpreted If Auto is selected the input type is determined automatically based on the characters entered in the Input field The input type is displayed to the right of the Input field The input type can be manually set using the Float Decimal and Hexadecimal buttons Invalid charac
68. nctions Show Flash Memory Show EEPROM Memory Clear Flash Memory Set Parameters Select Port menu item is used to display the Port Setup dialog which is used to select the serial communications port Port Setup Serial Port COM3 Baud Rate Data Bits Parity Stop Bits Read Stored Functions menu item has the same function as the Read Stored Functions button It reads the flash memory and updates the function list in the Function Window Program Functions menu item has the same function as the Program Functions button It programs the user defined functions to the FPU chip Show Flash Memory menu item displays a memory map showing the usage of the Flash memory reserved for user defined functions on the uM FPU V3 chip A status line at the top shows the percent of memory used and the number of bytes available Micromega Corporation 31 uM FPU V3 IDE User Manual Flash Memory Map Reference Guide Menus and Dialogs Flash Memory 16 used 1712 bytes available 4 of 64 defined dal Sei s le EECH ECO BA EES E Memory Map Legend LJ Function Header Unused Header EN Parameter Data Function Code Unused Show EEPROM Memory menu item displays the EEPROM Memory Map dialog wii EEPROM Memory Map EEPROM memory 256 address slots 1024 bytes Slot F FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FEFFFFFF C6 FFFFFFFF FFFFFFFF FFFFFFFF FFFFF
69. nctions Serial I O Target BASIC Stamp SPI vi Save the source file using the File gt Save menu item Save the file as tutorial1 with fpu extension added automatically Micromega Corporation 12 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code Click the Compile button The Output Window should look as follows Cl uM FPU V3 IDE File Edit Debug Functions Tools Help tutoriali fpu Output Debug Functions Serial UO uM FPU Register Definitions Radius CON 10 uM FPU register ee Variable Definitions distance VAR Word signed word variable lk a a la ak sg eb i Generated Code distance VAR Word Radius equ F10 Radius distance 1000 SHIFTOUT Fpudut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSETO LOADWORD 03 SES FDIVO The generated code does the following SELECTA Radius select the Radius register as register A LOADWORD distance HIGHBYTE distance LOWBYTE FSETO load the 16 bit distance variable to the FPU convert it to floating point and store in Radius register LOADWORD 03 E8 FDIVO load the constant 1000 hexadecimal value 03 E8 convert it to floating point and divide the Radius register by that value Copying Code to your Main Program In this example we are using the BASIC Stamp as the target so open the BASIC Stamp Editor and open the template file umfpu spi bs2 Save a new copy called tutorial1 bs
70. nel The register panel displays the value of each register and indicates the register currently selected as register A and register X Register A and register X are indicated by an A and X marker in the left margin of the register panel The temporary registers are displayed at the bottom on the register panel For each register the register number optional register name hexadecimal value and formatted value is displayed If you click on the formatted value a pop up menu is displayed with the register value displayed in floating point long integer and unsigned long integer format If you select a different format the display will be updated to show that format Registers Read Registers X RO 40490FDB 3 141593 al SORE EERE EE EERE EEE EERE EERE EERE EE EEE EEE EERE EE EEE EEE EE EEE EERE EE EEE EEE EEE EEE EEE EEE EEE EEE EERE EE EE EEE EEE EE EEE EERE EEE EEE EEE EE EEE EEE EEE EEE EEE EE EEE EES CORRE EERE EERE EERE EERE EERE EERE EEE EEE EERE EEE EEE EERE EERE EEE EERE EERE EEE EEE EEE EEE EEE EEE EERE EE EEE EERE EE EEE EEE E ESET EEE EEE EE Eee EEE EEE EEE TT SORE EERE EERE EEE EERE EERE EERE EERE EERE EEE EEE EERE EEE EEE EEE EEE EERE EE EEE EERE EEE TEETER EEE EE EE EEE EE EEE EEE EEE TEESE EEE EE EEE EEE EEE EEE EEE EEE EEE EEE EEE EE EE EE EEE EEE eee EEE EEE Eee eee eee e eee ERE E EERE EERE EEE EERE EERE EERE EERE EERE EERE EEE EEE REESE EERE EERE EERE EEE EERE EERE EERE EEE EEE EERE EEE EERE EERE EEE EERE EERE EEE LETTE EEE E E
71. nt float angle print CRLF Reserved Words The IDE code generator uses symbolic values for the FPU opcodes Some microcontroller languages may need a prefix for the opcodes or some FPU opcodes may conflict with reserved names in the microcontroller language For example an object oriented language like Java requires a module prefix for all constants The OPCODE PREFIX command can be used to add a prefix to all opcodes OPCODE PREFIX lt Fpu gt An example of the opcodes generated is as follows Fpu SELECTA FPU FADD Other languages may have only a few reserved words that conflict with the FPU opcodes The RESERVED_WORD command is used to identify these words and the RESERVED_PREFIX command defines a prefix to make them unique The following example adds an F_ prefix to three reserved words the other opcodes would be unaffected RESERVED PREFIX lt F gt RESERVED WORD lt SIN gt RESERVED WORD lt COS gt RESERVED WORD lt TAN gt An example of the opcodes generated 1s as follows SELECTA FADD F SIN F COS Micromega Corporation 65 uM FPU V3 IDE User Manual Reference Guide Target Description File Target Description Commands BYTE_DEFINITION Define byte variable definition BYTE_DEFINITION lt string gt Default empty string Parameters byte Example BYTE DEFINITION lt char name gt Description This command defines the instruction sequence used to define an 8 bit integer variable A lt carriage return gt
72. on file It defines the name that will appear in the target menu WAIT Define instructions to wait for ready status WAIT lt string gt Default empty string Parameters none Example WAIT lt call fpu wait gt Description This command defines the instruction seguence used to wait for the FPU ready status A lt carriage return gt and lt linefeed gt is appended to the end of the output Micromega Corporation 72 uM FPU V3 IDE User Manual Reference Guide Target Description File WORD DEFINITION Define word variable definition WORD_DEFINITION lt string gt Default empty string Parameters name Example WORD DEFINITION lt int name gt Description This command defines the instruction sequence used to define a 16 bit integer variable A lt carriage return gt and lt linefeed gt is appended to the end of the output WRITE Define instructions to write bytes WRITE lt string gt Default empty string Parameters byte Example WRITE lt call fpu write byte gt Description This command defines the instruction sequence used to write bytes to the FPU and is required for all implementations A lt carriage return gt and lt linefeed gt is appended to the end of the output WRITE_BYTE Define instructions to write 8 bit value WRITE_BYTE lt string gt Default empty string Parameters none Example WRITE BYTE lt call fpu write byte gt Description This command defines the instruct
73. ons are being programmed If an error occurs check the connection You may need to Micromega Corporation 24 uM FPU V3 IDE User Manual Tutorial 3 Programming FPU Flash Memory power the uM FPU V3 chip off and then back on to ensure that it has been reset properly before trying again Running the Program Copy the generated code from the Output Window to the BASIC Stamp program replacing the diameter circumference and area calculations with function calls Remember to also copy the UM FPU Function definitions The main routine in your BASIC Stamp program should now look as follows EE uM FPU Register Definitions Radius CON 1 uM FPU register 1 Diameter CON 2 uM FPU register 2 Circumference CON 3 uM FPU register 3 Area CON 4 uM FPU register A uM FPU Function Definitions GetDiameter CON 1 uM FPU user function 1 GetCircumference CON 2 uM FPU user function 2 GetArea CON 3 uM FPU user function 3 oooooooooooooo Variable Definitions distance VAR Word signed word variable arealn VAR Word signed word variable EE initialization Main distance 2575 Radius distance 1000 SHIFTOUT FpuOut FpuClk MSBFIRST SELECTA Radius LOADWORD distance HIGHBYTE distance LOWBYTE FSET0 LOADWORD 03 SES FDIVO DEBUG CR Radius format 63 GOSUB Print_FloatFormat
74. or end of read or write transfer STOP lt string gt Default empty string Parameters none Micromega Corporation 71 uM FPU V3 IDE User Manual Reference Guide Target Description File Example STOP lt CALL STOP gt Description This command defines the instruction sequence used to end a read or write transfer Some implementations will not require this command A lt carriage return gt and lt linefeed gt character is appended to the end of the output STRING_HEX_FORMAT Define format for non printable string characters STRING_HEX_FORMAT lt string gt Default empty string Parameters none Example STRING HEX FORMAT lt byte gt Description This command defines the syntax for writing a non printable character using write_command TAB_SPACING Set number of characters per tab TAB_SPACING lt n gt Default 4 Parameters none Example TAB SPACING lt 8 gt Description This command sets the number of characters in a tab The absolute value of n specifies the number of characters If n is positive only spaces are used to move to the next tab position If n is negative then horizontal tabs 0x09 and spaces are used to move to the next tab position TARGET_NAME Define the target name TARGET NAME lt rarget name gt Default none Parameters none Example TARGET NAME lt C compiler gt Description This command must be on the first line of the file in order for the file to be recognized as a target descripti
75. ry on the uM FPU V3 chip This tutorial takes you through an example of creating some user defined functions Making the Connection For programming Flash memory the uM FPU V3 IDE must have a serial connection to the uM FPU V3 chip Refer to the section at the start of this document called Connecting to the uM FPU V3 chip Defining functions In the previous tutorials we developed and tested code to calculate the diameter circumference and area of a circle For this demonstration we H define each of these calculations as a separate function The FUNCTION directive is used to define a function It specifies the number of the function 0 to 63 and an optional name FUNCTION 1 GetDiameter All code that appears after a FUNCTION directive will be stored in that function until the next FUNCTION directive an END directive or the end of the source file There s an implicit RET instruction at the end of all functions Functions can call other functions To ensure that the function being called is already defined function prototypes can be included at the start of the program Function prototypes are defined using the FUNC operator which assigns a symbol name to a function number We ll use function prototypes in this tutorial example The following function prototype defines GetDiameter as function number 1 GetDiameter func 1 You can assign the function number explicitly or use the character to assign the next unused function num
76. s WAIT lt t fpu_wait gt The commands for reading data values are shown below READ BYTE lt t name fpu read gt READ WORD lt t name fpu readWord gt READ LONG lt t name fpu readLong gt READ FLOAT lt t name fpu readFloat gt An example of the output generated by these commands is as follows tmp fpu read cnt fpu readWord sum fpu readLong angle fpu readFloat The following command specifies how registers are defined REGISTER DEFINITION lt define name t register gt An example of register definitions is as follows define angle 10 define latl 11 Next are the commands to define microcontroller variable BYTE DEFINITION lt int name gt WORD DEFINITION lt long name gt LONG DEFINITION lt int32 name gt FLOAT DEFINITION lt float name j gt An example of the output generated by these commands is as follows int cnt long sum float angle Finally the commands to define print statement PRINT FLOAT lt t print_float byte t print CRLF gt Micromega Corporation 64 uM FPU V3 IDE User Manual Reference Guide Target Description File PRINT LONG lt t print long byte t print CRLF gt PRINT FPUSTRING lt t print fpuString READSTR t print CRLF gt PRINT NEWLINE lt t print CRLF gt PRINT STRING lt t printf string t print CRLF gt An example of the output generated by these commands is as follows pri
77. s for length require a decimal number to be entered in the field on the right The comparisons for selection length require two decimal numbers separated by a comma to be entered in the field on the right Micromega Corporation 56 uM FPU V3 IDE User Manual Reference Guide Programming Flash Memory Reference Guide Programming Flash Memory The Function window provides support for storing user defined functions on the uM FPU V3 chip Stored functions can reduce memory usage on the microcontroller simplify the interface and often increase the speed of operation The uM FPU V3 reserves 2048 bytes of flash memory for user defined functions and parameters plus 256 bytes for the header information Functions are stored as a string of FPU instructions and up to 64 functions can be defined Functions are specified in the source file by using the FUNCTION directive See the section entitled Reference Guide Generating uM F PU V3 Code for more details Function Window Function List Name New Size Stored Size Compare New Function Code Button Bar uM FPU V3 IDE AEJ File Edit Debug Functisos Tools Help GCdistdnce fpu Output Debyg Functions Serial I O Functidn List New Function 7 NMEA Degrees Name stored 0000 LEFT A Read Stored Functions 0001 STRFIELD 129 0003 STRTOL 0004 LSETO e 0005 LDIV I 100 Program Functions 0007 FLOAT 0008 LEFT Overwrite Stored Functions 0009 STRFIND Dana 000C STRDEC 000D STRDEC Con
78. sa aiad aaa he cee eat alaalia ia an 36 Beil TR EE 36 Micromega Corporation 2 uM FPU V3 IDE User Manual Installing and Connecting Selen 36 Register Data RU 37 Bee ri Ee 2 219 1451600 E let 37 Veer demmed Register NANNES ceisir e a a alale t lkis k 37 Decimal CSASTANIS EE 37 Hexadecimal e ele LE CC 37 Floating Point CONSTANTS serari iag n isik EE EE aE E E 37 Pre delned ConStanlS EEN 37 BI dreien CN 37 Sekt ee E 38 Microcontroller Ela 38 le Wiere eee TEN cee eee eet ee eee eee ee ee ee eee 38 Man Zi ieren Tele LEE 39 User Defined FUNCTIONS EEN 39 alale lein Side 014 ie 40 Global gle e VS Bee E nalja AAA 40 Assembler C OGG EE 41 eliT gr ele uu i ua eee one acne 41 Reference Guide Assembler 105 isata Eeer Ee Eh 42 Assembler IST ee a E 42 Assembler BI 43 101810 CS giele p E A AMAAN 44 Branch and Return Instructions 44 COnditon ee 44 EADSIS 00001000 500000 10008 dla 26 a as E 45 Using Branch Instructions and NET EE 45 Foe eae aa aw ects r aaa ul tali a ences 45 Renea EE EE 45 PO aia loal EE 46 dee 46 PADIG Ale Gg d Tei e EEN 47 MOP Te Erd ed e EE 47 Reference Guide NET e e E 48 WAKING the COMME COM E 48 BEDUG VVINGOW EE 48 14268 BUN asu eee ee tee deat tg mate tents ets le be te au aa alia 49 BREAK ee Uu 49 The Register Panel scares ka nasi kanale aaa teen koaalad verte a td plaane Here alaalia 50 EMT Le ET 50 Jala de 00 Gl 06 ua ee 50 A WACG SUDO EE Eeer EES 51 Date eieiei TE a EE 51 Reference Guide Auto
79. signed data types More detailed information on the functions can be obtained by referring to the corresponding FPU instruction in the uM FPU V3 1 Instruction Set document Function Arguments Return Description SORT arg1 Float Float square root of arg LOG arg Float Float logarithm base e of arg LOG10 arg Float Float logarithm base 10 of arg EXP arg Float Float e to the power of arg EXP10 arg Float Float 10 to the power of arg SIN arg Float Float sine of the angle arg in radians COS arg Float Float cosine of the angle arg in radians TAN arg Float Float tangent of the angle arg in radians ASIN arg Float Float inverse sine of the value arg ACOS arg Float Float inverse cosine of the value arg ATAN arg Float Float inverse tangent of the value arg ATAN2 arg1 arg2 Float Float inverse tangent of the value arg divided by arg2 DEGREES arg Float Float angle arg converted from radians to degrees RADIANS arg Float Float angle arg converted from degrees to radians FLOOR arg Float Float floor of arg CEIL arg Float Float ceiling of arg ROUND arg Float Float argi rounded to the nearest integer POWER arg1 arg2 Float Float arg raised to the power of arg2 ROOT arg1 arg2 Float Float arg2 root of arg FRAC arg Float Float fractional part of arg INV arg Float Float the inverse of arg FLOAT arg Long Float converts arg from long to float FIX arg Floa
80. t Long converts arg from float to long FIXR arg Float Long rounds arg then converts from float to long ABS arg Float Long Float Long absolute value of arg1 MOD arg1 arg2 Float Long Float Long the remainder of arg divided by arg2 MIN arg1 arg2 Float Long Float Long the minimum of arg and arg2 MAX arg1 arg2 Float Long Float Long the maximum of arg and arg2 theta sin angle fcube power 3 result cos PI 2 sin theta User Defined Functions User defined functions are specified using the FUNCTION directive After a FUNCTION directive is encountered all compiled code is stored in the function specified The end of a function occurs at the next Micromega Corporation 39 uM FPU V3 IDE User Manual Reference Guide Compiler FUNCTION directive END directive or the end of the source file The FUNCTION directive can optionally include a function name that can be used in the remainder of the source file to call the function FUNCTION 1 GetDiameter function definition A function call is specified by using the character followed by a constant value between 0 and 63 representing the number of the function or by the character followed by the name of a previously defined function EN call function 1 eAddValue call function AddValue An example of a function definition and function call is as follows Valuel EOU BYTE microprocessor variable definitions Value2 EOU BYTE X EQU F1 register definitions
81. ter A register number can be typed in or if registers have been defined in the current source file and compiled a pop up menu can be used Break on Expression Micromega Corporation 54 uM FPU V3 IDE User Manual The operator used by the expression is chosen from the middle pop up menu Break on Expression latt The operators are as follows lt gt egual not egual greater than greater than or equal less than less than or equal approximately equal Reference Guide Auto Step and Conditional Breakpoints The approximately equal operator is used for floating point values The condition is true if the register value is greater than value 0 000001 and less than value 0 000001 The left side of the expression can be any value The value can be typed in or the pop up menu can be used for predefined values Break on Expression lati Micromega Corporation Infinity 1000000 1000 100 10 55 uM FPU V3 IDE User Manual Reference Guide Auto Step and Conditional Breakpoints Break on String This condition causes a breakpoint if the string comparison is true Break on String starts with ABER String Selection The string comparison can either be the entire string buffer or the current string selection The comparison operator is selected from the left pop up menu and the string to compare is entered in the field on the right Break on String RW The comparison
82. ter FSET Radius FMULI 2 FTOA 63 READSTR 5 150 SELECTA Circumference LOADPI FSETO FMUL Diameter FTOA 63 READSTR 16 179 SELECTA Area LOADPI FSETO FMUL Radius FMUL Radius String Selection 0 6 Registers Read Registers 00000015 2 942727e 44 A Status 50 COM4 57600 8 N 1 The reset message is displayed at the top of the screen Every time the FPU resets a reset message is displayed with a time stamp The instruction trace shows the hexadecimal bytes of the instruction on the left followed by the disassembled instruction If a source file has been compiled with symbol definitions these symbols are used when displaying the instructions For instructions that read data from the FPU the trace will also display the data being sent Compare the instructions in the Debug Trace to the tutorial1 bs2 program Tracing is very useful for checking the actual sequence of instruction executed by the FPU Many programming errors can often be found simply by examining the trace Breakpoints A breakpoint stops execution of FPU instructions A BREAK message is displayed in the Debug Trace and the Register Display String Buffer and Status are automatically updated This enables you to examine the state of the FPU at that point and then continue execution or to single step through the code one instruction at a time Micromega Corporation 20 uM FPU V3 IDE User Manual Tutorial 2 Debugging FP
83. ters for the selected type are displayed in red and will be ignored by the converter The Output fields display the input value in all three formats The hexadecimal format can be displayed as 8 bit bytes 16 bit word or as a 32 bit value with a choice of prefix characters The format can be selected to match the format used by microcontroller programs One of the handiest ways of using the number converter is with copy and paste You can copy a number from program code or a trace listing and paste into the Input field The Input field accepts floating point numbers decimal numbers and hexadecimal numbers in 8 bit 16 bit and 32 bit formats You can copy from the Output fields to program code Micromega Corporation 33 uM FPU V3 IDE User Manual Reference Guide Menus and Dialogs Number Converter Decimal Hexadecimal 100 25 Float Output 100 25 Float 1120436224 Decimal 42 SCH 80 00 Hexadecimal Hex Prefix Hex Format v et vi Close Set Clock Speed menu item displays the Set Clock Speed dialog and is used to change the clock speed of the FPU Set Clock Speed Clock Speed ETS EVENT elo v May require power downipower up cycle Change Clock The default clock speed is 29 48 MHz using an internal oscillator which provides the maximum execution speed The clock speed only needs to be changed for special circumstances such as low power applications e g for 3 3V operation the
84. tions Branch instructions are only valid inside a function There are four types of branch instructions and a computed GOTO instruction BRA lt label gt branch to label BRA lt condition code gt lt label gt if condition code is true branch to label JMP lt label gt jump to label JMP lt condition code gt lt label gt if condition code is true jump to label GOTO lt register gt jump the address contained in the register BRA instructions requires one less byte than the equivalent JMP instructions but are limited to branching to a label located at an address 128 bytes or 127 bytes from the next instruction JMP instructions can branch to any address in the function The GOTO instruction jumps to the address specified by the value in a register If a BRA JMP or GOTO instruction specifies an address that is outside the address range of the function the function will exit An implicit RET instruction is included at the end of all function RET instructions can also be placed within the function RET return from function RET lt condition code gt if condition is true return from function Condition Codes The condition codes used by various instructions are summarized below Symbol Definition Condition Code Status Bits Z EQ zero or equal 51 N 0 Z 1 NZ NE non zero or not equal 50 N 0 Z 0 LT less than 72 N 0 S 1 Z 0 LE less than or equal 62 special case Micromega Corporation 44 uM FPU V3 IDE User Manual GT GE
85. ts the ability to trace uM FPU instructions set breakpoints single step through execution of uM FPU instructions and display the value of uM FPU registers The IDE includes a disassembler so that instruction traces are displayed in easy to read assembler format Making the Connection For debugging the uM FPU V3 IDE must have a serial connection to the uM FPU V3 chip Refer to the section at the start of this document called Connecting to the uM FPU V3 chip Debug Window Register Display Debug Trace Button Bar Selected Name Hex Value Formatted Value uM FPU V3 IDE AEJ File Edit Debug Functions Tools Help tutoriali fpu Output Debug Functions Serial I O to top Registers 40490FDB 3 141593 F2754D2D4650 READSTR uM FPU V3 1 2 52056332E31 2E3200 0104 SELECTA Radius 5B0000 LOADWORD O 29 FSETO S5BO3E6 LOADWORD 1000 2E FDIVO 0105 SELECTA Diameter 2004 FSET Radius 3602 FMULI 2 010C SELECTA Circumference LOADPI FSETO FMUL Diameter SELECTA Area TEEFFFFF LOADPI FSETO FMUL Radius FMUL Radius ARTE String Selection 0 13 Status 00 COM4 57600 8 N 1 Connection Status String Buffer Status Message Status Byte The Debug Trace displays messages and instruction traces The Reset message includes a time stamp is is displayed whenever a hardware or software reset occurs Instruction tracing will only occur if tracing is enabled This can be enabled at Reset by setting the Tr
86. uM FPU V3 IDE d 4 User Manual b Micromega Corporation Introduction The uM FPU V3 Integrated Development Environment IDE software provides a set of easy to use tools for developing applications using the uM FPU V3 floating point coprocessor The IDE runs on Windows XP Vista and Windows 7 and provides support for compiling debugging and programming the uM FPU V3 floating point coprocessor Main Features Compiling ebuilt in code editor for entering symbol definitions and math expressions ecompiler generates code customized to the selected microcontroller epre defined code generators included for most microcontrollers etarget description files can be defined by the user for customized code generation ecompiler code and assembler code can be mixed to support all uM FPU V3 instructions output code can be copied to the microcontroller program Debugging einstruction tracing econtents of all FPU registers can be displayed in various formats ebreakpoints and single step execution econditional breakpoints using auto step capability esymbol definitions from compiler used by instruction trace and register display enumeric conversion tool for 32 bit floating point and integer values Programming Flash Memory ebuilt in programmer for storing user defined functions in Flash memory memory map display for Flash memory and EEPROM memory oraphic interface for setting parameter bytes stored in Flash support for setting alternate clock speeds
87. ual Overview of UM FPU V3 IDE User Interface Overview of uM FPU V3 IDE User Interface The main window of the IDE has a menu bar and a set of tabs attached to five different windows Clicking a tab will display the associated window File Edit Debug Functions Tools Help tutoriall fpu Output Debug Functions Serial UO Source Window The Source Window is the leftmost tab and the filename of the source file is displayed on the tab If the source file has not been previously saved the name of the tab will be untitled If the source file has been modified since the last save an asterisk is displayed after the filename The source file is stored as a text file with a default extension of fpu File Name Compile Button Target Menu Source Code uM FPU V3 IDE File ED Debug Function ools Help tutoriall fpu Outpd Debug Functions Serial I Target BASIC Stamp SPI v distance VAR Word Microcontroller variable definiti ns arealn VAR Word Radius equ F10 FPU register definitions Diameter equ Fll Circumference equ Fl2 Area equ Fl3 Radius distance 1000 Calculations Diameter Radius 2 Circumference PI Diameter Area PI Radius Radius COM4 57600 8 N 1 Connection Status Status Message The Source Window is used to edit the source code and compile the source code Pressing the Compile button Micromega Corporation 6 uM FPU V3 IDE User Manual Overview of UM FPU V3
88. un the program again The following output should now be displayed in the terminal window Saving the Source File Use the File gt Save command to save the file This completes the tutorial on compiling code for the uM FPU V3 chip With the information gained from this tutorial and more detailed information from the reference section you should now be able to use the IDE to create your own programs Micromega Corporation 18 uM FPU V3 IDE User Manual Tutorial 2 Debugging FPU Code Tutorial 2 Debugging FPU Code This tutorial takes you through some examples of debugging FPU code using the uM FPU V3 IDE We will use the Basic Stamp program created in the previous tutorial for debugging Making the Connection For debugging the uM FPU V3 IDE must have a serial connection to the uM FPU V3 chip Refer to the section at the start of this document called Connecting to the uM FPU V3 chip Tracing Instructions The Debug Window of the IDE can display a trace of all instructions as they are executed By default tracing is disabled It can be enabled at Reset by setting the Trace on Reset option in the Functions gt Set Parameters dialog or it can be turned on or off at any time by sending the TRACEON or TRACEOFF instruction For this tutorial we will use the Trace on Reset option Select the Functions gt Set Parameters menu item and enable the Trace on Reset option as shown below Set Parameters Break on Reset Trace on Reset
89. unctions button is used to program new functions to the uM FPU V3 chip If a newly defined function is different then the currently stored functions the action taken is determined by the Overwrite Stored Functions option Ovenarite Stored Functions O Always Confirm with User 5 Never If the Always option is selected a new function will always overwrite any previously stored function If the Confirm with User option is selected you are asked to confirm whether a new function should replace the previously stored function If the Never option is selected new functions are not allowed to replace previously stored functions Micromega Corporation 58 uM FPU V3 IDE User Manual Reference Guide Setting uM FPU V3 Parameters Reference Guide Setting uM FPU V3 Parameters The Set Parameters menu item is used to set the uM FPU V3 mode parameter bytes Set Parameters Dialog Set Parameters Break on Reset Enable Busy Ready Status on OUT Use PIC format IEEE 754 is default Idle Mode Power Saving Enable Sleep Mode Power Saving Enabled Interface Mode CS pin selects interface default O I2C interface CS pin ignored SPI interface CS pin used as chip select LC Address LD Auto Start Mode IF CS pin is Low at Reset _ Disable Debug Call Function Restore Default Settings Break on Reset If this option is selected a breakpoint will occur on the first instruction following a Res
90. we ll read the Area value back to the microcontroller as a 16 bit integer and print the result To do this we first add the following definition for the microcontroller variable arealn VAR Word Next we add the following line to convert the Area value to long integer and send the lower 16 bits back to microcontroller arealn Area Micromega Corporation 15 uM FPU V3 IDE User Manual Tutorial 1 Compiling FPU Code The Source Window should look as follows CT uM FPU V3 IDE File Edit Debug Functions Tools Help tutoriali fpu Output Debug Functions Serial UO Target BASIC Stamp SPI v distance VAR Word arealn VAR Word Radius equ F10 Diameter equ Fll Circumference equ Fl2 Area equ Fl3 Radius distance 1000 Diameter Radius 2 Circumference PI Diameter Area PI Radius Radius areaIn Area Click the Compile button Copy Revised Code to the Main Program Copy the generated code from the IDE Output Window and paste over the previous code in the BASIC Stamp program Add additional DEBUG statements as described above to print the new results Copy the uM FPU Register Definitions and Variable Definitions from the Output Window and paste in the Basic Stamp program in the main definitions section replacing the previous definitions Copy the Generated Code from the Output Window and paste in the Basic Stamp program after the Main label replacing the previous code Add DEBUG and Print
Download Pdf Manuals
Related Search
Related Contents
Fujitsu STYLISTIC M532 32GB 3G Black 2Mestre et. al - Grupo de Investigaciones Entomológicas pestañas de easy live chat GAME BOY® PLAYER INSTRUCTION BOOKLET MODE D`EMPLOI DataMate - Alpine Power Systems manual do proprietário Impala semi 09 - Sûreté du Québec Glance View Gesture Shot Gesture View Getting to Know 162 05 00 Rev1 Folheto de Instrução Cafeteira D36P Copyright © All rights reserved.
Failed to retrieve file