Rev Author Line No. Line
3283 kakl 1 CCS PCM C Compiler, Version 4.106, 47914 03-IX-13 00:32
3275 kaklik 2  
3283 kakl 3 Filename: D:\MLAB\Designs\Measuring_instruments\GeoMet01A\SW\PIC16F887\main.lst
3275 kaklik 4  
3283 kakl 5 ROM used: 3183 words (39%)
3275 kaklik 6 Largest free fragment is 2048
3283 kakl 7 RAM used: 27 (7%) at main() level
8 52 (14%) worst case
3275 kaklik 9 Stack: 5 locations
10  
11 *
12 0000: MOVLW 0A
13 0001: MOVWF 0A
3283 kakl 14 0002: GOTO 2B7
3275 kaklik 15 0003: NOP
16 .................... #include "main.h"
17 .................... #include <16F887.h>
18 .................... //////// Standard Header file for the PIC16F887 device ////////////////
19 .................... #device PIC16F887
20 .................... #list
21 ....................
22 .................... #device adc=10
23 ....................
24 .................... #FUSES NOWDT //No Watch Dog Timer
25 .................... #FUSES INTRC //Internal RC Osc
26 .................... #FUSES NOPUT //No Power Up Timer
27 .................... #FUSES MCLR //Master Clear pin enabled
28 .................... #FUSES NOPROTECT //Code not protected from reading
29 .................... #FUSES NOCPD //No EE protection
30 .................... #FUSES NOBROWNOUT //No brownout reset
31 .................... #FUSES IESO //Internal External Switch Over mode enabled
32 .................... #FUSES FCMEN //Fail-safe clock monitor enabled
33 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
34 .................... #FUSES NODEBUG //No Debug mode for ICD
35 .................... #FUSES NOWRT //Program memory not write protected
36 .................... #FUSES BORV40 //Brownout reset at 4.0V
37 ....................
38 .................... #use delay(clock=8000000)
39 *
3283 kakl 40 00FB: MOVLW 43
41 00FC: MOVWF 04
42 00FD: BCF 03.7
43 00FE: MOVF 00,W
44 00FF: BTFSC 03.2
45 0100: GOTO 10E
46 0101: MOVLW 02
47 0102: MOVWF 78
48 0103: CLRF 77
49 0104: DECFSZ 77,F
50 0105: GOTO 104
51 0106: DECFSZ 78,F
52 0107: GOTO 103
53 0108: MOVLW 97
54 0109: MOVWF 77
55 010A: DECFSZ 77,F
56 010B: GOTO 10A
57 010C: DECFSZ 00,F
58 010D: GOTO 101
59 010E: RETURN
3275 kaklik 60 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
61 *
3283 kakl 62 0078: MOVLW 08
63 0079: MOVWF 78
64 007A: NOP
65 007B: BCF 07.3
66 007C: BCF 20.3
67 007D: MOVF 20,W
68 007E: BSF 03.5
69 007F: MOVWF 07
70 0080: NOP
71 0081: BCF 03.5
72 0082: RLF 3B,F
73 0083: BCF 07.4
74 0084: BTFSS 03.0
75 0085: GOTO 08C
76 0086: BSF 20.4
77 0087: MOVF 20,W
78 0088: BSF 03.5
79 0089: MOVWF 07
80 008A: GOTO 090
81 008B: BCF 03.5
82 008C: BCF 20.4
83 008D: MOVF 20,W
84 008E: BSF 03.5
85 008F: MOVWF 07
86 0090: NOP
87 0091: BCF 03.5
88 0092: BSF 20.3
89 0093: MOVF 20,W
90 0094: BSF 03.5
91 0095: MOVWF 07
92 0096: BCF 03.5
93 0097: BTFSS 07.3
94 0098: GOTO 097
95 0099: DECFSZ 78,F
96 009A: GOTO 07A
97 009B: NOP
98 009C: BCF 07.3
99 009D: BCF 20.3
100 009E: MOVF 20,W
101 009F: BSF 03.5
102 00A0: MOVWF 07
103 00A1: NOP
104 00A2: BCF 03.5
105 00A3: BSF 20.4
106 00A4: MOVF 20,W
107 00A5: BSF 03.5
108 00A6: MOVWF 07
109 00A7: NOP
110 00A8: NOP
111 00A9: BCF 03.5
112 00AA: BSF 20.3
113 00AB: MOVF 20,W
114 00AC: BSF 03.5
115 00AD: MOVWF 07
116 00AE: BCF 03.5
117 00AF: BTFSS 07.3
118 00B0: GOTO 0AF
119 00B1: CLRF 78
120 00B2: NOP
121 00B3: BTFSC 07.4
122 00B4: BSF 78.0
123 00B5: BCF 07.3
124 00B6: BCF 20.3
125 00B7: MOVF 20,W
126 00B8: BSF 03.5
127 00B9: MOVWF 07
128 00BA: BCF 03.5
129 00BB: BCF 07.4
130 00BC: BCF 20.4
131 00BD: MOVF 20,W
132 00BE: BSF 03.5
133 00BF: MOVWF 07
134 00C0: BCF 03.5
135 00C1: RETURN
136 *
137 0285: MOVLW 08
138 0286: MOVWF 3C
139 0287: MOVF 77,W
140 0288: MOVWF 3D
141 0289: BSF 20.4
142 028A: MOVF 20,W
143 028B: BSF 03.5
144 028C: MOVWF 07
145 028D: NOP
146 028E: BCF 03.5
147 028F: BSF 20.3
148 0290: MOVF 20,W
149 0291: BSF 03.5
150 0292: MOVWF 07
151 0293: BCF 03.5
152 0294: BTFSS 07.3
153 0295: GOTO 294
154 0296: BTFSC 07.4
155 0297: BSF 03.0
156 0298: BTFSS 07.4
157 0299: BCF 03.0
158 029A: RLF 78,F
159 029B: NOP
160 029C: BCF 20.3
161 029D: MOVF 20,W
162 029E: BSF 03.5
163 029F: MOVWF 07
164 02A0: BCF 03.5
165 02A1: BCF 07.3
166 02A2: DECFSZ 3C,F
167 02A3: GOTO 289
168 02A4: BSF 20.4
169 02A5: MOVF 20,W
170 02A6: BSF 03.5
171 02A7: MOVWF 07
172 02A8: NOP
173 02A9: BCF 03.5
174 02AA: BCF 07.4
175 02AB: MOVF 3D,W
176 02AC: BTFSC 03.2
177 02AD: GOTO 2B3
178 02AE: BCF 20.4
179 02AF: MOVF 20,W
180 02B0: BSF 03.5
181 02B1: MOVWF 07
182 02B2: BCF 03.5
183 02B3: NOP
184 02B4: BSF 20.3
185 02B5: MOVF 20,W
186 02B6: BSF 03.5
187 02B7: MOVWF 07
188 02B8: BCF 03.5
189 02B9: BTFSS 07.3
190 02BA: GOTO 2B9
191 02BB: NOP
192 02BC: BCF 07.3
193 02BD: BCF 20.3
194 02BE: MOVF 20,W
195 02BF: BSF 03.5
196 02C0: MOVWF 07
197 02C1: NOP
198 02C2: BCF 03.5
199 02C3: BCF 07.4
200 02C4: BCF 20.4
201 02C5: MOVF 20,W
202 02C6: BSF 03.5
203 02C7: MOVWF 07
204 02C8: BCF 03.5
205 02C9: RETURN
3275 kaklik 206 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
207 ....................
208 ....................
209 ....................
210 .................... #define LCD_ENABLE_PIN PIN_E0 ////
211 .................... #define LCD_RS_PIN PIN_E1 ////
212 .................... #define LCD_RW_PIN PIN_E2 ////
213 .................... #define LCD_DATA4 PIN_D4 ////
214 .................... #define LCD_DATA5 PIN_D5 ////
215 .................... #define LCD_DATA6 PIN_D6 ////
216 .................... #define LCD_DATA7 PIN_D7
217 .................... #include <lcd.c>
218 .................... ///////////////////////////////////////////////////////////////////////////////
219 .................... //// LCD.C ////
220 .................... //// Driver for common LCD modules ////
221 .................... //// ////
222 .................... //// lcd_init() Must be called before any other function. ////
223 .................... //// ////
224 .................... //// lcd_putc(c) Will display c on the next position of the LCD. ////
225 .................... //// \a Set cursor position to upper left ////
226 .................... //// \f Clear display, set cursor to upper left ////
227 .................... //// \n Go to start of second line ////
228 .................... //// \b Move back one position ////
229 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character ////
230 .................... //// will erase all remanining characters on the current ////
231 .................... //// line, and move the cursor to the beginning of the next ////
232 .................... //// line. ////
233 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character ////
234 .................... //// will move the cursor to the start of the current ////
235 .................... //// line. ////
236 .................... //// ////
237 .................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
238 .................... //// ////
239 .................... //// lcd_getc(x,y) Returns character at position x,y on LCD ////
240 .................... //// ////
241 .................... //// CONFIGURATION ////
242 .................... //// The LCD can be configured in one of two ways: a.) port access or ////
243 .................... //// b.) pin access. Port access requires the entire 7 bit interface ////
244 .................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) ////
245 .................... //// connected to sequential pins on the GPIO. Pin access ////
246 .................... //// has no requirements, all 7 bits of the control interface can ////
247 .................... //// can be connected to any GPIO using several ports. ////
248 .................... //// ////
249 .................... //// To use port access, #define LCD_DATA_PORT to the SFR location of ////
250 .................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////
251 .................... //// of this file to configure the pin order. If you are using a ////
252 .................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////
253 .................... //// be defined. ////
254 .................... //// ////
255 .................... //// Example of port access: ////
256 .................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") ////
257 .................... //// ////
258 .................... //// To use pin access, the following pins must be defined: ////
259 .................... //// LCD_ENABLE_PIN ////
260 .................... //// LCD_RS_PIN ////
261 .................... //// LCD_RW_PIN ////
262 .................... //// LCD_DATA4 ////
263 .................... //// LCD_DATA5 ////
264 .................... //// LCD_DATA6 ////
265 .................... //// LCD_DATA7 ////
266 .................... //// ////
267 .................... //// Example of pin access: ////
268 .................... //// #define LCD_ENABLE_PIN PIN_E0 ////
269 .................... //// #define LCD_RS_PIN PIN_E1 ////
270 .................... //// #define LCD_RW_PIN PIN_E2 ////
271 .................... //// #define LCD_DATA4 PIN_D4 ////
272 .................... //// #define LCD_DATA5 PIN_D5 ////
273 .................... //// #define LCD_DATA6 PIN_D6 ////
274 .................... //// #define LCD_DATA7 PIN_D7 ////
275 .................... //// ////
276 .................... ///////////////////////////////////////////////////////////////////////////////
277 .................... //// (C) Copyright 1996,2010 Custom Computer Services ////
278 .................... //// This source code may only be used by licensed users of the CCS C ////
279 .................... //// compiler. This source code may only be distributed to other ////
280 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
281 .................... //// or distribution is permitted without written permission. ////
282 .................... //// Derivative programs created using this software in object code ////
283 .................... //// form are not restricted in any way. ////
284 .................... ///////////////////////////////////////////////////////////////////////////
285 ....................
286 .................... // define the pinout.
287 .................... // only required if port access is being used.
288 .................... typedef struct
289 .................... { // This structure is overlayed
290 .................... BOOLEAN enable; // on to an I/O port to gain
291 .................... BOOLEAN rs; // access to the LCD pins.
292 .................... BOOLEAN rw; // The bits are allocated from
293 .................... BOOLEAN unused; // low order up. ENABLE will
294 .................... int data : 4; // be LSB pin of that port.
295 .................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT.
296 .................... int reserved: 8;
297 .................... #endif
298 .................... } LCD_PIN_MAP;
299 ....................
300 .................... // this is to improve compatability with previous LCD drivers that accepted
301 .................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
302 .................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
303 .................... #define LCD_DATA_PORT getenv("SFR:PORTB")
304 .................... #endif
305 ....................
306 .................... #if defined(__PCB__)
307 .................... // these definitions only need to be modified for baseline PICs.
308 .................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
309 .................... /* EN, RS, RW, UNUSED, DATA */
310 .................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0};
311 .................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF};
312 .................... #endif
313 ....................
314 .................... ////////////////////// END CONFIGURATION ///////////////////////////////////
315 ....................
316 .................... #ifndef LCD_ENABLE_PIN
317 .................... #define lcd_output_enable(x) lcdlat.enable=x
318 .................... #define lcd_enable_tris() lcdtris.enable=0
319 .................... #else
320 .................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
321 .................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN)
322 .................... #endif
323 ....................
324 .................... #ifndef LCD_RS_PIN
325 .................... #define lcd_output_rs(x) lcdlat.rs=x
326 .................... #define lcd_rs_tris() lcdtris.rs=0
327 .................... #else
328 .................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
329 .................... #define lcd_rs_tris() output_drive(LCD_RS_PIN)
330 .................... #endif
331 ....................
332 .................... #ifndef LCD_RW_PIN
333 .................... #define lcd_output_rw(x) lcdlat.rw=x
334 .................... #define lcd_rw_tris() lcdtris.rw=0
335 .................... #else
336 .................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
337 .................... #define lcd_rw_tris() output_drive(LCD_RW_PIN)
338 .................... #endif
339 ....................
340 .................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
341 .................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver
342 .................... // compatible with any code written for the original library
343 .................... #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))
344 .................... #define LCD_DATA4 LCD_DATA0
345 .................... #define LCD_DATA5 LCD_DATA1
346 .................... #define LCD_DATA6 LCD_DATA2
347 .................... #define LCD_DATA7 LCD_DATA3
348 .................... #endif
349 ....................
350 .................... #ifndef LCD_DATA4
351 .................... #ifndef LCD_DATA_PORT
352 .................... #if defined(__PCB__)
353 .................... #define LCD_DATA_PORT 0x06 //portb
354 .................... #define set_tris_lcd(x) set_tris_b(x)
355 .................... #else
356 .................... #if defined(PIN_D0)
357 .................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd
358 .................... #else
359 .................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb
360 .................... #endif
361 .................... #endif
362 .................... #endif
363 ....................
364 .................... #if defined(__PCB__)
365 .................... LCD_PIN_MAP lcd, lcdlat;
366 .................... #byte lcd = LCD_DATA_PORT
367 .................... #byte lcdlat = LCD_DATA_PORT
368 .................... #elif defined(__PCM__)
369 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
370 .................... #byte lcd = LCD_DATA_PORT
371 .................... #byte lcdlat = LCD_DATA_PORT
372 .................... #byte lcdtris = LCD_DATA_PORT+0x80
373 .................... #elif defined(__PCH__)
374 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
375 .................... #byte lcd = LCD_DATA_PORT
376 .................... #byte lcdlat = LCD_DATA_PORT+9
377 .................... #byte lcdtris = LCD_DATA_PORT+0x12
378 .................... #elif defined(__PCD__)
379 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
380 .................... #word lcd = LCD_DATA_PORT
381 .................... #word lcdlat = LCD_DATA_PORT+2
382 .................... #word lcdtris = LCD_DATA_PORT-0x02
383 .................... #endif
384 .................... #endif //LCD_DATA4 not defined
385 ....................
386 .................... #ifndef LCD_TYPE
387 .................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines
388 .................... #endif
389 ....................
390 .................... #ifndef LCD_LINE_TWO
391 .................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line
392 .................... #endif
393 ....................
394 .................... #ifndef LCD_LINE_LENGTH
395 .................... #define LCD_LINE_LENGTH 20
396 .................... #endif
397 ....................
398 .................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
399 .................... // These bytes need to be sent to the LCD
400 .................... // to start it up.
401 ....................
402 .................... BYTE lcd_read_nibble(void);
403 ....................
404 .................... BYTE lcd_read_byte(void)
405 .................... {
406 .................... BYTE low,high;
407 ....................
408 .................... #if defined(__PCB__)
409 .................... set_tris_lcd(LCD_INPUT_MAP);
410 .................... #else
411 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
412 .................... output_float(LCD_DATA4);
413 *
3283 kakl 414 0174: BSF 08.4
3275 kaklik 415 .................... output_float(LCD_DATA5);
3283 kakl 416 0175: BSF 08.5
3275 kaklik 417 .................... output_float(LCD_DATA6);
3283 kakl 418 0176: BSF 08.6
3275 kaklik 419 .................... output_float(LCD_DATA7);
3283 kakl 420 0177: BSF 08.7
3275 kaklik 421 .................... #else
422 .................... lcdtris.data = 0xF;
423 .................... #endif
424 .................... #endif
425 ....................
426 .................... lcd_output_rw(1);
3283 kakl 427 0178: BCF 03.5
428 0179: BSF 09.2
429 017A: BSF 03.5
430 017B: BCF 09.2
3275 kaklik 431 .................... delay_cycles(1);
3283 kakl 432 017C: NOP
3275 kaklik 433 .................... lcd_output_enable(1);
3283 kakl 434 017D: BCF 03.5
435 017E: BSF 09.0
436 017F: BSF 03.5
437 0180: BCF 09.0
3275 kaklik 438 .................... delay_cycles(1);
3283 kakl 439 0181: NOP
3275 kaklik 440 .................... high = lcd_read_nibble();
3283 kakl 441 0182: BCF 03.5
442 0183: CALL 13B
443 0184: MOVF 78,W
444 0185: MOVWF 4A
3275 kaklik 445 ....................
446 .................... lcd_output_enable(0);
3283 kakl 447 0186: BCF 09.0
448 0187: BSF 03.5
449 0188: BCF 09.0
3275 kaklik 450 .................... delay_cycles(1);
3283 kakl 451 0189: NOP
3275 kaklik 452 .................... lcd_output_enable(1);
3283 kakl 453 018A: BCF 03.5
454 018B: BSF 09.0
455 018C: BSF 03.5
456 018D: BCF 09.0
3275 kaklik 457 .................... delay_us(1);
3283 kakl 458 018E: GOTO 18F
3275 kaklik 459 .................... low = lcd_read_nibble();
3283 kakl 460 018F: BCF 03.5
461 0190: CALL 13B
462 0191: MOVF 78,W
463 0192: MOVWF 49
3275 kaklik 464 ....................
465 .................... lcd_output_enable(0);
3283 kakl 466 0193: BCF 09.0
467 0194: BSF 03.5
468 0195: BCF 09.0
3275 kaklik 469 ....................
470 .................... #if defined(__PCB__)
471 .................... set_tris_lcd(LCD_OUTPUT_MAP);
472 .................... #else
473 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
474 .................... output_drive(LCD_DATA4);
3283 kakl 475 0196: BCF 08.4
3275 kaklik 476 .................... output_drive(LCD_DATA5);
3283 kakl 477 0197: BCF 08.5
3275 kaklik 478 .................... output_drive(LCD_DATA6);
3283 kakl 479 0198: BCF 08.6
3275 kaklik 480 .................... output_drive(LCD_DATA7);
3283 kakl 481 0199: BCF 08.7
3275 kaklik 482 .................... #else
483 .................... lcdtris.data = 0x0;
484 .................... #endif
485 .................... #endif
486 ....................
487 .................... return( (high<<4) | low);
3283 kakl 488 019A: BCF 03.5
489 019B: SWAPF 4A,W
490 019C: MOVWF 77
491 019D: MOVLW F0
492 019E: ANDWF 77,F
493 019F: MOVF 77,W
494 01A0: IORWF 49,W
495 01A1: MOVWF 78
3275 kaklik 496 .................... }
497 ....................
498 .................... BYTE lcd_read_nibble(void)
499 .................... {
500 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
501 *
3283 kakl 502 013B: CLRF 4B
3275 kaklik 503 .................... BYTE n = 0x00;
504 ....................
505 .................... /* Read the data port */
506 .................... n |= input(LCD_DATA4);
3283 kakl 507 013C: BSF 03.5
508 013D: BSF 08.4
509 013E: MOVLW 00
510 013F: BCF 03.5
511 0140: BTFSC 08.4
512 0141: MOVLW 01
513 0142: IORWF 4B,F
3275 kaklik 514 .................... n |= input(LCD_DATA5) << 1;
3283 kakl 515 0143: BSF 03.5
516 0144: BSF 08.5
517 0145: MOVLW 00
518 0146: BCF 03.5
519 0147: BTFSC 08.5
520 0148: MOVLW 01
521 0149: MOVWF 77
522 014A: BCF 03.0
523 014B: RLF 77,F
524 014C: MOVF 77,W
525 014D: IORWF 4B,F
3275 kaklik 526 .................... n |= input(LCD_DATA6) << 2;
3283 kakl 527 014E: BSF 03.5
528 014F: BSF 08.6
529 0150: MOVLW 00
530 0151: BCF 03.5
531 0152: BTFSC 08.6
532 0153: MOVLW 01
533 0154: MOVWF 77
534 0155: RLF 77,F
535 0156: RLF 77,F
536 0157: MOVLW FC
537 0158: ANDWF 77,F
538 0159: MOVF 77,W
539 015A: IORWF 4B,F
3275 kaklik 540 .................... n |= input(LCD_DATA7) << 3;
3283 kakl 541 015B: BSF 03.5
542 015C: BSF 08.7
543 015D: MOVLW 00
544 015E: BCF 03.5
545 015F: BTFSC 08.7
546 0160: MOVLW 01
547 0161: MOVWF 77
548 0162: RLF 77,F
549 0163: RLF 77,F
550 0164: RLF 77,F
551 0165: MOVLW F8
552 0166: ANDWF 77,F
553 0167: MOVF 77,W
554 0168: IORWF 4B,F
3275 kaklik 555 ....................
556 .................... return(n);
3283 kakl 557 0169: MOVF 4B,W
558 016A: MOVWF 78
3275 kaklik 559 .................... #else
560 .................... return(lcd.data);
561 .................... #endif
562 .................... }
3283 kakl 563 016B: RETURN
3275 kaklik 564 ....................
565 .................... void lcd_send_nibble(BYTE n)
566 .................... {
567 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
568 .................... /* Write to the data port */
569 .................... output_bit(LCD_DATA4, bit_test(n, 0));
570 *
3283 kakl 571 010F: BTFSC 4A.0
572 0110: GOTO 113
573 0111: BCF 08.4
574 0112: GOTO 114
575 0113: BSF 08.4
576 0114: BSF 03.5
577 0115: BCF 08.4
3275 kaklik 578 .................... output_bit(LCD_DATA5, bit_test(n, 1));
3283 kakl 579 0116: BCF 03.5
580 0117: BTFSC 4A.1
581 0118: GOTO 11B
582 0119: BCF 08.5
583 011A: GOTO 11C
584 011B: BSF 08.5
585 011C: BSF 03.5
586 011D: BCF 08.5
3275 kaklik 587 .................... output_bit(LCD_DATA6, bit_test(n, 2));
3283 kakl 588 011E: BCF 03.5
589 011F: BTFSC 4A.2
590 0120: GOTO 123
591 0121: BCF 08.6
592 0122: GOTO 124
593 0123: BSF 08.6
594 0124: BSF 03.5
595 0125: BCF 08.6
3275 kaklik 596 .................... output_bit(LCD_DATA7, bit_test(n, 3));
3283 kakl 597 0126: BCF 03.5
598 0127: BTFSC 4A.3
599 0128: GOTO 12B
600 0129: BCF 08.7
601 012A: GOTO 12C
602 012B: BSF 08.7
603 012C: BSF 03.5
604 012D: BCF 08.7
3275 kaklik 605 .................... #else
606 .................... lcdlat.data = n;
607 .................... #endif
608 ....................
609 .................... delay_cycles(1);
3283 kakl 610 012E: NOP
3275 kaklik 611 .................... lcd_output_enable(1);
3283 kakl 612 012F: BCF 03.5
613 0130: BSF 09.0
614 0131: BSF 03.5
615 0132: BCF 09.0
3275 kaklik 616 .................... delay_us(2);
3283 kakl 617 0133: GOTO 134
618 0134: GOTO 135
3275 kaklik 619 .................... lcd_output_enable(0);
3283 kakl 620 0135: BCF 03.5
621 0136: BCF 09.0
622 0137: BSF 03.5
623 0138: BCF 09.0
3275 kaklik 624 .................... }
3283 kakl 625 0139: BCF 03.5
626 013A: RETURN
3275 kaklik 627 ....................
628 .................... void lcd_send_byte(BYTE address, BYTE n)
629 .................... {
630 .................... #if defined(__PCB__)
631 .................... set_tris_lcd(LCD_OUTPUT_MAP);
632 .................... #else
633 .................... lcd_enable_tris();
634 *
3283 kakl 635 016C: BSF 03.5
636 016D: BCF 09.0
3275 kaklik 637 .................... lcd_rs_tris();
3283 kakl 638 016E: BCF 09.1
3275 kaklik 639 .................... lcd_rw_tris();
3283 kakl 640 016F: BCF 09.2
3275 kaklik 641 .................... #endif
642 ....................
643 .................... lcd_output_rs(0);
3283 kakl 644 0170: BCF 03.5
645 0171: BCF 09.1
646 0172: BSF 03.5
647 0173: BCF 09.1
3275 kaklik 648 .................... while ( bit_test(lcd_read_byte(),7) ) ;
649 *
3283 kakl 650 01A2: MOVF 78,W
651 01A3: MOVWF 49
652 01A4: BTFSS 49.7
653 01A5: GOTO 1A8
654 01A6: BSF 03.5
655 01A7: GOTO 174
3275 kaklik 656 .................... lcd_output_rs(address);
3283 kakl 657 01A8: MOVF 47,F
658 01A9: BTFSS 03.2
659 01AA: GOTO 1AD
660 01AB: BCF 09.1
661 01AC: GOTO 1AE
662 01AD: BSF 09.1
663 01AE: BSF 03.5
664 01AF: BCF 09.1
3275 kaklik 665 .................... delay_cycles(1);
3283 kakl 666 01B0: NOP
3275 kaklik 667 .................... lcd_output_rw(0);
3283 kakl 668 01B1: BCF 03.5
669 01B2: BCF 09.2
670 01B3: BSF 03.5
671 01B4: BCF 09.2
3275 kaklik 672 .................... delay_cycles(1);
3283 kakl 673 01B5: NOP
3275 kaklik 674 .................... lcd_output_enable(0);
3283 kakl 675 01B6: BCF 03.5
676 01B7: BCF 09.0
677 01B8: BSF 03.5
678 01B9: BCF 09.0
3275 kaklik 679 .................... lcd_send_nibble(n >> 4);
3283 kakl 680 01BA: BCF 03.5
681 01BB: SWAPF 48,W
682 01BC: MOVWF 49
683 01BD: MOVLW 0F
684 01BE: ANDWF 49,F
685 01BF: MOVF 49,W
686 01C0: MOVWF 4A
687 01C1: CALL 10F
3275 kaklik 688 .................... lcd_send_nibble(n & 0xf);
3283 kakl 689 01C2: MOVF 48,W
690 01C3: ANDLW 0F
691 01C4: MOVWF 49
692 01C5: MOVWF 4A
693 01C6: CALL 10F
3275 kaklik 694 .................... }
3283 kakl 695 01C7: RETURN
3275 kaklik 696 ....................
697 .................... #if defined(LCD_EXTENDED_NEWLINE)
698 .................... unsigned int8 g_LcdX, g_LcdY;
699 .................... #endif
700 ....................
701 .................... void lcd_init(void)
702 .................... {
703 .................... BYTE i;
704 ....................
705 .................... #if defined(__PCB__)
706 .................... set_tris_lcd(LCD_OUTPUT_MAP);
707 .................... #else
708 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
709 .................... output_drive(LCD_DATA4);
3283 kakl 710 01C8: BSF 03.5
711 01C9: BCF 08.4
3275 kaklik 712 .................... output_drive(LCD_DATA5);
3283 kakl 713 01CA: BCF 08.5
3275 kaklik 714 .................... output_drive(LCD_DATA6);
3283 kakl 715 01CB: BCF 08.6
3275 kaklik 716 .................... output_drive(LCD_DATA7);
3283 kakl 717 01CC: BCF 08.7
3275 kaklik 718 .................... #else
719 .................... lcdtris.data = 0x0;
720 .................... #endif
721 .................... lcd_enable_tris();
3283 kakl 722 01CD: BCF 09.0
3275 kaklik 723 .................... lcd_rs_tris();
3283 kakl 724 01CE: BCF 09.1
3275 kaklik 725 .................... lcd_rw_tris();
3283 kakl 726 01CF: BCF 09.2
3275 kaklik 727 .................... #endif
728 ....................
729 .................... lcd_output_rs(0);
3283 kakl 730 01D0: BCF 03.5
731 01D1: BCF 09.1
732 01D2: BSF 03.5
733 01D3: BCF 09.1
3275 kaklik 734 .................... lcd_output_rw(0);
3283 kakl 735 01D4: BCF 03.5
736 01D5: BCF 09.2
737 01D6: BSF 03.5
738 01D7: BCF 09.2
3275 kaklik 739 .................... lcd_output_enable(0);
3283 kakl 740 01D8: BCF 03.5
741 01D9: BCF 09.0
742 01DA: BSF 03.5
743 01DB: BCF 09.0
3275 kaklik 744 ....................
745 .................... delay_ms(15);
3283 kakl 746 01DC: MOVLW 0F
747 01DD: BCF 03.5
748 01DE: MOVWF 43
749 01DF: CALL 0FB
3275 kaklik 750 .................... for(i=1;i<=3;++i)
3283 kakl 751 01E0: MOVLW 01
752 01E1: MOVWF 35
753 01E2: MOVF 35,W
754 01E3: SUBLW 03
755 01E4: BTFSS 03.0
756 01E5: GOTO 1EE
3275 kaklik 757 .................... {
758 .................... lcd_send_nibble(3);
3283 kakl 759 01E6: MOVLW 03
760 01E7: MOVWF 4A
761 01E8: CALL 10F
3275 kaklik 762 .................... delay_ms(5);
3283 kakl 763 01E9: MOVLW 05
764 01EA: MOVWF 43
765 01EB: CALL 0FB
3275 kaklik 766 .................... }
3283 kakl 767 01EC: INCF 35,F
768 01ED: GOTO 1E2
3275 kaklik 769 ....................
770 .................... lcd_send_nibble(2);
3283 kakl 771 01EE: MOVLW 02
772 01EF: MOVWF 4A
773 01F0: CALL 10F
3275 kaklik 774 .................... for(i=0;i<=3;++i)
3283 kakl 775 01F1: CLRF 35
776 01F2: MOVF 35,W
777 01F3: SUBLW 03
778 01F4: BTFSS 03.0
779 01F5: GOTO 1FF
3275 kaklik 780 .................... lcd_send_byte(0,LCD_INIT_STRING[i]);
3283 kakl 781 01F6: MOVF 35,W
782 01F7: CALL 004
783 01F8: MOVWF 36
784 01F9: CLRF 47
785 01FA: MOVF 36,W
786 01FB: MOVWF 48
787 01FC: CALL 16C
3275 kaklik 788 ....................
789 .................... #if defined(LCD_EXTENDED_NEWLINE)
3283 kakl 790 01FD: INCF 35,F
791 01FE: GOTO 1F2
3275 kaklik 792 .................... g_LcdX = 0;
793 .................... g_LcdY = 0;
794 .................... #endif
795 .................... }
3283 kakl 796 01FF: RETURN
3275 kaklik 797 ....................
798 .................... void lcd_gotoxy(BYTE x, BYTE y)
799 .................... {
800 .................... BYTE address;
801 ....................
802 .................... if(y!=1)
3283 kakl 803 0200: DECFSZ 44,W
804 0201: GOTO 203
805 0202: GOTO 206
3275 kaklik 806 .................... address=LCD_LINE_TWO;
3283 kakl 807 0203: MOVLW 40
808 0204: MOVWF 45
3275 kaklik 809 .................... else
3283 kakl 810 0205: GOTO 207
3275 kaklik 811 .................... address=0;
3283 kakl 812 0206: CLRF 45
3275 kaklik 813 ....................
814 .................... address+=x-1;
3283 kakl 815 0207: MOVLW 01
816 0208: SUBWF 43,W
817 0209: ADDWF 45,F
3275 kaklik 818 .................... lcd_send_byte(0,0x80|address);
3283 kakl 819 020A: MOVF 45,W
820 020B: IORLW 80
821 020C: MOVWF 46
822 020D: CLRF 47
823 020E: MOVF 46,W
824 020F: MOVWF 48
825 0210: CALL 16C
3275 kaklik 826 ....................
827 .................... #if defined(LCD_EXTENDED_NEWLINE)
828 .................... g_LcdX = x - 1;
829 .................... g_LcdY = y - 1;
830 .................... #endif
831 .................... }
3283 kakl 832 0211: RETURN
3275 kaklik 833 ....................
834 .................... void lcd_putc(char c)
835 .................... {
836 .................... switch (c)
837 .................... {
3283 kakl 838 0212: MOVF 42,W
839 0213: XORLW 07
840 0214: BTFSC 03.2
841 0215: GOTO 220
842 0216: XORLW 0B
843 0217: BTFSC 03.2
844 0218: GOTO 225
845 0219: XORLW 06
846 021A: BTFSC 03.2
847 021B: GOTO 22D
848 021C: XORLW 02
849 021D: BTFSC 03.2
850 021E: GOTO 233
851 021F: GOTO 238
3275 kaklik 852 .................... case '\a' : lcd_gotoxy(1,1); break;
3283 kakl 853 0220: MOVLW 01
854 0221: MOVWF 43
855 0222: MOVWF 44
856 0223: CALL 200
857 0224: GOTO 23E
3275 kaklik 858 ....................
859 .................... case '\f' : lcd_send_byte(0,1);
3283 kakl 860 0225: CLRF 47
861 0226: MOVLW 01
862 0227: MOVWF 48
863 0228: CALL 16C
3275 kaklik 864 .................... delay_ms(2);
3283 kakl 865 0229: MOVLW 02
866 022A: MOVWF 43
867 022B: CALL 0FB
3275 kaklik 868 .................... #if defined(LCD_EXTENDED_NEWLINE)
869 .................... g_LcdX = 0;
870 .................... g_LcdY = 0;
871 .................... #endif
872 .................... break;
3283 kakl 873 022C: GOTO 23E
3275 kaklik 874 ....................
875 .................... #if defined(LCD_EXTENDED_NEWLINE)
876 .................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break;
877 .................... case '\n' :
878 .................... while (g_LcdX++ < LCD_LINE_LENGTH)
879 .................... {
880 .................... lcd_send_byte(1, ' ');
881 .................... }
882 .................... lcd_gotoxy(1, g_LcdY+2);
883 .................... break;
884 .................... #else
885 .................... case '\n' : lcd_gotoxy(1,2); break;
3283 kakl 886 022D: MOVLW 01
887 022E: MOVWF 43
888 022F: MOVLW 02
889 0230: MOVWF 44
890 0231: CALL 200
891 0232: GOTO 23E
3275 kaklik 892 .................... #endif
893 ....................
894 .................... case '\b' : lcd_send_byte(0,0x10); break;
3283 kakl 895 0233: CLRF 47
896 0234: MOVLW 10
897 0235: MOVWF 48
898 0236: CALL 16C
899 0237: GOTO 23E
3275 kaklik 900 ....................
901 .................... #if defined(LCD_EXTENDED_NEWLINE)
902 .................... default :
903 .................... if (g_LcdX < LCD_LINE_LENGTH)
904 .................... {
905 .................... lcd_send_byte(1, c);
906 .................... g_LcdX++;
907 .................... }
908 .................... break;
909 .................... #else
910 .................... default : lcd_send_byte(1,c); break;
3283 kakl 911 0238: MOVLW 01
912 0239: MOVWF 47
913 023A: MOVF 42,W
914 023B: MOVWF 48
915 023C: CALL 16C
916 023D: GOTO 23E
3275 kaklik 917 .................... #endif
918 .................... }
919 .................... }
3283 kakl 920 023E: RETURN
3275 kaklik 921 ....................
922 .................... char lcd_getc(BYTE x, BYTE y)
923 .................... {
924 .................... char value;
925 ....................
926 .................... lcd_gotoxy(x,y);
927 .................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
928 .................... lcd_output_rs(1);
929 .................... value = lcd_read_byte();
930 .................... lcd_output_rs(0);
931 ....................
932 .................... return(value);
933 .................... }
934 ....................
935 ....................
936 .................... #include "../SHT25.h"
937 ....................
938 .................... #define SHT25_HEATER_ON 0x04
939 .................... #define SHT25_HEATER_OFF 0x00
940 .................... #define SHT25_OTP_reload_off 0x02
941 .................... #define SHT25_RH12_T14 0x00
942 .................... #define SHT25_RH8_T12 0x01
943 .................... #define SHT25_RH10_T13 0x80
944 .................... #define SHT25_RH11_T11 0x81
945 ....................
946 .................... #define SHT25_ADDR 0x80
947 ....................
948 .................... #include "SHT25.c"
949 .................... void SHT25_soft_reset()
950 .................... {
951 .................... i2c_start(); // Start condition
952 .................... i2c_write(0x80); // Device address
953 .................... i2c_write(0xFE); // Device command
954 .................... i2c_stop(); // Stop condition
955 .................... }
956 ....................
957 .................... unsigned int8 SHT25_setup(unsigned int8 setup_reg ) // writes to status register and returns its value
958 .................... {
959 .................... unsigned int8 reg;
960 ....................
961 .................... i2c_start(); // Start condition
962 .................... i2c_write(SHT25_ADDR); // Device address
963 .................... i2c_write(0xE7); // Device command
964 ....................
965 .................... i2c_start(); // Start condition
966 .................... i2c_write(SHT25_ADDR+1); // Device address
967 .................... reg=i2c_read(0); // Read status actual status register
968 ....................
969 .................... reg = (reg & 0x3A) | setup_reg;
970 ....................
971 .................... i2c_start(); // Start condition
972 .................... i2c_write(SHT25_ADDR); // Device address
973 .................... i2c_write(0xE6); // Write to status register
974 .................... i2c_write(reg); // Device command
975 .................... i2c_stop(); // Stop condition
976 ....................
977 .................... delay_ms(10);
978 ....................
979 .................... i2c_start(); // Start condition
980 .................... i2c_write(SHT25_ADDR); // Device address
981 .................... i2c_write(0xE7); // Device command
982 ....................
983 .................... i2c_start(); // Start condition
984 .................... i2c_write(SHT25_ADDR+1); // Device address
985 .................... reg=i2c_read(0); // Read status actual status register
986 ....................
987 .................... return (reg);
988 .................... }
989 ....................
990 ....................
991 .................... float SHT25_get_temp()
992 .................... {
993 .................... unsigned int8 MSB, LSB, Check;
994 .................... unsigned int16 data;
995 ....................
996 .................... i2c_start();
997 *
3283 kakl 998 0567: BSF 20.4
999 0568: MOVF 20,W
1000 0569: BSF 03.5
1001 056A: MOVWF 07
1002 056B: NOP
1003 056C: BCF 03.5
1004 056D: BSF 20.3
1005 056E: MOVF 20,W
1006 056F: BSF 03.5
1007 0570: MOVWF 07
1008 0571: NOP
1009 0572: BCF 03.5
1010 0573: BTFSS 07.3
1011 0574: GOTO 573
1012 0575: BCF 07.4
1013 0576: BCF 20.4
1014 0577: MOVF 20,W
1015 0578: BSF 03.5
1016 0579: MOVWF 07
1017 057A: NOP
1018 057B: BCF 03.5
1019 057C: BCF 07.3
1020 057D: BCF 20.3
1021 057E: MOVF 20,W
1022 057F: BSF 03.5
1023 0580: MOVWF 07
3275 kaklik 1024 .................... I2C_Write(SHT25_ADDR);
3283 kakl 1025 0581: MOVLW 80
1026 0582: BCF 03.5
1027 0583: MOVWF 3B
1028 0584: CALL 078
3275 kaklik 1029 .................... I2C_write(0xE3);
3283 kakl 1030 0585: MOVLW E3
1031 0586: MOVWF 3B
1032 0587: CALL 078
3275 kaklik 1033 .................... i2c_stop();
3283 kakl 1034 0588: BCF 20.4
1035 0589: MOVF 20,W
1036 058A: BSF 03.5
1037 058B: MOVWF 07
1038 058C: NOP
1039 058D: BCF 03.5
1040 058E: BSF 20.3
1041 058F: MOVF 20,W
1042 0590: BSF 03.5
1043 0591: MOVWF 07
1044 0592: BCF 03.5
1045 0593: BTFSS 07.3
1046 0594: GOTO 593
1047 0595: NOP
1048 0596: GOTO 597
1049 0597: NOP
1050 0598: BSF 20.4
1051 0599: MOVF 20,W
1052 059A: BSF 03.5
1053 059B: MOVWF 07
1054 059C: NOP
3275 kaklik 1055 ....................
1056 .................... delay_ms(100);
3283 kakl 1057 059D: MOVLW 64
1058 059E: BCF 03.5
1059 059F: MOVWF 43
1060 05A0: CALL 0FB
3275 kaklik 1061 ....................
1062 .................... i2c_start();
3283 kakl 1063 05A1: BSF 20.4
1064 05A2: MOVF 20,W
1065 05A3: BSF 03.5
1066 05A4: MOVWF 07
1067 05A5: NOP
1068 05A6: BCF 03.5
1069 05A7: BSF 20.3
1070 05A8: MOVF 20,W
1071 05A9: BSF 03.5
1072 05AA: MOVWF 07
1073 05AB: NOP
1074 05AC: BCF 03.5
1075 05AD: BCF 07.4
1076 05AE: BCF 20.4
1077 05AF: MOVF 20,W
1078 05B0: BSF 03.5
1079 05B1: MOVWF 07
1080 05B2: NOP
1081 05B3: BCF 03.5
1082 05B4: BCF 07.3
1083 05B5: BCF 20.3
1084 05B6: MOVF 20,W
1085 05B7: BSF 03.5
1086 05B8: MOVWF 07
3275 kaklik 1087 .................... I2C_Write(SHT25_ADDR+1);
3283 kakl 1088 05B9: MOVLW 81
1089 05BA: BCF 03.5
1090 05BB: MOVWF 3B
1091 05BC: CALL 078
3275 kaklik 1092 .................... MSB=i2c_read(1);
3283 kakl 1093 05BD: MOVLW 01
1094 05BE: MOVWF 77
1095 05BF: CALL 285
1096 05C0: MOVF 78,W
1097 05C1: MOVWF 35
3275 kaklik 1098 .................... LSB=i2c_read(1);
3283 kakl 1099 05C2: MOVLW 01
1100 05C3: MOVWF 77
1101 05C4: CALL 285
1102 05C5: MOVF 78,W
1103 05C6: MOVWF 36
3275 kaklik 1104 .................... Check=i2c_read(0);
3283 kakl 1105 05C7: CLRF 77
1106 05C8: CALL 285
1107 05C9: MOVF 78,W
1108 05CA: MOVWF 37
3275 kaklik 1109 .................... i2c_stop();
3283 kakl 1110 05CB: BCF 20.4
1111 05CC: MOVF 20,W
1112 05CD: BSF 03.5
1113 05CE: MOVWF 07
1114 05CF: NOP
1115 05D0: BCF 03.5
1116 05D1: BSF 20.3
1117 05D2: MOVF 20,W
1118 05D3: BSF 03.5
1119 05D4: MOVWF 07
1120 05D5: BCF 03.5
1121 05D6: BTFSS 07.3
1122 05D7: GOTO 5D6
1123 05D8: NOP
1124 05D9: GOTO 5DA
1125 05DA: NOP
1126 05DB: BSF 20.4
1127 05DC: MOVF 20,W
1128 05DD: BSF 03.5
1129 05DE: MOVWF 07
1130 05DF: NOP
3275 kaklik 1131 ....................
1132 .................... LSB = LSB >> 2; // trow out status bits
3283 kakl 1133 05E0: BCF 03.5
1134 05E1: RRF 36,F
1135 05E2: RRF 36,F
1136 05E3: MOVLW 3F
1137 05E4: ANDWF 36,F
3275 kaklik 1138 ....................
1139 .................... data = (((unsigned int16) MSB << 8) + (LSB << 4));
3283 kakl 1140 05E5: CLRF 3B
1141 05E6: MOVF 35,W
1142 05E7: MOVWF 3A
1143 05E8: MOVWF 3B
1144 05E9: CLRF 3A
1145 05EA: SWAPF 36,W
1146 05EB: MOVWF 77
1147 05EC: MOVLW F0
1148 05ED: ANDWF 77,F
1149 05EE: MOVF 77,W
1150 05EF: ADDWF 3A,W
1151 05F0: MOVWF 38
1152 05F1: MOVF 3B,W
1153 05F2: MOVWF 39
1154 05F3: BTFSC 03.0
1155 05F4: INCF 39,F
3275 kaklik 1156 .................... return(-46.85 + 175.72*((float)data/0xFFFF));
3283 kakl 1157 05F5: MOVF 39,W
1158 05F6: MOVWF 3B
1159 05F7: MOVF 38,W
1160 05F8: MOVWF 3A
1161 05F9: CALL 2CA
1162 05FA: MOVF 77,W
1163 05FB: MOVWF 3A
1164 05FC: MOVF 78,W
1165 05FD: MOVWF 3B
1166 05FE: MOVF 79,W
1167 05FF: MOVWF 3C
1168 0600: MOVF 7A,W
1169 0601: MOVWF 3D
1170 0602: MOVWF 41
1171 0603: MOVF 79,W
1172 0604: MOVWF 40
1173 0605: MOVF 78,W
1174 0606: MOVWF 3F
1175 0607: MOVF 77,W
1176 0608: MOVWF 3E
1177 0609: CLRF 45
1178 060A: MOVLW FF
1179 060B: MOVWF 44
1180 060C: MOVLW 7F
1181 060D: MOVWF 43
1182 060E: MOVLW 8E
1183 060F: MOVWF 42
1184 0610: CALL 2E7
1185 0611: MOVLW 52
1186 0612: MOVWF 45
1187 0613: MOVLW B8
1188 0614: MOVWF 44
1189 0615: MOVLW 2F
1190 0616: MOVWF 43
1191 0617: MOVLW 86
1192 0618: MOVWF 42
1193 0619: MOVF 7A,W
1194 061A: MOVWF 49
1195 061B: MOVF 79,W
1196 061C: MOVWF 48
1197 061D: MOVF 78,W
1198 061E: MOVWF 47
1199 061F: MOVF 77,W
1200 0620: MOVWF 46
1201 0621: CALL 3B1
1202 0622: BCF 03.1
1203 0623: MOVLW 66
1204 0624: MOVWF 3D
1205 0625: MOVWF 3C
1206 0626: MOVLW BB
1207 0627: MOVWF 3B
1208 0628: MOVLW 84
1209 0629: MOVWF 3A
1210 062A: MOVF 7A,W
1211 062B: MOVWF 41
1212 062C: MOVF 79,W
1213 062D: MOVWF 40
1214 062E: MOVF 78,W
1215 062F: MOVWF 3F
1216 0630: MOVF 77,W
1217 0631: MOVWF 3E
1218 0632: CALL 426
3275 kaklik 1219 .................... }
3283 kakl 1220 0633: BSF 0A.3
1221 0634: BCF 0A.4
1222 0635: GOTO 38B (RETURN)
3275 kaklik 1223 ....................
1224 .................... float SHT25_get_hum()
1225 .................... {
1226 .................... unsigned int8 MSB, LSB, Check;
1227 .................... unsigned int16 data;
1228 ....................
1229 .................... i2c_start(); //RH
3283 kakl 1230 0636: BSF 20.4
1231 0637: MOVF 20,W
1232 0638: BSF 03.5
1233 0639: MOVWF 07
1234 063A: NOP
1235 063B: BCF 03.5
1236 063C: BSF 20.3
1237 063D: MOVF 20,W
1238 063E: BSF 03.5
1239 063F: MOVWF 07
1240 0640: NOP
1241 0641: BCF 03.5
1242 0642: BCF 07.4
1243 0643: BCF 20.4
1244 0644: MOVF 20,W
1245 0645: BSF 03.5
1246 0646: MOVWF 07
1247 0647: NOP
1248 0648: BCF 03.5
1249 0649: BCF 07.3
1250 064A: BCF 20.3
1251 064B: MOVF 20,W
1252 064C: BSF 03.5
1253 064D: MOVWF 07
3275 kaklik 1254 .................... I2C_Write(SHT25_ADDR);
3283 kakl 1255 064E: MOVLW 80
1256 064F: BCF 03.5
1257 0650: MOVWF 3B
1258 0651: CALL 078
3275 kaklik 1259 .................... I2C_write(0xE5);
3283 kakl 1260 0652: MOVLW E5
1261 0653: MOVWF 3B
1262 0654: CALL 078
3275 kaklik 1263 ....................
1264 .................... delay_ms(100);
3283 kakl 1265 0655: MOVLW 64
1266 0656: MOVWF 43
1267 0657: CALL 0FB
3275 kaklik 1268 ....................
1269 .................... i2c_start();
3283 kakl 1270 0658: BSF 20.4
1271 0659: MOVF 20,W
1272 065A: BSF 03.5
1273 065B: MOVWF 07
1274 065C: NOP
1275 065D: BCF 03.5
1276 065E: BSF 20.3
1277 065F: MOVF 20,W
1278 0660: BSF 03.5
1279 0661: MOVWF 07
1280 0662: NOP
1281 0663: BCF 03.5
1282 0664: BTFSS 07.3
1283 0665: GOTO 664
1284 0666: BCF 07.4
1285 0667: BCF 20.4
1286 0668: MOVF 20,W
1287 0669: BSF 03.5
1288 066A: MOVWF 07
1289 066B: NOP
1290 066C: BCF 03.5
1291 066D: BCF 07.3
1292 066E: BCF 20.3
1293 066F: MOVF 20,W
1294 0670: BSF 03.5
1295 0671: MOVWF 07
3275 kaklik 1296 .................... I2C_Write(SHT25_ADDR+1);
3283 kakl 1297 0672: MOVLW 81
1298 0673: BCF 03.5
1299 0674: MOVWF 3B
1300 0675: CALL 078
3275 kaklik 1301 .................... MSB=i2c_read(1);
3283 kakl 1302 0676: MOVLW 01
1303 0677: MOVWF 77
1304 0678: CALL 285
1305 0679: MOVF 78,W
1306 067A: MOVWF 35
3275 kaklik 1307 .................... LSB=i2c_read(1);
3283 kakl 1308 067B: MOVLW 01
1309 067C: MOVWF 77
1310 067D: CALL 285
1311 067E: MOVF 78,W
1312 067F: MOVWF 36
3275 kaklik 1313 .................... Check=i2c_read(0);
3283 kakl 1314 0680: CLRF 77
1315 0681: CALL 285
1316 0682: MOVF 78,W
1317 0683: MOVWF 37
3275 kaklik 1318 .................... i2c_stop();
3283 kakl 1319 0684: BCF 20.4
1320 0685: MOVF 20,W
1321 0686: BSF 03.5
1322 0687: MOVWF 07
1323 0688: NOP
1324 0689: BCF 03.5
1325 068A: BSF 20.3
1326 068B: MOVF 20,W
1327 068C: BSF 03.5
1328 068D: MOVWF 07
1329 068E: BCF 03.5
1330 068F: BTFSS 07.3
1331 0690: GOTO 68F
1332 0691: NOP
1333 0692: GOTO 693
1334 0693: NOP
1335 0694: BSF 20.4
1336 0695: MOVF 20,W
1337 0696: BSF 03.5
1338 0697: MOVWF 07
1339 0698: NOP
3275 kaklik 1340 ....................
1341 .................... LSB = LSB >> 2; // trow out status bits
3283 kakl 1342 0699: BCF 03.5
1343 069A: RRF 36,F
1344 069B: RRF 36,F
1345 069C: MOVLW 3F
1346 069D: ANDWF 36,F
3275 kaklik 1347 ....................
1348 .................... data = (((unsigned int16) MSB << 8) + (LSB << 4) );
3283 kakl 1349 069E: CLRF 3B
1350 069F: MOVF 35,W
1351 06A0: MOVWF 3A
1352 06A1: MOVWF 3B
1353 06A2: CLRF 3A
1354 06A3: SWAPF 36,W
1355 06A4: MOVWF 77
1356 06A5: MOVLW F0
1357 06A6: ANDWF 77,F
1358 06A7: MOVF 77,W
1359 06A8: ADDWF 3A,W
1360 06A9: MOVWF 38
1361 06AA: MOVF 3B,W
1362 06AB: MOVWF 39
1363 06AC: BTFSC 03.0
1364 06AD: INCF 39,F
3275 kaklik 1365 .................... return( -6.0 + 125.0*((float)data/0xFFFF));
3283 kakl 1366 06AE: MOVF 39,W
1367 06AF: MOVWF 3B
1368 06B0: MOVF 38,W
1369 06B1: MOVWF 3A
1370 06B2: CALL 2CA
1371 06B3: MOVF 77,W
1372 06B4: MOVWF 3A
1373 06B5: MOVF 78,W
1374 06B6: MOVWF 3B
1375 06B7: MOVF 79,W
1376 06B8: MOVWF 3C
1377 06B9: MOVF 7A,W
1378 06BA: MOVWF 3D
1379 06BB: MOVWF 41
1380 06BC: MOVF 79,W
1381 06BD: MOVWF 40
1382 06BE: MOVF 78,W
1383 06BF: MOVWF 3F
1384 06C0: MOVF 77,W
1385 06C1: MOVWF 3E
1386 06C2: CLRF 45
1387 06C3: MOVLW FF
1388 06C4: MOVWF 44
1389 06C5: MOVLW 7F
1390 06C6: MOVWF 43
1391 06C7: MOVLW 8E
1392 06C8: MOVWF 42
1393 06C9: CALL 2E7
1394 06CA: CLRF 45
1395 06CB: CLRF 44
1396 06CC: MOVLW 7A
1397 06CD: MOVWF 43
1398 06CE: MOVLW 85
1399 06CF: MOVWF 42
1400 06D0: MOVF 7A,W
1401 06D1: MOVWF 49
1402 06D2: MOVF 79,W
1403 06D3: MOVWF 48
1404 06D4: MOVF 78,W
1405 06D5: MOVWF 47
1406 06D6: MOVF 77,W
1407 06D7: MOVWF 46
1408 06D8: CALL 3B1
1409 06D9: BCF 03.1
1410 06DA: CLRF 3D
1411 06DB: CLRF 3C
1412 06DC: MOVLW C0
1413 06DD: MOVWF 3B
1414 06DE: MOVLW 81
1415 06DF: MOVWF 3A
1416 06E0: MOVF 7A,W
1417 06E1: MOVWF 41
1418 06E2: MOVF 79,W
1419 06E3: MOVWF 40
1420 06E4: MOVF 78,W
1421 06E5: MOVWF 3F
1422 06E6: MOVF 77,W
1423 06E7: MOVWF 3E
1424 06E8: CALL 426
3275 kaklik 1425 .................... }
3283 kakl 1426 06E9: BSF 0A.3
1427 06EA: BCF 0A.4
1428 06EB: GOTO 396 (RETURN)
3275 kaklik 1429 ....................
1430 ....................
1431 ....................
1432 ....................
1433 .................... #include "../LTS01.h"
1434 .................... //Adresa pro VDD, VDD, VDD W 0x9E R 0x9F
1435 .................... //Adresa pro GND GND GND W 0x90 R 0x91
1436 ....................
1437 .................... #define LTS01A_address 0x90
1438 ....................
1439 .................... #include "LTS01.c"
1440 .................... float LTS01_get_temp()
1441 .................... {
1442 .................... unsigned int8 MSB;
1443 .................... unsigned int8 LSB;
1444 .................... signed int16 data;
1445 ....................
1446 .................... i2c_start();
3283 kakl 1447 06EC: BSF 20.4
1448 06ED: MOVF 20,W
1449 06EE: BSF 03.5
1450 06EF: MOVWF 07
1451 06F0: NOP
1452 06F1: BCF 03.5
1453 06F2: BSF 20.3
1454 06F3: MOVF 20,W
1455 06F4: BSF 03.5
1456 06F5: MOVWF 07
1457 06F6: NOP
1458 06F7: BCF 03.5
1459 06F8: BCF 07.4
1460 06F9: BCF 20.4
1461 06FA: MOVF 20,W
1462 06FB: BSF 03.5
1463 06FC: MOVWF 07
1464 06FD: NOP
1465 06FE: BCF 03.5
1466 06FF: BCF 07.3
1467 0700: BCF 20.3
1468 0701: MOVF 20,W
1469 0702: BSF 03.5
1470 0703: MOVWF 07
3275 kaklik 1471 .................... I2C_Write(LTS01A_address);
3283 kakl 1472 0704: MOVLW 90
1473 0705: BCF 03.5
1474 0706: MOVWF 3B
1475 0707: CALL 078
3275 kaklik 1476 .................... I2C_write(0x00);
3283 kakl 1477 0708: CLRF 3B
1478 0709: CALL 078
3275 kaklik 1479 .................... i2c_stop();
3283 kakl 1480 070A: BCF 20.4
1481 070B: MOVF 20,W
1482 070C: BSF 03.5
1483 070D: MOVWF 07
1484 070E: NOP
1485 070F: BCF 03.5
1486 0710: BSF 20.3
1487 0711: MOVF 20,W
1488 0712: BSF 03.5
1489 0713: MOVWF 07
1490 0714: BCF 03.5
1491 0715: BTFSS 07.3
1492 0716: GOTO 715
1493 0717: NOP
1494 0718: GOTO 719
1495 0719: NOP
1496 071A: BSF 20.4
1497 071B: MOVF 20,W
1498 071C: BSF 03.5
1499 071D: MOVWF 07
1500 071E: NOP
3275 kaklik 1501 .................... i2c_start();
3283 kakl 1502 071F: BCF 03.5
1503 0720: BSF 20.4
1504 0721: MOVF 20,W
1505 0722: BSF 03.5
1506 0723: MOVWF 07
1507 0724: NOP
1508 0725: BCF 03.5
1509 0726: BSF 20.3
1510 0727: MOVF 20,W
1511 0728: BSF 03.5
1512 0729: MOVWF 07
1513 072A: NOP
1514 072B: BCF 03.5
1515 072C: BCF 07.4
1516 072D: BCF 20.4
1517 072E: MOVF 20,W
1518 072F: BSF 03.5
1519 0730: MOVWF 07
1520 0731: NOP
1521 0732: BCF 03.5
1522 0733: BCF 07.3
1523 0734: BCF 20.3
1524 0735: MOVF 20,W
1525 0736: BSF 03.5
1526 0737: MOVWF 07
3275 kaklik 1527 .................... I2C_Write(LTS01A_address+1);
3283 kakl 1528 0738: MOVLW 91
1529 0739: BCF 03.5
1530 073A: MOVWF 3B
1531 073B: CALL 078
3275 kaklik 1532 .................... MSB=i2c_read(1);
3283 kakl 1533 073C: MOVLW 01
1534 073D: MOVWF 77
1535 073E: CALL 285
1536 073F: MOVF 78,W
1537 0740: MOVWF 35
3275 kaklik 1538 .................... LSB=i2c_read(0);
3283 kakl 1539 0741: CLRF 77
1540 0742: CALL 285
1541 0743: MOVF 78,W
1542 0744: MOVWF 36
3275 kaklik 1543 .................... i2c_stop();
3283 kakl 1544 0745: BCF 20.4
1545 0746: MOVF 20,W
1546 0747: BSF 03.5
1547 0748: MOVWF 07
1548 0749: NOP
1549 074A: BCF 03.5
1550 074B: BSF 20.3
1551 074C: MOVF 20,W
1552 074D: BSF 03.5
1553 074E: MOVWF 07
1554 074F: BCF 03.5
1555 0750: BTFSS 07.3
1556 0751: GOTO 750
1557 0752: NOP
1558 0753: GOTO 754
1559 0754: NOP
1560 0755: BSF 20.4
1561 0756: MOVF 20,W
1562 0757: BSF 03.5
1563 0758: MOVWF 07
1564 0759: NOP
3275 kaklik 1565 ....................
1566 .................... data = MAKE16(MSB,LSB);
3283 kakl 1567 075A: BCF 03.5
1568 075B: MOVF 35,W
1569 075C: MOVWF 38
1570 075D: MOVF 36,W
1571 075E: MOVWF 37
3275 kaklik 1572 ....................
1573 .................... return (data * 0.00390625 );
3283 kakl 1574 075F: MOVF 38,W
1575 0760: MOVWF 3A
1576 0761: MOVF 37,W
1577 0762: MOVWF 39
1578 0763: MOVF 3A,W
1579 0764: MOVWF 3C
1580 0765: MOVF 39,W
1581 0766: MOVWF 3B
3275 kaklik 1582 *
3283 kakl 1583 078B: MOVF 7A,W
1584 078C: MOVWF 45
1585 078D: MOVF 79,W
1586 078E: MOVWF 44
1587 078F: MOVF 78,W
1588 0790: MOVWF 43
1589 0791: MOVF 77,W
1590 0792: MOVWF 42
1591 0793: CLRF 49
1592 0794: CLRF 48
1593 0795: CLRF 47
1594 0796: MOVLW 77
1595 0797: MOVWF 46
1596 0798: CALL 3B1
3275 kaklik 1597 ....................
1598 .................... }
3283 kakl 1599 0799: BSF 0A.3
1600 079A: BCF 0A.4
1601 079B: GOTO 3A1 (RETURN)
3275 kaklik 1602 ....................
1603 ....................
1604 ....................
3283 kakl 1605 .................... #include "./HMC5883L.h"
1606 .................... // i2c slave addresses
1607 .................... #define HMC5883L_WRT_ADDR 0x3C
1608 .................... #define HMC5883L_READ_ADDR 0x3D
3275 kaklik 1609 ....................
3283 kakl 1610 .................... // Register addresses
1611 .................... #define HMC5883L_CFG_A_REG 0x00
1612 .................... #define HMC5883L_CFG_B_REG 0x01
1613 .................... #define HMC5883L_MODE_REG 0x02
1614 .................... #define HMC5883L_X_MSB_REG 0x03
1615 ....................
1616 .................... //Konstanty nastavujici rozsah
1617 .................... //pro void set_mag_roz (unsigned int8 h)
1618 .................... #define MAG_ROZ088 0x00
1619 .................... #define MAG_ROZ130 0x20
1620 .................... #define MAG_ROZ190 0x40
1621 .................... #define MAG_ROZ250 0x60
1622 .................... #define MAG_ROZ400 0x80
1623 .................... #define MAG_ROZ470 0xA0
1624 .................... #define MAG_ROZ560 0xC0
1625 .................... #define MAG_ROZ810 0xE0
1626 ....................
1627 ....................
1628 .................... #include "HMC5883L.c"
1629 .................... //------------------------------
1630 .................... // Low level routines
1631 .................... //------------------------------
1632 .................... void hmc5883l_write_reg(int8 reg, int8 data)
1633 .................... {
1634 .................... i2c_start();
1635 *
1636 00C2: BSF 20.4
1637 00C3: MOVF 20,W
1638 00C4: BSF 03.5
1639 00C5: MOVWF 07
1640 00C6: NOP
1641 00C7: BCF 03.5
1642 00C8: BSF 20.3
1643 00C9: MOVF 20,W
1644 00CA: BSF 03.5
1645 00CB: MOVWF 07
1646 00CC: NOP
1647 00CD: BCF 03.5
1648 00CE: BCF 07.4
1649 00CF: BCF 20.4
1650 00D0: MOVF 20,W
1651 00D1: BSF 03.5
1652 00D2: MOVWF 07
1653 00D3: NOP
1654 00D4: BCF 03.5
1655 00D5: BCF 07.3
1656 00D6: BCF 20.3
1657 00D7: MOVF 20,W
1658 00D8: BSF 03.5
1659 00D9: MOVWF 07
1660 .................... i2c_write(HMC5883L_WRT_ADDR);
1661 00DA: MOVLW 3C
1662 00DB: BCF 03.5
1663 00DC: MOVWF 3B
1664 00DD: CALL 078
1665 .................... i2c_write(reg);
1666 00DE: MOVF 35,W
1667 00DF: MOVWF 3B
1668 00E0: CALL 078
1669 .................... i2c_write(data);
1670 00E1: MOVF 36,W
1671 00E2: MOVWF 3B
1672 00E3: CALL 078
1673 .................... i2c_stop();
1674 00E4: BCF 20.4
1675 00E5: MOVF 20,W
1676 00E6: BSF 03.5
1677 00E7: MOVWF 07
1678 00E8: NOP
1679 00E9: BCF 03.5
1680 00EA: BSF 20.3
1681 00EB: MOVF 20,W
1682 00EC: BSF 03.5
1683 00ED: MOVWF 07
1684 00EE: BCF 03.5
1685 00EF: BTFSS 07.3
1686 00F0: GOTO 0EF
1687 00F1: NOP
1688 00F2: GOTO 0F3
1689 00F3: NOP
1690 00F4: BSF 20.4
1691 00F5: MOVF 20,W
1692 00F6: BSF 03.5
1693 00F7: MOVWF 07
1694 00F8: NOP
1695 .................... }
1696 00F9: BCF 03.5
1697 00FA: RETURN
1698 ....................
1699 .................... //------------------------------
1700 .................... int8 hmc5883l_read_reg(int8 reg)
1701 .................... {
1702 .................... int8 retval;
1703 ....................
1704 .................... i2c_start();
1705 .................... i2c_write(HMC5883L_WRT_ADDR);
1706 .................... i2c_write(reg);
1707 .................... i2c_start();
1708 .................... i2c_write(HMC5883L_READ_ADDR);
1709 .................... retval = i2c_read(0);
1710 .................... i2c_stop();
1711 ....................
1712 .................... return(retval);
1713 .................... }
1714 ....................
1715 .................... //------------------------------
1716 .................... typedef struct
1717 .................... {
1718 .................... signed int16 x;
1719 .................... signed int16 y;
1720 .................... signed int16 z;
1721 .................... }hmc5883l_result;
1722 ....................
1723 .................... // This global structure holds the values read
1724 .................... // from the HMC5883L x,y,z registers.
1725 .................... hmc5883l_result compass = {0,0,0};
1726 *
1727 0ADB: CLRF 21
1728 0ADC: CLRF 22
1729 0ADD: CLRF 23
1730 0ADE: CLRF 24
1731 0ADF: CLRF 25
1732 0AE0: CLRF 26
1733 ....................
1734 .................... //------------------------------
1735 .................... void hmc5883l_read_data(void)
1736 .................... {
1737 .................... unsigned int8 x_lsb;
1738 .................... unsigned int8 x_msb;
1739 ....................
1740 .................... unsigned int8 y_lsb;
1741 .................... unsigned int8 y_msb;
1742 ....................
1743 .................... unsigned int8 z_lsb;
1744 .................... unsigned int8 z_msb;
1745 ....................
1746 .................... i2c_start();
1747 *
1748 0800: BSF 20.4
1749 0801: MOVF 20,W
1750 0802: BSF 03.5
1751 0803: MOVWF 07
1752 0804: NOP
1753 0805: BCF 03.5
1754 0806: BSF 20.3
1755 0807: MOVF 20,W
1756 0808: BSF 03.5
1757 0809: MOVWF 07
1758 080A: NOP
1759 080B: BCF 03.5
1760 080C: BCF 07.4
1761 080D: BCF 20.4
1762 080E: MOVF 20,W
1763 080F: BSF 03.5
1764 0810: MOVWF 07
1765 0811: NOP
1766 0812: BCF 03.5
1767 0813: BCF 07.3
1768 0814: BCF 20.3
1769 0815: MOVF 20,W
1770 0816: BSF 03.5
1771 0817: MOVWF 07
1772 .................... i2c_write(HMC5883L_WRT_ADDR);
1773 0818: MOVLW 3C
1774 0819: BCF 03.5
1775 081A: MOVWF 3B
1776 081B: BCF 0A.3
1777 081C: CALL 078
1778 081D: BSF 0A.3
1779 .................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register
1780 081E: MOVLW 03
1781 081F: MOVWF 3B
1782 0820: BCF 0A.3
1783 0821: CALL 078
1784 0822: BSF 0A.3
1785 .................... i2c_start();
1786 0823: BSF 20.4
1787 0824: MOVF 20,W
1788 0825: BSF 03.5
1789 0826: MOVWF 07
1790 0827: NOP
1791 0828: BCF 03.5
1792 0829: BSF 20.3
1793 082A: MOVF 20,W
1794 082B: BSF 03.5
1795 082C: MOVWF 07
1796 082D: NOP
1797 082E: BCF 03.5
1798 082F: BTFSS 07.3
1799 0830: GOTO 02F
1800 0831: BCF 07.4
1801 0832: BCF 20.4
1802 0833: MOVF 20,W
1803 0834: BSF 03.5
1804 0835: MOVWF 07
1805 0836: NOP
1806 0837: BCF 03.5
1807 0838: BCF 07.3
1808 0839: BCF 20.3
1809 083A: MOVF 20,W
1810 083B: BSF 03.5
1811 083C: MOVWF 07
1812 .................... i2c_write(HMC5883L_READ_ADDR);
1813 083D: MOVLW 3D
1814 083E: BCF 03.5
1815 083F: MOVWF 3B
1816 0840: BCF 0A.3
1817 0841: CALL 078
1818 0842: BSF 0A.3
1819 ....................
1820 .................... x_msb = i2c_read();
1821 0843: MOVLW 01
1822 0844: MOVWF 77
1823 0845: BCF 0A.3
1824 0846: CALL 285
1825 0847: BSF 0A.3
1826 0848: MOVF 78,W
1827 0849: MOVWF 36
1828 .................... x_lsb = i2c_read();
1829 084A: MOVLW 01
1830 084B: MOVWF 77
1831 084C: BCF 0A.3
1832 084D: CALL 285
1833 084E: BSF 0A.3
1834 084F: MOVF 78,W
1835 0850: MOVWF 35
1836 ....................
1837 .................... z_msb = i2c_read();
1838 0851: MOVLW 01
1839 0852: MOVWF 77
1840 0853: BCF 0A.3
1841 0854: CALL 285
1842 0855: BSF 0A.3
1843 0856: MOVF 78,W
1844 0857: MOVWF 3A
1845 .................... z_lsb = i2c_read();
1846 0858: MOVLW 01
1847 0859: MOVWF 77
1848 085A: BCF 0A.3
1849 085B: CALL 285
1850 085C: BSF 0A.3
1851 085D: MOVF 78,W
1852 085E: MOVWF 39
1853 ....................
1854 .................... y_msb = i2c_read();
1855 085F: MOVLW 01
1856 0860: MOVWF 77
1857 0861: BCF 0A.3
1858 0862: CALL 285
1859 0863: BSF 0A.3
1860 0864: MOVF 78,W
1861 0865: MOVWF 38
1862 .................... y_lsb = i2c_read(0); // do a NACK on last read
1863 0866: CLRF 77
1864 0867: BCF 0A.3
1865 0868: CALL 285
1866 0869: BSF 0A.3
1867 086A: MOVF 78,W
1868 086B: MOVWF 37
1869 ....................
1870 .................... i2c_stop();
1871 086C: BCF 20.4
1872 086D: MOVF 20,W
1873 086E: BSF 03.5
1874 086F: MOVWF 07
1875 0870: NOP
1876 0871: BCF 03.5
1877 0872: BSF 20.3
1878 0873: MOVF 20,W
1879 0874: BSF 03.5
1880 0875: MOVWF 07
1881 0876: BCF 03.5
1882 0877: BTFSS 07.3
1883 0878: GOTO 077
1884 0879: NOP
1885 087A: GOTO 07B
1886 087B: NOP
1887 087C: BSF 20.4
1888 087D: MOVF 20,W
1889 087E: BSF 03.5
1890 087F: MOVWF 07
1891 0880: NOP
1892 ....................
1893 .................... // Combine high and low bytes into 16-bit values.
1894 .................... compass.x = make16(x_msb, x_lsb);
1895 0881: BCF 03.5
1896 0882: MOVF 36,W
1897 0883: MOVWF 22
1898 0884: MOVF 35,W
1899 0885: MOVWF 21
1900 .................... compass.y = make16(y_msb, y_lsb);
1901 0886: MOVF 38,W
1902 0887: MOVWF 24
1903 0888: MOVF 37,W
1904 0889: MOVWF 23
1905 .................... compass.z = make16(z_msb, z_lsb);
1906 088A: MOVF 3A,W
1907 088B: MOVWF 26
1908 088C: MOVF 39,W
1909 088D: MOVWF 25
1910 .................... }
1911 088E: BSF 0A.3
1912 088F: BCF 0A.4
1913 0890: GOTO 3AB (RETURN)
1914 ....................
1915 ....................
1916 ....................
1917 ....................
1918 .................... #include <math.h>
1919 .................... ////////////////////////////////////////////////////////////////////////////
1920 .................... //// (C) Copyright 1996,2008 Custom Computer Services ////
1921 .................... //// This source code may only be used by licensed users of the CCS C ////
1922 .................... //// compiler. This source code may only be distributed to other ////
1923 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
1924 .................... //// or distribution is permitted without written permission. ////
1925 .................... //// Derivative programs created using this software in object code ////
1926 .................... //// form are not restricted in any way. ////
1927 .................... ////////////////////////////////////////////////////////////////////////////
1928 .................... //// ////
1929 .................... //// History: ////
1930 .................... //// * 9/20/2001 : Improvments are made to sin/cos code. ////
1931 .................... //// The code now is small, much faster, ////
1932 .................... //// and more accurate. ////
1933 .................... //// * 2/21/2007 : Compiler handles & operator differently and does
1934 .................... //// not return generic (int8 *) so type cast is done ////
1935 .................... //// ////
1936 .................... ////////////////////////////////////////////////////////////////////////////
1937 ....................
1938 .................... #ifndef MATH_H
1939 .................... #define MATH_H
1940 ....................
1941 .................... #ifdef PI
1942 .................... #undef PI
1943 .................... #endif
1944 .................... #define PI 3.1415926535897932
1945 ....................
1946 ....................
1947 .................... #define SQRT2 1.4142135623730950
1948 ....................
1949 .................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};
1950 .................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};
1951 ....................
1952 .................... ///////////////////////////// Round Functions //////////////////////////////
1953 ....................
1954 .................... float32 CEIL_FLOOR(float32 x, unsigned int8 n)
1955 .................... {
1956 .................... float32 y, res;
1957 .................... unsigned int16 l;
1958 .................... int1 s;
1959 ....................
1960 .................... s = 0;
1961 .................... y = x;
1962 ....................
1963 .................... if (x < 0)
1964 .................... {
1965 .................... s = 1;
1966 .................... y = -y;
1967 .................... }
1968 ....................
1969 .................... if (y <= 32768.0)
1970 .................... res = (float32)(unsigned int16)y;
1971 ....................
1972 .................... else if (y < 10000000.0)
1973 .................... {
1974 .................... l = (unsigned int16)(y/32768.0);
1975 .................... y = 32768.0*(y/32768.0 - (float32)l);
1976 .................... res = 32768.0*(float32)l;
1977 .................... res += (float32)(unsigned int16)y;
1978 .................... }
1979 ....................
1980 .................... else
1981 .................... res = y;
1982 ....................
1983 .................... y = y - (float32)(unsigned int16)y;
1984 ....................
1985 .................... if (s)
1986 .................... res = -res;
1987 ....................
1988 .................... if (y != 0)
1989 .................... {
1990 .................... if (s == 1 && n == 0)
1991 .................... res -= 1.0;
1992 ....................
1993 .................... if (s == 0 && n == 1)
1994 .................... res += 1.0;
1995 .................... }
1996 .................... if (x == 0)
1997 .................... res = 0;
1998 ....................
1999 .................... return (res);
2000 .................... }
2001 ....................
2002 .................... // Overloaded Functions to take care for new Data types in PCD
2003 .................... // Overloaded function CEIL_FLOOR() for data type - Float48
2004 .................... #if defined(__PCD__)
2005 .................... float48 CEIL_FLOOR(float48 x, unsigned int8 n)
2006 .................... {
2007 .................... float48 y, res;
2008 .................... unsigned int16 l;
2009 .................... int1 s;
2010 ....................
2011 .................... s = 0;
2012 .................... y = x;
2013 ....................
2014 .................... if (x < 0)
2015 .................... {
2016 .................... s = 1;
2017 .................... y = -y;
2018 .................... }
2019 ....................
2020 .................... if (y <= 32768.0)
2021 .................... res = (float48)(unsigned int16)y;
2022 ....................
2023 .................... else if (y < 10000000.0)
2024 .................... {
2025 .................... l = (unsigned int16)(y/32768.0);
2026 .................... y = 32768.0*(y/32768.0 - (float48)l);
2027 .................... res = 32768.0*(float32)l;
2028 .................... res += (float48)(unsigned int16)y;
2029 .................... }
2030 ....................
2031 .................... else
2032 .................... res = y;
2033 ....................
2034 .................... y = y - (float48)(unsigned int16)y;
2035 ....................
2036 .................... if (s)
2037 .................... res = -res;
2038 ....................
2039 .................... if (y != 0)
2040 .................... {
2041 .................... if (s == 1 && n == 0)
2042 .................... res -= 1.0;
2043 ....................
2044 .................... if (s == 0 && n == 1)
2045 .................... res += 1.0;
2046 .................... }
2047 .................... if (x == 0)
2048 .................... res = 0;
2049 ....................
2050 .................... return (res);
2051 .................... }
2052 ....................
2053 ....................
2054 .................... // Overloaded function CEIL_FLOOR() for data type - Float64
2055 .................... float64 CEIL_FLOOR(float64 x, unsigned int8 n)
2056 .................... {
2057 .................... float64 y, res;
2058 .................... unsigned int16 l;
2059 .................... int1 s;
2060 ....................
2061 .................... s = 0;
2062 .................... y = x;
2063 ....................
2064 .................... if (x < 0)
2065 .................... {
2066 .................... s = 1;
2067 .................... y = -y;
2068 .................... }
2069 ....................
2070 .................... if (y <= 32768.0)
2071 .................... res = (float64)(unsigned int16)y;
2072 ....................
2073 .................... else if (y < 10000000.0)
2074 .................... {
2075 .................... l = (unsigned int16)(y/32768.0);
2076 .................... y = 32768.0*(y/32768.0 - (float64)l);
2077 .................... res = 32768.0*(float64)l;
2078 .................... res += (float64)(unsigned int16)y;
2079 .................... }
2080 ....................
2081 .................... else
2082 .................... res = y;
2083 ....................
2084 .................... y = y - (float64)(unsigned int16)y;
2085 ....................
2086 .................... if (s)
2087 .................... res = -res;
2088 ....................
2089 .................... if (y != 0)
2090 .................... {
2091 .................... if (s == 1 && n == 0)
2092 .................... res -= 1.0;
2093 ....................
2094 .................... if (s == 0 && n == 1)
2095 .................... res += 1.0;
2096 .................... }
2097 .................... if (x == 0)
2098 .................... res = 0;
2099 ....................
2100 .................... return (res);
2101 .................... }
2102 .................... #endif
2103 ....................
2104 .................... ////////////////////////////////////////////////////////////////////////////
2105 .................... // float floor(float x)
2106 .................... ////////////////////////////////////////////////////////////////////////////
2107 .................... // Description : rounds down the number x.
2108 .................... // Date : N/A
2109 .................... //
2110 .................... float32 floor(float32 x)
2111 .................... {
2112 .................... return CEIL_FLOOR(x, 0);
2113 .................... }
2114 .................... // Following 2 functions are overloaded functions of floor() for PCD
2115 .................... // Overloaded function floor() for data type - Float48
2116 .................... #if defined(__PCD__)
2117 .................... float48 floor(float48 x)
2118 .................... {
2119 .................... return CEIL_FLOOR(x, 0);
2120 .................... }
2121 ....................
2122 .................... // Overloaded function floor() for data type - Float64
2123 .................... float64 floor(float64 x)
2124 .................... {
2125 .................... return CEIL_FLOOR(x, 0);
2126 .................... }
2127 .................... #endif
2128 ....................
2129 ....................
2130 .................... ////////////////////////////////////////////////////////////////////////////
2131 .................... // float ceil(float x)
2132 .................... ////////////////////////////////////////////////////////////////////////////
2133 .................... // Description : rounds up the number x.
2134 .................... // Date : N/A
2135 .................... //
2136 .................... float32 ceil(float32 x)
2137 .................... {
2138 .................... return CEIL_FLOOR(x, 1);
2139 .................... }
2140 .................... // Following 2 functions are overloaded functions of ceil() for PCD
2141 .................... // Overloaded function ceil() for data type - Float48
2142 .................... #if defined(__PCD__)
2143 .................... float48 ceil(float48 x)
2144 .................... {
2145 .................... return CEIL_FLOOR(x, 1);
2146 .................... }
2147 ....................
2148 .................... // Overloaded function ceil() for data type - Float64
2149 .................... float64 ceil(float64 x)
2150 .................... {
2151 .................... return CEIL_FLOOR(x, 1);
2152 .................... }
2153 .................... #endif
2154 ....................
2155 .................... ////////////////////////////////////////////////////////////////////////////
2156 .................... // float fabs(float x)
2157 .................... ////////////////////////////////////////////////////////////////////////////
2158 .................... // Description : Computes the absolute value of floating point number x
2159 .................... // Returns : returns the absolute value of x
2160 .................... // Date : N/A
2161 .................... //
2162 .................... #define fabs abs
2163 ....................
2164 .................... ////////////////////////////////////////////////////////////////////////////
2165 .................... // float fmod(float x)
2166 .................... ////////////////////////////////////////////////////////////////////////////
2167 .................... // Description : Computes the floating point remainder of x/y
2168 .................... // Returns : returns the value of x= i*y, for some integer i such that, if y
2169 .................... // is non zero, the result has the same isgn of x na dmagnitude less than the
2170 .................... // magnitude of y. If y is zero then a domain error occurs.
2171 .................... // Date : N/A
2172 .................... //
2173 ....................
2174 .................... float fmod(float32 x,float32 y)
2175 .................... {
2176 .................... float32 i;
2177 .................... if (y!=0.0)
2178 .................... {
2179 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
2180 .................... return(x-(i*y));
2181 .................... }
2182 .................... else
2183 .................... {
2184 .................... #ifdef _ERRNO
2185 .................... {
2186 .................... errno=EDOM;
2187 .................... }
2188 .................... #endif
2189 .................... }
2190 .................... }
2191 .................... //Overloaded function for fmod() for PCD
2192 .................... // Overloaded function fmod() for data type - Float48
2193 .................... #if defined(__PCD__)
2194 .................... float48 fmod(float48 x,float48 y)
2195 .................... {
2196 .................... float48 i;
2197 .................... if (y!=0.0)
2198 .................... {
2199 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
2200 .................... return(x-(i*y));
2201 .................... }
2202 .................... else
2203 .................... {
2204 .................... #ifdef _ERRNO
2205 .................... {
2206 .................... errno=EDOM;
2207 .................... }
2208 .................... #endif
2209 .................... }
2210 .................... }
2211 .................... // Overloaded function fmod() for data type - Float64
2212 .................... float64 fmod(float64 x,float64 y)
2213 .................... {
2214 .................... float64 i;
2215 .................... if (y!=0.0)
2216 .................... {
2217 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
2218 .................... return(x-(i*y));
2219 .................... }
2220 .................... else
2221 .................... {
2222 .................... #ifdef _ERRNO
2223 .................... {
2224 .................... errno=EDOM;
2225 .................... }
2226 .................... #endif
2227 .................... }
2228 .................... }
2229 .................... #endif
2230 .................... //////////////////// Exponential and logarithmic functions ////////////////////
2231 .................... ////////////////////////////////////////////////////////////////////////////
2232 .................... // float exp(float x)
2233 .................... ////////////////////////////////////////////////////////////////////////////
2234 .................... // Description : returns the value (e^x)
2235 .................... // Date : N/A
2236 .................... //
2237 .................... #define LN2 0.6931471805599453
2238 ....................
2239 .................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,
2240 .................... 0.0554965651, 0.240227138, 0.693147172};
2241 ....................
2242 ....................
2243 .................... float32 exp(float32 x)
2244 .................... {
2245 .................... float32 y, res, r;
2246 .................... #if defined(__PCD__)
2247 .................... int8 data1;
2248 .................... #endif
2249 .................... signed int8 n;
2250 .................... int1 s;
2251 .................... #ifdef _ERRNO
2252 .................... if(x > 88.722838)
2253 .................... {
2254 .................... errno=ERANGE;
2255 .................... return(0);
2256 .................... }
2257 .................... #endif
2258 .................... n = (signed int16)(x/LN2);
2259 .................... s = 0;
2260 .................... y = x;
2261 ....................
2262 .................... if (x < 0)
2263 .................... {
2264 .................... s = 1;
2265 .................... n = -n;
2266 .................... y = -y;
2267 .................... }
2268 ....................
2269 .................... res = 0.0;
2270 .................... #if !defined(__PCD__)
2271 .................... *((unsigned int8 *)(&res)) = n + 0x7F;
2272 .................... #endif
2273 ....................
2274 .................... #if defined(__PCD__) // Takes care of IEEE format for PCD
2275 .................... data1 = n+0x7F;
2276 .................... if(bit_test(data1,0))
2277 .................... bit_set(*(((unsigned int8 *)(&res)+2)),7);
2278 .................... rotate_right(&data1,1);
2279 .................... bit_clear(data1,7);
2280 .................... *(((unsigned int8 *)(&res)+3)) = data1;
2281 .................... #endif
2282 ....................
2283 .................... y = y/LN2 - (float32)n;
2284 ....................
2285 .................... r = pe[0]*y + pe[1];
2286 .................... r = r*y + pe[2];
2287 .................... r = r*y + pe[3];
2288 .................... r = r*y + pe[4];
2289 .................... r = r*y + pe[5];
2290 ....................
2291 .................... res = res*(1.0 + y*r);
2292 ....................
2293 .................... if (s)
2294 .................... res = 1.0/res;
2295 .................... return(res);
2296 .................... }
2297 ....................
2298 ....................
2299 .................... //Overloaded function for exp() for PCD
2300 .................... // Overloaded function exp() for data type - Float48
2301 .................... #if defined(__PCD__)
2302 .................... float48 exp(float48 x)
2303 .................... {
2304 .................... float48 y, res, r;
2305 .................... int8 data1;
2306 .................... signed int8 n;
2307 .................... int1 s;
2308 .................... #ifdef _ERRNO
2309 .................... if(x > 88.722838)
2310 .................... {
2311 .................... errno=ERANGE;
2312 .................... return(0);
2313 .................... }
2314 .................... #endif
2315 .................... n = (signed int16)(x/LN2);
2316 .................... s = 0;
2317 .................... y = x;
2318 ....................
2319 .................... if (x < 0)
2320 .................... {
2321 .................... s = 1;
2322 .................... n = -n;
2323 .................... y = -y;
2324 .................... }
2325 ....................
2326 .................... res = 0.0;
2327 ....................
2328 .................... data1 = n+0x7F;
2329 .................... if(bit_test(data1,0))
2330 .................... bit_set(*(((unsigned int8 *)(&res)+4)),7);
2331 .................... rotate_right(&data1,1);
2332 .................... bit_clear(data1,7);
2333 .................... *(((unsigned int8 *)(&res)+5)) = data1;
2334 ....................
2335 .................... y = y/LN2 - (float48)n;
2336 ....................
2337 .................... r = pe[0]*y + pe[1];
2338 .................... r = r*y + pe[2];
2339 .................... r = r*y + pe[3];
2340 .................... r = r*y + pe[4];
2341 .................... r = r*y + pe[5];
2342 ....................
2343 .................... res = res*(1.0 + y*r);
2344 ....................
2345 .................... if (s)
2346 .................... res = 1.0/res;
2347 .................... return(res);
2348 .................... }
2349 ....................
2350 .................... // Overloaded function exp() for data type - Float64
2351 .................... float64 exp(float64 x)
2352 .................... {
2353 .................... float64 y, res, r;
2354 .................... unsigned int16 data1, data2;
2355 .................... unsigned int16 *p;
2356 .................... signed int16 n;
2357 .................... int1 s;
2358 .................... #ifdef _ERRNO
2359 .................... if(x > 709.7827128)
2360 .................... {
2361 .................... errno=ERANGE;
2362 .................... return(0);
2363 .................... }
2364 .................... #endif
2365 .................... n = (signed int16)(x/LN2);
2366 .................... s = 0;
2367 .................... y = x;
2368 ....................
2369 .................... if (x < 0)
2370 .................... {
2371 .................... s = 1;
2372 .................... n = -n;
2373 .................... y = -y;
2374 .................... }
2375 ....................
2376 .................... res = 0.0;
2377 ....................
2378 .................... #if !defined(__PCD__)
2379 .................... *((unsigned int16 *)(&res)) = n + 0x7F;
2380 .................... #endif
2381 .................... p= (((unsigned int16 *)(&res))+3);
2382 .................... data1 = *p;
2383 .................... data2 = *p;
2384 .................... data1 = n + 0x3FF;
2385 .................... data1 = data1 <<4;
2386 .................... if(bit_test(data2,15))
2387 .................... bit_set(data1,15);
2388 .................... data2 = data2 & 0x000F;
2389 .................... data1 ^= data2;
2390 ....................
2391 .................... *(((unsigned int16 *)(&res)+3)) = data1;
2392 ....................
2393 ....................
2394 .................... y = y/LN2 - (float64)n;
2395 ....................
2396 .................... r = pe[0]*y + pe[1];
2397 .................... r = r*y + pe[2];
2398 .................... r = r*y + pe[3];
2399 .................... r = r*y + pe[4];
2400 .................... r = r*y + pe[5];
2401 ....................
2402 .................... res = res*(1.0 + y*r);
2403 ....................
2404 .................... if (s)
2405 .................... res = 1.0/res;
2406 .................... return(res);
2407 .................... }
2408 ....................
2409 .................... #ENDIF
2410 ....................
2411 ....................
2412 .................... /************************************************************/
2413 ....................
2414 .................... float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
2415 .................... float32 const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
2416 ....................
2417 .................... ////////////////////////////////////////////////////////////////////////////
2418 .................... // float log(float x)
2419 .................... ////////////////////////////////////////////////////////////////////////////
2420 .................... // Description : returns the the natural log of x
2421 .................... // Date : N/A
2422 .................... //
2423 .................... float32 log(float32 x)
2424 .................... {
2425 .................... float32 y, res, r, y2;
2426 .................... #if defined(__PCD__)
2427 .................... unsigned int8 data1,data2;
2428 .................... #endif
2429 .................... signed int8 n;
2430 .................... #ifdef _ERRNO
2431 .................... if(x <0)
2432 .................... {
2433 .................... errno=EDOM;
2434 .................... }
2435 .................... if(x ==0)
2436 .................... {
2437 .................... errno=ERANGE;
2438 .................... return(0);
2439 .................... }
2440 .................... #endif
2441 .................... y = x;
2442 ....................
2443 .................... if (y != 1.0)
2444 .................... {
2445 .................... #if !defined(__PCD__)
2446 .................... *((unsigned int8 *)(&y)) = 0x7E;
2447 .................... #endif
2448 ....................
2449 .................... #if defined(__PCD__) // Takes care of IEEE format
2450 .................... data2 = *(((unsigned int8 *)(&y))+3);
2451 .................... *(((unsigned int8 *)(&y))+3) = 0x3F;
2452 .................... data1 = *(((unsigned int8 *)(&y))+2);
2453 .................... bit_clear(data1,7);
2454 .................... *(((unsigned int8 *)(&y))+2) = data1;
2455 .................... if(bit_test(data2,7))
2456 .................... bit_set(*(((unsigned int8 *)(&y))+3),7);
2457 .................... #endif
2458 ....................
2459 .................... y = (y - 1.0)/(y + 1.0);
2460 ....................
2461 .................... y2=y*y;
2462 ....................
2463 .................... res = pl[0]*y2 + pl[1];
2464 .................... res = res*y2 + pl[2];
2465 .................... res = res*y2 + pl[3];
2466 ....................
2467 .................... r = ql[0]*y2 + ql[1];
2468 .................... r = r*y2 + ql[2];
2469 .................... r = r*y2 + ql[3];
2470 ....................
2471 .................... res = y*res/r;
2472 .................... #if !defined(__PCD__)
2473 .................... n = *((unsigned int8 *)(&x)) - 0x7E;
2474 .................... #endif
2475 .................... #if defined(__PCD__)
2476 .................... data1 = *(((unsigned int8 *)(&x)+3));
2477 .................... rotate_left(&data1,1);
2478 .................... data2 = *(((unsigned int8 *)(&x)+2));
2479 .................... if(bit_test (data2,7))
2480 .................... bit_set(data1,0);
2481 .................... n = data1 - 0x7E;
2482 .................... #endif
2483 ....................
2484 .................... if (n<0)
2485 .................... r = -(float32)-n;
2486 .................... else
2487 .................... r = (float32)n;
2488 ....................
2489 .................... res += r*LN2;
2490 .................... }
2491 ....................
2492 .................... else
2493 .................... res = 0.0;
2494 ....................
2495 .................... return(res);
2496 .................... }
2497 ....................
2498 .................... //Overloaded function for log() for PCD
2499 .................... // Overloaded function log() for data type - Float48
2500 .................... #if defined(__PCD__)
2501 .................... float48 log(float48 x)
2502 .................... {
2503 .................... float48 y, res, r, y2;
2504 .................... unsigned int8 data1,data2;
2505 .................... signed int8 n;
2506 .................... #ifdef _ERRNO
2507 .................... if(x <0)
2508 .................... {
2509 .................... errno=EDOM;
2510 .................... }
2511 .................... if(x ==0)
2512 .................... {
2513 .................... errno=ERANGE;
2514 .................... return(0);
2515 .................... }
2516 .................... #endif
2517 .................... y = x;
2518 ....................
2519 .................... if (y != 1.0)
2520 .................... {
2521 ....................
2522 .................... #if !defined(__PCD__)
2523 .................... *((unsigned int8 *)(&y)) = 0x7E;
2524 .................... #endif
2525 .................... data2 = *(((unsigned int8 *)(&y))+5);
2526 .................... *(((unsigned int8 *)(&y))+5) = 0x3F;
2527 .................... data1 = *(((unsigned int8 *)(&y))+4);
2528 .................... bit_clear(data1,7);
2529 .................... *(((unsigned int8 *)(&y))+4) = data1;
2530 ....................
2531 .................... if(bit_test(data2,7))
2532 .................... bit_set(*(((unsigned int8 *)(&y))+4),7);
2533 .................... y = (y - 1.0)/(y + 1.0);
2534 ....................
2535 .................... y2=y*y;
2536 ....................
2537 .................... res = pl[0]*y2 + pl[1];
2538 .................... res = res*y2 + pl[2];
2539 .................... res = res*y2 + pl[3];
2540 ....................
2541 .................... r = ql[0]*y2 + ql[1];
2542 .................... r = r*y2 + ql[2];
2543 .................... r = r*y2 + ql[3];
2544 ....................
2545 .................... res = y*res/r;
2546 ....................
2547 .................... data1 = *(((unsigned int8 *)(&x)+5));
2548 .................... rotate_left(&data1,1);
2549 .................... data2 = *(((unsigned int8 *)(&x)+4));
2550 .................... if(bit_test (data2,7))
2551 .................... bit_set(data1,0);
2552 ....................
2553 .................... n = data1 - 0x7E;
2554 ....................
2555 .................... if (n<0)
2556 .................... r = -(float48)-n;
2557 .................... else
2558 .................... r = (float48)n;
2559 ....................
2560 .................... res += r*LN2;
2561 .................... }
2562 ....................
2563 .................... else
2564 .................... res = 0.0;
2565 ....................
2566 .................... return(res);
2567 .................... }
2568 ....................
2569 .................... // Overloaded function log() for data type - Float48
2570 .................... #if defined(__PCD__)
2571 .................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
2572 .................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
2573 .................... #endif
2574 .................... float64 log(float64 x)
2575 .................... {
2576 .................... float64 y, res, r, y2;
2577 .................... unsigned int16 data1,data2;
2578 .................... unsigned int16 *p;
2579 .................... signed int16 n;
2580 .................... #ifdef _ERRNO
2581 .................... if(x <0)
2582 .................... {
2583 .................... errno=EDOM;
2584 .................... }
2585 .................... if(x ==0)
2586 .................... {
2587 .................... errno=ERANGE;
2588 .................... return(0);
2589 .................... }
2590 .................... #endif
2591 .................... y = x;
2592 ....................
2593 .................... if (y != 1.0)
2594 .................... {
2595 .................... #if !defined(__PCD__)
2596 .................... *((unsigned int8 *)(&y)) = 0x7E;
2597 .................... #endif
2598 .................... p= (((unsigned int16 *)(&y))+3);
2599 .................... data1 = *p;
2600 .................... data2 = *p;
2601 .................... data1 = 0x3FE;
2602 .................... data1 = data1 <<4;
2603 .................... if(bit_test (data2,15))
2604 .................... bit_set(data1,15);
2605 .................... data2 = data2 & 0x000F;
2606 .................... data1 ^=data2;
2607 ....................
2608 .................... *p = data1;
2609 ....................
2610 .................... y = (y - 1.0)/(y + 1.0);
2611 ....................
2612 .................... y2=y*y;
2613 ....................
2614 .................... res = pl_64[0]*y2 + pl_64[1];
2615 .................... res = res*y2 + pl_64[2];
2616 .................... res = res*y2 + pl_64[3];
2617 ....................
2618 .................... r = ql_64[0]*y2 + ql_64[1];
2619 .................... r = r*y2 + ql_64[2];
2620 .................... r = r*y2 + ql_64[3];
2621 ....................
2622 .................... res = y*res/r;
2623 ....................
2624 .................... p= (((unsigned int16 *)(&x))+3);
2625 .................... data1 = *p;
2626 .................... bit_clear(data1,15);
2627 .................... data1 = data1 >>4;
2628 .................... n = data1 - 0x3FE;
2629 ....................
2630 ....................
2631 .................... if (n<0)
2632 .................... r = -(float64)-n;
2633 .................... else
2634 .................... r = (float64)n;
2635 ....................
2636 .................... res += r*LN2;
2637 .................... }
2638 ....................
2639 .................... else
2640 .................... res = 0.0;
2641 ....................
2642 .................... return(res);
2643 .................... }
2644 .................... #endif
2645 ....................
2646 ....................
2647 .................... #define LN10 2.3025850929940456
2648 ....................
2649 .................... ////////////////////////////////////////////////////////////////////////////
2650 .................... // float log10(float x)
2651 .................... ////////////////////////////////////////////////////////////////////////////
2652 .................... // Description : returns the the log base 10 of x
2653 .................... // Date : N/A
2654 .................... //
2655 .................... float32 log10(float32 x)
2656 .................... {
2657 .................... float32 r;
2658 ....................
2659 .................... r = log(x);
2660 .................... r = r/LN10;
2661 .................... return(r);
2662 .................... }
2663 ....................
2664 .................... //Overloaded functions for log10() for PCD
2665 .................... // Overloaded function log10() for data type - Float48
2666 .................... #if defined(__PCD__)
2667 .................... float48 log10(float48 x)
2668 .................... {
2669 .................... float48 r;
2670 ....................
2671 .................... r = log(x);
2672 .................... r = r/LN10;
2673 .................... return(r);
2674 .................... }
2675 ....................
2676 .................... // Overloaded function log10() for data type - Float64
2677 .................... float64 log10(float64 x)
2678 .................... {
2679 .................... float64 r;
2680 ....................
2681 .................... r = log(x);
2682 .................... r = r/LN10;
2683 .................... return(r);
2684 .................... }
2685 .................... #endif
2686 .................... ////////////////////////////////////////////////////////////////////////////
2687 .................... // float modf(float x)
2688 .................... ////////////////////////////////////////////////////////////////////////////
2689 .................... // Description :breaks the argument value int integral and fractional parts,
2690 .................... // ach of which have the same sign as the argument. It stores the integral part
2691 .................... // as a float in the object pointed to by the iptr
2692 .................... // Returns : returns the signed fractional part of value.
2693 .................... // Date : N/A
2694 .................... //
2695 ....................
2696 .................... float32 modf(float32 value,float32 *iptr)
2697 .................... {
2698 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
2699 .................... return(value - *iptr);
2700 .................... }
2701 .................... //Overloaded functions for modf() for PCD
2702 .................... // Overloaded function modf() for data type - Float48
2703 .................... #if defined(__PCD__)
2704 .................... float48 modf(float48 value,float48 *iptr)
2705 .................... {
2706 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
2707 .................... return(value - *iptr);
2708 .................... }
2709 .................... // Overloaded function modf() for data type - Float64
2710 .................... float64 modf(float64 value,float64 *iptr)
2711 .................... {
2712 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
2713 .................... return(value - *iptr);
2714 .................... }
2715 .................... #endif
2716 ....................
2717 .................... ////////////////////////////////////////////////////////////////////////////
2718 .................... // float pwr(float x,float y)
2719 .................... ////////////////////////////////////////////////////////////////////////////
2720 .................... // Description : returns the value (x^y)
2721 .................... // Date : N/A
2722 .................... // Note : 0 is returned when the function will generate an imaginary number
2723 .................... //
2724 .................... float32 pwr(float32 x,float32 y)
2725 .................... {
2726 .................... if(0 > x && fmod(y, 1) == 0) {
2727 .................... if(fmod(y, 2) == 0) {
2728 .................... return (exp(log(-x) * y));
2729 .................... } else {
2730 .................... return (-exp(log(-x) * y));
2731 .................... }
2732 .................... } else if(0 > x && fmod(y, 1) != 0) {
2733 .................... return 0;
2734 .................... } else {
2735 .................... if(x != 0 || 0 >= y) {
2736 .................... return (exp(log(x) * y));
2737 .................... }
2738 .................... }
2739 .................... }
2740 .................... //Overloaded functions for pwr() for PCD
2741 .................... // Overloaded function pwr() for data type - Float48
2742 .................... #if defined(__PCD__)
2743 .................... float48 pwr(float48 x,float48 y)
2744 .................... {
2745 .................... if(0 > x && fmod(y, 1) == 0) {
2746 .................... if(fmod(y, 2) == 0) {
2747 .................... return (exp(log(-x) * y));
2748 .................... } else {
2749 .................... return (-exp(log(-x) * y));
2750 .................... }
2751 .................... } else if(0 > x && fmod(y, 1) != 0) {
2752 .................... return 0;
2753 .................... } else {
2754 .................... if(x != 0 || 0 >= y) {
2755 .................... return (exp(log(x) * y));
2756 .................... }
2757 .................... }
2758 .................... }
2759 .................... // Overloaded function pwr() for data type - Float64
2760 .................... float64 pwr(float64 x,float64 y)
2761 .................... {
2762 .................... if(0 > x && fmod(y, 1) == 0) {
2763 .................... if(fmod(y, 2) == 0) {
2764 .................... return (exp(log(-x) * y));
2765 .................... } else {
2766 .................... return (-exp(log(-x) * y));
2767 .................... }
2768 .................... } else if(0 > x && fmod(y, 1) != 0) {
2769 .................... return 0;
2770 .................... } else {
2771 .................... if(x != 0 || 0 >= y) {
2772 .................... return (exp(log(x) * y));
2773 .................... }
2774 .................... }
2775 .................... }
2776 .................... #endif
2777 ....................
2778 .................... //////////////////// Power functions ////////////////////
2779 ....................
2780 .................... ////////////////////////////////////////////////////////////////////////////
2781 .................... // float pow(float x,float y)
2782 .................... ////////////////////////////////////////////////////////////////////////////
2783 .................... // Description : returns the value (x^y)
2784 .................... // Date : N/A
2785 .................... // Note : 0 is returned when the function will generate an imaginary number
2786 .................... //
2787 .................... float32 pow(float32 x,float32 y)
2788 .................... {
2789 .................... if(0 > x && fmod(y, 1) == 0) {
2790 .................... if(fmod(y, 2) == 0) {
2791 .................... return (exp(log(-x) * y));
2792 .................... } else {
2793 .................... return (-exp(log(-x) * y));
2794 .................... }
2795 .................... } else if(0 > x && fmod(y, 1) != 0) {
2796 .................... return 0;
2797 .................... } else {
2798 .................... if(x != 0 || 0 >= y) {
2799 .................... return (exp(log(x) * y));
2800 .................... }
2801 .................... }
2802 .................... }
2803 .................... //Overloaded functions for pow() for PCD
2804 .................... // Overloaded function for pow() data type - Float48
2805 .................... #if defined(__PCD__)
2806 .................... float48 pow(float48 x,float48 y)
2807 .................... {
2808 .................... if(0 > x && fmod(y, 1) == 0) {
2809 .................... if(fmod(y, 2) == 0) {
2810 .................... return (exp(log(-x) * y));
2811 .................... } else {
2812 .................... return (-exp(log(-x) * y));
2813 .................... }
2814 .................... } else if(0 > x && fmod(y, 1) != 0) {
2815 .................... return 0;
2816 .................... } else {
2817 .................... if(x != 0 || 0 >= y) {
2818 .................... return (exp(log(x) * y));
2819 .................... }
2820 .................... }
2821 .................... }
2822 ....................
2823 .................... // Overloaded function pow() for data type - Float64
2824 .................... float64 pow(float64 x,float64 y)
2825 .................... {
2826 .................... if(0 > x && fmod(y, 1) == 0) {
2827 .................... if(fmod(y, 2) == 0) {
2828 .................... return (exp(log(-x) * y));
2829 .................... } else {
2830 .................... return (-exp(log(-x) * y));
2831 .................... }
2832 .................... } else if(0 > x && fmod(y, 1) != 0) {
2833 .................... return 0;
2834 .................... } else {
2835 .................... if(x != 0 || 0 >= y) {
2836 .................... return (exp(log(x) * y));
2837 .................... }
2838 .................... }
2839 .................... }
2840 .................... #endif
2841 ....................
2842 .................... ////////////////////////////////////////////////////////////////////////////
2843 .................... // float sqrt(float x)
2844 .................... ////////////////////////////////////////////////////////////////////////////
2845 .................... // Description : returns the square root of x
2846 .................... // Date : N/A
2847 .................... //
2848 .................... float32 sqrt(float32 x)
2849 .................... {
2850 .................... float32 y, res;
2851 .................... #if defined(__PCD__)
2852 .................... unsigned int16 data1,data2;
2853 .................... #endif
2854 .................... BYTE *p;
2855 ....................
2856 .................... #ifdef _ERRNO
2857 .................... if(x < 0)
2858 .................... {
2859 .................... errno=EDOM;
2860 .................... }
2861 .................... #endif
2862 ....................
2863 .................... if( x<=0.0)
2864 .................... return(0.0);
2865 ....................
2866 .................... y=x;
2867 ....................
2868 .................... #if !defined(__PCD__)
2869 .................... p=&y;
2870 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
2871 .................... #endif
2872 ....................
2873 .................... #if defined(__PCD__)
2874 .................... p = (((unsigned int8 *)(&y))+3);
2875 .................... data1 = *(((unsigned int8 *)(&y))+3);
2876 .................... data2 = *(((unsigned int8 *)(&y))+2);
2877 .................... rotate_left(&data1,1);
2878 .................... if(bit_test(data2,7))
2879 .................... bit_set(data1,0);
2880 .................... data1 = ((data1+127) >>1);
2881 .................... bit_clear(data2,7);
2882 .................... if(bit_test(data1,0))
2883 .................... bit_set(data2,7);
2884 .................... data1 = data1 >>1;
2885 .................... *(((unsigned int8 *)(&y))+3) = data1;
2886 .................... *(((unsigned int8 *)(&y))+2) = data2;
2887 ....................
2888 .................... #endif
2889 ....................
2890 .................... do {
2891 .................... res=y;
2892 .................... y+=(x/y);
2893 ....................
2894 .................... #if !defined(__PCD__)
2895 .................... (*p)--;
2896 .................... #endif
2897 ....................
2898 .................... #if defined(__PCD__)
2899 .................... data1 = *(((unsigned int8 *)(&y))+3);
2900 .................... data2 = *(((unsigned int8 *)(&y))+2);
2901 .................... rotate_left(&data1,1);
2902 .................... if(bit_test(data2,7))
2903 .................... bit_set(data1,0);
2904 .................... data1--;
2905 .................... bit_clear(data2,7);
2906 .................... if(bit_test(data1,0))
2907 .................... bit_set(data2,7);
2908 .................... data1 = data1 >>1;
2909 .................... *(((unsigned int8 *)(&y))+3) = data1;
2910 .................... *(((unsigned int8 *)(&y))+2) = data2;
2911 ....................
2912 .................... #endif
2913 .................... } while(res != y);
2914 ....................
2915 .................... return(res);
2916 .................... }
2917 .................... //Overloaded functions for sqrt() for PCD
2918 .................... // Overloaded function sqrt() for data type - Float48
2919 .................... #if defined(__PCD__)
2920 .................... float48 sqrt(float48 x)
2921 .................... {
2922 .................... float48 y, res;
2923 .................... unsigned int16 data1,data2;
2924 .................... BYTE *p;
2925 ....................
2926 .................... #ifdef _ERRNO
2927 .................... if(x < 0)
2928 .................... {
2929 .................... errno=EDOM;
2930 .................... }
2931 .................... #endif
2932 ....................
2933 .................... if( x<=0.0)
2934 .................... return(0.0);
2935 ....................
2936 .................... y=x;
2937 ....................
2938 .................... #if !defined(__PCD__)
2939 .................... p=&y;
2940 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
2941 .................... #endif
2942 ....................
2943 .................... #if defined(__PCD__)
2944 .................... p = (((unsigned int8 *)(&y))+5);
2945 .................... data1 = *(((unsigned int8 *)(&y))+5);
2946 .................... data2 = *(((unsigned int8 *)(&y))+4);
2947 .................... rotate_left(&data1,1);
2948 .................... if(bit_test(data2,7))
2949 .................... bit_set(data1,0);
2950 .................... data1 = ((data1+127) >>1);
2951 .................... bit_clear(data2,7);
2952 .................... if(bit_test(data1,0))
2953 .................... bit_set(data2,7);
2954 .................... data1 = data1 >>1;
2955 .................... *(((unsigned int8 *)(&y))+5) = data1;
2956 .................... *(((unsigned int8 *)(&y))+4) = data2;
2957 ....................
2958 .................... #endif
2959 ....................
2960 .................... do {
2961 .................... res=y;
2962 .................... y+=(x/y);
2963 ....................
2964 .................... #if !defined(__PCD__)
2965 .................... (*p)--;
2966 .................... #endif
2967 ....................
2968 .................... data1 = *(((unsigned int8 *)(&y))+5);
2969 .................... data2 = *(((unsigned int8 *)(&y))+4);
2970 .................... rotate_left(&data1,1);
2971 .................... if(bit_test(data2,7))
2972 .................... bit_set(data1,0);
2973 .................... data1--;
2974 .................... bit_clear(data2,7);
2975 .................... if(bit_test(data1,0))
2976 .................... bit_set(data2,7);
2977 .................... data1 = data1 >>1;
2978 .................... *(((unsigned int8 *)(&y))+5) = data1;
2979 .................... *(((unsigned int8 *)(&y))+4) = data2;
2980 ....................
2981 .................... } while(res != y);
2982 ....................
2983 .................... return(res);
2984 .................... }
2985 ....................
2986 .................... // Overloaded function sqrt() for data type - Float64
2987 .................... float64 sqrt(float64 x)
2988 .................... {
2989 .................... float64 y, res;
2990 .................... unsigned int16 *p;
2991 .................... unsigned int16 temp1,temp2;
2992 ....................
2993 .................... #ifdef _ERRNO
2994 .................... if(x < 0)
2995 .................... {
2996 .................... errno=EDOM;
2997 .................... }
2998 .................... #endif
2999 ....................
3000 .................... if( x<=0.0)
3001 .................... return(0.0);
3002 ....................
3003 .................... y=x;
3004 .................... p= (((unsigned int16 *)(&y))+3);
3005 .................... temp1 = *p;
3006 .................... temp2 = *p;
3007 .................... bit_clear(temp1,15);
3008 .................... temp1 = (temp1>>4)+1023;
3009 .................... temp1 = temp1 >> 1;
3010 .................... temp1 = (temp1<<4) & 0xFFF0;
3011 .................... if(bit_test(temp2,15))
3012 .................... bit_set(temp1,15);
3013 .................... temp2 = temp2 & 0x000F;
3014 .................... temp1 ^= temp2;
3015 ....................
3016 .................... (*p) = temp1;
3017 ....................
3018 .................... do {
3019 .................... res=y;
3020 .................... y+=(x/y);
3021 .................... temp1 = *p;
3022 .................... temp2 = *p;
3023 .................... bit_clear(temp1,15);
3024 .................... temp1 = (temp1>>4);
3025 .................... temp1--;
3026 .................... temp1 = (temp1<<4) & 0xFFF0;
3027 .................... if(bit_test(temp2,15))
3028 .................... bit_set(temp1,15);
3029 .................... temp2 = temp2 & 0x000F;
3030 .................... temp1 ^= temp2;
3031 .................... (*p) = temp1;
3032 ....................
3033 .................... } while(res != y);
3034 ....................
3035 .................... return(res);
3036 .................... }
3037 .................... #endif
3038 ....................
3039 .................... ////////////////////////////// Trig Functions //////////////////////////////
3040 .................... #ifdef PI_DIV_BY_TWO
3041 .................... #undef PI_DIV_BY_TWO
3042 .................... #endif
3043 .................... #define PI_DIV_BY_TWO 1.5707963267948966
3044 .................... #ifdef TWOBYPI
3045 .................... #undef TWOBYPI
3046 .................... #define TWOBYPI 0.6366197723675813
3047 .................... #endif
3048 .................... ////////////////////////////////////////////////////////////////////////////
3049 .................... // float cos(float x)
3050 .................... ////////////////////////////////////////////////////////////////////////////
3051 .................... // Description : returns the cosine value of the angle x, which is in radian
3052 .................... // Date : 9/20/2001
3053 .................... //
3054 .................... float32 cos(float32 x)
3055 .................... {
3056 .................... float32 y, t, t2 = 1.0;
3057 .................... unsigned int8 quad, i;
3058 .................... float32 frac;
3059 .................... float32 p[6] = { //by the series definition for cosine
3060 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
3061 .................... 0.04166666666667,
3062 .................... -0.00138888888889,
3063 .................... 0.00002480158730,
3064 .................... -0.00000027557319,
3065 .................... 0.00000000208767,
3066 .................... //-0.00000000001147,
3067 .................... // 0.00000000000005
3068 .................... };
3069 ....................
3070 .................... if (x < 0) x = -x; // absolute value of input
3071 ....................
3072 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
3073 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
3074 .................... quad = quad % 4; // quadrant (0 to 3)
3075 ....................
3076 .................... if (quad == 0 || quad == 2)
3077 .................... t = frac * PI_DIV_BY_TWO;
3078 .................... else if (quad == 1)
3079 .................... t = (1-frac) * PI_DIV_BY_TWO;
3080 .................... else // should be 3
3081 .................... t = (frac-1) * PI_DIV_BY_TWO;
3082 ....................
3083 .................... y = 1.0;
3084 .................... t = t * t;
3085 .................... for (i = 0; i <= 5; i++)
3086 .................... {
3087 .................... t2 = t2 * t;
3088 .................... y = y + p[i] * t2;
3089 .................... }
3090 ....................
3091 .................... if (quad == 2 || quad == 1)
3092 .................... y = -y; // correct sign
3093 ....................
3094 .................... return (y);
3095 .................... }
3096 ....................
3097 ....................
3098 .................... //Overloaded functions for cos() for PCD
3099 .................... // Overloaded function cos() for data type - Float48
3100 .................... #if defined(__PCD__)
3101 .................... float48 cos(float48 x)
3102 .................... {
3103 .................... float48 y, t, t2 = 1.0;
3104 .................... unsigned int8 quad, i;
3105 .................... float48 frac;
3106 .................... float48 p[6] = { //by the series definition for cosine
3107 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
3108 .................... 0.04166666666667,
3109 .................... -0.00138888888889,
3110 .................... 0.00002480158730,
3111 .................... -0.00000027557319,
3112 .................... 0.00000000208767,
3113 .................... //-0.00000000001147,
3114 .................... // 0.00000000000005
3115 .................... };
3116 ....................
3117 .................... if (x < 0) x = -x; // absolute value of input
3118 ....................
3119 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
3120 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
3121 .................... quad = quad % 4; // quadrant (0 to 3)
3122 ....................
3123 .................... if (quad == 0 || quad == 2)
3124 .................... t = frac * PI_DIV_BY_TWO;
3125 .................... else if (quad == 1)
3126 .................... t = (1-frac) * PI_DIV_BY_TWO;
3127 .................... else // should be 3
3128 .................... t = (frac-1) * PI_DIV_BY_TWO;
3129 ....................
3130 .................... y = 0.999999999781;
3131 .................... t = t * t;
3132 .................... for (i = 0; i <= 5; i++)
3133 .................... {
3134 .................... t2 = t2 * t;
3135 .................... y = y + p[i] * t2;
3136 .................... }
3137 ....................
3138 .................... if (quad == 2 || quad == 1)
3139 .................... y = -y; // correct sign
3140 ....................
3141 .................... return (y);
3142 .................... }
3143 ....................
3144 .................... // Overloaded function cos() for data type - Float48
3145 .................... float64 cos(float64 x)
3146 .................... {
3147 .................... float64 y, t, t2 = 1.0;
3148 .................... unsigned int8 quad, i;
3149 .................... float64 frac;
3150 .................... float64 p[6] = { //by the series definition for cosine
3151 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
3152 .................... 0.04166666666667,
3153 .................... -0.00138888888889,
3154 .................... 0.00002480158730,
3155 .................... -0.00000027557319,
3156 .................... 0.00000000208767,
3157 .................... //-0.00000000001147,
3158 .................... // 0.00000000000005
3159 .................... };
3160 ....................
3161 .................... if (x < 0) x = -x; // absolute value of input
3162 ....................
3163 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
3164 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
3165 .................... quad = quad % 4; // quadrant (0 to 3)
3166 ....................
3167 .................... if (quad == 0 || quad == 2)
3168 .................... t = frac * PI_DIV_BY_TWO;
3169 .................... else if (quad == 1)
3170 .................... t = (1-frac) * PI_DIV_BY_TWO;
3171 .................... else // should be 3
3172 .................... t = (frac-1) * PI_DIV_BY_TWO;
3173 ....................
3174 .................... y = 0.999999999781;
3175 .................... t = t * t;
3176 .................... for (i = 0; i <= 5; i++)
3177 .................... {
3178 .................... t2 = t2 * t;
3179 .................... y = y + p[i] * t2;
3180 .................... }
3181 ....................
3182 .................... if (quad == 2 || quad == 1)
3183 .................... y = -y; // correct sign
3184 ....................
3185 .................... return (y);
3186 .................... }
3187 ....................
3188 .................... #endif
3189 ....................
3190 .................... ////////////////////////////////////////////////////////////////////////////
3191 .................... // float sin(float x)
3192 .................... ////////////////////////////////////////////////////////////////////////////
3193 .................... // Description : returns the sine value of the angle x, which is in radian
3194 .................... // Date : 9/20/2001
3195 .................... //
3196 .................... float32 sin(float32 x)
3197 .................... {
3198 .................... return cos(x - PI_DIV_BY_TWO);
3199 .................... }
3200 ....................
3201 .................... //Overloaded functions for sin() for PCD
3202 .................... // Overloaded function sin() for data type - Float48
3203 .................... #if defined(__PCD__)
3204 .................... float48 sin(float48 x)
3205 .................... {
3206 .................... return cos(x - PI_DIV_BY_TWO);
3207 .................... }
3208 ....................
3209 .................... // Overloaded function sin() for data type - Float48
3210 .................... float64 sin(float64 x)
3211 .................... {
3212 .................... return cos(x - PI_DIV_BY_TWO);
3213 .................... }
3214 .................... #endif
3215 ....................
3216 .................... ////////////////////////////////////////////////////////////////////////////
3217 .................... // float tan(float x)
3218 .................... ////////////////////////////////////////////////////////////////////////////
3219 .................... // Description : returns the tangent value of the angle x, which is in radian
3220 .................... // Date : 9/20/2001
3221 .................... //
3222 .................... float32 tan(float32 x)
3223 .................... {
3224 .................... float32 c, s;
3225 ....................
3226 .................... c = cos(x);
3227 .................... if (c == 0.0)
3228 .................... return (1.0e+36);
3229 ....................
3230 .................... s = sin(x);
3231 .................... return(s/c);
3232 .................... }
3233 .................... //Overloaded functions for tan() for PCD
3234 .................... // Overloaded function tan() for data type - Float48
3235 .................... #if defined(__PCD__)
3236 .................... float48 tan(float48 x)
3237 .................... {
3238 .................... float48 c, s;
3239 ....................
3240 .................... c = cos(x);
3241 .................... if (c == 0.0)
3242 .................... return (1.0e+36);
3243 ....................
3244 .................... s = sin(x);
3245 .................... return(s/c);
3246 .................... }
3247 ....................
3248 .................... // Overloaded function tan() for data type - Float48
3249 .................... float64 tan(float64 x)
3250 .................... {
3251 .................... float64 c, s;
3252 ....................
3253 .................... c = cos(x);
3254 .................... if (c == 0.0)
3255 .................... return (1.0e+36);
3256 ....................
3257 .................... s = sin(x);
3258 .................... return(s/c);
3259 .................... }
3260 .................... #endif
3261 ....................
3262 .................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290};
3263 .................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290};
3264 ....................
3265 .................... float32 ASIN_COS(float32 x, unsigned int8 n)
3266 .................... {
3267 .................... float32 y, res, r, y2;
3268 .................... int1 s;
3269 .................... #ifdef _ERRNO
3270 .................... if(x <-1 || x > 1)
3271 .................... {
3272 .................... errno=EDOM;
3273 .................... }
3274 .................... #endif
3275 .................... s = 0;
3276 .................... y = x;
3277 ....................
3278 .................... if (x < 0)
3279 .................... {
3280 .................... s = 1;
3281 .................... y = -y;
3282 .................... }
3283 ....................
3284 .................... if (y > 0.5)
3285 .................... {
3286 .................... y = sqrt((1.0 - y)/2.0);
3287 .................... n += 2;
3288 .................... }
3289 ....................
3290 .................... y2=y*y;
3291 ....................
3292 .................... res = pas[0]*y2 + pas[1];
3293 .................... res = res*y2 + pas[2];
3294 ....................
3295 .................... r = qas[0]*y2 + qas[1];
3296 .................... r = r*y2 + qas[2];
3297 ....................
3298 .................... res = y*res/r;
3299 ....................
3300 .................... if (n & 2) // |x| > 0.5
3301 .................... res = PI_DIV_BY_TWO - 2.0*res;
3302 .................... if (s)
3303 .................... res = -res;
3304 .................... if (n & 1) // take arccos
3305 .................... res = PI_DIV_BY_TWO - res;
3306 ....................
3307 .................... return(res);
3308 .................... }
3309 ....................
3310 .................... //Overloaded functions for ASIN_COS() for PCD
3311 .................... // Overloaded function ASIN_COS() for data type - Float48
3312 .................... #if defined(__PCD__)
3313 .................... float48 ASIN_COS(float48 x, unsigned int8 n)
3314 .................... {
3315 .................... float48 y, res, r, y2;
3316 .................... int1 s;
3317 .................... #ifdef _ERRNO
3318 .................... if(x <-1 || x > 1)
3319 .................... {
3320 .................... errno=EDOM;
3321 .................... }
3322 .................... #endif
3323 .................... s = 0;
3324 .................... y = x;
3325 ....................
3326 .................... if (x < 0)
3327 .................... {
3328 .................... s = 1;
3329 .................... y = -y;
3330 .................... }
3331 ....................
3332 .................... if (y > 0.5)
3333 .................... {
3334 .................... y = sqrt((1.0 - y)/2.0);
3335 .................... n += 2;
3336 .................... }
3337 ....................
3338 .................... y2=y*y;
3339 ....................
3340 .................... res = pas[0]*y2 + pas[1];
3341 .................... res = res*y2 + pas[2];
3342 ....................
3343 .................... r = qas[0]*y2 + qas[1];
3344 .................... r = r*y2 + qas[2];
3345 ....................
3346 .................... res = y*res/r;
3347 ....................
3348 .................... if (n & 2) // |x| > 0.5
3349 .................... res = PI_DIV_BY_TWO - 2.0*res;
3350 .................... if (s)
3351 .................... res = -res;
3352 .................... if (n & 1) // take arccos
3353 .................... res = PI_DIV_BY_TWO - res;
3354 ....................
3355 .................... return(res);
3356 .................... }
3357 ....................
3358 .................... // Overloaded function ASIN_COS() for data type - Float64
3359 .................... float64 ASIN_COS(float64 x, unsigned int8 n)
3360 .................... {
3361 .................... float64 y, res, r, y2;
3362 .................... int1 s;
3363 .................... #ifdef _ERRNO
3364 .................... if(x <-1 || x > 1)
3365 .................... {
3366 .................... errno=EDOM;
3367 .................... }
3368 .................... #endif
3369 .................... s = 0;
3370 .................... y = x;
3371 ....................
3372 .................... if (x < 0)
3373 .................... {
3374 .................... s = 1;
3375 .................... y = -y;
3376 .................... }
3377 ....................
3378 .................... if (y > 0.5)
3379 .................... {
3380 .................... y = sqrt((1.0 - y)/2.0);
3381 .................... n += 2;
3382 .................... }
3383 ....................
3384 .................... y2=y*y;
3385 ....................
3386 .................... res = pas[0]*y2 + pas[1];
3387 .................... res = res*y2 + pas[2];
3388 ....................
3389 .................... r = qas[0]*y2 + qas[1];
3390 .................... r = r*y2 + qas[2];
3391 ....................
3392 .................... res = y*res/r;
3393 ....................
3394 .................... if (n & 2) // |x| > 0.5
3395 .................... res = PI_DIV_BY_TWO - 2.0*res;
3396 .................... if (s)
3397 .................... res = -res;
3398 .................... if (n & 1) // take arccos
3399 .................... res = PI_DIV_BY_TWO - res;
3400 ....................
3401 .................... return(res);
3402 .................... }
3403 .................... #endif
3404 ....................
3405 .................... ////////////////////////////////////////////////////////////////////////////
3406 .................... // float asin(float x)
3407 .................... ////////////////////////////////////////////////////////////////////////////
3408 .................... // Description : returns the arcsine value of the value x.
3409 .................... // Date : N/A
3410 .................... //
3411 .................... float32 asin(float32 x)
3412 .................... {
3413 .................... float32 r;
3414 ....................
3415 .................... r = ASIN_COS(x, 0);
3416 .................... return(r);
3417 .................... }
3418 .................... //Overloaded functions for asin() for PCD
3419 .................... // Overloaded function asin() for data type - Float48
3420 .................... #if defined(__PCD__)
3421 .................... float48 asin(float48 x)
3422 .................... {
3423 .................... float48 r;
3424 ....................
3425 .................... r = ASIN_COS(x, 0);
3426 .................... return(r);
3427 .................... }
3428 ....................
3429 .................... // Overloaded function asin() for data type - Float64
3430 .................... float64 asin(float64 x)
3431 .................... {
3432 .................... float64 r;
3433 ....................
3434 .................... r = ASIN_COS(x, 0);
3435 .................... return(r);
3436 .................... }
3437 .................... #endif
3438 ....................
3439 .................... ////////////////////////////////////////////////////////////////////////////
3440 .................... // float acos(float x)
3441 .................... ////////////////////////////////////////////////////////////////////////////
3442 .................... // Description : returns the arccosine value of the value x.
3443 .................... // Date : N/A
3444 .................... //
3445 .................... float32 acos(float32 x)
3446 .................... {
3447 .................... float32 r;
3448 ....................
3449 .................... r = ASIN_COS(x, 1);
3450 .................... return(r);
3451 .................... }
3452 .................... //Overloaded functions for acos() for PCD
3453 .................... // Overloaded function acos() for data type - Float48
3454 .................... #if defined(__PCD__)
3455 .................... float48 acos(float48 x)
3456 .................... {
3457 .................... float48 r;
3458 ....................
3459 .................... r = ASIN_COS(x, 1);
3460 .................... return(r);
3461 .................... }
3462 ....................
3463 .................... // Overloaded function acos() for data type - Float64
3464 .................... float64 acos(float64 x)
3465 .................... {
3466 .................... float64 r;
3467 ....................
3468 .................... r = ASIN_COS(x, 1);
3469 .................... return(r);
3470 .................... }
3471 .................... #endif
3472 ....................
3473 .................... float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};
3474 .................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};
3475 ....................
3476 .................... ////////////////////////////////////////////////////////////////////////////
3477 .................... // float atan(float x)
3478 .................... ////////////////////////////////////////////////////////////////////////////
3479 .................... // Description : returns the arctangent value of the value x.
3480 .................... // Date : N/A
3481 .................... //
3482 .................... float32 atan(float32 x)
3483 .................... {
3484 .................... float32 y, res, r;
3485 .................... int1 s, flag;
3486 ....................
3487 .................... s = 0;
3488 .................... flag = 0;
3489 .................... y = x;
3490 ....................
3491 .................... if (x < 0)
3492 .................... {
3493 .................... s = 1;
3494 .................... y = -y;
3495 .................... }
3496 ....................
3497 .................... if (y > 1.0)
3498 .................... {
3499 .................... y = 1.0/y;
3500 .................... flag = 1;
3501 .................... }
3502 ....................
3503 .................... res = pat[0]*y*y + pat[1];
3504 .................... res = res*y*y + pat[2];
3505 .................... res = res*y*y + pat[3];
3506 ....................
3507 .................... r = qat[0]*y*y + qat[1];
3508 .................... r = r*y*y + qat[2];
3509 .................... r = r*y*y + qat[3];
3510 ....................
3511 .................... res = y*res/r;
3512 ....................
3513 ....................
3514 .................... if (flag) // for |x| > 1
3515 .................... res = PI_DIV_BY_TWO - res;
3516 .................... if (s)
3517 .................... res = -res;
3518 ....................
3519 .................... return(res);
3520 .................... }
3521 .................... //Overloaded functions for atan() for PCD
3522 .................... // Overloaded function atan() for data type - Float48
3523 .................... #if defined(__PCD__)
3524 .................... float48 atan(float48 x)
3525 .................... {
3526 .................... float48 y, res, r;
3527 .................... int1 s, flag;
3528 ....................
3529 .................... s = 0;
3530 .................... flag = 0;
3531 .................... y = x;
3532 ....................
3533 .................... if (x < 0)
3534 .................... {
3535 .................... s = 1;
3536 .................... y = -y;
3537 .................... }
3538 ....................
3539 .................... if (y > 1.0)
3540 .................... {
3541 .................... y = 1.0/y;
3542 .................... flag = 1;
3543 .................... }
3544 ....................
3545 .................... res = pat[0]*y*y + pat[1];
3546 .................... res = res*y*y + pat[2];
3547 .................... res = res*y*y + pat[3];
3548 ....................
3549 .................... r = qat[0]*y*y + qat[1];
3550 .................... r = r*y*y + qat[2];
3551 .................... r = r*y*y + qat[3];
3552 ....................
3553 .................... res = y*res/r;
3554 ....................
3555 ....................
3556 .................... if (flag) // for |x| > 1
3557 .................... res = PI_DIV_BY_TWO - res;
3558 .................... if (s)
3559 .................... res = -res;
3560 ....................
3561 .................... return(res);
3562 .................... }
3563 ....................
3564 .................... // Overloaded function atan() for data type - Float64
3565 .................... float64 atan(float64 x)
3566 .................... {
3567 .................... float64 y, res, r;
3568 .................... int1 s, flag;
3569 ....................
3570 .................... s = 0;
3571 .................... flag = 0;
3572 .................... y = x;
3573 ....................
3574 .................... if (x < 0)
3575 .................... {
3576 .................... s = 1;
3577 .................... y = -y;
3578 .................... }
3579 ....................
3580 .................... if (y > 1.0)
3581 .................... {
3582 .................... y = 1.0/y;
3583 .................... flag = 1;
3584 .................... }
3585 ....................
3586 .................... res = pat[0]*y*y + pat[1];
3587 .................... res = res*y*y + pat[2];
3588 .................... res = res*y*y + pat[3];
3589 ....................
3590 .................... r = qat[0]*y*y + qat[1];
3591 .................... r = r*y*y + qat[2];
3592 .................... r = r*y*y + qat[3];
3593 ....................
3594 .................... res = y*res/r;
3595 ....................
3596 ....................
3597 .................... if (flag) // for |x| > 1
3598 .................... res = PI_DIV_BY_TWO - res;
3599 .................... if (s)
3600 .................... res = -res;
3601 ....................
3602 .................... return(res);
3603 .................... }
3604 .................... #endif
3605 ....................
3606 .................... /////////////////////////////////////////////////////////////////////////////
3607 .................... // float atan2(float y, float x)
3608 .................... /////////////////////////////////////////////////////////////////////////////
3609 .................... // Description :computes the principal value of arc tangent of y/x, using the
3610 .................... // signs of both the arguments to determine the quadrant of the return value
3611 .................... // Returns : returns the arc tangent of y/x.
3612 .................... // Date : N/A
3613 .................... //
3614 ....................
3615 .................... float32 atan2(float32 y,float32 x)
3616 .................... {
3617 .................... float32 z;
3618 .................... int1 sign;
3619 .................... unsigned int8 quad;
3620 .................... sign=0;
3621 .................... quad=0; //quadrant
3622 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
3623 .................... if(y<0.0)
3624 .................... {
3625 .................... sign=1;
3626 .................... y=-y;
3627 .................... }
3628 .................... if(x<0.0)
3629 .................... {
3630 .................... x=-x;
3631 .................... }
3632 .................... if (x==0.0)
3633 .................... {
3634 .................... if(y==0.0)
3635 .................... {
3636 .................... #ifdef _ERRNO
3637 .................... {
3638 .................... errno=EDOM;
3639 .................... }
3640 .................... #endif
3641 .................... }
3642 .................... else
3643 .................... {
3644 .................... if(sign)
3645 .................... {
3646 .................... return (-(PI_DIV_BY_TWO));
3647 .................... }
3648 .................... else
3649 .................... {
3650 .................... return (PI_DIV_BY_TWO);
3651 .................... }
3652 .................... }
3653 .................... }
3654 .................... else
3655 .................... {
3656 .................... z=y/x;
3657 .................... switch(quad)
3658 .................... {
3659 .................... case 1:
3660 .................... {
3661 .................... return atan(z);
3662 .................... break;
3663 .................... }
3664 .................... case 2:
3665 .................... {
3666 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
3667 .................... return (PI-atan(z));
3668 .................... break;
3669 .................... }
3670 .................... case 3:
3671 .................... {
3672 .................... return (atan(z)-PI);
3673 .................... break;
3674 .................... }
3675 .................... case 4:
3676 .................... {
3677 .................... return (-atan(z));
3678 .................... break;
3679 .................... }
3680 .................... }
3681 .................... }
3682 .................... }
3683 ....................
3684 .................... //Overloaded functions for atan2() for PCD
3685 .................... // Overloaded function atan2() for data type - Float48
3686 .................... #if defined(__PCD__)
3687 .................... float48 atan2(float48 y,float48 x)
3688 .................... {
3689 .................... float48 z;
3690 .................... int1 sign;
3691 .................... unsigned int8 quad;
3692 .................... sign=0;
3693 .................... quad=0; //quadrant
3694 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
3695 .................... if(y<0.0)
3696 .................... {
3697 .................... sign=1;
3698 .................... y=-y;
3699 .................... }
3700 .................... if(x<0.0)
3701 .................... {
3702 .................... x=-x;
3703 .................... }
3704 .................... if (x==0.0)
3705 .................... {
3706 .................... if(y==0.0)
3707 .................... {
3708 .................... #ifdef _ERRNO
3709 .................... {
3710 .................... errno=EDOM;
3711 .................... }
3712 .................... #endif
3713 .................... }
3714 .................... else
3715 .................... {
3716 .................... if(sign)
3717 .................... {
3718 .................... return (-(PI_DIV_BY_TWO));
3719 .................... }
3720 .................... else
3721 .................... {
3722 .................... return (PI_DIV_BY_TWO);
3723 .................... }
3724 .................... }
3725 .................... }
3726 .................... else
3727 .................... {
3728 .................... z=y/x;
3729 .................... switch(quad)
3730 .................... {
3731 .................... case 1:
3732 .................... {
3733 .................... return atan(z);
3734 .................... break;
3735 .................... }
3736 .................... case 2:
3737 .................... {
3738 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
3739 .................... return (PI-atan(z));
3740 .................... break;
3741 .................... }
3742 .................... case 3:
3743 .................... {
3744 .................... return (atan(z)-PI);
3745 .................... break;
3746 .................... }
3747 .................... case 4:
3748 .................... {
3749 .................... return (-atan(z));
3750 .................... break;
3751 .................... }
3752 .................... }
3753 .................... }
3754 .................... }
3755 ....................
3756 .................... // Overloaded function atan2() for data type - Float64
3757 .................... float64 atan2(float64 y,float64 x)
3758 .................... {
3759 .................... float64 z;
3760 .................... int1 sign;
3761 .................... unsigned int8 quad;
3762 .................... sign=0;
3763 .................... quad=0; //quadrant
3764 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
3765 .................... if(y<0.0)
3766 .................... {
3767 .................... sign=1;
3768 .................... y=-y;
3769 .................... }
3770 .................... if(x<0.0)
3771 .................... {
3772 .................... x=-x;
3773 .................... }
3774 .................... if (x==0.0)
3775 .................... {
3776 .................... if(y==0.0)
3777 .................... {
3778 .................... #ifdef _ERRNO
3779 .................... {
3780 .................... errno=EDOM;
3781 .................... }
3782 .................... #endif
3783 .................... }
3784 .................... else
3785 .................... {
3786 .................... if(sign)
3787 .................... {
3788 .................... return (-(PI_DIV_BY_TWO));
3789 .................... }
3790 .................... else
3791 .................... {
3792 .................... return (PI_DIV_BY_TWO);
3793 .................... }
3794 .................... }
3795 .................... }
3796 .................... else
3797 .................... {
3798 .................... z=y/x;
3799 .................... switch(quad)
3800 .................... {
3801 .................... case 1:
3802 .................... {
3803 .................... return atan(z);
3804 .................... break;
3805 .................... }
3806 .................... case 2:
3807 .................... {
3808 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
3809 .................... return (PI-atan(z));
3810 .................... break;
3811 .................... }
3812 .................... case 3:
3813 .................... {
3814 .................... return (atan(z)-PI);
3815 .................... break;
3816 .................... }
3817 .................... case 4:
3818 .................... {
3819 .................... return (-atan(z));
3820 .................... break;
3821 .................... }
3822 .................... }
3823 .................... }
3824 .................... }
3825 .................... #endif
3826 ....................
3827 .................... //////////////////// Hyperbolic functions ////////////////////
3828 ....................
3829 .................... ////////////////////////////////////////////////////////////////////////////
3830 .................... // float cosh(float x)
3831 .................... ////////////////////////////////////////////////////////////////////////////
3832 .................... // Description : Computes the hyperbolic cosine value of x
3833 .................... // Returns : returns the hyperbolic cosine value of x
3834 .................... // Date : N/A
3835 .................... //
3836 ....................
3837 .................... float32 cosh(float32 x)
3838 .................... {
3839 .................... return ((exp(x)+exp(-x))/2);
3840 .................... }
3841 .................... //Overloaded functions for cosh() for PCD
3842 .................... // Overloaded function cosh() for data type - Float48
3843 .................... #if defined(__PCD__)
3844 .................... float48 cosh(float48 x)
3845 .................... {
3846 .................... return ((exp(x)+exp(-x))/2);
3847 .................... }
3848 ....................
3849 .................... // Overloaded function cosh() for data type - Float64
3850 .................... float64 cosh(float64 x)
3851 .................... {
3852 .................... return ((exp(x)+exp(-x))/2);
3853 .................... }
3854 .................... #endif
3855 ....................
3856 .................... ////////////////////////////////////////////////////////////////////////////
3857 .................... // float sinh(float x)
3858 .................... ////////////////////////////////////////////////////////////////////////////
3859 .................... // Description : Computes the hyperbolic sine value of x
3860 .................... // Returns : returns the hyperbolic sine value of x
3861 .................... // Date : N/A
3862 .................... //
3863 ....................
3864 .................... float32 sinh(float32 x)
3865 .................... {
3866 ....................
3867 .................... return ((exp(x) - exp(-x))/2);
3868 .................... }
3869 .................... //Overloaded functions for sinh() for PCD
3870 .................... // Overloaded function sinh() for data type - Float48
3871 .................... #if defined(__PCD__)
3872 .................... float48 sinh(float48 x)
3873 .................... {
3874 ....................
3875 .................... return ((exp(x) - exp(-x))/2);
3876 .................... }
3877 ....................
3878 .................... // Overloaded function sinh() for data type - Float48
3879 .................... float64 sinh(float64 x)
3880 .................... {
3881 ....................
3882 .................... return ((exp(x) - exp(-x))/2);
3883 .................... }
3884 .................... #endif
3885 ....................
3886 .................... ////////////////////////////////////////////////////////////////////////////
3887 .................... // float tanh(float x)
3888 .................... ////////////////////////////////////////////////////////////////////////////
3889 .................... // Description : Computes the hyperbolic tangent value of x
3890 .................... // Returns : returns the hyperbolic tangent value of x
3891 .................... // Date : N/A
3892 .................... //
3893 ....................
3894 .................... float32 tanh(float32 x)
3895 .................... {
3896 .................... return(sinh(x)/cosh(x));
3897 .................... }
3898 .................... //Overloaded functions for tanh() for PCD
3899 .................... // Overloaded function tanh() for data type - Float48
3900 .................... #if defined(__PCD__)
3901 .................... float48 tanh(float48 x)
3902 .................... {
3903 .................... return(sinh(x)/cosh(x));
3904 .................... }
3905 ....................
3906 .................... // Overloaded function tanh() for data type - Float64
3907 .................... float64 tanh(float64 x)
3908 .................... {
3909 .................... return(sinh(x)/cosh(x));
3910 .................... }
3911 .................... #endif
3912 ....................
3913 .................... ////////////////////////////////////////////////////////////////////////////
3914 .................... // float frexp(float x, signed int *exp)
3915 .................... ////////////////////////////////////////////////////////////////////////////
3916 .................... // Description : breaks a floating point number into a normalized fraction and an integral
3917 .................... // power of 2. It stores the integer in the signed int object pointed to by exp.
3918 .................... // Returns : returns the value x, such that x is a double with magnitude in the interval
3919 .................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero,
3920 .................... // both parts of the result are zero.
3921 .................... // Date : N/A
3922 .................... //
3923 ....................
3924 .................... #define LOG2 .30102999566398119521
3925 .................... float32 frexp(float32 x, signed int8 *exp)
3926 .................... {
3927 .................... float32 res;
3928 .................... int1 sign = 0;
3929 .................... if(x == 0.0)
3930 .................... {
3931 .................... *exp=0;
3932 .................... return (0.0);
3933 .................... }
3934 .................... if(x < 0.0)
3935 .................... {
3936 .................... x=-x;
3937 .................... sign=1;
3938 .................... }
3939 .................... if (x > 1.0)
3940 .................... {
3941 .................... *exp=(ceil(log10(x)/LOG2));
3942 .................... res=x/(pow(2, *exp));
3943 .................... if (res == 1)
3944 .................... {
3945 .................... *exp=*exp+1;
3946 .................... res=.5;
3947 .................... }
3948 .................... }
3949 .................... else
3950 .................... {
3951 .................... if(x < 0.5)
3952 .................... {
3953 .................... *exp=-1;
3954 .................... res=x*2;
3955 .................... }
3956 .................... else
3957 .................... {
3958 .................... *exp=0;
3959 .................... res=x;
3960 .................... }
3961 .................... }
3962 .................... if(sign)
3963 .................... {
3964 .................... res=-res;
3965 .................... }
3966 .................... return res;
3967 .................... }
3968 ....................
3969 .................... //Overloaded functions for frexp() for PCD
3970 .................... // Overloaded function frexp() for data type - Float48
3971 .................... #if defined(__PCD__)
3972 .................... float48 frexp(float48 x, signed int8 *exp)
3973 .................... {
3974 .................... float48 res;
3975 .................... int1 sign = 0;
3976 .................... if(x == 0.0)
3977 .................... {
3978 .................... *exp=0;
3979 .................... return (0.0);
3980 .................... }
3981 .................... if(x < 0.0)
3982 .................... {
3983 .................... x=-x;
3984 .................... sign=1;
3985 .................... }
3986 .................... if (x > 1.0)
3987 .................... {
3988 .................... *exp=(ceil(log10(x)/LOG2));
3989 .................... res=x/(pow(2, *exp));
3990 .................... if (res == 1)
3991 .................... {
3992 .................... *exp=*exp+1;
3993 .................... res=.5;
3994 .................... }
3995 .................... }
3996 .................... else
3997 .................... {
3998 .................... if(x < 0.5)
3999 .................... {
4000 .................... *exp=-1;
4001 .................... res=x*2;
4002 .................... }
4003 .................... else
4004 .................... {
4005 .................... *exp=0;
4006 .................... res=x;
4007 .................... }
4008 .................... }
4009 .................... if(sign)
4010 .................... {
4011 .................... res=-res;
4012 .................... }
4013 .................... return res;
4014 .................... }
4015 ....................
4016 .................... // Overloaded function frexp() for data type - Float64
4017 .................... float64 frexp(float64 x, signed int8 *exp)
4018 .................... {
4019 .................... float64 res;
4020 .................... int1 sign = 0;
4021 .................... if(x == 0.0)
4022 .................... {
4023 .................... *exp=0;
4024 .................... return (0.0);
4025 .................... }
4026 .................... if(x < 0.0)
4027 .................... {
4028 .................... x=-x;
4029 .................... sign=1;
4030 .................... }
4031 .................... if (x > 1.0)
4032 .................... {
4033 .................... *exp=(ceil(log10(x)/LOG2));
4034 .................... res=x/(pow(2, *exp));
4035 .................... if (res == 1)
4036 .................... {
4037 .................... *exp=*exp+1;
4038 .................... res=.5;
4039 .................... }
4040 .................... }
4041 .................... else
4042 .................... {
4043 .................... if(x < 0.5)
4044 .................... {
4045 .................... *exp=-1;
4046 .................... res=x*2;
4047 .................... }
4048 .................... else
4049 .................... {
4050 .................... *exp=0;
4051 .................... res=x;
4052 .................... }
4053 .................... }
4054 .................... if(sign)
4055 .................... {
4056 .................... res=-res;
4057 .................... }
4058 .................... return res;
4059 .................... }
4060 .................... #endif
4061 ....................
4062 .................... //////////////////////////////////////////////////////////////////////////////
4063 .................... // float ldexp(float x, signed int *exp)
4064 .................... //////////////////////////////////////////////////////////////////////////////
4065 .................... // Description : multiplies a floating point number by an integral power of 2.
4066 .................... // Returns : returns the value of x times 2 raised to the power exp.
4067 .................... // Date : N/A
4068 .................... //
4069 ....................
4070 .................... float32 ldexp(float32 value, signed int8 exp)
4071 .................... {
4072 .................... return (value * pow(2,exp));
4073 .................... }
4074 .................... //Overloaded functions for ldexp() for PCD
4075 .................... // Overloaded function ldexp() for data type - Float48
4076 ....................
4077 .................... #if defined(__PCD__)
4078 .................... float48 ldexp(float48 value, signed int8 exp)
4079 .................... {
4080 .................... return (value * pow(2,exp));
4081 .................... }
4082 .................... // Overloaded function ldexp() for data type - Float64
4083 .................... float64 ldexp(float64 value, signed int8 exp)
4084 .................... {
4085 .................... return (value * pow(2,exp));
4086 .................... }
4087 .................... #endif
4088 ....................
4089 .................... #endif
4090 ....................
4091 ....................
4092 ....................
3275 kaklik 4093 .................... void main()
4094 .................... {
4095 *
3283 kakl 4096 0AB7: CLRF 04
4097 0AB8: BCF 03.7
4098 0AB9: MOVLW 1F
4099 0ABA: ANDWF 03,F
4100 0ABB: MOVLW 71
4101 0ABC: BSF 03.5
4102 0ABD: MOVWF 0F
4103 0ABE: MOVF 0F,W
4104 0ABF: BSF 03.6
4105 0AC0: BCF 07.3
4106 0AC1: MOVLW 0C
4107 0AC2: BCF 03.6
4108 0AC3: MOVWF 19
4109 0AC4: MOVLW A2
4110 0AC5: MOVWF 18
4111 0AC6: MOVLW 90
4112 0AC7: BCF 03.5
4113 0AC8: MOVWF 18
4114 0AC9: BSF 03.5
4115 0ACA: BSF 03.6
4116 0ACB: MOVF 09,W
4117 0ACC: ANDLW C0
4118 0ACD: MOVWF 09
4119 0ACE: BCF 03.6
4120 0ACF: BCF 1F.4
4121 0AD0: BCF 1F.5
4122 0AD1: MOVLW 00
4123 0AD2: BSF 03.6
4124 0AD3: MOVWF 08
4125 0AD4: BCF 03.5
4126 0AD5: CLRF 07
4127 0AD6: CLRF 08
4128 0AD7: CLRF 09
3275 kaklik 4129 *
3283 kakl 4130 0AE1: CLRF 34
4131 0AE2: CLRF 33
3275 kaklik 4132 .................... float temp1, temp2, humidity;
4133 .................... int16 i=0;
4134 ....................
4135 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
3283 kakl 4136 0AE3: BSF 03.5
4137 0AE4: BSF 03.6
4138 0AE5: MOVF 09,W
4139 0AE6: ANDLW C0
4140 0AE7: MOVWF 09
4141 0AE8: BCF 03.6
4142 0AE9: BCF 1F.4
4143 0AEA: BCF 1F.5
4144 0AEB: MOVLW 00
4145 0AEC: BSF 03.6
4146 0AED: MOVWF 08
3275 kaklik 4147 .................... setup_adc(ADC_CLOCK_DIV_2);
3283 kakl 4148 0AEE: BCF 03.5
4149 0AEF: BCF 03.6
4150 0AF0: BCF 1F.6
4151 0AF1: BCF 1F.7
4152 0AF2: BSF 03.5
4153 0AF3: BSF 1F.7
4154 0AF4: BCF 03.5
4155 0AF5: BSF 1F.0
3275 kaklik 4156 .................... setup_spi(SPI_SS_DISABLED);
3283 kakl 4157 0AF6: BCF 14.5
4158 0AF7: BCF 20.5
4159 0AF8: MOVF 20,W
4160 0AF9: BSF 03.5
4161 0AFA: MOVWF 07
4162 0AFB: BCF 03.5
4163 0AFC: BSF 20.4
4164 0AFD: MOVF 20,W
4165 0AFE: BSF 03.5
4166 0AFF: MOVWF 07
4167 0B00: BCF 03.5
4168 0B01: BCF 20.3
4169 0B02: MOVF 20,W
4170 0B03: BSF 03.5
4171 0B04: MOVWF 07
4172 0B05: MOVLW 01
4173 0B06: BCF 03.5
4174 0B07: MOVWF 14
4175 0B08: MOVLW 00
4176 0B09: BSF 03.5
4177 0B0A: MOVWF 14
3275 kaklik 4178 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
3283 kakl 4179 0B0B: MOVF 01,W
4180 0B0C: ANDLW C7
4181 0B0D: IORLW 08
4182 0B0E: MOVWF 01
3275 kaklik 4183 .................... setup_timer_1(T1_DISABLED);
3283 kakl 4184 0B0F: BCF 03.5
4185 0B10: CLRF 10
3275 kaklik 4186 .................... setup_timer_2(T2_DISABLED,0,1);
3283 kakl 4187 0B11: MOVLW 00
4188 0B12: MOVWF 78
4189 0B13: MOVWF 12
4190 0B14: MOVLW 00
4191 0B15: BSF 03.5
4192 0B16: MOVWF 12
3275 kaklik 4193 .................... setup_ccp1(CCP_OFF);
3283 kakl 4194 0B17: BCF 03.5
4195 0B18: BSF 20.2
4196 0B19: MOVF 20,W
4197 0B1A: BSF 03.5
4198 0B1B: MOVWF 07
4199 0B1C: BCF 03.5
4200 0B1D: CLRF 17
4201 0B1E: BSF 03.5
4202 0B1F: CLRF 1B
4203 0B20: CLRF 1C
4204 0B21: MOVLW 01
4205 0B22: MOVWF 1D
3275 kaklik 4206 .................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
3283 kakl 4207 0B23: BCF 03.5
4208 0B24: BSF 03.6
4209 0B25: CLRF 07
4210 0B26: CLRF 08
4211 0B27: CLRF 09
3275 kaklik 4212 .................... setup_oscillator(OSC_8MHZ);
3283 kakl 4213 0B28: MOVLW 71
4214 0B29: BSF 03.5
4215 0B2A: BCF 03.6
4216 0B2B: MOVWF 0F
4217 0B2C: MOVF 0F,W
3275 kaklik 4218 ....................
4219 ....................
3283 kakl 4220 .................... printf("GeoMet01A\r\n");
4221 0B2D: MOVLW 0C
4222 0B2E: BCF 03.5
4223 0B2F: BSF 03.6
4224 0B30: MOVWF 0D
4225 0B31: MOVLW 00
4226 0B32: MOVWF 0F
4227 0B33: BCF 0A.3
4228 0B34: BCF 03.6
4229 0B35: CALL 030
4230 0B36: BSF 0A.3
3275 kaklik 4231 .................... printf("(c) Kaklik 2013\r\n");
3283 kakl 4232 0B37: MOVLW 12
4233 0B38: BSF 03.6
4234 0B39: MOVWF 0D
4235 0B3A: MOVLW 00
4236 0B3B: MOVWF 0F
4237 0B3C: BCF 0A.3
4238 0B3D: BCF 03.6
4239 0B3E: CALL 030
4240 0B3F: BSF 0A.3
3275 kaklik 4241 .................... printf("www.mlab.cz\r\n");
3283 kakl 4242 0B40: MOVLW 1B
4243 0B41: BSF 03.6
4244 0B42: MOVWF 0D
4245 0B43: MOVLW 00
4246 0B44: MOVWF 0F
4247 0B45: BCF 0A.3
4248 0B46: BCF 03.6
4249 0B47: CALL 030
4250 0B48: BSF 0A.3
4251 ....................
4252 .................... // Init the HMC5883L. Set Mode register for
4253 .................... // continuous measurements.
4254 .................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range
4255 0B49: CLRF 35
4256 0B4A: MOVLW 18
4257 0B4B: MOVWF 36
4258 0B4C: BCF 0A.3
4259 0B4D: CALL 0C2
4260 0B4E: BSF 0A.3
4261 .................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range
4262 0B4F: MOVLW 01
4263 0B50: MOVWF 35
4264 0B51: CLRF 36
4265 0B52: BCF 0A.3
4266 0B53: CALL 0C2
4267 0B54: BSF 0A.3
4268 .................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00);
4269 0B55: MOVLW 02
4270 0B56: MOVWF 35
4271 0B57: CLRF 36
4272 0B58: BCF 0A.3
4273 0B59: CALL 0C2
4274 0B5A: BSF 0A.3
3275 kaklik 4275 ....................
4276 .................... lcd_init();
3283 kakl 4277 0B5B: BCF 0A.3
4278 0B5C: CALL 1C8
4279 0B5D: BSF 0A.3
3275 kaklik 4280 .................... lcd_putc("(c) Kaklik 2013");
3283 kakl 4281 0B5E: MOVLW 22
4282 0B5F: BSF 03.6
4283 0B60: MOVWF 0D
4284 0B61: MOVLW 00
4285 0B62: MOVWF 0F
4286 0B63: BCF 0A.3
4287 0B64: BCF 03.6
4288 0B65: CALL 23F
4289 0B66: BSF 0A.3
3275 kaklik 4290 .................... lcd_gotoxy(3,2);
3283 kakl 4291 0B67: MOVLW 03
4292 0B68: MOVWF 43
4293 0B69: MOVLW 02
4294 0B6A: MOVWF 44
4295 0B6B: BCF 0A.3
4296 0B6C: CALL 200
4297 0B6D: BSF 0A.3
3275 kaklik 4298 .................... lcd_putc("www.mlab.cz");
3283 kakl 4299 0B6E: MOVLW 2A
4300 0B6F: BSF 03.6
4301 0B70: MOVWF 0D
4302 0B71: MOVLW 00
4303 0B72: MOVWF 0F
4304 0B73: BCF 0A.3
4305 0B74: BCF 03.6
4306 0B75: CALL 23F
4307 0B76: BSF 0A.3
3275 kaklik 4308 .................... Delay_ms(2000);
3283 kakl 4309 0B77: MOVLW 08
4310 0B78: MOVWF 35
4311 0B79: MOVLW FA
4312 0B7A: MOVWF 43
4313 0B7B: BCF 0A.3
4314 0B7C: CALL 0FB
4315 0B7D: BSF 0A.3
4316 0B7E: DECFSZ 35,F
4317 0B7F: GOTO 379
3275 kaklik 4318 .................... lcd_init();
3283 kakl 4319 0B80: BCF 0A.3
4320 0B81: CALL 1C8
4321 0B82: BSF 0A.3
3275 kaklik 4322 ....................
4323 .................... while (TRUE)
4324 .................... {
4325 .................... lcd_gotoxy(1,1);
3283 kakl 4326 0B83: MOVLW 01
4327 0B84: MOVWF 43
4328 0B85: MOVWF 44
4329 0B86: BCF 0A.3
4330 0B87: CALL 200
4331 0B88: BSF 0A.3
3275 kaklik 4332 .................... temp1 = SHT25_get_temp();
3283 kakl 4333 0B89: BCF 0A.3
4334 0B8A: GOTO 567
4335 0B8B: BSF 0A.3
4336 0B8C: MOVF 7A,W
4337 0B8D: MOVWF 2A
4338 0B8E: MOVF 79,W
4339 0B8F: MOVWF 29
4340 0B90: MOVF 78,W
4341 0B91: MOVWF 28
4342 0B92: MOVF 77,W
4343 0B93: MOVWF 27
3275 kaklik 4344 .................... humidity = SHT25_get_hum();
3283 kakl 4345 0B94: BCF 0A.3
4346 0B95: GOTO 636
4347 0B96: BSF 0A.3
4348 0B97: MOVF 7A,W
3275 kaklik 4349 0B98: MOVWF 32
3283 kakl 4350 0B99: MOVF 79,W
3275 kaklik 4351 0B9A: MOVWF 31
3283 kakl 4352 0B9B: MOVF 78,W
3275 kaklik 4353 0B9C: MOVWF 30
3283 kakl 4354 0B9D: MOVF 77,W
3275 kaklik 4355 0B9E: MOVWF 2F
3283 kakl 4356 .................... temp2= LTS01_get_temp();
4357 0B9F: BCF 0A.3
4358 0BA0: GOTO 6EC
4359 0BA1: BSF 0A.3
4360 0BA2: MOVF 7A,W
4361 0BA3: MOVWF 2E
4362 0BA4: MOVF 79,W
4363 0BA5: MOVWF 2D
4364 0BA6: MOVF 78,W
4365 0BA7: MOVWF 2C
4366 0BA8: MOVF 77,W
4367 0BA9: MOVWF 2B
4368 .................... hmc5883l_read_data();
4369 0BAA: GOTO 000
4370 ....................
4371 .................... printf(lcd_putc,"%f C %f \%%",temp1, humidity);
4372 0BAB: MOVLW 89
4373 0BAC: MOVWF 04
4374 0BAD: MOVF 2A,W
4375 0BAE: MOVWF 38
4376 0BAF: MOVF 29,W
4377 0BB0: MOVWF 37
4378 0BB1: MOVF 28,W
4379 0BB2: MOVWF 36
4380 0BB3: MOVF 27,W
4381 0BB4: MOVWF 35
4382 0BB5: MOVLW 02
4383 0BB6: MOVWF 39
4384 0BB7: CALL 091
4385 0BB8: MOVLW 20
4386 0BB9: MOVWF 42
4387 0BBA: BCF 0A.3
4388 0BBB: CALL 212
4389 0BBC: BSF 0A.3
4390 0BBD: MOVLW 43
4391 0BBE: MOVWF 42
4392 0BBF: BCF 0A.3
4393 0BC0: CALL 212
4394 0BC1: BSF 0A.3
4395 0BC2: MOVLW 20
4396 0BC3: MOVWF 42
4397 0BC4: BCF 0A.3
4398 0BC5: CALL 212
4399 0BC6: BSF 0A.3
4400 0BC7: MOVLW 89
4401 0BC8: MOVWF 04
4402 0BC9: MOVF 32,W
4403 0BCA: MOVWF 38
4404 0BCB: MOVF 31,W
4405 0BCC: MOVWF 37
4406 0BCD: MOVF 30,W
4407 0BCE: MOVWF 36
4408 0BCF: MOVF 2F,W
4409 0BD0: MOVWF 35
4410 0BD1: MOVLW 02
4411 0BD2: MOVWF 39
4412 0BD3: CALL 091
4413 0BD4: MOVLW 20
4414 0BD5: MOVWF 42
4415 0BD6: BCF 0A.3
4416 0BD7: CALL 212
4417 0BD8: BSF 0A.3
4418 0BD9: MOVLW 25
4419 0BDA: MOVWF 42
4420 0BDB: BCF 0A.3
4421 0BDC: CALL 212
4422 0BDD: BSF 0A.3
4423 .................... lcd_gotoxy(1,2);
4424 0BDE: MOVLW 01
4425 0BDF: MOVWF 43
4426 0BE0: MOVLW 02
4427 0BE1: MOVWF 44
4428 0BE2: BCF 0A.3
4429 0BE3: CALL 200
4430 0BE4: BSF 0A.3
4431 .................... printf(lcd_putc," %f C",temp2);
4432 0BE5: MOVLW 20
4433 0BE6: MOVWF 42
4434 0BE7: BCF 0A.3
4435 0BE8: CALL 212
4436 0BE9: BSF 0A.3
4437 0BEA: MOVLW 89
4438 0BEB: MOVWF 04
4439 0BEC: MOVF 2E,W
4440 0BED: MOVWF 38
4441 0BEE: MOVF 2D,W
4442 0BEF: MOVWF 37
4443 0BF0: MOVF 2C,W
4444 0BF1: MOVWF 36
4445 0BF2: MOVF 2B,W
4446 0BF3: MOVWF 35
4447 0BF4: MOVLW 02
4448 0BF5: MOVWF 39
4449 0BF6: CALL 091
4450 0BF7: MOVLW 20
4451 0BF8: MOVWF 42
4452 0BF9: BCF 0A.3
4453 0BFA: CALL 212
4454 0BFB: BSF 0A.3
4455 0BFC: MOVLW 43
4456 0BFD: MOVWF 42
4457 0BFE: BCF 0A.3
4458 0BFF: CALL 212
4459 0C00: BSF 0A.3
4460 .................... printf("%ld %f %f %f ",i, temp1, humidity, temp2);
4461 0C01: MOVLW 10
4462 0C02: MOVWF 04
4463 0C03: MOVF 34,W
4464 0C04: MOVWF 36
4465 0C05: MOVF 33,W
4466 0C06: MOVWF 35
4467 0C07: CALL 16B
4468 0C08: MOVLW 20
4469 0C09: BTFSS 0C.4
4470 0C0A: GOTO 409
4471 0C0B: MOVWF 19
4472 0C0C: MOVLW 89
4473 0C0D: MOVWF 04
4474 0C0E: MOVF 2A,W
4475 0C0F: MOVWF 38
4476 0C10: MOVF 29,W
4477 0C11: MOVWF 37
4478 0C12: MOVF 28,W
4479 0C13: MOVWF 36
4480 0C14: MOVF 27,W
4481 0C15: MOVWF 35
4482 0C16: MOVLW 02
4483 0C17: MOVWF 39
4484 0C18: CALL 1E1
4485 0C19: MOVLW 20
4486 0C1A: BTFSS 0C.4
4487 0C1B: GOTO 41A
4488 0C1C: MOVWF 19
4489 0C1D: MOVLW 89
4490 0C1E: MOVWF 04
4491 0C1F: MOVF 32,W
4492 0C20: MOVWF 38
4493 0C21: MOVF 31,W
4494 0C22: MOVWF 37
4495 0C23: MOVF 30,W
4496 0C24: MOVWF 36
4497 0C25: MOVF 2F,W
4498 0C26: MOVWF 35
4499 0C27: MOVLW 02
4500 0C28: MOVWF 39
4501 0C29: CALL 1E1
4502 0C2A: MOVLW 20
4503 0C2B: BTFSS 0C.4
4504 0C2C: GOTO 42B
4505 0C2D: MOVWF 19
4506 0C2E: MOVLW 89
4507 0C2F: MOVWF 04
4508 0C30: MOVF 2E,W
4509 0C31: MOVWF 38
4510 0C32: MOVF 2D,W
4511 0C33: MOVWF 37
4512 0C34: MOVF 2C,W
4513 0C35: MOVWF 36
4514 0C36: MOVF 2B,W
4515 0C37: MOVWF 35
4516 0C38: MOVLW 02
4517 0C39: MOVWF 39
4518 0C3A: CALL 1E1
4519 0C3B: MOVLW 20
4520 0C3C: BTFSS 0C.4
4521 0C3D: GOTO 43C
4522 0C3E: MOVWF 19
4523 .................... printf("%Ld %Ld %Ld \n\r", compass.x, compass.y, compass.z);
4524 0C3F: MOVLW 10
4525 0C40: MOVWF 04
4526 0C41: MOVF 22,W
4527 0C42: MOVWF 36
4528 0C43: MOVF 21,W
4529 0C44: MOVWF 35
4530 0C45: CALL 16B
4531 0C46: MOVLW 20
4532 0C47: BTFSS 0C.4
4533 0C48: GOTO 447
4534 0C49: MOVWF 19
4535 0C4A: MOVLW 10
4536 0C4B: MOVWF 04
4537 0C4C: MOVF 24,W
4538 0C4D: MOVWF 36
4539 0C4E: MOVF 23,W
4540 0C4F: MOVWF 35
4541 0C50: CALL 16B
4542 0C51: MOVLW 20
4543 0C52: BTFSS 0C.4
4544 0C53: GOTO 452
4545 0C54: MOVWF 19
4546 0C55: MOVLW 10
4547 0C56: MOVWF 04
4548 0C57: MOVF 26,W
4549 0C58: MOVWF 36
4550 0C59: MOVF 25,W
4551 0C5A: MOVWF 35
4552 0C5B: CALL 16B
4553 0C5C: MOVLW 20
4554 0C5D: BTFSS 0C.4
4555 0C5E: GOTO 45D
4556 0C5F: MOVWF 19
4557 0C60: MOVLW 0A
4558 0C61: BTFSS 0C.4
4559 0C62: GOTO 461
4560 0C63: MOVWF 19
4561 0C64: MOVLW 0D
4562 0C65: BTFSS 0C.4
4563 0C66: GOTO 465
4564 0C67: MOVWF 19
3275 kaklik 4565 .................... i++;
3283 kakl 4566 0C68: INCF 33,F
4567 0C69: BTFSC 03.2
4568 0C6A: INCF 34,F
3275 kaklik 4569 .................... Delay_ms(100);
3283 kakl 4570 0C6B: MOVLW 64
4571 0C6C: MOVWF 43
4572 0C6D: BCF 0A.3
4573 0C6E: CALL 0FB
4574 0C6F: BSF 0A.3
3275 kaklik 4575 .................... }
3283 kakl 4576 0C70: GOTO 383
3275 kaklik 4577 ....................
4578 .................... }
3283 kakl 4579 0C71: SLEEP
3275 kaklik 4580  
4581 Configuration Fuses:
4582 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
4583 Word 2: 3FFF NOWRT BORV40