CCS PCM C Compiler, Version 4.106, 47914 11-5-13 10:50Filename: D:\Honza\MLAB\Modules\Sensors\IMU01A\SW\PIC16F887\main.lstROM used: 1146 words (14%)Largest free fragment is 2048RAM used: 13 (4%) at main() level26 (7%) worst caseStack: 3 locations*0000: MOVLW 030001: MOVWF 0A0002: GOTO 3970003: NOP.................... //Akcelerometr IMU01A.................... //(c) MLAB Jan Chroust 2013............................................................ #include <main.h>.................... #include <16F887.h>.................... //////// Standard Header file for the PIC16F887 device ////////////////.................... #device PIC16F887.................... #list........................................ #device adc=8........................................ #FUSES NOWDT //No Watch Dog Timer.................... #FUSES INTRC //Internal RC Osc.................... #FUSES NOPUT //No Power Up Timer.................... #FUSES MCLR //Master Clear pin enabled.................... #FUSES NOPROTECT //Code not protected from reading.................... #FUSES NOCPD //No EE protection.................... #FUSES NOBROWNOUT //No brownout reset.................... #FUSES IESO //Internal External Switch Over mode enabled.................... #FUSES FCMEN //Fail-safe clock monitor enabled.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O.................... #FUSES NODEBUG //No Debug mode for ICD.................... #FUSES NOWRT //Program memory not write protected.................... #FUSES BORV40 //Brownout reset at 4.0V........................................ #use delay(clock=8000000)*0381: MOVLW 280382: MOVWF 040383: BCF 03.70384: MOVF 00,W0385: BTFSC 03.20386: GOTO 3940387: MOVLW 020388: MOVWF 780389: CLRF 77038A: DECFSZ 77,F038B: GOTO 38A038C: DECFSZ 78,F038D: GOTO 389038E: MOVLW 97038F: MOVWF 770390: DECFSZ 77,F0391: GOTO 3900392: DECFSZ 00,F0393: GOTO 3870394: BCF 0A.30395: BCF 0A.40396: GOTO 476 (RETURN)................................................................................ #define PIN_SDA PIN_C4.................... #define PIN_SCL PIN_C3.................... #use i2c(master, sda=PIN_SDA, scl=PIN_SCL) //I2C*0041: MOVLW 080042: MOVWF 780043: NOP0044: BCF 07.30045: BCF 20.30046: MOVF 20,W0047: BSF 03.50048: MOVWF 070049: NOP004A: BCF 03.5004B: RLF 2F,F004C: BCF 07.4004D: BTFSS 03.0004E: GOTO 055004F: BSF 20.40050: MOVF 20,W0051: BSF 03.50052: MOVWF 070053: GOTO 0590054: BCF 03.50055: BCF 20.40056: MOVF 20,W0057: BSF 03.50058: MOVWF 070059: NOP005A: BCF 03.5005B: BSF 20.3005C: MOVF 20,W005D: BSF 03.5005E: MOVWF 07005F: BCF 03.50060: BTFSS 07.30061: GOTO 0600062: DECFSZ 78,F0063: GOTO 0430064: NOP0065: BCF 07.30066: BCF 20.30067: MOVF 20,W0068: BSF 03.50069: MOVWF 07006A: NOP006B: BCF 03.5006C: BSF 20.4006D: MOVF 20,W006E: BSF 03.5006F: MOVWF 070070: NOP0071: NOP0072: BCF 03.50073: BSF 20.30074: MOVF 20,W0075: BSF 03.50076: MOVWF 070077: BCF 03.50078: BTFSS 07.30079: GOTO 078007A: CLRF 78007B: NOP007C: BTFSC 07.4007D: BSF 78.0007E: BCF 07.3007F: BCF 20.30080: MOVF 20,W0081: BSF 03.50082: MOVWF 070083: BCF 03.50084: BCF 07.40085: BCF 20.40086: MOVF 20,W0087: BSF 03.50088: MOVWF 070089: BCF 03.5008A: RETURN*0130: MOVLW 080131: MOVWF 300132: MOVF 77,W0133: MOVWF 310134: BSF 20.40135: MOVF 20,W0136: BSF 03.50137: MOVWF 070138: NOP0139: BCF 03.5013A: BSF 20.3013B: MOVF 20,W013C: BSF 03.5013D: MOVWF 07013E: BCF 03.5013F: BTFSS 07.30140: GOTO 13F0141: BTFSC 07.40142: BSF 03.00143: BTFSS 07.40144: BCF 03.00145: RLF 78,F0146: NOP0147: BCF 20.30148: MOVF 20,W0149: BSF 03.5014A: MOVWF 07014B: BCF 03.5014C: BCF 07.3014D: DECFSZ 30,F014E: GOTO 134014F: BSF 20.40150: MOVF 20,W0151: BSF 03.50152: MOVWF 070153: NOP0154: BCF 03.50155: BCF 07.40156: MOVF 31,W0157: BTFSC 03.20158: GOTO 15E0159: BCF 20.4015A: MOVF 20,W015B: BSF 03.5015C: MOVWF 07015D: BCF 03.5015E: NOP015F: BSF 20.30160: MOVF 20,W0161: BSF 03.50162: MOVWF 070163: BCF 03.50164: BTFSS 07.30165: GOTO 1640166: NOP0167: BCF 07.30168: BCF 20.30169: MOVF 20,W016A: BSF 03.5016B: MOVWF 07016C: NOP016D: BCF 03.5016E: BCF 07.4016F: BCF 20.40170: MOVF 20,W0171: BSF 03.50172: MOVWF 070173: BCF 03.50174: RETURN.................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD*00C6: BCF 20.700C7: MOVF 20,W00C8: BSF 03.500C9: MOVWF 0700CA: BCF 03.500CB: BCF 07.700CC: MOVLW 0800CD: MOVWF 7800CE: GOTO 0CF00CF: NOP00D0: BSF 78.700D1: GOTO 0E000D2: BCF 78.700D3: RRF 30,F00D4: BTFSC 03.000D5: BSF 07.700D6: BTFSS 03.000D7: BCF 07.700D8: BSF 78.600D9: GOTO 0E000DA: BCF 78.600DB: DECFSZ 78,F00DC: GOTO 0D300DD: GOTO 0DE00DE: NOP00DF: BSF 07.700E0: MOVLW 3F00E1: MOVWF 0400E2: DECFSZ 04,F00E3: GOTO 0E200E4: NOP00E5: BTFSC 78.700E6: GOTO 0D200E7: BTFSC 78.600E8: GOTO 0DA00E9: RETURN.................... #include <math.h>.................... ////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2008 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ////////////////////////////////////////////////////////////////////////////.................... //// ////.................... //// History: ////.................... //// * 9/20/2001 : Improvments are made to sin/cos code. ////.................... //// The code now is small, much faster, ////.................... //// and more accurate. ////.................... //// * 2/21/2007 : Compiler handles & operator differently and does.................... //// not return generic (int8 *) so type cast is done ////.................... //// ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef MATH_H.................... #define MATH_H........................................ #ifdef PI.................... #undef PI.................... #endif.................... #define PI 3.1415926535897932............................................................ #define SQRT2 1.4142135623730950........................................ //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};.................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};........................................ ///////////////////////////// Round Functions //////////////////////////////........................................ float32 CEIL_FLOOR(float32 x, unsigned int8 n).................... {.................... float32 y, res;.................... unsigned int16 l;.................... int1 s;........................................ s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y <= 32768.0).................... res = (float32)(unsigned int16)y;........................................ else if (y < 10000000.0).................... {.................... l = (unsigned int16)(y/32768.0);.................... y = 32768.0*(y/32768.0 - (float32)l);.................... res = 32768.0*(float32)l;.................... res += (float32)(unsigned int16)y;.................... }........................................ else.................... res = y;........................................ y = y - (float32)(unsigned int16)y;........................................ if (s).................... res = -res;........................................ if (y != 0).................... {.................... if (s == 1 && n == 0).................... res -= 1.0;........................................ if (s == 0 && n == 1).................... res += 1.0;.................... }.................... if (x == 0).................... res = 0;........................................ return (res);.................... }........................................ // Overloaded Functions to take care for new Data types in PCD.................... // Overloaded function CEIL_FLOOR() for data type - Float48.................... #if defined(__PCD__).................... float48 CEIL_FLOOR(float48 x, unsigned int8 n).................... {.................... float48 y, res;.................... unsigned int16 l;.................... int1 s;........................................ s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y <= 32768.0).................... res = (float48)(unsigned int16)y;........................................ else if (y < 10000000.0).................... {.................... l = (unsigned int16)(y/32768.0);.................... y = 32768.0*(y/32768.0 - (float48)l);.................... res = 32768.0*(float32)l;.................... res += (float48)(unsigned int16)y;.................... }........................................ else.................... res = y;........................................ y = y - (float48)(unsigned int16)y;........................................ if (s).................... res = -res;........................................ if (y != 0).................... {.................... if (s == 1 && n == 0).................... res -= 1.0;........................................ if (s == 0 && n == 1).................... res += 1.0;.................... }.................... if (x == 0).................... res = 0;........................................ return (res);.................... }............................................................ // Overloaded function CEIL_FLOOR() for data type - Float64.................... float64 CEIL_FLOOR(float64 x, unsigned int8 n).................... {.................... float64 y, res;.................... unsigned int16 l;.................... int1 s;........................................ s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y <= 32768.0).................... res = (float64)(unsigned int16)y;........................................ else if (y < 10000000.0).................... {.................... l = (unsigned int16)(y/32768.0);.................... y = 32768.0*(y/32768.0 - (float64)l);.................... res = 32768.0*(float64)l;.................... res += (float64)(unsigned int16)y;.................... }........................................ else.................... res = y;........................................ y = y - (float64)(unsigned int16)y;........................................ if (s).................... res = -res;........................................ if (y != 0).................... {.................... if (s == 1 && n == 0).................... res -= 1.0;........................................ if (s == 0 && n == 1).................... res += 1.0;.................... }.................... if (x == 0).................... res = 0;........................................ return (res);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float floor(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : rounds down the number x..................... // Date : N/A.................... //.................... float32 floor(float32 x).................... {.................... return CEIL_FLOOR(x, 0);.................... }.................... // Following 2 functions are overloaded functions of floor() for PCD.................... // Overloaded function floor() for data type - Float48.................... #if defined(__PCD__).................... float48 floor(float48 x).................... {.................... return CEIL_FLOOR(x, 0);.................... }........................................ // Overloaded function floor() for data type - Float64.................... float64 floor(float64 x).................... {.................... return CEIL_FLOOR(x, 0);.................... }.................... #endif............................................................ ////////////////////////////////////////////////////////////////////////////.................... // float ceil(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : rounds up the number x..................... // Date : N/A.................... //.................... float32 ceil(float32 x).................... {.................... return CEIL_FLOOR(x, 1);.................... }.................... // Following 2 functions are overloaded functions of ceil() for PCD.................... // Overloaded function ceil() for data type - Float48.................... #if defined(__PCD__).................... float48 ceil(float48 x).................... {.................... return CEIL_FLOOR(x, 1);.................... }........................................ // Overloaded function ceil() for data type - Float64.................... float64 ceil(float64 x).................... {.................... return CEIL_FLOOR(x, 1);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float fabs(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : Computes the absolute value of floating point number x.................... // Returns : returns the absolute value of x.................... // Date : N/A.................... //.................... #define fabs abs........................................ ////////////////////////////////////////////////////////////////////////////.................... // float fmod(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : Computes the floating point remainder of x/y.................... // Returns : returns the value of x= i*y, for some integer i such that, if y.................... // is non zero, the result has the same isgn of x na dmagnitude less than the.................... // magnitude of y. If y is zero then a domain error occurs..................... // Date : N/A.................... //........................................ float fmod(float32 x,float32 y).................... {.................... float32 i;.................... if (y!=0.0).................... {.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);.................... return(x-(i*y));.................... }.................... else.................... {.................... #ifdef _ERRNO.................... {.................... errno=EDOM;.................... }.................... #endif.................... }.................... }.................... //Overloaded function for fmod() for PCD.................... // Overloaded function fmod() for data type - Float48.................... #if defined(__PCD__).................... float48 fmod(float48 x,float48 y).................... {.................... float48 i;.................... if (y!=0.0).................... {.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);.................... return(x-(i*y));.................... }.................... else.................... {.................... #ifdef _ERRNO.................... {.................... errno=EDOM;.................... }.................... #endif.................... }.................... }.................... // Overloaded function fmod() for data type - Float64.................... float64 fmod(float64 x,float64 y).................... {.................... float64 i;.................... if (y!=0.0).................... {.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);.................... return(x-(i*y));.................... }.................... else.................... {.................... #ifdef _ERRNO.................... {.................... errno=EDOM;.................... }.................... #endif.................... }.................... }.................... #endif.................... //////////////////// Exponential and logarithmic functions ////////////////////.................... ////////////////////////////////////////////////////////////////////////////.................... // float exp(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the value (e^x).................... // Date : N/A.................... //.................... #define LN2 0.6931471805599453........................................ float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,.................... 0.0554965651, 0.240227138, 0.693147172};............................................................ float32 exp(float32 x).................... {.................... float32 y, res, r;.................... #if defined(__PCD__).................... int8 data1;.................... #endif.................... signed int8 n;.................... int1 s;.................... #ifdef _ERRNO.................... if(x > 88.722838).................... {.................... errno=ERANGE;.................... return(0);.................... }.................... #endif.................... n = (signed int16)(x/LN2);.................... s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... n = -n;.................... y = -y;.................... }........................................ res = 0.0;.................... #if !defined(__PCD__).................... *((unsigned int8 *)(&res)) = n + 0x7F;.................... #endif........................................ #if defined(__PCD__) // Takes care of IEEE format for PCD.................... data1 = n+0x7F;.................... if(bit_test(data1,0)).................... bit_set(*(((unsigned int8 *)(&res)+2)),7);.................... rotate_right(&data1,1);.................... bit_clear(data1,7);.................... *(((unsigned int8 *)(&res)+3)) = data1;.................... #endif........................................ y = y/LN2 - (float32)n;........................................ r = pe[0]*y + pe[1];.................... r = r*y + pe[2];.................... r = r*y + pe[3];.................... r = r*y + pe[4];.................... r = r*y + pe[5];........................................ res = res*(1.0 + y*r);........................................ if (s).................... res = 1.0/res;.................... return(res);.................... }............................................................ //Overloaded function for exp() for PCD.................... // Overloaded function exp() for data type - Float48.................... #if defined(__PCD__).................... float48 exp(float48 x).................... {.................... float48 y, res, r;.................... int8 data1;.................... signed int8 n;.................... int1 s;.................... #ifdef _ERRNO.................... if(x > 88.722838).................... {.................... errno=ERANGE;.................... return(0);.................... }.................... #endif.................... n = (signed int16)(x/LN2);.................... s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... n = -n;.................... y = -y;.................... }........................................ res = 0.0;........................................ data1 = n+0x7F;.................... if(bit_test(data1,0)).................... bit_set(*(((unsigned int8 *)(&res)+4)),7);.................... rotate_right(&data1,1);.................... bit_clear(data1,7);.................... *(((unsigned int8 *)(&res)+5)) = data1;........................................ y = y/LN2 - (float48)n;........................................ r = pe[0]*y + pe[1];.................... r = r*y + pe[2];.................... r = r*y + pe[3];.................... r = r*y + pe[4];.................... r = r*y + pe[5];........................................ res = res*(1.0 + y*r);........................................ if (s).................... res = 1.0/res;.................... return(res);.................... }........................................ // Overloaded function exp() for data type - Float64.................... float64 exp(float64 x).................... {.................... float64 y, res, r;.................... unsigned int16 data1, data2;.................... unsigned int16 *p;.................... signed int16 n;.................... int1 s;.................... #ifdef _ERRNO.................... if(x > 709.7827128).................... {.................... errno=ERANGE;.................... return(0);.................... }.................... #endif.................... n = (signed int16)(x/LN2);.................... s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... n = -n;.................... y = -y;.................... }........................................ res = 0.0;........................................ #if !defined(__PCD__).................... *((unsigned int16 *)(&res)) = n + 0x7F;.................... #endif.................... p= (((unsigned int16 *)(&res))+3);.................... data1 = *p;.................... data2 = *p;.................... data1 = n + 0x3FF;.................... data1 = data1 <<4;.................... if(bit_test(data2,15)).................... bit_set(data1,15);.................... data2 = data2 & 0x000F;.................... data1 ^= data2;........................................ *(((unsigned int16 *)(&res)+3)) = data1;............................................................ y = y/LN2 - (float64)n;........................................ r = pe[0]*y + pe[1];.................... r = r*y + pe[2];.................... r = r*y + pe[3];.................... r = r*y + pe[4];.................... r = r*y + pe[5];........................................ res = res*(1.0 + y*r);........................................ if (s).................... res = 1.0/res;.................... return(res);.................... }........................................ #ENDIF............................................................ /************************************************************/........................................ float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};.................... float32 const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};........................................ ////////////////////////////////////////////////////////////////////////////.................... // float log(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the the natural log of x.................... // Date : N/A.................... //.................... float32 log(float32 x).................... {.................... float32 y, res, r, y2;.................... #if defined(__PCD__).................... unsigned int8 data1,data2;.................... #endif.................... signed int8 n;.................... #ifdef _ERRNO.................... if(x <0).................... {.................... errno=EDOM;.................... }.................... if(x ==0).................... {.................... errno=ERANGE;.................... return(0);.................... }.................... #endif.................... y = x;........................................ if (y != 1.0).................... {.................... #if !defined(__PCD__).................... *((unsigned int8 *)(&y)) = 0x7E;.................... #endif........................................ #if defined(__PCD__) // Takes care of IEEE format.................... data2 = *(((unsigned int8 *)(&y))+3);.................... *(((unsigned int8 *)(&y))+3) = 0x3F;.................... data1 = *(((unsigned int8 *)(&y))+2);.................... bit_clear(data1,7);.................... *(((unsigned int8 *)(&y))+2) = data1;.................... if(bit_test(data2,7)).................... bit_set(*(((unsigned int8 *)(&y))+3),7);.................... #endif........................................ y = (y - 1.0)/(y + 1.0);........................................ y2=y*y;........................................ res = pl[0]*y2 + pl[1];.................... res = res*y2 + pl[2];.................... res = res*y2 + pl[3];........................................ r = ql[0]*y2 + ql[1];.................... r = r*y2 + ql[2];.................... r = r*y2 + ql[3];........................................ res = y*res/r;.................... #if !defined(__PCD__).................... n = *((unsigned int8 *)(&x)) - 0x7E;.................... #endif.................... #if defined(__PCD__).................... data1 = *(((unsigned int8 *)(&x)+3));.................... rotate_left(&data1,1);.................... data2 = *(((unsigned int8 *)(&x)+2));.................... if(bit_test (data2,7)).................... bit_set(data1,0);.................... n = data1 - 0x7E;.................... #endif........................................ if (n<0).................... r = -(float32)-n;.................... else.................... r = (float32)n;........................................ res += r*LN2;.................... }........................................ else.................... res = 0.0;........................................ return(res);.................... }........................................ //Overloaded function for log() for PCD.................... // Overloaded function log() for data type - Float48.................... #if defined(__PCD__).................... float48 log(float48 x).................... {.................... float48 y, res, r, y2;.................... unsigned int8 data1,data2;.................... signed int8 n;.................... #ifdef _ERRNO.................... if(x <0).................... {.................... errno=EDOM;.................... }.................... if(x ==0).................... {.................... errno=ERANGE;.................... return(0);.................... }.................... #endif.................... y = x;........................................ if (y != 1.0).................... {........................................ #if !defined(__PCD__).................... *((unsigned int8 *)(&y)) = 0x7E;.................... #endif.................... data2 = *(((unsigned int8 *)(&y))+5);.................... *(((unsigned int8 *)(&y))+5) = 0x3F;.................... data1 = *(((unsigned int8 *)(&y))+4);.................... bit_clear(data1,7);.................... *(((unsigned int8 *)(&y))+4) = data1;........................................ if(bit_test(data2,7)).................... bit_set(*(((unsigned int8 *)(&y))+4),7);.................... y = (y - 1.0)/(y + 1.0);........................................ y2=y*y;........................................ res = pl[0]*y2 + pl[1];.................... res = res*y2 + pl[2];.................... res = res*y2 + pl[3];........................................ r = ql[0]*y2 + ql[1];.................... r = r*y2 + ql[2];.................... r = r*y2 + ql[3];........................................ res = y*res/r;........................................ data1 = *(((unsigned int8 *)(&x)+5));.................... rotate_left(&data1,1);.................... data2 = *(((unsigned int8 *)(&x)+4));.................... if(bit_test (data2,7)).................... bit_set(data1,0);........................................ n = data1 - 0x7E;........................................ if (n<0).................... r = -(float48)-n;.................... else.................... r = (float48)n;........................................ res += r*LN2;.................... }........................................ else.................... res = 0.0;........................................ return(res);.................... }........................................ // Overloaded function log() for data type - Float48.................... #if defined(__PCD__).................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};.................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};.................... #endif.................... float64 log(float64 x).................... {.................... float64 y, res, r, y2;.................... unsigned int16 data1,data2;.................... unsigned int16 *p;.................... signed int16 n;.................... #ifdef _ERRNO.................... if(x <0).................... {.................... errno=EDOM;.................... }.................... if(x ==0).................... {.................... errno=ERANGE;.................... return(0);.................... }.................... #endif.................... y = x;........................................ if (y != 1.0).................... {.................... #if !defined(__PCD__).................... *((unsigned int8 *)(&y)) = 0x7E;.................... #endif.................... p= (((unsigned int16 *)(&y))+3);.................... data1 = *p;.................... data2 = *p;.................... data1 = 0x3FE;.................... data1 = data1 <<4;.................... if(bit_test (data2,15)).................... bit_set(data1,15);.................... data2 = data2 & 0x000F;.................... data1 ^=data2;........................................ *p = data1;........................................ y = (y - 1.0)/(y + 1.0);........................................ y2=y*y;........................................ res = pl_64[0]*y2 + pl_64[1];.................... res = res*y2 + pl_64[2];.................... res = res*y2 + pl_64[3];........................................ r = ql_64[0]*y2 + ql_64[1];.................... r = r*y2 + ql_64[2];.................... r = r*y2 + ql_64[3];........................................ res = y*res/r;........................................ p= (((unsigned int16 *)(&x))+3);.................... data1 = *p;.................... bit_clear(data1,15);.................... data1 = data1 >>4;.................... n = data1 - 0x3FE;............................................................ if (n<0).................... r = -(float64)-n;.................... else.................... r = (float64)n;........................................ res += r*LN2;.................... }........................................ else.................... res = 0.0;........................................ return(res);.................... }.................... #endif............................................................ #define LN10 2.3025850929940456........................................ ////////////////////////////////////////////////////////////////////////////.................... // float log10(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the the log base 10 of x.................... // Date : N/A.................... //.................... float32 log10(float32 x).................... {.................... float32 r;........................................ r = log(x);.................... r = r/LN10;.................... return(r);.................... }........................................ //Overloaded functions for log10() for PCD.................... // Overloaded function log10() for data type - Float48.................... #if defined(__PCD__).................... float48 log10(float48 x).................... {.................... float48 r;........................................ r = log(x);.................... r = r/LN10;.................... return(r);.................... }........................................ // Overloaded function log10() for data type - Float64.................... float64 log10(float64 x).................... {.................... float64 r;........................................ r = log(x);.................... r = r/LN10;.................... return(r);.................... }.................... #endif.................... ////////////////////////////////////////////////////////////////////////////.................... // float modf(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description :breaks the argument value int integral and fractional parts,.................... // ach of which have the same sign as the argument. It stores the integral part.................... // as a float in the object pointed to by the iptr.................... // Returns : returns the signed fractional part of value..................... // Date : N/A.................... //........................................ float32 modf(float32 value,float32 *iptr).................... {.................... *iptr=(value < 0.0)? ceil(value): floor(value);.................... return(value - *iptr);.................... }.................... //Overloaded functions for modf() for PCD.................... // Overloaded function modf() for data type - Float48.................... #if defined(__PCD__).................... float48 modf(float48 value,float48 *iptr).................... {.................... *iptr=(value < 0.0)? ceil(value): floor(value);.................... return(value - *iptr);.................... }.................... // Overloaded function modf() for data type - Float64.................... float64 modf(float64 value,float64 *iptr).................... {.................... *iptr=(value < 0.0)? ceil(value): floor(value);.................... return(value - *iptr);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float pwr(float x,float y).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the value (x^y).................... // Date : N/A.................... // Note : 0 is returned when the function will generate an imaginary number.................... //.................... float32 pwr(float32 x,float32 y).................... {.................... if(0 > x && fmod(y, 1) == 0) {.................... if(fmod(y, 2) == 0) {.................... return (exp(log(-x) * y));.................... } else {.................... return (-exp(log(-x) * y));.................... }.................... } else if(0 > x && fmod(y, 1) != 0) {.................... return 0;.................... } else {.................... if(x != 0 || 0 >= y) {.................... return (exp(log(x) * y));.................... }.................... }.................... }.................... //Overloaded functions for pwr() for PCD.................... // Overloaded function pwr() for data type - Float48.................... #if defined(__PCD__).................... float48 pwr(float48 x,float48 y).................... {.................... if(0 > x && fmod(y, 1) == 0) {.................... if(fmod(y, 2) == 0) {.................... return (exp(log(-x) * y));.................... } else {.................... return (-exp(log(-x) * y));.................... }.................... } else if(0 > x && fmod(y, 1) != 0) {.................... return 0;.................... } else {.................... if(x != 0 || 0 >= y) {.................... return (exp(log(x) * y));.................... }.................... }.................... }.................... // Overloaded function pwr() for data type - Float64.................... float64 pwr(float64 x,float64 y).................... {.................... if(0 > x && fmod(y, 1) == 0) {.................... if(fmod(y, 2) == 0) {.................... return (exp(log(-x) * y));.................... } else {.................... return (-exp(log(-x) * y));.................... }.................... } else if(0 > x && fmod(y, 1) != 0) {.................... return 0;.................... } else {.................... if(x != 0 || 0 >= y) {.................... return (exp(log(x) * y));.................... }.................... }.................... }.................... #endif........................................ //////////////////// Power functions ////////////////////........................................ ////////////////////////////////////////////////////////////////////////////.................... // float pow(float x,float y).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the value (x^y).................... // Date : N/A.................... // Note : 0 is returned when the function will generate an imaginary number.................... //.................... float32 pow(float32 x,float32 y).................... {.................... if(0 > x && fmod(y, 1) == 0) {.................... if(fmod(y, 2) == 0) {.................... return (exp(log(-x) * y));.................... } else {.................... return (-exp(log(-x) * y));.................... }.................... } else if(0 > x && fmod(y, 1) != 0) {.................... return 0;.................... } else {.................... if(x != 0 || 0 >= y) {.................... return (exp(log(x) * y));.................... }.................... }.................... }.................... //Overloaded functions for pow() for PCD.................... // Overloaded function for pow() data type - Float48.................... #if defined(__PCD__).................... float48 pow(float48 x,float48 y).................... {.................... if(0 > x && fmod(y, 1) == 0) {.................... if(fmod(y, 2) == 0) {.................... return (exp(log(-x) * y));.................... } else {.................... return (-exp(log(-x) * y));.................... }.................... } else if(0 > x && fmod(y, 1) != 0) {.................... return 0;.................... } else {.................... if(x != 0 || 0 >= y) {.................... return (exp(log(x) * y));.................... }.................... }.................... }........................................ // Overloaded function pow() for data type - Float64.................... float64 pow(float64 x,float64 y).................... {.................... if(0 > x && fmod(y, 1) == 0) {.................... if(fmod(y, 2) == 0) {.................... return (exp(log(-x) * y));.................... } else {.................... return (-exp(log(-x) * y));.................... }.................... } else if(0 > x && fmod(y, 1) != 0) {.................... return 0;.................... } else {.................... if(x != 0 || 0 >= y) {.................... return (exp(log(x) * y));.................... }.................... }.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float sqrt(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the square root of x.................... // Date : N/A.................... //.................... float32 sqrt(float32 x).................... {.................... float32 y, res;.................... #if defined(__PCD__).................... unsigned int16 data1,data2;.................... #endif.................... BYTE *p;........................................ #ifdef _ERRNO.................... if(x < 0).................... {.................... errno=EDOM;.................... }.................... #endif........................................ if( x<=0.0).................... return(0.0);........................................ y=x;........................................ #if !defined(__PCD__).................... p=&y;.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);.................... #endif........................................ #if defined(__PCD__).................... p = (((unsigned int8 *)(&y))+3);.................... data1 = *(((unsigned int8 *)(&y))+3);.................... data2 = *(((unsigned int8 *)(&y))+2);.................... rotate_left(&data1,1);.................... if(bit_test(data2,7)).................... bit_set(data1,0);.................... data1 = ((data1+127) >>1);.................... bit_clear(data2,7);.................... if(bit_test(data1,0)).................... bit_set(data2,7);.................... data1 = data1 >>1;.................... *(((unsigned int8 *)(&y))+3) = data1;.................... *(((unsigned int8 *)(&y))+2) = data2;........................................ #endif........................................ do {.................... res=y;.................... y+=(x/y);........................................ #if !defined(__PCD__).................... (*p)--;.................... #endif........................................ #if defined(__PCD__).................... data1 = *(((unsigned int8 *)(&y))+3);.................... data2 = *(((unsigned int8 *)(&y))+2);.................... rotate_left(&data1,1);.................... if(bit_test(data2,7)).................... bit_set(data1,0);.................... data1--;.................... bit_clear(data2,7);.................... if(bit_test(data1,0)).................... bit_set(data2,7);.................... data1 = data1 >>1;.................... *(((unsigned int8 *)(&y))+3) = data1;.................... *(((unsigned int8 *)(&y))+2) = data2;........................................ #endif.................... } while(res != y);........................................ return(res);.................... }.................... //Overloaded functions for sqrt() for PCD.................... // Overloaded function sqrt() for data type - Float48.................... #if defined(__PCD__).................... float48 sqrt(float48 x).................... {.................... float48 y, res;.................... unsigned int16 data1,data2;.................... BYTE *p;........................................ #ifdef _ERRNO.................... if(x < 0).................... {.................... errno=EDOM;.................... }.................... #endif........................................ if( x<=0.0).................... return(0.0);........................................ y=x;........................................ #if !defined(__PCD__).................... p=&y;.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);.................... #endif........................................ #if defined(__PCD__).................... p = (((unsigned int8 *)(&y))+5);.................... data1 = *(((unsigned int8 *)(&y))+5);.................... data2 = *(((unsigned int8 *)(&y))+4);.................... rotate_left(&data1,1);.................... if(bit_test(data2,7)).................... bit_set(data1,0);.................... data1 = ((data1+127) >>1);.................... bit_clear(data2,7);.................... if(bit_test(data1,0)).................... bit_set(data2,7);.................... data1 = data1 >>1;.................... *(((unsigned int8 *)(&y))+5) = data1;.................... *(((unsigned int8 *)(&y))+4) = data2;........................................ #endif........................................ do {.................... res=y;.................... y+=(x/y);........................................ #if !defined(__PCD__).................... (*p)--;.................... #endif........................................ data1 = *(((unsigned int8 *)(&y))+5);.................... data2 = *(((unsigned int8 *)(&y))+4);.................... rotate_left(&data1,1);.................... if(bit_test(data2,7)).................... bit_set(data1,0);.................... data1--;.................... bit_clear(data2,7);.................... if(bit_test(data1,0)).................... bit_set(data2,7);.................... data1 = data1 >>1;.................... *(((unsigned int8 *)(&y))+5) = data1;.................... *(((unsigned int8 *)(&y))+4) = data2;........................................ } while(res != y);........................................ return(res);.................... }........................................ // Overloaded function sqrt() for data type - Float64.................... float64 sqrt(float64 x).................... {.................... float64 y, res;.................... unsigned int16 *p;.................... unsigned int16 temp1,temp2;........................................ #ifdef _ERRNO.................... if(x < 0).................... {.................... errno=EDOM;.................... }.................... #endif........................................ if( x<=0.0).................... return(0.0);........................................ y=x;.................... p= (((unsigned int16 *)(&y))+3);.................... temp1 = *p;.................... temp2 = *p;.................... bit_clear(temp1,15);.................... temp1 = (temp1>>4)+1023;.................... temp1 = temp1 >> 1;.................... temp1 = (temp1<<4) & 0xFFF0;.................... if(bit_test(temp2,15)).................... bit_set(temp1,15);.................... temp2 = temp2 & 0x000F;.................... temp1 ^= temp2;........................................ (*p) = temp1;........................................ do {.................... res=y;.................... y+=(x/y);.................... temp1 = *p;.................... temp2 = *p;.................... bit_clear(temp1,15);.................... temp1 = (temp1>>4);.................... temp1--;.................... temp1 = (temp1<<4) & 0xFFF0;.................... if(bit_test(temp2,15)).................... bit_set(temp1,15);.................... temp2 = temp2 & 0x000F;.................... temp1 ^= temp2;.................... (*p) = temp1;........................................ } while(res != y);........................................ return(res);.................... }.................... #endif........................................ ////////////////////////////// Trig Functions //////////////////////////////.................... #ifdef PI_DIV_BY_TWO.................... #undef PI_DIV_BY_TWO.................... #endif.................... #define PI_DIV_BY_TWO 1.5707963267948966.................... #ifdef TWOBYPI.................... #undef TWOBYPI.................... #define TWOBYPI 0.6366197723675813.................... #endif.................... ////////////////////////////////////////////////////////////////////////////.................... // float cos(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the cosine value of the angle x, which is in radian.................... // Date : 9/20/2001.................... //.................... float32 cos(float32 x).................... {.................... float32 y, t, t2 = 1.0;.................... unsigned int8 quad, i;.................... float32 frac;.................... float32 p[6] = { //by the series definition for cosine.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ).................... 0.04166666666667,.................... -0.00138888888889,.................... 0.00002480158730,.................... -0.00000027557319,.................... 0.00000000208767,.................... //-0.00000000001147,.................... // 0.00000000000005.................... };........................................ if (x < 0) x = -x; // absolute value of input........................................ quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input.................... quad = quad % 4; // quadrant (0 to 3)........................................ if (quad == 0 || quad == 2).................... t = frac * PI_DIV_BY_TWO;.................... else if (quad == 1).................... t = (1-frac) * PI_DIV_BY_TWO;.................... else // should be 3.................... t = (frac-1) * PI_DIV_BY_TWO;........................................ y = 1.0;.................... t = t * t;.................... for (i = 0; i <= 5; i++).................... {.................... t2 = t2 * t;.................... y = y + p[i] * t2;.................... }........................................ if (quad == 2 || quad == 1).................... y = -y; // correct sign........................................ return (y);.................... }............................................................ //Overloaded functions for cos() for PCD.................... // Overloaded function cos() for data type - Float48.................... #if defined(__PCD__).................... float48 cos(float48 x).................... {.................... float48 y, t, t2 = 1.0;.................... unsigned int8 quad, i;.................... float48 frac;.................... float48 p[6] = { //by the series definition for cosine.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ).................... 0.04166666666667,.................... -0.00138888888889,.................... 0.00002480158730,.................... -0.00000027557319,.................... 0.00000000208767,.................... //-0.00000000001147,.................... // 0.00000000000005.................... };........................................ if (x < 0) x = -x; // absolute value of input........................................ quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input.................... quad = quad % 4; // quadrant (0 to 3)........................................ if (quad == 0 || quad == 2).................... t = frac * PI_DIV_BY_TWO;.................... else if (quad == 1).................... t = (1-frac) * PI_DIV_BY_TWO;.................... else // should be 3.................... t = (frac-1) * PI_DIV_BY_TWO;........................................ y = 0.999999999781;.................... t = t * t;.................... for (i = 0; i <= 5; i++).................... {.................... t2 = t2 * t;.................... y = y + p[i] * t2;.................... }........................................ if (quad == 2 || quad == 1).................... y = -y; // correct sign........................................ return (y);.................... }........................................ // Overloaded function cos() for data type - Float48.................... float64 cos(float64 x).................... {.................... float64 y, t, t2 = 1.0;.................... unsigned int8 quad, i;.................... float64 frac;.................... float64 p[6] = { //by the series definition for cosine.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ).................... 0.04166666666667,.................... -0.00138888888889,.................... 0.00002480158730,.................... -0.00000027557319,.................... 0.00000000208767,.................... //-0.00000000001147,.................... // 0.00000000000005.................... };........................................ if (x < 0) x = -x; // absolute value of input........................................ quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input.................... quad = quad % 4; // quadrant (0 to 3)........................................ if (quad == 0 || quad == 2).................... t = frac * PI_DIV_BY_TWO;.................... else if (quad == 1).................... t = (1-frac) * PI_DIV_BY_TWO;.................... else // should be 3.................... t = (frac-1) * PI_DIV_BY_TWO;........................................ y = 0.999999999781;.................... t = t * t;.................... for (i = 0; i <= 5; i++).................... {.................... t2 = t2 * t;.................... y = y + p[i] * t2;.................... }........................................ if (quad == 2 || quad == 1).................... y = -y; // correct sign........................................ return (y);.................... }........................................ #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float sin(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the sine value of the angle x, which is in radian.................... // Date : 9/20/2001.................... //.................... float32 sin(float32 x).................... {.................... return cos(x - PI_DIV_BY_TWO);.................... }........................................ //Overloaded functions for sin() for PCD.................... // Overloaded function sin() for data type - Float48.................... #if defined(__PCD__).................... float48 sin(float48 x).................... {.................... return cos(x - PI_DIV_BY_TWO);.................... }........................................ // Overloaded function sin() for data type - Float48.................... float64 sin(float64 x).................... {.................... return cos(x - PI_DIV_BY_TWO);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float tan(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the tangent value of the angle x, which is in radian.................... // Date : 9/20/2001.................... //.................... float32 tan(float32 x).................... {.................... float32 c, s;........................................ c = cos(x);.................... if (c == 0.0).................... return (1.0e+36);........................................ s = sin(x);.................... return(s/c);.................... }.................... //Overloaded functions for tan() for PCD.................... // Overloaded function tan() for data type - Float48.................... #if defined(__PCD__).................... float48 tan(float48 x).................... {.................... float48 c, s;........................................ c = cos(x);.................... if (c == 0.0).................... return (1.0e+36);........................................ s = sin(x);.................... return(s/c);.................... }........................................ // Overloaded function tan() for data type - Float48.................... float64 tan(float64 x).................... {.................... float64 c, s;........................................ c = cos(x);.................... if (c == 0.0).................... return (1.0e+36);........................................ s = sin(x);.................... return(s/c);.................... }.................... #endif........................................ float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290};.................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290};........................................ float32 ASIN_COS(float32 x, unsigned int8 n).................... {.................... float32 y, res, r, y2;.................... int1 s;.................... #ifdef _ERRNO.................... if(x <-1 || x > 1).................... {.................... errno=EDOM;.................... }.................... #endif.................... s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y > 0.5).................... {.................... y = sqrt((1.0 - y)/2.0);.................... n += 2;.................... }........................................ y2=y*y;........................................ res = pas[0]*y2 + pas[1];.................... res = res*y2 + pas[2];........................................ r = qas[0]*y2 + qas[1];.................... r = r*y2 + qas[2];........................................ res = y*res/r;........................................ if (n & 2) // |x| > 0.5.................... res = PI_DIV_BY_TWO - 2.0*res;.................... if (s).................... res = -res;.................... if (n & 1) // take arccos.................... res = PI_DIV_BY_TWO - res;........................................ return(res);.................... }........................................ //Overloaded functions for ASIN_COS() for PCD.................... // Overloaded function ASIN_COS() for data type - Float48.................... #if defined(__PCD__).................... float48 ASIN_COS(float48 x, unsigned int8 n).................... {.................... float48 y, res, r, y2;.................... int1 s;.................... #ifdef _ERRNO.................... if(x <-1 || x > 1).................... {.................... errno=EDOM;.................... }.................... #endif.................... s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y > 0.5).................... {.................... y = sqrt((1.0 - y)/2.0);.................... n += 2;.................... }........................................ y2=y*y;........................................ res = pas[0]*y2 + pas[1];.................... res = res*y2 + pas[2];........................................ r = qas[0]*y2 + qas[1];.................... r = r*y2 + qas[2];........................................ res = y*res/r;........................................ if (n & 2) // |x| > 0.5.................... res = PI_DIV_BY_TWO - 2.0*res;.................... if (s).................... res = -res;.................... if (n & 1) // take arccos.................... res = PI_DIV_BY_TWO - res;........................................ return(res);.................... }........................................ // Overloaded function ASIN_COS() for data type - Float64.................... float64 ASIN_COS(float64 x, unsigned int8 n).................... {.................... float64 y, res, r, y2;.................... int1 s;.................... #ifdef _ERRNO.................... if(x <-1 || x > 1).................... {.................... errno=EDOM;.................... }.................... #endif.................... s = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y > 0.5).................... {.................... y = sqrt((1.0 - y)/2.0);.................... n += 2;.................... }........................................ y2=y*y;........................................ res = pas[0]*y2 + pas[1];.................... res = res*y2 + pas[2];........................................ r = qas[0]*y2 + qas[1];.................... r = r*y2 + qas[2];........................................ res = y*res/r;........................................ if (n & 2) // |x| > 0.5.................... res = PI_DIV_BY_TWO - 2.0*res;.................... if (s).................... res = -res;.................... if (n & 1) // take arccos.................... res = PI_DIV_BY_TWO - res;........................................ return(res);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float asin(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the arcsine value of the value x..................... // Date : N/A.................... //.................... float32 asin(float32 x).................... {.................... float32 r;........................................ r = ASIN_COS(x, 0);.................... return(r);.................... }.................... //Overloaded functions for asin() for PCD.................... // Overloaded function asin() for data type - Float48.................... #if defined(__PCD__).................... float48 asin(float48 x).................... {.................... float48 r;........................................ r = ASIN_COS(x, 0);.................... return(r);.................... }........................................ // Overloaded function asin() for data type - Float64.................... float64 asin(float64 x).................... {.................... float64 r;........................................ r = ASIN_COS(x, 0);.................... return(r);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float acos(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the arccosine value of the value x..................... // Date : N/A.................... //.................... float32 acos(float32 x).................... {.................... float32 r;........................................ r = ASIN_COS(x, 1);.................... return(r);.................... }.................... //Overloaded functions for acos() for PCD.................... // Overloaded function acos() for data type - Float48.................... #if defined(__PCD__).................... float48 acos(float48 x).................... {.................... float48 r;........................................ r = ASIN_COS(x, 1);.................... return(r);.................... }........................................ // Overloaded function acos() for data type - Float64.................... float64 acos(float64 x).................... {.................... float64 r;........................................ r = ASIN_COS(x, 1);.................... return(r);.................... }.................... #endif........................................ float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};.................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};........................................ ////////////////////////////////////////////////////////////////////////////.................... // float atan(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : returns the arctangent value of the value x..................... // Date : N/A.................... //.................... float32 atan(float32 x).................... {.................... float32 y, res, r;.................... int1 s, flag;........................................ s = 0;.................... flag = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y > 1.0).................... {.................... y = 1.0/y;.................... flag = 1;.................... }........................................ res = pat[0]*y*y + pat[1];.................... res = res*y*y + pat[2];.................... res = res*y*y + pat[3];........................................ r = qat[0]*y*y + qat[1];.................... r = r*y*y + qat[2];.................... r = r*y*y + qat[3];........................................ res = y*res/r;............................................................ if (flag) // for |x| > 1.................... res = PI_DIV_BY_TWO - res;.................... if (s).................... res = -res;........................................ return(res);.................... }.................... //Overloaded functions for atan() for PCD.................... // Overloaded function atan() for data type - Float48.................... #if defined(__PCD__).................... float48 atan(float48 x).................... {.................... float48 y, res, r;.................... int1 s, flag;........................................ s = 0;.................... flag = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y > 1.0).................... {.................... y = 1.0/y;.................... flag = 1;.................... }........................................ res = pat[0]*y*y + pat[1];.................... res = res*y*y + pat[2];.................... res = res*y*y + pat[3];........................................ r = qat[0]*y*y + qat[1];.................... r = r*y*y + qat[2];.................... r = r*y*y + qat[3];........................................ res = y*res/r;............................................................ if (flag) // for |x| > 1.................... res = PI_DIV_BY_TWO - res;.................... if (s).................... res = -res;........................................ return(res);.................... }........................................ // Overloaded function atan() for data type - Float64.................... float64 atan(float64 x).................... {.................... float64 y, res, r;.................... int1 s, flag;........................................ s = 0;.................... flag = 0;.................... y = x;........................................ if (x < 0).................... {.................... s = 1;.................... y = -y;.................... }........................................ if (y > 1.0).................... {.................... y = 1.0/y;.................... flag = 1;.................... }........................................ res = pat[0]*y*y + pat[1];.................... res = res*y*y + pat[2];.................... res = res*y*y + pat[3];........................................ r = qat[0]*y*y + qat[1];.................... r = r*y*y + qat[2];.................... r = r*y*y + qat[3];........................................ res = y*res/r;............................................................ if (flag) // for |x| > 1.................... res = PI_DIV_BY_TWO - res;.................... if (s).................... res = -res;........................................ return(res);.................... }.................... #endif........................................ /////////////////////////////////////////////////////////////////////////////.................... // float atan2(float y, float x).................... /////////////////////////////////////////////////////////////////////////////.................... // Description :computes the principal value of arc tangent of y/x, using the.................... // signs of both the arguments to determine the quadrant of the return value.................... // Returns : returns the arc tangent of y/x..................... // Date : N/A.................... //........................................ float32 atan2(float32 y,float32 x).................... {.................... float32 z;.................... int1 sign;.................... unsigned int8 quad;.................... sign=0;.................... quad=0; //quadrant.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));.................... if(y<0.0).................... {.................... sign=1;.................... y=-y;.................... }.................... if(x<0.0).................... {.................... x=-x;.................... }.................... if (x==0.0).................... {.................... if(y==0.0).................... {.................... #ifdef _ERRNO.................... {.................... errno=EDOM;.................... }.................... #endif.................... }.................... else.................... {.................... if(sign).................... {.................... return (-(PI_DIV_BY_TWO));.................... }.................... else.................... {.................... return (PI_DIV_BY_TWO);.................... }.................... }.................... }.................... else.................... {.................... z=y/x;.................... switch(quad).................... {.................... case 1:.................... {.................... return atan(z);.................... break;.................... }.................... case 2:.................... {.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122.................... return (PI-atan(z));.................... break;.................... }.................... case 3:.................... {.................... return (atan(z)-PI);.................... break;.................... }.................... case 4:.................... {.................... return (-atan(z));.................... break;.................... }.................... }.................... }.................... }........................................ //Overloaded functions for atan2() for PCD.................... // Overloaded function atan2() for data type - Float48.................... #if defined(__PCD__).................... float48 atan2(float48 y,float48 x).................... {.................... float48 z;.................... int1 sign;.................... unsigned int8 quad;.................... sign=0;.................... quad=0; //quadrant.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));.................... if(y<0.0).................... {.................... sign=1;.................... y=-y;.................... }.................... if(x<0.0).................... {.................... x=-x;.................... }.................... if (x==0.0).................... {.................... if(y==0.0).................... {.................... #ifdef _ERRNO.................... {.................... errno=EDOM;.................... }.................... #endif.................... }.................... else.................... {.................... if(sign).................... {.................... return (-(PI_DIV_BY_TWO));.................... }.................... else.................... {.................... return (PI_DIV_BY_TWO);.................... }.................... }.................... }.................... else.................... {.................... z=y/x;.................... switch(quad).................... {.................... case 1:.................... {.................... return atan(z);.................... break;.................... }.................... case 2:.................... {.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122.................... return (PI-atan(z));.................... break;.................... }.................... case 3:.................... {.................... return (atan(z)-PI);.................... break;.................... }.................... case 4:.................... {.................... return (-atan(z));.................... break;.................... }.................... }.................... }.................... }........................................ // Overloaded function atan2() for data type - Float64.................... float64 atan2(float64 y,float64 x).................... {.................... float64 z;.................... int1 sign;.................... unsigned int8 quad;.................... sign=0;.................... quad=0; //quadrant.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));.................... if(y<0.0).................... {.................... sign=1;.................... y=-y;.................... }.................... if(x<0.0).................... {.................... x=-x;.................... }.................... if (x==0.0).................... {.................... if(y==0.0).................... {.................... #ifdef _ERRNO.................... {.................... errno=EDOM;.................... }.................... #endif.................... }.................... else.................... {.................... if(sign).................... {.................... return (-(PI_DIV_BY_TWO));.................... }.................... else.................... {.................... return (PI_DIV_BY_TWO);.................... }.................... }.................... }.................... else.................... {.................... z=y/x;.................... switch(quad).................... {.................... case 1:.................... {.................... return atan(z);.................... break;.................... }.................... case 2:.................... {.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122.................... return (PI-atan(z));.................... break;.................... }.................... case 3:.................... {.................... return (atan(z)-PI);.................... break;.................... }.................... case 4:.................... {.................... return (-atan(z));.................... break;.................... }.................... }.................... }.................... }.................... #endif........................................ //////////////////// Hyperbolic functions ////////////////////........................................ ////////////////////////////////////////////////////////////////////////////.................... // float cosh(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : Computes the hyperbolic cosine value of x.................... // Returns : returns the hyperbolic cosine value of x.................... // Date : N/A.................... //........................................ float32 cosh(float32 x).................... {.................... return ((exp(x)+exp(-x))/2);.................... }.................... //Overloaded functions for cosh() for PCD.................... // Overloaded function cosh() for data type - Float48.................... #if defined(__PCD__).................... float48 cosh(float48 x).................... {.................... return ((exp(x)+exp(-x))/2);.................... }........................................ // Overloaded function cosh() for data type - Float64.................... float64 cosh(float64 x).................... {.................... return ((exp(x)+exp(-x))/2);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float sinh(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : Computes the hyperbolic sine value of x.................... // Returns : returns the hyperbolic sine value of x.................... // Date : N/A.................... //........................................ float32 sinh(float32 x).................... {........................................ return ((exp(x) - exp(-x))/2);.................... }.................... //Overloaded functions for sinh() for PCD.................... // Overloaded function sinh() for data type - Float48.................... #if defined(__PCD__).................... float48 sinh(float48 x).................... {........................................ return ((exp(x) - exp(-x))/2);.................... }........................................ // Overloaded function sinh() for data type - Float48.................... float64 sinh(float64 x).................... {........................................ return ((exp(x) - exp(-x))/2);.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float tanh(float x).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : Computes the hyperbolic tangent value of x.................... // Returns : returns the hyperbolic tangent value of x.................... // Date : N/A.................... //........................................ float32 tanh(float32 x).................... {.................... return(sinh(x)/cosh(x));.................... }.................... //Overloaded functions for tanh() for PCD.................... // Overloaded function tanh() for data type - Float48.................... #if defined(__PCD__).................... float48 tanh(float48 x).................... {.................... return(sinh(x)/cosh(x));.................... }........................................ // Overloaded function tanh() for data type - Float64.................... float64 tanh(float64 x).................... {.................... return(sinh(x)/cosh(x));.................... }.................... #endif........................................ ////////////////////////////////////////////////////////////////////////////.................... // float frexp(float x, signed int *exp).................... ////////////////////////////////////////////////////////////////////////////.................... // Description : breaks a floating point number into a normalized fraction and an integral.................... // power of 2. It stores the integer in the signed int object pointed to by exp..................... // Returns : returns the value x, such that x is a double with magnitude in the interval.................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero,.................... // both parts of the result are zero..................... // Date : N/A.................... //........................................ #define LOG2 .30102999566398119521.................... float32 frexp(float32 x, signed int8 *exp).................... {.................... float32 res;.................... int1 sign = 0;.................... if(x == 0.0).................... {.................... *exp=0;.................... return (0.0);.................... }.................... if(x < 0.0).................... {.................... x=-x;.................... sign=1;.................... }.................... if (x > 1.0).................... {.................... *exp=(ceil(log10(x)/LOG2));.................... res=x/(pow(2, *exp));.................... if (res == 1).................... {.................... *exp=*exp+1;.................... res=.5;.................... }.................... }.................... else.................... {.................... if(x < 0.5).................... {.................... *exp=-1;.................... res=x*2;.................... }.................... else.................... {.................... *exp=0;.................... res=x;.................... }.................... }.................... if(sign).................... {.................... res=-res;.................... }.................... return res;.................... }........................................ //Overloaded functions for frexp() for PCD.................... // Overloaded function frexp() for data type - Float48.................... #if defined(__PCD__).................... float48 frexp(float48 x, signed int8 *exp).................... {.................... float48 res;.................... int1 sign = 0;.................... if(x == 0.0).................... {.................... *exp=0;.................... return (0.0);.................... }.................... if(x < 0.0).................... {.................... x=-x;.................... sign=1;.................... }.................... if (x > 1.0).................... {.................... *exp=(ceil(log10(x)/LOG2));.................... res=x/(pow(2, *exp));.................... if (res == 1).................... {.................... *exp=*exp+1;.................... res=.5;.................... }.................... }.................... else.................... {.................... if(x < 0.5).................... {.................... *exp=-1;.................... res=x*2;.................... }.................... else.................... {.................... *exp=0;.................... res=x;.................... }.................... }.................... if(sign).................... {.................... res=-res;.................... }.................... return res;.................... }........................................ // Overloaded function frexp() for data type - Float64.................... float64 frexp(float64 x, signed int8 *exp).................... {.................... float64 res;.................... int1 sign = 0;.................... if(x == 0.0).................... {.................... *exp=0;.................... return (0.0);.................... }.................... if(x < 0.0).................... {.................... x=-x;.................... sign=1;.................... }.................... if (x > 1.0).................... {.................... *exp=(ceil(log10(x)/LOG2));.................... res=x/(pow(2, *exp));.................... if (res == 1).................... {.................... *exp=*exp+1;.................... res=.5;.................... }.................... }.................... else.................... {.................... if(x < 0.5).................... {.................... *exp=-1;.................... res=x*2;.................... }.................... else.................... {.................... *exp=0;.................... res=x;.................... }.................... }.................... if(sign).................... {.................... res=-res;.................... }.................... return res;.................... }.................... #endif........................................ //////////////////////////////////////////////////////////////////////////////.................... // float ldexp(float x, signed int *exp).................... //////////////////////////////////////////////////////////////////////////////.................... // Description : multiplies a floating point number by an integral power of 2..................... // Returns : returns the value of x times 2 raised to the power exp..................... // Date : N/A.................... //........................................ float32 ldexp(float32 value, signed int8 exp).................... {.................... return (value * pow(2,exp));.................... }.................... //Overloaded functions for ldexp() for PCD.................... // Overloaded function ldexp() for data type - Float48........................................ #if defined(__PCD__).................... float48 ldexp(float48 value, signed int8 exp).................... {.................... return (value * pow(2,exp));.................... }.................... // Overloaded function ldexp() for data type - Float64.................... float64 ldexp(float64 value, signed int8 exp).................... {.................... return (value * pow(2,exp));.................... }.................... #endif........................................ #endif........................................ #include <MMA8451Q.h>.................... //Adresa obvodu.................... #define AK_W 0x38 //adresa akcelerometru zápis.................... #define AK_R 0x39 //adresa akcelerometru ètení............................................................ #define AK_XH 0x01 //osa X LSB.................... #define AK_XL 0x02 //osa X MSB.................... #define AK_YH 0x03 //osa Y LSB.................... #define AK_YL 0x04 //osa Y MSB.................... #define AK_ZH 0x05 //osa Z LSB.................... #define AK_ZL 0x06 //osa Z MSB............................................................ #include "MMA8451Q.c".................... void setAK (void) //nastaveni akcelerometru.................... {.................... i2c_start();*008B: BSF 20.4008C: MOVF 20,W008D: BSF 03.5008E: MOVWF 07008F: NOP0090: BCF 03.50091: BSF 20.30092: MOVF 20,W0093: BSF 03.50094: MOVWF 070095: NOP0096: BCF 03.50097: BCF 07.40098: BCF 20.40099: MOVF 20,W009A: BSF 03.5009B: MOVWF 07009C: NOP009D: BCF 03.5009E: BCF 07.3009F: BCF 20.300A0: MOVF 20,W00A1: BSF 03.500A2: MOVWF 07.................... I2C_Write(AK_W);00A3: MOVLW 3800A4: BCF 03.500A5: MOVWF 2F00A6: CALL 041.................... I2C_write(0x2A);00A7: MOVLW 2A00A8: MOVWF 2F00A9: CALL 041.................... I2C_write(0x01); //nastavi aktivni stav00AA: MOVLW 0100AB: MOVWF 2F00AC: CALL 041........................................ i2c_stop();00AD: BCF 20.400AE: MOVF 20,W00AF: BSF 03.500B0: MOVWF 0700B1: NOP00B2: BCF 03.500B3: BSF 20.300B4: MOVF 20,W00B5: BSF 03.500B6: MOVWF 0700B7: BCF 03.500B8: BTFSS 07.300B9: GOTO 0B800BA: NOP00BB: GOTO 0BC00BC: NOP00BD: BSF 20.400BE: MOVF 20,W00BF: BSF 03.500C0: MOVWF 0700C1: NOP.................... }00C2: BCF 03.500C3: BCF 0A.300C4: BCF 0A.400C5: GOTO 3FF (RETURN)............................................................ int16 akR (int8 H, int8 L) //vycitani hodnot z akcelerometru.................... {*0175: CLRF 2B0176: CLRF 2C.................... unsigned int8 XL=0,XH=0;.................... signed int16 x;........................................ i2c_start();0177: BSF 20.40178: MOVF 20,W0179: BSF 03.5017A: MOVWF 07017B: NOP017C: BCF 03.5017D: BSF 20.3017E: MOVF 20,W017F: BSF 03.50180: MOVWF 070181: NOP0182: BCF 03.50183: BCF 07.40184: BCF 20.40185: MOVF 20,W0186: BSF 03.50187: MOVWF 070188: NOP0189: BCF 03.5018A: BCF 07.3018B: BCF 20.3018C: MOVF 20,W018D: BSF 03.5018E: MOVWF 07.................... I2C_Write(AK_W);018F: MOVLW 380190: BCF 03.50191: MOVWF 2F0192: CALL 041.................... I2C_write(H);0193: MOVF 29,W0194: MOVWF 2F0195: CALL 041.................... i2c_start();0196: BSF 20.40197: MOVF 20,W0198: BSF 03.50199: MOVWF 07019A: NOP019B: BCF 03.5019C: BSF 20.3019D: MOVF 20,W019E: BSF 03.5019F: MOVWF 0701A0: NOP01A1: BCF 03.501A2: BTFSS 07.301A3: GOTO 1A201A4: BCF 07.401A5: BCF 20.401A6: MOVF 20,W01A7: BSF 03.501A8: MOVWF 0701A9: NOP01AA: BCF 03.501AB: BCF 07.301AC: BCF 20.301AD: MOVF 20,W01AE: BSF 03.501AF: MOVWF 07.................... I2C_Write(AK_R);01B0: MOVLW 3901B1: BCF 03.501B2: MOVWF 2F01B3: CALL 041.................... XH=i2c_read(0);01B4: CLRF 7701B5: CALL 13001B6: MOVF 78,W01B7: MOVWF 2C.................... i2c_stop();01B8: BCF 20.401B9: MOVF 20,W01BA: BSF 03.501BB: MOVWF 0701BC: NOP01BD: BCF 03.501BE: BSF 20.301BF: MOVF 20,W01C0: BSF 03.501C1: MOVWF 0701C2: BCF 03.501C3: BTFSS 07.301C4: GOTO 1C301C5: NOP01C6: GOTO 1C701C7: NOP01C8: BSF 20.401C9: MOVF 20,W01CA: BSF 03.501CB: MOVWF 0701CC: NOP........................................ i2c_start();01CD: BCF 03.501CE: BSF 20.401CF: MOVF 20,W01D0: BSF 03.501D1: MOVWF 0701D2: NOP01D3: BCF 03.501D4: BSF 20.301D5: MOVF 20,W01D6: BSF 03.501D7: MOVWF 0701D8: NOP01D9: BCF 03.501DA: BCF 07.401DB: BCF 20.401DC: MOVF 20,W01DD: BSF 03.501DE: MOVWF 0701DF: NOP01E0: BCF 03.501E1: BCF 07.301E2: BCF 20.301E3: MOVF 20,W01E4: BSF 03.501E5: MOVWF 07.................... I2C_Write(AK_W);01E6: MOVLW 3801E7: BCF 03.501E8: MOVWF 2F01E9: CALL 041.................... I2C_write(L);01EA: MOVF 2A,W01EB: MOVWF 2F01EC: CALL 041.................... i2c_start();01ED: BSF 20.401EE: MOVF 20,W01EF: BSF 03.501F0: MOVWF 0701F1: NOP01F2: BCF 03.501F3: BSF 20.301F4: MOVF 20,W01F5: BSF 03.501F6: MOVWF 0701F7: NOP01F8: BCF 03.501F9: BTFSS 07.301FA: GOTO 1F901FB: BCF 07.401FC: BCF 20.401FD: MOVF 20,W01FE: BSF 03.501FF: MOVWF 070200: NOP0201: BCF 03.50202: BCF 07.30203: BCF 20.30204: MOVF 20,W0205: BSF 03.50206: MOVWF 07.................... I2C_Write(AK_R);0207: MOVLW 390208: BCF 03.50209: MOVWF 2F020A: CALL 041.................... XL=i2c_read(0);020B: CLRF 77020C: CALL 130020D: MOVF 78,W020E: MOVWF 2B.................... i2c_stop();020F: BCF 20.40210: MOVF 20,W0211: BSF 03.50212: MOVWF 070213: NOP0214: BCF 03.50215: BSF 20.30216: MOVF 20,W0217: BSF 03.50218: MOVWF 070219: BCF 03.5021A: BTFSS 07.3021B: GOTO 21A021C: NOP021D: GOTO 21E021E: NOP021F: BSF 20.40220: MOVF 20,W0221: BSF 03.50222: MOVWF 070223: NOP........................................ x = (((unsigned int16) XH << 8) + XL ); //prevod na 16bit hodnotu0224: BCF 03.50225: CLRF 300226: MOVF 2C,W0227: MOVWF 2F0228: MOVWF 300229: CLRF 2F022A: MOVF 2B,W022B: ADDWF 2F,W022C: MOVWF 78022D: MOVF 30,W022E: MOVWF 7A022F: BTFSC 03.00230: INCF 7A,F0231: MOVF 78,W0232: MOVWF 2D0233: MOVF 7A,W0234: MOVWF 2E.................... x=x/4;0235: MOVF 2E,W0236: MOVWF 300237: MOVF 2D,W0238: MOVWF 2F0239: CLRF 32023A: MOVLW 04023B: MOVWF 31*0279: MOVF 79,W027A: MOVWF 2E027B: MOVF 78,W027C: MOVWF 2D........................................ return x;027D: MOVF 2D,W027E: MOVWF 78027F: MOVF 2E,W0280: MOVWF 79.................... }0281: RETURN........................................ int16 akX (void).................... {.................... int16 X;.................... X= akR (AK_XH, AK_XL);0282: MOVLW 010283: MOVWF 290284: MOVLW 020285: MOVWF 2A0286: CALL 1750287: MOVF 79,W0288: MOVWF 280289: MOVF 78,W028A: MOVWF 27.................... return X;028B: MOVF 27,W028C: MOVWF 78028D: MOVF 28,W028E: MOVWF 79.................... }028F: BCF 0A.30290: BCF 0A.40291: GOTO 40E (RETURN)........................................ int16 akY (void).................... {.................... int16 Y;.................... Y= akR (AK_YH, AK_YL);0292: MOVLW 030293: MOVWF 290294: MOVLW 040295: MOVWF 2A0296: CALL 1750297: MOVF 79,W0298: MOVWF 280299: MOVF 78,W029A: MOVWF 27.................... return Y;029B: MOVF 27,W029C: MOVWF 78029D: MOVF 28,W029E: MOVWF 79.................... }029F: BCF 0A.302A0: BCF 0A.402A1: GOTO 413 (RETURN)........................................ int16 akZ (void).................... {.................... int16 Z;.................... Z= akR (AK_ZH, AK_ZL);02A2: MOVLW 0502A3: MOVWF 2902A4: MOVLW 0602A5: MOVWF 2A02A6: CALL 17502A7: MOVF 79,W02A8: MOVWF 2802A9: MOVF 78,W02AA: MOVWF 27.................... return Z;02AB: MOVF 27,W02AC: MOVWF 7802AD: MOVF 28,W02AE: MOVWF 79.................... }02AF: BCF 0A.302B0: BCF 0A.402B1: GOTO 418 (RETURN)........................................................................................................................ signed int16 X, Y, Z; //promenne pro akcelerometr........................................ void main().................... {*0397: CLRF 040398: BCF 03.70399: MOVLW 1F039A: ANDWF 03,F039B: MOVLW 71039C: BSF 03.5039D: MOVWF 0F039E: MOVF 0F,W039F: BCF 03.503A0: BCF 20.703A1: MOVF 20,W03A2: BSF 03.503A3: MOVWF 0703A4: BCF 03.503A5: BSF 07.703A6: BSF 03.503A7: BSF 03.603A8: MOVF 09,W03A9: ANDLW C003AA: MOVWF 0903AB: BCF 03.603AC: BCF 1F.403AD: BCF 1F.503AE: MOVLW 0003AF: BSF 03.603B0: MOVWF 0803B1: BCF 03.503B2: CLRF 0703B3: CLRF 0803B4: CLRF 09.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);*03B8: BSF 03.503B9: BSF 03.603BA: MOVF 09,W03BB: ANDLW C003BC: MOVWF 0903BD: BCF 03.603BE: BCF 1F.403BF: BCF 1F.503C0: MOVLW 0003C1: BSF 03.603C2: MOVWF 08.................... setup_adc(ADC_CLOCK_DIV_2);03C3: BCF 03.503C4: BCF 03.603C5: BCF 1F.603C6: BCF 1F.703C7: BSF 03.503C8: BCF 1F.703C9: BCF 03.503CA: BSF 1F.0.................... setup_spi(SPI_SS_DISABLED);03CB: BCF 14.503CC: BCF 20.503CD: MOVF 20,W03CE: BSF 03.503CF: MOVWF 0703D0: BCF 03.503D1: BSF 20.403D2: MOVF 20,W03D3: BSF 03.503D4: MOVWF 0703D5: BCF 03.503D6: BCF 20.303D7: MOVF 20,W03D8: BSF 03.503D9: MOVWF 0703DA: MOVLW 0103DB: BCF 03.503DC: MOVWF 1403DD: MOVLW 0003DE: BSF 03.503DF: MOVWF 14.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);03E0: MOVF 01,W03E1: ANDLW C703E2: IORLW 0803E3: MOVWF 01.................... setup_timer_1(T1_DISABLED);03E4: BCF 03.503E5: CLRF 10.................... setup_timer_2(T2_DISABLED,0,1);03E6: MOVLW 0003E7: MOVWF 7803E8: MOVWF 1203E9: MOVLW 0003EA: BSF 03.503EB: MOVWF 12.................... setup_ccp1(CCP_OFF);03EC: BCF 03.503ED: BSF 20.203EE: MOVF 20,W03EF: BSF 03.503F0: MOVWF 0703F1: BCF 03.503F2: CLRF 1703F3: BSF 03.503F4: CLRF 1B03F5: CLRF 1C03F6: MOVLW 0103F7: MOVWF 1D.................... setup_comparator(NC_NC_NC_NC);03F8: BCF 03.503F9: BSF 03.603FA: CLRF 0703FB: CLRF 0803FC: CLRF 09........................................ setAK(); //nastaveni akcelerometru03FD: BCF 03.603FE: GOTO 08B........................................ printf("Akcelerometr IMU01A - MMA8451Q \r\n",);03FF: MOVLW 040400: BSF 03.60401: MOVWF 0D0402: MOVLW 000403: MOVWF 0F0404: BCF 03.60405: CALL 0EA.................... printf("(c) MLAB JACHO 2013 \r\n",);0406: MOVLW 150407: BSF 03.60408: MOVWF 0D0409: MOVLW 00040A: MOVWF 0F040B: BCF 03.6040C: CALL 0EA........................................ while(TRUE).................... {.................... X=akX ();040D: GOTO 282040E: MOVF 79,W040F: MOVWF 220410: MOVF 78,W0411: MOVWF 21.................... Y=akY ();0412: GOTO 2920413: MOVF 79,W0414: MOVWF 240415: MOVF 78,W0416: MOVWF 23.................... Z=akZ ();0417: GOTO 2A20418: MOVF 79,W0419: MOVWF 26041A: MOVF 78,W041B: MOVWF 25.................... printf("Namerene hodnoty: \r\n",);041C: MOVLW 21041D: BSF 03.6041E: MOVWF 0D041F: MOVLW 000420: MOVWF 0F0421: BCF 03.60422: CALL 0EA.................... printf("Osa X: %Ld \r\n",X);0423: MOVLW 2C0424: BSF 03.60425: MOVWF 0D0426: MOVLW 000427: MOVWF 0F0428: BCF 03.00429: MOVLW 07042A: BCF 03.6042B: MOVWF 27042C: CALL 2B2042D: MOVLW 10042E: MOVWF 04042F: MOVF 22,W0430: MOVWF 280431: MOVF 21,W0432: MOVWF 270433: CALL 3010434: MOVLW 200435: MOVWF 300436: CALL 0C60437: MOVLW 0D0438: MOVWF 300439: CALL 0C6043A: MOVLW 0A043B: MOVWF 30043C: CALL 0C6.................... printf("Osa Y: %Ld \r\n",Y);043D: MOVLW 33043E: BSF 03.6043F: MOVWF 0D0440: MOVLW 000441: MOVWF 0F0442: BCF 03.00443: MOVLW 070444: BCF 03.60445: MOVWF 270446: CALL 2B20447: MOVLW 100448: MOVWF 040449: MOVF 24,W044A: MOVWF 28044B: MOVF 23,W044C: MOVWF 27044D: CALL 301044E: MOVLW 20044F: MOVWF 300450: CALL 0C60451: MOVLW 0D0452: MOVWF 300453: CALL 0C60454: MOVLW 0A0455: MOVWF 300456: CALL 0C6.................... printf("Osa Z: %Ld \r\n",Z);0457: MOVLW 3A0458: BSF 03.60459: MOVWF 0D045A: MOVLW 00045B: MOVWF 0F045C: BCF 03.0045D: MOVLW 07045E: BCF 03.6045F: MOVWF 270460: CALL 2B20461: MOVLW 100462: MOVWF 040463: MOVF 26,W0464: MOVWF 280465: MOVF 25,W0466: MOVWF 270467: CALL 3010468: MOVLW 200469: MOVWF 30046A: CALL 0C6046B: MOVLW 0D046C: MOVWF 30046D: CALL 0C6046E: MOVLW 0A046F: MOVWF 300470: CALL 0C6.................... delay_ms (2000);0471: MOVLW 080472: MOVWF 270473: MOVLW FA0474: MOVWF 280475: GOTO 3810476: DECFSZ 27,F0477: GOTO 473........................................ }0478: GOTO 40D.................... }....................0479: SLEEPConfiguration Fuses:Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUGWord 2: 3FFF NOWRT BORV40