0,0 → 1,1025 |
CCS PCM C Compiler, Version 3.245, 27853 20-IX-06 03:03 |
|
Filename: D:\KAKL\roboti\solarni\2006\scamnum\menic.lst |
|
ROM used: 769 words (19%) |
Largest free fragment is 2048 |
RAM used: 76 (43%) at main() level |
82 (47%) worst case |
Stack: 3 locations |
|
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 189 |
0003: NOP |
.................... // ************************************* |
.................... // * Scamnum Specularis ** 20. 9. 2006 * |
.................... // ************************************* |
.................... |
.................... #include ".\menic.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, DEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3 |
.................... |
.................... #use delay(clock=3900000,RESTART_WDT) |
* |
0004: MOVLW 66 |
0005: MOVWF 04 |
0006: MOVF 00,W |
0007: BTFSC 03.2 |
0008: GOTO 019 |
0009: MOVLW 01 |
000A: MOVWF 78 |
000B: MOVLW BF |
000C: MOVWF 77 |
000D: CLRWDT |
000E: DECFSZ 77,F |
000F: GOTO 00D |
0010: DECFSZ 78,F |
0011: GOTO 00B |
0012: MOVLW 42 |
0013: MOVWF 77 |
0014: DECFSZ 77,F |
0015: GOTO 014 |
0016: CLRWDT |
0017: DECFSZ 00,F |
0018: GOTO 009 |
0019: RETLW 00 |
* |
0176: MOVLW 12 |
0177: SUBWF 66,F |
0178: BTFSS 03.0 |
0179: GOTO 188 |
017A: MOVLW 66 |
017B: MOVWF 04 |
017C: MOVLW FC |
017D: ANDWF 00,F |
017E: BCF 03.0 |
017F: RRF 00,F |
0180: RRF 00,F |
0181: MOVF 00,W |
0182: BTFSC 03.2 |
0183: GOTO 188 |
0184: GOTO 186 |
0185: CLRWDT |
0186: DECFSZ 00,F |
0187: GOTO 185 |
0188: RETLW 00 |
.................... |
.................... |
.................... |
.................... #define TXo PIN_B5 // To the transmitter modulator |
.................... #include ".\AX25.c" // Podprogram pro prenos telemetrie |
.................... //#define PTT PIN_A2 // PTT control |
.................... //#define TXo PIN_C0 // To the transmitter modulator |
.................... //#define PERIODAH delay_us(218) // Halfperiod H 222;78/1200 500;430/500 |
.................... //#define TAILH delay_us(74) |
.................... //#define PERIODAL delay_us(408) // Halfperiod L 412;345/1200 1000;880/500 |
.................... //#define TAILL delay_us(341) |
.................... #define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500 |
.................... #define TAILH delay_us(78) |
.................... #define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500 |
.................... #define TAILL delay_us(345) |
.................... #byte STATUS = 3 // CPUs status register |
.................... |
.................... byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60, |
.................... 'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61, |
.................... 0x03, 0xF0}; |
* |
0194: MOVLW 82 |
0195: BCF 03.5 |
0196: MOVWF 20 |
0197: MOVLW 98 |
0198: MOVWF 21 |
0199: MOVWF 22 |
019A: MOVLW 40 |
019B: MOVWF 23 |
019C: MOVWF 24 |
019D: MOVWF 25 |
019E: MOVLW 60 |
019F: MOVWF 26 |
01A0: MOVLW 86 |
01A1: MOVWF 27 |
01A2: MOVLW B4 |
01A3: MOVWF 28 |
01A4: MOVLW 60 |
01A5: MOVWF 29 |
01A6: MOVLW A4 |
01A7: MOVWF 2A |
01A8: MOVWF 2B |
01A9: MOVWF 2C |
01AA: MOVLW 61 |
01AB: MOVWF 2D |
01AC: MOVLW 03 |
01AD: MOVWF 2E |
01AE: MOVLW F0 |
01AF: MOVWF 2F |
.................... |
.................... boolean bit; |
.................... int fcslo, fcshi; // variabloes for calculating FCS (CRC) |
.................... int stuff; // stuff counter for extra 0 |
.................... int flag_flag; // if it is sending flag (7E) |
.................... int fcs_flag; // if it is sending Frame Check Sequence |
.................... int i; // for for |
.................... |
.................... void flipout() //flips the state of output pin a_1 |
.................... { |
.................... stuff = 0; //since this is a 0, reset the stuff counter |
* |
00A3: CLRF 33 |
.................... if (bit) |
00A4: BTFSS 30.0 |
00A5: GOTO 0A8 |
.................... { |
.................... bit=FALSE; //if the state of the pin was low, make it high. |
00A6: BCF 30.0 |
.................... } |
.................... else |
00A7: GOTO 0A9 |
.................... { |
.................... bit=TRUE; //if the state of the pin was high make it low |
00A8: BSF 30.0 |
.................... } |
.................... } |
00A9: RETLW 00 |
.................... |
.................... void fcsbit(byte tbyte) |
.................... { |
.................... #asm |
.................... BCF STATUS,0 |
* |
0105: BCF 03.0 |
.................... RRF fcshi,F // rotates the entire 16 bits |
0106: RRF 32,F |
.................... RRF fcslo,F // to the right |
0107: RRF 31,F |
.................... #endasm |
.................... if (((STATUS & 0x01)^(tbyte)) ==0x01) |
0108: MOVF 03,W |
0109: ANDLW 01 |
010A: XORWF 6A,W |
010B: SUBLW 01 |
010C: BTFSS 03.2 |
010D: GOTO 112 |
.................... { |
.................... fcshi = fcshi^0x84; |
010E: MOVLW 84 |
010F: XORWF 32,F |
.................... fcslo = fcslo^0x08; |
0110: MOVLW 08 |
0111: XORWF 31,F |
.................... } |
.................... } |
.................... |
.................... void SendBit () |
.................... { |
.................... if (bit) |
* |
00AA: BTFSS 30.0 |
00AB: GOTO 0D6 |
.................... { |
.................... output_low(TXo); |
00AC: BSF 03.5 |
00AD: BCF 06.5 |
00AE: BCF 03.5 |
00AF: BCF 06.5 |
.................... PERIODAH; |
00B0: CLRWDT |
00B1: MOVLW 47 |
00B2: MOVWF 77 |
00B3: DECFSZ 77,F |
00B4: GOTO 0B3 |
00B5: NOP |
.................... output_high(TXo); |
00B6: BSF 03.5 |
00B7: BCF 06.5 |
00B8: BCF 03.5 |
00B9: BSF 06.5 |
.................... PERIODAH; |
00BA: CLRWDT |
00BB: MOVLW 47 |
00BC: MOVWF 77 |
00BD: DECFSZ 77,F |
00BE: GOTO 0BD |
00BF: NOP |
.................... output_low(TXo); |
00C0: BSF 03.5 |
00C1: BCF 06.5 |
00C2: BCF 03.5 |
00C3: BCF 06.5 |
.................... PERIODAH; |
00C4: CLRWDT |
00C5: MOVLW 47 |
00C6: MOVWF 77 |
00C7: DECFSZ 77,F |
00C8: GOTO 0C7 |
00C9: NOP |
.................... output_high(TXo); |
00CA: BSF 03.5 |
00CB: BCF 06.5 |
00CC: BCF 03.5 |
00CD: BSF 06.5 |
.................... TAILH; |
00CE: CLRWDT |
00CF: MOVLW 18 |
00D0: MOVWF 77 |
00D1: DECFSZ 77,F |
00D2: GOTO 0D1 |
00D3: NOP |
00D4: NOP |
.................... } |
.................... else |
00D5: GOTO 0E9 |
.................... { |
.................... output_low(TXo); |
00D6: BSF 03.5 |
00D7: BCF 06.5 |
00D8: BCF 03.5 |
00D9: BCF 06.5 |
.................... PERIODAL; |
00DA: CLRWDT |
00DB: MOVLW 85 |
00DC: MOVWF 77 |
00DD: DECFSZ 77,F |
00DE: GOTO 0DD |
.................... output_high(TXo); |
00DF: BSF 03.5 |
00E0: BCF 06.5 |
00E1: BCF 03.5 |
00E2: BSF 06.5 |
.................... TAILL; |
00E3: CLRWDT |
00E4: MOVLW 6F |
00E5: MOVWF 77 |
00E6: DECFSZ 77,F |
00E7: GOTO 0E6 |
00E8: NOP |
.................... }; |
.................... } |
00E9: RETLW 00 |
.................... |
.................... void SendByte (byte inbyte) |
.................... { |
.................... int k, bt; |
.................... |
.................... for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte |
00EA: CLRF 68 |
00EB: MOVF 68,W |
00EC: SUBLW 07 |
00ED: BTFSS 03.0 |
00EE: GOTO 132 |
.................... { |
.................... bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte) |
00EF: MOVF 67,W |
00F0: ANDLW 01 |
00F1: MOVWF 69 |
.................... if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this |
00F2: MOVF 35,F |
00F3: BTFSC 03.2 |
00F4: GOTO 0F7 |
00F5: MOVLW 00 |
00F6: GOTO 0F8 |
00F7: MOVLW 01 |
00F8: MOVWF 6A |
00F9: MOVF 34,F |
00FA: BTFSC 03.2 |
00FB: GOTO 0FE |
00FC: MOVLW 00 |
00FD: GOTO 0FF |
00FE: MOVLW 01 |
00FF: ANDWF 6A,W |
0100: XORLW 00 |
0101: BTFSC 03.2 |
0102: GOTO 112 |
0103: MOVF 69,W |
0104: MOVWF 6A |
.................... //is not a flag or fcs byte |
.................... if (bt == 0) |
* |
0112: MOVF 69,F |
0113: BTFSS 03.2 |
0114: GOTO 117 |
.................... { |
.................... flipout(); |
0115: CALL 0A3 |
.................... } // if this bit is a zero, flip the output state |
.................... else |
0116: GOTO 12D |
.................... { //otherwise if it is a 1, do the following: |
.................... if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's |
0117: MOVF 34,F |
0118: BTFSC 03.2 |
0119: INCF 33,F |
.................... if ((flag_flag == FALSE) & (stuff == 5)) |
011A: MOVF 34,F |
011B: BTFSC 03.2 |
011C: GOTO 11F |
011D: MOVLW 00 |
011E: GOTO 120 |
011F: MOVLW 01 |
0120: MOVWF 6A |
0121: MOVF 33,W |
0122: SUBLW 05 |
0123: BTFSC 03.2 |
0124: GOTO 127 |
0125: MOVLW 00 |
0126: GOTO 128 |
0127: MOVLW 01 |
0128: ANDWF 6A,W |
0129: BTFSC 03.2 |
012A: GOTO 12D |
.................... { //stuff an extra 0, if 5 1's in a row |
.................... SendBit(); |
012B: CALL 0AA |
.................... flipout(); //flip the output state to stuff a 0 |
012C: CALL 0A3 |
.................... }//end of if |
.................... }//end of else |
.................... // delay_us(850); //introduces a delay that creates 1200 baud |
.................... SendBit(); |
012D: CALL 0AA |
.................... inbyte = inbyte>>1; //go to the next bit in the byte |
012E: BCF 03.0 |
012F: RRF 67,F |
.................... }//end of for |
0130: INCF 68,F |
0131: GOTO 0EB |
.................... }//end of SendByte |
0132: RETLW 00 |
.................... |
.................... void SendPacket(char *data) |
.................... { |
.................... bit=FALSE; |
0133: BCF 30.0 |
.................... |
.................... fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF |
0134: MOVLW FF |
0135: MOVWF 32 |
0136: MOVWF 31 |
.................... stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5 |
0137: CLRF 33 |
.................... // it is time to stuff a 0. |
.................... |
.................... // output_low(PTT); // Blinking LED |
.................... // delay_ms(1000); |
.................... // output_high(PTT); |
.................... |
.................... flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise. |
0138: MOVLW 01 |
0139: MOVWF 34 |
.................... fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise. |
013A: CLRF 35 |
.................... |
.................... for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay |
013B: CLRF 36 |
013C: MOVF 36,W |
013D: SUBLW 09 |
013E: BTFSS 03.0 |
013F: GOTO 145 |
0140: MOVLW 7E |
0141: MOVWF 67 |
0142: CALL 0EA |
0143: INCF 36,F |
0144: GOTO 13C |
.................... //each flag takes approx 6.7 ms |
.................... flag_flag = FALSE; //done sending flags |
0145: CLRF 34 |
.................... |
.................... for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes |
0146: CLRF 36 |
0147: MOVF 36,W |
0148: SUBLW 0F |
0149: BTFSS 03.0 |
014A: GOTO 154 |
014B: MOVLW 20 |
014C: ADDWF 36,W |
014D: MOVWF 04 |
014E: MOVF 00,W |
014F: MOVWF 66 |
0150: MOVWF 67 |
0151: CALL 0EA |
0152: INCF 36,F |
0153: GOTO 147 |
.................... |
.................... for(i=0; 0 != *data; i++) |
0154: CLRF 36 |
0155: MOVF 65,W |
0156: MOVWF 04 |
0157: MOVF 00,W |
0158: BTFSC 03.2 |
0159: GOTO 163 |
.................... { |
.................... SendByte(*data); //send the packet bytes |
015A: MOVF 65,W |
015B: MOVWF 04 |
015C: MOVF 00,W |
015D: MOVWF 66 |
015E: MOVWF 67 |
015F: CALL 0EA |
.................... data++; |
0160: INCF 65,F |
.................... }; |
0161: INCF 36,F |
0162: GOTO 155 |
.................... |
.................... fcs_flag = TRUE; //about to send the FCS bytes |
0163: MOVLW 01 |
0164: MOVWF 35 |
.................... fcslo =fcslo^0xff; //must XOR them with FF before sending |
0165: MOVLW FF |
0166: XORWF 31,F |
.................... fcshi = fcshi^0xff; |
0167: XORWF 32,F |
.................... SendByte(fcslo); //send the low byte of fcs |
0168: MOVF 31,W |
0169: MOVWF 67 |
016A: CALL 0EA |
.................... SendByte(fcshi); //send the high byte of fcs |
016B: MOVF 32,W |
016C: MOVWF 67 |
016D: CALL 0EA |
.................... fcs_flag = FALSE; //done sending FCS |
016E: CLRF 35 |
.................... flag_flag = TRUE; //about to send flags |
016F: MOVLW 01 |
0170: MOVWF 34 |
.................... SendByte(0x7e); // Send a flag to end packet |
0171: MOVLW 7E |
0172: MOVWF 67 |
0173: CALL 0EA |
.................... } |
0174: BCF 0A.3 |
0175: GOTO 2C2 (RETURN) |
.................... |
.................... |
.................... |
.................... |
.................... char AXstring[40]; // Buffer pro prenos telemetrie |
.................... |
.................... #define REFSTART 95 // Hodnota odpovidajici 1,2V pri nezatizenych clancich |
.................... #define DUTY1 2 // Delka sepnuti PWM v us pro sero |
.................... #define DUTY2 19 // Delka sepnuti PWM v us pro jednu zarovku 500W |
.................... |
.................... // Tabulka hodnot prevodniku pro ruzna napajeci napeti |
.................... // 80 3,99V |
.................... // 90 3,54V |
.................... // 100 3,20V |
.................... // 105 3,04V |
.................... // 107 2,99V |
.................... // 110 2,91v |
.................... // 200 1,61V |
.................... |
.................... #define PIEZO PIN_A6 // Jeden pol piezo reproduktoru |
.................... #define LED PIN_A7 // LED / druhy pol piezo reproduktoru |
.................... #define MENIC PIN_B3 // Spinani tranzistoru menice |
.................... #define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti |
.................... #define MOTOR PIN_B2 // Spinani tranzistoru motoru |
.................... #define SW1 PIN_B6 // DIPswitch 1 |
.................... #define SW2 PIN_B7 // DIPswitch 2 |
.................... #define NAPETI 4 // Cislo kanalu DA prevodniku pro mereni napeti |
.................... #define PWM 0 // Cislo kanalu DA prevodniku pro nastaveni PWM |
.................... #define ROZJEZD 1 // Cislo kanalu DA prevodniku pro nastaveni rozjezdu |
.................... |
.................... void pip() // pipnuti a bliknuti |
.................... { |
.................... int1 beep; |
.................... int i; |
.................... |
.................... for(i=0; i<250; i++) |
* |
0027: CLRF 66 |
0028: MOVF 66,W |
0029: SUBLW F9 |
002A: BTFSS 03.0 |
002B: GOTO 047 |
.................... { |
.................... output_bit(PIEZO, beep); |
002C: BTFSC 65.0 |
002D: GOTO 030 |
002E: BCF 05.6 |
002F: GOTO 031 |
0030: BSF 05.6 |
0031: BSF 03.5 |
0032: BCF 05.6 |
.................... beep=~beep; |
0033: MOVLW 01 |
0034: BCF 03.5 |
0035: XORWF 65,F |
.................... output_bit(LED, beep); |
0036: BTFSC 65.0 |
0037: GOTO 03A |
0038: BCF 05.7 |
0039: GOTO 03B |
003A: BSF 05.7 |
003B: BSF 03.5 |
003C: BCF 05.7 |
.................... delay_us(100); |
003D: CLRWDT |
003E: MOVLW 1F |
003F: MOVWF 77 |
0040: DECFSZ 77,F |
0041: GOTO 040 |
0042: NOP |
0043: NOP |
.................... }; |
0044: BCF 03.5 |
0045: INCF 66,F |
0046: GOTO 028 |
.................... output_high(PIEZO); |
0047: BSF 03.5 |
0048: BCF 05.6 |
0049: BCF 03.5 |
004A: BSF 05.6 |
.................... output_high(LED); |
004B: BSF 03.5 |
004C: BCF 05.7 |
004D: BCF 03.5 |
004E: BSF 05.7 |
.................... } |
004F: BCF 0A.3 |
0050: GOTO 276 (RETURN) |
.................... |
.................... void cvak() // pouze cvaknuti piezoelementem bez bliknuti |
.................... { |
.................... output_bit(PIEZO,~input(PIEZO)); |
* |
001A: BSF 03.5 |
001B: BSF 05.6 |
001C: BCF 03.5 |
001D: BTFSS 05.6 |
001E: GOTO 021 |
001F: BCF 05.6 |
0020: GOTO 022 |
0021: BSF 05.6 |
0022: BSF 03.5 |
0023: BCF 05.6 |
.................... } |
0024: BCF 03.5 |
0025: BCF 0A.3 |
0026: GOTO 229 (RETURN) |
.................... |
.................... void main() |
.................... { |
* |
0189: CLRF 04 |
018A: MOVLW 1F |
018B: ANDWF 03,F |
018C: BSF 03.5 |
018D: BCF 1F.4 |
018E: BCF 1F.5 |
018F: MOVF 1B,W |
0190: ANDLW 80 |
0191: MOVWF 1B |
0192: MOVLW 07 |
0193: MOVWF 1C |
.................... int8 n; |
.................... int8 perioda; |
.................... int8 razeni; |
.................... int8 uclanku; |
.................... int8 ble; |
.................... |
.................... setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_1152MS); |
* |
01B1: BSF 03.5 |
01B2: MOVF 01,W |
01B3: ANDLW C0 |
01B4: MOVWF 01 |
01B5: MOVLW 0E |
01B6: MOVWF 77 |
01B7: MOVLW 07 |
01B8: BCF 03.5 |
01B9: CLRF 01 |
01BA: MOVLW 81 |
01BB: MOVWF 04 |
01BC: MOVF 00,W |
01BD: ANDLW F0 |
01BE: IORLW 07 |
01BF: MOVWF 00 |
01C0: CLRWDT |
01C1: MOVF 00,W |
01C2: ANDLW F7 |
01C3: BTFSC 77.3 |
01C4: ANDLW F0 |
01C5: IORWF 77,W |
01C6: MOVWF 00 |
.................... setup_timer_1(T1_DISABLED); |
01C7: CLRF 10 |
.................... setup_adc_ports(ADC_CLOCK_INTERNAL|sAN0|sAN1|sAN4|VSS_VDD); |
01C8: BSF 03.5 |
01C9: BCF 1F.4 |
01CA: BCF 1F.5 |
01CB: MOVF 1B,W |
01CC: ANDLW 80 |
01CD: IORLW D3 |
01CE: MOVWF 1B |
.................... setup_adc(ADC_CLOCK_INTERNAL); |
01CF: BCF 1F.6 |
01D0: BCF 03.5 |
01D1: BSF 1F.6 |
01D2: BSF 1F.7 |
01D3: BSF 03.5 |
01D4: BCF 1F.7 |
01D5: BCF 03.5 |
01D6: BSF 1F.0 |
.................... setup_spi(FALSE); |
01D7: BCF 14.5 |
01D8: BSF 03.5 |
01D9: BCF 06.2 |
01DA: BSF 06.1 |
01DB: BCF 06.4 |
01DC: MOVLW 00 |
01DD: BCF 03.5 |
01DE: MOVWF 14 |
01DF: BSF 03.5 |
01E0: MOVWF 14 |
.................... setup_comparator(NC_NC_NC_NC); |
01E1: MOVLW 07 |
01E2: MOVWF 1C |
01E3: MOVF 05,W |
01E4: CLRWDT |
01E5: MOVLW 02 |
01E6: MOVWF 77 |
01E7: DECFSZ 77,F |
01E8: GOTO 1E7 |
01E9: NOP |
01EA: MOVF 1C,W |
01EB: BCF 03.5 |
01EC: BCF 0D.6 |
.................... setup_vref(FALSE); |
01ED: BSF 03.5 |
01EE: CLRF 1D |
.................... |
.................... output_low(MENIC); // Vsechno zastav |
01EF: BCF 06.3 |
01F0: BCF 03.5 |
01F1: BCF 06.3 |
.................... output_low(MOTOR); |
01F2: BSF 03.5 |
01F3: BCF 06.2 |
01F4: BCF 03.5 |
01F5: BCF 06.2 |
.................... output_low(REFPWR); |
01F6: BSF 03.5 |
01F7: BCF 06.1 |
01F8: BCF 03.5 |
01F9: BCF 06.1 |
.................... output_high(LED); |
01FA: BSF 03.5 |
01FB: BCF 05.7 |
01FC: BCF 03.5 |
01FD: BSF 05.7 |
.................... output_high(PIEZO); |
01FE: BSF 03.5 |
01FF: BCF 05.6 |
0200: BCF 03.5 |
0201: BSF 05.6 |
.................... |
.................... set_adc_channel(NAPETI); // Vyber AD kanal pro pomerne mereni napeti |
0202: MOVLW 20 |
0203: MOVWF 78 |
0204: MOVF 1F,W |
0205: ANDLW C7 |
0206: IORWF 78,W |
0207: MOVWF 1F |
.................... set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu |
0208: CLRF 15 |
.................... setup_ccp1(CCP_PWM); |
0209: BSF 03.5 |
020A: BCF 06.3 |
020B: BCF 03.5 |
020C: BCF 06.3 |
020D: MOVLW 0C |
020E: MOVWF 17 |
.................... setup_timer_2(T2_DIV_BY_1,100,1); // perioda |
020F: MOVLW 00 |
0210: MOVWF 78 |
0211: IORLW 04 |
0212: MOVWF 12 |
0213: MOVLW 64 |
0214: BSF 03.5 |
0215: MOVWF 12 |
.................... |
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber) |
0216: MOVLW 62 |
0217: MOVWF 0F |
.................... |
.................... // jsme v depu? |
.................... set_pwm1_duty(DUTY1); // PWM pro zatizeni clanku pri malem osvetleni |
0218: MOVLW 02 |
0219: BCF 03.5 |
021A: MOVWF 15 |
.................... n=0; |
021B: CLRF 60 |
.................... do |
.................... { |
.................... output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo |
021C: BSF 03.5 |
021D: BCF 06.1 |
021E: BCF 03.5 |
021F: BCF 06.1 |
.................... delay_ms(100); |
0220: MOVLW 64 |
0221: MOVWF 66 |
0222: CALL 004 |
.................... if (4==n++) {cvak(); n=0;}; // Kazdy 4. pruchod cvakni |
0223: MOVF 60,W |
0224: INCF 60,F |
0225: SUBLW 04 |
0226: BTFSS 03.2 |
0227: GOTO 22A |
0228: GOTO 01A |
0229: CLRF 60 |
.................... output_high(REFPWR); // Zapni napajeni napetove reference |
022A: BSF 03.5 |
022B: BCF 06.1 |
022C: BCF 03.5 |
022D: BSF 06.1 |
.................... delay_ms(1); // Pockej na ustaleni napeti |
022E: MOVLW 01 |
022F: MOVWF 66 |
0230: CALL 004 |
.................... } while (read_adc()>REFSTART); // Odkryl starter clanky? |
0231: BSF 1F.2 |
0232: BTFSC 1F.2 |
0233: GOTO 232 |
0234: MOVF 1E,W |
0235: SUBLW 5F |
0236: BTFSS 03.0 |
0237: GOTO 21C |
.................... output_low(REFPWR); // Vypni napajeni napetove reference, aby se setrilo |
0238: BSF 03.5 |
0239: BCF 06.1 |
023A: BCF 03.5 |
023B: BCF 06.1 |
.................... |
.................... // port_b_pullups(TRUE); // Zapni pullupy, aby slo cist DIPswitch |
.................... // do |
.................... // { |
.................... // Precti trimry |
.................... set_adc_channel(PWM); // Zjisteni nastaveni PWM |
023C: MOVLW 00 |
023D: MOVWF 78 |
023E: MOVF 1F,W |
023F: ANDLW C7 |
0240: IORWF 78,W |
0241: MOVWF 1F |
.................... delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku |
0242: CLRWDT |
0243: MOVLW 1F |
0244: MOVWF 77 |
0245: DECFSZ 77,F |
0246: GOTO 245 |
0247: NOP |
0248: NOP |
.................... perioda=(read_adc()>>2)+40; // rozsah: 40 az 103 |
0249: BSF 1F.2 |
024A: BTFSC 1F.2 |
024B: GOTO 24A |
024C: MOVF 1E,W |
024D: MOVWF 77 |
024E: RRF 77,F |
024F: RRF 77,F |
0250: MOVLW 3F |
0251: ANDWF 77,F |
0252: MOVF 77,W |
0253: ADDLW 28 |
0254: MOVWF 61 |
.................... |
.................... set_adc_channel(ROZJEZD); // Zjisteni nastaveni rozjezdu |
0255: MOVLW 08 |
0256: MOVWF 78 |
0257: MOVF 1F,W |
0258: ANDLW C7 |
0259: IORWF 78,W |
025A: MOVWF 1F |
.................... delay_us(100); // Pockej na prepnuti kanalu A/D prevodniku |
025B: CLRWDT |
025C: MOVLW 1F |
025D: MOVWF 77 |
025E: DECFSZ 77,F |
025F: GOTO 25E |
0260: NOP |
0261: NOP |
.................... razeni=read_adc()>>4; // rozsah: 0 az 15 |
0262: BSF 1F.2 |
0263: BTFSC 1F.2 |
0264: GOTO 263 |
0265: MOVF 1E,W |
0266: SWAPF 1E,W |
0267: MOVWF 62 |
0268: MOVLW 0F |
0269: ANDWF 62,F |
.................... |
.................... // Rozjeti menice |
.................... set_pwm1_duty(0); // Zastav PWM, aby slo nastavit jinou frekvenci |
026A: CLRF 15 |
.................... setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda |
026B: MOVLW 00 |
026C: MOVWF 78 |
026D: IORLW 04 |
026E: MOVWF 12 |
026F: MOVF 61,W |
0270: BSF 03.5 |
0271: MOVWF 12 |
.................... set_pwm1_duty(DUTY2); // PWM pro zatizeni clanku pri jedne 500W zarovce |
0272: MOVLW 13 |
0273: BCF 03.5 |
0274: MOVWF 15 |
.................... |
.................... pip(); // potvrzeni odstartovani / servisni mod |
0275: GOTO 027 |
.................... delay_ms(500); |
0276: MOVLW 02 |
0277: MOVWF 65 |
0278: MOVLW FA |
0279: MOVWF 66 |
027A: CALL 004 |
027B: DECFSZ 65,F |
027C: GOTO 278 |
.................... |
.................... // } while (input(SW1)); // Je zapnut servisni mod? SW1(OFF)=ANO |
.................... // port_b_pullups(FALSE); // Vypni pullupy, aby se setrilo energii |
.................... |
.................... // zmereni napeti na clancich |
.................... output_high(REFPWR); // Prepni AD na mereni napeti clanku |
027D: BSF 03.5 |
027E: BCF 06.1 |
027F: BCF 03.5 |
0280: BSF 06.1 |
.................... set_adc_channel(NAPETI); // Prepni Zmer napeti clanku |
0281: MOVLW 20 |
0282: MOVWF 78 |
0283: MOVF 1F,W |
0284: ANDLW C7 |
0285: IORWF 78,W |
0286: MOVWF 1F |
.................... delay_us(50); // Pockej na prepnuti kanalu A/D prevodniku |
0287: CLRWDT |
0288: MOVLW 0F |
0289: MOVWF 77 |
028A: DECFSZ 77,F |
028B: GOTO 28A |
028C: NOP |
.................... uclanku=read_adc(); |
028D: BSF 1F.2 |
028E: BTFSC 1F.2 |
028F: GOTO 28E |
0290: MOVF 1E,W |
0291: MOVWF 63 |
.................... output_low(REFPWR); // odpoj odpor pro mereni napeti |
0292: BSF 03.5 |
0293: BCF 06.1 |
0294: BCF 03.5 |
0295: BCF 06.1 |
.................... |
.................... // posli telemetrii |
.................... sprintf(AXstring,"p=%u r=%u u=%u", perioda, razeni, uclanku); // Convert DATA to String. |
* |
01B0: CLRF 5F |
* |
0296: MOVLW 37 |
0297: MOVWF 5F |
0298: MOVLW 70 |
0299: MOVWF 67 |
029A: CALL 051 |
029B: MOVLW 3D |
029C: MOVWF 67 |
029D: CALL 051 |
029E: MOVF 61,W |
029F: MOVWF 65 |
02A0: MOVLW 1B |
02A1: MOVWF 66 |
02A2: CALL 06E |
02A3: MOVLW 20 |
02A4: MOVWF 67 |
02A5: CALL 051 |
02A6: MOVLW 72 |
02A7: MOVWF 67 |
02A8: CALL 051 |
02A9: MOVLW 3D |
02AA: MOVWF 67 |
02AB: CALL 051 |
02AC: MOVF 62,W |
02AD: MOVWF 65 |
02AE: MOVLW 1B |
02AF: MOVWF 66 |
02B0: CALL 06E |
02B1: MOVLW 20 |
02B2: MOVWF 67 |
02B3: CALL 051 |
02B4: MOVLW 75 |
02B5: MOVWF 67 |
02B6: CALL 051 |
02B7: MOVLW 3D |
02B8: MOVWF 67 |
02B9: CALL 051 |
02BA: MOVF 63,W |
02BB: MOVWF 65 |
02BC: MOVLW 1B |
02BD: MOVWF 66 |
02BE: CALL 06E |
.................... SendPacket(&AXstring[0]); |
02BF: MOVLW 37 |
02C0: MOVWF 65 |
02C1: GOTO 133 |
.................... |
.................... delay_ms(14000); // Pockame do 14.5s |
02C2: MOVLW 38 |
02C3: MOVWF 65 |
02C4: MOVLW FA |
02C5: MOVWF 66 |
02C6: CALL 004 |
02C7: DECFSZ 65,F |
02C8: GOTO 2C4 |
.................... |
.................... // rozjezd |
.................... for( ble=1;ble<255;ble++) |
02C9: MOVLW 01 |
02CA: MOVWF 64 |
02CB: INCFSZ 64,W |
02CC: GOTO 2CE |
02CD: GOTO 2EF |
.................... { |
.................... for(n=0;n<=razeni;n++) |
02CE: CLRF 60 |
02CF: MOVF 60,W |
02D0: SUBWF 62,W |
02D1: BTFSS 03.0 |
02D2: GOTO 2ED |
.................... { |
.................... output_high(MOTOR); |
02D3: BSF 03.5 |
02D4: BCF 06.2 |
02D5: BCF 03.5 |
02D6: BSF 06.2 |
.................... delay_us(ble); |
02D7: MOVF 64,W |
02D8: MOVWF 66 |
02D9: CALL 176 |
.................... delay_us(ble); |
02DA: MOVF 64,W |
02DB: MOVWF 66 |
02DC: CALL 176 |
.................... output_low(MOTOR); |
02DD: BSF 03.5 |
02DE: BCF 06.2 |
02DF: BCF 03.5 |
02E0: BCF 06.2 |
.................... delay_us(255-ble); |
02E1: MOVF 64,W |
02E2: SUBLW FF |
02E3: MOVWF 65 |
02E4: MOVWF 66 |
02E5: CALL 176 |
.................... delay_us(255-ble); |
02E6: MOVF 64,W |
02E7: SUBLW FF |
02E8: MOVWF 65 |
02E9: MOVWF 66 |
02EA: CALL 176 |
.................... } |
02EB: INCF 60,F |
02EC: GOTO 2CF |
.................... } |
02ED: INCF 64,F |
02EE: GOTO 2CB |
.................... |
.................... // jedem co to da |
.................... output_high(MOTOR); |
02EF: BSF 03.5 |
02F0: BCF 06.2 |
02F1: BCF 03.5 |
02F2: BSF 06.2 |
.................... |
.................... delay_ms(1300); // Nemeli bysme jet dele nez 1,3s :-) |
02F3: MOVLW 0A |
02F4: MOVWF 65 |
02F5: MOVLW 82 |
02F6: MOVWF 66 |
02F7: CALL 004 |
02F8: DECFSZ 65,F |
02F9: GOTO 2F5 |
.................... output_low(MOTOR); // Zastav motor |
02FA: BSF 03.5 |
02FB: BCF 06.2 |
02FC: BCF 03.5 |
02FD: BCF 06.2 |
.................... // Menic je stale zapnut a zatezuje clanky |
.................... |
.................... reset_cpu(); |
02FE: CLRF 0A |
02FF: GOTO 000 |
.................... } |
0300: SLEEP |
|
Configuration Fuses: |
Word 1: 2738 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT DEBUG CCPB3 NOPROTECT INTRC_IO |
Word 2: 3FFC NOFCMEN NOIESO |