Go to most recent revision | Blame | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.245, 27853 01-IV-06 23:13
Filename: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\main.lst
ROM used: 582 words (14%)
Largest free fragment is 2048
RAM used: 35 (20%) at main() level
38 (22%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 18F
0003: NOP
.................... #include ".\main.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC_IO
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES BROWNOUT //Reset when brownout detected
.................... #FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES IESO //Internal External Switch Over mode enabled
....................
.................... #use delay(clock=8000000,RESTART_WDT)
000E: MOVLW 3F
000F: MOVWF 04
0010: MOVF 00,W
0011: BTFSC 03.2
0012: GOTO 025
0013: MOVLW 02
0014: MOVWF 78
0015: MOVLW BF
0016: MOVWF 77
0017: CLRWDT
0018: DECFSZ 77,F
0019: GOTO 017
001A: DECFSZ 78,F
001B: GOTO 015
001C: MOVLW 96
001D: MOVWF 77
001E: DECFSZ 77,F
001F: GOTO 01E
0020: NOP
0021: NOP
0022: CLRWDT
0023: DECFSZ 00,F
0024: GOTO 013
0025: BCF 0A.3
0026: GOTO 040 (RETURN)
0027: MOVLW 08
0028: SUBWF 3F,F
0029: BTFSS 03.0
002A: GOTO 036
002B: MOVLW 3F
002C: MOVWF 04
002D: BCF 03.0
002E: RRF 00,F
002F: MOVF 00,W
0030: BTFSC 03.2
0031: GOTO 036
0032: GOTO 034
0033: CLRWDT
0034: DECFSZ 00,F
0035: GOTO 033
0036: BCF 0A.3
0037: GOTO 043 (RETURN)
....................
....................
....................
.................... #use rtos (timer=2, minor_cycle=2ms)
....................
.................... unsigned int8 sensors; // pomocna promenna pro cteni cidel na caru
.................... unsigned int8 line; // na ktere strane byla detekovana cara
.................... unsigned int8 dira; // pocita dobu po kterou je ztracena cara
.................... unsigned int8 uhel; // urcuje aktualni uhel zataceni
....................
.................... signed int16 Lmotor; // promene, ktere urcuji velikost vykonu na levem
.................... signed int16 Rmotor; // a pravem motoru
....................
.................... #define LMAX 190 // maximalni zatoceni doleva
.................... #define RMAX 60 // maximalni zatoceni doprava
.................... #define STRED 128 // sredni poloha zadniho kolecka
....................
.................... // servo
.................... #define SERVO PIN_A2
....................
.................... //motory
.................... #define FR output_low(PIN_A7); output_high(PIN_A6) // Vpred
.................... #define FL output_low(PIN_A1); output_high(PIN_A0)
.................... #define BR output_low(PIN_A6); output_high(PIN_A7) // Vzad
.................... #define BL output_low(PIN_A0); output_high(PIN_A1)
.................... #define STOPR output_low(PIN_A6);output_low(PIN_A7)
.................... #define STOPL output_low(PIN_A0);output_low(PIN_A1)
....................
.................... //HID
.................... #define LED1 PIN_B1 //oranzova
.................... #define LED2 PIN_B2 //zluta
....................
.................... #define STROBE PIN_B0
.................... //#define SW1 PIN_A2 // Motory On/off
....................
.................... // makro pro PWM
.................... #define GO(motor, direction, power) if(get_timer0()<=power) \
.................... {direction##motor;} else {stop##motor;}
....................
....................
.................... ////////////////////////////////////////////////////////////////////////////////
.................... ////////////////////////////////////////////////////////////////////////////////
.................... /*
.................... void diagnostika()
.................... {
.................... if(input(SW1))STOPR;STOPL;While(TRUE);
.................... // if(LSENSOR==true) output_high(LED2); else output_low(LED2);
.................... // if(RSENSOR==true) output_high(LED1); else output_low(LED1);
.................... }
.................... */
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #task (rate=16ms,max=2ms)
.................... void zatoc() // ridi servo ktere otaci kolem
.................... {
.................... unsigned int8 n;
.................... output_high(SERVO);
0038: BSF 03.5
0039: BCF 05.2
003A: BCF 03.5
003B: BSF 05.2
.................... delay_us(1200);
003C: CLRWDT
003D: MOVLW 01
003E: MOVWF 3F
003F: GOTO 00E
0040: MOVLW C7
0041: MOVWF 3F
0042: GOTO 027
.................... for(n=uhel; n>0; n--);
0043: MOVF 24,W
0044: MOVWF 3E
0045: MOVF 3E,F
0046: BTFSC 03.2
0047: GOTO 04A
0048: DECF 3E,F
0049: GOTO 045
.................... output_low(SERVO);
004A: BSF 03.5
004B: BCF 05.2
004C: BCF 03.5
004D: BCF 05.2
.................... }
004E: MOVLW 38
004F: MOVWF 2E
0050: MOVLW 00
0051: MOVWF 2F
0052: BCF 0A.3
0053: GOTO 236
0054: RETLW 00
....................
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #task (rate=2ms, max=500us)
.................... void motory() // umoznuje nezavisle rizeni vykonu na obou motorech
.................... {
....................
.................... if(Rmotor>0) //pravy motor
0055: BTFSC 28.7
0056: GOTO 07D
0057: MOVF 28,F
0058: BTFSS 03.2
0059: GOTO 05E
005A: MOVF 27,W
005B: SUBLW 00
005C: BTFSC 03.0
005D: GOTO 07D
.................... {
.................... GO(R, F, Rmotor);
005E: MOVF 01,W
005F: BTFSS 00.7
0060: GOTO 064
0061: BTFSS 28.7
0062: GOTO 06C
0063: GOTO 066
0064: BTFSC 28.7
0065: GOTO 075
0066: MOVF 28,F
0067: BTFSS 03.2
0068: GOTO 06C
0069: SUBWF 27,W
006A: BTFSS 03.0
006B: GOTO 075
006C: BSF 03.5
006D: BCF 05.7
006E: BCF 03.5
006F: BCF 05.7
0070: BSF 03.5
0071: BCF 05.6
0072: BCF 03.5
0073: BSF 05.6
0074: GOTO 07D
0075: BSF 03.5
0076: BCF 05.6
0077: BCF 03.5
0078: BCF 05.6
0079: BSF 03.5
007A: BCF 05.7
007B: BCF 03.5
007C: BCF 05.7
.................... }
....................
.................... if(Rmotor==0) STOPR;
007D: MOVF 27,F
007E: BTFSS 03.2
007F: GOTO 087
0080: MOVF 28,F
0081: BTFSS 03.2
0082: GOTO 087
0083: BSF 03.5
0084: BCF 05.6
0085: BCF 03.5
0086: BCF 05.6
0087: BSF 03.5
0088: BCF 05.7
0089: BCF 03.5
008A: BCF 05.7
....................
.................... if(Rmotor<0)
008B: BTFSS 28.7
008C: GOTO 0BD
.................... {
.................... GO(R, B, abs(Rmotor));
008D: MOVF 01,W
008E: MOVWF 40
008F: MOVF 28,W
0090: MOVWF 7A
0091: MOVF 27,W
0092: BTFSS 28.7
0093: GOTO 09D
0094: MOVF 27,W
0095: SUBLW 00
0096: MOVWF 77
0097: CLRF 7A
0098: MOVF 28,W
0099: BTFSS 03.0
009A: INCFSZ 28,W
009B: SUBWF 7A,F
009C: MOVF 77,W
009D: MOVWF 78
009E: BTFSS 40.7
009F: GOTO 0A3
00A0: BTFSS 7A.7
00A1: GOTO 0AC
00A2: GOTO 0A5
00A3: BTFSC 7A.7
00A4: GOTO 0B5
00A5: MOVF 7A,F
00A6: BTFSS 03.2
00A7: GOTO 0AC
00A8: MOVF 40,W
00A9: SUBWF 78,W
00AA: BTFSS 03.0
00AB: GOTO 0B5
00AC: BSF 03.5
00AD: BCF 05.6
00AE: BCF 03.5
00AF: BCF 05.6
00B0: BSF 03.5
00B1: BCF 05.7
00B2: BCF 03.5
00B3: BSF 05.7
00B4: GOTO 0BD
00B5: BSF 03.5
00B6: BCF 05.6
00B7: BCF 03.5
00B8: BCF 05.6
00B9: BSF 03.5
00BA: BCF 05.7
00BB: BCF 03.5
00BC: BCF 05.7
.................... }
....................
.................... if(Lmotor>0) // levy motor
00BD: BTFSC 26.7
00BE: GOTO 0E5
00BF: MOVF 26,F
00C0: BTFSS 03.2
00C1: GOTO 0C6
00C2: MOVF 25,W
00C3: SUBLW 00
00C4: BTFSC 03.0
00C5: GOTO 0E5
.................... {
.................... GO(L, F, Lmotor);
00C6: MOVF 01,W
00C7: BTFSS 00.7
00C8: GOTO 0CC
00C9: BTFSS 26.7
00CA: GOTO 0D4
00CB: GOTO 0CE
00CC: BTFSC 26.7
00CD: GOTO 0DD
00CE: MOVF 26,F
00CF: BTFSS 03.2
00D0: GOTO 0D4
00D1: SUBWF 25,W
00D2: BTFSS 03.0
00D3: GOTO 0DD
00D4: BSF 03.5
00D5: BCF 05.1
00D6: BCF 03.5
00D7: BCF 05.1
00D8: BSF 03.5
00D9: BCF 05.0
00DA: BCF 03.5
00DB: BSF 05.0
00DC: GOTO 0E5
00DD: BSF 03.5
00DE: BCF 05.0
00DF: BCF 03.5
00E0: BCF 05.0
00E1: BSF 03.5
00E2: BCF 05.1
00E3: BCF 03.5
00E4: BCF 05.1
.................... }
....................
.................... if(Lmotor==0) STOPL;
00E5: MOVF 25,F
00E6: BTFSS 03.2
00E7: GOTO 0EF
00E8: MOVF 26,F
00E9: BTFSS 03.2
00EA: GOTO 0EF
00EB: BSF 03.5
00EC: BCF 05.0
00ED: BCF 03.5
00EE: BCF 05.0
00EF: BSF 03.5
00F0: BCF 05.1
00F1: BCF 03.5
00F2: BCF 05.1
....................
.................... if(Lmotor<0)
00F3: BTFSS 26.7
00F4: GOTO 125
.................... {
.................... GO(L, B, abs(Lmotor));
00F5: MOVF 01,W
00F6: MOVWF 40
00F7: MOVF 26,W
00F8: MOVWF 7A
00F9: MOVF 25,W
00FA: BTFSS 26.7
00FB: GOTO 105
00FC: MOVF 25,W
00FD: SUBLW 00
00FE: MOVWF 77
00FF: CLRF 7A
0100: MOVF 26,W
0101: BTFSS 03.0
0102: INCFSZ 26,W
0103: SUBWF 7A,F
0104: MOVF 77,W
0105: MOVWF 78
0106: BTFSS 40.7
0107: GOTO 10B
0108: BTFSS 7A.7
0109: GOTO 114
010A: GOTO 10D
010B: BTFSC 7A.7
010C: GOTO 11D
010D: MOVF 7A,F
010E: BTFSS 03.2
010F: GOTO 114
0110: MOVF 40,W
0111: SUBWF 78,W
0112: BTFSS 03.0
0113: GOTO 11D
0114: BSF 03.5
0115: BCF 05.0
0116: BCF 03.5
0117: BCF 05.0
0118: BSF 03.5
0119: BCF 05.1
011A: BCF 03.5
011B: BSF 05.1
011C: GOTO 125
011D: BSF 03.5
011E: BCF 05.0
011F: BCF 03.5
0120: BCF 05.0
0121: BSF 03.5
0122: BCF 05.1
0123: BCF 03.5
0124: BCF 05.1
.................... }
.................... }
0125: MOVLW 55
0126: MOVWF 35
0127: MOVLW 00
0128: MOVWF 36
0129: BCF 0A.3
012A: GOTO 236
012B: RETLW 00
.................... ////////////////////////////////////////////////////////////////////////////////
.................... #task (rate=4ms, max=500us, queue=0)
.................... void rizeni()
.................... {
.................... rizeni:
....................
.................... sensors = spi_read(0); // cteni senzoru na caru
012C: MOVF 13,W
012D: CLRF 13
012E: BSF 03.5
012F: BTFSC 14.0
0130: GOTO 133
0131: BCF 03.5
0132: GOTO 12E
0133: BCF 03.5
0134: MOVF 13,W
0135: MOVWF 21
.................... output_high(STROBE);
0136: BSF 03.5
0137: BCF 06.0
0138: BCF 03.5
0139: BSF 06.0
.................... output_low(STROBE);
013A: BSF 03.5
013B: BCF 06.0
013C: BCF 03.5
013D: BCF 06.0
....................
.................... if(bit_test(sensors,0)) //*......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
013E: BTFSS 21.0
013F: GOTO 148
.................... {
.................... uhel=LMAX;
0140: MOVLW BE
0141: MOVWF 24
.................... Lmotor=0;Rmotor=127;
0142: CLRF 26
0143: CLRF 25
0144: CLRF 28
0145: MOVLW 7F
0146: MOVWF 27
.................... goto rizeni;
0147: GOTO 12C
.................... }
.................... if(bit_test(sensors,6)) //......*//
0148: BTFSS 21.6
0149: GOTO 152
.................... {
.................... uhel=RMAX;
014A: MOVLW 3C
014B: MOVWF 24
.................... Rmotor=0;Lmotor=127;
014C: CLRF 28
014D: CLRF 27
014E: CLRF 26
014F: MOVLW 7F
0150: MOVWF 25
.................... goto rizeni;
0151: GOTO 12C
.................... }
.................... if(bit_test(sensors,1)) //.*.....//
0152: BTFSS 21.1
0153: GOTO 15D
.................... {
.................... uhel=STRED+30;
0154: MOVLW 9E
0155: MOVWF 24
.................... Lmotor=70;Rmotor=127;
0156: CLRF 26
0157: MOVLW 46
0158: MOVWF 25
0159: CLRF 28
015A: MOVLW 7F
015B: MOVWF 27
.................... goto rizeni;
015C: GOTO 12C
.................... }
.................... if(bit_test(sensors,5)) //.....*.//
015D: BTFSS 21.5
015E: GOTO 168
.................... {
.................... uhel=STRED-30;
015F: MOVLW 62
0160: MOVWF 24
.................... Rmotor=70;Lmotor=127;
0161: CLRF 28
0162: MOVLW 46
0163: MOVWF 27
0164: CLRF 26
0165: MOVLW 7F
0166: MOVWF 25
.................... goto rizeni;
0167: GOTO 12C
.................... }
.................... if(bit_test(sensors,2)) //..*....//
0168: BTFSS 21.2
0169: GOTO 173
.................... {
.................... uhel=STRED+20;
016A: MOVLW 94
016B: MOVWF 24
.................... Lmotor=90;Rmotor=127;
016C: CLRF 26
016D: MOVLW 5A
016E: MOVWF 25
016F: CLRF 28
0170: MOVLW 7F
0171: MOVWF 27
.................... goto rizeni;
0172: GOTO 12C
.................... }
.................... if(bit_test(sensors,4)) //....*..//
0173: BTFSS 21.4
0174: GOTO 17E
.................... {
.................... uhel=STRED-20;
0175: MOVLW 6C
0176: MOVWF 24
.................... Rmotor=90;Lmotor=127;
0177: CLRF 28
0178: MOVLW 5A
0179: MOVWF 27
017A: CLRF 26
017B: MOVLW 7F
017C: MOVWF 25
.................... goto rizeni;
017D: GOTO 12C
.................... }
.................... if(bit_test(sensors,3)) //...*...//
017E: BTFSS 21.3
017F: GOTO 188
.................... {
.................... uhel=STRED;
0180: MOVLW 80
0181: MOVWF 24
.................... Lmotor=100;Rmotor=100;
0182: CLRF 26
0183: MOVLW 64
0184: MOVWF 25
0185: CLRF 28
0186: MOVWF 27
.................... goto rizeni;
0187: GOTO 12C
.................... }
....................
.................... /*STOPL;STOPR;
.................... if(bit_test(sensors,7))
.................... {
....................
.................... }*/
.................... }
0188: MOVLW 2C
0189: MOVWF 3C
018A: MOVLW 01
018B: MOVWF 3D
018C: BCF 0A.3
018D: GOTO 236
018E: RETLW 00
.................... ////////////////////////////////////////////////////////////////////////////////
.................... void main()
.................... {
018F: CLRF 04
0190: MOVLW 1F
0191: ANDWF 03,F
0192: MOVLW 70
0193: BSF 03.5
0194: MOVWF 0F
0195: BCF 1F.4
0196: BCF 1F.5
0197: MOVF 1B,W
0198: ANDLW 80
0199: MOVWF 1B
019A: MOVLW 07
019B: MOVWF 1C
.................... setup_adc_ports(NO_ANALOGS);
019C: BCF 1F.4
019D: BCF 1F.5
019E: MOVF 1B,W
019F: ANDLW 80
01A0: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
01A1: BCF 1F.6
01A2: BCF 03.5
01A3: BSF 1F.6
01A4: BSF 1F.7
01A5: BSF 03.5
01A6: BCF 1F.7
01A7: BCF 03.5
01A8: BSF 1F.0
.................... setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4);
01A9: BCF 14.5
01AA: BSF 03.5
01AB: BCF 06.2
01AC: BSF 06.1
01AD: BCF 06.4
01AE: MOVLW 30
01AF: BCF 03.5
01B0: MOVWF 14
01B1: MOVLW 00
01B2: BSF 03.5
01B3: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
01B4: MOVF 01,W
01B5: ANDLW C7
01B6: IORLW 08
01B7: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
01B8: BCF 03.5
01B9: CLRF 10
.................... setup_oscillator(OSC_8MHZ|OSC_INTRC);
01BA: MOVLW 72
01BB: BSF 03.5
01BC: MOVWF 0F
.................... // set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
.................... // setup_ccp1(CCP_PWM);
.................... // setup_timer_2(T2_DIV_BY_16,200,1); // perioda
.................... // setup_timer_2(T2_DIV_BY_4,255,10); // Casovac pro regulaci
....................
.................... STOPR; STOPL;
01BD: BCF 05.6
01BE: BCF 03.5
01BF: BCF 05.6
01C0: BSF 03.5
01C1: BCF 05.7
01C2: BCF 03.5
01C3: BCF 05.7
01C4: BSF 03.5
01C5: BCF 05.0
01C6: BCF 03.5
01C7: BCF 05.0
01C8: BSF 03.5
01C9: BCF 05.1
01CA: BCF 03.5
01CB: BCF 05.1
.................... uhel=STRED;
01CC: MOVLW 80
01CD: MOVWF 24
.................... // diagnostika();
.................... Lmotor=0;
01CE: CLRF 26
01CF: CLRF 25
.................... Rmotor=0;
01D0: CLRF 28
01D1: CLRF 27
.................... rtos_run();
01D2: CLRF 29
01D3: CLRF 2B
01D4: MOVLW 08
01D5: MOVWF 2A
01D6: CLRF 2D
01D7: MOVLW 01
01D8: MOVWF 2C
01D9: MOVLW 38
01DA: MOVWF 2E
01DB: MOVLW 00
01DC: MOVWF 2F
01DD: CLRF 30
01DE: CLRF 32
01DF: MOVLW 01
01E0: MOVWF 31
01E1: CLRF 34
01E2: CLRF 33
01E3: MOVLW 55
01E4: MOVWF 35
01E5: MOVLW 00
01E6: MOVWF 36
01E7: CLRF 37
01E8: CLRF 39
01E9: MOVLW 02
01EA: MOVWF 38
01EB: CLRF 3B
01EC: CLRF 3A
01ED: MOVLW 2C
01EE: MOVWF 3C
01EF: MOVLW 01
01F0: MOVWF 3D
01F1: CLRF 20
01F2: MOVLW 00
01F3: MOVWF 78
01F4: IORLW 06
01F5: MOVWF 12
01F6: MOVLW FA
01F7: BSF 03.5
01F8: MOVWF 12
01F9: BCF 03.5
01FA: BCF 0C.1
01FB: MOVLW 00
01FC: MOVWF 78
01FD: IORLW 06
01FE: MOVWF 12
01FF: MOVLW FA
0200: BSF 03.5
0201: MOVWF 12
0202: BCF 03.5
0203: BCF 0C.1
0204: BCF 03.0
0205: RLF 20,W
0206: MOVWF 77
0207: CALL 004
0208: MOVWF 79
0209: MOVLW 01
020A: ADDWF 77,W
020B: CALL 004
020C: MOVWF 7A
020D: MOVF 79,W
020E: MOVWF 04
020F: MOVF 00,W
0210: MOVWF 79
0211: INCF 04,F
0212: MOVF 00,W
0213: MOVWF 77
0214: INCF 04,F
0215: MOVF 00,W
0216: MOVWF 78
0217: INCF 04,F
0218: INCF 00,F
0219: MOVF 00,W
021A: MOVWF 7A
021B: BTFSS 03.2
021C: GOTO 220
021D: INCF 04,F
021E: INCF 00,F
021F: DECF 04,F
0220: INCF 04,F
0221: MOVF 00,W
0222: SUBWF 78,W
0223: BTFSS 03.2
0224: GOTO 238
0225: MOVF 77,W
0226: SUBWF 7A,W
0227: BTFSS 03.2
0228: GOTO 238
0229: DECF 04,F
022A: CLRF 00
022B: INCF 04,F
022C: CLRF 00
022D: INCF 04,F
022E: BTFSC 79.7
022F: GOTO 238
0230: INCF 04,F
0231: MOVF 00,W
0232: MOVWF 0A
0233: DECF 04,F
0234: MOVF 00,W
0235: MOVWF 02
0236: BCF 03.5
0237: BCF 03.6
0238: INCF 20,F
0239: MOVLW 03
023A: SUBWF 20,W
023B: BTFSS 03.2
023C: GOTO 204
023D: CLRF 20
023E: BTFSS 0C.1
023F: GOTO 242
0240: BSF 03.5
0241: GOTO 202
0242: GOTO 23E
0243: MOVLW FF
0244: MOVWF 20
....................
.................... }
0245: SLEEP
Configuration Fuses:
Word 1: 3FF8 NOWDT NOPUT MCLR BROWNOUT LVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
Word 2: 3FFF FCMEN IESO