CCS PCM C Compiler, Version 4.106, 47914 10-IX-13 13:59
Filename: Z:\home\kaklik\svnMLAB\Designs\Measuring_instruments\GeoMet01A\SW\PIC16F887\main.lst
ROM used: 3809 words (46%)
Largest free fragment is 2048
RAM used: 35 (10%) at main() level
72 (20%) worst case
Stack: 5 locations
*
0000: MOVLW 0C
0001: MOVWF 0A
0002: GOTO 4E5
0003: NOP
.................... #include "main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
.................... #device PIC16F887
.................... #list
....................
.................... #device adc=10
....................
.................... #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)
*
00FB: MOVLW 4B
00FC: MOVWF 04
00FD: BCF 03.7
00FE: MOVF 00,W
00FF: BTFSC 03.2
0100: GOTO 10E
0101: MOVLW 02
0102: MOVWF 78
0103: CLRF 77
0104: DECFSZ 77,F
0105: GOTO 104
0106: DECFSZ 78,F
0107: GOTO 103
0108: MOVLW 97
0109: MOVWF 77
010A: DECFSZ 77,F
010B: GOTO 10A
010C: DECFSZ 00,F
010D: GOTO 101
010E: RETURN
.................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
*
0078: MOVLW 08
0079: MOVWF 78
007A: NOP
007B: BCF 07.3
007C: BCF 20.3
007D: MOVF 20,W
007E: BSF 03.5
007F: MOVWF 07
0080: NOP
0081: BCF 03.5
0082: RLF 4E,F
0083: BCF 07.4
0084: BTFSS 03.0
0085: GOTO 08C
0086: BSF 20.4
0087: MOVF 20,W
0088: BSF 03.5
0089: MOVWF 07
008A: GOTO 090
008B: BCF 03.5
008C: BCF 20.4
008D: MOVF 20,W
008E: BSF 03.5
008F: MOVWF 07
0090: NOP
0091: BCF 03.5
0092: BSF 20.3
0093: MOVF 20,W
0094: BSF 03.5
0095: MOVWF 07
0096: BCF 03.5
0097: BTFSS 07.3
0098: GOTO 097
0099: DECFSZ 78,F
009A: GOTO 07A
009B: NOP
009C: BCF 07.3
009D: BCF 20.3
009E: MOVF 20,W
009F: BSF 03.5
00A0: MOVWF 07
00A1: NOP
00A2: BCF 03.5
00A3: BSF 20.4
00A4: MOVF 20,W
00A5: BSF 03.5
00A6: MOVWF 07
00A7: NOP
00A8: NOP
00A9: BCF 03.5
00AA: BSF 20.3
00AB: MOVF 20,W
00AC: BSF 03.5
00AD: MOVWF 07
00AE: BCF 03.5
00AF: BTFSS 07.3
00B0: GOTO 0AF
00B1: CLRF 78
00B2: NOP
00B3: BTFSC 07.4
00B4: BSF 78.0
00B5: BCF 07.3
00B6: BCF 20.3
00B7: MOVF 20,W
00B8: BSF 03.5
00B9: MOVWF 07
00BA: BCF 03.5
00BB: BCF 07.4
00BC: BCF 20.4
00BD: MOVF 20,W
00BE: BSF 03.5
00BF: MOVWF 07
00C0: BCF 03.5
00C1: RETURN
*
0285: MOVLW 08
0286: MOVWF 4F
0287: MOVF 77,W
0288: MOVWF 50
0289: BSF 20.4
028A: MOVF 20,W
028B: BSF 03.5
028C: MOVWF 07
028D: NOP
028E: BCF 03.5
028F: BSF 20.3
0290: MOVF 20,W
0291: BSF 03.5
0292: MOVWF 07
0293: BCF 03.5
0294: BTFSS 07.3
0295: GOTO 294
0296: BTFSC 07.4
0297: BSF 03.0
0298: BTFSS 07.4
0299: BCF 03.0
029A: RLF 78,F
029B: NOP
029C: BCF 20.3
029D: MOVF 20,W
029E: BSF 03.5
029F: MOVWF 07
02A0: BCF 03.5
02A1: BCF 07.3
02A2: DECFSZ 4F,F
02A3: GOTO 289
02A4: BSF 20.4
02A5: MOVF 20,W
02A6: BSF 03.5
02A7: MOVWF 07
02A8: NOP
02A9: BCF 03.5
02AA: BCF 07.4
02AB: MOVF 50,W
02AC: BTFSC 03.2
02AD: GOTO 2B3
02AE: BCF 20.4
02AF: MOVF 20,W
02B0: BSF 03.5
02B1: MOVWF 07
02B2: BCF 03.5
02B3: NOP
02B4: BSF 20.3
02B5: MOVF 20,W
02B6: BSF 03.5
02B7: MOVWF 07
02B8: BCF 03.5
02B9: BTFSS 07.3
02BA: GOTO 2B9
02BB: NOP
02BC: BCF 07.3
02BD: BCF 20.3
02BE: MOVF 20,W
02BF: BSF 03.5
02C0: MOVWF 07
02C1: NOP
02C2: BCF 03.5
02C3: BCF 07.4
02C4: BCF 20.4
02C5: MOVF 20,W
02C6: BSF 03.5
02C7: MOVWF 07
02C8: BCF 03.5
02C9: RETURN
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
....................
....................
....................
.................... #define LCD_ENABLE_PIN PIN_E0 ////
.................... #define LCD_RS_PIN PIN_E1 ////
.................... #define LCD_RW_PIN PIN_E2 ////
.................... #define LCD_DATA4 PIN_D4 ////
.................... #define LCD_DATA5 PIN_D5 ////
.................... #define LCD_DATA6 PIN_D6 ////
.................... #define LCD_DATA7 PIN_D7
.................... #include <lcd.c>
.................... ///////////////////////////////////////////////////////////////////////////////
.................... //// LCD.C ////
.................... //// Driver for common LCD modules ////
.................... //// ////
.................... //// lcd_init() Must be called before any other function. ////
.................... //// ////
.................... //// lcd_putc(c) Will display c on the next position of the LCD. ////
.................... //// \a Set cursor position to upper left ////
.................... //// \f Clear display, set cursor to upper left ////
.................... //// \n Go to start of second line ////
.................... //// \b Move back one position ////
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character ////
.................... //// will erase all remanining characters on the current ////
.................... //// line, and move the cursor to the beginning of the next ////
.................... //// line. ////
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character ////
.................... //// will move the cursor to the start of the current ////
.................... //// line. ////
.................... //// ////
.................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
.................... //// ////
.................... //// lcd_getc(x,y) Returns character at position x,y on LCD ////
.................... //// ////
.................... //// CONFIGURATION ////
.................... //// The LCD can be configured in one of two ways: a.) port access or ////
.................... //// b.) pin access. Port access requires the entire 7 bit interface ////
.................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) ////
.................... //// connected to sequential pins on the GPIO. Pin access ////
.................... //// has no requirements, all 7 bits of the control interface can ////
.................... //// can be connected to any GPIO using several ports. ////
.................... //// ////
.................... //// To use port access, #define LCD_DATA_PORT to the SFR location of ////
.................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////
.................... //// of this file to configure the pin order. If you are using a ////
.................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////
.................... //// be defined. ////
.................... //// ////
.................... //// Example of port access: ////
.................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") ////
.................... //// ////
.................... //// To use pin access, the following pins must be defined: ////
.................... //// LCD_ENABLE_PIN ////
.................... //// LCD_RS_PIN ////
.................... //// LCD_RW_PIN ////
.................... //// LCD_DATA4 ////
.................... //// LCD_DATA5 ////
.................... //// LCD_DATA6 ////
.................... //// LCD_DATA7 ////
.................... //// ////
.................... //// Example of pin access: ////
.................... //// #define LCD_ENABLE_PIN PIN_E0 ////
.................... //// #define LCD_RS_PIN PIN_E1 ////
.................... //// #define LCD_RW_PIN PIN_E2 ////
.................... //// #define LCD_DATA4 PIN_D4 ////
.................... //// #define LCD_DATA5 PIN_D5 ////
.................... //// #define LCD_DATA6 PIN_D6 ////
.................... //// #define LCD_DATA7 PIN_D7 ////
.................... //// ////
.................... ///////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2010 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. ////
.................... ///////////////////////////////////////////////////////////////////////////
....................
.................... // define the pinout.
.................... // only required if port access is being used.
.................... typedef struct
.................... { // This structure is overlayed
.................... BOOLEAN enable; // on to an I/O port to gain
.................... BOOLEAN rs; // access to the LCD pins.
.................... BOOLEAN rw; // The bits are allocated from
.................... BOOLEAN unused; // low order up. ENABLE will
.................... int data : 4; // be LSB pin of that port.
.................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT.
.................... int reserved: 8;
.................... #endif
.................... } LCD_PIN_MAP;
....................
.................... // this is to improve compatability with previous LCD drivers that accepted
.................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
.................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
.................... #define LCD_DATA_PORT getenv("SFR:PORTB")
.................... #endif
....................
.................... #if defined(__PCB__)
.................... // these definitions only need to be modified for baseline PICs.
.................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
.................... /* EN, RS, RW, UNUSED, DATA */
.................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0};
.................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF};
.................... #endif
....................
.................... ////////////////////// END CONFIGURATION ///////////////////////////////////
....................
.................... #ifndef LCD_ENABLE_PIN
.................... #define lcd_output_enable(x) lcdlat.enable=x
.................... #define lcd_enable_tris() lcdtris.enable=0
.................... #else
.................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
.................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN)
.................... #endif
....................
.................... #ifndef LCD_RS_PIN
.................... #define lcd_output_rs(x) lcdlat.rs=x
.................... #define lcd_rs_tris() lcdtris.rs=0
.................... #else
.................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
.................... #define lcd_rs_tris() output_drive(LCD_RS_PIN)
.................... #endif
....................
.................... #ifndef LCD_RW_PIN
.................... #define lcd_output_rw(x) lcdlat.rw=x
.................... #define lcd_rw_tris() lcdtris.rw=0
.................... #else
.................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
.................... #define lcd_rw_tris() output_drive(LCD_RW_PIN)
.................... #endif
....................
.................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
.................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver
.................... // compatible with any code written for the original library
.................... #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
.................... #define LCD_DATA4 LCD_DATA0
.................... #define LCD_DATA5 LCD_DATA1
.................... #define LCD_DATA6 LCD_DATA2
.................... #define LCD_DATA7 LCD_DATA3
.................... #endif
....................
.................... #ifndef LCD_DATA4
.................... #ifndef LCD_DATA_PORT
.................... #if defined(__PCB__)
.................... #define LCD_DATA_PORT 0x06 //portb
.................... #define set_tris_lcd(x) set_tris_b(x)
.................... #else
.................... #if defined(PIN_D0)
.................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd
.................... #else
.................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb
.................... #endif
.................... #endif
.................... #endif
....................
.................... #if defined(__PCB__)
.................... LCD_PIN_MAP lcd, lcdlat;
.................... #byte lcd = LCD_DATA_PORT
.................... #byte lcdlat = LCD_DATA_PORT
.................... #elif defined(__PCM__)
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
.................... #byte lcd = LCD_DATA_PORT
.................... #byte lcdlat = LCD_DATA_PORT
.................... #byte lcdtris = LCD_DATA_PORT+0x80
.................... #elif defined(__PCH__)
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
.................... #byte lcd = LCD_DATA_PORT
.................... #byte lcdlat = LCD_DATA_PORT+9
.................... #byte lcdtris = LCD_DATA_PORT+0x12
.................... #elif defined(__PCD__)
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
.................... #word lcd = LCD_DATA_PORT
.................... #word lcdlat = LCD_DATA_PORT+2
.................... #word lcdtris = LCD_DATA_PORT-0x02
.................... #endif
.................... #endif //LCD_DATA4 not defined
....................
.................... #ifndef LCD_TYPE
.................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines
.................... #endif
....................
.................... #ifndef LCD_LINE_TWO
.................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line
.................... #endif
....................
.................... #ifndef LCD_LINE_LENGTH
.................... #define LCD_LINE_LENGTH 20
.................... #endif
....................
.................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
.................... // These bytes need to be sent to the LCD
.................... // to start it up.
....................
.................... BYTE lcd_read_nibble(void);
....................
.................... BYTE lcd_read_byte(void)
.................... {
.................... BYTE low,high;
....................
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_INPUT_MAP);
.................... #else
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... output_float(LCD_DATA4);
*
0174: BSF 08.4
.................... output_float(LCD_DATA5);
0175: BSF 08.5
.................... output_float(LCD_DATA6);
0176: BSF 08.6
.................... output_float(LCD_DATA7);
0177: BSF 08.7
.................... #else
.................... lcdtris.data = 0xF;
.................... #endif
.................... #endif
....................
.................... lcd_output_rw(1);
0178: BCF 03.5
0179: BSF 09.2
017A: BSF 03.5
017B: BCF 09.2
.................... delay_cycles(1);
017C: NOP
.................... lcd_output_enable(1);
017D: BCF 03.5
017E: BSF 09.0
017F: BSF 03.5
0180: BCF 09.0
.................... delay_cycles(1);
0181: NOP
.................... high = lcd_read_nibble();
0182: BCF 03.5
0183: CALL 13B
0184: MOVF 78,W
0185: MOVWF 52
....................
.................... lcd_output_enable(0);
0186: BCF 09.0
0187: BSF 03.5
0188: BCF 09.0
.................... delay_cycles(1);
0189: NOP
.................... lcd_output_enable(1);
018A: BCF 03.5
018B: BSF 09.0
018C: BSF 03.5
018D: BCF 09.0
.................... delay_us(1);
018E: GOTO 18F
.................... low = lcd_read_nibble();
018F: BCF 03.5
0190: CALL 13B
0191: MOVF 78,W
0192: MOVWF 51
....................
.................... lcd_output_enable(0);
0193: BCF 09.0
0194: BSF 03.5
0195: BCF 09.0
....................
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_OUTPUT_MAP);
.................... #else
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... output_drive(LCD_DATA4);
0196: BCF 08.4
.................... output_drive(LCD_DATA5);
0197: BCF 08.5
.................... output_drive(LCD_DATA6);
0198: BCF 08.6
.................... output_drive(LCD_DATA7);
0199: BCF 08.7
.................... #else
.................... lcdtris.data = 0x0;
.................... #endif
.................... #endif
....................
.................... return( (high<<4) | low);
019A: BCF 03.5
019B: SWAPF 52,W
019C: MOVWF 77
019D: MOVLW F0
019E: ANDWF 77,F
019F: MOVF 77,W
01A0: IORWF 51,W
01A1: MOVWF 78
.................... }
....................
.................... BYTE lcd_read_nibble(void)
.................... {
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
*
013B: CLRF 53
.................... BYTE n = 0x00;
....................
.................... /* Read the data port */
.................... n |= input(LCD_DATA4);
013C: BSF 03.5
013D: BSF 08.4
013E: MOVLW 00
013F: BCF 03.5
0140: BTFSC 08.4
0141: MOVLW 01
0142: IORWF 53,F
.................... n |= input(LCD_DATA5) << 1;
0143: BSF 03.5
0144: BSF 08.5
0145: MOVLW 00
0146: BCF 03.5
0147: BTFSC 08.5
0148: MOVLW 01
0149: MOVWF 77
014A: BCF 03.0
014B: RLF 77,F
014C: MOVF 77,W
014D: IORWF 53,F
.................... n |= input(LCD_DATA6) << 2;
014E: BSF 03.5
014F: BSF 08.6
0150: MOVLW 00
0151: BCF 03.5
0152: BTFSC 08.6
0153: MOVLW 01
0154: MOVWF 77
0155: RLF 77,F
0156: RLF 77,F
0157: MOVLW FC
0158: ANDWF 77,F
0159: MOVF 77,W
015A: IORWF 53,F
.................... n |= input(LCD_DATA7) << 3;
015B: BSF 03.5
015C: BSF 08.7
015D: MOVLW 00
015E: BCF 03.5
015F: BTFSC 08.7
0160: MOVLW 01
0161: MOVWF 77
0162: RLF 77,F
0163: RLF 77,F
0164: RLF 77,F
0165: MOVLW F8
0166: ANDWF 77,F
0167: MOVF 77,W
0168: IORWF 53,F
....................
.................... return(n);
0169: MOVF 53,W
016A: MOVWF 78
.................... #else
.................... return(lcd.data);
.................... #endif
.................... }
016B: RETURN
....................
.................... void lcd_send_nibble(BYTE n)
.................... {
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... /* Write to the data port */
.................... output_bit(LCD_DATA4, bit_test(n, 0));
*
010F: BTFSC 52.0
0110: GOTO 113
0111: BCF 08.4
0112: GOTO 114
0113: BSF 08.4
0114: BSF 03.5
0115: BCF 08.4
.................... output_bit(LCD_DATA5, bit_test(n, 1));
0116: BCF 03.5
0117: BTFSC 52.1
0118: GOTO 11B
0119: BCF 08.5
011A: GOTO 11C
011B: BSF 08.5
011C: BSF 03.5
011D: BCF 08.5
.................... output_bit(LCD_DATA6, bit_test(n, 2));
011E: BCF 03.5
011F: BTFSC 52.2
0120: GOTO 123
0121: BCF 08.6
0122: GOTO 124
0123: BSF 08.6
0124: BSF 03.5
0125: BCF 08.6
.................... output_bit(LCD_DATA7, bit_test(n, 3));
0126: BCF 03.5
0127: BTFSC 52.3
0128: GOTO 12B
0129: BCF 08.7
012A: GOTO 12C
012B: BSF 08.7
012C: BSF 03.5
012D: BCF 08.7
.................... #else
.................... lcdlat.data = n;
.................... #endif
....................
.................... delay_cycles(1);
012E: NOP
.................... lcd_output_enable(1);
012F: BCF 03.5
0130: BSF 09.0
0131: BSF 03.5
0132: BCF 09.0
.................... delay_us(2);
0133: GOTO 134
0134: GOTO 135
.................... lcd_output_enable(0);
0135: BCF 03.5
0136: BCF 09.0
0137: BSF 03.5
0138: BCF 09.0
.................... }
0139: BCF 03.5
013A: RETURN
....................
.................... void lcd_send_byte(BYTE address, BYTE n)
.................... {
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_OUTPUT_MAP);
.................... #else
.................... lcd_enable_tris();
*
016C: BSF 03.5
016D: BCF 09.0
.................... lcd_rs_tris();
016E: BCF 09.1
.................... lcd_rw_tris();
016F: BCF 09.2
.................... #endif
....................
.................... lcd_output_rs(0);
0170: BCF 03.5
0171: BCF 09.1
0172: BSF 03.5
0173: BCF 09.1
.................... while ( bit_test(lcd_read_byte(),7) ) ;
*
01A2: MOVF 78,W
01A3: MOVWF 51
01A4: BTFSS 51.7
01A5: GOTO 1A8
01A6: BSF 03.5
01A7: GOTO 174
.................... lcd_output_rs(address);
01A8: MOVF 4F,F
01A9: BTFSS 03.2
01AA: GOTO 1AD
01AB: BCF 09.1
01AC: GOTO 1AE
01AD: BSF 09.1
01AE: BSF 03.5
01AF: BCF 09.1
.................... delay_cycles(1);
01B0: NOP
.................... lcd_output_rw(0);
01B1: BCF 03.5
01B2: BCF 09.2
01B3: BSF 03.5
01B4: BCF 09.2
.................... delay_cycles(1);
01B5: NOP
.................... lcd_output_enable(0);
01B6: BCF 03.5
01B7: BCF 09.0
01B8: BSF 03.5
01B9: BCF 09.0
.................... lcd_send_nibble(n >> 4);
01BA: BCF 03.5
01BB: SWAPF 50,W
01BC: MOVWF 51
01BD: MOVLW 0F
01BE: ANDWF 51,F
01BF: MOVF 51,W
01C0: MOVWF 52
01C1: CALL 10F
.................... lcd_send_nibble(n & 0xf);
01C2: MOVF 50,W
01C3: ANDLW 0F
01C4: MOVWF 51
01C5: MOVWF 52
01C6: CALL 10F
.................... }
01C7: RETURN
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... unsigned int8 g_LcdX, g_LcdY;
.................... #endif
....................
.................... void lcd_init(void)
.................... {
.................... BYTE i;
....................
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_OUTPUT_MAP);
.................... #else
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... output_drive(LCD_DATA4);
01C8: BSF 03.5
01C9: BCF 08.4
.................... output_drive(LCD_DATA5);
01CA: BCF 08.5
.................... output_drive(LCD_DATA6);
01CB: BCF 08.6
.................... output_drive(LCD_DATA7);
01CC: BCF 08.7
.................... #else
.................... lcdtris.data = 0x0;
.................... #endif
.................... lcd_enable_tris();
01CD: BCF 09.0
.................... lcd_rs_tris();
01CE: BCF 09.1
.................... lcd_rw_tris();
01CF: BCF 09.2
.................... #endif
....................
.................... lcd_output_rs(0);
01D0: BCF 03.5
01D1: BCF 09.1
01D2: BSF 03.5
01D3: BCF 09.1
.................... lcd_output_rw(0);
01D4: BCF 03.5
01D5: BCF 09.2
01D6: BSF 03.5
01D7: BCF 09.2
.................... lcd_output_enable(0);
01D8: BCF 03.5
01D9: BCF 09.0
01DA: BSF 03.5
01DB: BCF 09.0
....................
.................... delay_ms(15);
01DC: MOVLW 0F
01DD: BCF 03.5
01DE: MOVWF 4B
01DF: CALL 0FB
.................... for(i=1;i<=3;++i)
01E0: MOVLW 01
01E1: MOVWF 3D
01E2: MOVF 3D,W
01E3: SUBLW 03
01E4: BTFSS 03.0
01E5: GOTO 1EE
.................... {
.................... lcd_send_nibble(3);
01E6: MOVLW 03
01E7: MOVWF 52
01E8: CALL 10F
.................... delay_ms(5);
01E9: MOVLW 05
01EA: MOVWF 4B
01EB: CALL 0FB
.................... }
01EC: INCF 3D,F
01ED: GOTO 1E2
....................
.................... lcd_send_nibble(2);
01EE: MOVLW 02
01EF: MOVWF 52
01F0: CALL 10F
.................... for(i=0;i<=3;++i)
01F1: CLRF 3D
01F2: MOVF 3D,W
01F3: SUBLW 03
01F4: BTFSS 03.0
01F5: GOTO 1FF
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
01F6: MOVF 3D,W
01F7: CALL 004
01F8: MOVWF 3E
01F9: CLRF 4F
01FA: MOVF 3E,W
01FB: MOVWF 50
01FC: CALL 16C
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
01FD: INCF 3D,F
01FE: GOTO 1F2
.................... g_LcdX = 0;
.................... g_LcdY = 0;
.................... #endif
.................... }
01FF: RETURN
....................
.................... void lcd_gotoxy(BYTE x, BYTE y)
.................... {
.................... BYTE address;
....................
.................... if(y!=1)
0200: DECFSZ 4C,W
0201: GOTO 203
0202: GOTO 206
.................... address=LCD_LINE_TWO;
0203: MOVLW 40
0204: MOVWF 4D
.................... else
0205: GOTO 207
.................... address=0;
0206: CLRF 4D
....................
.................... address+=x-1;
0207: MOVLW 01
0208: SUBWF 4B,W
0209: ADDWF 4D,F
.................... lcd_send_byte(0,0x80|address);
020A: MOVF 4D,W
020B: IORLW 80
020C: MOVWF 4E
020D: CLRF 4F
020E: MOVF 4E,W
020F: MOVWF 50
0210: CALL 16C
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... g_LcdX = x - 1;
.................... g_LcdY = y - 1;
.................... #endif
.................... }
0211: RETURN
....................
.................... void lcd_putc(char c)
.................... {
.................... switch (c)
.................... {
0212: MOVF 4A,W
0213: XORLW 07
0214: BTFSC 03.2
0215: GOTO 220
0216: XORLW 0B
0217: BTFSC 03.2
0218: GOTO 225
0219: XORLW 06
021A: BTFSC 03.2
021B: GOTO 22D
021C: XORLW 02
021D: BTFSC 03.2
021E: GOTO 233
021F: GOTO 238
.................... case '\a' : lcd_gotoxy(1,1); break;
0220: MOVLW 01
0221: MOVWF 4B
0222: MOVWF 4C
0223: CALL 200
0224: GOTO 23E
....................
.................... case '\f' : lcd_send_byte(0,1);
0225: CLRF 4F
0226: MOVLW 01
0227: MOVWF 50
0228: CALL 16C
.................... delay_ms(2);
0229: MOVLW 02
022A: MOVWF 4B
022B: CALL 0FB
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... g_LcdX = 0;
.................... g_LcdY = 0;
.................... #endif
.................... break;
022C: GOTO 23E
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break;
.................... case '\n' :
.................... while (g_LcdX++ < LCD_LINE_LENGTH)
.................... {
.................... lcd_send_byte(1, ' ');
.................... }
.................... lcd_gotoxy(1, g_LcdY+2);
.................... break;
.................... #else
.................... case '\n' : lcd_gotoxy(1,2); break;
022D: MOVLW 01
022E: MOVWF 4B
022F: MOVLW 02
0230: MOVWF 4C
0231: CALL 200
0232: GOTO 23E
.................... #endif
....................
.................... case '\b' : lcd_send_byte(0,0x10); break;
0233: CLRF 4F
0234: MOVLW 10
0235: MOVWF 50
0236: CALL 16C
0237: GOTO 23E
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... default :
.................... if (g_LcdX < LCD_LINE_LENGTH)
.................... {
.................... lcd_send_byte(1, c);
.................... g_LcdX++;
.................... }
.................... break;
.................... #else
.................... default : lcd_send_byte(1,c); break;
0238: MOVLW 01
0239: MOVWF 4F
023A: MOVF 4A,W
023B: MOVWF 50
023C: CALL 16C
023D: GOTO 23E
.................... #endif
.................... }
.................... }
023E: RETURN
....................
.................... char lcd_getc(BYTE x, BYTE y)
.................... {
.................... char value;
....................
.................... lcd_gotoxy(x,y);
.................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
.................... lcd_output_rs(1);
.................... value = lcd_read_byte();
.................... lcd_output_rs(0);
....................
.................... return(value);
.................... }
....................
....................
.................... #include "../SHT25.h"
....................
.................... #define SHT25_HEATER_ON 0x04
.................... #define SHT25_HEATER_OFF 0x00
.................... #define SHT25_OTP_reload_off 0x02
.................... #define SHT25_RH12_T14 0x00
.................... #define SHT25_RH8_T12 0x01
.................... #define SHT25_RH10_T13 0x80
.................... #define SHT25_RH11_T11 0x81
....................
.................... #define SHT25_ADDR 0x80
....................
.................... #include "SHT25.c"
.................... void SHT25_soft_reset()
.................... {
.................... i2c_start(); // Start condition
.................... i2c_write(0x80); // Device address
.................... i2c_write(0xFE); // Device command
.................... i2c_stop(); // Stop condition
.................... }
....................
.................... unsigned int8 SHT25_setup(unsigned int8 setup_reg ) // writes to status register and returns its value
.................... {
.................... unsigned int8 reg;
....................
.................... i2c_start(); // Start condition
.................... i2c_write(SHT25_ADDR); // Device address
.................... i2c_write(0xE7); // Device command
....................
.................... i2c_start(); // Start condition
.................... i2c_write(SHT25_ADDR+1); // Device address
.................... reg=i2c_read(0); // Read status actual status register
....................
.................... reg = (reg & 0x3A) | setup_reg;
....................
.................... i2c_start(); // Start condition
.................... i2c_write(SHT25_ADDR); // Device address
.................... i2c_write(0xE6); // Write to status register
.................... i2c_write(reg); // Device command
.................... i2c_stop(); // Stop condition
....................
.................... delay_ms(10);
....................
.................... i2c_start(); // Start condition
.................... i2c_write(SHT25_ADDR); // Device address
.................... i2c_write(0xE7); // Device command
....................
.................... i2c_start(); // Start condition
.................... i2c_write(SHT25_ADDR+1); // Device address
.................... reg=i2c_read(0); // Read status actual status register
....................
.................... return (reg);
.................... }
....................
....................
.................... float SHT25_get_temp()
.................... {
.................... unsigned int8 MSB, LSB, Check;
.................... unsigned int16 data;
....................
.................... i2c_start();
*
0567: BSF 20.4
0568: MOVF 20,W
0569: BSF 03.5
056A: MOVWF 07
056B: NOP
056C: BCF 03.5
056D: BSF 20.3
056E: MOVF 20,W
056F: BSF 03.5
0570: MOVWF 07
0571: NOP
0572: BCF 03.5
0573: BTFSS 07.3
0574: GOTO 573
0575: BCF 07.4
0576: BCF 20.4
0577: MOVF 20,W
0578: BSF 03.5
0579: MOVWF 07
057A: NOP
057B: BCF 03.5
057C: BCF 07.3
057D: BCF 20.3
057E: MOVF 20,W
057F: BSF 03.5
0580: MOVWF 07
.................... I2C_Write(SHT25_ADDR);
0581: MOVLW 80
0582: BCF 03.5
0583: MOVWF 4E
0584: CALL 078
.................... I2C_write(0xE3);
0585: MOVLW E3
0586: MOVWF 4E
0587: CALL 078
.................... i2c_stop();
0588: BCF 20.4
0589: MOVF 20,W
058A: BSF 03.5
058B: MOVWF 07
058C: NOP
058D: BCF 03.5
058E: BSF 20.3
058F: MOVF 20,W
0590: BSF 03.5
0591: MOVWF 07
0592: BCF 03.5
0593: BTFSS 07.3
0594: GOTO 593
0595: NOP
0596: GOTO 597
0597: NOP
0598: BSF 20.4
0599: MOVF 20,W
059A: BSF 03.5
059B: MOVWF 07
059C: NOP
....................
.................... delay_ms(100);
059D: MOVLW 64
059E: BCF 03.5
059F: MOVWF 4B
05A0: CALL 0FB
....................
.................... i2c_start();
05A1: BSF 20.4
05A2: MOVF 20,W
05A3: BSF 03.5
05A4: MOVWF 07
05A5: NOP
05A6: BCF 03.5
05A7: BSF 20.3
05A8: MOVF 20,W
05A9: BSF 03.5
05AA: MOVWF 07
05AB: NOP
05AC: BCF 03.5
05AD: BCF 07.4
05AE: BCF 20.4
05AF: MOVF 20,W
05B0: BSF 03.5
05B1: MOVWF 07
05B2: NOP
05B3: BCF 03.5
05B4: BCF 07.3
05B5: BCF 20.3
05B6: MOVF 20,W
05B7: BSF 03.5
05B8: MOVWF 07
.................... I2C_Write(SHT25_ADDR+1);
05B9: MOVLW 81
05BA: BCF 03.5
05BB: MOVWF 4E
05BC: CALL 078
.................... MSB=i2c_read(1);
05BD: MOVLW 01
05BE: MOVWF 77
05BF: CALL 285
05C0: MOVF 78,W
05C1: MOVWF 3D
.................... LSB=i2c_read(1);
05C2: MOVLW 01
05C3: MOVWF 77
05C4: CALL 285
05C5: MOVF 78,W
05C6: MOVWF 3E
.................... Check=i2c_read(0);
05C7: CLRF 77
05C8: CALL 285
05C9: MOVF 78,W
05CA: MOVWF 3F
.................... i2c_stop();
05CB: BCF 20.4
05CC: MOVF 20,W
05CD: BSF 03.5
05CE: MOVWF 07
05CF: NOP
05D0: BCF 03.5
05D1: BSF 20.3
05D2: MOVF 20,W
05D3: BSF 03.5
05D4: MOVWF 07
05D5: BCF 03.5
05D6: BTFSS 07.3
05D7: GOTO 5D6
05D8: NOP
05D9: GOTO 5DA
05DA: NOP
05DB: BSF 20.4
05DC: MOVF 20,W
05DD: BSF 03.5
05DE: MOVWF 07
05DF: NOP
....................
.................... LSB = LSB >> 2; // trow out status bits
05E0: BCF 03.5
05E1: RRF 3E,F
05E2: RRF 3E,F
05E3: MOVLW 3F
05E4: ANDWF 3E,F
....................
.................... data = (((unsigned int16) MSB << 8) + (LSB << 4));
05E5: CLRF 43
05E6: MOVF 3D,W
05E7: MOVWF 42
05E8: MOVWF 43
05E9: CLRF 42
05EA: SWAPF 3E,W
05EB: MOVWF 77
05EC: MOVLW F0
05ED: ANDWF 77,F
05EE: MOVF 77,W
05EF: ADDWF 42,W
05F0: MOVWF 40
05F1: MOVF 43,W
05F2: MOVWF 41
05F3: BTFSC 03.0
05F4: INCF 41,F
.................... return(-46.85 + 175.72*((float)data/0xFFFF));
05F5: MOVF 41,W
05F6: MOVWF 4E
05F7: MOVF 40,W
05F8: MOVWF 4D
05F9: CALL 2CA
05FA: MOVF 77,W
05FB: MOVWF 42
05FC: MOVF 78,W
05FD: MOVWF 43
05FE: MOVF 79,W
05FF: MOVWF 44
0600: MOVF 7A,W
0601: MOVWF 45
0602: MOVWF 54
0603: MOVF 79,W
0604: MOVWF 53
0605: MOVF 78,W
0606: MOVWF 52
0607: MOVF 77,W
0608: MOVWF 51
0609: CLRF 58
060A: MOVLW FF
060B: MOVWF 57
060C: MOVLW 7F
060D: MOVWF 56
060E: MOVLW 8E
060F: MOVWF 55
0610: CALL 2E7
0611: MOVLW 52
0612: MOVWF 4D
0613: MOVLW B8
0614: MOVWF 4C
0615: MOVLW 2F
0616: MOVWF 4B
0617: MOVLW 86
0618: MOVWF 4A
0619: MOVF 7A,W
061A: MOVWF 51
061B: MOVF 79,W
061C: MOVWF 50
061D: MOVF 78,W
061E: MOVWF 4F
061F: MOVF 77,W
0620: MOVWF 4E
0621: CALL 3B1
0622: BCF 03.1
0623: MOVLW 66
0624: MOVWF 56
0625: MOVWF 55
0626: MOVLW BB
0627: MOVWF 54
0628: MOVLW 84
0629: MOVWF 53
062A: MOVF 7A,W
062B: MOVWF 5A
062C: MOVF 79,W
062D: MOVWF 59
062E: MOVF 78,W
062F: MOVWF 58
0630: MOVF 77,W
0631: MOVWF 57
0632: CALL 426
.................... }
0633: BSF 0A.3
0634: BCF 0A.4
0635: GOTO 5B9 (RETURN)
....................
.................... float SHT25_get_hum()
.................... {
.................... unsigned int8 MSB, LSB, Check;
.................... unsigned int16 data;
....................
.................... i2c_start(); //RH
0636: BSF 20.4
0637: MOVF 20,W
0638: BSF 03.5
0639: MOVWF 07
063A: NOP
063B: BCF 03.5
063C: BSF 20.3
063D: MOVF 20,W
063E: BSF 03.5
063F: MOVWF 07
0640: NOP
0641: BCF 03.5
0642: BCF 07.4
0643: BCF 20.4
0644: MOVF 20,W
0645: BSF 03.5
0646: MOVWF 07
0647: NOP
0648: BCF 03.5
0649: BCF 07.3
064A: BCF 20.3
064B: MOVF 20,W
064C: BSF 03.5
064D: MOVWF 07
.................... I2C_Write(SHT25_ADDR);
064E: MOVLW 80
064F: BCF 03.5
0650: MOVWF 4E
0651: CALL 078
.................... I2C_write(0xE5);
0652: MOVLW E5
0653: MOVWF 4E
0654: CALL 078
....................
.................... delay_ms(100);
0655: MOVLW 64
0656: MOVWF 4B
0657: CALL 0FB
....................
.................... i2c_start();
0658: BSF 20.4
0659: MOVF 20,W
065A: BSF 03.5
065B: MOVWF 07
065C: NOP
065D: BCF 03.5
065E: BSF 20.3
065F: MOVF 20,W
0660: BSF 03.5
0661: MOVWF 07
0662: NOP
0663: BCF 03.5
0664: BTFSS 07.3
0665: GOTO 664
0666: BCF 07.4
0667: BCF 20.4
0668: MOVF 20,W
0669: BSF 03.5
066A: MOVWF 07
066B: NOP
066C: BCF 03.5
066D: BCF 07.3
066E: BCF 20.3
066F: MOVF 20,W
0670: BSF 03.5
0671: MOVWF 07
.................... I2C_Write(SHT25_ADDR+1);
0672: MOVLW 81
0673: BCF 03.5
0674: MOVWF 4E
0675: CALL 078
.................... MSB=i2c_read(1);
0676: MOVLW 01
0677: MOVWF 77
0678: CALL 285
0679: MOVF 78,W
067A: MOVWF 3D
.................... LSB=i2c_read(1);
067B: MOVLW 01
067C: MOVWF 77
067D: CALL 285
067E: MOVF 78,W
067F: MOVWF 3E
.................... Check=i2c_read(0);
0680: CLRF 77
0681: CALL 285
0682: MOVF 78,W
0683: MOVWF 3F
.................... i2c_stop();
0684: BCF 20.4
0685: MOVF 20,W
0686: BSF 03.5
0687: MOVWF 07
0688: NOP
0689: BCF 03.5
068A: BSF 20.3
068B: MOVF 20,W
068C: BSF 03.5
068D: MOVWF 07
068E: BCF 03.5
068F: BTFSS 07.3
0690: GOTO 68F
0691: NOP
0692: GOTO 693
0693: NOP
0694: BSF 20.4
0695: MOVF 20,W
0696: BSF 03.5
0697: MOVWF 07
0698: NOP
....................
.................... LSB = LSB >> 2; // trow out status bits
0699: BCF 03.5
069A: RRF 3E,F
069B: RRF 3E,F
069C: MOVLW 3F
069D: ANDWF 3E,F
....................
.................... data = (((unsigned int16) MSB << 8) + (LSB << 4) );
069E: CLRF 43
069F: MOVF 3D,W
06A0: MOVWF 42
06A1: MOVWF 43
06A2: CLRF 42
06A3: SWAPF 3E,W
06A4: MOVWF 77
06A5: MOVLW F0
06A6: ANDWF 77,F
06A7: MOVF 77,W
06A8: ADDWF 42,W
06A9: MOVWF 40
06AA: MOVF 43,W
06AB: MOVWF 41
06AC: BTFSC 03.0
06AD: INCF 41,F
.................... return( -6.0 + 125.0*((float)data/0xFFFF));
06AE: MOVF 41,W
06AF: MOVWF 4E
06B0: MOVF 40,W
06B1: MOVWF 4D
06B2: CALL 2CA
06B3: MOVF 77,W
06B4: MOVWF 42
06B5: MOVF 78,W
06B6: MOVWF 43
06B7: MOVF 79,W
06B8: MOVWF 44
06B9: MOVF 7A,W
06BA: MOVWF 45
06BB: MOVWF 54
06BC: MOVF 79,W
06BD: MOVWF 53
06BE: MOVF 78,W
06BF: MOVWF 52
06C0: MOVF 77,W
06C1: MOVWF 51
06C2: CLRF 58
06C3: MOVLW FF
06C4: MOVWF 57
06C5: MOVLW 7F
06C6: MOVWF 56
06C7: MOVLW 8E
06C8: MOVWF 55
06C9: CALL 2E7
06CA: CLRF 4D
06CB: CLRF 4C
06CC: MOVLW 7A
06CD: MOVWF 4B
06CE: MOVLW 85
06CF: MOVWF 4A
06D0: MOVF 7A,W
06D1: MOVWF 51
06D2: MOVF 79,W
06D3: MOVWF 50
06D4: MOVF 78,W
06D5: MOVWF 4F
06D6: MOVF 77,W
06D7: MOVWF 4E
06D8: CALL 3B1
06D9: BCF 03.1
06DA: CLRF 56
06DB: CLRF 55
06DC: MOVLW C0
06DD: MOVWF 54
06DE: MOVLW 81
06DF: MOVWF 53
06E0: MOVF 7A,W
06E1: MOVWF 5A
06E2: MOVF 79,W
06E3: MOVWF 59
06E4: MOVF 78,W
06E5: MOVWF 58
06E6: MOVF 77,W
06E7: MOVWF 57
06E8: CALL 426
.................... }
06E9: BSF 0A.3
06EA: BCF 0A.4
06EB: GOTO 5C4 (RETURN)
....................
....................
....................
....................
.................... #include "../LTS01.h"
.................... //Adresa pro VDD, VDD, VDD W 0x9E R 0x9F
.................... //Adresa pro GND GND GND W 0x90 R 0x91
....................
.................... #define LTS01A_address 0x90
....................
.................... #include "LTS01.c"
.................... float LTS01_get_temp()
.................... {
.................... unsigned int8 MSB;
.................... unsigned int8 LSB;
.................... signed int16 data;
....................
.................... i2c_start();
06EC: BSF 20.4
06ED: MOVF 20,W
06EE: BSF 03.5
06EF: MOVWF 07
06F0: NOP
06F1: BCF 03.5
06F2: BSF 20.3
06F3: MOVF 20,W
06F4: BSF 03.5
06F5: MOVWF 07
06F6: NOP
06F7: BCF 03.5
06F8: BCF 07.4
06F9: BCF 20.4
06FA: MOVF 20,W
06FB: BSF 03.5
06FC: MOVWF 07
06FD: NOP
06FE: BCF 03.5
06FF: BCF 07.3
0700: BCF 20.3
0701: MOVF 20,W
0702: BSF 03.5
0703: MOVWF 07
.................... I2C_Write(LTS01A_address);
0704: MOVLW 90
0705: BCF 03.5
0706: MOVWF 4E
0707: CALL 078
.................... I2C_write(0x00);
0708: CLRF 4E
0709: CALL 078
.................... i2c_stop();
070A: BCF 20.4
070B: MOVF 20,W
070C: BSF 03.5
070D: MOVWF 07
070E: NOP
070F: BCF 03.5
0710: BSF 20.3
0711: MOVF 20,W
0712: BSF 03.5
0713: MOVWF 07
0714: BCF 03.5
0715: BTFSS 07.3
0716: GOTO 715
0717: NOP
0718: GOTO 719
0719: NOP
071A: BSF 20.4
071B: MOVF 20,W
071C: BSF 03.5
071D: MOVWF 07
071E: NOP
.................... i2c_start();
071F: BCF 03.5
0720: BSF 20.4
0721: MOVF 20,W
0722: BSF 03.5
0723: MOVWF 07
0724: NOP
0725: BCF 03.5
0726: BSF 20.3
0727: MOVF 20,W
0728: BSF 03.5
0729: MOVWF 07
072A: NOP
072B: BCF 03.5
072C: BCF 07.4
072D: BCF 20.4
072E: MOVF 20,W
072F: BSF 03.5
0730: MOVWF 07
0731: NOP
0732: BCF 03.5
0733: BCF 07.3
0734: BCF 20.3
0735: MOVF 20,W
0736: BSF 03.5
0737: MOVWF 07
.................... I2C_Write(LTS01A_address+1);
0738: MOVLW 91
0739: BCF 03.5
073A: MOVWF 4E
073B: CALL 078
.................... MSB=i2c_read(1);
073C: MOVLW 01
073D: MOVWF 77
073E: CALL 285
073F: MOVF 78,W
0740: MOVWF 3D
.................... LSB=i2c_read(0);
0741: CLRF 77
0742: CALL 285
0743: MOVF 78,W
0744: MOVWF 3E
.................... i2c_stop();
0745: BCF 20.4
0746: MOVF 20,W
0747: BSF 03.5
0748: MOVWF 07
0749: NOP
074A: BCF 03.5
074B: BSF 20.3
074C: MOVF 20,W
074D: BSF 03.5
074E: MOVWF 07
074F: BCF 03.5
0750: BTFSS 07.3
0751: GOTO 750
0752: NOP
0753: GOTO 754
0754: NOP
0755: BSF 20.4
0756: MOVF 20,W
0757: BSF 03.5
0758: MOVWF 07
0759: NOP
....................
.................... data = MAKE16(MSB,LSB);
075A: BCF 03.5
075B: MOVF 3D,W
075C: MOVWF 40
075D: MOVF 3E,W
075E: MOVWF 3F
....................
.................... return (data * 0.00390625 );
075F: MOVF 40,W
0760: MOVWF 42
0761: MOVF 3F,W
0762: MOVWF 41
0763: MOVF 42,W
0764: MOVWF 44
0765: MOVF 41,W
0766: MOVWF 43
*
078B: MOVF 7A,W
078C: MOVWF 4D
078D: MOVF 79,W
078E: MOVWF 4C
078F: MOVF 78,W
0790: MOVWF 4B
0791: MOVF 77,W
0792: MOVWF 4A
0793: CLRF 51
0794: CLRF 50
0795: CLRF 4F
0796: MOVLW 77
0797: MOVWF 4E
0798: CALL 3B1
....................
.................... }
0799: BSF 0A.3
079A: BCF 0A.4
079B: GOTO 5CF (RETURN)
....................
....................
....................
.................... #include "./HMC5883L.h"
.................... // i2c slave addresses
.................... #define HMC5883L_WRT_ADDR 0x3C
.................... #define HMC5883L_READ_ADDR 0x3D
....................
.................... // Register addresses
.................... #define HMC5883L_CFG_A_REG 0x00
.................... #define HMC5883L_CFG_B_REG 0x01
.................... #define HMC5883L_MODE_REG 0x02
.................... #define HMC5883L_X_MSB_REG 0x03
....................
.................... //Konstanty nastavujici rozsah
.................... //pro void set_mag_roz (unsigned int8 h)
.................... #define MAG_ROZ088 0x00
.................... #define MAG_ROZ130 0x20
.................... #define MAG_ROZ190 0x40
.................... #define MAG_ROZ250 0x60
.................... #define MAG_ROZ400 0x80
.................... #define MAG_ROZ470 0xA0
.................... #define MAG_ROZ560 0xC0
.................... #define MAG_ROZ810 0xE0
....................
....................
.................... #include "HMC5883L.c"
.................... //------------------------------
.................... // Low level routines
.................... //------------------------------
.................... void hmc5883l_write_reg(int8 reg, int8 data)
.................... {
.................... i2c_start();
*
00C2: BSF 20.4
00C3: MOVF 20,W
00C4: BSF 03.5
00C5: MOVWF 07
00C6: NOP
00C7: BCF 03.5
00C8: BSF 20.3
00C9: MOVF 20,W
00CA: BSF 03.5
00CB: MOVWF 07
00CC: NOP
00CD: BCF 03.5
00CE: BCF 07.4
00CF: BCF 20.4
00D0: MOVF 20,W
00D1: BSF 03.5
00D2: MOVWF 07
00D3: NOP
00D4: BCF 03.5
00D5: BCF 07.3
00D6: BCF 20.3
00D7: MOVF 20,W
00D8: BSF 03.5
00D9: MOVWF 07
.................... i2c_write(HMC5883L_WRT_ADDR);
00DA: MOVLW 3C
00DB: BCF 03.5
00DC: MOVWF 4E
00DD: CALL 078
.................... i2c_write(reg);
00DE: MOVF 3D,W
00DF: MOVWF 4E
00E0: CALL 078
.................... i2c_write(data);
00E1: MOVF 3E,W
00E2: MOVWF 4E
00E3: CALL 078
.................... i2c_stop();
00E4: BCF 20.4
00E5: MOVF 20,W
00E6: BSF 03.5
00E7: MOVWF 07
00E8: NOP
00E9: BCF 03.5
00EA: BSF 20.3
00EB: MOVF 20,W
00EC: BSF 03.5
00ED: MOVWF 07
00EE: BCF 03.5
00EF: BTFSS 07.3
00F0: GOTO 0EF
00F1: NOP
00F2: GOTO 0F3
00F3: NOP
00F4: BSF 20.4
00F5: MOVF 20,W
00F6: BSF 03.5
00F7: MOVWF 07
00F8: NOP
.................... }
00F9: BCF 03.5
00FA: RETURN
....................
.................... //------------------------------
.................... int8 hmc5883l_read_reg(int8 reg)
.................... {
.................... int8 retval;
....................
.................... i2c_start();
.................... i2c_write(HMC5883L_WRT_ADDR);
.................... i2c_write(reg);
.................... i2c_start();
.................... i2c_write(HMC5883L_READ_ADDR);
.................... retval = i2c_read(0);
.................... i2c_stop();
....................
.................... return(retval);
.................... }
....................
.................... //------------------------------
.................... typedef struct
.................... {
.................... signed int16 x;
.................... signed int16 y;
.................... signed int16 z;
.................... }hmc5883l_result;
....................
.................... // This global structure holds the values read
.................... // from the HMC5883L x,y,z registers.
.................... hmc5883l_result compass = {0,0,0};
*
0D09: CLRF 21
0D0A: CLRF 22
0D0B: CLRF 23
0D0C: CLRF 24
0D0D: CLRF 25
0D0E: CLRF 26
....................
.................... //------------------------------
.................... void hmc5883l_read_data(void)
.................... {
.................... unsigned int8 x_lsb;
.................... unsigned int8 x_msb;
....................
.................... unsigned int8 y_lsb;
.................... unsigned int8 y_msb;
....................
.................... unsigned int8 z_lsb;
.................... unsigned int8 z_msb;
....................
.................... i2c_start();
*
0800: BSF 20.4
0801: MOVF 20,W
0802: BSF 03.5
0803: MOVWF 07
0804: NOP
0805: BCF 03.5
0806: BSF 20.3
0807: MOVF 20,W
0808: BSF 03.5
0809: MOVWF 07
080A: NOP
080B: BCF 03.5
080C: BCF 07.4
080D: BCF 20.4
080E: MOVF 20,W
080F: BSF 03.5
0810: MOVWF 07
0811: NOP
0812: BCF 03.5
0813: BCF 07.3
0814: BCF 20.3
0815: MOVF 20,W
0816: BSF 03.5
0817: MOVWF 07
.................... i2c_write(HMC5883L_WRT_ADDR);
0818: MOVLW 3C
0819: BCF 03.5
081A: MOVWF 4E
081B: BCF 0A.3
081C: CALL 078
081D: BSF 0A.3
.................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register
081E: MOVLW 03
081F: MOVWF 4E
0820: BCF 0A.3
0821: CALL 078
0822: BSF 0A.3
.................... i2c_start();
0823: BSF 20.4
0824: MOVF 20,W
0825: BSF 03.5
0826: MOVWF 07
0827: NOP
0828: BCF 03.5
0829: BSF 20.3
082A: MOVF 20,W
082B: BSF 03.5
082C: MOVWF 07
082D: NOP
082E: BCF 03.5
082F: BTFSS 07.3
0830: GOTO 02F
0831: BCF 07.4
0832: BCF 20.4
0833: MOVF 20,W
0834: BSF 03.5
0835: MOVWF 07
0836: NOP
0837: BCF 03.5
0838: BCF 07.3
0839: BCF 20.3
083A: MOVF 20,W
083B: BSF 03.5
083C: MOVWF 07
.................... i2c_write(HMC5883L_READ_ADDR);
083D: MOVLW 3D
083E: BCF 03.5
083F: MOVWF 4E
0840: BCF 0A.3
0841: CALL 078
0842: BSF 0A.3
....................
.................... x_msb = i2c_read();
0843: MOVLW 01
0844: MOVWF 77
0845: BCF 0A.3
0846: CALL 285
0847: BSF 0A.3
0848: MOVF 78,W
0849: MOVWF 3E
.................... x_lsb = i2c_read();
084A: MOVLW 01
084B: MOVWF 77
084C: BCF 0A.3
084D: CALL 285
084E: BSF 0A.3
084F: MOVF 78,W
0850: MOVWF 3D
....................
.................... z_msb = i2c_read();
0851: MOVLW 01
0852: MOVWF 77
0853: BCF 0A.3
0854: CALL 285
0855: BSF 0A.3
0856: MOVF 78,W
0857: MOVWF 42
.................... z_lsb = i2c_read();
0858: MOVLW 01
0859: MOVWF 77
085A: BCF 0A.3
085B: CALL 285
085C: BSF 0A.3
085D: MOVF 78,W
085E: MOVWF 41
....................
.................... y_msb = i2c_read();
085F: MOVLW 01
0860: MOVWF 77
0861: BCF 0A.3
0862: CALL 285
0863: BSF 0A.3
0864: MOVF 78,W
0865: MOVWF 40
.................... y_lsb = i2c_read(0); // do a NACK on last read
0866: CLRF 77
0867: BCF 0A.3
0868: CALL 285
0869: BSF 0A.3
086A: MOVF 78,W
086B: MOVWF 3F
....................
.................... i2c_stop();
086C: BCF 20.4
086D: MOVF 20,W
086E: BSF 03.5
086F: MOVWF 07
0870: NOP
0871: BCF 03.5
0872: BSF 20.3
0873: MOVF 20,W
0874: BSF 03.5
0875: MOVWF 07
0876: BCF 03.5
0877: BTFSS 07.3
0878: GOTO 077
0879: NOP
087A: GOTO 07B
087B: NOP
087C: BSF 20.4
087D: MOVF 20,W
087E: BSF 03.5
087F: MOVWF 07
0880: NOP
....................
.................... // Combine high and low bytes into 16-bit values.
.................... compass.x = make16(x_msb, x_lsb);
0881: BCF 03.5
0882: MOVF 3E,W
0883: MOVWF 22
0884: MOVF 3D,W
0885: MOVWF 21
.................... compass.y = make16(y_msb, y_lsb);
0886: MOVF 40,W
0887: MOVWF 24
0888: MOVF 3F,W
0889: MOVWF 23
.................... compass.z = make16(z_msb, z_lsb);
088A: MOVF 42,W
088B: MOVWF 26
088C: MOVF 41,W
088D: MOVWF 25
.................... }
088E: BSF 0A.3
088F: BCF 0A.4
0890: GOTO 5D9 (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
....................
....................
.................... #define MPL3115_ADDR_R 0xC1 //addresa pro cteni
.................... #define MPL3115_ADDR_W 0xC0
....................
.................... #include "../MPL3115.h"
.................... //microchip pic library for Freescale MPL3115 I2C barometer sensor
....................
.................... /*void mpl3115_setA (void) //setup sensor for altitude measurement
.................... void mpl3115_setP (void) //setup sensor for preasure measurement
.................... float mpl3115_T (void) //temperature in Celsius degrees
.................... float mpl3115_A (void) //altitude in metres
.................... float mpl3115_P (void) //preassure in pascals
.................... */
....................
.................... #include "MPL3115.c"
.................... void mpl3115_setA (void) //setup for altitude measurement
.................... {
....................
....................
.................... i2c_start(); //STANDBY mode
.................... I2C_Write(MPL3115_ADDR_W);
.................... I2C_write(0x26);
.................... I2C_write(0xB8);
.................... i2c_stop();
....................
.................... i2c_start(); //PT_DATA_CFG set
.................... I2C_Write(MPL3115_ADDR_W);
.................... I2C_write(0x13);
.................... I2C_write(0x07); //hodnota
.................... i2c_stop();
....................
.................... i2c_start(); //ACTIVE mode
.................... I2C_Write(MPL3115_ADDR_W);
.................... I2C_write(0x26);
.................... I2C_write(0xB9);
.................... i2c_stop();
.................... }
....................
.................... void mpl3115_setP (void) //nastavení pro tlak
.................... {
....................
....................
.................... i2c_start(); //STANDBY mode
*
09AD: BSF 20.4
09AE: MOVF 20,W
09AF: BSF 03.5
09B0: MOVWF 07
09B1: NOP
09B2: BCF 03.5
09B3: BSF 20.3
09B4: MOVF 20,W
09B5: BSF 03.5
09B6: MOVWF 07
09B7: NOP
09B8: BCF 03.5
09B9: BCF 07.4
09BA: BCF 20.4
09BB: MOVF 20,W
09BC: BSF 03.5
09BD: MOVWF 07
09BE: NOP
09BF: BCF 03.5
09C0: BCF 07.3
09C1: BCF 20.3
09C2: MOVF 20,W
09C3: BSF 03.5
09C4: MOVWF 07
.................... I2C_Write(MPL3115_ADDR_W);
09C5: MOVLW C0
09C6: BCF 03.5
09C7: MOVWF 4E
09C8: BCF 0A.3
09C9: CALL 078
09CA: BSF 0A.3
.................... I2C_write(0x26);
09CB: MOVLW 26
09CC: MOVWF 4E
09CD: BCF 0A.3
09CE: CALL 078
09CF: BSF 0A.3
.................... I2C_write(0xB8);
09D0: MOVLW B8
09D1: MOVWF 4E
09D2: BCF 0A.3
09D3: CALL 078
09D4: BSF 0A.3
.................... i2c_stop();
09D5: BCF 20.4
09D6: MOVF 20,W
09D7: BSF 03.5
09D8: MOVWF 07
09D9: NOP
09DA: BCF 03.5
09DB: BSF 20.3
09DC: MOVF 20,W
09DD: BSF 03.5
09DE: MOVWF 07
09DF: BCF 03.5
09E0: BTFSS 07.3
09E1: GOTO 1E0
09E2: NOP
09E3: GOTO 1E4
09E4: NOP
09E5: BSF 20.4
09E6: MOVF 20,W
09E7: BSF 03.5
09E8: MOVWF 07
09E9: NOP
....................
.................... i2c_start(); //PT_DATA_CFG set
09EA: BCF 03.5
09EB: BSF 20.4
09EC: MOVF 20,W
09ED: BSF 03.5
09EE: MOVWF 07
09EF: NOP
09F0: BCF 03.5
09F1: BSF 20.3
09F2: MOVF 20,W
09F3: BSF 03.5
09F4: MOVWF 07
09F5: NOP
09F6: BCF 03.5
09F7: BCF 07.4
09F8: BCF 20.4
09F9: MOVF 20,W
09FA: BSF 03.5
09FB: MOVWF 07
09FC: NOP
09FD: BCF 03.5
09FE: BCF 07.3
09FF: BCF 20.3
0A00: MOVF 20,W
0A01: BSF 03.5
0A02: MOVWF 07
.................... I2C_Write(MPL3115_ADDR_W);
0A03: MOVLW C0
0A04: BCF 03.5
0A05: MOVWF 4E
0A06: BCF 0A.3
0A07: CALL 078
0A08: BSF 0A.3
.................... I2C_write(0x13);
0A09: MOVLW 13
0A0A: MOVWF 4E
0A0B: BCF 0A.3
0A0C: CALL 078
0A0D: BSF 0A.3
.................... I2C_write(0x07); //hodnota
0A0E: MOVLW 07
0A0F: MOVWF 4E
0A10: BCF 0A.3
0A11: CALL 078
0A12: BSF 0A.3
.................... i2c_stop();
0A13: BCF 20.4
0A14: MOVF 20,W
0A15: BSF 03.5
0A16: MOVWF 07
0A17: NOP
0A18: BCF 03.5
0A19: BSF 20.3
0A1A: MOVF 20,W
0A1B: BSF 03.5
0A1C: MOVWF 07
0A1D: BCF 03.5
0A1E: BTFSS 07.3
0A1F: GOTO 21E
0A20: NOP
0A21: GOTO 222
0A22: NOP
0A23: BSF 20.4
0A24: MOVF 20,W
0A25: BSF 03.5
0A26: MOVWF 07
0A27: NOP
....................
.................... i2c_start(); //ACTIVE mode
0A28: BCF 03.5
0A29: BSF 20.4
0A2A: MOVF 20,W
0A2B: BSF 03.5
0A2C: MOVWF 07
0A2D: NOP
0A2E: BCF 03.5
0A2F: BSF 20.3
0A30: MOVF 20,W
0A31: BSF 03.5
0A32: MOVWF 07
0A33: NOP
0A34: BCF 03.5
0A35: BCF 07.4
0A36: BCF 20.4
0A37: MOVF 20,W
0A38: BSF 03.5
0A39: MOVWF 07
0A3A: NOP
0A3B: BCF 03.5
0A3C: BCF 07.3
0A3D: BCF 20.3
0A3E: MOVF 20,W
0A3F: BSF 03.5
0A40: MOVWF 07
.................... I2C_Write(MPL3115_ADDR_W);
0A41: MOVLW C0
0A42: BCF 03.5
0A43: MOVWF 4E
0A44: BCF 0A.3
0A45: CALL 078
0A46: BSF 0A.3
.................... I2C_write(0x26);
0A47: MOVLW 26
0A48: MOVWF 4E
0A49: BCF 0A.3
0A4A: CALL 078
0A4B: BSF 0A.3
.................... I2C_write(0x39);
0A4C: MOVLW 39
0A4D: MOVWF 4E
0A4E: BCF 0A.3
0A4F: CALL 078
0A50: BSF 0A.3
.................... i2c_stop();
0A51: BCF 20.4
0A52: MOVF 20,W
0A53: BSF 03.5
0A54: MOVWF 07
0A55: NOP
0A56: BCF 03.5
0A57: BSF 20.3
0A58: MOVF 20,W
0A59: BSF 03.5
0A5A: MOVWF 07
0A5B: BCF 03.5
0A5C: BTFSS 07.3
0A5D: GOTO 25C
0A5E: NOP
0A5F: GOTO 260
0A60: NOP
0A61: BSF 20.4
0A62: MOVF 20,W
0A63: BSF 03.5
0A64: MOVWF 07
0A65: NOP
.................... }
0A66: BCF 03.5
0A67: BSF 0A.3
0A68: BCF 0A.4
0A69: GOTO 5EC (RETURN)
....................
....................
.................... byte mpl3115_read (byte reg)
.................... {
.................... byte i;
....................
.................... i2c_start();
*
079C: BSF 20.4
079D: MOVF 20,W
079E: BSF 03.5
079F: MOVWF 07
07A0: NOP
07A1: BCF 03.5
07A2: BSF 20.3
07A3: MOVF 20,W
07A4: BSF 03.5
07A5: MOVWF 07
07A6: NOP
07A7: BCF 03.5
07A8: BCF 07.4
07A9: BCF 20.4
07AA: MOVF 20,W
07AB: BSF 03.5
07AC: MOVWF 07
07AD: NOP
07AE: BCF 03.5
07AF: BCF 07.3
07B0: BCF 20.3
07B1: MOVF 20,W
07B2: BSF 03.5
07B3: MOVWF 07
.................... I2C_Write(MPL3115_ADDR_W);
07B4: MOVLW C0
07B5: BCF 03.5
07B6: MOVWF 4E
07B7: CALL 078
.................... I2C_write(reg);
07B8: MOVF 4C,W
07B9: MOVWF 4E
07BA: CALL 078
.................... i2c_start();
07BB: BSF 20.4
07BC: MOVF 20,W
07BD: BSF 03.5
07BE: MOVWF 07
07BF: NOP
07C0: BCF 03.5
07C1: BSF 20.3
07C2: MOVF 20,W
07C3: BSF 03.5
07C4: MOVWF 07
07C5: NOP
07C6: BCF 03.5
07C7: BTFSS 07.3
07C8: GOTO 7C7
07C9: BCF 07.4
07CA: BCF 20.4
07CB: MOVF 20,W
07CC: BSF 03.5
07CD: MOVWF 07
07CE: NOP
07CF: BCF 03.5
07D0: BCF 07.3
07D1: BCF 20.3
07D2: MOVF 20,W
07D3: BSF 03.5
07D4: MOVWF 07
.................... I2C_Write(MPL3115_ADDR_R);
07D5: MOVLW C1
07D6: BCF 03.5
07D7: MOVWF 4E
07D8: CALL 078
.................... i=i2c_read(0);
07D9: CLRF 77
07DA: CALL 285
07DB: MOVF 78,W
07DC: MOVWF 4D
.................... i2c_stop();
07DD: BCF 20.4
07DE: MOVF 20,W
07DF: BSF 03.5
07E0: MOVWF 07
07E1: NOP
07E2: BCF 03.5
07E3: BSF 20.3
07E4: MOVF 20,W
07E5: BSF 03.5
07E6: MOVWF 07
07E7: BCF 03.5
07E8: BTFSS 07.3
07E9: GOTO 7E8
07EA: NOP
07EB: GOTO 7EC
07EC: NOP
07ED: BSF 20.4
07EE: MOVF 20,W
07EF: BSF 03.5
07F0: MOVWF 07
07F1: NOP
....................
.................... return i;
07F2: BCF 03.5
07F3: MOVF 4D,W
07F4: MOVWF 78
.................... }
07F5: RETURN
....................
....................
.................... float mpl3115_T (void) //teplota ve stupnich
.................... {
.................... int m;
.................... float l, t;
....................
.................... m = mpl3115_read (0x04);
*
0891: MOVLW 04
0892: MOVWF 4C
0893: BCF 0A.3
0894: CALL 79C
0895: BSF 0A.3
0896: MOVF 78,W
0897: MOVWF 3D
.................... l = (float)(mpl3115_read(0x05)>>4)/16.0;
0898: MOVLW 05
0899: MOVWF 4C
089A: BCF 0A.3
089B: CALL 79C
089C: BSF 0A.3
089D: SWAPF 78,W
089E: MOVWF 77
089F: MOVLW 0F
08A0: ANDWF 77,F
08A1: MOVF 77,W
08A2: CLRF 4E
08A3: MOVWF 4D
08A4: BCF 0A.3
08A5: CALL 2CA
08A6: BSF 0A.3
08A7: MOVF 77,W
08A8: MOVWF 46
08A9: MOVF 78,W
08AA: MOVWF 47
08AB: MOVF 79,W
08AC: MOVWF 48
08AD: MOVF 7A,W
08AE: MOVWF 49
08AF: MOVWF 54
08B0: MOVF 48,W
08B1: MOVWF 53
08B2: MOVF 47,W
08B3: MOVWF 52
08B4: MOVF 46,W
08B5: MOVWF 51
08B6: CLRF 58
08B7: CLRF 57
08B8: CLRF 56
08B9: MOVLW 83
08BA: MOVWF 55
08BB: BCF 0A.3
08BC: CALL 2E7
08BD: BSF 0A.3
08BE: MOVF 7A,W
08BF: MOVWF 41
08C0: MOVF 79,W
08C1: MOVWF 40
08C2: MOVF 78,W
08C3: MOVWF 3F
08C4: MOVF 77,W
08C5: MOVWF 3E
.................... t = (float)(M + L);
08C6: CLRF 4E
08C7: MOVF 3D,W
08C8: MOVWF 4D
08C9: BCF 0A.3
08CA: CALL 2CA
08CB: BSF 0A.3
08CC: BCF 03.1
08CD: MOVF 7A,W
08CE: MOVWF 56
08CF: MOVF 79,W
08D0: MOVWF 55
08D1: MOVF 78,W
08D2: MOVWF 54
08D3: MOVF 77,W
08D4: MOVWF 53
08D5: MOVF 41,W
08D6: MOVWF 5A
08D7: MOVF 40,W
08D8: MOVWF 59
08D9: MOVF 3F,W
08DA: MOVWF 58
08DB: MOVF 3E,W
08DC: MOVWF 57
08DD: BCF 0A.3
08DE: CALL 426
08DF: BSF 0A.3
08E0: MOVF 7A,W
08E1: MOVWF 45
08E2: MOVF 79,W
08E3: MOVWF 44
08E4: MOVF 78,W
08E5: MOVWF 43
08E6: MOVF 77,W
08E7: MOVWF 42
.................... return t;
08E8: MOVF 42,W
08E9: MOVWF 77
08EA: MOVF 43,W
08EB: MOVWF 78
08EC: MOVF 44,W
08ED: MOVWF 79
08EE: MOVF 45,W
08EF: MOVWF 7A
.................... }
08F0: BSF 0A.3
08F1: BCF 0A.4
08F2: GOTO 5DA (RETURN)
....................
.................... float mpl3115_A (void) //vyska v m
.................... {
....................
.................... int16 m, c;
.................... float l, a;
....................
.................... m = mpl3115_read (0x01);
.................... c = mpl3115_read (0x02);
.................... l = (float)(mpl3115_read(0x03)>>4)/16.0;
.................... a = (float)((m << 8)|c) + l;
.................... return a;
.................... }
....................
....................
.................... float mpl3115_P (void) //tlak v Pa
.................... {
.................... unsigned int32 m;
.................... unsigned int16 c;
.................... unsigned int l;
.................... float p, l1;
....................
.................... m = mpl3115_read (0x01);
08F3: MOVLW 01
08F4: MOVWF 4C
08F5: BCF 0A.3
08F6: CALL 79C
08F7: BSF 0A.3
08F8: CLRF 40
08F9: CLRF 3F
08FA: CLRF 3E
08FB: MOVF 78,W
08FC: MOVWF 3D
.................... c = mpl3115_read (0x02);
08FD: MOVLW 02
08FE: MOVWF 4C
08FF: BCF 0A.3
0900: CALL 79C
0901: BSF 0A.3
0902: CLRF 42
0903: MOVF 78,W
0904: MOVWF 41
.................... l = mpl3115_read(0x03);
0905: MOVLW 03
0906: MOVWF 4C
0907: BCF 0A.3
0908: CALL 79C
0909: BSF 0A.3
090A: MOVF 78,W
090B: MOVWF 43
....................
.................... l1= (float)(l>>4)/4.0;
090C: SWAPF 43,W
090D: MOVWF 77
090E: MOVLW 0F
090F: ANDWF 77,F
0910: MOVF 77,W
0911: CLRF 4E
0912: MOVWF 4D
0913: BCF 0A.3
0914: CALL 2CA
0915: BSF 0A.3
0916: MOVF 77,W
0917: MOVWF 4D
0918: MOVF 78,W
0919: MOVWF 4E
091A: MOVF 79,W
091B: MOVWF 4F
091C: MOVF 7A,W
091D: MOVWF 50
091E: MOVWF 54
091F: MOVF 79,W
0920: MOVWF 53
0921: MOVF 78,W
0922: MOVWF 52
0923: MOVF 77,W
0924: MOVWF 51
0925: CLRF 58
0926: CLRF 57
0927: CLRF 56
0928: MOVLW 81
0929: MOVWF 55
092A: BCF 0A.3
092B: CALL 2E7
092C: BSF 0A.3
092D: MOVF 7A,W
092E: MOVWF 4B
092F: MOVF 79,W
0930: MOVWF 4A
0931: MOVF 78,W
0932: MOVWF 49
0933: MOVF 77,W
0934: MOVWF 48
.................... p = (float)((m << 10)|(c<<2)|(l>>6)) + l1;
0935: CLRF 4D
0936: RLF 3D,W
0937: MOVWF 4E
0938: RLF 3E,W
0939: MOVWF 4F
093A: RLF 3F,W
093B: MOVWF 50
093C: RLF 4E,F
093D: RLF 4F,F
093E: RLF 50,F
093F: MOVLW FC
0940: ANDWF 4E,F
0941: RLF 41,W
0942: MOVWF 79
0943: RLF 42,W
0944: MOVWF 7A
0945: RLF 79,F
0946: RLF 7A,F
0947: MOVLW FC
0948: ANDWF 79,F
0949: MOVF 79,W
094A: IORWF 4D,F
094B: MOVF 7A,W
094C: IORWF 4E,F
094D: SWAPF 43,W
094E: MOVWF 77
094F: RRF 77,F
0950: RRF 77,F
0951: MOVLW 03
0952: ANDWF 77,F
0953: MOVF 77,W
0954: IORWF 4D,W
0955: MOVWF 77
0956: MOVF 4E,W
0957: MOVWF 78
0958: MOVF 4F,W
0959: MOVWF 79
095A: MOVF 50,W
095B: MOVWF 7A
095C: MOVF 7A,W
095D: MOVWF 56
095E: MOVF 79,W
095F: MOVWF 55
0960: MOVF 78,W
0961: MOVWF 54
0962: MOVF 77,W
0963: MOVWF 53
*
097E: MOVF 77,W
097F: MOVWF 4D
0980: MOVF 78,W
0981: MOVWF 4E
0982: MOVF 79,W
0983: MOVWF 4F
0984: MOVF 7A,W
0985: MOVWF 50
0986: BCF 03.1
0987: MOVF 7A,W
0988: MOVWF 56
0989: MOVF 79,W
098A: MOVWF 55
098B: MOVF 78,W
098C: MOVWF 54
098D: MOVF 77,W
098E: MOVWF 53
098F: MOVF 4B,W
0990: MOVWF 5A
0991: MOVF 4A,W
0992: MOVWF 59
0993: MOVF 49,W
0994: MOVWF 58
0995: MOVF 48,W
0996: MOVWF 57
0997: BCF 0A.3
0998: CALL 426
0999: BSF 0A.3
099A: MOVF 7A,W
099B: MOVWF 47
099C: MOVF 79,W
099D: MOVWF 46
099E: MOVF 78,W
099F: MOVWF 45
09A0: MOVF 77,W
09A1: MOVWF 44
....................
.................... return p;
09A2: MOVF 44,W
09A3: MOVWF 77
09A4: MOVF 45,W
09A5: MOVWF 78
09A6: MOVF 46,W
09A7: MOVWF 79
09A8: MOVF 47,W
09A9: MOVWF 7A
.................... }
09AA: BSF 0A.3
09AB: BCF 0A.4
09AC: GOTO 5E3 (RETURN)
....................
....................
....................
....................
....................
....................
.................... void main()
.................... {
*
0CE5: CLRF 04
0CE6: BCF 03.7
0CE7: MOVLW 1F
0CE8: ANDWF 03,F
0CE9: MOVLW 71
0CEA: BSF 03.5
0CEB: MOVWF 0F
0CEC: MOVF 0F,W
0CED: BSF 03.6
0CEE: BCF 07.3
0CEF: MOVLW 0C
0CF0: BCF 03.6
0CF1: MOVWF 19
0CF2: MOVLW A2
0CF3: MOVWF 18
0CF4: MOVLW 90
0CF5: BCF 03.5
0CF6: MOVWF 18
0CF7: BSF 03.5
0CF8: BSF 03.6
0CF9: MOVF 09,W
0CFA: ANDLW C0
0CFB: MOVWF 09
0CFC: BCF 03.6
0CFD: BCF 1F.4
0CFE: BCF 1F.5
0CFF: MOVLW 00
0D00: BSF 03.6
0D01: MOVWF 08
0D02: BCF 03.5
0D03: CLRF 07
0D04: CLRF 08
0D05: CLRF 09
*
0D0F: CLRF 3C
0D10: CLRF 3B
.................... float temp1, temp2, temp3, humidity, preasure;
.................... int16 i=0;
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
0D11: BSF 03.5
0D12: BSF 03.6
0D13: MOVF 09,W
0D14: ANDLW C0
0D15: MOVWF 09
0D16: BCF 03.6
0D17: BCF 1F.4
0D18: BCF 1F.5
0D19: MOVLW 00
0D1A: BSF 03.6
0D1B: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
0D1C: BCF 03.5
0D1D: BCF 03.6
0D1E: BCF 1F.6
0D1F: BCF 1F.7
0D20: BSF 03.5
0D21: BSF 1F.7
0D22: BCF 03.5
0D23: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
0D24: BCF 14.5
0D25: BCF 20.5
0D26: MOVF 20,W
0D27: BSF 03.5
0D28: MOVWF 07
0D29: BCF 03.5
0D2A: BSF 20.4
0D2B: MOVF 20,W
0D2C: BSF 03.5
0D2D: MOVWF 07
0D2E: BCF 03.5
0D2F: BCF 20.3
0D30: MOVF 20,W
0D31: BSF 03.5
0D32: MOVWF 07
0D33: MOVLW 01
0D34: BCF 03.5
0D35: MOVWF 14
0D36: MOVLW 00
0D37: BSF 03.5
0D38: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0D39: MOVF 01,W
0D3A: ANDLW C7
0D3B: IORLW 08
0D3C: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0D3D: BCF 03.5
0D3E: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0D3F: MOVLW 00
0D40: MOVWF 78
0D41: MOVWF 12
0D42: MOVLW 00
0D43: BSF 03.5
0D44: MOVWF 12
.................... setup_ccp1(CCP_OFF);
0D45: BCF 03.5
0D46: BSF 20.2
0D47: MOVF 20,W
0D48: BSF 03.5
0D49: MOVWF 07
0D4A: BCF 03.5
0D4B: CLRF 17
0D4C: BSF 03.5
0D4D: CLRF 1B
0D4E: CLRF 1C
0D4F: MOVLW 01
0D50: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
0D51: BCF 03.5
0D52: BSF 03.6
0D53: CLRF 07
0D54: CLRF 08
0D55: CLRF 09
.................... setup_oscillator(OSC_8MHZ);
0D56: MOVLW 71
0D57: BSF 03.5
0D58: BCF 03.6
0D59: MOVWF 0F
0D5A: MOVF 0F,W
....................
....................
.................... printf("GeoMet01A\r\n");
0D5B: MOVLW 0C
0D5C: BCF 03.5
0D5D: BSF 03.6
0D5E: MOVWF 0D
0D5F: MOVLW 00
0D60: MOVWF 0F
0D61: BCF 0A.3
0D62: BCF 03.6
0D63: CALL 030
0D64: BSF 0A.3
.................... printf("(c) Kaklik 2013\r\n");
0D65: MOVLW 12
0D66: BSF 03.6
0D67: MOVWF 0D
0D68: MOVLW 00
0D69: MOVWF 0F
0D6A: BCF 0A.3
0D6B: BCF 03.6
0D6C: CALL 030
0D6D: BSF 0A.3
.................... printf("www.mlab.cz\r\n");
0D6E: MOVLW 1B
0D6F: BSF 03.6
0D70: MOVWF 0D
0D71: MOVLW 00
0D72: MOVWF 0F
0D73: BCF 0A.3
0D74: BCF 03.6
0D75: CALL 030
0D76: BSF 0A.3
....................
.................... // Init the HMC5883L. Set Mode register for
.................... // continuous measurements.
.................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range
0D77: CLRF 3D
0D78: MOVLW 18
0D79: MOVWF 3E
0D7A: BCF 0A.3
0D7B: CALL 0C2
0D7C: BSF 0A.3
.................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range
0D7D: MOVLW 01
0D7E: MOVWF 3D
0D7F: CLRF 3E
0D80: BCF 0A.3
0D81: CALL 0C2
0D82: BSF 0A.3
.................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00);
0D83: MOVLW 02
0D84: MOVWF 3D
0D85: CLRF 3E
0D86: BCF 0A.3
0D87: CALL 0C2
0D88: BSF 0A.3
....................
.................... lcd_init();
0D89: BCF 0A.3
0D8A: CALL 1C8
0D8B: BSF 0A.3
.................... lcd_putc("(c) Kaklik 2013");
0D8C: MOVLW 22
0D8D: BSF 03.6
0D8E: MOVWF 0D
0D8F: MOVLW 00
0D90: MOVWF 0F
0D91: BCF 0A.3
0D92: BCF 03.6
0D93: CALL 23F
0D94: BSF 0A.3
.................... lcd_gotoxy(3,2);
0D95: MOVLW 03
0D96: MOVWF 4B
0D97: MOVLW 02
0D98: MOVWF 4C
0D99: BCF 0A.3
0D9A: CALL 200
0D9B: BSF 0A.3
.................... lcd_putc("www.mlab.cz");
0D9C: MOVLW 2A
0D9D: BSF 03.6
0D9E: MOVWF 0D
0D9F: MOVLW 00
0DA0: MOVWF 0F
0DA1: BCF 0A.3
0DA2: BCF 03.6
0DA3: CALL 23F
0DA4: BSF 0A.3
.................... Delay_ms(2000);
0DA5: MOVLW 08
0DA6: MOVWF 3D
0DA7: MOVLW FA
0DA8: MOVWF 4B
0DA9: BCF 0A.3
0DAA: CALL 0FB
0DAB: BSF 0A.3
0DAC: DECFSZ 3D,F
0DAD: GOTO 5A7
.................... lcd_init();
0DAE: BCF 0A.3
0DAF: CALL 1C8
0DB0: BSF 0A.3
....................
.................... while (TRUE)
.................... {
.................... lcd_gotoxy(1,1);
0DB1: MOVLW 01
0DB2: MOVWF 4B
0DB3: MOVWF 4C
0DB4: BCF 0A.3
0DB5: CALL 200
0DB6: BSF 0A.3
.................... temp1 = SHT25_get_temp();
0DB7: BCF 0A.3
0DB8: GOTO 567
0DB9: BSF 0A.3
0DBA: MOVF 7A,W
0DBB: MOVWF 2A
0DBC: MOVF 79,W
0DBD: MOVWF 29
0DBE: MOVF 78,W
0DBF: MOVWF 28
0DC0: MOVF 77,W
0DC1: MOVWF 27
.................... humidity = SHT25_get_hum();
0DC2: BCF 0A.3
0DC3: GOTO 636
0DC4: BSF 0A.3
0DC5: MOVF 7A,W
0DC6: MOVWF 36
0DC7: MOVF 79,W
0DC8: MOVWF 35
0DC9: MOVF 78,W
0DCA: MOVWF 34
0DCB: MOVF 77,W
0DCC: MOVWF 33
.................... temp2= LTS01_get_temp();
0DCD: BCF 0A.3
0DCE: GOTO 6EC
0DCF: BSF 0A.3
0DD0: MOVF 7A,W
0DD1: MOVWF 2E
0DD2: MOVF 79,W
0DD3: MOVWF 2D
0DD4: MOVF 78,W
0DD5: MOVWF 2C
0DD6: MOVF 77,W
0DD7: MOVWF 2B
.................... hmc5883l_read_data();
0DD8: GOTO 000
....................
.................... temp3=mpl3115_T();
0DD9: GOTO 091
0DDA: MOVF 7A,W
0DDB: MOVWF 32
0DDC: MOVF 79,W
0DDD: MOVWF 31
0DDE: MOVF 78,W
0DDF: MOVWF 30
0DE0: MOVF 77,W
0DE1: MOVWF 2F
.................... preasure=mpl3115_P();
0DE2: GOTO 0F3
0DE3: MOVF 7A,W
0DE4: MOVWF 3A
0DE5: MOVF 79,W
0DE6: MOVWF 39
0DE7: MOVF 78,W
0DE8: MOVWF 38
0DE9: MOVF 77,W
0DEA: MOVWF 37
.................... mpl3115_setP(); //nastaveni pro tlak a teplotu
0DEB: GOTO 1AD
....................
.................... printf(lcd_putc,"%2.2f%cC %2.2f\%%",temp1, 0xb2, humidity);
0DEC: MOVLW 89
0DED: MOVWF 04
0DEE: MOVF 2A,W
0DEF: MOVWF 40
0DF0: MOVF 29,W
0DF1: MOVWF 3F
0DF2: MOVF 28,W
0DF3: MOVWF 3E
0DF4: MOVF 27,W
0DF5: MOVWF 3D
0DF6: MOVLW 02
0DF7: MOVWF 41
0DF8: CALL 2CB
0DF9: MOVLW B2
0DFA: MOVWF 4A
0DFB: BCF 0A.3
0DFC: CALL 212
0DFD: BSF 0A.3
0DFE: MOVLW 43
0DFF: MOVWF 4A
0E00: BCF 0A.3
0E01: CALL 212
0E02: BSF 0A.3
0E03: MOVLW 20
0E04: MOVWF 4A
0E05: BCF 0A.3
0E06: CALL 212
0E07: BSF 0A.3
0E08: MOVLW 89
0E09: MOVWF 04
0E0A: MOVF 36,W
0E0B: MOVWF 40
0E0C: MOVF 35,W
0E0D: MOVWF 3F
0E0E: MOVF 34,W
0E0F: MOVWF 3E
0E10: MOVF 33,W
0E11: MOVWF 3D
0E12: MOVLW 02
0E13: MOVWF 41
0E14: CALL 2CB
0E15: MOVLW 25
0E16: MOVWF 4A
0E17: BCF 0A.3
0E18: CALL 212
0E19: BSF 0A.3
.................... lcd_gotoxy(1,2);
0E1A: MOVLW 01
0E1B: MOVWF 4B
0E1C: MOVLW 02
0E1D: MOVWF 4C
0E1E: BCF 0A.3
0E1F: CALL 200
0E20: BSF 0A.3
.................... printf(lcd_putc,"%2.2f%cC %6.0fPa ",temp2, 0xb2, preasure);
0E21: MOVLW 89
0E22: MOVWF 04
0E23: MOVF 2E,W
0E24: MOVWF 40
0E25: MOVF 2D,W
0E26: MOVWF 3F
0E27: MOVF 2C,W
0E28: MOVWF 3E
0E29: MOVF 2B,W
0E2A: MOVWF 3D
0E2B: MOVLW 02
0E2C: MOVWF 41
0E2D: CALL 2CB
0E2E: MOVLW B2
0E2F: MOVWF 4A
0E30: BCF 0A.3
0E31: CALL 212
0E32: BSF 0A.3
0E33: MOVLW 43
0E34: MOVWF 4A
0E35: BCF 0A.3
0E36: CALL 212
0E37: BSF 0A.3
0E38: MOVLW 20
0E39: MOVWF 4A
0E3A: BCF 0A.3
0E3B: CALL 212
0E3C: BSF 0A.3
0E3D: MOVLW 05
0E3E: MOVWF 04
0E3F: MOVF 3A,W
0E40: MOVWF 40
0E41: MOVF 39,W
0E42: MOVWF 3F
0E43: MOVF 38,W
0E44: MOVWF 3E
0E45: MOVF 37,W
0E46: MOVWF 3D
0E47: CLRF 41
0E48: CALL 2CB
0E49: MOVLW 50
0E4A: MOVWF 4A
0E4B: BCF 0A.3
0E4C: CALL 212
0E4D: BSF 0A.3
0E4E: MOVLW 61
0E4F: MOVWF 4A
0E50: BCF 0A.3
0E51: CALL 212
0E52: BSF 0A.3
0E53: MOVLW 20
0E54: MOVWF 4A
0E55: BCF 0A.3
0E56: CALL 212
0E57: BSF 0A.3
....................
.................... printf("%ld %f %f %f %6.2f %3.2f %Ld %Ld %Ld \n\r",i, temp1, humidity, temp2, preasure, temp3, compass.x, compass.y, compass.z);
0E58: MOVLW 10
0E59: MOVWF 04
0E5A: MOVF 3C,W
0E5B: MOVWF 3E
0E5C: MOVF 3B,W
0E5D: MOVWF 3D
0E5E: CALL 39F
0E5F: MOVLW 20
0E60: BTFSS 0C.4
0E61: GOTO 660
0E62: MOVWF 19
0E63: MOVLW 89
0E64: MOVWF 04
0E65: MOVF 2A,W
0E66: MOVWF 40
0E67: MOVF 29,W
0E68: MOVWF 3F
0E69: MOVF 28,W
0E6A: MOVWF 3E
0E6B: MOVF 27,W
0E6C: MOVWF 3D
0E6D: MOVLW 02
0E6E: MOVWF 41
0E6F: CALL 415
0E70: MOVLW 20
0E71: BTFSS 0C.4
0E72: GOTO 671
0E73: MOVWF 19
0E74: MOVLW 89
0E75: MOVWF 04
0E76: MOVF 36,W
0E77: MOVWF 40
0E78: MOVF 35,W
0E79: MOVWF 3F
0E7A: MOVF 34,W
0E7B: MOVWF 3E
0E7C: MOVF 33,W
0E7D: MOVWF 3D
0E7E: MOVLW 02
0E7F: MOVWF 41
0E80: CALL 415
0E81: MOVLW 20
0E82: BTFSS 0C.4
0E83: GOTO 682
0E84: MOVWF 19
0E85: MOVLW 89
0E86: MOVWF 04
0E87: MOVF 2E,W
0E88: MOVWF 40
0E89: MOVF 2D,W
0E8A: MOVWF 3F
0E8B: MOVF 2C,W
0E8C: MOVWF 3E
0E8D: MOVF 2B,W
0E8E: MOVWF 3D
0E8F: MOVLW 02
0E90: MOVWF 41
0E91: CALL 415
0E92: MOVLW 20
0E93: BTFSS 0C.4
0E94: GOTO 693
0E95: MOVWF 19
0E96: MOVLW 05
0E97: MOVWF 04
0E98: MOVF 3A,W
0E99: MOVWF 40
0E9A: MOVF 39,W
0E9B: MOVWF 3F
0E9C: MOVF 38,W
0E9D: MOVWF 3E
0E9E: MOVF 37,W
0E9F: MOVWF 3D
0EA0: MOVLW 02
0EA1: MOVWF 41
0EA2: CALL 415
0EA3: MOVLW 20
0EA4: BTFSS 0C.4
0EA5: GOTO 6A4
0EA6: MOVWF 19
0EA7: MOVLW 02
0EA8: MOVWF 04
0EA9: MOVF 32,W
0EAA: MOVWF 40
0EAB: MOVF 31,W
0EAC: MOVWF 3F
0EAD: MOVF 30,W
0EAE: MOVWF 3E
0EAF: MOVF 2F,W
0EB0: MOVWF 3D
0EB1: MOVLW 02
0EB2: MOVWF 41
0EB3: CALL 415
0EB4: MOVLW 20
0EB5: BTFSS 0C.4
0EB6: GOTO 6B5
0EB7: MOVWF 19
0EB8: MOVLW 10
0EB9: MOVWF 04
0EBA: MOVF 22,W
0EBB: MOVWF 3E
0EBC: MOVF 21,W
0EBD: MOVWF 3D
0EBE: CALL 39F
0EBF: MOVLW 20
0EC0: BTFSS 0C.4
0EC1: GOTO 6C0
0EC2: MOVWF 19
0EC3: MOVLW 10
0EC4: MOVWF 04
0EC5: MOVF 24,W
0EC6: MOVWF 3E
0EC7: MOVF 23,W
0EC8: MOVWF 3D
0EC9: CALL 39F
0ECA: MOVLW 20
0ECB: BTFSS 0C.4
0ECC: GOTO 6CB
0ECD: MOVWF 19
0ECE: MOVLW 10
0ECF: MOVWF 04
0ED0: MOVF 26,W
0ED1: MOVWF 3E
0ED2: MOVF 25,W
0ED3: MOVWF 3D
0ED4: CALL 39F
0ED5: MOVLW 20
0ED6: BTFSS 0C.4
0ED7: GOTO 6D6
0ED8: MOVWF 19
0ED9: MOVLW 0A
0EDA: BTFSS 0C.4
0EDB: GOTO 6DA
0EDC: MOVWF 19
0EDD: MOVLW 0D
0EDE: BTFSS 0C.4
0EDF: GOTO 6DE
0EE0: MOVWF 19
.................... i++;
0EE1: INCF 3B,F
0EE2: BTFSC 03.2
0EE3: INCF 3C,F
....................
.................... Delay_ms(100);
0EE4: MOVLW 64
0EE5: MOVWF 4B
0EE6: BCF 0A.3
0EE7: CALL 0FB
0EE8: BSF 0A.3
.................... }
0EE9: GOTO 5B1
....................
.................... }
0EEA: SLEEP
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40