在应用编程MAXQ微控制器中可分区擦除的程序和数据闪存

[09-13 17:04:32]   来源:http://www.88dzw.com  控制技术   阅读:8553

文章摘要:表5. 应用ROM闪存例程 Routine NumberRoutine NameEntry PointROMTable = ROM[800Dh]Entry PointPhysical Address2flashEraseSectorROM[ROMTable + 1]0x8XXX3flashEraseAllROM[ROMTable + 2]0x8XXX15flashWriteROM[ROMTable + 14]0x8XXXflashWrite Routineu16 flashWrite(u16 *pAddress, u16 iData)SummaryPrograms a single word

在应用编程MAXQ微控制器中可分区擦除的程序和数据闪存,标签:计算机控制技术,工厂电气控制技术,http://www.88dzw.com
表5. 应用ROM闪存例程
Routine Number Routine Name Entry Point
ROMTable = ROM[800Dh]
Entry Point
Physical Address
2 flashEraseSector ROM[ROMTable + 1] 0x8XXX
3 flashEraseAll ROM[ROMTable + 2] 0x8XXX
15 flashWrite ROM[ROMTable + 14] 0x8XXX

flashWrite
Routine u16 flashWrite(u16 *pAddress, u16 iData)
Summary Programs a single word of flash memory.
Inputs A[0] - Word address in flash memory to which to write.
A[1] - Word value to write to flash memory.
Outputs Carry: Set on error and cleared on success. If set, then A[0] contains one of the following error codes:
1 : failure due to software timeout
2 : failure reported by hardware (DQ5/FERR)
4 : command not supportedSW_FERR - Set on error, cleared on success.
Notes The watchdog must not be active, or the watchdog timeout must be set long enough to complete this routine without triggering a reset.

以下汇编代码实例采用间接寻址方法(查表)调用flashWrite()应用例程。该例程可由C代码调用。
; This routine is callable by C code using the following prototype
; u16 flashWrite(u16 *pAddress, u16 iData);
;
flashWrite:
    move APC, #0           ; No auto inc/dec of accumulator.
    move AP,  #2           ; Set ACC to A[2]
    move DP[0], #0800Dh    ; This is where the address of the table is stored.
    move ACC, @DP[0]       ; Get the location of the routine table.
    add  #14               ; Add the index to the flashWrite routine.
    move DP[0], ACC
    move ACC, @DP[0]       ; Retrieve the address of the routine.
    call ACC               ; Execute the routine.
    ret                    ; Status returned in A[0]
flashEraseSector
Routine u16 flashEraseSector(void *pAddress)
Summary Erases a single sector of flash memory
Inputs A[0] - Address located in the sector to erase.
Outputs Carry: Set on error and cleared on success. If set, then A[0] contains one of the following error codes:
1 : failure due to software timeout
2 : failure reported by hardware (DQ5/FERR)
4 : command not supported
SW_FERR - Set on error, cleared on success.
Notes The watchdog must not be active, or the watchdog timeout must be set long enough to complete this routine without triggering a reset.

; This routine is callable by C code using the following prototype
; u16 flashEraseSector(void *pAddress);
;
flashEraseSector:
    move APC, #0           ; No auto inc/dec of accumulator.
    move AP,  #1           ; Set ACC to A[1]
    move DP[0], #0800Dh    ; This is where the address of the table is stored.
    move ACC, @DP[0]       ; Get the location of the routine table.
    add  #1                ; Add the index to the flashEraseSector routine.
    move DP[0], ACC
    move ACC, @DP[0]       ; Retrieve the address of the routine.
    call ACC               ; Execute the routine.
    ret                    ; Status returned in A[0]

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


Tag:控制技术计算机控制技术,工厂电气控制技术控制技术