U盘读TXT文件问题

我建立一个TXT文档,起名为AAA。然后找到它根目录所在的扇区为504,然后我想用汇编将这个AAA.txt文档读出来,可是读出的数据返回值是1DH,不是40H。请问是怎么回事 PS:我程序很菜,请指教。谢谢。下面是我的程序,带“☆”的地方就是我认为应该返回40H但去返回1DH的位置。 ORG 0000H AJMP MAIN MAIN: MOV DPH,#80H ;TEST MOV A,#06H MOVX @DPTR,A MOV DPH,#00H MOV A,#55H MOVX @DPTR,A NOP MOVX A,@DPTR NOP ////////返回正常,AAH ; MOV DPH,#80H ;RESET MOV A,#15H MOVX @DPTR,A MOV A,#07H MOVX @DPTR,A MOV R0,#014H WAIT1: NOP ;DELAY20US DJNZ R0,WAIT1 MOV DPH,#00H MOVX A,@DPTR LCALL DELAY ; MOV DPH,#80H ;SET MODE MOV A,#15H MOVX @DPTR,A MOV A,#06H MOVX @DPTR,A MOV R0,#14H WAIT2: NOP ;FIND USB DJNZ R0,WAIT2 MOV DPH,#00H MOVX A,@DPTR NOP //////返回51H ; MOV DPH,#80H ;INIT MOV A,#51H MOVX @DPTR,A NOP LCALL DELAY MOV DPH,#80H MOV A,#22H MOVX @DPTR,A NOP MOV DPH,#00H MOVX A,@DPTR NOP NOP ///// 返回14H

RDDATA: MOV DPH,#80H ;;;DISK READ MOV A,#54H MOVX @DPTR,A NOP MOV DPH,#00H MOV A,#0F8H ;;;;;ZUI DI MOVX @DPTR,A NOP NOP MOV DPH,#00H MOV A,#01H ;;;;;JIAO DI MOVX @DPTR,A NOP NOP MOV DPH,#00H MOV A,#00H ;;;;;JIAO GAO MOVX @DPTR,A NOP NOP MOV DPH,#00H MOV A,#00H ;;;;;ZUI GAO MOVX @DPTR,A NOP NOP MOV DPH,#00H ;;;;;SHAN QU MOV A,#01H MOVX @DPTR,A NOP NOP MOV DPH,#80H MOV A,#22H MOVX @DPTR,A NOP MOV DPH,#00H MOVX A,@DPTR NOP NOP ///// 返回1DH LCALL DELAY CJNE A,#1DH,RDDATA NOP NOP MOV DPH,#80H ;;;;;RD USB DATA MOV A,#28H MOVX @DPTR,A NOP LCALL DELAY MOV DPH,#00H MOVX A,@DPTR NOP ☆☆☆☆☆☆☆☆☆////返回错误

,返回值为1DH☆☆☆☆☆☆☆☆☆☆☆ LCALL DELAY NOP MOV R0,#40H MOV R1,#08H RDGO: MOV DPH,#80H ;;;;;DISK RD GO MOV A,#55H MOVX @DPTR,A NOP MOV DPH,#80H MOV A,#22H MOVX @DPTR,A NOP MOV DPH,#00H MOVX A,@DPTR MOV 30H,A MOVC A,@A+DPTR INC 30H DJNZ R0,RDGO NOP MOV DPH,#80H MOV A,#22H MOVX @DPTR,A NOP DJNZ R1,RDDATA NOP LCALL DELAY MOV DPH,#80H MOV A,#22H MOVX @DPTR,A NOP MOV DPH,#00H MOVX A,@DPTR NOP NOP RDWC: CJNE A,#14H,RDWC

;;;;;;;;

DELAY: MOV R6,#0C8H ;DELAY 200mS LOOP1: MOV R7,#0F8H NOP LOOP2: DJNZ R7,LOOP2 DJNZ R6,LOOP1 RET

你在读扇区的过程中,调用DELAY 200mS的延时太长了。如获取到USB_INT_DISK_READ(0X1D)的中断状态,接着发CMD_RD_USB_DATA即可。 延时的话要满足命令与命令之间2um,数据与命令之间2um,数据与数据之间1um。


只有登录才能回复,可以选择微信账号登录