關(guān)于單片機(jī)AT89S52和CF卡的接口設(shè)計(jì)
限于篇幅只將寫(xiě)一個(gè)扇區(qū)代碼編寫(xiě)(讀扇區(qū)代碼基本與此相同)如下:
?。粚?xiě)一個(gè)扇區(qū)
WRITE: MOV DPTR, #SECTR_CNT
MOV A, #1
MOVX @DPTR, A
MOV DPTR, #SECTR_NO
MOV A, SECTRNO
MOVX @DPTR, A
MOV DPTR, #CYLINDER_LOW
MOV A, CYLINDERL
MOVX @DPTR, A
MOV DPTR, #CYLINDER_HI
MOV A, CYLINDERH
MOVX @DPTR, A
MOV DPTR, #DRV_HEAD
MOV A, DRVHEAD
ANL A, #0FH
ORL A, #0E0H
MOVX @DPTR, A
MOV DPTR, #COMMAND
MOV A, 30H
MOVX @DPTR, A
WRITE512:MOV R6,#0
MOV R7,#2
WRITE: MOV DPTR,#DATA_REG
MOV A,#31H
MOVX @DPTR,A
DJNZ R6,WRITE
DJNZ R7,WRITE
RET
4.結(jié)束語(yǔ)
本設(shè)計(jì)的接口電路,闡述了CF卡的讀寫(xiě)方法,并采用了通用的MCS-51系列單片機(jī)為系統(tǒng)控制器,可移植性好。根據(jù)此電路可應(yīng)用于其他單片機(jī)對(duì)CF卡進(jìn)行讀寫(xiě),采用CF卡作為存儲(chǔ)介質(zhì),容量大,體積小,價(jià)格低廉,可應(yīng)用于MP3播放器,數(shù)碼相機(jī),移動(dòng)存儲(chǔ)等各個(gè)領(lǐng)域,本試驗(yàn)在線路板上調(diào)試通過(guò),并配合計(jì)算機(jī)串口對(duì)CF卡進(jìn)行讀寫(xiě)操作,并可對(duì)CF卡進(jìn)行數(shù)據(jù)恢復(fù)。
評(píng)論