📄 flashwrite.c
字号:
//
// Project: Experiment 2.10.5 Flash Programming - Chapter 2
// File name: flashWrite.c
// Function: flashWrite()
//
// Description: This function writes data to the C5510 DSK flash memory
// Note: this funciton is for AMD: AM29LV400B
//
// For the book "Real Time Digital Signal Processing:
// Implementation and Application, 2nd Ed"
// By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
// Publisher: John Wiley and Sons, Ltd
//
// Tools used: CCS v.2.12.07
// TMS320VC5510 DSK Rev-C
//
#include "flash.h"
#pragma CODE_SECTION(flashWrite, ".text:example:flashWrite");
short flashWrite(unsigned short *src, unsigned short *dest, unsigned long len)
{
unsigned long i;
volatile short j;
for (i=0; i<len; i++)
{
// Issue flash chip write sequence: AA-55-A0 then Addr Data
*((volatile unsigned short *)FLASH_MEM_ADDR555) = 0xaa;
*((volatile unsigned short *)FLASH_MEM_ADDR2AA) = 0x55;
*((volatile unsigned short *)FLASH_MEM_ADDR555) = 0xa0;
// Write data
*dest = *src;
// Wait until stable before check
for (j=0; j<500; j++);
// Check and wait until the flash write complete
while(1)
{
if ((*dest & FLASH_MEM_DQ7) == (*src & FLASH_MEM_DQ7))
{
break; // Write success
}
if ((*dest & FLASH_MEM_DQ5) == FLASH_MEM_DQ5)
{
flashReset(); // Reset flash
return (1); // Write failed and timed out
}
}
dest++;
src++;
}
// Reset flash
flashReset();
return (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -