;Li-Ion 電池 1 セル用スピコン PIC16F84A Version 0.2
;SPC16F02.ASM
;入力 正パルス(入力トランジスタバッファ省略) クロック 4MHz
; 22steps for Futaba PCM1024Z
LIST P=PIC16F84A
INCLUDE "P16F84A.INC"
CYCLE EQU 0CH
CNT050 EQU 0DH
CNT100 EQU 0EH
CNT150 EQU 0FH
CNT200 EQU 10H
CNT250 EQU 11H
CNT300 EQU 12H
CNT350 EQU 13H
CNT400 EQU 14H
CNT450 EQU 15H
CNT500 EQU 16H
CNT550 EQU 17H
CNT600 EQU 18H
CNT650 EQU 19H
CNT700 EQU 1AH
CNT750 EQU 1BH
CNT800 EQU 1CH
CNT850 EQU 1DH
CNT900 EQU 1EH
CNT950 EQU 1FH
CHECKTM1 EQU 20H
CHECKTM2 EQU 21H
ORG 0
MAIN
CLRF PORTB ;PORTB クリア
BSF STATUS,RP0 ;PAGE1 に切替え
MOVLW B'1111' ;PORTA をすべて入力に設定
MOVWF TRISA
CLRF TRISB ;PORTB をすべて出力に設定
BCF STATUS,RP0 ;PAGE0 に戻る
;メインループ
LOOP
TP1 BTFSC PORTA,0 ;RA0 入力が LOW なら次をスキップ
GOTO TP1
MOVLW D'0'
MOVWF CHECKTM1
MOVWF CHECKTM2
TP2 BTFSS PORTA,0 ;RA0 入力が HIGH なら次をスキップ
GOTO CHECK
TP3 CALL W100 ;102
CALL W100 ;202
CALL W100 ;302
CALL W100 ;402
CALL W100 ;502
CALL W100 ;602
CALL W100 ;702
CALL W100 ;802
CALL W100 ;902
CALL W100 ;1002
;1002μsec
BTFSS PORTA,0
GOTO OUT1002
CAL W038 ;1040
;1040μsec
BTFSS PORTA,0
GOTO OUT1040
CALL W038 ;1078
;1078μsec
BTFSS PORTA,0
GOTO OUT1078
CALL W083 ;1116
;1116μsec
BTFSS PORTA,0
GOTO OUT1116
CALL W038 ;1154
;1154μsec
BTFSS PORTA,0
GOTO OUT1154
CALL W038 ;1192
;1192μsec
BTFSS PORTA,0
GOTO OUT1192
CALL W038 ;1230
;1230μsec
BTFSS PORTA,0
GOTO OUT1230
CALL W038 ;1268
;1268μsec
BTFSS PORTA,0
GOTO 1268
CALL W038 ;1306
;1306μsec
BTFSS PORTA,0
GOTO OUT1306
CALL W038 ;1344
;1344μsec
BTFSS PORTA,0
GOTO OUT1344
CALL W038 ;1382
;1382μsec
BTFSS PORTA,0
GOTO OUT1382
CALL W038 ;1420
;1420μsec
BTFSS PORTA,0
GOTO OUT1420
CALL W038 ;1458
;1458μsec
BTFSS PORTA,0
GOTO OUT1458
CALL W038 ;1496
;1496μsec
BTFSS PORTA,0
GOTO OUT1496
CALL W038 ;1534
;1534μsec
BTFSS PORTA,0
GOTO OUT1534
CALL W038 ;1572
;1572μsec
BTFSS PORTA,0
GOTO OUT1572
CALL W038 ;1610
;1610μsec
BTFSS PORTA,0
GOTO OUT1610
CALL W038 ;1648
;1648μsec
BTFSS PORTA,0
GOTO OUT1648
CALL W038 ;1686
;1686μsec
BTFSS PORTA,0
GOTO OUT1686
CALL W038 ;1724
;1724μsec
BTFSS PORTA,0
GOTO OUT1724
;1725μsec
GOTO OUT1725
CHECK
INCF CHECKTM1,F
BTFSS STATUS,Z
GOTO TP2
INCF CHECKTM2,F
BTFSS STATUS,Z
GOTO TP2
CALL OUT00 ;65msec 以上信号入力がなかったら出力を OFF
GOTO TP2
;38μsec timer (36steps)
W038 MOVLW 0AH
MOVWF CNT050
TLP1 DECFSZ CNT050,F
GOTO TLP1
NOP
RETURN
;100μsec
W100 MOVLW 17H
MOVWF CNT100
TLP2 NOP
DECFSZ CNT100,F
GOTO TLP2
GOTO $+1
NOP
RETURN
OUT1002
CALL OUT00
GOTO LOOP
OUT1040 MOVLW D'20'
MOVWF CYCLE
LP1040
CALL OUT11
CALL WAIT050
CALL OUT00
CALL WAIT950
DECFSZ CYCLE,F
GOTO LP1040
GOTO LOOP
OUT1078 MOVLW D'20'
CALL OUT11
CALL WAIT100
CALL OUT00
CALL WAIT900
DECFSZ CYCLE,F
GOTO LP1078
GOTO LOOP
OUT1116 MOVLW D'20'
MOVWF CYCLE
LP1116
CALL OUT11
CALL WAIT150
CALL OUT00
CALL WAIT850
DECFSZ CYCLE,F
GOTO LP1116
GOTO LOOP
OUT1154 MOVLW D'20'
MOVWF CYCLE
LP1154
CALL OUT11
CALL WAIT200
CALL OUT00
CALL WAIT800
DECFSZ CYCLE,F
GOTO LP1154
GOTO LOOP
OUT1192 MOVLW D'20'
MOVWF CYCLE
LP1192
CALL OUT11
CALL WAIT250
CALL OUT00
CALL WAIT750
DECFSZ CYCLE,F
GOTO LP1192
GOTO LOOP
OUT1230 MOVLW D'20'
MOVWF CYCLE
LP1230
CALL OUT11
CALL WAIT300
CALL OUT00
CALL WAIT700
DECFSZ CYCLE,F
GOTO LP1230
GOTO LOOP
OUT1268 MOVLW D'20'
MOVWF CYCLE
LP1268
CALL OUT11
CALL WAIT350
CALL OUT00
CALL WAIT650
DECFSZ CYCLE,F
GOTO LP1268
GOTO LOOP
OUT1306 MOVLW D'20'
MOVWF CYCLE
LP1306
CALL OUT11
CALL WAIT400
CALL OUT00
CALL WAIT600
DECFSZ CYCLE,F
GOTO LP1306
GOTO LOOP
OUT1344 MOVLW D'20'
MOVWF CYCLE
LP1344
CALL OUT11
CALL WAIT450
CALL OUT00
CALL WAIT550
DECFSZ CYCLE,F
GOTO LP1344
GOTO LOOP
OUT1382 MOVLW D'20'
MOVWF CYCLE
LP1382
CALL OUT11
CALL WAIT500
CALL OUT00
CALL WAIT500
DECFSZ CYCLE,F
GOTO LP1382
GOTO LOOP
OUT1420 MOVLW D'20'
MOVWF CYCLE
LP1420
CALL OUT11
CALL WAIT550
CALL OUT00
CALL WAIT450
DECFSZ CYCLE,F
GOTO LP1420
GOTO LOOP
OUT1458 MOVLW D'20'
MOVWF CYCLE
LP1458
CALL OUT11
CALL WAIT600
CALL OUT00
CALL WAIT400
DECFSZ CYCLE,F
GOTO LP1458
GOTO LOOP
OUT1496 MOVLW D'20'
MOVWF CYCLE
LP1496
CALL OUT11
CALL WAIT650
CALL OUT00
CALL WAIT350
DECFSZ CYCLE,F
GOTO LP1496
GOTO LOOP
OUT1534 MOVLW D'20'
MOVWF CYCLE
LP1534
CALL OUT11
CALL WAIT700
CALL OUT00
CALL WAIT300
DECFSZ CYCLE,F
GOTO LP1534
GOTO LOOP
OUT1572 MOVLW D'20'
MOVWF CYCLE
LP1572
CALL OUT11
CALL WAIT750
CALL OUT00
CALL WAIT250
DECFSZ CYCLE,F
GOTO LP1572
GOTO LOOP
OUT1610 MOVLW D'20'
MOVWF CYCLE
LP1610
CALL OUT11
CALL WAIT800
CALL OUT00
CALL WAIT200
DECFSZ CYCLE,F
GOTO LP1610
GOTO LOOP
OUT1648 MOVLW D'20'
MOVWF CYCLE
LP1648
CALL OUT11
CALL WAIT850
CALL OUT00
CALL WAIT150
DECFSZ CYCLE,F
GOTO LP1648
GOTO LOOP
OUT1686 MOVLW D'20'
MOVWF CYCLE
LP1686
CALL OUT11
CALL WAIT900
CALL OUT00
CALL WAIT100
DECFSZ CYCLE,F
GOTO LP1686
GOTO LOOP
OUT1724 MOVLW D'20'
MOVWF CYCLE
LP1724
CALL OUT11
CALL WAIT950
CALL OUT00
CALL WAIT050
DECFSZ CYCLE,F
GOTO LP1724
GOTO LOOP
OUT1725
CALL OUT11
GOTO LOOP
;出力テーブル
OUT11 MOVLW B'01111111' ;PORTB RB0-RB7 HIGH
MOVWF PORTB
RETURN
OUT00 MOVLW B'00000000' ;PORTB RB0-RB7 LOW
MOVWF PORTB
RETURN
;タイマーテーブル
WAIT050
MOVLW 0BH
MOVWF CNT050
TLP3 NOP
DECFSZ CNT050,F
GOTO TLP3
NOP
RETURN
WAIT100
MOVLW 17H
MOVWF CNT100
TLP4 NOP
DECFSZ CNT100,F
GOTO TLP4
GOTO $+1
NOP
RETURN
WAIT150
MOVLW 23H
MOVWF CNT150
TLP5 NOP
DECFSZ CNT150,F
GOTO TLP5
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT200
MOVLW 41H
MOVWF CNT200
TLP6 DECFSZ CNT200,F
GOTO TLP6
RETURN
WAIT250
MOVLW 51H
MOVWF CNT250
TLP7 DECFSZ CNT250,F
GOTO TLP7
GOTO $+1
RETURN
WAIT300
MOVLW 62H
MOVWF CNT300
TLP8 DECFSZ CNT300,F
NOP
RETURN
WAIT350
MOVLW 72H
MOVWF CNT350
TLP9 DECFSZ CNT350,F
GOTO TLP9
NOP
RETURN
WAIT400
MOVLW 82H
MOVWF CNT400
TLP10 DECFSZ CNT400,F
GOTO TLP10
NOP
RETURN
WAIT450
MOVLW 92H
MOVWF CNT450
TLP11 DECFSZ CNT450,F
GOTO TLP11
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT500
MOVLW 0A2H
MOVWF CNT500
TLP12 DECFSZ CNT500,F
GOTO TLP12
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT550
MOVLW 0B2H
MOVWF CNT550
TLP13 DECFSZ CNT550,F
GOTO TLP13
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT600
MOVLW 0C4H
MOVWF CNT600
TLP14 DECFSZ CNT6700,F
GOTO TLP14
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT650
MOVLW 0D4H
MOVWF CNT650
TLP15 DECFSZ CNT650,F
GOTO TLP15
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT700
MOVLW 0E4H
MOVWF CNT700
TLP16 DECFSZ CNT700,F
GOTO TLP16
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
NOP
RETURN
WAIT750
MOVLW 0BAH
MOVWF CNT750
TLP17 DECFSZ CNT750,F
GOTO TLP17
NOP
RETURN
WAIT800
MOVLW 0C6H
MOVWF CNT800
TLP18 NOP
DECFSZ CNT800,F
GOTO TLP18
GOTO $+1
NOP
RETURN
WAIT850
MOVLW 0D3H
MOVWF CNT850
TLP19 NOP
DECFSZ CNT850,F
GOTO TLP19
NOP
RETURN
WAIT900
MOVLW 0DFH
MOVWF CNT900
TLP20 NOP
DECFSZ CNT900,F
GOTO TLP20
GOTO $+1
NOP
RETURN
WAIT950
MOVLW 0ECH
MOVWF CNT950
TLP21 NOP
DECFSZ CNT950,F
GOTO TLP21
NOP
RETURN
END