Page 250 - Journal451
P. 250
วารสารราชบััณฑิิตยสภา
ปีีที่่� ๔๕ ฉบัับัที่่� ๑ มกราคม-เมษายน ๒๕๖๓
238 การแลกเปล่�ยนข้้อมููลแบบอนุกรมูโดยใช้้สายสัญญาณ ๒ เส้นระหว่่างไมูโครคอนโทรลเลอร์
;Page 5/7 of Fig. 6 ;Page 6/7 of Fig. 6
;at this point, DATA BIT = “0”, check bl for ;//case of lead bit=”1” => upld by uC PIC
;lead signal to download data ;reply uC PIC by sending lead bit=”0”
cmp bl,0 ;INT flag=0 => "0" = lead signal rcve: zrobit ;send "0" bit code
je xmit ;lead sig=”0” => dwnld to uC PIC call delay1 ;wait 64 ms
jmp back2 ;with intflag=1
;regular data bit=0, shift left dl but no increm. ;*************************
shl dl,1 isr88 endp
jmp short gtbck ;return ;******************************************
;Case of DATA BIT = “1”, check bl for lead signal dsply1 proc ;display and send byte in al
;to upload data out ppi_port2b,al ;turn on LEDs
lgc1: cmp bl,0 ;INT flag = 0 => "1" = lead sign call xmtdat
je rcve ;lead sig=”1” => upld by uC PIC call delay2 ;250 ms
call delay1 ;64 ms
;regular data-bit=1, shift left and increm. dl mov al,0 ;
shl dl,1 out ppi_port2b,al ;turn off LEDs
inc dl call delay2 ;250 ms
jmp short gtbck ;return call delay1 ;64 ms
ret
stpbt: dsply1 endp
;Case of stop bit, ah=00h & al=10h ;******************************************
;save 8 bits in dl to data buffer
mov di,datpos dsply2 proc ;only display byte in al
mov si,word ptr[di] out ppi_port2b,al ;turn on LEDs
mov di,offset dtbuf call delay1 ;64 ms
add di,si mov al,0 ;
;save complete data byte in store out ppi_port2b,al ;turn off LEDs
mov byte ptr[di],dl call delay2 ;250 ms
inc si ;prepare for next byte ret
mov di,datpos ;save new count of bytes dsply2 endp
mov word ptr[di],si ;******************************************
;watch for 5 consec. FFh's xmtdat proc
cmp dl,0FFh ;xmit 8 data-bits in al + start & stop bits
je cntit cli ;prevent sys interrupt
mov dh,0 ;if not FFh, reset count push cx
jmp short retrn ;for next data byte mov ah,al ;store data in ah
cntit: inc dh ;increm. end count of FFh's ;send start bit (1-1-1 pulses)
retrn: zrolev ;Port1C.3 = 0
mov di,endcnt ;save end count of FFh's onelev ;Port1C.3 = 1
mov byte ptr[di],dh onelev ;Port1C.3 = 1
;show complete data byte on Port2B LEDs (debug) onelev ;Port1C.3 = 1
mov al,dl
call dsply2 ;no xmit of data ;send 8 data bits (1-X-1) via Port1C.3 pin
mov cx,8 ;for 8 regular bits
back3: mov dl,0 ;prepare for new interm. byte rep1: mov al,ah ;retrieve data from ah
gtbck: rol al,1 ;rotate left: MSb->LSb
mov di,datbyt mov ah,al ;save rotated data
mov byte ptr[di],dl ;save dl in datbyt and al,1 ;take LSb only
back2: mov bl,1 ;bl=1 => not first-time INT cmp al,1
mov di,intflg ;set INT flag je snd1
mov byte ptr[di],bl ;save new INT flag zrobit ;send X=0
back1: jmp short lprp1
pop dx snd1: onebit ;send X=1
pop cx lprp1: loop rep1 ;next lower bit
pop bx
pop ax ;send stop bit (1-0-1 pulses)
sti ;allow sys interrupt zrolev ;Port1C.3=0
iret ;with temp. data in datbyt onelev ;Port1C.3=1
;************************* zrolev ;Port1C.3=0
;//case of lead bit=”0” => dwnld to uC PIC onelev ;Port1C.3=1
;set xmit flag and get out of ISR
xmit: mov di,xmtflg pop cx
mov byte ptr[di],1 sti ;allow sys interrupt
jmp back1 ret
;************************* xmtdat endp
;*******************************************
ภาพท่� ๖ ซึ่อฟตั์แวร์การแลกเปล้�ยนี้ข้้อมูลแบบข้ัดจังหวะข้องแผงวงจรไมโครคอนี้โทรลเลอร์ 8088 (ตั่อ)