📄 f411_vr_sstflash.lst
字号:
214 1 while (TXBMT != 1) // wait until the command is moved into
215 1 { // the XMIT buffer
216 2 }
217 1 SPI0DAT = temp_addr.UByte[1]; // load the high byte of the address
218 1 while (TXBMT != 1) // wait until the data is moved into
219 1 { // the XMIT buffer
220 2 }
221 1 SPI0DAT = temp_addr.UByte[2]; // load the middle byte of the address
222 1 while (TXBMT != 1) // wait until the data is moved into
223 1 { // the XMIT buffer
224 2 }
225 1 SPI0DAT = temp_addr.UByte[3]; // load the low byte of the address
226 1 while (TXBMT != 1) // wait until the data is moved into
227 1 { // the XMIT buffer
228 2 }
229 1 SPI0DAT = 0xFF; // load junk data in order to receive
230 1 // data from the flash
231 1 while (TXBMT != 1) // wait until the junk data is moved
232 1 { // into the XMIT buffer
233 2 }
234 1 SPIF = 0;
235 1 while (SPIF != 1) // wait until the read data is received
236 1 {
237 2 }
238 1 SPIF = 0;
239 1
240 1 NSSMD0 = 1; // disable the flash
241 1
C51 COMPILER V7.06 F411_VR_SSTFLASH 02/18/2009 16:30:51 PAGE 5
242 1 return SPI0DAT;
243 1 }
244
245 //-----------------------------------------------------------------------------
246 // Erase_MEM
247 //-----------------------------------------------------------------------------
248 //
249 // Return Value : None
250 // Parameters : None
251 //
252 // Erase all data from the SST flash memory.
253 //
254 void Erase_MEM (void)
255 {
256 1 unsigned char mem_status = 0x01;
257 1
258 1 NSSMD0 = 0; // enable the flash
259 1
260 1 // send the write enable command
261 1 SPI0DAT = WREN; // load the XMIT register
262 1 while (TXBMT != 1) // wait until the command is moved into
263 1 { // the XMIT buffer
264 2 }
265 1 SPIF = 0;
266 1 while (SPIF != 1) // wait until the command reaches the
267 1 { // flash
268 2 }
269 1 SPIF = 0;
270 1
271 1 NSSMD0 = 1; // allow the WREN to execute
272 1
273 1 NSSMD0 = 0; // enable the flash
274 1
275 1 // send the chip erase instruction
276 1 SPI0DAT = CERASE; // load the XMIT register
277 1 while (TXBMT != 1) // wait until the command is moved into
278 1 { // the XMIT buffer
279 2 }
280 1 SPIF = 0;
281 1 while (SPIF != 1) // wait until the command reaches the
282 1 { // flash
283 2 }
284 1 SPIF = 0;
285 1
286 1 NSSMD0 = 1; // allow the erase to execute
287 1
288 1 // poll on the busy bit in the flash until the erase operation is complete
289 1 NSSMD0 = 0; // enable the flash
290 1 SPI0DAT = RDSR; // send the read status register command
291 1 while (TXBMT != 1) // wait until the SPI can accept more
292 1 { // data
293 2 }
294 1 while (mem_status == 0x01)
295 1 {
296 2 SPI0DAT = 0xFF; // send junk in order to receive data
297 2 while (TXBMT != 1) // wait until the junk data is moved
298 2 { // into the XMIT buffer
299 3 }
300 2 SPIF = 0;
301 2 while (SPIF != 1) // wait until the read data is received
302 2 {
303 3 }
C51 COMPILER V7.06 F411_VR_SSTFLASH 02/18/2009 16:30:51 PAGE 6
304 2 SPIF = 0;
305 2 mem_status = SPI0DAT & 0x01; // check the BUSY bit
306 2 }
307 1
308 1 NSSMD0 = 1; // disable the flash
309 1 }
310
311 //-----------------------------------------------------------------------------
312 // Read_MEM_Init
313 //-----------------------------------------------------------------------------
314 //
315 // Return Value :
316 // 1) char data_byte - the data byte read from memory
317 // range is positive range of character: 0 to 255
318 // Parameters :
319 // 1) long address - address in the 512 kB external SST Flash
320 // range is postive values up to 2^19: 0 to 524287,
321 // or, 0 to 0x7FFFF
322 //
323 // Read one byte of data from a 24-bit address in the SST Flash Memory using
324 // the SPI. This function is called by Recording_Search in F411_VR.c
325 // and is a duplicate of Read_MEM to avoid a warning by the compiler.
326 //
327 unsigned char Read_MEM_Init (unsigned long address)
328 {
329 1 ADDRESS temp_addr;
330 1 temp_addr.ULong = address;
331 1
332 1 NSSMD0 = 0; // enable the flash
333 1
334 1 // send the read instruction
335 1 SPI0DAT = READ; // load the XMIT register
336 1 while (TXBMT != 1) // wait until the command is moved into
337 1 { // the XMIT buffer
338 2 }
339 1 SPI0DAT = temp_addr.UByte[1]; // load the high byte of the address
340 1 while (TXBMT != 1) // wait until the data is moved into
341 1 { // the XMIT buffer
342 2 }
343 1 SPI0DAT = temp_addr.UByte[2]; // load the middle byte of the address
344 1 while (TXBMT != 1) // wait until the data is moved into
345 1 { // the XMIT buffer
346 2 }
347 1 SPI0DAT = temp_addr.UByte[3]; // load the low byte of the address
348 1 while (TXBMT != 1) // wait until the data is moved into
349 1 { // the XMIT buffer
350 2 }
351 1 SPI0DAT = 0xFF; // load junk data in order to receive
352 1 // data from the flash
353 1 while (TXBMT != 1) // wait until the junk data is moved
354 1 { // into the XMIT buffer
355 2 }
356 1 SPIF = 0;
357 1 while (SPIF != 1) // wait until the read data is received
358 1 {
359 2 }
360 1 SPIF = 0;
361 1
362 1 NSSMD0 = 1; // disable the flash
363 1
364 1 return SPI0DAT;
365 1 }
C51 COMPILER V7.06 F411_VR_SSTFLASH 02/18/2009 16:30:51 PAGE 7
366
367 //-----------------------------------------------------------------------------
368 // ReadID_MEM
369 //-----------------------------------------------------------------------------
370 //
371 // Return Value :
372 // 1) char data_byte - the device ID read from memory at address 0x000001
373 // (this address is specified in the SST Flash datasheet)
374 // range is positive range of character: 0 to 255
375 // Parameters : None
376 //
377 // Read the part ID from the flash memory (used for debugging).
378 //
379 /*
380 char ReadID_MEM (void)
381 {
382 NSSMD0 = 0; // enable the flash
383
384 SPI0DAT = READID; // send the read ID instruction
385 while (TXBMT != 1) // wait until the SPI can accept more
386 { // data
387 }
388 SPI0DAT = 0x00; // send the device ID address
389 while (TXBMT != 1) // wait until the SPI can accept more
390 { // data
391 }
392 SPI0DAT = 0x00; // send the device ID address
393 while (TXBMT != 1) // wait until the SPI can accept more
394 { // data
395 }
396 SPI0DAT = 0x01; // send the device ID address
397 while (TXBMT != 1) // wait until the SPI can accept more
398 { // data
399 }
400 SPI0DAT = 0xA5; // send dummy data for shift register
401 while (TXBMT != 1) // wait until the SPI can accept more
402 { // data
403 }
404 SPIF = 0;
405 while (SPIF != 1) // wait until the read data is received
406 {
407 }
408 SPIF = 0;
409
410 NSSMD0 = 1; // disable the flash
411
412 return SPI0DAT;
413 }
414 */
415 //-----------------------------------------------------------------------------
416 // End Of File
417 //-----------------------------------------------------------------------------
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 282 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 17
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
C51 COMPILER V7.06 F411_VR_SSTFLASH 02/18/2009 16:30:51 PAGE 8
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -