SST89C58电子盘电路及代码

[10-10 20:38:44]   来源:http://www.88dzw.com  微机|单片机   阅读:8488

文章摘要:Function:acallBusymovdptr, #Sectr_Cntmova, R2; R2 is Sector Countmovx @dptr, amovdptr, #Sectr_Nomova, R3; R3 contains LBA0:7movx @dptr, amovdptr, #Cylinder_Lowmova, R4; R4 contains LBA8:15movx @dptr, amovdptr, #Cylinder_Himova, R5; R5 contains LBA16:23movx @dptr, amovdptr, #Drv_Headmova, R6; R6 cont

SST89C58电子盘电路及代码,标签:电路设计,http://www.88dzw.com

Function:acallBusy

movdptr, #Sectr_Cnt

mova, R2; R2 is Sector Count

movx @dptr, a

movdptr, #Sectr_No

mova, R3; R3 contains LBA0:7

movx @dptr, a

movdptr, #Cylinder_Low

mova, R4; R4 contains LBA8:15

movx @dptr, a

movdptr, #Cylinder_Hi

mova, R5; R5 contains LBA16:23

movx @dptr, a

movdptr, #Drv_Head

mova, R6; R6 contains LBA24:27

anla,#00001111b

orla,#11100000b; bit4=0 as MASTER-p.htm" target="_blank" title="MASTER货源和PDF资料">MASTER, 1 as Slave; bit6=1, enable LBA.

movx @dptr, a

movdptr, #command

mova, R7; R7 is command code.

movx @dptr, a

ret

;========================================

Busy:movdptr, #status

movx a, @dptr

jbacc.7, Busy

jbacc.0, errors

;jnbacc.6, Busy

clra; acc=0 when successful

clrC; C=0, ADC is not busy (BUSY=0) and no error (ERR=0)

ret; and is ready to accept commands (RDY=1)

errors:movdptr, #Error_Reg

movx a, @dptr

setb C; C=1 flags error codes contained in ACC register

ret

;========================================

WaitDRQ:movdptr, #status

movx a, @dptr

jbacc.7,WaitDRQ; if BUSY=1, then WaitDRQ

jnbacc.3, WaitDRQ; if DRQ=0, then WaitDRQ

jbacc.0,errors; if ERR=1, then read errors code and set flag C

;jnbacc.6, WaitDRQ

clra

clrC; C=0, ADC is BUSY=0, DRQ=1, ERR=0.

ret

;========================================

Done?:mova, SFST

jbacc.2,Done?

ret

;========================================

Enable8bit:acall Busy

movdptr, #Features

mova,#01h; enable 8 bit data transfer

movx@dptr, a

movdptr, #Drv_Head

mova,#11100000b; bit4=0 as MASTER-p.htm" target="_blank" title="MASTER货源和PDF资料">MASTER, 1 as Slave ; bit6=1, enable LBA

movx@dptr, a

movdptr, #COMMAND

mova,#SetFeature; #0EFh

movx@dptr, a

ret

;========================================

Write_Sctr:movR2,#1; write 1 sector at a time.

movR3,#0Ah; suppose LBA to be 000000Ah

movR4,#0

movR5,#0

movR6,#0

movR7,#WriteSctr

acallFunction

acallWaitDRQ

acallWrite512

ret

;========================================

Write512:movR0,#high(message) ; get the higher address of message

movR1,#low(message); get the lower address of message

movR7,#2; 512 bytes = 2 * 256

movB,#0

write:movdph,R0; get the address

movdpl,R1

clra

movca,@a dptr; get the data in message

incdptr; point to next byte in message

movR0,dph; save the address

movR1,dpl

movDPTR, #Data_Reg; point to ADC

movx@dptr, a; write 1 byte data into ADC

djnzB,write

djnzR7, write; write all 512 bytes to ADC

ret

;========================================

Read_Sctr:movR2,#1; read 1 sector at a time.

movR3,#0Ah; suppose LBA to be 000000Ah

movR4,#0

movR5,#0

movR6,#0

movR7,#ReadSctr

acallFunction

acallWaitDRQ

acallRead512

ret

;========================================

; read 1 sector of 512 bytes data and write into flash on chip of SST FlashFlex51 MCU

Read512:movR7,#2; 512 bytes = 2 * 256

movB,#0

movdptr,#Data_Reg

movSFAH, #high(FlashAddrs)

上一页  [1] [2] [3] [4]  下一页


Tag:微机|单片机电路设计家电维修 - 单元电路介绍 - 微机|单片机