Go to most recent revision | Blame | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.234, 27853 16-X-05 21:12
Filename: C:\MIHO_DAT\KROKAC\krokac.LST
ROM used: 321 words (8%)
Largest free fragment is 2048
RAM used: 21 (12%) at main() level
24 (14%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 098
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.1
001F: GOTO 022
0020: BTFSC 0C.1
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 "C:\MIHO_DAT\KROKAC\krokac.h"
.................... #include <16F88.h>
.................... //////// Standard Header file for the PIC16F88 device ////////////////
.................... #device PIC16F88
.................... #list
....................
.................... //#device ICD=TRUE
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES RC //Resistor/Capacitor Osc with CLKOUT
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... //#FUSES DEBUG //Debug mode for use with 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=4000000)
*
0082: MOVLW 31
0083: MOVWF 04
0084: MOVF 00,W
0085: BTFSC 03.2
0086: GOTO 096
0087: MOVLW 01
0088: MOVWF 78
0089: CLRF 77
008A: DECFSZ 77,F
008B: GOTO 08A
008C: DECFSZ 78,F
008D: GOTO 089
008E: MOVLW 4A
008F: MOVWF 77
0090: DECFSZ 77,F
0091: GOTO 090
0092: NOP
0093: NOP
0094: DECFSZ 00,F
0095: GOTO 087
0096: BCF 0A.3
0097: GOTO 130 (RETURN)
.................... #define MOTORA PIN_B0
.................... #define MOTORB PIN_B1
.................... #define MOTORC PIN_B2
.................... #define MOTORD PIN_B3
....................
....................
....................
....................
.................... unsigned int StepState; // Vnitrni promenna kroku
.................... signed int StepDirection; // Smer +1/0/-1
....................
.................... byte const StepTab[8]={ // Tabulka pro krokovy motor
.................... 0b0001, // 0
.................... 0b0101, // 1
.................... 0b0100, // 2
.................... 0b0110, // 3
.................... 0b0010, // 4
.................... 0b1010, // 5
.................... 0b1000 // 6
.................... 0b1001, // 7
.................... };
....................
.................... #INT_TIMER2
.................... void StepNext()
.................... {
.................... unsigned int i;
....................
.................... StepState+=StepDirection; // posun se na dalsi krok
*
0043: MOVF 2A,W
0044: ADDWF 29,W
0045: MOVWF 29
.................... i=StepState&0b111; // vezmi spodni 3 bity stavu
0046: MOVF 29,W
0047: ANDLW 07
0048: MOVWF 32
.................... i=StepTab[i]; // prekoduj pomoci tabulky
0049: MOVF 32,W
004A: CALL 037
004B: MOVWF 78
004C: MOVWF 32
.................... output_bit(MOTORA,i&0b0001); // aktivuj jednotlive vystupy
004D: BTFSC 32.0
004E: GOTO 051
004F: BCF 06.0
0050: GOTO 052
0051: BSF 06.0
0052: BSF 03.5
0053: BCF 06.0
.................... output_bit(MOTORB,i&0b0010);
0054: BCF 03.5
0055: BTFSC 32.1
0056: GOTO 059
0057: BCF 06.1
0058: GOTO 05A
0059: BSF 06.1
005A: BSF 03.5
005B: BCF 06.1
.................... output_bit(MOTORC,i&0b0100);
005C: BCF 03.5
005D: BTFSC 32.2
005E: GOTO 061
005F: BCF 06.2
0060: GOTO 062
0061: BSF 06.2
0062: BSF 03.5
0063: BCF 06.2
.................... output_bit(MOTORD,i&0b1000);
0064: BCF 03.5
0065: BTFSC 32.3
0066: GOTO 069
0067: BCF 06.3
0068: GOTO 06A
0069: BSF 06.3
006A: BSF 03.5
006B: BCF 06.3
.................... }
....................
....................
006C: BCF 03.5
006D: BCF 0C.1
006E: BCF 0A.3
006F: GOTO 022
.................... void StepSetDirection(signed int Direction)
.................... {
.................... if(Direction> 1) Direction= 1;
0070: BTFSC 30.7
0071: GOTO 078
0072: MOVF 30,W
0073: SUBLW 01
0074: BTFSC 03.0
0075: GOTO 078
0076: MOVLW 01
0077: MOVWF 30
.................... if(Direction<-1) Direction=-1;
0078: MOVF 30,W
0079: XORLW 80
007A: SUBLW 7E
007B: BTFSS 03.0
007C: GOTO 07F
007D: MOVLW FF
007E: MOVWF 30
.................... StepDirection=Direction;
007F: MOVF 30,W
0080: MOVWF 2A
.................... }
0081: RETLW 00
....................
....................
.................... void StepSetTime(unsigned int16 Time)
.................... {
....................
.................... }
....................
.................... void Delay(unsigned int16 Time)
.................... {
.................... while(Time>255) {Time-=256;delay_us(256);};
.................... if(Time!=0) delay_us(Time);
.................... }
....................
....................
.................... void main()
.................... {
*
0098: CLRF 04
0099: MOVLW 1F
009A: ANDWF 03,F
009B: BSF 03.5
009C: BCF 1F.4
009D: BCF 1F.5
009E: MOVF 1B,W
009F: ANDLW 80
00A0: MOVWF 1B
00A1: MOVLW 07
00A2: MOVWF 1C
00A3: MOVF 1C,W
00A4: BCF 03.5
00A5: BCF 0D.6
.................... unsigned int16 T;
.................... unsigned long int i;
....................
.................... // Nastav pracovni frekvenci procesoru
.................... setup_oscillator(OSC_4MHZ);
00A6: MOVLW 60
00A7: BSF 03.5
00A8: MOVWF 0F
....................
.................... // Vypni motorovy vystup
.................... output_low(MOTORA);
00A9: BCF 06.0
00AA: BCF 03.5
00AB: BCF 06.0
.................... output_low(MOTORB);
00AC: BSF 03.5
00AD: BCF 06.1
00AE: BCF 03.5
00AF: BCF 06.1
.................... output_low(MOTORC);
00B0: BSF 03.5
00B1: BCF 06.2
00B2: BCF 03.5
00B3: BCF 06.2
.................... output_low(MOTORD);
00B4: BSF 03.5
00B5: BCF 06.3
00B6: BCF 03.5
00B7: BCF 06.3
....................
.................... // Vstupy s pull-up odporem
.................... port_b_pullups(TRUE);
00B8: BSF 03.5
00B9: BCF 01.7
....................
.................... // Inicializace A/D prevodniku
.................... setup_adc_ports(sAN0|VSS_VDD);
00BA: BCF 1F.4
00BB: BCF 1F.5
00BC: MOVF 1B,W
00BD: ANDLW 80
00BE: IORLW 01
00BF: MOVWF 1B
.................... setup_adc(ADC_CLOCK_INTERNAL);
00C0: BCF 1F.6
00C1: BCF 03.5
00C2: BSF 1F.6
00C3: BSF 1F.7
00C4: BSF 03.5
00C5: BCF 1F.7
00C6: BCF 03.5
00C7: BSF 1F.0
.................... set_adc_channel(0);
00C8: MOVLW 00
00C9: MOVWF 78
00CA: MOVF 1F,W
00CB: ANDLW C7
00CC: IORWF 78,W
00CD: MOVWF 1F
....................
.................... // Dalsi inicializace
.................... setup_spi(FALSE);
00CE: BCF 14.5
00CF: BSF 03.5
00D0: BCF 06.2
00D1: BSF 06.1
00D2: BCF 06.4
00D3: MOVLW 00
00D4: BCF 03.5
00D5: MOVWF 14
00D6: BSF 03.5
00D7: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
00D8: MOVF 01,W
00D9: ANDLW C7
00DA: IORLW 08
00DB: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
00DC: BCF 03.5
00DD: CLRF 10
.................... setup_comparator(NC_NC_NC_NC);
00DE: MOVLW 07
00DF: BSF 03.5
00E0: MOVWF 1C
00E1: MOVF 05,W
00E2: MOVLW 03
00E3: MOVWF 77
00E4: DECFSZ 77,F
00E5: GOTO 0E4
00E6: MOVF 1C,W
00E7: BCF 03.5
00E8: BCF 0D.6
.................... setup_vref(FALSE);
00E9: BSF 03.5
00EA: CLRF 1D
....................
.................... // Inicializace stavovych promennych
.................... StepState=0;
00EB: BCF 03.5
00EC: CLRF 29
....................
.................... // Nastaveni casovace
.................... setup_timer_2(T2_DIV_BY_16,0xFF,1);
00ED: MOVLW 00
00EE: MOVWF 78
00EF: IORLW 06
00F0: MOVWF 12
00F1: MOVLW FF
00F2: BSF 03.5
00F3: MOVWF 12
....................
.................... // Nastveni preruseni od casovace
.................... enable_interrupts(global);
00F4: MOVLW C0
00F5: BCF 03.5
00F6: IORWF 0B,F
.................... enable_interrupts(int_timer2);
00F7: BSF 03.5
00F8: BSF 0C.1
....................
.................... for(;;)
.................... {
....................
.................... T=read_adc(ADC_READ_ONLY); // Prectu hodnotu
00F9: BCF 03.5
00FA: BTFSS 1F.2
00FB: GOTO 0FE
00FC: BSF 03.5
00FD: GOTO 0F9
00FE: MOVF 1E,W
00FF: CLRF 2C
0100: MOVWF 2B
.................... read_adc(ADC_START_ONLY); // Ostartuji dalsi prevod (na pozadi)
0101: BSF 1F.2
....................
.................... //setup_timer_2(T2_DIV_BY_16,T,1);
.................... if(T>0) *0x92=T; // Preload register casovace
0102: MOVF 2B,F
0103: BTFSS 03.2
0104: GOTO 108
0105: MOVF 2C,F
0106: BTFSC 03.2
0107: GOTO 10C
0108: MOVF 2B,W
0109: BSF 03.5
010A: MOVWF 12
010B: BCF 03.5
....................
.................... // Podle prepinacu se hybu
.................... if(input(PIN_B5))
010C: BSF 03.5
010D: BSF 06.5
010E: BCF 03.5
010F: BTFSS 06.5
0110: GOTO 11E
.................... {
.................... if(input(PIN_B4)) StepSetDirection(1); else StepSetDirection(-1);
0111: BSF 03.5
0112: BSF 06.4
0113: BCF 03.5
0114: BTFSS 06.4
0115: GOTO 11A
0116: MOVLW 01
0117: MOVWF 30
0118: CALL 070
0119: GOTO 11D
011A: MOVLW FF
011B: MOVWF 30
011C: CALL 070
.................... }
.................... else
011D: GOTO 13E
.................... { int1 x; // pomocna promenna aby se volalo spozdeni jen 1x
.................... if (StepState>230) {
011E: MOVF 29,W
011F: SUBLW E6
0120: BTFSC 03.0
0121: GOTO 136
.................... if (!input(PIN_B4) && (x))
0122: BSF 03.5
0123: BSF 06.4
0124: BCF 03.5
0125: BTFSC 06.4
0126: GOTO 133
0127: BTFSS 2F.0
0128: GOTO 133
.................... {
.................... StepSetDirection(0);
0129: CLRF 30
012A: CALL 070
.................... delay_ms(500);
012B: MOVLW 02
012C: MOVWF 30
012D: MOVLW FA
012E: MOVWF 31
012F: GOTO 082
0130: DECFSZ 30,F
0131: GOTO 12D
.................... x=0;
0132: BCF 2F.0
.................... };
.................... StepSetDirection(-1);
0133: MOVLW FF
0134: MOVWF 30
0135: CALL 070
.................... }
.................... if (StepState<30) {
0136: MOVF 29,W
0137: SUBLW 1D
0138: BTFSS 03.0
0139: GOTO 13E
.................... StepSetDirection( 1);
013A: MOVLW 01
013B: MOVWF 30
013C: CALL 070
.................... x=1;
013D: BSF 2F.0
.................... }
.................... }
.................... //StepDirection=2;
.................... //for(i=0;i<800;i++)
.................... //{
.................... // StepNext();
.................... // Delay(T);
.................... //}
.................... //delay_ms(10);
.................... //StepDirection=-1;
.................... //for(i=0;i<800;i++)
.................... //{
.................... // StepNext();
.................... // Delay(T);
.................... //}
.................... //delay_ms(10);
....................
.................... } // Cyklus for
013E: BSF 03.5
013F: GOTO 0F9
....................
.................... }
....................
0140: SLEEP
Configuration Fuses:
Word 1: 3F3B NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT RC
Word 2: 3FFF FCMEN IESO