在应用编程MAXQ微控制器中可分区擦除的程序和数
时间:03-19
来源:互联网
点击:
注意,直接访问方法与未来的ROM版本无法前向兼容。
第二种为查表法。尽管这种方法兼容性较好,但是执行时间较长。在下面每一段例程说明的后面,汇编例程采用查表法获取ROM应用例程的地址。表5所示为应用ROM提供的几个闪存例程。关于ROM应用例程的完整列表,参见特定MAXQ器件的用户指南。
表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)< BR>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], ACCmove 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], ACCmove ACC, @DP[0] ; Retrieve the address of the routine.call ACC ; Execute the routine.ret ; Status returned in A[0]flashEraseAll
Routine | void flashEraseAll(void) |
Summary | Erases 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. |
Inputs | None |
Outputs | Carry: Set on error and cleared on success.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; 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应用程序的要领。- 智能铅酸蓄电池充电器的设计(01-02)
- 用微控制器或 DSP 电路控制开机/关机功能(06-22)
- 微控制器的市场前景及发展趋势(06-21)
- 基于AT89S52汉字多方式显示屏的设计(01-06)
- 灵活高效的数字解决方案满足新兴电源管理需求(01-10)
- 基于ARM微处理器的十回路智能配电监控单元的设计(11-17)