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

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

文章摘要: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.InputsNoneOutputsCarry: Set o

在应用编程MAXQ微控制器中可分区擦除的程序和数据闪存,标签:计算机控制技术,工厂电气控制技术,http://www.88dzw.com
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], ACC
    move ACC, @DP[0]       ; Retrieve the address of the routine.
    call ACC               ; Execute the routine.
    ret

在应用编程

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

上面列出的应用ROM闪存例程,可完成闪存ROM所需要的所有擦除和写入操作,从而允许用户代码对闪存进行操作。与其他子程序调用相似,程序执行完成之后,控制将返回到用户代码。

要实现可靠的IAP,引导装载程序必须与主程序分开。这样可以确保在经历一次未竟编程之后,可以重新启动编程过程。

引导装载程序
初始化以后,由于ROM跳转至地址0x0000,因此,引导装载程序的入口应为0x0000。不同的MAXQ器件,其引导闪存分区的大小也不相同。可以根据需要,将引导程序扩展至多个闪存分区,用户应用程序代码不能使用已被占用的任何分区。擦除和写入闪存时必须满足的特定要求见表6。

表6. 调用应用ROM闪存例程的要求

You cannot erase or program from the same flash sector from which you are executing code. This is not normally a problem since the flash Boot Sector should never be erased during IAP.
The watchdog must not be enabled or the watchdog timeout must be set long enough to complete this routine without triggering a reset before the flashEraseSector() routine is called. If the watchdog time out occurs before the erase is complete, it will reset the part. Erasing a sector typically takes 0.7 seconds; it can take up to 15 seconds under worst case conditions.
Since the System Control Register bit SC.UPA must be set to 0 to access the Utility ROM, a ROM Utility routine cannot be called directly from program memory addresses = 0x8000. If access to a Utility ROM routine is required from a program in upper memory (= 0x8000), the program must indirectly call the ROM routine through a routine residing in lower memory (<0x8000). This effectively limits the boot loader to = 64kB (32kB x 16).

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


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