EverydayThanks

PIC・arduinoなど電子工作の備忘録

広告

※このエリアは、60日間投稿が無い場合に表示されます。記事を投稿すると、表示されなくなります。

PICマイコンを利用した赤外線コントロール戦車(受信プログラム)

2014年07月12日 | PICマイコン

3-2)赤外線受信プログラム

 

;*************************************
; 赤外線受信プログラム
;*************************************
;                    LED-RECV.ASM
                     LIST    P=PIC16F84A;
                     INCLUDE    P16F84.INC;

 

MEM_1            EQU    0CH
MEM_2            EQU    0DH
MEM_3            EQU    0EH
MEM_4            EQU    0FH
                      ORG    0

 

;*****************************
;メインルーチン
;*****************************
MAIN   
                     BSF      STATUS,RP0
                     CLRF     TRISB
                     MOVLW    01H
                     MOVWF    TRISA
                     BCF       OPTION_REG,7
                     BCF      STATUS,RP0
LOOP
                     CLRF      PORTA
                     CLRF      PORTB
                     CLRF      MEM_4
                     BTFSC    PORTA,0

 

                     GOTO      LOOP
                     CALL      TIM04
                     BTFSC    PORTA,0

 

                     GOTO     LOOP
                     CALL      TIM02
                     CALL      TIM04
                     BTFSS    PORTA,0

 

                     GOTO     LOOP
                     CALL      TIM02
                     CALL      TIM04
                     BTFSC    PORTA,0

 

                     GOTO     LOOP
                     CALL     TIM02
                     CALL     TIM04
                     BTFSC    PORTA,0

 

                     GOTO    B0
                     BSF       MEM_4,3
B0
                     CALL     TIM02
                     CALL     TIM04
                     BTFSC   PORTA,0

 

                     GOTO    B1
                     BSF       MEM_4,2
B1
                     CALL     TIM02
                     CALL     TIM04
                     BTFSC   PORTA,0

 

                     GOTO    B2
                     BSF       MEM_4,1
B2
                     CALL     TIM02
                     CALL     TIM04
                     BTFSC   PORTA,0

 

                     GOTO    B3
                     BSF       MEM_4,0
B3
                     CALL     TIM02
                     CALL     TIM04
                     BTFSC   PORTA,0

 

                     GOTO    LOOP
                     CALL    TIM02
                     CALL    TIM04
                     BTFSS   PORTA,0

 

                     GOTO    LOOP
                     CALL    TIM02
                     CALL    TIM04
                     BTFSC    PORTA,0

 

                     GOTO    LOOP
                     CALL     TIM02
                     CALL     TIM04
                     BTFSS    PORTA,0

 

                     GOTO     LOOP
                     CALL     TIM02
                     CALL     TIM04
                     BTFSC    PORTA,0

 

                     GOTO     LOOP
                     DECFSZ  MEM_4,1
                     GOTO     C0
                     GOTO     Label0
C0
                     DECFSZ    MEM_4,1
                     GOTO       C1
                     GOTO       Label1
C1
                     DECFSZ    MEM_4,1
                     GOTO       C2
                     GOTO       Label2
C2
                     DECFSZ    MEM_4,1
                     GOTO       C3
                     GOTO       Label3
C3
                     DECFSZ    MEM_4,1
                     GOTO       C4
                     GOTO       Label4
C4
                     DECFSZ    MEM_4,1
                     GOTO       C5
                     GOTO       Label5
C5
                     DECFSZ    MEM_4,1
                     GOTO       C6
                     GOTO       Label6
C6
                     DECFSZ    MEM_4,1
                     GOTO       LOOP
                     GOTO       Label7

 

Label0
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    0AH
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label1
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    09H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label2
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    06H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label3
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    08H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label4
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    02H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label5
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    05H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label6
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    04H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
Label7
                     MOVLW    02H
                     MOVWF    PORTA

 

                     MOVLW    01H
                     MOVWF    PORTB

 

                     CALL       TIM100
                     GOTO       LOOP
;*****************************
;200μs
;*****************************
TIM02
                     MOVLW    07CH
                     MOVWF    MEM_1
TIMLP1          NOP
                     DECFSZ    MEM_1,F
                     GOTO    TIMLP1
                     RETURN
;*****************************
;400μs
;*****************************
TIM04
                      MOVLW    0F9H
                      MOVWF    MEM_2
TIMLP2           NOP
                      DECFSZ    MEM_2,F
                      GOTO      TIMLP2
                      RETURN
;*****************************
;0.1s
;*****************************
TIM100
                      MOVLW    0F9H
                      MOVWF    MEM_3
TIMLP3            CALL    TIM04
                      DECFSZ    MEM_3,F
                      GOTO       TIMLP3
                      RETURN
END

 

『その他』 ジャンルのランキング
この記事についてブログを書く
この記事をはてなブックマークに追加
« PIC16F84による赤外線送信回路に... | トップ | PICマイコンを利用した赤外線コ... »
最近の画像もっと見る

あわせて読む