DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

AN669 データシートの表示(PDF) - Microchip Technology

部品番号
コンポーネント説明
メーカー
AN669 Datasheet PDF : 7 Pages
1 2 3 4 5 6 7
AN669
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:
A = πr2
Let,
π = 3.141592654
r = 12.34567898 meters
Find A:
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: PICmicro32-BIT FLOATING POINT REPRESENTATIONS OF OUR EXAMPLE
Decimal Number
π = 3.141592654
r = 12.34567898 meters
A = 478.8283246 m2 -- fprep.exe calculated result
A = 478.8283246 m2 -- PIC16C74A measured result
using MPLAB 3.12 and PICMASTER 16J probe
Microchip Floating Point Equivalent
EXP
B0 (MSB)
B1
B2 (LSB)
0x80
0x82
0x87
0x49
0x45
0x6F
0x0F
0x87
0x6A
0xDB
0xE7
0x07
0x87
0x6F
0x6A
0x07
EXAMPLE 6: MAIN ROUTINE TO TEST OUT OUR NEW 32-BIT FLOAT MULTIPLY IN C
#include "16c74a.h"
#include "math16c.c"
#include "fpm32.inc"
void main (void)
{
AEXP = 0X80;
AARGB0 = 0X49;
AARGB1 = 0X0F;
AARGB2 = 0XDB;
BEXP = 0X82;
BARGB0 = 0X45;
BARGB1 = 0X87;
BARGB2 = 0XE7;
// Notice that fpm32 is located in page 0
// Thus, all GOTOs reside in the same page.
// PI = 3.141592654
// r = 12.34567898
fpm32();
BEXP = 0X82;
BARGB0 = 0X45;
BARGB1 = 0X87;
BARGB2 = 0XE7;
fpm32();
while(1);
}
// AARG = PI * r
// you must reload r into BARG since
// fpm32() destroys BARG.
// r = 12.34567898
// AARG = (PI*r)*r
DS00669A-page 4
© 1997 Microchip Technology Inc.

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]