CCS PCM C Compiler, Version 4.106, 47914 06-X-13 22:07
Filename: Z:\home\kaklik\svnMLAB\Designs\Measuring_instruments\GM_counter\SW\PIC16F887\main.lst
ROM used: 3009 words (37%)
Largest free fragment is 2048
RAM used: 37 (10%) at main() level
56 (15%) worst case
Stack: 6 worst case (5 in main + 1 for interrupts)
*
0000: MOVLW 08
0001: MOVWF 0A
0002: GOTO 000
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 0A,W
0009: MOVWF 20
000A: CLRF 0A
000B: MOVF 04,W
000C: MOVWF 22
000D: MOVF 77,W
000E: MOVWF 23
000F: MOVF 78,W
0010: MOVWF 24
0011: MOVF 79,W
0012: MOVWF 25
0013: MOVF 7A,W
0014: MOVWF 26
0015: BCF 03.7
0016: BCF 03.5
0017: BTFSS 0B.5
0018: GOTO 01B
0019: BTFSC 0B.2
001A: GOTO 032
001B: MOVLW 8C
001C: MOVWF 04
001D: BTFSS 00.0
001E: GOTO 021
001F: BTFSC 0C.0
0020: GOTO 035
0021: MOVF 22,W
0022: MOVWF 04
0023: MOVF 23,W
0024: MOVWF 77
0025: MOVF 24,W
0026: MOVWF 78
0027: MOVF 25,W
0028: MOVWF 79
0029: MOVF 26,W
002A: MOVWF 7A
002B: MOVF 20,W
002C: MOVWF 0A
002D: SWAPF 21,W
002E: MOVWF 03
002F: SWAPF 7F,F
0030: SWAPF 7F,W
0031: RETFIE
0032: BCF 0A.3
0033: BCF 0A.4
0034: GOTO 040
0035: BCF 0A.3
0036: BCF 0A.4
0037: GOTO 047
.................... #include ".\main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
.................... #device PIC16F887
.................... #list
....................
.................... #device adc=10
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC //Internal RC Osc
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES IESO //Internal External Switch Over mode enabled
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES BORV40 //Brownout reset at 4.0V
....................
.................... #use delay(clock=8000000)
*
00A4: MOVLW 47
00A5: MOVWF 04
00A6: BCF 03.7
00A7: MOVF 00,W
00A8: BTFSC 03.2
00A9: GOTO 0B7
00AA: MOVLW 02
00AB: MOVWF 78
00AC: CLRF 77
00AD: DECFSZ 77,F
00AE: GOTO 0AD
00AF: DECFSZ 78,F
00B0: GOTO 0AC
00B1: MOVLW 97
00B2: MOVWF 77
00B3: DECFSZ 77,F
00B4: GOTO 0B3
00B5: DECFSZ 00,F
00B6: GOTO 0AA
00B7: RETURN
*
0643: MOVLW 08
0644: SUBWF 41,F
0645: BTFSS 03.0
0646: GOTO 653
0647: MOVLW 41
0648: MOVWF 04
0649: BCF 03.7
064A: BCF 03.0
064B: RRF 00,F
064C: MOVF 00,W
064D: BTFSC 03.2
064E: GOTO 653
064F: GOTO 651
0650: NOP
0651: DECFSZ 00,F
0652: GOTO 650
0653: RETURN
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8)
*
0230: BSF 03.5
0231: BCF 06.7
0232: BCF 03.5
0233: BCF 06.7
0234: MOVLW 08
0235: MOVWF 78
0236: GOTO 237
0237: NOP
0238: BSF 78.7
0239: GOTO 248
023A: BCF 78.7
023B: RRF 46,F
023C: BTFSC 03.0
023D: BSF 06.7
023E: BTFSS 03.0
023F: BCF 06.7
0240: BSF 78.6
0241: GOTO 248
0242: BCF 78.6
0243: DECFSZ 78,F
0244: GOTO 23B
0245: GOTO 246
0246: NOP
0247: BSF 06.7
0248: MOVLW 3F
0249: MOVWF 04
024A: DECFSZ 04,F
024B: GOTO 24A
024C: NOP
024D: BTFSC 78.7
024E: GOTO 23A
024F: BTFSC 78.6
0250: GOTO 242
0251: RETURN
....................
....................
....................
.................... #define LED1 PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
.................... #define LED2 PIN_C5 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
.................... #define LED3 PIN_C4 // pulse detect
.................... #define LED4 PIN_D3 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
....................
.................... #define S1 PIN_C2 // raw up
.................... #define S2 PIN_C3 // raw down
.................... #define S3 PIN_D0 // fine up
.................... #define S4 PIN_D1 // fine down
.................... #define S5 PIN_B1 // time setup
.................... #define S6 PIN_B2 // treshold setup
....................
.................... #define BEEP PIN_D2 //piezo beeper
....................
.................... #define LCD_ENABLE_PIN PIN_E0 ////
.................... #define LCD_RS_PIN PIN_E1 ////
.................... #define LCD_RW_PIN PIN_E2 ////
.................... #define LCD_DATA4 PIN_D4 ////
.................... #define LCD_DATA5 PIN_D5 ////
.................... #define LCD_DATA6 PIN_D6 ////
.................... #define LCD_DATA7 PIN_D7
.................... #include <lcd.c>
.................... ///////////////////////////////////////////////////////////////////////////////
.................... //// LCD.C ////
.................... //// Driver for common LCD modules ////
.................... //// ////
.................... //// lcd_init() Must be called before any other function. ////
.................... //// ////
.................... //// lcd_putc(c) Will display c on the next position of the LCD. ////
.................... //// \a Set cursor position to upper left ////
.................... //// \f Clear display, set cursor to upper left ////
.................... //// \n Go to start of second line ////
.................... //// \b Move back one position ////
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character ////
.................... //// will erase all remanining characters on the current ////
.................... //// line, and move the cursor to the beginning of the next ////
.................... //// line. ////
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character ////
.................... //// will move the cursor to the start of the current ////
.................... //// line. ////
.................... //// ////
.................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
.................... //// ////
.................... //// lcd_getc(x,y) Returns character at position x,y on LCD ////
.................... //// ////
.................... //// CONFIGURATION ////
.................... //// The LCD can be configured in one of two ways: a.) port access or ////
.................... //// b.) pin access. Port access requires the entire 7 bit interface ////
.................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) ////
.................... //// connected to sequential pins on the GPIO. Pin access ////
.................... //// has no requirements, all 7 bits of the control interface can ////
.................... //// can be connected to any GPIO using several ports. ////
.................... //// ////
.................... //// To use port access, #define LCD_DATA_PORT to the SFR location of ////
.................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////
.................... //// of this file to configure the pin order. If you are using a ////
.................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////
.................... //// be defined. ////
.................... //// ////
.................... //// Example of port access: ////
.................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") ////
.................... //// ////
.................... //// To use pin access, the following pins must be defined: ////
.................... //// LCD_ENABLE_PIN ////
.................... //// LCD_RS_PIN ////
.................... //// LCD_RW_PIN ////
.................... //// LCD_DATA4 ////
.................... //// LCD_DATA5 ////
.................... //// LCD_DATA6 ////
.................... //// LCD_DATA7 ////
.................... //// ////
.................... //// Example of pin access: ////
.................... //// #define LCD_ENABLE_PIN PIN_E0 ////
.................... //// #define LCD_RS_PIN PIN_E1 ////
.................... //// #define LCD_RW_PIN PIN_E2 ////
.................... //// #define LCD_DATA4 PIN_D4 ////
.................... //// #define LCD_DATA5 PIN_D5 ////
.................... //// #define LCD_DATA6 PIN_D6 ////
.................... //// #define LCD_DATA7 PIN_D7 ////
.................... //// ////
.................... ///////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2010 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
....................
.................... // define the pinout.
.................... // only required if port access is being used.
.................... typedef struct
.................... { // This structure is overlayed
.................... BOOLEAN enable; // on to an I/O port to gain
.................... BOOLEAN rs; // access to the LCD pins.
.................... BOOLEAN rw; // The bits are allocated from
.................... BOOLEAN unused; // low order up. ENABLE will
.................... int data : 4; // be LSB pin of that port.
.................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT.
.................... int reserved: 8;
.................... #endif
.................... } LCD_PIN_MAP;
....................
.................... // this is to improve compatability with previous LCD drivers that accepted
.................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
.................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
.................... #define LCD_DATA_PORT getenv("SFR:PORTB")
.................... #endif
....................
.................... #if defined(__PCB__)
.................... // these definitions only need to be modified for baseline PICs.
.................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
.................... /* EN, RS, RW, UNUSED, DATA */
.................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0};
.................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF};
.................... #endif
....................
.................... ////////////////////// END CONFIGURATION ///////////////////////////////////
....................
.................... #ifndef LCD_ENABLE_PIN
.................... #define lcd_output_enable(x) lcdlat.enable=x
.................... #define lcd_enable_tris() lcdtris.enable=0
.................... #else
.................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
.................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN)
.................... #endif
....................
.................... #ifndef LCD_RS_PIN
.................... #define lcd_output_rs(x) lcdlat.rs=x
.................... #define lcd_rs_tris() lcdtris.rs=0
.................... #else
.................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
.................... #define lcd_rs_tris() output_drive(LCD_RS_PIN)
.................... #endif
....................
.................... #ifndef LCD_RW_PIN
.................... #define lcd_output_rw(x) lcdlat.rw=x
.................... #define lcd_rw_tris() lcdtris.rw=0
.................... #else
.................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
.................... #define lcd_rw_tris() output_drive(LCD_RW_PIN)
.................... #endif
....................
.................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
.................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver
.................... // compatible with any code written for the original library
.................... #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
.................... #define LCD_DATA4 LCD_DATA0
.................... #define LCD_DATA5 LCD_DATA1
.................... #define LCD_DATA6 LCD_DATA2
.................... #define LCD_DATA7 LCD_DATA3
.................... #endif
....................
.................... #ifndef LCD_DATA4
.................... #ifndef LCD_DATA_PORT
.................... #if defined(__PCB__)
.................... #define LCD_DATA_PORT 0x06 //portb
.................... #define set_tris_lcd(x) set_tris_b(x)
.................... #else
.................... #if defined(PIN_D0)
.................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd
.................... #else
.................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb
.................... #endif
.................... #endif
.................... #endif
....................
.................... #if defined(__PCB__)
.................... LCD_PIN_MAP lcd, lcdlat;
.................... #byte lcd = LCD_DATA_PORT
.................... #byte lcdlat = LCD_DATA_PORT
.................... #elif defined(__PCM__)
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
.................... #byte lcd = LCD_DATA_PORT
.................... #byte lcdlat = LCD_DATA_PORT
.................... #byte lcdtris = LCD_DATA_PORT+0x80
.................... #elif defined(__PCH__)
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
.................... #byte lcd = LCD_DATA_PORT
.................... #byte lcdlat = LCD_DATA_PORT+9
.................... #byte lcdtris = LCD_DATA_PORT+0x12
.................... #elif defined(__PCD__)
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
.................... #word lcd = LCD_DATA_PORT
.................... #word lcdlat = LCD_DATA_PORT+2
.................... #word lcdtris = LCD_DATA_PORT-0x02
.................... #endif
.................... #endif //LCD_DATA4 not defined
....................
.................... #ifndef LCD_TYPE
.................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines
.................... #endif
....................
.................... #ifndef LCD_LINE_TWO
.................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line
.................... #endif
....................
.................... #ifndef LCD_LINE_LENGTH
.................... #define LCD_LINE_LENGTH 20
.................... #endif
....................
.................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
.................... // These bytes need to be sent to the LCD
.................... // to start it up.
....................
.................... BYTE lcd_read_nibble(void);
....................
.................... BYTE lcd_read_byte(void)
.................... {
.................... BYTE low,high;
....................
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_INPUT_MAP);
.................... #else
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... output_float(LCD_DATA4);
*
011D: BSF 08.4
.................... output_float(LCD_DATA5);
011E: BSF 08.5
.................... output_float(LCD_DATA6);
011F: BSF 08.6
.................... output_float(LCD_DATA7);
0120: BSF 08.7
.................... #else
.................... lcdtris.data = 0xF;
.................... #endif
.................... #endif
....................
.................... lcd_output_rw(1);
0121: BCF 03.5
0122: BSF 09.2
0123: BSF 03.5
0124: BCF 09.2
.................... delay_cycles(1);
0125: NOP
.................... lcd_output_enable(1);
0126: BCF 03.5
0127: BSF 09.0
0128: BSF 03.5
0129: BCF 09.0
.................... delay_cycles(1);
012A: NOP
.................... high = lcd_read_nibble();
012B: BCF 03.5
012C: CALL 0E4
012D: MOVF 78,W
012E: MOVWF 4E
....................
.................... lcd_output_enable(0);
012F: BCF 09.0
0130: BSF 03.5
0131: BCF 09.0
.................... delay_cycles(1);
0132: NOP
.................... lcd_output_enable(1);
0133: BCF 03.5
0134: BSF 09.0
0135: BSF 03.5
0136: BCF 09.0
.................... delay_us(1);
0137: GOTO 138
.................... low = lcd_read_nibble();
0138: BCF 03.5
0139: CALL 0E4
013A: MOVF 78,W
013B: MOVWF 4D
....................
.................... lcd_output_enable(0);
013C: BCF 09.0
013D: BSF 03.5
013E: BCF 09.0
....................
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_OUTPUT_MAP);
.................... #else
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... output_drive(LCD_DATA4);
013F: BCF 08.4
.................... output_drive(LCD_DATA5);
0140: BCF 08.5
.................... output_drive(LCD_DATA6);
0141: BCF 08.6
.................... output_drive(LCD_DATA7);
0142: BCF 08.7
.................... #else
.................... lcdtris.data = 0x0;
.................... #endif
.................... #endif
....................
.................... return( (high<<4) | low);
0143: BCF 03.5
0144: SWAPF 4E,W
0145: MOVWF 77
0146: MOVLW F0
0147: ANDWF 77,F
0148: MOVF 77,W
0149: IORWF 4D,W
014A: MOVWF 78
.................... }
....................
.................... BYTE lcd_read_nibble(void)
.................... {
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
*
00E4: CLRF 4F
.................... BYTE n = 0x00;
....................
.................... /* Read the data port */
.................... n |= input(LCD_DATA4);
00E5: BSF 03.5
00E6: BSF 08.4
00E7: MOVLW 00
00E8: BCF 03.5
00E9: BTFSC 08.4
00EA: MOVLW 01
00EB: IORWF 4F,F
.................... n |= input(LCD_DATA5) << 1;
00EC: BSF 03.5
00ED: BSF 08.5
00EE: MOVLW 00
00EF: BCF 03.5
00F0: BTFSC 08.5
00F1: MOVLW 01
00F2: MOVWF 77
00F3: BCF 03.0
00F4: RLF 77,F
00F5: MOVF 77,W
00F6: IORWF 4F,F
.................... n |= input(LCD_DATA6) << 2;
00F7: BSF 03.5
00F8: BSF 08.6
00F9: MOVLW 00
00FA: BCF 03.5
00FB: BTFSC 08.6
00FC: MOVLW 01
00FD: MOVWF 77
00FE: RLF 77,F
00FF: RLF 77,F
0100: MOVLW FC
0101: ANDWF 77,F
0102: MOVF 77,W
0103: IORWF 4F,F
.................... n |= input(LCD_DATA7) << 3;
0104: BSF 03.5
0105: BSF 08.7
0106: MOVLW 00
0107: BCF 03.5
0108: BTFSC 08.7
0109: MOVLW 01
010A: MOVWF 77
010B: RLF 77,F
010C: RLF 77,F
010D: RLF 77,F
010E: MOVLW F8
010F: ANDWF 77,F
0110: MOVF 77,W
0111: IORWF 4F,F
....................
.................... return(n);
0112: MOVF 4F,W
0113: MOVWF 78
.................... #else
.................... return(lcd.data);
.................... #endif
.................... }
0114: RETURN
....................
.................... void lcd_send_nibble(BYTE n)
.................... {
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... /* Write to the data port */
.................... output_bit(LCD_DATA4, bit_test(n, 0));
*
00B8: BTFSC 4E.0
00B9: GOTO 0BC
00BA: BCF 08.4
00BB: GOTO 0BD
00BC: BSF 08.4
00BD: BSF 03.5
00BE: BCF 08.4
.................... output_bit(LCD_DATA5, bit_test(n, 1));
00BF: BCF 03.5
00C0: BTFSC 4E.1
00C1: GOTO 0C4
00C2: BCF 08.5
00C3: GOTO 0C5
00C4: BSF 08.5
00C5: BSF 03.5
00C6: BCF 08.5
.................... output_bit(LCD_DATA6, bit_test(n, 2));
00C7: BCF 03.5
00C8: BTFSC 4E.2
00C9: GOTO 0CC
00CA: BCF 08.6
00CB: GOTO 0CD
00CC: BSF 08.6
00CD: BSF 03.5
00CE: BCF 08.6
.................... output_bit(LCD_DATA7, bit_test(n, 3));
00CF: BCF 03.5
00D0: BTFSC 4E.3
00D1: GOTO 0D4
00D2: BCF 08.7
00D3: GOTO 0D5
00D4: BSF 08.7
00D5: BSF 03.5
00D6: BCF 08.7
.................... #else
.................... lcdlat.data = n;
.................... #endif
....................
.................... delay_cycles(1);
00D7: NOP
.................... lcd_output_enable(1);
00D8: BCF 03.5
00D9: BSF 09.0
00DA: BSF 03.5
00DB: BCF 09.0
.................... delay_us(2);
00DC: GOTO 0DD
00DD: GOTO 0DE
.................... lcd_output_enable(0);
00DE: BCF 03.5
00DF: BCF 09.0
00E0: BSF 03.5
00E1: BCF 09.0
.................... }
00E2: BCF 03.5
00E3: RETURN
....................
.................... void lcd_send_byte(BYTE address, BYTE n)
.................... {
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_OUTPUT_MAP);
.................... #else
.................... lcd_enable_tris();
*
0115: BSF 03.5
0116: BCF 09.0
.................... lcd_rs_tris();
0117: BCF 09.1
.................... lcd_rw_tris();
0118: BCF 09.2
.................... #endif
....................
.................... lcd_output_rs(0);
0119: BCF 03.5
011A: BCF 09.1
011B: BSF 03.5
011C: BCF 09.1
.................... while ( bit_test(lcd_read_byte(),7) ) ;
*
014B: MOVF 78,W
014C: MOVWF 4D
014D: BTFSS 4D.7
014E: GOTO 151
014F: BSF 03.5
0150: GOTO 11D
.................... lcd_output_rs(address);
0151: MOVF 4B,F
0152: BTFSS 03.2
0153: GOTO 156
0154: BCF 09.1
0155: GOTO 157
0156: BSF 09.1
0157: BSF 03.5
0158: BCF 09.1
.................... delay_cycles(1);
0159: NOP
.................... lcd_output_rw(0);
015A: BCF 03.5
015B: BCF 09.2
015C: BSF 03.5
015D: BCF 09.2
.................... delay_cycles(1);
015E: NOP
.................... lcd_output_enable(0);
015F: BCF 03.5
0160: BCF 09.0
0161: BSF 03.5
0162: BCF 09.0
.................... lcd_send_nibble(n >> 4);
0163: BCF 03.5
0164: SWAPF 4C,W
0165: MOVWF 4D
0166: MOVLW 0F
0167: ANDWF 4D,F
0168: MOVF 4D,W
0169: MOVWF 4E
016A: CALL 0B8
.................... lcd_send_nibble(n & 0xf);
016B: MOVF 4C,W
016C: ANDLW 0F
016D: MOVWF 4D
016E: MOVWF 4E
016F: CALL 0B8
.................... }
0170: RETURN
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... unsigned int8 g_LcdX, g_LcdY;
.................... #endif
....................
.................... void lcd_init(void)
.................... {
.................... BYTE i;
....................
.................... #if defined(__PCB__)
.................... set_tris_lcd(LCD_OUTPUT_MAP);
.................... #else
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
.................... output_drive(LCD_DATA4);
0171: BSF 03.5
0172: BCF 08.4
.................... output_drive(LCD_DATA5);
0173: BCF 08.5
.................... output_drive(LCD_DATA6);
0174: BCF 08.6
.................... output_drive(LCD_DATA7);
0175: BCF 08.7
.................... #else
.................... lcdtris.data = 0x0;
.................... #endif
.................... lcd_enable_tris();
0176: BCF 09.0
.................... lcd_rs_tris();
0177: BCF 09.1
.................... lcd_rw_tris();
0178: BCF 09.2
.................... #endif
....................
.................... lcd_output_rs(0);
0179: BCF 03.5
017A: BCF 09.1
017B: BSF 03.5
017C: BCF 09.1
.................... lcd_output_rw(0);
017D: BCF 03.5
017E: BCF 09.2
017F: BSF 03.5
0180: BCF 09.2
.................... lcd_output_enable(0);
0181: BCF 03.5
0182: BCF 09.0
0183: BSF 03.5
0184: BCF 09.0
....................
.................... delay_ms(15);
0185: MOVLW 0F
0186: BCF 03.5
0187: MOVWF 47
0188: CALL 0A4
.................... for(i=1;i<=3;++i)
0189: MOVLW 01
018A: MOVWF 3A
018B: MOVF 3A,W
018C: SUBLW 03
018D: BTFSS 03.0
018E: GOTO 197
.................... {
.................... lcd_send_nibble(3);
018F: MOVLW 03
0190: MOVWF 4E
0191: CALL 0B8
.................... delay_ms(5);
0192: MOVLW 05
0193: MOVWF 47
0194: CALL 0A4
.................... }
0195: INCF 3A,F
0196: GOTO 18B
....................
.................... lcd_send_nibble(2);
0197: MOVLW 02
0198: MOVWF 4E
0199: CALL 0B8
.................... for(i=0;i<=3;++i)
019A: CLRF 3A
019B: MOVF 3A,W
019C: SUBLW 03
019D: BTFSS 03.0
019E: GOTO 1A8
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
019F: MOVF 3A,W
01A0: CALL 038
01A1: MOVWF 3B
01A2: CLRF 4B
01A3: MOVF 3B,W
01A4: MOVWF 4C
01A5: CALL 115
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
01A6: INCF 3A,F
01A7: GOTO 19B
.................... g_LcdX = 0;
.................... g_LcdY = 0;
.................... #endif
.................... }
01A8: BSF 0A.3
01A9: BCF 0A.4
01AA: GOTO 0BA (RETURN)
....................
.................... void lcd_gotoxy(BYTE x, BYTE y)
.................... {
.................... BYTE address;
....................
.................... if(y!=1)
01AB: DECFSZ 48,W
01AC: GOTO 1AE
01AD: GOTO 1B1
.................... address=LCD_LINE_TWO;
01AE: MOVLW 40
01AF: MOVWF 49
.................... else
01B0: GOTO 1B2
.................... address=0;
01B1: CLRF 49
....................
.................... address+=x-1;
01B2: MOVLW 01
01B3: SUBWF 47,W
01B4: ADDWF 49,F
.................... lcd_send_byte(0,0x80|address);
01B5: MOVF 49,W
01B6: IORLW 80
01B7: MOVWF 4A
01B8: CLRF 4B
01B9: MOVF 4A,W
01BA: MOVWF 4C
01BB: CALL 115
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... g_LcdX = x - 1;
.................... g_LcdY = y - 1;
.................... #endif
.................... }
01BC: RETURN
....................
.................... void lcd_putc(char c)
.................... {
.................... switch (c)
.................... {
01BD: MOVF 46,W
01BE: XORLW 07
01BF: BTFSC 03.2
01C0: GOTO 1CB
01C1: XORLW 0B
01C2: BTFSC 03.2
01C3: GOTO 1D0
01C4: XORLW 06
01C5: BTFSC 03.2
01C6: GOTO 1D8
01C7: XORLW 02
01C8: BTFSC 03.2
01C9: GOTO 1DE
01CA: GOTO 1E3
.................... case '\a' : lcd_gotoxy(1,1); break;
01CB: MOVLW 01
01CC: MOVWF 47
01CD: MOVWF 48
01CE: CALL 1AB
01CF: GOTO 1E9
....................
.................... case '\f' : lcd_send_byte(0,1);
01D0: CLRF 4B
01D1: MOVLW 01
01D2: MOVWF 4C
01D3: CALL 115
.................... delay_ms(2);
01D4: MOVLW 02
01D5: MOVWF 47
01D6: CALL 0A4
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... g_LcdX = 0;
.................... g_LcdY = 0;
.................... #endif
.................... break;
01D7: GOTO 1E9
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break;
.................... case '\n' :
.................... while (g_LcdX++ < LCD_LINE_LENGTH)
.................... {
.................... lcd_send_byte(1, ' ');
.................... }
.................... lcd_gotoxy(1, g_LcdY+2);
.................... break;
.................... #else
.................... case '\n' : lcd_gotoxy(1,2); break;
01D8: MOVLW 01
01D9: MOVWF 47
01DA: MOVLW 02
01DB: MOVWF 48
01DC: CALL 1AB
01DD: GOTO 1E9
.................... #endif
....................
.................... case '\b' : lcd_send_byte(0,0x10); break;
01DE: CLRF 4B
01DF: MOVLW 10
01E0: MOVWF 4C
01E1: CALL 115
01E2: GOTO 1E9
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... default :
.................... if (g_LcdX < LCD_LINE_LENGTH)
.................... {
.................... lcd_send_byte(1, c);
.................... g_LcdX++;
.................... }
.................... break;
.................... #else
.................... default : lcd_send_byte(1,c); break;
01E3: MOVLW 01
01E4: MOVWF 4B
01E5: MOVF 46,W
01E6: MOVWF 4C
01E7: CALL 115
01E8: GOTO 1E9
.................... #endif
.................... }
.................... }
01E9: RETURN
....................
.................... char lcd_getc(BYTE x, BYTE y)
.................... {
.................... char value;
....................
.................... lcd_gotoxy(x,y);
.................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
.................... lcd_output_rs(1);
.................... value = lcd_read_byte();
.................... lcd_output_rs(0);
....................
.................... return(value);
.................... }
....................
....................
....................
.................... unsigned int32 pulse_count=0;
.................... unsigned int16 overflow_count=0;
.................... unsigned int16 time_overflow_count=0;
....................
....................
.................... #int_RTCC
.................... void RTCC_isr(void)
.................... {
.................... time_overflow_count++;
*
0040: INCF 2D,F
0041: BTFSC 03.2
0042: INCF 2E,F
.................... }
....................
0043: BCF 0B.2
0044: BCF 0A.3
0045: BCF 0A.4
0046: GOTO 021
.................... #int_TIMER1
.................... void TIMER1_isr(void)
.................... {
.................... overflow_count++;
0047: INCF 2B,F
0048: BTFSC 03.2
0049: INCF 2C,F
.................... output_toggle(LED3);
004A: BCF 2F.4
004B: MOVF 2F,W
004C: BSF 03.5
004D: MOVWF 07
004E: MOVLW 10
004F: BCF 03.5
0050: XORWF 07,F
.................... output_toggle(BEEP);
0051: BSF 03.5
0052: BCF 08.2
0053: MOVLW 04
0054: BCF 03.5
0055: XORWF 08,F
.................... }
....................
0056: BCF 0C.0
0057: BCF 0A.3
0058: BCF 0A.4
0059: GOTO 021
.................... void sound_beep( unsigned int lenght, int16 frequency)
.................... {
.................... unsigned int i;
....................
.................... for(i=0;i<=lenght;i++)
*
0654: CLRF 3D
0655: MOVF 3D,W
0656: SUBWF 3A,W
0657: BTFSS 03.0
0658: GOTO 69C
.................... {
.................... output_toggle(BEEP);
0659: BSF 03.5
065A: BCF 08.2
065B: MOVLW 04
065C: BCF 03.5
065D: XORWF 08,F
.................... delay_us(1/frequency);
065E: CLRF 3F
065F: MOVLW 01
0660: MOVWF 3E
0661: MOVF 3C,W
0662: MOVWF 41
0663: MOVF 3B,W
0664: MOVWF 40
*
0689: MOVF 79,W
068A: MOVWF 3F
068B: MOVF 78,W
068C: MOVWF 3E
068D: MOVF 3F,W
068E: MOVWF 40
068F: INCF 40,F
0690: DECF 40,F
0691: BTFSC 03.2
0692: GOTO 697
0693: MOVLW FF
0694: MOVWF 41
0695: CALL 643
0696: GOTO 690
0697: MOVF 3E,W
0698: MOVWF 41
0699: CALL 643
.................... }
069A: INCF 3D,F
069B: GOTO 655
.................... }
069C: RETURN
....................
.................... #define TRESHOLD_setup 1
.................... #define INTERVAL_setup 0
....................
....................
.................... void main()
.................... {
*
0800: CLRF 04
0801: BCF 03.7
0802: MOVLW 1F
0803: ANDWF 03,F
0804: MOVLW 71
0805: BSF 03.5
0806: MOVWF 0F
0807: MOVF 0F,W
0808: BCF 06.7
0809: BCF 03.5
080A: BSF 06.7
080B: CLRF 2A
080C: CLRF 29
080D: CLRF 28
080E: CLRF 27
080F: CLRF 2C
0810: CLRF 2B
0811: CLRF 2E
0812: CLRF 2D
0813: BSF 03.5
0814: BSF 03.6
0815: MOVF 09,W
0816: ANDLW C0
0817: MOVWF 09
0818: BCF 03.6
0819: BCF 1F.4
081A: BCF 1F.5
081B: MOVLW 00
081C: BSF 03.6
081D: MOVWF 08
081E: BCF 03.5
081F: CLRF 07
0820: CLRF 08
0821: CLRF 09
*
0825: CLRF 31
0826: MOVLW 3C
0827: MOVWF 30
0828: BCF 36.1
0829: CLRF 38
082A: CLRF 37
082B: MOVLW 06
082C: MOVWF 39
.................... unsigned int16 integration_time=60;
.................... unsigned int16 time;
.................... unsigned int16 last_timer; // promena pro praskani
.................... unsigned int1 button_press,setup_mode=INTERVAL_setup; // semafor pro cteni tlacitek
.................... unsigned int16 measurement_number=0;
.................... unsigned int8 treshold=6;
....................
.................... setup_adc_ports(sAN0|VSS_VDD);
082D: BSF 03.5
082E: BSF 03.6
082F: MOVF 09,W
0830: ANDLW C0
0831: MOVWF 09
0832: BCF 03.6
0833: BCF 1F.4
0834: BCF 1F.5
0835: MOVLW 01
0836: BSF 03.6
0837: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_32);
0838: BCF 03.5
0839: BCF 03.6
083A: BCF 1F.6
083B: BSF 1F.7
083C: BSF 03.5
083D: BSF 1F.7
083E: BCF 03.5
083F: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
0840: BCF 14.5
0841: BCF 2F.5
0842: MOVF 2F,W
0843: BSF 03.5
0844: MOVWF 07
0845: BCF 03.5
0846: BSF 2F.4
0847: MOVF 2F,W
0848: BSF 03.5
0849: MOVWF 07
084A: BCF 03.5
084B: BCF 2F.3
084C: MOVF 2F,W
084D: BSF 03.5
084E: MOVWF 07
084F: MOVLW 01
0850: BCF 03.5
0851: MOVWF 14
0852: MOVLW 00
0853: BSF 03.5
0854: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
0855: MOVF 01,W
0856: ANDLW C0
0857: IORLW 07
0858: MOVWF 01
.................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
0859: MOVLW 07
085A: BCF 03.5
085B: MOVWF 10
.................... setup_timer_2(T2_DISABLED,0,1);
085C: MOVLW 00
085D: MOVWF 78
085E: MOVWF 12
085F: MOVLW 00
0860: BSF 03.5
0861: MOVWF 12
.................... setup_ccp1(CCP_PWM);
0862: BCF 03.5
0863: BCF 2F.2
0864: MOVF 2F,W
0865: BSF 03.5
0866: MOVWF 07
0867: BCF 03.5
0868: BCF 07.2
0869: BSF 03.5
086A: BCF 09.6
086B: MOVLW 0C
086C: BCF 03.5
086D: MOVWF 17
086E: BSF 03.5
086F: CLRF 1B
0870: CLRF 1C
0871: MOVLW 01
0872: MOVWF 1D
.................... setup_ccp2(CCP_PWM);
0873: BCF 03.5
0874: BCF 2F.1
0875: MOVF 2F,W
0876: BSF 03.5
0877: MOVWF 07
0878: BCF 03.5
0879: BCF 07.1
087A: MOVLW 0C
087B: MOVWF 1D
087C: MOVLW 01
087D: MOVWF 00
.................... setup_oscillator(OSC_8MHZ);
087E: MOVLW 71
087F: BSF 03.5
0880: MOVWF 0F
0881: MOVF 0F,W
....................
.................... set_pwm1_duty(0);
0882: BCF 03.5
0883: CLRF 15
.................... set_pwm2_duty(0);
0884: CLRF 1B
....................
.................... output_high(LED1);
0885: BCF 2F.6
0886: MOVF 2F,W
0887: BSF 03.5
0888: MOVWF 07
0889: BCF 03.5
088A: BSF 07.6
.................... output_high(LED2);
088B: BCF 2F.5
088C: MOVF 2F,W
088D: BSF 03.5
088E: MOVWF 07
088F: BCF 03.5
0890: BSF 07.5
.................... output_high(LED3);
0891: BCF 2F.4
0892: MOVF 2F,W
0893: BSF 03.5
0894: MOVWF 07
0895: BCF 03.5
0896: BSF 07.4
.................... output_high(LED4);
0897: BSF 03.5
0898: BCF 08.3
0899: BCF 03.5
089A: BSF 08.3
.................... output_low(BEEP);
089B: BSF 03.5
089C: BCF 08.2
089D: BCF 03.5
089E: BCF 08.2
....................
.................... setup_comparator(CP2_A0_VREF|CP2_OUT_ON_A5); // sets two comparators(A1 and VR and A2 as the output)
089F: BSF 03.6
08A0: CLRF 07
08A1: MOVLW A4
08A2: MOVWF 08
08A3: MOVLW 10
08A4: MOVWF 09
08A5: BSF 03.5
08A6: BCF 03.6
08A7: BCF 05.5
08A8: BSF 05.0
.................... setup_vref(VREF_HIGH|treshold); //sets 3.6(vdd *value/32 +vdd/4) if vdd is 5.0V
08A9: BCF 03.5
08AA: MOVF 39,W
08AB: IORLW 80
08AC: MOVWF 3A
08AD: BSF 03.5
08AE: MOVWF 17
.................... enable_interrupts(INT_COMP); //enables the comparator interrupt
08AF: BSF 0D.5
.................... enable_interrupts(INT_RTCC);
08B0: BCF 03.5
08B1: BSF 0B.5
.................... enable_interrupts(INT_TIMER1);
08B2: BSF 03.5
08B3: BSF 0C.0
.................... enable_interrupts(INT_TIMER2);
08B4: BSF 0C.1
.................... enable_interrupts(GLOBAL);
08B5: MOVLW C0
08B6: BCF 03.5
08B7: IORWF 0B,F
.................... lcd_init();
08B8: BCF 0A.3
08B9: GOTO 171
08BA: BSF 0A.3
....................
.................... lcd_putc("\fGM counter V1.0 \n 2013 MLAB");
08BB: MOVLW 5A
08BC: BSF 03.6
08BD: MOVWF 0D
08BE: MOVLW 00
08BF: MOVWF 0F
08C0: BCF 0A.3
08C1: BCF 03.6
08C2: CALL 1EA
08C3: BSF 0A.3
.................... printf("Geiger-Muller Counter V1.0 \r\n");
08C4: MOVLW 6A
08C5: BSF 03.6
08C6: MOVWF 0D
08C7: MOVLW 00
08C8: MOVWF 0F
08C9: BCF 0A.3
08CA: BCF 03.6
08CB: CALL 252
08CC: BSF 0A.3
.................... printf("(c) 2013 MLAB and UST.cz \r\n");
08CD: MOVLW 79
08CE: BSF 03.6
08CF: MOVWF 0D
08D0: MOVLW 00
08D1: MOVWF 0F
08D2: BCF 0A.3
08D3: BCF 03.6
08D4: CALL 252
08D5: BSF 0A.3
.................... Delay_ms(1000);
08D6: MOVLW 04
08D7: MOVWF 3A
08D8: MOVLW FA
08D9: MOVWF 47
08DA: BCF 0A.3
08DB: CALL 0A4
08DC: BSF 0A.3
08DD: DECFSZ 3A,F
08DE: GOTO 0D8
....................
.................... lcd_putc("\f");
08DF: MOVLW 87
08E0: BSF 03.6
08E1: MOVWF 0D
08E2: MOVLW 00
08E3: MOVWF 0F
08E4: BCF 0A.3
08E5: BCF 03.6
08E6: CALL 1EA
08E7: BSF 0A.3
.................... printf("\r\n");
08E8: MOVLW 0D
08E9: MOVWF 46
08EA: BCF 0A.3
08EB: CALL 230
08EC: BSF 0A.3
08ED: MOVLW 0A
08EE: MOVWF 46
08EF: BCF 0A.3
08F0: CALL 230
08F1: BSF 0A.3
....................
.................... set_timer1(0);
08F2: CLRF 0F
08F3: CLRF 0E
....................
.................... lcd_gotoxy(1,1); // vypsani hodnoty count, abz byla na LCD hned od zapnuti
08F4: MOVLW 01
08F5: MOVWF 47
08F6: MOVWF 48
08F7: BCF 0A.3
08F8: CALL 1AB
08F9: BSF 0A.3
.................... printf(lcd_putc,"Count:%lu ",pulse_count);
08FA: MOVLW 88
08FB: BSF 03.6
08FC: MOVWF 0D
08FD: MOVLW 00
08FE: MOVWF 0F
08FF: BCF 03.0
0900: MOVLW 06
0901: BCF 03.6
0902: MOVWF 3A
0903: BCF 0A.3
0904: CALL 298
0905: BSF 0A.3
0906: MOVLW 41
0907: MOVWF 04
0908: MOVF 2A,W
0909: MOVWF 3D
090A: MOVF 29,W
090B: MOVWF 3C
090C: MOVF 28,W
090D: MOVWF 3B
090E: MOVF 27,W
090F: MOVWF 3A
0910: BCF 0A.3
0911: CALL 329
0912: BSF 0A.3
0913: MOVLW 8C
0914: BSF 03.6
0915: MOVWF 0D
0916: MOVLW 00
0917: MOVWF 0F
0918: BSF 03.0
0919: MOVLW 05
091A: BCF 03.6
091B: MOVWF 3A
091C: BCF 0A.3
091D: CALL 298
091E: BSF 0A.3
....................
.................... while(true)
.................... {
.................... pulse_count = get_timer1() + (0xffff * overflow_count); // compute pulse count
091F: MOVF 0F,W
0920: MOVWF 7A
0921: MOVF 0E,W
0922: MOVWF 77
0923: MOVF 0F,W
0924: SUBWF 7A,W
0925: BTFSS 03.2
0926: GOTO 11F
0927: MOVF 77,W
0928: MOVWF 3A
0929: MOVF 7A,W
092A: MOVWF 3B
092B: MOVLW FF
092C: MOVWF 3D
092D: MOVWF 3C
092E: MOVF 2C,W
092F: MOVWF 3F
0930: MOVF 2B,W
0931: MOVWF 3E
0932: BCF 0A.3
0933: GOTO 385
0934: BSF 0A.3
0935: MOVF 79,W
0936: MOVWF 7A
0937: MOVF 78,W
0938: ADDWF 3A,W
0939: MOVWF 27
093A: MOVF 3B,W
093B: MOVWF 28
093C: MOVF 7A,W
093D: BTFSC 03.0
093E: INCFSZ 7A,W
093F: ADDWF 28,F
0940: CLRF 29
0941: CLRF 2A
.................... time = integration_time + 1 - (time_overflow_count * 0.0327); // compute time interval
0942: MOVLW 01
0943: ADDWF 30,W
0944: MOVWF 3A
0945: MOVF 31,W
0946: MOVWF 3B
0947: BTFSC 03.0
0948: INCF 3B,F
0949: MOVF 2E,W
094A: MOVWF 41
094B: MOVF 2D,W
094C: MOVWF 40
094D: BCF 0A.3
094E: CALL 39C
094F: BSF 0A.3
0950: MOVF 7A,W
0951: MOVWF 3F
0952: MOVF 79,W
0953: MOVWF 3E
0954: MOVF 78,W
0955: MOVWF 3D
0956: MOVF 77,W
0957: MOVWF 3C
0958: MOVLW 6F
0959: MOVWF 43
095A: MOVLW F0
095B: MOVWF 42
095C: MOVLW 05
095D: MOVWF 41
095E: MOVLW 7A
095F: MOVWF 40
0960: BCF 0A.3
0961: GOTO 3B9
0962: BSF 0A.3
0963: MOVF 77,W
0964: MOVWF 3C
0965: MOVF 78,W
0966: MOVWF 3D
0967: MOVF 79,W
0968: MOVWF 3E
0969: MOVF 7A,W
096A: MOVWF 3F
096B: MOVF 3B,W
096C: MOVWF 41
096D: MOVF 3A,W
096E: MOVWF 40
096F: BCF 0A.3
0970: CALL 39C
0971: BSF 0A.3
0972: BSF 03.1
0973: MOVF 7A,W
0974: MOVWF 43
0975: MOVF 79,W
0976: MOVWF 42
0977: MOVF 78,W
0978: MOVWF 41
0979: MOVF 77,W
097A: MOVWF 40
097B: MOVF 3F,W
097C: MOVWF 47
097D: MOVF 3E,W
097E: MOVWF 46
097F: MOVF 3D,W
0980: MOVWF 45
0981: MOVF 3C,W
0982: MOVWF 44
0983: BCF 0A.3
0984: GOTO 430
0985: BSF 0A.3
0986: MOVF 7A,W
0987: MOVWF 43
0988: MOVF 79,W
0989: MOVWF 42
098A: MOVF 78,W
098B: MOVWF 41
098C: MOVF 77,W
098D: MOVWF 40
098E: BCF 0A.3
098F: GOTO 573
0990: BSF 0A.3
0991: MOVF 79,W
0992: MOVWF 33
0993: MOVF 78,W
0994: MOVWF 32
....................
.................... if(get_timer1() != last_timer) // timer count increment detection
0995: MOVF 0F,W
0996: MOVWF 7A
0997: MOVF 0E,W
0998: MOVWF 77
0999: MOVF 0F,W
099A: SUBWF 7A,W
099B: BTFSS 03.2
099C: GOTO 195
099D: MOVF 77,W
099E: MOVWF 3A
099F: MOVF 7A,W
09A0: MOVWF 3B
09A1: MOVF 34,W
09A2: SUBWF 3A,W
09A3: BTFSS 03.2
09A4: GOTO 1A9
09A5: MOVF 35,W
09A6: SUBWF 3B,W
09A7: BTFSC 03.2
09A8: GOTO 1F6
.................... {
.................... output_toggle(BEEP);
09A9: BSF 03.5
09AA: BCF 08.2
09AB: MOVLW 04
09AC: BCF 03.5
09AD: XORWF 08,F
.................... delay_ms(1);
09AE: MOVLW 01
09AF: MOVWF 47
09B0: BCF 0A.3
09B1: CALL 0A4
09B2: BSF 0A.3
.................... output_toggle(BEEP);
09B3: BSF 03.5
09B4: BCF 08.2
09B5: MOVLW 04
09B6: BCF 03.5
09B7: XORWF 08,F
.................... output_toggle(LED3);
09B8: BCF 2F.4
09B9: MOVF 2F,W
09BA: BSF 03.5
09BB: MOVWF 07
09BC: MOVLW 10
09BD: BCF 03.5
09BE: XORWF 07,F
.................... last_timer=get_timer1();
09BF: MOVF 0F,W
09C0: MOVWF 7A
09C1: MOVF 0E,W
09C2: MOVWF 77
09C3: MOVF 0F,W
09C4: SUBWF 7A,W
09C5: BTFSS 03.2
09C6: GOTO 1BF
09C7: MOVF 77,W
09C8: MOVWF 34
09C9: MOVF 7A,W
09CA: MOVWF 35
.................... lcd_gotoxy(1,1); // prepsani dat na displeje
09CB: MOVLW 01
09CC: MOVWF 47
09CD: MOVWF 48
09CE: BCF 0A.3
09CF: CALL 1AB
09D0: BSF 0A.3
.................... printf(lcd_putc,"Count:%lu ",pulse_count);
09D1: MOVLW 90
09D2: BSF 03.6
09D3: MOVWF 0D
09D4: MOVLW 00
09D5: MOVWF 0F
09D6: BCF 03.0
09D7: MOVLW 06
09D8: BCF 03.6
09D9: MOVWF 3A
09DA: BCF 0A.3
09DB: CALL 298
09DC: BSF 0A.3
09DD: MOVLW 41
09DE: MOVWF 04
09DF: MOVF 2A,W
09E0: MOVWF 3D
09E1: MOVF 29,W
09E2: MOVWF 3C
09E3: MOVF 28,W
09E4: MOVWF 3B
09E5: MOVF 27,W
09E6: MOVWF 3A
09E7: BCF 0A.3
09E8: CALL 329
09E9: BSF 0A.3
09EA: MOVLW 94
09EB: BSF 03.6
09EC: MOVWF 0D
09ED: MOVLW 00
09EE: MOVWF 0F
09EF: BSF 03.0
09F0: MOVLW 05
09F1: BCF 03.6
09F2: MOVWF 3A
09F3: BCF 0A.3
09F4: CALL 298
09F5: BSF 0A.3
.................... }
....................
.................... lcd_gotoxy(1,2);
09F6: MOVLW 01
09F7: MOVWF 47
09F8: MOVLW 02
09F9: MOVWF 48
09FA: BCF 0A.3
09FB: CALL 1AB
09FC: BSF 0A.3
.................... printf(lcd_putc,"T:%3lu I:%3lu U:%2u ",time,integration_time,treshold);
09FD: MOVLW 54
09FE: MOVWF 46
09FF: BCF 0A.3
0A00: CALL 1BD
0A01: BSF 0A.3
0A02: MOVLW 3A
0A03: MOVWF 46
0A04: BCF 0A.3
0A05: CALL 1BD
0A06: BSF 0A.3
0A07: MOVLW 02
0A08: MOVWF 04
0A09: MOVF 33,W
0A0A: MOVWF 3B
0A0B: MOVF 32,W
0A0C: MOVWF 3A
0A0D: BCF 0A.3
0A0E: CALL 594
0A0F: BSF 0A.3
0A10: MOVLW 20
0A11: MOVWF 46
0A12: BCF 0A.3
0A13: CALL 1BD
0A14: BSF 0A.3
0A15: MOVLW 49
0A16: MOVWF 46
0A17: BCF 0A.3
0A18: CALL 1BD
0A19: BSF 0A.3
0A1A: MOVLW 3A
0A1B: MOVWF 46
0A1C: BCF 0A.3
0A1D: CALL 1BD
0A1E: BSF 0A.3
0A1F: MOVLW 02
0A20: MOVWF 04
0A21: MOVF 31,W
0A22: MOVWF 3B
0A23: MOVF 30,W
0A24: MOVWF 3A
0A25: BCF 0A.3
0A26: CALL 594
0A27: BSF 0A.3
0A28: MOVLW 20
0A29: MOVWF 46
0A2A: BCF 0A.3
0A2B: CALL 1BD
0A2C: BSF 0A.3
0A2D: MOVLW 55
0A2E: MOVWF 46
0A2F: BCF 0A.3
0A30: CALL 1BD
0A31: BSF 0A.3
0A32: MOVLW 3A
0A33: MOVWF 46
0A34: BCF 0A.3
0A35: CALL 1BD
0A36: BSF 0A.3
0A37: MOVF 39,W
0A38: MOVWF 3A
0A39: MOVLW 11
0A3A: MOVWF 3B
0A3B: BCF 0A.3
0A3C: GOTO 60C
0A3D: BSF 0A.3
0A3E: MOVLW 20
0A3F: MOVWF 46
0A40: BCF 0A.3
0A41: CALL 1BD
0A42: BSF 0A.3
.................... // printf(lcd_putc,"I:%4lu ", integration_time);
....................
.................... if(time == 0) // po uplynuti mereneho intervalu vypis na seriovku
0A43: MOVF 32,F
0A44: BTFSS 03.2
0A45: GOTO 29D
0A46: MOVF 33,F
0A47: BTFSS 03.2
0A48: GOTO 29D
.................... {
.................... set_timer0(0);
0A49: CLRF 01
.................... time_overflow_count=0;
0A4A: CLRF 2E
0A4B: CLRF 2D
.................... sound_beep(1000,700);
0A4C: MOVLW E8
0A4D: MOVWF 3A
0A4E: MOVLW 02
0A4F: MOVWF 3C
0A50: MOVLW BC
0A51: MOVWF 3B
0A52: BCF 0A.3
0A53: CALL 654
0A54: BSF 0A.3
.................... printf("$GMC1.0 %lu %lu %lu \r\n", measurement_number, integration_time, pulse_count);
0A55: MOVLW 98
0A56: BSF 03.6
0A57: MOVWF 0D
0A58: MOVLW 00
0A59: MOVWF 0F
0A5A: BCF 03.0
0A5B: MOVLW 08
0A5C: BCF 03.6
0A5D: MOVWF 3A
0A5E: BCF 0A.3
0A5F: CALL 69D
0A60: BSF 0A.3
0A61: MOVLW 10
0A62: MOVWF 04
0A63: MOVF 38,W
0A64: MOVWF 3B
0A65: MOVF 37,W
0A66: MOVWF 3A
0A67: BCF 0A.3
0A68: CALL 6EC
0A69: BSF 0A.3
0A6A: MOVLW 20
0A6B: MOVWF 46
0A6C: BCF 0A.3
0A6D: CALL 230
0A6E: BSF 0A.3
0A6F: MOVLW 10
0A70: MOVWF 04
0A71: MOVF 31,W
0A72: MOVWF 3B
0A73: MOVF 30,W
0A74: MOVWF 3A
0A75: BCF 0A.3
0A76: CALL 6EC
0A77: BSF 0A.3
0A78: MOVLW 20
0A79: MOVWF 46
0A7A: BCF 0A.3
0A7B: CALL 230
0A7C: BSF 0A.3
0A7D: MOVLW 41
0A7E: MOVWF 04
0A7F: MOVF 2A,W
0A80: MOVWF 3D
0A81: MOVF 29,W
0A82: MOVWF 3C
0A83: MOVF 28,W
0A84: MOVWF 3B
0A85: MOVF 27,W
0A86: MOVWF 3A
0A87: BCF 0A.3
0A88: GOTO 74F
0A89: BSF 0A.3
0A8A: MOVLW A1
0A8B: BSF 03.6
0A8C: MOVWF 0D
0A8D: MOVLW 00
0A8E: MOVWF 0F
0A8F: BSF 03.0
0A90: MOVLW 04
0A91: BCF 03.6
0A92: MOVWF 3A
0A93: BCF 0A.3
0A94: CALL 69D
0A95: BSF 0A.3
.................... set_timer1(0);
0A96: CLRF 0F
0A97: CLRF 0E
.................... overflow_count=0;
0A98: CLRF 2C
0A99: CLRF 2B
.................... measurement_number++;
0A9A: INCF 37,F
0A9B: BTFSC 03.2
0A9C: INCF 38,F
.................... }
....................
.................... if(button_press==false ) // tlacitka se ctou znovu pouze pokud v redchozim cyklu nebyla zmacknuta.
0A9D: BTFSC 36.0
0A9E: GOTO 3EF
.................... {
.................... if(!input(S1))
0A9F: BSF 2F.2
0AA0: MOVF 2F,W
0AA1: BSF 03.5
0AA2: MOVWF 07
0AA3: BCF 03.5
0AA4: BTFSC 07.2
0AA5: GOTO 2E2
.................... {
.................... delay_ms(20);
0AA6: MOVLW 14
0AA7: MOVWF 47
0AA8: BCF 0A.3
0AA9: CALL 0A4
0AAA: BSF 0A.3
.................... if(!input(S1))
0AAB: BSF 2F.2
0AAC: MOVF 2F,W
0AAD: BSF 03.5
0AAE: MOVWF 07
0AAF: BCF 03.5
0AB0: BTFSC 07.2
0AB1: GOTO 2E2
.................... {
.................... button_press=true;
0AB2: BSF 36.0
.................... sound_beep(100,700);
0AB3: MOVLW 64
0AB4: MOVWF 3A
0AB5: MOVLW 02
0AB6: MOVWF 3C
0AB7: MOVLW BC
0AB8: MOVWF 3B
0AB9: BCF 0A.3
0ABA: CALL 654
0ABB: BSF 0A.3
.................... switch (setup_mode)
.................... {
0ABC: MOVLW 00
0ABD: BTFSC 36.1
0ABE: MOVLW 01
0ABF: XORLW 00
0AC0: BTFSC 03.2
0AC1: GOTO 2C6
0AC2: XORLW 01
0AC3: BTFSC 03.2
0AC4: GOTO 2D5
0AC5: GOTO 2E2
.................... case INTERVAL_setup:
.................... if(integration_time < 0xfffa ) integration_time+=5;
0AC6: MOVF 31,W
0AC7: SUBLW FF
0AC8: BTFSS 03.0
0AC9: GOTO 2D4
0ACA: BTFSS 03.2
0ACB: GOTO 2D0
0ACC: MOVF 30,W
0ACD: SUBLW F9
0ACE: BTFSS 03.0
0ACF: GOTO 2D4
0AD0: MOVLW 05
0AD1: ADDWF 30,F
0AD2: BTFSC 03.0
0AD3: INCF 31,F
.................... break;
0AD4: GOTO 2E2
....................
.................... case TRESHOLD_setup:
.................... if(treshold < 0x0a ) treshold +=5;
0AD5: MOVF 39,W
0AD6: SUBLW 09
0AD7: BTFSS 03.0
0AD8: GOTO 2DB
0AD9: MOVLW 05
0ADA: ADDWF 39,F
.................... setup_vref(VREF_HIGH|treshold); //sets 3.6(vdd *value/32 +vdd/4) if vdd is 5.0V
0ADB: MOVF 39,W
0ADC: IORLW 80
0ADD: MOVWF 3A
0ADE: BSF 03.5
0ADF: MOVWF 17
.................... break;
0AE0: BCF 03.5
0AE1: GOTO 2E2
.................... }
.................... }
.................... }
....................
.................... if(!input(S2))
0AE2: BSF 2F.3
0AE3: MOVF 2F,W
0AE4: BSF 03.5
0AE5: MOVWF 07
0AE6: BCF 03.5
0AE7: BTFSC 07.3
0AE8: GOTO 32B
.................... {
.................... delay_ms(20);
0AE9: MOVLW 14
0AEA: MOVWF 47
0AEB: BCF 0A.3
0AEC: CALL 0A4
0AED: BSF 0A.3
.................... if(!input(S2))
0AEE: BSF 2F.3
0AEF: MOVF 2F,W
0AF0: BSF 03.5
0AF1: MOVWF 07
0AF2: BCF 03.5
0AF3: BTFSC 07.3
0AF4: GOTO 32B
.................... {
.................... button_press=true;
0AF5: BSF 36.0
.................... sound_beep(100,600);
0AF6: MOVLW 64
0AF7: MOVWF 3A
0AF8: MOVLW 02
0AF9: MOVWF 3C
0AFA: MOVLW 58
0AFB: MOVWF 3B
0AFC: BCF 0A.3
0AFD: CALL 654
0AFE: BSF 0A.3
.................... switch (setup_mode)
.................... {
0AFF: MOVLW 00
0B00: BTFSC 36.1
0B01: MOVLW 01
0B02: XORLW 00
0B03: BTFSC 03.2
0B04: GOTO 309
0B05: XORLW 01
0B06: BTFSC 03.2
0B07: GOTO 31E
0B08: GOTO 32B
.................... case INTERVAL_setup:
.................... if(integration_time > 0x0005 ) integration_time-=5;
0B09: MOVF 31,F
0B0A: BTFSS 03.2
0B0B: GOTO 310
0B0C: MOVF 30,W
0B0D: SUBLW 05
0B0E: BTFSC 03.0
0B0F: GOTO 316
0B10: MOVLW 05
0B11: SUBWF 30,F
0B12: MOVLW 00
0B13: BTFSS 03.0
0B14: MOVLW 01
0B15: SUBWF 31,F
.................... set_timer0(0); // vynulovani pocitadel, kdyz uzivatel sahne na tlacitka
0B16: CLRF 01
.................... time_overflow_count=0;
0B17: CLRF 2E
0B18: CLRF 2D
.................... set_timer1(0);
0B19: CLRF 0F
0B1A: CLRF 0E
.................... overflow_count=0;
0B1B: CLRF 2C
0B1C: CLRF 2B
.................... break;
0B1D: GOTO 32B
.................... case TRESHOLD_setup:
.................... if(treshold > 0x05 ) treshold -=5;
0B1E: MOVF 39,W
0B1F: SUBLW 05
0B20: BTFSC 03.0
0B21: GOTO 324
0B22: MOVLW 05
0B23: SUBWF 39,F
.................... setup_vref(VREF_HIGH|treshold); //sets 3.6(vdd *value/32 +vdd/4) if vdd is 5.0V
0B24: MOVF 39,W
0B25: IORLW 80
0B26: MOVWF 3A
0B27: BSF 03.5
0B28: MOVWF 17
.................... break;
0B29: BCF 03.5
0B2A: GOTO 32B
.................... }
.................... }
.................... }
....................
.................... if(!input(S3))
0B2B: BSF 03.5
0B2C: BSF 08.0
0B2D: BCF 03.5
0B2E: BTFSC 08.0
0B2F: GOTO 362
.................... {
.................... delay_ms(20);
0B30: MOVLW 14
0B31: MOVWF 47
0B32: BCF 0A.3
0B33: CALL 0A4
0B34: BSF 0A.3
.................... if(!input(S3))
0B35: BSF 03.5
0B36: BSF 08.0
0B37: BCF 03.5
0B38: BTFSC 08.0
0B39: GOTO 362
.................... {
.................... button_press=true;
0B3A: BSF 36.0
.................... sound_beep(100,500);
0B3B: MOVLW 64
0B3C: MOVWF 3A
0B3D: MOVLW 01
0B3E: MOVWF 3C
0B3F: MOVLW F4
0B40: MOVWF 3B
0B41: BCF 0A.3
0B42: CALL 654
0B43: BSF 0A.3
.................... switch (setup_mode)
.................... {
0B44: MOVLW 00
0B45: BTFSC 36.1
0B46: MOVLW 01
0B47: XORLW 00
0B48: BTFSC 03.2
0B49: GOTO 34E
0B4A: XORLW 01
0B4B: BTFSC 03.2
0B4C: GOTO 357
0B4D: GOTO 362
.................... case INTERVAL_setup:
.................... if(integration_time < 0xffff ) integration_time++;
0B4E: INCFSZ 30,W
0B4F: GOTO 353
0B50: INCFSZ 31,W
0B51: GOTO 353
0B52: GOTO 356
0B53: INCF 30,F
0B54: BTFSC 03.2
0B55: INCF 31,F
.................... break;
0B56: GOTO 362
....................
.................... case TRESHOLD_setup:
.................... if(treshold < 0x0F ) treshold ++;
0B57: MOVF 39,W
0B58: SUBLW 0E
0B59: BTFSC 03.0
0B5A: INCF 39,F
.................... setup_vref(VREF_HIGH|treshold); //sets 3.6(vdd *value/32 +vdd/4) if vdd is 5.0V
0B5B: MOVF 39,W
0B5C: IORLW 80
0B5D: MOVWF 3A
0B5E: BSF 03.5
0B5F: MOVWF 17
.................... break;
0B60: BCF 03.5
0B61: GOTO 362
.................... }
.................... }
.................... }
....................
.................... if(!input(S4))
0B62: BSF 03.5
0B63: BSF 08.1
0B64: BCF 03.5
0B65: BTFSC 08.1
0B66: GOTO 3A3
.................... {
.................... delay_ms(20);
0B67: MOVLW 14
0B68: MOVWF 47
0B69: BCF 0A.3
0B6A: CALL 0A4
0B6B: BSF 0A.3
.................... if(!input(S4))
0B6C: BSF 03.5
0B6D: BSF 08.1
0B6E: BCF 03.5
0B6F: BTFSC 08.1
0B70: GOTO 3A3
.................... {
.................... button_press=true;
0B71: BSF 36.0
.................... sound_beep(100,400);
0B72: MOVLW 64
0B73: MOVWF 3A
0B74: MOVLW 01
0B75: MOVWF 3C
0B76: MOVLW 90
0B77: MOVWF 3B
0B78: BCF 0A.3
0B79: CALL 654
0B7A: BSF 0A.3
.................... switch (setup_mode)
.................... {
0B7B: MOVLW 00
0B7C: BTFSC 36.1
0B7D: MOVLW 01
0B7E: XORLW 00
0B7F: BTFSC 03.2
0B80: GOTO 385
0B81: XORLW 01
0B82: BTFSC 03.2
0B83: GOTO 398
0B84: GOTO 3A3
.................... case INTERVAL_setup:
....................
.................... if(integration_time > 0x0001 ) integration_time--;
0B85: MOVF 31,F
0B86: BTFSS 03.2
0B87: GOTO 38C
0B88: MOVF 30,W
0B89: SUBLW 01
0B8A: BTFSC 03.0
0B8B: GOTO 390
0B8C: MOVF 30,W
0B8D: BTFSC 03.2
0B8E: DECF 31,F
0B8F: DECF 30,F
....................
.................... set_timer0(0); // vynulovani pocitadel, kdyz uzivatel sahne na tlacitka
0B90: CLRF 01
.................... time_overflow_count=0;
0B91: CLRF 2E
0B92: CLRF 2D
.................... set_timer1(0);
0B93: CLRF 0F
0B94: CLRF 0E
.................... overflow_count=0;
0B95: CLRF 2C
0B96: CLRF 2B
.................... break;
0B97: GOTO 3A3
.................... case TRESHOLD_setup:
.................... if(treshold > 0x01 ) treshold--;
0B98: MOVF 39,W
0B99: SUBLW 01
0B9A: BTFSS 03.0
0B9B: DECF 39,F
.................... setup_vref(VREF_HIGH|treshold); //sets 3.6(vdd *value/32 +vdd/4) if vdd is 5.0V
0B9C: MOVF 39,W
0B9D: IORLW 80
0B9E: MOVWF 3A
0B9F: BSF 03.5
0BA0: MOVWF 17
.................... break;
0BA1: BCF 03.5
0BA2: GOTO 3A3
.................... }
.................... }
.................... }
....................
.................... if(!input(S5)) // prepnuti na nastavovani casu
0BA3: BSF 03.5
0BA4: BSF 06.1
0BA5: BCF 03.5
0BA6: BTFSC 06.1
0BA7: GOTO 3C9
.................... {
.................... delay_ms(20);
0BA8: MOVLW 14
0BA9: MOVWF 47
0BAA: BCF 0A.3
0BAB: CALL 0A4
0BAC: BSF 0A.3
.................... if(!input(S5))
0BAD: BSF 03.5
0BAE: BSF 06.1
0BAF: BCF 03.5
0BB0: BTFSC 06.1
0BB1: GOTO 3C9
.................... {
.................... button_press=true;
0BB2: BSF 36.0
.................... sound_beep(100,800);
0BB3: MOVLW 64
0BB4: MOVWF 3A
0BB5: MOVLW 03
0BB6: MOVWF 3C
0BB7: MOVLW 20
0BB8: MOVWF 3B
0BB9: BCF 0A.3
0BBA: CALL 654
0BBB: BSF 0A.3
.................... setup_mode=INTERVAL_setup;
0BBC: BCF 36.1
.................... lcd_gotoxy(16,1); // prepsani dat na displeje
0BBD: MOVLW 10
0BBE: MOVWF 47
0BBF: MOVLW 01
0BC0: MOVWF 48
0BC1: BCF 0A.3
0BC2: CALL 1AB
0BC3: BSF 0A.3
.................... printf(lcd_putc,"I");
0BC4: MOVLW 49
0BC5: MOVWF 46
0BC6: BCF 0A.3
0BC7: CALL 1BD
0BC8: BSF 0A.3
.................... }
.................... }
....................
.................... if(!input(S6)) // prepnuti na nastavovani napeti
0BC9: BSF 03.5
0BCA: BSF 06.2
0BCB: BCF 03.5
0BCC: BTFSC 06.2
0BCD: GOTO 3EF
.................... {
.................... delay_ms(20);
0BCE: MOVLW 14
0BCF: MOVWF 47
0BD0: BCF 0A.3
0BD1: CALL 0A4
0BD2: BSF 0A.3
.................... if(!input(S6))
0BD3: BSF 03.5
0BD4: BSF 06.2
0BD5: BCF 03.5
0BD6: BTFSC 06.2
0BD7: GOTO 3EF
.................... {
.................... button_press=true;
0BD8: BSF 36.0
.................... sound_beep(100,800);
0BD9: MOVLW 64
0BDA: MOVWF 3A
0BDB: MOVLW 03
0BDC: MOVWF 3C
0BDD: MOVLW 20
0BDE: MOVWF 3B
0BDF: BCF 0A.3
0BE0: CALL 654
0BE1: BSF 0A.3
.................... setup_mode=TRESHOLD_setup;
0BE2: BSF 36.1
.................... lcd_gotoxy(16,1); // prepsani dat na displeje
0BE3: MOVLW 10
0BE4: MOVWF 47
0BE5: MOVLW 01
0BE6: MOVWF 48
0BE7: BCF 0A.3
0BE8: CALL 1AB
0BE9: BSF 0A.3
.................... printf(lcd_putc,"U");
0BEA: MOVLW 55
0BEB: MOVWF 46
0BEC: BCF 0A.3
0BED: CALL 1BD
0BEE: BSF 0A.3
.................... }
.................... }
.................... }
....................
.................... if ( input(S1) && input(S2) && input(S3) && input(S4) && input(S5) && input(S6)) // detekce pustenych tlacitek
0BEF: BSF 2F.2
0BF0: MOVF 2F,W
0BF1: BSF 03.5
0BF2: MOVWF 07
0BF3: BCF 03.5
0BF4: BTFSS 07.2
0BF5: GOTO 412
0BF6: BSF 2F.3
0BF7: MOVF 2F,W
0BF8: BSF 03.5
0BF9: MOVWF 07
0BFA: BCF 03.5
0BFB: BTFSS 07.3
0BFC: GOTO 412
0BFD: BSF 03.5
0BFE: BSF 08.0
0BFF: BCF 03.5
0C00: BTFSS 08.0
0C01: GOTO 412
0C02: BSF 03.5
0C03: BSF 08.1
0C04: BCF 03.5
0C05: BTFSS 08.1
0C06: GOTO 412
0C07: BSF 03.5
0C08: BSF 06.1
0C09: BCF 03.5
0C0A: BTFSS 06.1
0C0B: GOTO 412
0C0C: BSF 03.5
0C0D: BSF 06.2
0C0E: BCF 03.5
0C0F: BTFSS 06.2
0C10: GOTO 412
.................... {
.................... button_press=false;
0C11: BCF 36.0
.................... }
.................... }
0C12: GOTO 11F
.................... }
0C13: SLEEP
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40