Texas Instruments TMS320F20x/F24x DSP Computer Drive User Manual


 
Assembly Source for Algorithms
PRELIMINARY
A-21
Assembly Source Listings and Program Examples
PRELIMINARY
* BASE_3 Used for buffer/row start addr *
* BASE_4 Used for destination end addr *
* BASE_5 Used for byte mask *
******************************************************
GPGMJ: SPLK #0,IMR ;MASK ALL INTERRUPTS
SETC INTM ;GLOBALLY MASK ALL INTERRUPTS
SPLK #0,ERROR ;Initialize error flag (no error).
LACL PRG_paddr ;Get destination start address.
SACL FL_ADRS ;Save as current address.
ADD PRG_length ;Determine destination end addr.
SUB #1 ;
SACL BASE_4 ;Save destination end addr.
LACL PRG_paddr ;Get destination start addr.
LAR AR3,PRG_bufaddr ;Get buffer start address.
********Begin a new row.*
NEWROW
SACL BASE_1 ;Save row start address.
SAR AR3,BASE_3 ;Save buffer/row start address.
LAR AR1,#0 ;Init pulse count to zero.
SPLK #31,BASE_2 ;Init row length–1 to 31.
AND #001Fh ;Is start addr on row boundary?
CC ADJ_ROW,NEQ ;If not then adjust row length.
LACL BASE_1 ;Get row start address.
OR #001Fh ;Get row end address.
SUB BASE_4 ;Is end address on row boundary?
CC ADJ_ROW,GT ;If not then adjust row length.
********Same row, next pulse.*
SAMEROW SPLK #1,BASE_0 ;Set row done flag = 1(True).
LACL BASE_1 ;Get row start address.
SACL FL_ADRS ;Save as current address.
LAR AR3,BASE_3 ;Get buffer/row start addr.
LAR AR2,BASE_2 ;Init row index.
** Repeat the following code 32 times or until end of row.*
LOBYTE ;********First, do low byte.*
CALL SET_MODULE,AR4 ;Determine which flash module.
SPLK #0FFh,BASE_5 ;Set lo–byte mask.
CALL PRG_BYTE ;Check/Program lo–byte.
SPLK #0FF00h,BASE_5 ;Set hi–byte mask.
CALL PRG_BYTE ;Check/Program hi–byte.
NEXTWORD ;********Next word in row.
LACL FL_ADRS ;Load address for next word.
ADD #1 ;Increment address.
SACL FL_ADRS ;Save as current address.
MAR *,AR3 ;ARP –> buffer addr index.
MAR *+,AR2 ;Inc, and ARP –> row index.
BANZ LOBYTE ;Do next word,and dec AR2.
** Reached end of row. Check if row done. *
BIT BASE_0,15 ;Get row_done flag.
BCND ROW_DONE,TC ;If 1 then row is done.
MAR *,AR1 ;Else, row is not done, so
MAR *+ ;inc row pulse count.
LAR AR0,#MAX_PGM ;Check if passed allowable max.
CMPR 2 ;If AR1>MAX_PGM then