📄 nokon628.lst
字号:
CCS PCM C Compiler, Version 4.069, 47189 06-Aug-08 21:18
Filename: Nokon628.lst
ROM used: 253 words (12%)
Largest free fragment is 1795
RAM used: 8 (4%) at main() level
10 (4%) worst case
Stack: 2 locations
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0C7
0003: NOP
.................... #include "C:\PIC\CCS_PRJ\NIKON_16F628\Nokon628.h"
.................... #include <16F628.h>
.................... //////// Standard Header file for the PIC16F628 device ////////////////
.................... #device PIC16F628
.................... #list
....................
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Internal RC Osc, no CLKOUT
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES BROWNOUT //Reset when brownout detected
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
.................... #FUSES NOCPD //No EE protection
....................
.................... #use delay(clock=4000000)
*
0031: MOVLW 21
0032: MOVWF 04
0033: BCF 03.7
0034: MOVF 00,W
0035: BTFSC 03.2
0036: GOTO 045
0037: MOVLW 01
0038: MOVWF 78
0039: CLRF 77
003A: DECFSZ 77,F
003B: GOTO 03A
003C: DECFSZ 78,F
003D: GOTO 039
003E: MOVLW 4A
003F: MOVWF 77
0040: DECFSZ 77,F
0041: GOTO 040
0042: GOTO 043
0043: DECFSZ 00,F
0044: GOTO 037
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8)
....................
....................
.................... /*
.................... #int_RDA
.................... void RDA_isr(void)
.................... {
.................... return;
.................... }
....................
.................... #int_TIMER1
.................... void TIMER1_isr(void)
.................... {
.................... return;
.................... }
....................
.................... #int_CCP1
.................... void CCP1_isr(void)
.................... {
.................... return;
.................... }
....................
.................... */
.................... #DEFINE BUTTON PIN_B4
.................... #define LED_ON output_low
.................... #define LED_OFF output_high
.................... #define IR_LED PIN_B5
.................... #DEFINE DEBOUNCE_TIME 10
.................... #define PORTA 5
.................... #define PORTB 6
.................... #define _DOUT PORTB, 5 // Outgoing data
....................
....................
.................... int BUTTON_PRESSED()
.................... {
.................... static int laststate=0;
*
00D5: CLRF 20
....................
.................... if (!input(BUTTON))
*
002A: BSF 03.5
002B: BSF 06.4
002C: BCF 03.5
002D: BTFSC 06.4
002E: GOTO 04C
.................... {
.................... delay_ms(DEBOUNCE_TIME); // debounce time
002F: MOVLW 0A
0030: MOVWF 21
.................... if (bit_test(laststate,0))
*
0045: BTFSS 20.0
0046: GOTO 04B
.................... {
.................... laststate = 0;
0047: CLRF 20
.................... return (1);
0048: MOVLW 01
0049: MOVWF 78
004A: GOTO 04F
.................... }
.................... } else
004B: GOTO 04D
.................... bit_set(laststate,0);
004C: BSF 20.0
....................
.................... return (0);
004D: MOVLW 00
004E: MOVWF 78
.................... }
004F: GOTO 0EA (RETURN)
....................
.................... // IR command sequence for AF & shutter release :
.................... // - starting pulse 2250us (IR on) OR: 2ms on
.................... // - pause 27600us (IR off) 28ms off
.................... // - 650us pulse 0.5ms on
.................... // - pause 13750us 1.5ms off
.................... // - 575us pulse 0.5ms on
.................... // - pause 3350us 3.5ms off
.................... // - pulse 650us 0.5ms on
.................... // - pause 63msec 60ms off pause
.................... // - repeat the above sequence one time
.................... //
.................... // The IR on-pulses need to be gated/modulated with 40kHz,
.................... // i.e. on for 12.5us off for 12.5us
.................... //
.................... // The PIC runs on its 4MHz internal oscillator, so one
.................... // instruction cycle takes 1.0us (1/4th of clock)
....................
.................... void Pulse_12_5Khz_Out()
.................... {
.................... int8 Counter;
.................... #asm
.................... movlw 80
0050: MOVLW 50
.................... movwf Counter
0051: MOVWF 22
.................... Loop2ms:
.................... bsf _DOUT
0052: BSF 06.5
.................... nop
0053: NOP
.................... nop
0054: NOP
.................... nop
0055: NOP
.................... nop
0056: NOP
.................... nop
0057: NOP
.................... nop
0058: NOP
.................... nop
0059: NOP
.................... nop
005A: NOP
.................... nop
005B: NOP
.................... nop
005C: NOP
.................... nop
005D: NOP
.................... bcf _DOUT
005E: BCF 06.5
.................... nop
005F: NOP
.................... nop
0060: NOP
.................... nop
0061: NOP
.................... nop
0062: NOP
.................... nop
0063: NOP
.................... nop
0064: NOP
.................... nop
0065: NOP
.................... nop
0066: NOP
.................... nop
0067: NOP
.................... decfsz Counter, F
0068: DECFSZ 22,F
.................... goto Loop2ms
0069: GOTO 052
.................... #endasm
.................... return;
.................... }
006A: RETLW 00
....................
.................... void Pulse_12_5Khz_Pause()
.................... {
.................... int8 Counter;
.................... #asm
.................... movlw 80
006B: MOVLW 50
.................... movwf Counter
006C: MOVWF 22
.................... Loop2ms:
.................... bcf _DOUT
006D: BCF 06.5
.................... nop
006E: NOP
.................... nop
006F: NOP
.................... nop
0070: NOP
.................... nop
0071: NOP
.................... nop
0072: NOP
.................... nop
0073: NOP
.................... nop
0074: NOP
.................... nop
0075: NOP
.................... nop
0076: NOP
.................... nop
0077: NOP
.................... nop
0078: NOP
.................... bcf _DOUT
0079: BCF 06.5
.................... nop
007A: NOP
.................... nop
007B: NOP
.................... nop
007C: NOP
.................... nop
007D: NOP
.................... nop
007E: NOP
.................... nop
007F: NOP
.................... nop
0080: NOP
.................... nop
0081: NOP
.................... nop
0082: NOP
.................... decfsz Counter, F
0083: DECFSZ 22,F
.................... goto Loop2ms
0084: GOTO 06D
.................... #endasm
.................... return;
.................... }
0085: RETLW 00
....................
.................... void pause28ms()
.................... {
.................... int8 Counter, Counter2;
.................... #asm
.................... movlw 20
*
008F: MOVLW 14
.................... movwf Counter2
0090: MOVWF 23
.................... Loop28msO:
.................... movlw 199
0091: MOVLW C7
.................... movwf Counter
0092: MOVWF 22
.................... Loop28msI:
.................... nop
0093: NOP
.................... nop
0094: NOP
.................... nop
0095: NOP
.................... nop
0096: NOP
.................... decfsz Counter, F
0097: DECFSZ 22,F
.................... goto Loop28msI
0098: GOTO 093
.................... // Total delay - 7 ins
.................... nop
0099: NOP
.................... nop
009A: NOP
.................... nop
009B: NOP
.................... decfsz Counter2, F
009C: DECFSZ 23,F
.................... goto Loop28msO
009D: GOTO 091
.................... #endasm
.................... return;
.................... }
.................... void SendNikonCommand ()
.................... {
.................... int count=0;
*
0086: CLRF 21
.................... //- starting pulse 2250us (IR on) OR: 2ms on
.................... for(count=0;count <80;count++)
0087: CLRF 21
0088: MOVF 21,W
0089: SUBLW 4F
008A: BTFSS 03.0
008B: GOTO 08F
.................... Pulse_12_5Khz_Out();
008C: CALL 050
008D: INCF 21,F
008E: GOTO 088
.................... //- pause 27600us (IR off) 28ms off
.................... pause28ms();
.................... //- 650us pulse 0.5ms on
.................... for(count=0;count <20;count++)
*
009E: CLRF 21
009F: MOVF 21,W
00A0: SUBLW 13
00A1: BTFSS 03.0
00A2: GOTO 0A6
.................... Pulse_12_5Khz_Out();
00A3: CALL 050
00A4: INCF 21,F
00A5: GOTO 09F
.................... //- pause 13750us 1.5ms off
.................... for(count=0;count <60;count++)
00A6: CLRF 21
00A7: MOVF 21,W
00A8: SUBLW 3B
00A9: BTFSS 03.0
00AA: GOTO 0AE
.................... Pulse_12_5Khz_Pause();
00AB: CALL 06B
00AC: INCF 21,F
00AD: GOTO 0A7
.................... //- 575us pulse 0.5ms on
.................... for(count=0;count <20;count++)
00AE: CLRF 21
00AF: MOVF 21,W
00B0: SUBLW 13
00B1: BTFSS 03.0
00B2: GOTO 0B6
.................... Pulse_12_5Khz_Out();
00B3: CALL 050
00B4: INCF 21,F
00B5: GOTO 0AF
.................... //- pause 3350us 3.5ms off
.................... for(count=0;count <140;count++)
00B6: CLRF 21
00B7: MOVF 21,W
00B8: SUBLW 8B
00B9: BTFSS 03.0
00BA: GOTO 0BE
.................... Pulse_12_5Khz_Pause();
00BB: CALL 06B
00BC: INCF 21,F
00BD: GOTO 0B7
.................... //- 650us pulse 0.5ms on
.................... for(count=0;count <20;count++)
00BE: CLRF 21
00BF: MOVF 21,W
00C0: SUBLW 13
00C1: BTFSS 03.0
00C2: GOTO 0C6
.................... Pulse_12_5Khz_Out();
00C3: CALL 050
00C4: INCF 21,F
00C5: GOTO 0BF
....................
.................... //- pause 63msec 60ms off pause
.................... }
00C6: GOTO 0EE (RETURN)
....................
....................
.................... void main()
.................... {
00C7: CLRF 04
00C8: BCF 03.7
00C9: MOVLW 1F
00CA: ANDWF 03,F
00CB: MOVLW 19
00CC: BSF 03.5
00CD: MOVWF 19
00CE: MOVLW A6
00CF: MOVWF 18
00D0: MOVLW 90
00D1: BCF 03.5
00D2: MOVWF 18
00D3: MOVLW 07
00D4: MOVWF 1F
....................
.................... // setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
.................... // setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
.................... // setup_timer_2(T2_DISABLED,0,1);
.................... // setup_ccp1(CCP_CAPTURE_RE);
.................... // setup_comparator(NC_NC_NC_NC);
.................... // setup_vref(FALSE);
....................
.................... set_tris_b(0x1F); //B4 - input, B5 - Output
*
00D6: MOVLW 1F
00D7: TRIS 6
.................... output_high(PIN_B4);
00D8: BSF 03.5
00D9: BCF 06.4
00DA: BCF 03.5
00DB: BSF 06.4
....................
.................... // enable_interrupts(INT_RDA);
.................... //enable_interrupts(INT_TIMER1);
.................... //enable_interrupts(INT_CCP1);
.................... //enable_interrupts(GLOBAL);
....................
.................... // TODO: USER CODE!!
.................... printf("Nikon IR Remote.\r\n");
00DC: CLRF 21
00DD: MOVF 21,W
00DE: CALL 004
00DF: INCF 21,F
00E0: MOVWF 77
00E1: MOVF 77,W
00E2: BTFSS 0C.4
00E3: GOTO 0E2
00E4: MOVWF 19
00E5: MOVLW 12
00E6: SUBWF 21,W
00E7: BTFSS 03.2
00E8: GOTO 0DD
....................
.................... while (1){
....................
....................
.................... if( BUTTON_PRESSED())
00E9: GOTO 02A
00EA: MOVF 78,F
00EB: BTFSC 03.2
00EC: GOTO 0FB
.................... {
....................
.................... SendNikonCommand ();
00ED: GOTO 086
.................... printf("Sent OK.\r\n");
00EE: CLRF 21
00EF: MOVF 21,W
00F0: CALL 01B
00F1: INCF 21,F
00F2: MOVWF 77
00F3: MOVF 77,W
00F4: BTFSS 0C.4
00F5: GOTO 0F4
00F6: MOVWF 19
00F7: MOVLW 0A
00F8: SUBWF 21,W
00F9: BTFSS 03.2
00FA: GOTO 0EF
.................... }
....................
.................... };
00FB: GOTO 0E9
....................
.................... }
00FC: SLEEP
Configuration Fuses:
Word 1: 3FE9 XT NOWDT NOPUT NOPROTECT BROWNOUT MCLR LVP NOCPD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -