CCS PCM C Compiler, Version 4.059d, 15399 03-III-07 19:39
Filename: main.lst
ROM used: 252 words (12%)
Largest free fragment is 1796
RAM used: 8 (2%) at main() level
8 (2%) worst case
Stack: 0 locations
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 004
0003: NOP
.................... /**** Analog to Digital Converter ****/
.................... #include "main.h"
.................... #include <16F877A.h>
.................... //////// Standard Header file for the PIC16F877A device ////////////////
.................... #device PIC16F877A
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Crystal osc <= 4mhz
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES WRT_50% //Lower half of Program Memory is Write Protected
....................
.................... #use delay(clock=4000000,RESTART_WDT)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
....................
....................
....................
.................... #define LED1 PIN_A2
.................... #define LED2 PIN_A3 // LEDky
.................... #define LED3 PIN_A5
.................... #define CIDLO 8 // Port A/D prevodniku
.................... #define TAD 8 // Doba na prevod jednoho bitu
....................
.................... void main()
.................... {
0004: CLRF 04
0005: BCF 03.7
0006: MOVLW 1F
0007: ANDWF 03,F
0008: MOVLW 19
0009: BSF 03.5
000A: MOVWF 19
000B: MOVLW A6
000C: MOVWF 18
000D: MOVLW 90
000E: BCF 03.5
000F: MOVWF 18
0010: BSF 03.5
0011: BSF 1F.0
0012: BSF 1F.1
0013: BSF 1F.2
0014: BCF 1F.3
0015: MOVLW 07
0016: MOVWF 1C
.................... int8 t; // Promenna pro nacteni hodnoty z potenciometru
....................
.................... setup_adc_ports(AN0); // Povolime analogovy vstup 0
*
001A: BSF 03.5
001B: BCF 1F.0
001C: BSF 1F.1
001D: BSF 1F.2
001E: BSF 1F.3
.................... setup_adc(ADC_CLOCK_DIV_8); // Delicka hodin pro prevodnik
001F: BCF 1F.6
0020: BCF 03.5
0021: BSF 1F.6
0022: BCF 1F.7
0023: BSF 03.5
0024: BCF 1F.7
0025: BCF 03.5
0026: BSF 1F.0
.................... // setup_psp(PSP_DISABLED); // Tento HW ma pouze PIC16F877A
.................... setup_spi(SPI_SS_DISABLED);
*
0017: MOVLW FF
0018: BCF 03.5
0019: MOVWF 20
*
0027: BCF 14.5
0028: BCF 20.5
0029: MOVF 20,W
002A: BSF 03.5
002B: MOVWF 07
002C: BCF 03.5
002D: BSF 20.4
002E: MOVF 20,W
002F: BSF 03.5
0030: MOVWF 07
0031: BCF 03.5
0032: BCF 20.3
0033: MOVF 20,W
0034: BSF 03.5
0035: MOVWF 07
0036: MOVLW 01
0037: BCF 03.5
0038: MOVWF 14
0039: MOVLW 00
003A: BSF 03.5
003B: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
003C: MOVF 01,W
003D: ANDLW C7
003E: IORLW 08
003F: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0040: BCF 03.5
0041: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0042: MOVLW 00
0043: MOVWF 78
0044: MOVWF 12
0045: MOVLW 00
0046: BSF 03.5
0047: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);
0048: MOVLW 07
0049: MOVWF 1C
004A: MOVF 05,W
004B: CLRWDT
004C: MOVLW 02
004D: MOVWF 77
004E: DECFSZ 77,F
004F: GOTO 04E
0050: GOTO 051
0051: MOVF 1C,W
0052: BCF 03.5
0053: BCF 0D.6
.................... setup_vref(FALSE);
0054: BSF 03.5
0055: CLRF 1D
....................
.................... set_adc_channel(CIDLO); // Pripojime cidlo na A/D prevodnik
0056: MOVLW 40
0057: MOVWF 78
0058: BCF 03.5
0059: MOVF 1F,W
005A: ANDLW C7
005B: IORWF 78,W
005C: MOVWF 1F
.................... delay_us(20); // Pockame na nabiti kapacit po prepnuti
005D: CLRWDT
005E: MOVLW 06
005F: MOVWF 77
0060: DECFSZ 77,F
0061: GOTO 060
.................... //t=read_adc(); // Prvni precteni cidla
....................
.................... while(TRUE){
.................... t=read_adc(); // Prvni precteni cidla
0062: BSF 1F.2
0063: BTFSC 1F.2
0064: GOTO 063
0065: MOVF 1E,W
0066: MOVWF 21
....................
....................
.................... if(t>00&&t<50){
0067: MOVF 21,F
0068: BTFSC 03.2
0069: GOTO 073
006A: MOVF 21,W
006B: SUBLW 31
006C: BTFSS 03.0
006D: GOTO 073
.................... output_high(LED1);
006E: BSF 03.5
006F: BCF 05.2
0070: BCF 03.5
0071: BSF 05.2
.................... //rozsvit modrou
.................... }
.................... else if(t>50&&t<80){
0072: GOTO 0FA
0073: MOVF 21,W
0074: SUBLW 32
0075: BTFSC 03.0
0076: GOTO 0A4
0077: MOVF 21,W
0078: SUBLW 4F
0079: BTFSS 03.0
007A: GOTO 0A4
.................... output_high (LED1); // Zhasneme LED
007B: BSF 03.5
007C: BCF 05.2
007D: BCF 03.5
007E: BSF 05.2
.................... delay_us(100);
007F: CLRWDT
0080: MOVLW 20
0081: MOVWF 77
0082: DECFSZ 77,F
0083: GOTO 082
0084: GOTO 085
.................... output_low (LED1); // Rozsvitime LED
0085: BSF 03.5
0086: BCF 05.2
0087: BCF 03.5
0088: BCF 05.2
.................... delay_us(100);
0089: CLRWDT
008A: MOVLW 20
008B: MOVWF 77
008C: DECFSZ 77,F
008D: GOTO 08C
008E: GOTO 08F
.................... output_low (LED2); // Rozsvitime LED
008F: BSF 03.5
0090: BCF 05.3
0091: BCF 03.5
0092: BCF 05.3
.................... delay_us(100);
0093: CLRWDT
0094: MOVLW 20
0095: MOVWF 77
0096: DECFSZ 77,F
0097: GOTO 096
0098: GOTO 099
.................... output_high (LED2); // Zhasneme LED
0099: BSF 03.5
009A: BCF 05.3
009B: BCF 03.5
009C: BSF 05.3
.................... delay_us(100);
009D: CLRWDT
009E: MOVLW 20
009F: MOVWF 77
00A0: DECFSZ 77,F
00A1: GOTO 0A0
00A2: GOTO 0A3
.................... //rozsvit modrou+zelenou
.................... }
.................... else if(t>80&&t<120){
00A3: GOTO 0FA
00A4: MOVF 21,W
00A5: SUBLW 50
00A6: BTFSC 03.0
00A7: GOTO 0C1
00A8: MOVF 21,W
00A9: SUBLW 77
00AA: BTFSS 03.0
00AB: GOTO 0C1
.................... //output_high(LED2);
.................... //rozvit zelenou
.................... output_low (LED2); // Rozsvitime LED
00AC: BSF 03.5
00AD: BCF 05.3
00AE: BCF 03.5
00AF: BCF 05.3
.................... delay_us(100);
00B0: CLRWDT
00B1: MOVLW 20
00B2: MOVWF 77
00B3: DECFSZ 77,F
00B4: GOTO 0B3
00B5: GOTO 0B6
.................... output_high (LED2); // Zhasneme LED
00B6: BSF 03.5
00B7: BCF 05.3
00B8: BCF 03.5
00B9: BSF 05.3
.................... delay_us(100);
00BA: CLRWDT
00BB: MOVLW 20
00BC: MOVWF 77
00BD: DECFSZ 77,F
00BE: GOTO 0BD
00BF: GOTO 0C0
.................... }
.................... else if(t>120&&t<160){
00C0: GOTO 0FA
00C1: MOVF 21,W
00C2: SUBLW 78
00C3: BTFSC 03.0
00C4: GOTO 0F2
00C5: MOVF 21,W
00C6: SUBLW 9F
00C7: BTFSS 03.0
00C8: GOTO 0F2
.................... output_high (LED3); // Zhasneme LED
00C9: BSF 03.5
00CA: BCF 05.5
00CB: BCF 03.5
00CC: BSF 05.5
.................... delay_us(100);
00CD: CLRWDT
00CE: MOVLW 20
00CF: MOVWF 77
00D0: DECFSZ 77,F
00D1: GOTO 0D0
00D2: GOTO 0D3
.................... output_low (LED3); // Rozsvitime LED
00D3: BSF 03.5
00D4: BCF 05.5
00D5: BCF 03.5
00D6: BCF 05.5
.................... delay_us(100);
00D7: CLRWDT
00D8: MOVLW 20
00D9: MOVWF 77
00DA: DECFSZ 77,F
00DB: GOTO 0DA
00DC: GOTO 0DD
.................... output_low (LED2); // Rozsvitime LED
00DD: BSF 03.5
00DE: BCF 05.3
00DF: BCF 03.5
00E0: BCF 05.3
.................... delay_us(100);
00E1: CLRWDT
00E2: MOVLW 20
00E3: MOVWF 77
00E4: DECFSZ 77,F
00E5: GOTO 0E4
00E6: GOTO 0E7
.................... output_high (LED2); // Zhasneme LED
00E7: BSF 03.5
00E8: BCF 05.3
00E9: BCF 03.5
00EA: BSF 05.3
.................... delay_us(100);
00EB: CLRWDT
00EC: MOVLW 20
00ED: MOVWF 77
00EE: DECFSZ 77,F
00EF: GOTO 0EE
00F0: GOTO 0F1
.................... //rozsvit zelenou+cervenou
.................... }
.................... else if(t>160){
00F1: GOTO 0FA
00F2: MOVF 21,W
00F3: SUBLW A0
00F4: BTFSC 03.0
00F5: GOTO 0FA
.................... output_high(LED3);
00F6: BSF 03.5
00F7: BCF 05.5
00F8: BCF 03.5
00F9: BSF 05.5
.................... //rozsvit cervenou
.................... }
....................
.................... }}
00FA: GOTO 062
....................
....................
00FB: SLEEP
Configuration Fuses:
Word 1: 3939 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD WRT_50%