资源简介
在tms320dm648下对s29gl256 flash进行编程程序,CCS环境下直接运行。
代码片段和文件信息
#include
#include
#include
//#define Buffer_Num 4096 // 0000H-1FFFFH for S29Gl256数据宽度16bit
#define Buffer_Num 2048 // 0000H-FFFFH for S29Gl256数据宽度16bit
#define Buffer_Size 32 // S29Gl256最大写入缓冲字数=32
#define FlashbaseAddr 0xA0000000 /* 16Mbytes Flash */
#define EMIFB_baseCTRL_ADDR (0x70000000)
#define EMIFB_CE2CFG (*(int*)(EMIFB_baseCTRL_ADDR + 0x00000080))
#define EMIFB_CE3CFG (*(int*)(EMIFB_baseCTRL_ADDR + 0x00000084))
#define EMIFB_AWCC (*(int*)(EMIFB_baseCTRL_ADDR + 0x000000A0))
void delay(unsigned int delaytime)
{
unsigned short ij;
for(i=0;i for(j=0;j<0x40;j++);
}
//擦除一个段,需要加上段地址号
void EraseOneSector(unsigned int sector)
{
volatile short *FlashAddr;
FlashAddr = (volatile short *)FlashbaseAddr;
if (sector>=256) sector=0;
FlashAddr[0x0555] = 0x00AA;
FlashAddr[0x02AA] = 0x0055;
FlashAddr[0x0555] = 0x0080;
FlashAddr[0x0555] = 0x00AA;
FlashAddr[0x02AA] = 0x0055;
FlashAddr[sector] = 0x30;
delay(2000);
}
unsigned short Sector_Buf[256];
char BinFileName[80];
void main()
{
unsigned int ij;
int size;
volatile short *FlashAddr;
FILE * fp;
unsigned short pollsector_numsector;
unsigned int EraseError=0;
// Configure async EMIF 16 bits max wait cycles
// EMIFB_CE2CFG = 0x00310181;
EMIFB_CE2CFG = 0x0FFFFFFD;
EMIFB_CE3CFG = 0x0FFFFFFD;
// Adjust TA for flash mem
EMIFB_AWCC = 0x40000380;
delay(100);
FlashAddr = (volatile short *)FlashbaseAddr;
FlashAddr[0]=0x00F0; /* Write Software reset command to reset Flash */
/********檫除flash段***********/
sector_num=Buffer_Num>>11;
for(sector=0; sector
评论
共有 条评论