Blame | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.221, 27853 28-VIII-05 19:00
Filename: D:\KAKLIK\programy\PIC_C\roboti\solarni\2005\jump\menic.LST
ROM used: 433 words (11%)
Largest free fragment is 2048
RAM used: 18 (10%) at main() level
19 (11%) worst case
Stack: 2 worst case (1 in main + 1 for interrupts)
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 090
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 7F,W
0009: MOVWF 20
000A: MOVF 0A,W
000B: MOVWF 28
000C: CLRF 0A
000D: SWAPF 20,F
000E: MOVF 04,W
000F: MOVWF 22
0010: MOVF 77,W
0011: MOVWF 23
0012: MOVF 78,W
0013: MOVWF 24
0014: MOVF 79,W
0015: MOVWF 25
0016: MOVF 7A,W
0017: MOVWF 26
0018: MOVF 7B,W
0019: MOVWF 27
001A: BCF 03.7
001B: BCF 03.5
001C: MOVLW 8C
001D: MOVWF 04
001E: BTFSS 00.3
001F: GOTO 022
0020: BTFSC 0C.3
0021: GOTO 035
0022: MOVF 22,W
0023: MOVWF 04
0024: MOVF 23,W
0025: MOVWF 77
0026: MOVF 24,W
0027: MOVWF 78
0028: MOVF 25,W
0029: MOVWF 79
002A: MOVF 26,W
002B: MOVWF 7A
002C: MOVF 27,W
002D: MOVWF 7B
002E: MOVF 28,W
002F: MOVWF 0A
0030: SWAPF 21,W
0031: MOVWF 03
0032: SWAPF 7F,F
0033: SWAPF 7F,W
0034: RETFIE
0035: BCF 0A.3
0036: GOTO 043
.................... #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=4000000)
*
0048: MOVLW 2D
0049: MOVWF 04
004A: MOVF 00,W
004B: BTFSC 03.2
004C: GOTO 05C
004D: MOVLW 01
004E: MOVWF 78
004F: CLRF 77
0050: DECFSZ 77,F
0051: GOTO 050
0052: DECFSZ 78,F
0053: GOTO 04F
0054: MOVLW 4A
0055: MOVWF 77
0056: DECFSZ 77,F
0057: GOTO 056
0058: NOP
0059: NOP
005A: DECFSZ 00,F
005B: GOTO 04D
005C: RETLW 00
....................
....................
....................
.................... #define RAZENI 60 // Po kolika ms se bude menit rychlost pro rozjizdeni
.................... #define REFNOM 107 // Hodnota odpovidajici 1,2V pri nominalnim zatizeni
.................... #define REFSTART 80 // Hodnota odpovidajici 1,2V pri nezatizenych clancich
....................
.................... #define PIEZO PIN_A6 // Jeden pol piezo reproduktoru
.................... #define LED PIN_A7 // LED
.................... #define MENIC PIN_B3 // Spinani tranzistoru menice
.................... #define REFPWR PIN_B1 // Napajeni zdroje referencniho napeti
.................... #define MOTOR PIN_B2 // Spinani tranzistoru motoru
....................
.................... #byte SSPBUF = 0x13 // Registry jednotky SSP
.................... #byte SSPCON1 = 0x14
.................... #byte SSPSTAT = 0x94
....................
.................... // Vzorky pro generovani PWM pomoci SSP
.................... unsigned int8 const Pattern[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff};
.................... unsigned int8 MotorPattern;
....................
.................... #INT_SSP
.................... void IntSSP()
.................... {
.................... SSPBUF=MotorPattern; // znovu vysli stejnou hodnotu
*
0043: MOVF 29,W
0044: MOVWF 13
.................... }
....................
0045: BCF 0C.3
0046: BCF 0A.3
0047: GOTO 022
.................... void pip() // pipnuti a bliknuti
.................... {
.................... int1 beep;
.................... int i;
....................
.................... for(i=0; i<250; i++)
*
006A: CLRF 2D
006B: MOVF 2D,W
006C: SUBLW F9
006D: BTFSS 03.0
006E: GOTO 087
.................... {
.................... output_bit(PIEZO, beep);
006F: BTFSC 2C.0
0070: GOTO 073
0071: BCF 05.6
0072: GOTO 074
0073: BSF 05.6
0074: BSF 03.5
0075: BCF 05.6
.................... beep=~beep;
0076: MOVLW 01
0077: BCF 03.5
0078: XORWF 2C,F
.................... output_bit(LED, beep);
0079: BTFSC 2C.0
007A: GOTO 07D
007B: BCF 05.7
007C: GOTO 07E
007D: BSF 05.7
007E: BSF 03.5
007F: BCF 05.7
.................... delay_us(100);
0080: MOVLW 21
0081: MOVWF 77
0082: DECFSZ 77,F
0083: GOTO 082
.................... };
0084: BCF 03.5
0085: INCF 2D,F
0086: GOTO 06B
.................... output_high(PIEZO);
0087: BSF 03.5
0088: BCF 05.6
0089: BCF 03.5
008A: BSF 05.6
.................... output_high(LED);
008B: BSF 03.5
008C: BCF 05.7
008D: BCF 03.5
008E: BSF 05.7
.................... }
008F: RETLW 00
....................
.................... void cvak() // pouze cvaknuti piezoelementem bez bliknuti
.................... {
.................... output_bit(PIEZO,~input(PIEZO));
*
005D: BSF 03.5
005E: BSF 05.6
005F: BCF 03.5
0060: BTFSS 05.6
0061: GOTO 064
0062: BCF 05.6
0063: GOTO 065
0064: BSF 05.6
0065: BSF 03.5
0066: BCF 05.6
.................... }
0067: BCF 03.5
0068: BCF 0A.3
0069: GOTO 106 (RETURN)
....................
.................... void main()
.................... {
*
0090: CLRF 04
0091: MOVLW 1F
0092: ANDWF 03,F
0093: BSF 03.5
0094: BCF 1F.4
0095: BCF 1F.5
0096: MOVF 1B,W
0097: ANDLW 80
0098: MOVWF 1B
0099: MOVLW 07
009A: MOVWF 1C
009B: MOVF 1C,W
009C: BCF 03.5
009D: BCF 0D.6
009E: MOVLW 60
009F: BSF 03.5
00A0: MOVWF 0F
.................... int8 n;
.................... int8 perioda;
....................
.................... setup_adc_ports(ADC_CLOCK_INTERNAL|sAN4|VSS_VDD);
00A1: BCF 1F.4
00A2: BCF 1F.5
00A3: MOVF 1B,W
00A4: ANDLW 80
00A5: IORLW D0
00A6: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
00A7: BCF 1F.6
00A8: BCF 03.5
00A9: BSF 1F.6
00AA: BSF 1F.7
00AB: BSF 03.5
00AC: BCF 1F.7
00AD: BCF 03.5
00AE: BSF 1F.0
.................... setup_spi(FALSE);
00AF: BCF 14.5
00B0: BSF 03.5
00B1: BCF 06.2
00B2: BSF 06.1
00B3: BCF 06.4
00B4: MOVLW 00
00B5: BCF 03.5
00B6: MOVWF 14
00B7: BSF 03.5
00B8: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
00B9: MOVF 01,W
00BA: ANDLW C0
00BB: IORLW 07
00BC: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
00BD: BCF 03.5
00BE: CLRF 10
.................... setup_comparator(NC_NC_NC_NC);
00BF: MOVLW 07
00C0: BSF 03.5
00C1: MOVWF 1C
00C2: MOVF 05,W
00C3: MOVLW 03
00C4: MOVWF 77
00C5: DECFSZ 77,F
00C6: GOTO 0C5
00C7: MOVF 1C,W
00C8: BCF 03.5
00C9: BCF 0D.6
.................... setup_vref(FALSE);
00CA: BSF 03.5
00CB: CLRF 1D
....................
.................... output_low(MENIC); // Vsechno zastav
00CC: BCF 06.3
00CD: BCF 03.5
00CE: BCF 06.3
.................... output_low(MOTOR);
00CF: BSF 03.5
00D0: BCF 06.2
00D1: BCF 03.5
00D2: BCF 06.2
.................... output_low(REFPWR);
00D3: BSF 03.5
00D4: BCF 06.1
00D5: BCF 03.5
00D6: BCF 06.1
.................... output_high(LED);
00D7: BSF 03.5
00D8: BCF 05.7
00D9: BCF 03.5
00DA: BSF 05.7
.................... output_high(PIEZO);
00DB: BSF 03.5
00DC: BCF 05.6
00DD: BCF 03.5
00DE: BSF 05.6
....................
.................... set_adc_channel(4); // Vyber AD kanal pro pomerne mereni napeti
00DF: MOVLW 20
00E0: MOVWF 78
00E1: MOVF 1F,W
00E2: ANDLW C7
00E3: IORWF 78,W
00E4: MOVWF 1F
.................... set_pwm1_duty(0); // Spust PWM, ale zatim s trvalou 0 na vystupu
00E5: CLRF 15
.................... setup_ccp1(CCP_PWM); // PWM pro zatizeni clanku v seru
00E6: BSF 03.5
00E7: BCF 06.3
00E8: BCF 03.5
00E9: BCF 06.3
00EA: MOVLW 0C
00EB: MOVWF 17
.................... setup_timer_2(T2_DIV_BY_1,100,1); // perioda
00EC: MOVLW 00
00ED: MOVWF 78
00EE: IORLW 04
00EF: MOVWF 12
00F0: MOVLW 64
00F1: BSF 03.5
00F2: MOVWF 12
....................
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // rozjed PIC (zvysi se odber)
00F3: MOVLW 62
00F4: MOVWF 0F
....................
....................
.................... // jsme v depu?
.................... set_pwm1_duty(2); // PWM pro zatizeni clanku pri malem osvetleni
00F5: MOVLW 02
00F6: BCF 03.5
00F7: MOVWF 15
.................... n=0;
00F8: CLRF 2A
.................... do
.................... {
.................... output_low(REFPWR);
00F9: BSF 03.5
00FA: BCF 06.1
00FB: BCF 03.5
00FC: BCF 06.1
.................... delay_ms(100);
00FD: MOVLW 64
00FE: MOVWF 2D
00FF: CALL 048
.................... if (4==n++) {cvak(); n=0;};
0100: MOVF 2A,W
0101: INCF 2A,F
0102: SUBLW 04
0103: BTFSS 03.2
0104: GOTO 107
0105: GOTO 05D
0106: CLRF 2A
.................... output_high(REFPWR); // zapni napajeni napetove reference
0107: BSF 03.5
0108: BCF 06.1
0109: BCF 03.5
010A: BSF 06.1
.................... delay_ms(1);
010B: MOVLW 01
010C: MOVWF 2D
010D: CALL 048
.................... } while (read_adc()>REFSTART); // Odkryl starter clanky?
010E: BSF 1F.2
010F: BTFSC 1F.2
0110: GOTO 10F
0111: MOVF 1E,W
0112: SUBLW 50
0113: BTFSS 03.0
0114: GOTO 0F9
.................... output_low(REFPWR);
0115: BSF 03.5
0116: BCF 06.1
0117: BCF 03.5
0118: BCF 06.1
....................
.................... pip(); // potvrzeni odstartovani
0119: CALL 06A
....................
.................... // regulace
.................... perioda=100; // nastav optimalni periodu pri jedne 500W zarovce
011A: MOVLW 64
011B: MOVWF 2B
.................... for(n=0;n<=7;n++)
011C: CLRF 2A
011D: MOVF 2A,W
011E: SUBLW 07
011F: BTFSS 03.0
0120: GOTO 143
.................... {
.................... set_pwm1_duty(0);
0121: CLRF 15
.................... setup_timer_2(T2_DIV_BY_1,perioda,1); // perioda
0122: MOVLW 00
0123: MOVWF 78
0124: IORLW 04
0125: MOVWF 12
0126: MOVF 2B,W
0127: BSF 03.5
0128: MOVWF 12
.................... set_pwm1_duty(19); // delka sepnuti
0129: MOVLW 13
012A: BCF 03.5
012B: MOVWF 15
.................... delay_ms(100);
012C: MOVLW 64
012D: MOVWF 2D
012E: CALL 048
.................... output_high(REFPWR); // zapni napajeni napetove reference
012F: BSF 03.5
0130: BCF 06.1
0131: BCF 03.5
0132: BSF 06.1
.................... delay_ms(1);
0133: MOVLW 01
0134: MOVWF 2D
0135: CALL 048
.................... if (read_adc()<REFNOM) perioda--; // zvyseni zatizeni menice
0136: BSF 1F.2
0137: BTFSC 1F.2
0138: GOTO 137
0139: MOVF 1E,W
013A: SUBLW 6A
013B: BTFSC 03.0
013C: DECF 2B,F
.................... output_low(REFPWR); // konec mereni, odpoj napajeni reference
013D: BSF 03.5
013E: BCF 06.1
013F: BCF 03.5
0140: BCF 06.1
.................... };
0141: INCF 2A,F
0142: GOTO 11D
....................
.................... // nabíjíme
.................... delay_ms(14000);
0143: MOVLW 38
0144: MOVWF 2C
0145: MOVLW FA
0146: MOVWF 2D
0147: CALL 048
0148: DECFSZ 2C,F
0149: GOTO 145
....................
.................... // rozjezd
.................... SSPSTAT = 0;
014A: BSF 03.5
014B: CLRF 14
.................... SSPCON1 = 0x22; // SPI OSC/64
014C: MOVLW 22
014D: BCF 03.5
014E: MOVWF 14
.................... MotorPattern=0x02; // prvni data pro vyslani
014F: MOVLW 02
0150: MOVWF 29
.................... SSPBUF=MotorPattern; // data pro vyslani
0151: MOVF 29,W
0152: MOVWF 13
.................... enable_interrupts(global);
0153: MOVLW C0
0154: IORWF 0B,F
.................... enable_interrupts(INT_SSP); // az budou vyslana, prijde interrupt od SSP
0155: BSF 03.5
0156: BSF 0C.3
....................
.................... for(n=0; n<=7; n++) // razeni osmi rychlostnich stupnu
0157: BCF 03.5
0158: CLRF 2A
0159: MOVF 2A,W
015A: SUBLW 07
015B: BTFSS 03.0
015C: GOTO 166
.................... {
.................... MotorPattern=Pattern[n];
015D: MOVF 2A,W
015E: CALL 037
015F: MOVWF 78
0160: MOVWF 29
.................... delay_ms(RAZENI); // Pockej na dalsi razeni
0161: MOVLW 3C
0162: MOVWF 2D
0163: CALL 048
.................... };
0164: INCF 2A,F
0165: GOTO 159
.................... SSPSTAT = 0;
0166: BSF 03.5
0167: CLRF 14
.................... SSPCON1 = 0; // SPI stop
0168: BCF 03.5
0169: CLRF 14
.................... disable_interrupts(INT_SSP); // zastav preruseni od SSP
016A: BSF 03.5
016B: BCF 0C.3
....................
.................... // jedem co to da
.................... output_high(MOTOR);
016C: BCF 06.2
016D: BCF 03.5
016E: BSF 06.2
.................... delay_ms(1000);
016F: MOVLW 04
0170: MOVWF 2C
0171: MOVLW FA
0172: MOVWF 2D
0173: CALL 048
0174: DECFSZ 2C,F
0175: GOTO 171
.................... output_low(MOTOR);
0176: BSF 03.5
0177: BCF 06.2
0178: BCF 03.5
0179: BCF 06.2
.................... set_pwm1_duty(0); // zastav menic
017A: CLRF 15
....................
.................... // vybiti kondenzatoru pro ucely mereni
.................... pip();
017B: CALL 06A
.................... delay_ms(2000);
017C: MOVLW 08
017D: MOVWF 2C
017E: MOVLW FA
017F: MOVWF 2D
0180: CALL 048
0181: DECFSZ 2C,F
0182: GOTO 17E
.................... pip();
0183: CALL 06A
.................... output_high(MOTOR);
0184: BSF 03.5
0185: BCF 06.2
0186: BCF 03.5
0187: BSF 06.2
....................
.................... while(true)
.................... {
.................... output_high(LED);
0188: BSF 03.5
0189: BCF 05.7
018A: BCF 03.5
018B: BSF 05.7
.................... output_low(PIEZO);
018C: BSF 03.5
018D: BCF 05.6
018E: BCF 03.5
018F: BCF 05.6
.................... delay_ms(300);
0190: MOVLW 02
0191: MOVWF 2C
0192: MOVLW 96
0193: MOVWF 2D
0194: CALL 048
0195: DECFSZ 2C,F
0196: GOTO 192
.................... output_low(LED);
0197: BSF 03.5
0198: BCF 05.7
0199: BCF 03.5
019A: BCF 05.7
.................... output_high(PIEZO);
019B: BSF 03.5
019C: BCF 05.6
019D: BCF 03.5
019E: BSF 05.6
.................... delay_ms(300);
019F: MOVLW 02
01A0: MOVWF 2C
01A1: MOVLW 96
01A2: MOVWF 2D
01A3: CALL 048
01A4: DECFSZ 2C,F
01A5: GOTO 1A1
.................... }
01A6: GOTO 188
.................... // priprava na dalsi jizdu
.................... delay_ms(5000);
01A7: MOVLW 14
01A8: MOVWF 2C
01A9: MOVLW FA
01AA: MOVWF 2D
01AB: CALL 048
01AC: DECFSZ 2C,F
01AD: GOTO 1A9
.................... reset_cpu();
01AE: CLRF 0A
01AF: GOTO 000
.................... }
....................
01B0: SLEEP
Configuration Fuses:
Word 1: 2738 NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT DEBUG CCPB3 NOPROTECT INTRC_IO
Word 2: 3FFC NOFCMEN NOIESO