PRELIMINARY
* passes, the flash is ready to be reprogrammed. The | * | ||||
* | operations are performed on the segments of the flash * | ||||
* module described by the parameter list: | * | ||||
* | 1)PROTECT±defines which flash segments to protect.* | ||||
* | 2)SEG_ST ±start address of segment to be erased. * | ||||
* | 3)SEG_END±end address of segment to be erased. | * | |||
* To erase flash0 use erase(0xff00,0x0000,0x3fff). | * | ||||
* To erase flash1 use erase(0xff00,0x4000,0x7fff). | * | ||||
********************************************************* | |||||
* CAUTION: Erasing individual segments is not allowed. * | |||||
* | The PROTECT parameter should always be set to | * | |||
* | enable all segments, and SEG_ST and SEG_END | * | |||
* | should be set to the end and start address of | * | |||
* | the array to be erased. | * | |||
********************************************************* | |||||
_erase: |
|
|
|
| |
ERS_PARAMS | .set 3 |
|
| ||
AR_STACK |
| .set ar1 |
|
| |
AR_PROTECT | .set ar2 |
|
| ||
AR_SEG_ST |
| .set ar3 |
|
| |
AR_SEG_END | .set ar4 |
|
| ||
;Begin C Preprocessing |
|
| |||
| POPD | *+ | ;pop return address, push on software stack | ||
| sar | ar0,*+ ;save FP |
| ||
| sar | ar6,* ;save ar6 |
| ||
| sbrk | #3 |
|
|
|
| ;get arguments and place them properly ± take them from | ||||
| ;the software stack and place them into their correct | ||||
| ;positions |
|
| ||
| lar | AR_PROTECT,*± |
|
| |
| lar | AR_SEG_ST,*± |
|
| |
| lar | AR_SEG_END,*± |
|
| |
| adrk #ERS_PARAMS+4 | ;ar1 = next empty point on stack (SP) | |||
;End C Preprocessing |
|
| |||
| LDP | #PARMS |
|
| |
| SAR | AR1,SV_AR1 | ;Save AR1. |
| |
| SPLK | #0,ERS_COUNT | ;Set erase fail count to 0. |
| |
| SPLK | #0,ERROR | ;Set algo error flag to 0 (no errors). | ||
**********Put parameters where they belong.********** |
| ||||
| SAR | AR_PROTECT,PROTECT |
| ||
| SAR | AR_SEG_ST,SEG_ST |
| ||
| SAR | AR_SEG_END,SEG_END |
| ||
***********Next Setup to clear flash ************ |
| ||||
ers_loop: |
|
|
|
| |
| CALL | GCLR | ;Clear flash. |
| |
| LACL | ERROR | ;Check for CLEAR/ERASE error |
| |
| BCND | ers_error,neq ;If error, then hard fail. |
| ||
***********Next Setup to erase flash ************ |
| ||||
| CALL | GERS | ;Erase flash. |
| |
| LACL | ERROR | ;Check for CLEAR/ERASE error |
| |
| BCND | depletion,neq ;If error, try Flash±write. |
| ||
| LACL | #1 | ;Else, no errors erasing. |
| |
| B |
| ers_done | ;Restore registers and return. |
|
depletion: |
|
|
| ||
| LACL | ERS_COUNT | ;Get erase fail count. |
|
PRELIMINARY | Assembly Source Listings and Program Examples |