微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 模拟电路设计 > 在应用编程MAXQ微控制器中可分区擦除的程序和数

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

时间:03-19 来源:互联网 点击:

注意,直接访问方法与未来的ROM版本无法前向兼容。

第二种为查表法。尽管这种方法兼容性较好,但是执行时间较长。在下面每一段例程说明的后面,汇编例程采用查表法获取ROM应用例程的地址。表5所示为应用ROM提供的几个闪存例程。关于ROM应用例程的完整列表,参见特定MAXQ器件的用户指南。

表5. 应用ROM闪存例程

Routine NumberRoutine NameEntry Point
ROMTable = ROM[800Dh]
Entry Point
Physical Address
2flashEraseSectorROM[ROMTable + 1]0x8XXX
3flashEraseAllROM[ROMTable + 2]0x8XXX
15flashWriteROM[ROMTable + 14]0x8XXX

flashWrite
Routineu16 flashWrite(u16 *pAddress, u16 iData)
SummaryPrograms a single word of flash memory.
InputsA[0] - Word address in flash memory to which to write.
A[1] - Word value to write to flash memory.
OutputsCarry: 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)< BR>4 : command not supportedSW_FERR - Set on error, cleared on success.
NotesThe 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], ACCmove ACC, @DP[0]       ; Retrieve the address of the routine.call ACC               ; Execute the routine.ret                    ; Status returned in A[0]
flashEraseSector
Routineu16 flashEraseSector(void *pAddress)
SummaryErases a single sector of flash memory
InputsA[0] - Address located in the sector to erase.
OutputsCarry: 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.
NotesThe 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], ACCmove ACC, @DP[0]       ; Retrieve the address of the routine.call ACC               ; Execute the routine.ret                    ; Status returned in A[0]
flashEraseAll
Routinevoid flashEraseAll(void)
SummaryErases the entire program and data flash memory, including the boot loader sector. This routine is not normally used for IAP, as great care must be taken to ensure that the erase/programming sequence is not interrupted.
InputsNone
OutputsCarry: Set on error and cleared on success.SW_FERR: Set on error, cleared on success.
NotesThe 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; void flashEraseAll(void);;flashEraseAll:move APC, #0           ; No auto inc/dec of accumulator.move AP,  #0           ; Set ACC to A[0]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  #2                ; Add the index to the flashEraseAll routine.move DP[0], ACCmove ACC, @DP[0]       ; Retrieve the address of the routine.call ACC               ; Execute the routine.ret

在应用编程

大多数基于闪存的系统要求,当系统安装到终端产品上以后,其固件必须具备升级的能力。这种功能称为在应用编程(IAP)。本节概述了创建一个IAP应用程序的要领。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top