文字データが受信できているところのテストベンチを図39〜図42に示す。
図 39では最初の立下りから半パルス分の時間をカウントしたのちの値を
図38: LED MATRIX表示機 回路図
再度読み取り、同じ値であればスタートビット確定としている。以後赤線の タイミングでデータを取り込んでいく。
図40では0xAが取り込まれていることがわかる。図 41では0xDが取り 込まれていることがわかる。図42では0x5が取り込まれていることがわか る。この時点でデータラインに0x5が出力される。
図 39: Aコードのスタートbit検出
図40: Aコードの検出
図41: Dコードの検出
図 42: 数値5の検出
参考文献
[1] 改訂版 電子工作のためのPIC16F活用ガイドブック 後閑 哲也 著 [2] C言語によるPICプログラミング入門 後閑 哲也 著
[3] 改訂VHDLによるハードウェア設計入門 長谷川 裕恭 著 [4] VHDLとCPLDによるロジック設計入門 中 幸政 [5] PIC/CPLD作れる電子回路工作入門 井上 誠一 著
9 謝辞
今回の研究と論文の製作にあたり、終始丁寧で熱心なご指導とご教示を賜 りました高知工科大学電子・光システム工学科綿森道夫助教授に深い感謝の 意を表します。本論文では綿森道夫助教授のお力添え無しでは完成まで至り ませんでした。綿森道夫助教授のおかげで完成したといっても過言ではあり ません。
また、本研究の実験遂行、各過程で終始ご厚意頂きました高知工科大学電 子・光システム工学科長 神戸宏教授、原央教授、川津哲教授、木村正廣教授、
岩下克教授、成沢忠教授、河東田隆教授、矢野政顕教授、八田章光教授、真田 克教授、山本哲也教授、野中弘二助教授、橘昌良助教授、山本真行講師、植 田和憲講師、前田元輝講師、武田光由教育講師、杉田彰久教育講師、西田謙 助手、吉村紘明助手、根引拓也助手の方々には重ねて感謝の意を述べさせて 頂きます。
10 LED ストップウォッチ ソースコード
;********************************************************
;
; StopWatch
;
;********************************************************
list p=PIC16F648A
include P16F648A.inc
;**************** Label Definition *******************
c10h equ h’20’ ;Counter adr (10th hour) c01h equ h’21’ ;Counter adr (1st hour) c10m equ h’22’ ;Counter adr (10th min) c01m equ h’23’ ;Counter adr ( 1st min) c10s equ h’24’ ;Counter adr (10th sec) c01s equ h’25’ ;Counter adr ( 1st sec) c1000 equ h’26’ ;Counter adr (1000th sub-sec) c100 equ h’27’ ;Counter adr (100th sub-sec) c10 equ h’28’ ;Counter adr (10th sub-sec) c001 equ h’29’ ;Counter adr (1st sub-sec)
hyoji equ h’2a’ ;0 -> --h--m--s-- / 1 -> --m--s----temp equ h’2b’ ;Adjust waiting time
running equ h’30’
pushed equ h’31’ ;0 -> pushed, 1 -> release chnum equ h’32’
pushch equ h’33’
relech equ h’34’
letgo equ h’35’
keta equ h’3a’ ;display position 0~7 bcd_in equ h’3b’ ;display substance
seg7_0 equ b’11000000’ ;Pattern 0 seg7_1 equ b’11111001’ ;Pattern 1 seg7_2 equ b’10100100’ ;Pattern 2 seg7_3 equ b’10110000’ ;Pattern 3 seg7_4 equ b’10011001’ ;Pattern 4 seg7_5 equ b’10010010’ ;Pattern 5
seg7_6 equ b’10000010’ ;Pattern 6 seg7_7 equ b’11111000’ ;Pattern 7 seg7_8 equ b’10000000’ ;Pattern 8 seg7_9 equ b’10010000’ ;Pattern 9
seg70 equ h’40’ ;Pattern 0 set address seg71 equ h’41’ ;Pattern 1 set address seg72 equ h’42’ ;Pattern 2 set address seg73 equ h’43’ ;Pattern 3 set address seg74 equ h’44’ ;Pattern 4 set address seg75 equ h’45’ ;Pattern 5 set address seg76 equ h’46’ ;Pattern 6 set address seg77 equ h’47’ ;Pattern 7 set address seg78 equ h’48’ ;Pattern 8 set address seg79 equ h’49’ ;Pattern 9 set address
w_save equ h’4a’ ;W Register save adr s_save equ h’4b’ ;STATUS Register save adr
CNT1 equ h’4c’ ;1m sec conter address CNT2 equ h’4d’ ;1m sec conter address
;**************** Program Start ***********************
org 0 ;Reset Vector
goto init
org 4 ;Interrupt Vector
goto int
;**************** Initial Process *********************
init
bcf status, rp0 movlw h’07’
movwf cmcon ;All digital bsf status, rp0 ;Change to Bank1 movlw b’00111000’ ;RA012 out / RA345 in
movwf trisa ;Set PORTA
clrf trisb ;RB all out
movlw b’10000111’ ;not RBPU/TOCS/PSA=0,PS=111 movwf option_reg ;Set OPTION_REG
movlw b’00000100’ ;CCP1IE -ON
movwf pie1
bcf status, rp0 ;Change to Bank0
movlw 0xff
movwf portb ;Set OFF all 7seg
movlw b’01000000’
movwf intcon ;PEIE-ON / GIE-OFF
movlw b’00001011’
movwf ccp1con ;compare mode、Spcial event trigger
movlw 0x01 movwf ccpr1h movlw 0xF4
movwf ccpr1l ;compare = 0.2u*500 = 100u Sec
clrf t1con ;TMR1:prescaler 1:1 not use clrf tmr1h
clrf tmr1l
movlw seg7_0 ;Set 7segment pattern 0 movwf seg70 ;Save pattern 0
movlw seg7_1 ;Set 7segment pattern 1 movwf seg71 ;Save pattern 1
movlw seg7_2 ;Set 7segment pattern 2 movwf seg72 ;Save pattern 2
movlw seg7_3 ;Set 7segment pattern 3 movwf seg73 ;Save pattern 3
movlw seg7_4 ;Set 7segment pattern 4 movwf seg74 ;Save pattern 4
movlw seg7_5 ;Set 7segment pattern 5 movwf seg75 ;Save pattern 5
movlw seg7_6 ;Set 7segment pattern 6 movwf seg76 ;Save pattern 6
movlw seg7_7 ;Set 7segment pattern 7 movwf seg77 ;Save pattern 7
movlw seg7_8 ;Set 7segment pattern 8 movwf seg78 ;Save pattern 8
movlw seg7_9 ;Set 7segment pattern 9 movwf seg79 ;Save pattern 9
;************* Timer stand-by Process *****************
stand_by
clrf c10h clrf c01h clrf c10m clrf c01m clrf c10s clrf c01s clrf c1000 clrf c100 clrf c10 clrf c001 clrf running clrf letgo clrf pushed clrf tmr1h
clrf tmr1l ;Clear just in case
; movlw 0
; movwf c10h
; movlw 0
; movwf c01h
; movlw 0
; movwf c10m
; movlw 0
; movwf c01m
; movlw 0
; movwf c10s
; movlw 0
; movwf c01s
; movlw 0
; movwf c1000
; movlw 0
; movwf c100
; movlw 0
; movwf c10
; movlw 0
; movwf c01 ;If you want to change initial display, change here
loopin
bcf intcon, gie
bcf t1con, 0 ;TMR 1 STOP
clrf tmr1h
clrf tmr1l ;Clear just in case hloop
call led_cont ;Call LED Countrol sub btfsc porta, 4
goto go ;reset check
clrf c10h clrf c01h clrf c10m clrf c01m clrf c10s clrf c01s clrf c1000 clrf c100 clrf c10 clrf c001
goto hloop
;************** Timer start Process *******************
go
btfss letgo, 0 goto loopin
bsf intcon, gie ;Interruption enable
bsf t1con, 0 ;TMR1 start
loop
call led_cont ;Call LED Countrol sub btfss letgo, 0
goto loopin goto loop
;************* 1msec Timer Subroutine *****************
wait
movlw 0x04 movwf cnt2
t1m2
movlw 0xF2 movwf cnt1 timloop
nop
decfsz cnt1, f goto timloop decfsz cnt2, f goto t1m2 return
;************ Bottom Check *************************
checkin movlw 9 movwf chnum clrf pushch clrf relech btfsc running, 0 goto stopchk btfss pushed, 0
goto Lcheck1_stop ;押されてなければLのチェックのみ
goto Hcheck1_stop ;押されてたらHのチェックのみ Lcheck1_stop
btfsc porta, 3 return
goto LinL_stop LinL_stop
bcf pushch, 0 rlf pushch, f Lcheck2_stop
decfsz chnum
goto Lcheck1_stop movf pushch, w btfsc status, z bsf pushed, 0 bsf letgo, 0 return
Hcheck1_stop
btfsc porta, 3 goto HinH_stop
return HinH_stop
bsf relech, 0 rlf relech, f goto Hcheck2_stop Hcheck2_stop
decfsz chnum
goto Hcheck1_stop movlw 0xff
subwf relech, w btfss status, z return
bcf pushed, 0 bsf running, 0 return
;**********************************
stopchk
btfss pushed, 0
goto Lcheck1_run ;押されてなければLのチェックのみ goto Hcheck1_run ;押されてたらHのチェックのみ Lcheck1_run
btfsc porta, 3 return
goto LinL_run LinL_run
bcf pushch, 0 rlf pushch, f Lcheck2_run
decfsz chnum goto Lcheck1_run movf pushch, w btfsc status, z bsf pushed, 0 bcf letgo, 0 return
Hcheck1_run
btfsc porta, 3 goto HinH_run return
HinH_run
bsf relech, 0 rlf relech, f goto Hcheck2_run Hcheck2_run
decfsz chnum goto Hcheck1_run movlw 0xff
subwf relech, w btfss status, z return
bcf pushed, 0 bcf running, 0 return
;************ Begin Interruption Process **************
int
movwf w_save ;Save W register movf status,w ;Read STATUS reg movwf s_save ;Save STATUS reg bcf status,rp0 ;Change to Bank0 btfss pir1, ccp1if
goto int_end
;*********** Interruption routine by ccp1if **************
count
incf c001, f movlw 10
subwf c001, w ;freg - wreg -> wreg btfss status, z
goto int_end ;10を引いて0ではなかった -> 桁上がりなし clrf c001
incf c10, f movlw 10 subwf c10, w btfss status, z goto int_end clrf c10 incf c100, f movlw 10 subwf c100, w
btfss status, z goto int_end clrf c100 incf c1000, f movlw 10 subwf c1000, w btfss status, z goto int_end clrf c1000 incf c01s, f movlw 10 subwf c01s, w btfss status, z goto int_end clrf c01s incf c10s, f movlw 6 subwf c10s, w btfss status, z goto int_end clrf c10s incf c01m, f movlw 10 subwf c01m, w btfss status, z goto int_end clrf c01m incf c10m, f movlw 6 subwf c10m, w btfss status, z goto int_end clrf c10m incf c01h, f movlw 10 subwf c01h, w btfss status, z goto int_end clrf c01h
incf c10h, f movlw 10 subwf c10h, w btfss status, z goto int_end clrf c10h
;************ END of Interruption Process **************
int_end
bcf pir1, ccp1if ;Clear interrupt flag movf s_save,w ;Read saved STATUS reg movwf status ;Recover STATUS reg swapf w_save,f ;Read saved W register swapf w_save,w ;Recover W register retfie
;*****************************************************
;************** LED Control Subroutine *************
;*****************************************************
led_cont
btfss porta, 5 ;mode switch check
goto type2 ;type2:2ndmode
type1
clrf hyoji
;--h--m--s--clrf keta ;HC138-Q0:L
;----1 桁目表示---movf keta, w movwf porta movf c10h, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----2 桁目表示---movf keta, w movwf porta movf c01h, w
movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----3 桁目表示---movf keta, w movwf porta movf c10m, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----4 桁目表示---movf keta, w movwf porta movf c01m, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----5 桁目表示---movf keta, w movwf porta movf c10s, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb
incf keta, f
;----6 桁目表示---movf keta, w movwf porta movf c01s, w movwf bcd_in call bcd_7seg bcf portb, 7 ;dot call wait
call checkin movlw h’ff’
movwf portb incf keta, f
;----7 桁目表示---movf keta, w movwf porta movf c1000, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----8 桁目表示---movf keta, w movwf porta movf c100, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb return
;---type2
movlw h’01’;--m--s----movwf hyoji
clrf keta ;HC138-Q0:L
;----1 桁目表示---movf keta, w movwf porta movf c10m, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----2 桁目表示---movf keta, w movwf porta movf c01m, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----3 桁目表示---movf keta, w movwf porta movf c10s, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----4 桁目表示---movf keta, w movwf porta movf c01s, w movwf bcd_in
call bcd_7seg bcf portb, 7 ;dot call wait
call checkin movlw h’ff’
movwf portb incf keta, f
;----5 桁目表示---movf keta, w movwf porta movf c1000, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----6 桁目表示---movf keta, w movwf porta movf c100, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb incf keta, f
;----7 桁目表示---movf keta, w movwf porta movf c10, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb
incf keta, f
;----8 桁目表示---movf keta, w movwf porta movf c001, w movwf bcd_in call bcd_7seg call wait call checkin movlw h’ff’
movwf portb return
;---bcd_7seg
movlw seg70 addwf bcd_in, w movwf fsr movf indf, w movwf portb return
end
11 LCD ストップウォッチ ソースコード
;********************************************************
;
; 大型LCD TZ250Aを使ったStop Watch
;
;********************************************************
list p=PIC16F628A include P16F628A.inc
__config _xt_osc & _wdt_off & _pwrte_off & _boden_of&
_mclre_off & _cp_off & _lvp_off
;**************** Label Definition *******************
c10m equ h’20’ ;Counter adr (10th min) c01m equ h’21’ ;Counter adr (1st min) c10s equ h’22’ ;Counter adr (10th sec) c01s equ h’23’ ;Counter adr (1st sec) c10 equ h’24’ ;Counter adr (10th sub-sec) c01 equ h’25’ ;Counter adr (100th sub-sec)
t0tmp equ h’26’ ;TMR0用
work1 equ h’27’ ;展開ルーチン用
work2 equ h’28’
w_save equ h’30’ ;W Register save adr s_save equ h’31’ ;STATUS Register save adr gogo equ h’32’
running equ h’33’
pushed equ h’34’
chnum equ h’35’
pushch equ h’36’
rerech equ h’37’
letgo equ h’38’
first equ h’39’
gogoch equ h’3A’
d10m equ h’40’
d01m equ h’41’
d10s equ h’42’
d01s equ h’43’
d10 equ h’44’
d01 equ h’45’
segch equ h’46’
blight equ h’47’
seg_code equ h’48’
;**************** Program Start ***********************
org 0 ;Reset Vector
goto init
org 4 ;Interrupt Vector
goto int
;**************** Initial Process *********************
init
bcf status, rp0 movlw h’07’
movwf cmcon ;All digital
bsf status, rp0 ;Change to Bank1 movlw b’00111000’ ;RA012 out / RA345 in
movwf trisa ;Set PORTA
movlw b’01000000’
movwf trisb ;RB6 in others out
movlw b’10000111’ ;not RBPU/TOCS/PSA=0,PS=111 movwf option_reg ;Set OPTION_REG
movlw b’00000100’ ;CCP1IE -ON movwf pie1
movlw 200 movwf pr2
bcf status, rp0 ;Change to Bank0 bsf portb, 5 ;RESET->ON movlw b’01000000’
movwf intcon ;PEIE-ON / GIE-OFF movlw b’00001011’
movwf ccp1con ;compare mode , special event trigger movlw 0x27
movwf ccpr1h movlw 0x10
movwf ccpr1l ;compare = 1u*10000 = 10mSec clrf t1con ;TMR1:pre1:1 not use
clrf tmr1h
clrf tmr1l ;tmr1 reset
clrf c10m clrf c01m clrf c10s clrf c01s clrf c10 clrf c01 clrf gogo clrf gogoch clrf letgo
;---Reset---bsf portb, 5 ;RESET->ON
movlw 8 movwf t0tmp clrf tmr0 reset_wait1_1
bcf intcon, t0if reset_wait1_2
btfss intcon, t0if goto reset_wait1_2 decfsz t0tmp, f
goto reset_wait1_1 ;500mSecWait bcf portb, 5 ;RESET ->Low movlw 8
movwf t0tmp clrf tmr0 reset_wait2_1
bcf intcon, t0if reset_wait2_2
btfss intcon, t0if goto reset_wait2_2 decfsz t0tmp, f
goto reset_wait2_1 ;500m Sec Wait
;---bsf status, rp0 ;Bank1へ
movlw b’10000001’
movwf option_reg ;prescaler 1:4 bcf status, rp0 ;Bank0へ movlw 0xA1
movwf d10m movlw 0x96 movwf d01m movlw 0xA5 movwf d10s movlw 0xA5 movwf d01s movlw 0xB0 movwf d10 movlw 0xC6
movwf d01 ;initial display
movlw 1 movwf first movlw 5
movwf gogo ;初期表示が最後まで通るように
bsf gogoch, 0 movlw 0x01 movwf segch movlw 0x00
movwf blight ;00:消灯,FF:点灯
movlw 0xE0 movwf seg_code
;--- dokokara ikimasuka ? ---dokokara?
btfss gogoch, 0 return
clrf gogoch clrf porta movf gogo, w btfsc status, z
goto keta0.01 ;1/100のみ更新
movf gogo, w sublw 1
btfsc status, z
goto keta0.1 ;1/10から更新
movf gogo, w
sublw 2
btfsc status, z
goto keta01s ;1Secから更新
movf gogo, w sublw 3
btfsc status, z
goto keta10s ;10Secから更新
movf gogo, w sublw 4
btfsc status, z
goto keta01m ;1Minから更新
;---10min keta10m
btfsc first, 0 goto keta10m_2 movf c10m, w call tenkai
movwf d10m ;コード展開
keta10m_2 movlw 0 movwf porta
movf d10m, w ;d01を表示
andlw b’00001111’ ;下位4bitを取り出す
movwf portb ;下位データを出力
bsf portb, 4 ;strobe high busylp_d10m
btfss portb, 6 ;busyがhighになるまで待つ goto busylp_d10m
bcf portb, 4 ;strobe low bcf intcon, t0if ;TMR0 flag clear movlw 42
movwf tmr0 ;TMR0 count 42 clear t0lp1_d10m
btfss intcon, t0if ;855u sec wait goto t0lp1_d10m
btfss portb, 6 ;check busy clear goto highb_d10m
busyc1_d10m
btfsc portb, 6 ;busyがlowになるまで待つ
goto busyc1_d10m highb_d10m
swapf d10m, w ;下位と上位を入れ替える
andlw b’00001111’ ;元上位4bitを取り出す
movwf portb ;上位データを出力
bsf portb, 4 ;strobe high busylp2_d10m
btfss portb, 6 ;busyがhighになるまで待つ goto busylp2_d10m
bcf portb, 4 ;strobe low bcf intcon, t0if ;TMR0 flag clear movlw 42
movwf tmr0 ;TMR0 count 42 clear t0lp2_d10m
btfss intcon, t0if ;855u sec wait goto t0lp2_d10m
btfss portb, 6 ;check busy clear goto keta01m
busyc2_d10m
btfsc portb, 6 ;busyがlowになるまで待つ goto busyc2_d10m
;---1min keta01m
btfsc first, 0 goto keta01m_2 movf c01m, w call tenkai movwf d01m keta01m_2
movlw 1 movwf porta movf d01m, w andlw b’00001111’
movwf portb bsf portb, 4 busylp_d01m
btfss portb, 6 goto busylp_d01m bcf portb, 4
bcf intcon, t0if movlw 42
movwf tmr0 t0lp1_d01m
btfss intcon, t0if goto t0lp1_d01m btfss portb, 6 goto highb_d01m busyc1_d01m
btfsc portb, 6 goto busyc1_d01m highb_d01m
swapf d01m, w andlw b’00001111’
movwf portb bsf portb, 4 busylp2_d01m
btfss portb, 6 goto busylp2_d01m bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp2_d01m
btfss intcon, t0if goto t0lp2_d01m btfss portb, 6 goto keta10s busyc2_d01m
btfsc portb, 6 goto busyc2_d01m
;---10Sec keta10s
btfsc first, 0 goto keta10s_2 movf c10s, w call tenkai movwf d10s keta10s_2
movlw 2 movwf porta movf d10s, w andlw b’00001111’
movwf portb bsf portb, 4 busylp_d10s
btfss portb, 6 goto busylp_d10s bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp1_d10s
btfss intcon, t0if goto t0lp1_d10s btfss portb, 6 goto highb_d10s busyc1_d10s
btfsc portb, 6 goto busyc1_d10s highb_d10s
swapf d10s, w andlw b’00001111’
movwf portb bsf portb, 4 busylp2_d10s
btfss portb, 6 goto busylp2_d10s bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp2_d10s
btfss intcon, t0if goto t0lp2_d10s btfss portb, 6 goto keta01s busyc2_d10s
btfsc portb, 6 goto busyc2_d10s
;---1Sec keta01s
btfsc first, 0 goto keta01s_2 movf c01s, w call tenkai movwf d01s keta01s_2
movlw 3 movwf porta movf d01s, w andlw b’00001111’
movwf portb bsf portb, 4 busylp_d01s
btfss portb, 6 goto busylp_d01s bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp1_d01s
btfss intcon, t0if goto t0lp1_d01s btfss portb, 6 goto highb_d01s busyc1_d01s
btfsc portb, 6 goto busyc1_d01s highb_d01s
swapf d01s, w andlw b’00001111’
movwf portb bsf portb, 4 busylp2_d01s
btfss portb, 6 goto busylp2_d01s
bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp2_d01s
btfss intcon, t0if goto t0lp2_d01s btfss portb, 6 goto keta0.1 busyc2_d01s
btfsc portb, 6 goto busyc2_d01s
;---1/10 keta0.1
btfsc first, 0 goto keta0.1_2 movf c10, w call tenkai movwf d10 keta0.1_2
movlw 4 movwf porta movf d10, w andlw b’00001111’
movwf portb bsf portb, 4 busylp_d10
btfss portb, 6 goto busylp_d10 bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp1_d10
btfss intcon, t0if goto t0lp1_d10 btfss portb, 6 goto highb_d10 busyc1_d10
btfsc portb, 6 goto busyc1_d10 highb_d10
swapf d10, w andlw b’00001111’
movwf portb bsf portb, 4 busylp2_d10
btfss portb, 6 goto busylp2_d10 bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp2_d10
btfss intcon, t0if goto t0lp2_d10 btfss portb, 6 goto keta0.01 busyc2_d10
btfsc portb, 6 goto busyc2_d10
;---1/100 keta0.01
btfsc first, 0 goto keta0.01_2 movf c01, w call tenkai movwf d01 keta0.01_2
movlw 5 movwf porta movf d01, w andlw b’00001111’
movwf portb bsf portb, 4 busylp_d01
btfss portb, 6 goto busylp_d01
bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp1_d01
btfss intcon, t0if goto t0lp1_d01 btfss portb, 6 goto highb_d01 busyc1_d01
btfsc portb, 6 goto busyc1_d01 highb_d01
swapf d01, w andlw b’00001111’
movwf portb bsf portb, 4 busylp2_d01
btfss portb, 6 goto busylp2_d01 bcf portb, 4 bcf intcon, t0if movlw 42
movwf tmr0 t0lp2_d01
btfss intcon, t0if goto t0lp2_d01 btfss portb, 6 goto segments busyc2_d01
btfsc portb, 6 goto busyc2_d01
;---segments
btfss segch, 0 goto seg_end movf blight, f
btfss status, z ;Z flagが立つ->消灯 goto seg_off