X25045的读写程序
来源:本站整理 作者:佚名 2005-06-26 09:25:29
设置写使能锁存器
----------------------------
WREN: CLR SCK
CLR CS
MOV A,#COMMAND
LCALL OUT
CLR SCK
SETB CS
RET
----------------------------
复位写使能锁存器
----------------------------
WRDI: CLR SCK
CLR CS
MOV A,#COMMAND
LCALL OUT
CLR SCK
SETB CS
RET
----------------------------
写状态寄存器
----------------------------
WRSR: CLR SCK
CLR CS
MOV A,#COMMAND
LCALL OUT
CLR SCK
SETB CS
LCALL POLL
RET
----------------------------
读状态寄存器
----------------------------
RDSR: CLR SCK
CLR CS
MOV A,#COMMAND
LCALL OUT
LCALL IN
CLR SCK
SETB CS
RET
----------------------------
字节写
----------------------------
WRITE: MOV DPTR,#ADDR
CLR SCK
CLR CS
MOV A,#COMMAND
MOV B,DPH
MOV C,B.0
MOV ACC.3,C
LCALL OUT
MOV A,DPL
LCALL OUT
MOV A,#BYTE_DATA
LCALL OUT
CLR SCK
SETB CS
LCALL POLL
RET
----------------------------
字节读
----------------------------
READ: MOV DPTR,#ADDR
CLR SCK
CLR CS
MOV A,#COMMAND
MOV B,DPH
MOV C,B.0
MOV ACC.3,C
LCALL OUT
MOV A,DPL
LCALL OUT
LCALL IN
CLR SCK
SETB CS
RET
----------------------------
复位看门狗
----------------------------
DOG: CLR CS
SETB CS
RET
----------------------------
写检查
----------------------------
POLL: MOV R1,#MAX_POLL
POLL1: LCALL RDSR
JNB ACC.0,POLL2
DJNZ R1,POLL1
POLL2: RET
----------------------------
传送单字节
----------------------------
OUT: MOV R0,#08H
OUT1: CLR SCK
RLC A
MOV SI,C
SETB SCK
DJNZ R0,OUT1
CLR SI
RET
----------------------------
接收单字节
----------------------------
IN: MOV R0,#08H
IN1: SETB SCK
CLR SCK
MOV C,SO
RLC A
DJNZ R0,IN1
RET
关键词:
文章评论评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0条,得分 0分,平均 0分)