📄 pgm_alg.lst
字号:
142 002c SDELAY #Tpv_h_P ; Wait for Program verify hold time
1 002c bb3a RPT #Tpv_h_P
1 002d 8b00 NOP
143
144 002e ae04! SPLK #0001h,flashAlgoVars.PAD1 ;Clear out PMPC and CTRL
002f 0001
145 0030 7a80 CALL CLRCMD ;Since PMPC is cleared already, it is unchanged.
0031 00ab+
146
147 0032 SDELAY #Tpv_h_C ;Hold the normal read mode.
1 0032 bb3a RPT #Tpv_h_C
1 0033 8b00 NOP
148
149 ;--------------------------------------------------------------------------------------------------
150 ; Compare:
151 ;--------------------------------------------------------------------------------------------------
152 ; This section of code compares the data read out from the flash with the data
153 ; intended to be programmed in the flash.
154 ; 1. Get the data read out during the read.
155 ; 2. Create a bitmask by XOR-ing the data read out during verify with the
156 ; intended data pointed to by DATA_PTR.
157 ; 3. If not equal, builds the mask and calls the PROG routine.
158 ;--------------------------------------------------------------------------------------------------
159 ; Notes on building the mask:
160 ;
161 ; This implementation uses the Bitmask = DATA + !READ_Flash boolean expression for building the
162 ; bitmask. (The + is the boolean operator OR, and ! is inversion.)
163 ; The mask building works as follows:
164 ;
165 ; 1. Read the flash data.
166 ; 2. Invert this by XOR-ing this with 0xffff.
167 ; 3. OR this with the reference data from the buffer.
168 ; 4. Store the result as the mask into the DATA (subsequently sent to WDATA).
169 ;
170 ; For example lets say the flash cells contain the 16 bits: cccc cccc cccc cccc.
171 ;
172 ; CCCC cccc cccc cccc cccc (flash contents)
173 ; XOR
174 ; FFFF 1111 1111 1111 1111 (all ones mask)
175 ; ---- ---- ---- ---- ----
176 ; PPPP pppp pppp pppp pppp (intermediate result)
177 ; OR
178 ; DDDD dddd dddd dddd dddd (reference data from RAM buffer)
179 ; ---- ---- ---- ---- ----
180 ; MMMM mmmm mmmm mmmm mmmm (mask for writing in WDATA)
181 ;
182 ; Now the bits m are the result as p = ((C ^ 1) + y). The truth table for this is:
183 ;
184 ; d c c^1 or !c m = p = !c + d Action caused by m Comments
185 ;--------------------------------------------------------------------------------------------------
186 ; 0 0 1 1 No pulse applied. Note 1.
187 ; 0 1 0 0 Pulse applied. Note 2.
188 ; 1 0 1 1 No pulse applied. Note 3.
189 ; 1 1 0 1 No pulse applied. Note 4.
TMS320C24xx COFF Assembler Version 7.02 Tue Jul 29 10:56:11 2003
Copyright (c) 1987-2002 Texas Instruments Incorporated
pgm_alg.asm PAGE 5
190 ;
191 ;
192 ; Note 1: This is the case wheen the reference data is a 0 and the flash cell is a 0.
193 ; Clearly since Cell = Reference data, no pulse is needed, and this is what
194 ; happens with WDATA = 1 for this bit.
195 ;
196 ; Note 2: Case where the reference data is a 0, but the cell is a 1. So a pulse is
197 ; applied, to program the cell to a 0.
198 ;
199 ; Note 3. Case where the reference data is a 1, but the cell is a 0. This is a case
200 ; where the program routine is asked to 'program' a cell to a 1, while the
201 ; cell is already at a 0. This is a VIOLATION of the established flow, and
202 ; no pulses are really required. So no pulse is applied. This will lead
203 ; (rightly so) to an error condition.
204 ; Note 4: This is the case wheen the reference data is a 1 and the flash cell is a 1.
205 ; Clearly since Cell = Reference data, no pulse is needed, and this is what
206 ; happens with WDATA = 1 for this bit.
207 ;
208 ;--------------------------------------------------------------------------------------------------
209 0034 GET_DATA:
210 0034 020b! LAR AR2,flashAlgoVars.DATA_PTR ;Load AR2 with the address of the data.
211 0035 a980 BLDD *,#flashAlgoVars.DATA ;Load DATA with the intended contents.
0036 0003!
212 ;--------------------------------------------------------------------------------------------------
213 ; Zero Bit Error Check:
214 ; A zero bit error is defined as occurring when a bit in flash is a zero, when its intended value
215 ; as defined by the RAM buffer is a one.
216 ; The function used to detect this is err= (!READ).(DATA)
217 ; If non zero, a zero bit error is defined as having occurred.
218 ; This needs to be checked once per word. This avoids application of MAX_PCNT pulses to a cell
219 ; that is a zero, but is a one in the RAM buffer.
220 ;--------------------------------------------------------------------------------------------------
221 0037 ZERO_BIT_ERROR_CHK:
222 0037 6902! LACL flashAlgoVars.READ ;Get the value read out during the verify.
223 0038 bfd0 XOR #0ffffh ;Invert read out from flash.
0039 ffff
224 003a 6e03! AND flashAlgoVars.DATA ;ACC= (!READ).(DATA)
225
226 003b e308 BCND ZERO_BIT_ERROR,NEQ ;Branch to the corresponding error handler
003c 008d+
227 ;when this error happens.
228 ;--------------------------------------------------------------------------------------------------
229 003d COMPARE:
230 003d 6902! LACL flashAlgoVars.READ ;Get the value read out during the verify.
231 003e 6c03! XOR flashAlgoVars.DATA ;XOR the read out value with the desired
232 ;data.
233
234 003f e388 BCND NEXTWORD,EQ ;If ==0 then this word is done pgm-ing,
0040 004f+
235 ;if not start building the mask.
236
237 0041 1002! LACC flashAlgoVars.READ ;Get the contents READ from flash.
238 0042 bfd0 XOR #0ffffh ;ACC = !Flash.
0043 ffff
TMS320C24xx COFF Assembler Version 7.02 Tue Jul 29 10:56:11 2003
Copyright (c) 1987-2002 Texas Instruments Incorporated
pgm_alg.asm PAGE 6
239 0044 6d03! OR flashAlgoVars.DATA ;ACC = !FLASH + Data. i.e. ACC = MASK.
240 0045 9003! SACL flashAlgoVars.DATA ;Store mask in DATA, since PROG expects
241 ;the mask there.
242 0046 7a80 CALL PROG
0047 0062+
243 ;--------------------------------------------------------------------------------------------------
244 ; PGCNT:
245 ;--------------------------------------------------------------------------------------------------
246 ; This routine keeps track of the number of pulses applied to the flash memory location. If
247 ; number of pulses allowed reaches zero, error handling is commenced. Otherwise the program
248 ; pulse counter is decremented and one more cycle is commenced.
249 ;--------------------------------------------------------------------------------------------------
250 0048 1005! PGCNT: LACC flashAlgoVars.PLS_CNT ;Get the number of pulses remaining.
251 0049 ba01 SUB #1 ;Decrement the pulse counter
252 004a 9005! SACL flashAlgoVars.PLS_CNT ;and store it back.
253 004b e388 BCND PULSE_LIMIT_ERROR,EQ ;If zero, then branch to error handling.
004c 0083+
254 004d 7980 B PGVERON ;else, verify the word programmed.
004e 0012+
255
256 ;--------------------------------------------------------------------------------------------------
257 ; NEXTWORD
258 ;--------------------------------------------------------------------------------------------------
259 ; This section checks if the last address in the block is done.
260 ; If not increments the address and loops back to program the next word.
261 ;--------------------------------------------------------------------------------------------------
262 004f NEXTWORD:
263 004f 1008! LACC flashAlgoVars.FL_SECEND ;Get the counter.
264 0050 ba01 SUB #1 ;and advance it.
265 0051 9008! SACL flashAlgoVars.FL_SECEND
266
267 0052 e308 BCND NW,NEQ ;If the counter is non-zero, more words in
0053 0056+
268 ;this block remain to be programmed. So
269 ;proceed to program the next word.
270
271 0054 7980 B END1 ;Other wise exit the programming routine.
0055 009e+
272 ;--------------------------------------------------------------------------------------------------
273 0056 1000! NW LACC flashAlgoVars.ADDR ;Get the address variable and increment
274 0057 b801 ADD #1 ;the address counter and store it back.
275 0058 9000! SACL flashAlgoVars.ADDR ;
276
277 0059 ae05! SPLK #MX_PCNT,flashAlgoVars.PLS_CNT ;Initialize the Program Pulse Counter.
005a 00fa
278
279 005b 100b! LACC flashAlgoVars.DATA_PTR ;Increment the pointer into the buffer
280 005c b801 ADD #1 ;containing the programming data.
281 005d 900b! SACL flashAlgoVars.DATA_PTR
282
283 005e a90b! BLDD flashAlgoVars.DATA_PTR,#0064h ;Get the next data value to be programmed.
005f 0064
284 0060 7980 B PGVERON ;begin prog of next word
0061 0012+
TMS320C24xx COFF Assembler Version 7.02 Tue Jul 29 10:56:11 2003
Copyright (c) 1987-2002 Texas Instruments Incorporated
pgm_alg.asm PAGE 7
285 ;--------------------------------------------------------------------------------------------------
286 ; Program:
287 ;--------------------------------------------------------------------------------------------------
288 ; This subroutine applies a single program pulse to the flash word at
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -