PRELIMINARY
Sample Assembly Code to Erase and Reprogram the TMS320F206
;data section used for | * |
;temporary variables, and | * |
;for passing parameters | * |
;to the flash algorithms. | * |
*********************************************************
PROTECT .set PARMS ;Segment enable bits. *
**********************************************************
***Parameters needed for Programming algorithm. ***
**********************************************************
PRG_bufaddr | .set | PARMS+1 | ;Address of buffer for | * |
|
|
| ;program data. | * |
PRG_paddr | .set | PARMS+2 | ;First flash address to | * |
|
|
| ;program. | * |
PRG_length | .set | PARMS+3 | ;Length of block to program. * |
**********************************************************
*Parameters needed for CLEAR, ERASE, and FLW algorithms.
**********************************************************
SEG_ST | .set | PARMS+4 | ;Segment | start address. | * |
SEG_END | .set | PARMS+5 | ;Segment | end address. | * |
**********************************************************
****Other misc variables.****
**********************************************************
ERS_COUNT .set PARMS+6 ;Used for erase fail count. *
**********************************************************
.text
*********************************************************
** First, erase flash1 by | invoking the clear and erase | * | |
** | algorithms. |
| * |
** | Note: three parameters | must be initialized before | * |
** | calling the algorithms. |
| * |
*********************************************************
LDP | #PARMS |
SPLK | #0,ERS_COUNT ;Set erase fail count to 0. |
**********Put parameters where they belong.**********
SPLK | #0ff00h,PROTECT |
|
SPLK | #04000h,SEG_ST |
|
SPLK | #07FFFh,SEG_END |
|
***********First clear flash ************ | ||
ers_loop: |
|
|
CALL | GCLR | ;Clear flash. |
LACL | ERROR | ;Check for CLEAR error |
BCND | ers_error,neq | ;If error, then hard fail. |
***********Next erase flash ************ | ||
CALL | GERS | ;Erase flash. |
LACL | ERROR | ;Check for CLEAR error |
BCND | depletion,neq | ;If error, then try |
|
| ;flash±write. |
B | ers_done | ;Else, no errors erasing. |
depletion: |
|
|
LACL | ERS_COUNT | ;Get erase fail count. |
ADD #1 |
| ;Increment fail count. |
SACL | ERS_COUNT | ;Save new count. |
PRELIMINARY | Assembly Source Listings and Program Examples |