Page 249 - Journal451
P. 249
วารสารราชบััณฑิิตยสภา
ปีีที่่� ๔๕ ฉบัับัที่่� ๑ มกราคม-เมษายน ๒๕๖๓
ศาสตราจารย์์ ดร.มงคล เดชนครินทร์ 237
;Page 3/7 of Fig. 6 ;Page 4/7 of Fig. 6
mov di,intflg ;interrupt flag mov si,offset dtbuf
mov byte ptr[di],0 shwlp: mov al,byte ptr[si]
mov di,xmtflg ;transmit flag call dsply2 ;display data byte
mov byte ptr[di],0 call delay2 ;add 250-ms delay
mov di,datpos ;data positn in data buff inc si ;next byte
mov word ptr[di],0 loop shwlp
;WAIT FOR INT 5Fh FROM uC PIC16F62A jmp bgin ;begin new oper. cycle
endls:
call delay2 ;wait for about 1 sec main endp
call delay2 ;******************************************
call delay2
call delay2 ;ISR activated by INT 5Fh on IR7 of 8259
isr88 proc
;check end of upload from uC PIC16F627A cli ;prevent sys interrupt
call delay1 push ax
mov si,endcnt push bx ;bl: interrupt flag
mov al,byte ptr[si] push cx
cmp al,5 ;5 FFh's counted? push dx ;dl: temp. 8 data-bits
je shwdt ;display received data ;dh: end count of FFh’s
;check transmit flag for data download to uC PIC ;get intermediate data byte
call delay1 ;64-ms delay mov si,datbyt
mov si,xmtflg mov dl,byte ptr[si]
mov al,byte ptr[si] ;get transmit flag
cmp al,0 ;al = 0 => no transmit ;retrieve end count of FFh's
je endls ;wait for next INT 5Fh mov si,endcnt
mov dh,byte ptr[si]
dwnlod: ;xmit flag !=0 => dwnld
;reset xmit flag to prevent repeat of xmission ;get interrupt flag (init. = 0)
mov di,xmtflg mov si,intflg
mov byte ptr[di],0 mov bl,byte ptr[si]
;prepare to download data by sending lead bit=”1”
onebit ;send "1" bit code ;get the lead signal from uC PIC16F627A
call delay2 ;wait 250 ms ;skip reading sync pulse in the front
call delayhms ;0.5-ms delay
;PUT DATA BYTES 01h-80h in dtbuf before sending call delay1ms ;1-ms delay
mov al,01h
mov cx,7 ;read Port1C.4 bit for 2 consecutive times
mov di,offset dtbuf ;addr. of data store in al,ppi_port1c ;read front pulse
mov byte ptr[di],al call delay1ms ;1-ms wait
fill: shl al,1 and al,10h ;take bit C4 only
inc di mov ah,al ;save front pulse in ah
mov byte ptr[di],al
loop fill in al,ppi_port1c ;read rear pulse
jmp $+2 ;I/O delay
;START SENDING 8 BYTES FROM DATA STORE and al,10h ;take bit C4 only
mov si,offset dtbuf ;addr. of data store
mov cx,8 ;for next 8 bytes ;check ah & al for data/control bit
again: mov al,byte ptr[si] ;get 8-bit data cmp ah,10h ;front pulse = 1?
call dsply1 ;display & send byte jne lgc0 ;=> "0" or stop bit
inc si ;next byte
loop again ;in the set of 8 ;check for "1" bit or start bit
cmp al,10h ;rear pulse = 1?
mov cx,5 ;send 5 FFh’s jne lgc1 ;ah=10h, al=00h => "1" bit
rpeat: mov al,0FFh ;at end of 8 bytes
call dsply1 ;display & send byte ;ah=10h,al=10h => start bit, not data-bit
loop rpeat sttbt:
jmp bgin ;start new operation cycle jmp short back3 ;with datbyt = dl=0
;display all stored data via 8255 Port2B LEDs lgc0: cmp al,00h ;rear pulse = 0?
shwdt: mov si,datpos jne stpbt ;ah=00h,al=10h => stop bit
mov cx,word ptr[si] ;total bytes stored
ภาพท่� ๖ ซึ่อฟตั์แวร์การแลกเปล้�ยนี้ข้้อมูลแบบข้ัดจังหวะข้องแผงวงจรไมโครคอนี้โทรลเลอร์ 8088 (ตั่อ)