當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] ;*************************************************;Function:基于HT48R50A的AT24C02IIC示例程序*;MicroProcessor:HT48R50A-1/28SKDIP-A*;Author:www.picavr.com*;Crystal:4MHz*;*******************

;*************************************************
;Function:基于HT48R50AAT24C02IIC示例程序*

;MicroProcessor:HT48R50A-1/28SKDIP-A*

;Author:www.picavr.com*
;Crystal:4MHz*
;*************************************************
#INCLUDEHT48R50A-1.INC
OKEQU0CCH
ERROREQU0DDH
;--------------------------------------------------------------------
PUBLICHT_DEVICE_ADD
PUBLICHT_DATA
PUBLICHT_DATA_ADD
;--------------------------------------------------------------------
EXTERNLCD_RESET:NEAR
EXTERNLCD_CURSOR:NEAR
EXTERNLCD_PUT_A_CHAR:NEAR
EXTERNDELAY_LONG:NEAR

EXTERNKEY_GET:NEAR
EXTERNKEY_IN_ADDRESS:NEAR
EXTERNKEY_IN_DATA:NEAR

EXTERNBYTE_WRITE:NEAR
EXTERNPAGE_WRITE:NEAR
EXTERNCURRENT_READ:NEAR
EXTERNRANDOM_READ:NEAR
EXTERNSEQUENTIAL_READ:NEAR

EXTERNMESSAGE_01:NEAR
EXTERNMESSAGE_02:NEAR
EXTERNMESSAGE_03:NEAR
EXTERNMESSAGE_04:NEAR
EXTERNMESSAGE_05:NEAR
EXTERNMESSAGE_06:NEAR
EXTERNMESSAGE_07:NEAR
EXTERNMESSAGE_08:NEAR
EXTERNMESSAGE_09:NEAR
EXTERNMESSAGE_10:NEAR
EXTERNMESSAGE_11:NEAR
EXTERNMESSAGE_12:NEAR
EXTERNMESSAGE_13:NEAR
EXTERNMESSAGE_14:NEAR
EXTERNMESSAGE_15:NEAR
EXTERNMESSAGE_16:NEAR
EXTERNMESSAGE_17:NEAR
EXTERNBIN_TO_HEX_TABLE:NEAR
EXTERNDEC_TO_HEX_TABLE:NEAR
EXTERNHEX_TO_TEXT_TABLE:NEAR
;--------------------------------------------------------------------
EXTERNKEY_DATA:BYTE
EXTERNKEY_IN_ADD_BUFFER:BYTE
EXTERNKEY_IN_DATA_BUFFER:BYTE
EXTERNSEQUENTIAL_READ_BUFFER:BYTE
;--------------------------------------------------------------------
DATA_9724.SECTIONAT60H’DATA’
HT_DEVICE_ADDDB?
HT_DATADB?
HT_DATA_ADDDB?
COUNTERDB?
DATA_REGISTERDB?
ADDRESS_REGISTERDB?
SEQ_COUNTERDB?
;--------------------------------------------------------------------
CODE.SECTIONAT00H’CODE’
ORG00H
JMPSTART
START:
SETPBC
SETPB

CALLLCD_RESET

CALLMESSAGE_01
CALLKEY_GET
;--------------------------------------------------------------------
SELECT_12:
CALLMESSAGE_02
MOV A,4FH
CALLLCD_CURSOR
AGAIN_12:
CALLKEY_GET
MOV A,KEY_DATA
SUBA,0DH
SZACC
JMPCOMPARE_12_1
JMPSELECT_34
COMPARE_12_1:
MOV A,KEY_DATA
SUBA,01H
SZACC
JMPCOMPARE_12_2
JMPFUNCTION_1
COMPARE_12_2:
MOV A,KEY_DATA
SUBA,02H
SZACC
JMPAGAIN_12
JMPFUNCTION_2
RET
;--------------------------------------------------------------------
SELECT_34:
CALLMESSAGE_03
MOV A,4FH
CALLLCD_CURSOR
AGAIN_34:
CALLKEY_GET
MOV A,KEY_DATA
SUBA,0CH
SZACC
JMPCOMPARE_34_D
JMPSELECT_12
COMPARE_34_D:
MOV A,KEY_DATA
SUBA,0DH
SZACC
JMPCOMPARE_34_3
JMPSELECT_56
COMPARE_34_3:
MOV A,KEY_DATA
SUBA,03H
SZACC
JMPCOMPARE_34_4
JMPFUNCTION_3
COMPARE_34_4:
MOV A,KEY_DATA
SUBA,04H
SZACC
JMPAGAIN_34
JMPFUNCTION_4
RET
;--------------------------------------------------------------------
SELECT_56:
CALLMESSAGE_04
MOV A,4FH
CALLLCD_CURSOR
AGAIN_56:
CALLKEY_GET
MOV A,KEY_DATA
SUBA,0CH
SZACC
JMPCOMPARE_56_D
JMPSELECT_34
COMPARE_56_D:
MOV A,KEY_DATA
SUBA,0DH
SZACC
JMPCOMPARE_56_5
JMPSELECT_7
COMPARE_56_5:
MOV A,KEY_DATA
SUBA,05H
SZACC
JMPCOMPARE_56_6
JMPFUNCTION_5
COMPARE_56_6:
MOV A,KEY_DATA
SUBA,06H
SZACC
JMPAGAIN_56
JMPFUNCTION_6
RET
;--------------------------------------------------------------------
SELECT_7:
CALLMESSAGE_05
MOV A,4FH
CALLLCD_CURSOR
AGAIN_7:
CALLKEY_GET
MOV A,KEY_DATA
SUBA,0CH
SZACC
JMPCOMPARE_7_7
JMPSELECT_56
COMPARE_7_7:
MOV A,KEY_DATA
SUBA,07H
SZACC
JMPAGAIN_7
JMPFUNCTION_7
RET
;--------------------------------------------------------------------
FUNCTION_1:
CALLMESSAGE_08
MOV A,4FH
CALLLCD_CURSOR
F_1_AGAIN:
CALLKEY_GET
MOV A,KEY_DATA
SUBA,01H
SZACC
JMPF_1_COMPARE_2
CALLMESSAGE_09
SETPC.4;WRITEPROTECT
CALLKEY_GET;ENABLE
JMPF_1_END
F_1_COMPARE_2:
MOV A,KEY_DATA
SUBA,02H
SZACC
JMPF_1_AGAIN
CALLMESSAGE_10
CLRPC.4;WRITEPROTECT
CALLKEY_GET;DISABLE
F_1_END:
JMPSELECT_12
RET
;--------------------------------------------------------------------
FUNCTION_2:
CALLMESSAGE_06
MOV A,41H
CALLLCD_CURSOR
CALLKEY_IN_ADDRESS
CALLBIN_TO_HEX
SUBA,OK
SZACC
JMPF_2_ERROR
CALLMESSAGE_07
CALLKEY_GET
JMPF_2_END
F_2_ERROR:
CALLMESSAGE_15
CALLKEY_GET
F_2_END:
JMPSELECT_12
RET
;--------------------------------------------------------------------
FUNCTION_3:
CALLMESSAGE_11
MOV A,41H
CALLLCD_CURSOR
CALLKEY_IN_ADDRESS
CALLDEC_TO_HEX
SUBA,OK
SZACC
JMPF_3_ERROR

CALLMESSAGE_12
MOV A,42H
CALLLCD_CURSOR
CALLKEY_IN_DATA
CALLHEX_TO_HEX
CALLBYTE_WRITE

CALLMESSAGE_16
CALLKEY_GET
JMPF_3_END
F_3_ERROR:
CALLMESSAGE_15
CALLKEY_GET
F_3_END:
JMPSELECT_34
RET
;--------------------------------------------------------------------
FUNCTION_4:
CALLMESSAGE_11
MOV A,41H
CALLLCD_CURSOR
CALLKEY_IN_ADDRESS
CALLDEC_TO_HEX
SUBA,OK
SZACC
JMPF_4_ERROR
CALLMESSAGE_12
MOV A,42H
CALLLCD_CURSOR
CALLKEY_IN_DATA
CALLHEX_TO_HEX
CALLPAGE_WRITE
CALLMESSAGE_17
CALLKEY_GET
JMPF_4_END
F_4_ERROR:
CALLMESSAGE_15
CALLKEY_GET
F_4_END:
JMPSELECT_34
RET
;--------------------------------------------------------------------
FUNCTION_5:
CALLCURRENT_READ
CALLMESSAGE_13
CALLADDRESS_DATA_DISPLAY
CALLKEY_GET
JMPSELECT_56
RET
;--------------------------------------------------------------------
FUNCTION_6:
CALLMESSAGE_11
MOV A,41H
CALLLCD_CURSOR
CALLKEY_IN_ADDRESS
CALLDEC_TO_HEX
SUBA,OK
SZACC
JMPF_6_ERROR
CALLRANDOM_READ
CALLMESSAGE_13
CALLADDRESS_DATA_DISPLAY
CALLKEY_GET
JMPF_6_END
F_6_ERROR:
CALLMESSAGE_15
CALLKEY_GET
F_6_END:
JMPSELECT_56
RET
;--------------------------------------------------------------------
FUNCTION_7:
CALLMESSAGE_11
MOV A,41H
CALLLCD_CURSOR
CALLKEY_IN_ADDRESS
CALLDEC_TO_HEX
SUBA,OK
SZACC
JMPF_7_ERROR
CALLSEQUENTIAL_READ
CALLMESSAGE_13
CALLSEQ_READ_BUFFER_DISPLAY
JMPF_7_END
F_7_ERROR:
CALLMESSAGE_15
CALLKEY_GET
F_7_END:

JMPSELECT_7
RET
;--------------------------------------------------------------------
BIN_TO_HEXPROC
CLRHT_DEVICE_ADD
MOV A,OFFSETBIN_TO_HEX_TABLE+2
MOV TBLP,A
MOV A,OFFSETKEY_IN_ADD_BUFFER+2
MOV MP0,A
MOV A,03H
MOV COUNTER,A
BIN_LOOP:
MOV A,R0
SUBA,01
SZACC
JMPBIN_BIT_X_0
TABRDLACC
ADDMA,HT_DEVICE_ADD
JMPBIN_NEXT
BIN_BIT_X_0:
MOV A,R0
SZACC
JMPBIN_ERROR
BIN_NEXT:
DECTBLP
DECMP0
SDZCOUNTER
JMPBIN_LOOP
MOV A,OK
JMPBIN_END
BIN_ERROR:
MOV A,ERROR
BIN_END:
RET
BIN_TO_HEXENDP
;--------------------------------------------------------------------
DEC_TO_HEXPROC
MOV A,HT_DATA_ADD
MOV ADDRESS_REGISTER,A
CLRHT_DATA_ADD
MOV A,OFFSETDEC_TO_HEX_TABLE
MOV TBLP,A
MOV A,OFFSETKEY_IN_ADD_BUFFER+2
MOV MP0,A
MOV A,R0
ADDMA,HT_DATA_ADD
DECMP0
MOV A,R0
ADDMA,TBLP
TABRDLACC
ADDMA,HT_DATA_ADD
DECMP0
MOV A,R0
SNZACC.0
JMPCHECK_ZERO
MOV A,64H
ADDMA,HT_DATA_ADD
JMPCHECK_ERROR
CHECK_ZERO:
MOV A,R0
SZACC
JMPDEC_TO_HEX_ERROR
JMPDEC_TO_HEX_OK
CHECK_ERROR:
MOV A,7FH
SUBA,HT_DATA_ADD
SNZACC.7
JMPDEC_TO_HEX_OK
DEC_TO_HEX_ERROR:
MOV A,ADDRESS_REGISTER
MOV HT_DATA_ADD,A
MOV A,ERROR
JMPDEC_TO_HEX_END
DEC_TO_HEX_OK:
MOV A,OK
DEC_TO_HEX_END:
RET
DEC_TO_HEXENDP
;--------------------------------------------------------------------
HEX_TO_HEXPROC
CLRHT_DATA
MOV A,OFFSETKEY_IN_DATA_BUFFER+1
MOV MP0,A
MOV A,R0
ADDMA,HT_DATA
DECMP0
MOV A,R0
SWAPACC
ADDMA,HT_DATA
RET
HEX_TO_HEXENDP
;--------------------------------------------------------------------
ADDRESS_DATA_DISPLAYPROC
MOV A,OFFSETKEY_IN_ADD_BUFFER+2
MOV MP0,A
CLRR0
DECMP0
CLRR0
DECMP0
CLRR0
MOV A,HT_DATA_ADD
SZACC
JMPTRANSFER_BEGIN
JMPADDRESS_DISPLAY_BEGIN
TRANSFER_BEGIN:
MOV A,HT_DATA_ADD
MOV COUNTER,A
TRANSFER:
MOV A,OFFSETKEY_IN_ADD_BUFFER+2
MOV MP0,A
MOV A,R0
SUBA,09H
SNZACC.7
JMPBYTE_1
INCR0
JMPTRANSFER_END
BYTE_1:
CLRR0
DECMP0
MOV A,R0
SUBA,09H
SNZACC.7
JMPBYTE_2
INCR0
JMPTRANSFER_END
BYTE_2:
CLRR0
DECMP0
INCR0
TRANSFER_END:
SDZCOUNTER
JMPTRANSFER
ADDRESS_DISPLAY_BEGIN:
MOV A,OFFSETKEY_IN_ADD_BUFFER
MOV MP0,A
MOV A,08H
CALLLCD_CURSOR
MOV A,7FH
DAAACC
MOV A,03H
MOV COUNTER,A
ADDRESS_DISPLAY:
MOV A,OFFSETHEX_TO_TEXT_TABLE
MOV TBLP,A
MOV A,R0
ADDMA,TBLP
TABRDLACC
CALLLCD_PUT_A_CHAR
INCMP0
SDZCOUNTER
JMPADDRESS_DISPLAY

MOV A,OFFSETKEY_IN_DATA_BUFFER+1
MOV MP0,A
MOV A,HT_DATA
ANDA,0FH
MOV R0,A
DECMP0
MOV A,HT_DATA
SWAPACC
ANDA,0FH
MOV R0,A

MOV A,48H
CALLLCD_CURSOR
MOV A,02H
MOV COUNTER,A
DATA_DISPLAY:
MOV A,OFFSETHEX_TO_TEXT_TABLE
MOV TBLP,A
MOV A,R0
ADDMA,TBLP
TABRDLACC
CALLLCD_PUT_A_CHAR
INCMP0
SDZCOUNTER
JMPDATA_DISPLAY
MOV A,50H
CALLLCD_CURSOR
RET
ADDRESS_DATA_DISPLAYENDP
;--------------------------------------------------------------------
SEQ_READ_BUFFER_DISPLAYPROC
MOV A,HT_DATA
MOV DATA_REGISTER,A
MOV A,HT_DATA_ADD
MOV ADDRESS_REGISTER,A

MOV A,HT_DATA_ADD
SUBA,07H
SNZACC.7
JMPSEQ_DATA_ADD_CHANGE
MOV A,HT_DATA_ADD
ADDA,80H
SUBA,07H
MOV HT_DATA_ADD,A
JMPSEQ_DISPLAY_BEGIN
SEQ_DATA_ADD_CHANGE:
MOV A,HT_DATA_ADD
SUBA,07H
MOV HT_DATA_ADD,A

SEQ_DISPLAY_BEGIN:
MOV A,OFFSETSEQUENTIAL_READ_BUFFER
MOV MP1,A
MOV A,08H
MOV SEQ_COUNTER,A
SEQ_LOOP:
MOV A,40H
CALLLCD_CURSOR
MOV A,SEQ_COUNTER
ADDA,30H
CALLLCD_PUT_A_CHAR

MOV A,R1
MOV HT_DATA,A
CALLADDRESS_DATA_DISPLAY
INCMP1
MOV A,HT_DATA_ADD
SUBA,7FH
SZACC
JMPSEQ_NOT_ZERO
CLRHT_DATA_ADD
JMPSEQ_END
SEQ_NOT_ZERO:
INCHT_DATA_ADD
SEQ_END:
MOV A,40H
CALLLCD_CURSOR
CALLKEY_GET
CALLDELAY_LONG
SDZSEQ_COUNTER
JMPSEQ_LOOP
MOV A,DATA_REGISTER
MOV HT_DATA,A
MOV A,ADDRESS_REGISTER
MOV HT_DATA_ADD,A
RET
SEQ_READ_BUFFER_DISPLAYENDP
;--------------------------------------------------------------------
END

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動(dòng) BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運(yùn)營商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺(tái)與中國電影電視技術(shù)學(xué)會(huì)聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會(huì)上宣布正式成立。 活動(dòng)現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會(huì)上,軟通動(dòng)力信息技術(shù)(集團(tuán))股份有限公司(以下簡稱"軟通動(dòng)力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉