Go to most recent revision | Blame | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.245, 27853 15-IV-06 16:26
Filename: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\cidla\cidla.lst
ROM used: 282 words (7%)
Largest free fragment is 2048
RAM used: 12 (7%) at main() level
12 (7%) worst case
Stack: 0 locations
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 004
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)
....................
....................
.................... //#include <stdlib.h>
....................
.................... #use rs232(baud=110,parity=N,xmit=PIN_B1,rcv=PIN_B0,bits=8,restart_wdt)
....................
.................... #define IRRX PIN_B0
....................
.................... #define TRESHOLD_MAX 60 // rozhodovaci uroven pro cidla cerna/bila
.................... #define TRESHOLD_MIN 40
.................... #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()
.................... {
0004: CLRF 04
0005: MOVLW 1F
0006: ANDWF 03,F
0007: MOVLW 60
0008: BSF 03.5
0009: MOVWF 0F
000A: BCF 06.1
000B: BCF 03.5
000C: BSF 06.1
000D: BSF 03.5
000E: BCF 1F.4
000F: BCF 1F.5
0010: MOVF 1B,W
0011: ANDLW 80
0012: MOVWF 1B
0013: MOVLW 07
0014: MOVWF 1C
.................... int8 cidla;
.................... unsigned int8 a;
.................... unsigned int8 n;
....................
.................... setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|VSS_VDD);
0015: BCF 1F.4
0016: BCF 1F.5
0017: MOVF 1B,W
0018: ANDLW 80
0019: IORLW 7F
001A: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
001B: BCF 1F.6
001C: BCF 03.5
001D: BSF 1F.6
001E: BSF 1F.7
001F: BSF 03.5
0020: BCF 1F.7
0021: BCF 03.5
0022: BSF 1F.0
.................... setup_spi(SPI_SLAVE|SPI_H_TO_L|SPI_SS_DISABLED);
0023: BCF 14.5
0024: BSF 03.5
0025: BCF 06.2
0026: BSF 06.1
0027: BSF 06.4
0028: MOVLW 35
0029: BCF 03.5
002A: MOVWF 14
002B: MOVLW 40
002C: BSF 03.5
002D: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
002E: MOVF 01,W
002F: ANDLW C7
0030: IORLW 08
0031: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0032: BCF 03.5
0033: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0034: MOVLW 00
0035: MOVWF 78
0036: MOVWF 12
0037: MOVLW 00
0038: BSF 03.5
0039: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);
003A: MOVLW 07
003B: MOVWF 1C
003C: MOVF 05,W
003D: CLRWDT
003E: MOVLW 02
003F: MOVWF 77
0040: DECFSZ 77,F
0041: GOTO 040
0042: NOP
0043: NOP
0044: MOVF 1C,W
0045: BCF 03.5
0046: BCF 0D.6
.................... setup_vref(FALSE);
0047: BSF 03.5
0048: CLRF 1D
....................
.................... last_radius=0b00001000; // minimalni rozsah snimani od stredu
0049: MOVLW 08
004A: BCF 03.5
004B: MOVWF 21
.................... last_cidla=0b00001000;
004C: MOVWF 22
....................
.................... shure=0;
004D: CLRF 23
....................
.................... while(true)
.................... {
.................... set_adc_channel(0);
004E: MOVLW 00
004F: MOVWF 78
0050: MOVF 1F,W
0051: ANDLW C7
0052: IORWF 78,W
0053: MOVWF 1F
.................... cidla=0;
0054: CLRF 24
.................... Delay_us(10);
0055: CLRWDT
0056: MOVLW 02
0057: MOVWF 77
0058: DECFSZ 77,F
0059: GOTO 058
005A: NOP
005B: NOP
.................... a=read_adc();
005C: BSF 1F.2
005D: BTFSC 1F.2
005E: GOTO 05D
005F: MOVF 1E,W
0060: MOVWF 25
....................
.................... set_adc_channel(1);
0061: MOVLW 08
0062: MOVWF 78
0063: MOVF 1F,W
0064: ANDLW C7
0065: IORWF 78,W
0066: MOVWF 1F
.................... if(a<TRESHOLD_MAX) //hystereze cidel
0067: MOVF 25,W
0068: SUBLW 3B
0069: BTFSS 03.0
006A: GOTO 074
.................... {
.................... if(a>TRESHOLD_MIN)
006B: MOVF 25,W
006C: SUBLW 28
006D: BTFSC 03.0
006E: GOTO 073
.................... {
.................... cidla |= (last_cidla & 0b00000001);
006F: MOVF 22,W
0070: ANDLW 01
0071: IORWF 24,F
.................... }
.................... else cidla |= 0b00000001;
0072: GOTO 074
0073: BSF 24.0
.................... }
....................
.................... a=read_adc();
0074: BSF 1F.2
0075: BTFSC 1F.2
0076: GOTO 075
0077: MOVF 1E,W
0078: MOVWF 25
....................
.................... set_adc_channel(2);
0079: MOVLW 10
007A: MOVWF 78
007B: MOVF 1F,W
007C: ANDLW C7
007D: IORWF 78,W
007E: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
007F: MOVF 25,W
0080: SUBLW 3B
0081: BTFSS 03.0
0082: GOTO 08C
.................... {
.................... if(a>TRESHOLD_MIN)
0083: MOVF 25,W
0084: SUBLW 28
0085: BTFSC 03.0
0086: GOTO 08B
.................... {
.................... cidla |= (last_cidla & 0b00000010);
0087: MOVF 22,W
0088: ANDLW 02
0089: IORWF 24,F
.................... }
.................... else cidla |= 0b00000010;
008A: GOTO 08C
008B: BSF 24.1
.................... }
....................
.................... a=read_adc();
008C: BSF 1F.2
008D: BTFSC 1F.2
008E: GOTO 08D
008F: MOVF 1E,W
0090: MOVWF 25
....................
.................... set_adc_channel(3);
0091: MOVLW 18
0092: MOVWF 78
0093: MOVF 1F,W
0094: ANDLW C7
0095: IORWF 78,W
0096: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
0097: MOVF 25,W
0098: SUBLW 3B
0099: BTFSS 03.0
009A: GOTO 0A4
.................... {
.................... if(a>TRESHOLD_MIN)
009B: MOVF 25,W
009C: SUBLW 28
009D: BTFSC 03.0
009E: GOTO 0A3
.................... {
.................... cidla |= (last_cidla & 0b00000100);
009F: MOVF 22,W
00A0: ANDLW 04
00A1: IORWF 24,F
.................... }
.................... else cidla |= 0b00000100;
00A2: GOTO 0A4
00A3: BSF 24.2
.................... }
....................
.................... a=read_adc();
00A4: BSF 1F.2
00A5: BTFSC 1F.2
00A6: GOTO 0A5
00A7: MOVF 1E,W
00A8: MOVWF 25
....................
.................... set_adc_channel(4);
00A9: MOVLW 20
00AA: MOVWF 78
00AB: MOVF 1F,W
00AC: ANDLW C7
00AD: IORWF 78,W
00AE: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
00AF: MOVF 25,W
00B0: SUBLW 3B
00B1: BTFSS 03.0
00B2: GOTO 0BC
.................... {
.................... if(a>TRESHOLD_MIN)
00B3: MOVF 25,W
00B4: SUBLW 28
00B5: BTFSC 03.0
00B6: GOTO 0BB
.................... {
.................... cidla |= (last_cidla & 0b00001000);
00B7: MOVF 22,W
00B8: ANDLW 08
00B9: IORWF 24,F
.................... }
.................... else cidla |= 0b00001000;
00BA: GOTO 0BC
00BB: BSF 24.3
.................... }
.................... a=read_adc();
00BC: BSF 1F.2
00BD: BTFSC 1F.2
00BE: GOTO 0BD
00BF: MOVF 1E,W
00C0: MOVWF 25
....................
.................... set_adc_channel(5);
00C1: MOVLW 28
00C2: MOVWF 78
00C3: MOVF 1F,W
00C4: ANDLW C7
00C5: IORWF 78,W
00C6: MOVWF 1F
....................
.................... if(a<TRESHOLD_MAX)
00C7: MOVF 25,W
00C8: SUBLW 3B
00C9: BTFSS 03.0
00CA: GOTO 0D4
.................... {
.................... if(a>TRESHOLD_MIN)
00CB: MOVF 25,W
00CC: SUBLW 28
00CD: BTFSC 03.0
00CE: GOTO 0D3
.................... {
.................... cidla |= (last_cidla & 0b00010000);
00CF: MOVF 22,W
00D0: ANDLW 10
00D1: IORWF 24,F
.................... }
.................... else cidla |= 0b00010000;
00D2: GOTO 0D4
00D3: BSF 24.4
.................... }
.................... a=read_adc();
00D4: BSF 1F.2
00D5: BTFSC 1F.2
00D6: GOTO 0D5
00D7: MOVF 1E,W
00D8: MOVWF 25
....................
.................... set_adc_channel(6);
00D9: MOVLW 30
00DA: MOVWF 78
00DB: MOVF 1F,W
00DC: ANDLW C7
00DD: IORWF 78,W
00DE: MOVWF 1F
.................... if(a<TRESHOLD_MAX)
00DF: MOVF 25,W
00E0: SUBLW 3B
00E1: BTFSS 03.0
00E2: GOTO 0EC
.................... {
.................... if(a>TRESHOLD_MIN)
00E3: MOVF 25,W
00E4: SUBLW 28
00E5: BTFSC 03.0
00E6: GOTO 0EB
.................... {
.................... cidla |= (last_cidla & 0b00100000);
00E7: MOVF 22,W
00E8: ANDLW 20
00E9: IORWF 24,F
.................... }
.................... else cidla |= 0b00100000;
00EA: GOTO 0EC
00EB: BSF 24.5
.................... }
.................... a=read_adc();
00EC: BSF 1F.2
00ED: BTFSC 1F.2
00EE: GOTO 0ED
00EF: MOVF 1E,W
00F0: MOVWF 25
....................
.................... if(a<TRESHOLD_MAX)
00F1: MOVF 25,W
00F2: SUBLW 3B
00F3: BTFSS 03.0
00F4: GOTO 0FE
.................... {
.................... if(a>TRESHOLD_MIN)
00F5: MOVF 25,W
00F6: SUBLW 28
00F7: BTFSC 03.0
00F8: GOTO 0FD
.................... {
.................... cidla |=(last_cidla & 0b01000000);
00F9: MOVF 22,W
00FA: ANDLW 40
00FB: IORWF 24,F
.................... }
.................... else cidla |= 0b01000000;
00FC: GOTO 0FE
00FD: BSF 24.6
.................... }
....................
.................... last_cidla=cidla;
00FE: MOVF 24,W
00FF: MOVWF 22
....................
.................... if (!input(IRRX)) {if (shure<255) shure++;} else {shure=0;};
0100: BSF 03.5
0101: BSF 06.0
0102: BCF 03.5
0103: BTFSC 06.0
0104: GOTO 10A
0105: INCFSZ 23,W
0106: GOTO 108
0107: GOTO 109
0108: INCF 23,F
0109: GOTO 10B
010A: CLRF 23
.................... if (shure>CIHLA) cidla|=0b10000000;
010B: MOVF 23,W
010C: SUBLW 0A
010D: BTFSS 03.0
010E: BSF 24.7
....................
.................... cidla=~cidla;
010F: COMF 24,F
.................... spi_write(cidla);
0110: MOVF 24,W
0111: MOVWF 13
0112: BSF 03.5
0113: BTFSC 14.0
0114: GOTO 117
0115: BCF 03.5
0116: GOTO 112
.................... }
0117: BCF 03.5
0118: GOTO 04E
.................... }
0119: SLEEP
Configuration Fuses:
Word 1: 3F38 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
Word 2: 3FFC NOFCMEN NOIESO