Blame | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.245, 27853 23-IV-06 01:20
Filename: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\cidla\cidla.lst
ROM used: 542 words (13%)
Largest free fragment is 2048
RAM used: 13 (7%) at main() level
18 (10%) worst case
Stack: 2 locations
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0B1
0003: NOP
.................... #include ".\cidla.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... #device adc=8
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO
.................... #use delay(clock=4000000,RESTART_WDT)
*
0050: MOVLW 27
0051: MOVWF 04
0052: MOVF 00,W
0053: BTFSC 03.2
0054: GOTO 066
0055: MOVLW 01
0056: MOVWF 78
0057: MOVLW BF
0058: MOVWF 77
0059: CLRWDT
005A: DECFSZ 77,F
005B: GOTO 059
005C: DECFSZ 78,F
005D: GOTO 057
005E: MOVLW 4A
005F: MOVWF 77
0060: DECFSZ 77,F
0061: GOTO 060
0062: NOP
0063: CLRWDT
0064: DECFSZ 00,F
0065: GOTO 055
0066: RETLW 00
....................
....................
.................... //#include <stdlib.h>
....................
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,bits=8,restart_wdt)
*
002A: BSF 03.5
002B: BCF 06.3
002C: BCF 03.5
002D: BCF 06.3
002E: MOVLW 08
002F: MOVWF 78
0030: NOP
0031: NOP
0032: NOP
0033: BSF 78.7
0034: GOTO 044
0035: BCF 78.7
0036: RRF 2A,F
0037: BTFSC 03.0
0038: BSF 06.3
0039: BTFSS 03.0
003A: BCF 06.3
003B: BSF 78.6
003C: GOTO 044
003D: BCF 78.6
003E: DECFSZ 78,F
003F: GOTO 036
0040: NOP
0041: NOP
0042: NOP
0043: BSF 06.3
0044: MOVLW 1C
0045: MOVWF 04
0046: DECFSZ 04,F
0047: GOTO 046
0048: NOP
0049: NOP
004A: CLRWDT
004B: BTFSC 78.7
004C: GOTO 035
004D: BTFSC 78.6
004E: GOTO 03D
004F: RETLW 00
....................
.................... #define IRRX PIN_B0
....................
.................... #define TRESHOLD_MAX 70 // rozhodovaci uroven pro cidla cerna/bila
.................... #define TRESHOLD_MIN 50
.................... #define CIHLA 10 // doba, po kterou musi byt detekovana cihla
....................
.................... unsigned int8 radius; // co cidla vidi
.................... unsigned int8 last_radius; // rozsah
.................... unsigned int8 last_cidla; // co cidla videla minule
.................... unsigned int8 shure; // citac doby, po kterou musi byt detekovana cihla
....................
.................... //tuning
.................... /*#define PULZACE 3 // urcuje rychlost pulzovani pomoci PWM
....................
.................... //Vystup PWM je na PIN_B3
.................... ////////////////////////////////////////////////////////////////////////////////
.................... void pulzovani() // postupne rozsvecuje a zhasina podsvetleni
.................... {
.................... unsigned int8 i,n;
.................... for(n=0;n<=3;n++)
.................... {
.................... for(i=0;i<255;i++) {set_pwm1_duty(i); Delay_ms(PULZACE);} // rozsvecovani
.................... for(i=255;i>0;i--) {set_pwm1_duty(i); Delay_ms(PULZACE);} // zhasinani
.................... }
.................... }
.................... */
.................... ////////////////////////////////////////////////////////////////////////////////
.................... void main()
.................... {
*
00B1: CLRF 04
00B2: MOVLW 1F
00B3: ANDWF 03,F
00B4: MOVLW 60
00B5: BSF 03.5
00B6: MOVWF 0F
00B7: BCF 06.3
00B8: BCF 03.5
00B9: BSF 06.3
00BA: BSF 03.5
00BB: BCF 1F.4
00BC: BCF 1F.5
00BD: MOVF 1B,W
00BE: ANDLW 80
00BF: MOVWF 1B
00C0: MOVLW 07
00C1: MOVWF 1C
.................... int8 cidla;
.................... unsigned int8 a;
.................... unsigned int8 n;
....................
.................... setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|VSS_VDD);
00C2: BCF 1F.4
00C3: BCF 1F.5
00C4: MOVF 1B,W
00C5: ANDLW 80
00C6: IORLW 7F
00C7: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
00C8: BCF 1F.6
00C9: BCF 03.5
00CA: BSF 1F.6
00CB: BSF 1F.7
00CC: BSF 03.5
00CD: BCF 1F.7
00CE: BCF 03.5
00CF: BSF 1F.0
.................... setup_spi(SPI_SLAVE|SPI_H_TO_L|SPI_SS_DISABLED);
00D0: BCF 14.5
00D1: BSF 03.5
00D2: BCF 06.2
00D3: BSF 06.1
00D4: BSF 06.4
00D5: MOVLW 35
00D6: BCF 03.5
00D7: MOVWF 14
00D8: MOVLW 40
00D9: BSF 03.5
00DA: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
00DB: MOVF 01,W
00DC: ANDLW C7
00DD: IORLW 08
00DE: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
00DF: BCF 03.5
00E0: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
00E1: MOVLW 00
00E2: MOVWF 78
00E3: MOVWF 12
00E4: MOVLW 00
00E5: BSF 03.5
00E6: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);
00E7: MOVLW 07
00E8: MOVWF 1C
00E9: MOVF 05,W
00EA: CLRWDT
00EB: MOVLW 02
00EC: MOVWF 77
00ED: DECFSZ 77,F
00EE: GOTO 0ED
00EF: NOP
00F0: NOP
00F1: MOVF 1C,W
00F2: BCF 03.5
00F3: BCF 0D.6
.................... setup_vref(FALSE);
00F4: BSF 03.5
00F5: CLRF 1D
....................
.................... last_radius=0b00001000; // minimalni rozsah snimani od stredu
00F6: MOVLW 08
00F7: BCF 03.5
00F8: MOVWF 21
.................... last_cidla=0b00001000;
00F9: MOVWF 22
....................
.................... // diagnostika
.................... printf("\n\r");
00FA: CLRF 27
00FB: MOVF 27,W
00FC: CALL 004
00FD: IORLW 00
00FE: BTFSC 03.2
00FF: GOTO 104
0100: INCF 27,F
0101: MOVWF 2A
0102: CALL 02A
0103: GOTO 0FB
.................... Delay_ms(100);
0104: MOVLW 64
0105: MOVWF 27
0106: CALL 050
.................... printf("***\n\r");
0107: CLRF 27
0108: MOVF 27,W
0109: CALL 00B
010A: IORLW 00
010B: BTFSC 03.2
010C: GOTO 111
010D: INCF 27,F
010E: MOVWF 2A
010F: CALL 02A
0110: GOTO 108
.................... Delay_ms(100);
0111: MOVLW 64
0112: MOVWF 27
0113: CALL 050
.................... for (n=0; n<=6; n++)
0114: CLRF 26
0115: MOVF 26,W
0116: SUBLW 06
0117: BTFSS 03.0
0118: GOTO 151
.................... {
.................... set_adc_channel(n);
0119: RLF 26,W
011A: MOVWF 77
011B: RLF 77,F
011C: RLF 77,F
011D: MOVLW F8
011E: ANDWF 77,F
011F: MOVF 1F,W
0120: ANDLW C7
0121: IORWF 77,W
0122: MOVWF 1F
.................... Delay_ms(100);
0123: MOVLW 64
0124: MOVWF 27
0125: CALL 050
.................... a=read_adc();
0126: BSF 1F.2
0127: BTFSC 1F.2
0128: GOTO 127
0129: MOVF 1E,W
012A: MOVWF 25
.................... printf("sensor %u - %u\n\r",n,a);
012B: CLRF 27
012C: MOVF 27,W
012D: CALL 015
012E: INCF 27,F
012F: MOVWF 77
0130: MOVWF 2A
0131: CALL 02A
0132: MOVLW 07
0133: SUBWF 27,W
0134: BTFSS 03.2
0135: GOTO 12C
0136: MOVF 26,W
0137: MOVWF 28
0138: MOVLW 1B
0139: MOVWF 29
013A: CALL 07C
013B: MOVLW 20
013C: MOVWF 2A
013D: CALL 02A
013E: MOVLW 2D
013F: MOVWF 2A
0140: CALL 02A
0141: MOVLW 20
0142: MOVWF 2A
0143: CALL 02A
0144: MOVF 25,W
0145: MOVWF 28
0146: MOVLW 1B
0147: MOVWF 29
0148: CALL 07C
0149: MOVLW 0A
014A: MOVWF 2A
014B: CALL 02A
014C: MOVLW 0D
014D: MOVWF 2A
014E: CALL 02A
.................... }
014F: INCF 26,F
0150: GOTO 115
....................
.................... shure=0;
0151: CLRF 23
.................... while(true)
.................... {
.................... set_adc_channel(0);
0152: MOVLW 00
0153: MOVWF 78
0154: MOVF 1F,W
0155: ANDLW C7
0156: IORWF 78,W
0157: MOVWF 1F
.................... cidla=0;
0158: CLRF 24
.................... Delay_us(10);
0159: CLRWDT
015A: MOVLW 02
015B: MOVWF 77
015C: DECFSZ 77,F
015D: GOTO 15C
015E: NOP
015F: NOP
.................... a=read_adc();
0160: BSF 1F.2
0161: BTFSC 1F.2
0162: GOTO 161
0163: MOVF 1E,W
0164: MOVWF 25
....................
.................... set_adc_channel(1);
0165: MOVLW 08
0166: MOVWF 78
0167: MOVF 1F,W
0168: ANDLW C7
0169: IORWF 78,W
016A: MOVWF 1F
.................... if(a<TRESHOLD_MAX) //hystereze cidel
016B: MOVF 25,W
016C: SUBLW 45
016D: BTFSS 03.0
016E: GOTO 178
.................... {
.................... if(a>TRESHOLD_MIN)
016F: MOVF 25,W
0170: SUBLW 32
0171: BTFSC 03.0
0172: GOTO 177
.................... {
.................... cidla |= (last_cidla & 0b00000001);
0173: MOVF 22,W
0174: ANDLW 01
0175: IORWF 24,F
.................... }
.................... else cidla |= 0b00000001;
0176: GOTO 178
0177: BSF 24.0
.................... }
....................
.................... a=read_adc();
0178: BSF 1F.2
0179: BTFSC 1F.2
017A: GOTO 179
017B: MOVF 1E,W
017C: MOVWF 25
....................
.................... set_adc_channel(2);
017D: MOVLW 10
017E: MOVWF 78
017F: MOVF 1F,W
0180: ANDLW C7
0181: IORWF 78,W
0182: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
0183: MOVF 25,W
0184: SUBLW 45
0185: BTFSS 03.0
0186: GOTO 190
.................... {
.................... if(a>TRESHOLD_MIN)
0187: MOVF 25,W
0188: SUBLW 32
0189: BTFSC 03.0
018A: GOTO 18F
.................... {
.................... cidla |= (last_cidla & 0b00000010);
018B: MOVF 22,W
018C: ANDLW 02
018D: IORWF 24,F
.................... }
.................... else cidla |= 0b00000010;
018E: GOTO 190
018F: BSF 24.1
.................... }
....................
.................... a=read_adc();
0190: BSF 1F.2
0191: BTFSC 1F.2
0192: GOTO 191
0193: MOVF 1E,W
0194: MOVWF 25
....................
.................... set_adc_channel(3);
0195: MOVLW 18
0196: MOVWF 78
0197: MOVF 1F,W
0198: ANDLW C7
0199: IORWF 78,W
019A: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
019B: MOVF 25,W
019C: SUBLW 45
019D: BTFSS 03.0
019E: GOTO 1A8
.................... {
.................... if(a>TRESHOLD_MIN)
019F: MOVF 25,W
01A0: SUBLW 32
01A1: BTFSC 03.0
01A2: GOTO 1A7
.................... {
.................... cidla |= (last_cidla & 0b00000100);
01A3: MOVF 22,W
01A4: ANDLW 04
01A5: IORWF 24,F
.................... }
.................... else cidla |= 0b00000100;
01A6: GOTO 1A8
01A7: BSF 24.2
.................... }
....................
.................... a=read_adc();
01A8: BSF 1F.2
01A9: BTFSC 1F.2
01AA: GOTO 1A9
01AB: MOVF 1E,W
01AC: MOVWF 25
....................
.................... set_adc_channel(4);
01AD: MOVLW 20
01AE: MOVWF 78
01AF: MOVF 1F,W
01B0: ANDLW C7
01B1: IORWF 78,W
01B2: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
01B3: MOVF 25,W
01B4: SUBLW 45
01B5: BTFSS 03.0
01B6: GOTO 1C0
.................... {
.................... if(a>TRESHOLD_MIN)
01B7: MOVF 25,W
01B8: SUBLW 32
01B9: BTFSC 03.0
01BA: GOTO 1BF
.................... {
.................... cidla |= (last_cidla & 0b00001000);
01BB: MOVF 22,W
01BC: ANDLW 08
01BD: IORWF 24,F
.................... }
.................... else cidla |= 0b00001000;
01BE: GOTO 1C0
01BF: BSF 24.3
.................... }
.................... a=read_adc();
01C0: BSF 1F.2
01C1: BTFSC 1F.2
01C2: GOTO 1C1
01C3: MOVF 1E,W
01C4: MOVWF 25
....................
.................... set_adc_channel(5);
01C5: MOVLW 28
01C6: MOVWF 78
01C7: MOVF 1F,W
01C8: ANDLW C7
01C9: IORWF 78,W
01CA: MOVWF 1F
....................
.................... if(a<TRESHOLD_MAX)
01CB: MOVF 25,W
01CC: SUBLW 45
01CD: BTFSS 03.0
01CE: GOTO 1D8
.................... {
.................... if(a>TRESHOLD_MIN)
01CF: MOVF 25,W
01D0: SUBLW 32
01D1: BTFSC 03.0
01D2: GOTO 1D7
.................... {
.................... cidla |= (last_cidla & 0b00010000);
01D3: MOVF 22,W
01D4: ANDLW 10
01D5: IORWF 24,F
.................... }
.................... else cidla |= 0b00010000;
01D6: GOTO 1D8
01D7: BSF 24.4
.................... }
.................... a=read_adc();
01D8: BSF 1F.2
01D9: BTFSC 1F.2
01DA: GOTO 1D9
01DB: MOVF 1E,W
01DC: MOVWF 25
....................
.................... set_adc_channel(6);
01DD: MOVLW 30
01DE: MOVWF 78
01DF: MOVF 1F,W
01E0: ANDLW C7
01E1: IORWF 78,W
01E2: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
01E3: MOVF 25,W
01E4: SUBLW 45
01E5: BTFSS 03.0
01E6: GOTO 1F0
.................... {
.................... if(a>TRESHOLD_MIN)
01E7: MOVF 25,W
01E8: SUBLW 32
01E9: BTFSC 03.0
01EA: GOTO 1EF
.................... {
.................... cidla |= (last_cidla & 0b00100000);
01EB: MOVF 22,W
01EC: ANDLW 20
01ED: IORWF 24,F
.................... }
.................... else cidla |= 0b00100000;
01EE: GOTO 1F0
01EF: BSF 24.5
.................... }
.................... a=read_adc();
01F0: BSF 1F.2
01F1: BTFSC 1F.2
01F2: GOTO 1F1
01F3: MOVF 1E,W
01F4: MOVWF 25
....................
.................... if(a<TRESHOLD_MAX)
01F5: MOVF 25,W
01F6: SUBLW 45
01F7: BTFSS 03.0
01F8: GOTO 202
.................... {
.................... if(a>TRESHOLD_MIN)
01F9: MOVF 25,W
01FA: SUBLW 32
01FB: BTFSC 03.0
01FC: GOTO 201
.................... {
.................... cidla |=(last_cidla & 0b01000000);
01FD: MOVF 22,W
01FE: ANDLW 40
01FF: IORWF 24,F
.................... }
.................... else cidla |= 0b01000000;
0200: GOTO 202
0201: BSF 24.6
.................... }
....................
.................... last_cidla=cidla;
0202: MOVF 24,W
0203: MOVWF 22
....................
.................... if (!input(IRRX)) {if (shure<255) shure++;} else {shure=0;};
0204: BSF 03.5
0205: BSF 06.0
0206: BCF 03.5
0207: BTFSC 06.0
0208: GOTO 20E
0209: INCFSZ 23,W
020A: GOTO 20C
020B: GOTO 20D
020C: INCF 23,F
020D: GOTO 20F
020E: CLRF 23
.................... if (shure>CIHLA) cidla|=0b10000000;
020F: MOVF 23,W
0210: SUBLW 0A
0211: BTFSS 03.0
0212: BSF 24.7
....................
.................... cidla=~cidla;
0213: COMF 24,F
.................... spi_write(cidla);
0214: MOVF 24,W
0215: MOVWF 13
0216: BSF 03.5
0217: BTFSC 14.0
0218: GOTO 21B
0219: BCF 03.5
021A: GOTO 216
.................... }
021B: BCF 03.5
021C: GOTO 152
.................... }
021D: SLEEP
Configuration Fuses:
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
Word 2: 3FFC NOFCMEN NOIESO