电子文章 | 电子资料下载 | 家电维修 | 维修资料下载 | 加入收藏 | 全站地图
您现在所在位置:电子爱好者电子文章电子电路图单片机电路图SST89C58电子盘电路及代码

SST89C58电子盘电路及代码

03-19 02:35:27 | http://www.5idzw.com | 单片机电路图 | 人气:300
标签:电路图讲解,电路图练习,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

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

,SST89C58电子盘电路及代码
关于《SST89C58电子盘电路及代码》的更多文章