| Electronic Components Datasheet Search |
|
AN669 Datasheet(PDF) 4 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
AN669 Datasheet(HTML) 4 Page - Microchip Technology |
|
4 / 7 page ![]() AN669 DS00669A-page 4 © 1997 Microchip Technology Inc. USING 32-BIT FLOATING POINT MULTIPLY Using the 32-bit floating point multiply supplied with AN575 in a C program is straightforward. First, copy the entire routine from the file fpm32.a16 (from AN575). Then, create a function with the same name as the assembly routine. Lets take a well known formula: Let, π = 3.141592654 r = 12.34567898 meters Find A: A πr 2 = We need to convert the previous decimal numbers to Microchip 32-bit floating point. Use fpm32 (from AN575), to solve the equation. We will use MPLAB-C and use our C function named fpm32(). The main routine is listed in Example 6. AN575 comes with a handy utility called fprep.exe. This Microchip file is a DOS executable. When running fprep , you can enter in a decimal number and it dis- plays the hexadecimal floating point number. Table 1 shows the numbers in our example and their equivalent floating point formats. TABLE 1: PICmicro ™ 32-BIT FLOATING POINT REPRESENTATIONS OF OUR EXAMPLE EXAMPLE 6: MAIN ROUTINE TO TEST OUT OUR NEW 32-BIT FLOAT MULTIPLY IN C #include "16c74a.h" #include "math16c.c" #include "fpm32.inc" // Notice that fpm32 is located in page 0 // Thus, all GOTOs reside in the same page. void main (void) { AEXP = 0X80; // PI = 3.141592654 AARGB0 = 0X49; AARGB1 = 0X0F; AARGB2 = 0XDB; BEXP = 0X82; // r = 12.34567898 BARGB0 = 0X45; BARGB1 = 0X87; BARGB2 = 0XE7; fpm32(); // AARG = PI * r // you must reload r into BARG since // fpm32() destroys BARG. BEXP = 0X82; // r = 12.34567898 BARGB0 = 0X45; BARGB1 = 0X87; BARGB2 = 0XE7; fpm32(); // AARG = (PI*r)*r while(1); } Microchip Floating Point Equivalent Decimal Number EXP B0 (MSB) B1 B2 (LSB) π = 3.141592654 0x80 0x49 0x0F 0xDB r = 12.34567898 meters 0x82 0x45 0x87 0xE7 A = 478.8283246 m2 -- fprep.exe calculated result 0x87 0x6F 0x6A 0x07 A = 478.8283246 m2 -- PIC16C74A measured result using MPLAB 3.12 and PICMASTER 16J probe 0x87 0x6F 0x6A 0x07 |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |