当前位置:首页 > 单片机 > 单片机
[导读] ;*************************************************;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

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

9月2日消息,不造车的华为或将催生出更大的独角兽公司,随着阿维塔和赛力斯的入局,华为引望愈发显得引人瞩目。

关键字: 阿维塔 塞力斯 华为

加利福尼亚州圣克拉拉县2024年8月30日 /美通社/ -- 数字化转型技术解决方案公司Trianz今天宣布,该公司与Amazon Web Services (AWS)签订了...

关键字: AWS AN BSP 数字化

伦敦2024年8月29日 /美通社/ -- 英国汽车技术公司SODA.Auto推出其旗舰产品SODA V,这是全球首款涵盖汽车工程师从创意到认证的所有需求的工具,可用于创建软件定义汽车。 SODA V工具的开发耗时1.5...

关键字: 汽车 人工智能 智能驱动 BSP

北京2024年8月28日 /美通社/ -- 越来越多用户希望企业业务能7×24不间断运行,同时企业却面临越来越多业务中断的风险,如企业系统复杂性的增加,频繁的功能更新和发布等。如何确保业务连续性,提升韧性,成...

关键字: 亚马逊 解密 控制平面 BSP

8月30日消息,据媒体报道,腾讯和网易近期正在缩减他们对日本游戏市场的投资。

关键字: 腾讯 编码器 CPU

8月28日消息,今天上午,2024中国国际大数据产业博览会开幕式在贵阳举行,华为董事、质量流程IT总裁陶景文发表了演讲。

关键字: 华为 12nm EDA 半导体

8月28日消息,在2024中国国际大数据产业博览会上,华为常务董事、华为云CEO张平安发表演讲称,数字世界的话语权最终是由生态的繁荣决定的。

关键字: 华为 12nm 手机 卫星通信

要点: 有效应对环境变化,经营业绩稳中有升 落实提质增效举措,毛利润率延续升势 战略布局成效显著,战新业务引领增长 以科技创新为引领,提升企业核心竞争力 坚持高质量发展策略,塑强核心竞争优势...

关键字: 通信 BSP 电信运营商 数字经济

北京2024年8月27日 /美通社/ -- 8月21日,由中央广播电视总台与中国电影电视技术学会联合牵头组建的NVI技术创新联盟在BIRTV2024超高清全产业链发展研讨会上宣布正式成立。 活动现场 NVI技术创新联...

关键字: VI 传输协议 音频 BSP

北京2024年8月27日 /美通社/ -- 在8月23日举办的2024年长三角生态绿色一体化发展示范区联合招商会上,软通动力信息技术(集团)股份有限公司(以下简称"软通动力")与长三角投资(上海)有限...

关键字: BSP 信息技术
关闭
关闭