Page 32 - The Journal of the Royal Society of Thailand
P. 32
วารสารราชบััณฑิิตยสภา
ปีที� ๔๙ ฉบับที� ๑ มกราคม-เมษายน ๒๕๖๗
22 การต่่อประสานแผงวงจรไมโครคอนโทรลเลอร์เพื่่�อการเรียนร้�กับหน่วยความจำอีอีพื่ร็อมแบบอนุกรมต่ามเกณฑ์์วิธีี I2C
wtc5hi proc
;wait for PC5=SCL to go hi (if SCL is hold at “0” by ser EEPROM)
push ax
c5low:
in al,ppi_port1c ;input from Port 1C
jmp $+2 ;I/O delay
and al,20h ;detect bit PC5=SCL
cmp al,00h ;bit PC5 lo?
je c5low ;wait for clock stretch to end
pop ax
ret
wtc5hi endp
;**********************************************
i2cstr proc ;start sequence
(โปรดดูรายละเอียดในเนื้อหาของบทความ)
i2cstr endp
;**********************************************
i2cstp proc ;stop sequence
(โปรดดูรายละเอียดในเนื้อหาของบทความ)
i2cstp endp
;**********************************************
i2c_wr proc
;send 8 bits in al, receive ACK/NACK in ah
(โปรดดูรายละเอียดในเนื้อหาของบทความ)
i2c_wr endp
;**********************************************
i2c_rd proc
;receive 8 bits in to al, send ACK/NACK=0/1 in ah
;ACK=0 => acknowledge, NACK=1 => No more ACK
(โปรดดูรายละเอียดในเนื้อหาของบทความ)
i2c_rd endp
;**********************************************
prewr proc
;prepare for writing data to ser EEPROM
;input: ax = start addr in ser EEPROM to write to
(โปรดดูรายละเอียดในเนื้อหาของบทความ)
prewr endp
;**********************************************
prerd proc
;prepare for reading data from ser EEPROM
;input: ax = start addr in ser EEPROM to read from
(โปรดดูรายละเอียดในเนื้อหาของบทความ)
prerd endp
;**********************************************