CCS PCM C Compiler, Version 4.059d, 15399 19-III-07 15:20
Filename: main.lst
ROM used: 268 words (13%)
Largest free fragment is 1780
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
....................
.................... #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 cidla
....................
.................... 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
....................
....................
....................
.................... 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
.................... //printf("%d\n\r",t);
....................
.................... if(t>00&&t<40){
0067: MOVF 21,F
0068: BTFSC 03.2
0069: GOTO 07B
006A: MOVF 21,W
006B: SUBLW 27
006C: BTFSS 03.0
006D: GOTO 07B
.................... output_low(LED2);
006E: BSF 03.5
006F: BCF 05.3
0070: BCF 03.5
0071: BCF 05.3
.................... output_low(LED3);
0072: BSF 03.5
0073: BCF 05.5
0074: BCF 03.5
0075: BCF 05.5
.................... output_high(LED1);
0076: BSF 03.5
0077: BCF 05.2
0078: BCF 03.5
0079: BSF 05.2
.................... //rozsvit modrou
.................... }
.................... else if(t>39&&t<60){
007A: GOTO 10A
007B: MOVF 21,W
007C: SUBLW 27
007D: BTFSC 03.0
007E: GOTO 0B0
007F: MOVF 21,W
0080: SUBLW 3B
0081: BTFSS 03.0
0082: GOTO 0B0
.................... output_low(LED3);
0083: BSF 03.5
0084: BCF 05.5
0085: BCF 03.5
0086: BCF 05.5
.................... output_high (LED1); // Zhasneme LED
0087: BSF 03.5
0088: BCF 05.2
0089: BCF 03.5
008A: BSF 05.2
.................... delay_us(100);
008B: CLRWDT
008C: MOVLW 20
008D: MOVWF 77
008E: DECFSZ 77,F
008F: GOTO 08E
0090: GOTO 091
.................... output_low (LED1); // Rozsvitime LED
0091: BSF 03.5
0092: BCF 05.2
0093: BCF 03.5
0094: BCF 05.2
.................... delay_us(100);
0095: CLRWDT
0096: MOVLW 20
0097: MOVWF 77
0098: DECFSZ 77,F
0099: GOTO 098
009A: GOTO 09B
.................... output_low (LED2); // Rozsvitime LED
009B: BSF 03.5
009C: BCF 05.3
009D: BCF 03.5
009E: BCF 05.3
.................... delay_us(100);
009F: CLRWDT
00A0: MOVLW 20
00A1: MOVWF 77
00A2: DECFSZ 77,F
00A3: GOTO 0A2
00A4: GOTO 0A5
.................... output_high (LED2); // Zhasneme LED
00A5: BSF 03.5
00A6: BCF 05.3
00A7: BCF 03.5
00A8: BSF 05.3
.................... delay_us(100);
00A9: CLRWDT
00AA: MOVLW 20
00AB: MOVWF 77
00AC: DECFSZ 77,F
00AD: GOTO 0AC
00AE: GOTO 0AF
.................... //rozsvit modrou+zelenou
.................... }
.................... else if(t>59&&t<80){
00AF: GOTO 10A
00B0: MOVF 21,W
00B1: SUBLW 3B
00B2: BTFSC 03.0
00B3: GOTO 0C5
00B4: MOVF 21,W
00B5: SUBLW 4F
00B6: BTFSS 03.0
00B7: GOTO 0C5
.................... output_low(LED3);
00B8: BSF 03.5
00B9: BCF 05.5
00BA: BCF 03.5
00BB: BCF 05.5
.................... output_low(LED1);
00BC: BSF 03.5
00BD: BCF 05.2
00BE: BCF 03.5
00BF: BCF 05.2
.................... output_high(LED2);
00C0: BSF 03.5
00C1: BCF 05.3
00C2: BCF 03.5
00C3: BSF 05.3
.................... //rozvit zelenou
.................... }
.................... else if(t>79&&t<100){
00C4: GOTO 10A
00C5: MOVF 21,W
00C6: SUBLW 4F
00C7: BTFSC 03.0
00C8: GOTO 0FA
00C9: MOVF 21,W
00CA: SUBLW 63
00CB: BTFSS 03.0
00CC: GOTO 0FA
.................... output_low(LED1);
00CD: BSF 03.5
00CE: BCF 05.2
00CF: BCF 03.5
00D0: BCF 05.2
.................... output_high (LED3); // Zhasneme LED
00D1: BSF 03.5
00D2: BCF 05.5
00D3: BCF 03.5
00D4: BSF 05.5
.................... delay_us(100);
00D5: CLRWDT
00D6: MOVLW 20
00D7: MOVWF 77
00D8: DECFSZ 77,F
00D9: GOTO 0D8
00DA: GOTO 0DB
.................... output_low (LED3); // Rozsvitime LED
00DB: BSF 03.5
00DC: BCF 05.5
00DD: BCF 03.5
00DE: BCF 05.5
.................... delay_us(100);
00DF: CLRWDT
00E0: MOVLW 20
00E1: MOVWF 77
00E2: DECFSZ 77,F
00E3: GOTO 0E2
00E4: GOTO 0E5
.................... output_low (LED2); // Rozsvitime LED
00E5: BSF 03.5
00E6: BCF 05.3
00E7: BCF 03.5
00E8: BCF 05.3
.................... delay_us(100);
00E9: CLRWDT
00EA: MOVLW 20
00EB: MOVWF 77
00EC: DECFSZ 77,F
00ED: GOTO 0EC
00EE: GOTO 0EF
.................... output_high (LED2); // Zhasneme LED
00EF: BSF 03.5
00F0: BCF 05.3
00F1: BCF 03.5
00F2: BSF 05.3
.................... delay_us(100);
00F3: CLRWDT
00F4: MOVLW 20
00F5: MOVWF 77
00F6: DECFSZ 77,F
00F7: GOTO 0F6
00F8: GOTO 0F9
.................... //rozsvit zelenou+cervenou
.................... }
.................... else if(t>99){
00F9: GOTO 10A
00FA: MOVF 21,W
00FB: SUBLW 63
00FC: BTFSC 03.0
00FD: GOTO 10A
.................... output_low(LED1);
00FE: BSF 03.5
00FF: BCF 05.2
0100: BCF 03.5
0101: BCF 05.2
.................... output_low(LED2);
0102: BSF 03.5
0103: BCF 05.3
0104: BCF 03.5
0105: BCF 05.3
.................... output_high(LED3);
0106: BSF 03.5
0107: BCF 05.5
0108: BCF 03.5
0109: BSF 05.5
.................... //rozsvit cervenou
.................... }
.................... }}
010A: GOTO 062
....................
....................
010B: SLEEP
Configuration Fuses:
Word 1: 3939 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD WRT_50%