标签:电路图讲解,电路图练习,http://www.5idzw.com
SST89C58电子盘电路及代码,http://www.5idzw.com
;========================================
Done?: mov a, SFST
jb acc.2, Done?
ret
;========================================
Enable8bit: acall Busy
mov dptr, #Features
mov a, #01h ; enable 8 bit data transfer
movx @dptr, a
mov dptr, #Drv_Head
mov a, #11100000b ; bit4=0 as MASTER, 1 as Slave ; bit6=1, enable LBA
movx @dptr, a
mov dptr, #COMMAND
mov a, #SetFeature ; #0EFh
movx @dptr, a
ret
;========================================
Write_Sctr: mov R2, #1 ; write 1 sector at a time.
mov R3, #0Ah ; suppose LBA to be 000000Ah
mov R4, #0
mov R5, #0
mov R6, #0
mov R7, #WriteSctr
acall Function
acall WaitDRQ
acall Write512
ret
;========================================
Write512: mov R0, #high(message) ; get the higher address of message
mov R1, #low(message) ; get the lower address of message
mov R7, #2 ; 512 bytes = 2 * 256
mov B, #0
write: mov dph, R0 ; get the address
mov dpl, R1
clr a
movc a, @a+dptr ; get the data in message
inc dptr ; point to next byte in message
mov R0, dph ; save the address
mov R1, dpl
mov DPTR, #Data_Reg ; point to ADC
movx @dptr, a ; write 1 byte data into ADC
djnz B, write
djnz R7, write ; write all 512 bytes to ADC
ret
;========================================
Read_Sctr: mov R2, #1 ; read 1 sector at a time.
mov R3, #0Ah ; suppose LBA to be 000000Ah
mov R4, #0
mov R5, #0
mov R6, #0
mov R7, #ReadSctr
acall Function
acall WaitDRQ
acall Read512
ret
;========================================
; read 1 sector of 512 bytes data and write into flash on chip of SST FlashFlex51 MCU
Read512: mov R7, #2 ; 512 bytes = 2 * 256
,SST89C58电子盘电路及代码
;========================================
Done?: mov a, SFST
jb acc.2, Done?
ret
;========================================
Enable8bit: acall Busy
mov dptr, #Features
mov a, #01h ; enable 8 bit data transfer
movx @dptr, a
mov dptr, #Drv_Head
mov a, #11100000b ; bit4=0 as MASTER, 1 as Slave ; bit6=1, enable LBA
movx @dptr, a
mov dptr, #COMMAND
mov a, #SetFeature ; #0EFh
movx @dptr, a
ret
;========================================
Write_Sctr: mov R2, #1 ; write 1 sector at a time.
mov R3, #0Ah ; suppose LBA to be 000000Ah
mov R4, #0
mov R5, #0
mov R6, #0
mov R7, #WriteSctr
acall Function
acall WaitDRQ
acall Write512
ret
;========================================
Write512: mov R0, #high(message) ; get the higher address of message
mov R1, #low(message) ; get the lower address of message
mov R7, #2 ; 512 bytes = 2 * 256
mov B, #0
write: mov dph, R0 ; get the address
mov dpl, R1
clr a
movc a, @a+dptr ; get the data in message
inc dptr ; point to next byte in message
mov R0, dph ; save the address
mov R1, dpl
mov DPTR, #Data_Reg ; point to ADC
movx @dptr, a ; write 1 byte data into ADC
djnz B, write
djnz R7, write ; write all 512 bytes to ADC
ret
;========================================
Read_Sctr: mov R2, #1 ; read 1 sector at a time.
mov R3, #0Ah ; suppose LBA to be 000000Ah
mov R4, #0
mov R5, #0
mov R6, #0
mov R7, #ReadSctr
acall Function
acall WaitDRQ
acall Read512
ret
;========================================
; read 1 sector of 512 bytes data and write into flash on chip of SST FlashFlex51 MCU
Read512: mov R7, #2 ; 512 bytes = 2 * 256
,SST89C58电子盘电路及代码
上一篇:LMl872 基本测试电路图