|
;自動バッテリー切替え装置
10min
+
20min
+
40min
(10min
-
70min)
and
100min |
;btchange.asm
Ver.
0.03 |
;PIC16F84A
@4MHz |
|
|
|
|
|
LIST |
P=PIC16F84A |
|
INCLUDE |
"P16F84A.INC" |
|
|
|
|
CNT1 |
EQU |
0CH |
;1msec
timer
で使用 |
CNT2 |
EQU |
0DH |
;100msec
timer
で使用 |
CNT3 |
EQU |
0EH |
;1sec
timer
で使用 |
CNT4 |
EQU |
0FH |
;30sec
timer
で使用 |
CNT5 |
EQU |
10H |
;10min
timer
で使用 |
SETTIME |
EQU |
11H |
;セットタイムを格納 |
COUNT |
EQU |
12H |
;サムホイールスイッチのセット数値を格納(1-7) |
CHKST |
EQU |
13H |
;タイマーセットのチェック用(1ならタイマーセットあり) |
|
|
|
|
|
ORG |
0 |
;0
番地スタート |
START |
|
|
|
|
BSF |
STATUS,RP0 |
;STATUS
レジスタの
RP0
ビットを
1
にして
Bank1
に切り替え |
|
MOVLW |
0FFH |
;入力モード用に
1
をセット |
|
MOVWF |
TRISA |
;PORTA
をすべて入力モードに設定 |
|
CLRF |
TRISB |
;PORTB
をすべて出力モードに設定 |
|
BCF |
STATUS,RP0 |
;Bank0
に戻る |
|
CLRF |
SETTIME |
;SETTIME
レジスタを
0
クリア |
|
CLRF |
CHKST |
;CHKST
レジスタを
0
クリア |
MAIN |
|
|
|
|
BTFSS |
PORTA,
0 |
;RA0
が
1
だったら次の命令をスキップ |
|
CALL |
TIMER10 |
;
の処理へ |
|
BTFSS |
PORTA,
1 |
;RA1
が
1
だったら次の命令をスキップ |
|
CALL |
TIMER20 |
;
の処理へ |
|
BTFSS |
PORTA,
2 |
;RA2
が
1
だったら次の命令をスキップ |
|
CALL |
TIMER40 |
;
の処理へ |
|
BTFSS |
CHKST,
0 |
;CHKST
の
0
ビットが
1
だったら次の命令をスキップ |
|
CALL |
TIMER100 |
;SETTIME
レジスタが
0
なら
TIMER100
の処理へ |
|
|
|
|
;RB0
OUT |
|
|
|
B0 |
|
|
|
|
MOVLW |
01H |
;01H
を
W
レジスタに格納 |
|
MOVWF |
PORTB |
;RB0
を
High |
|
CALL |
TIMESTART |
;サブルーチンコール |
|
MOVLW |
00H |
;00H
を
W
レジスタに格納 |
|
MOVWF |
PORTB |
;RB0
を
Low |
|
CALL |
T30sec |
;30sec
のインターバル |
|
|
|
|
;RB1
OUT |
|
|
|
B1 |
|
|
|
|
MOVLW |
02H |
|
|
MOVWF |
PORTB |
|
|
CALL |
TIMESTART |
|
|
MOVLW |
00H |
|
|
MOVWF |
PORTB |
|
|
CALL |
T30sec |
|
|
|
|
|
;RB2
OUT |
|
|
|
B2 |
|
|
|
|
MOVLW |
04H |
|
|
MOVWF |
PORTB |
|
|
CALL |
TIMESTART |
|
|
MOVLW |
00H |
|
|
MOVWF |
PORTB |
|
|
CALL |
T30sec |
|
|
|
|
|
;RB3
OUT |
|
|
|
B3 |
|
|
|
|
MOVLW |
08H |
|
|
MOVWF |
PORTB |
|
|
CALL |
TIMESTART |
|
|
MOVLW |
00H |
|
|
MOVWF |
PORTB |
|
|
CALL |
T30sec |
|
|
|
|
|
;RB4
OUT |
|
|
|
B4 |
|
|
|
|
MOVLW |
010H |
|
|
MOVWF |
PORTB |
|
|
CALL |
TIMESTART |
|
|
MOVLW |
00H |
|
|
MOVWF |
PORTB |
|
|
CALL |
T30sec |
|
|
|
|
|
;RB5
OUT |
|
|
|
B5 |
|
|
|
|
MOVLW |
020H |
|
|
MOVWF |
PORTB |
|
|
CALL |
TIMESTART |
|
|
MOVLW |
00H |
|
|
MOVWF |
PORTB |
|
|
|
|
|
;RB6
OUT
(充電サイクル完了表示
LED
点灯用) |
B6 |
|
|
|
|
MOVLW |
040H |
|
|
MOVWF |
PORTB |
|
|
GOTO |
B6 |
|
|
|
|
|
;タイマーセットルーチン |
TIMER10 |
|
|
;10min
timer |
|
MOVLW |
01H |
|
|
ADDWF |
SETTIME,
F |
;SETTIME
レジスタに
1
を加算 |
|
MOVLW |
01H |
|
|
MOVWF |
CHKST |
;CHKST
レジスタに
1
を格納 |
|
RETURN |
|
|
|
|
|
|
TIMER20 |
|
|
;20min
timer |
|
MOVLW |
02H |
|
|
ADDWF |
SETTIME,
F |
;SETTIME
レジスタに
2
を加算 |
|
MOVLW |
01H |
|
|
MOVWF |
CHKST |
;CHKST
レジスタに
1
を格納 |
|
RETURN |
|
|
|
|
|
|
TIMER40 |
|
|
;40min
timer |
|
MOVLW |
04H |
|
|
ADDWF |
SETTIME,
F |
;SETTIME
レジスタに
4
を加算 |
|
MOVLW |
01H |
|
|
MOVWF |
CHKST |
;CHKST
レジスタに
1
を格納 |
|
RETURN |
|
|
|
|
|
|
TIMER100 |
|
|
;100min
timer |
|
MOVLW |
0AH |
|
|
ADDWF |
SETTIME,
F |
;SETTIME
レジスタに
10
を加算 |
|
RETURN |
|
|
|
|
|
|
;タイマー実行ルーチン |
;COUNT
x
10min |
TIMESTART |
|
|
|
|
MOVF |
SETTIME,
W |
|
|
MOVWF |
COUNT |
|
TIMSLOOP |
|
|
|
|
CALL |
T10min |
|
|
DECFSZ |
COUNT,
F |
|
|
GOTO |
TIMSLOOP |
|
|
RETURN |
|
|
|
|
|
|
;タイマールーチン |
;1msec
timer |
T1msec |
|
|
|
|
MOVLW |
0F9H |
;249 |
|
MOVWF |
CNT1 |
|
T1MLOOP |
NOP |
|
|
|
DECFSZ |
CNT1,
F |
|
|
GOTO |
T1MLOOP |
|
|
RETURN |
|
|
|
|
|
|
;100msec
timer |
T100msec |
|
|
|
|
MOVLW |
064H |
;100 |
|
MOVWF |
CNT2 |
;1msec
x
100
=
100msec |
T100MLOOP |
|
|
|
|
CALL |
T1msec |
|
|
DECFSZ |
CNT2,
F |
|
|
GOTO |
T100MLOOP |
|
|
RETURN |
|
|
|
|
|
|
;1sec
timer |
T1sec |
|
|
|
|
MOVLW |
0AH |
;10 |
|
MOVWF |
CNT3 |
;100msec
x
10
=
1sec |
T1SLOOP |
|
|
|
|
CALL |
T100msec |
|
|
DECFSZ |
CNT3,
F |
|
|
GOTO |
T1SLOOP |
|
|
RETURN |
|
|
|
|
|
|
:30sec
timer |
T30sec |
|
|
|
|
MOVLW |
1EH |
;30 |
|
MOVWF |
CNT4 |
;100msec
x
30
=
30sec |
T30SLOOP |
|
|
|
|
CALL |
T1sec |
|
|
DECFSZ |
CNT4,
F |
|
|
GOTO |
T30SLOOP |
|
|
RETURN |
|
|
|
|
|
|
;10min
timer |
T10min |
|
|
|
|
MOVLW |
14H |
;20 |
|
MOVWF |
CNT5 |
;30sec
x
20
=
10min |
T10MLOOP |
|
|
|
|
CALL |
T30sec |
|
|
DECFSZ |
CNT5,
F |
|
|
GOTO |
T10MLOOP |
|
|
RETURN |
|
|
|
|
|
|
|
END |
|
|
|
|
|
|
|
|
|
|