加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

DSP学习第六篇——Flash 的使用

发布时间:2020-12-15 20:11:04 所属栏目:百科 来源:网络整理
导读:DSP学习第六篇——Flash?的使用 (2011-11-17 15:08:37) ? 标签: 杂谈 分类: DSP学习 Flash芯片 ? ? ? ? ? ? Am29LV800B : 8 Megabit (1 M x 8-Bit/512 K x 16-Bit) ? ? ? ? ? ? Am29LV800B简称LV800,它是一个低功耗flash,工作在2.7 - 3.6v电压下,一般

DSP学习第六篇——Flash?的使用

(2011-11-17 15:08:37)
?
标签:

杂谈

分类: DSP学习

Flash芯片

?

????? Am29LV800B :8 Megabit (1 M x 8-Bit/512 K x 16-Bit)

?

????? Am29LV800B简称LV800,它是一个低功耗flash,工作在2.7 - 3.6v电压下,一般来说存储数据可以保存100年以上,可以重复编程次数高达10万次。A18到A0为外部地址管脚, DQ0–DQ15为16条数据线,CE#为片选控制管脚(低有效),OE#为输出控制管脚(低有效),WE#为写入控制管脚(低有效)

?

Flash擦除

?

????? Flash一般有3种擦除方式:1按扇区擦除,2按块擦除,3整片擦除

?

????? 前两种方法为写入小程序时采用的部分擦除方法。后一种方法适用于大程序编程写入flash。本实验例程给出了第三种擦除方法

?

????? 擦除步骤



Attention:flash编程使用的是字地址

?

写flash

? ?



?

????? 1,编程使flash进入正常工作状态

?

????? 2,将要编程的flash空间擦除

?

????? 3,写flash

?

????? 4,将写入flash的中数据读出,进行读出校验

?

?

Flash_CS()与Flash_DisCS()

操作(读/写)flash前都要进行cpld片选flash的握手操作,即调用CS函数,操作完毕要释放dsp对flash的片选,调用disCS函数

CE1和CE2 接至? CPLD 使用

HX-5509 开发板通过功能选择寄存器组,利用 CE2、CE3 存储空间对各

寄存器组进行访问操作,操作流程如下:

1)读操作

①写功能选择寄存器组(写? CE2 空间任意地址),使能需要操作的目标寄

存器组,对于读? LCD 数据,必须将? LCDDIR 置为? 1;

②读目标寄存器组(读? CE2 空间任意地址) ;

③读操作完成后,再写功能选择寄存器组,禁用所有寄存器组。

2)写操作

①写功能选择寄存器组(写? CE2 空间任意地址),使能需要操作的目标寄

存器组;

②写目标寄存器组(写? CE3 空间任意地址) ;

③写操作完成后,再写功能选择寄存器组,禁用所有寄存器组。

void Flash_CS()
{
??
deminaddr = (int *)CESECT2;
??
*deminaddr =0x00fd;
???
deminaddr =(int*)CESECT3;
??
*deminaddr =0x0040;
??
deminaddr = (int *)CESECT2;
??
*deminaddr =0x00ff;
}

附录:


void Flash_CS()

{

deminaddr = (int *)CESECT2;

*deminaddr = 0x00fd;

? ? deminaddr = (int *)CESECT3;

*deminaddr = 0x0040;

deminaddr = (int *)CESECT2;

*deminaddr = 0x00ff;

}


void Flash_disCS()

{

deminaddr = (int *)CESECT2;

*deminaddr = 0x00fd;

? ? deminaddr = (int *)CESECT3;

*deminaddr = 0x00c0;

deminaddr = (int *)CESECT2;

*deminaddr = 0x00ff;

}


void Flash_Reset() ?//AM29LV800复位

{

deminaddr = (int *)CESECT2;

*deminaddr = 0x00fd;

? ? deminaddr = (int *)CESECT3;

*deminaddr = 0x0000;

delay(1000);

*deminaddr = 0x0040;

*deminaddr = 0x00c0;

deminaddr = (int *)CESECT2;

*deminaddr = 0x00ff;

}


Uint16 Flash_Erase_all() ?//AM29LV800芯片擦除

{

? ? Flash_CS();


deminaddr = (int *)CESECT1;

addbias = 0x0555;

*(deminaddr+addbias) = 0x00aa;

addbias = 0x02aa;

*(deminaddr+addbias) = 0x0055;

addbias = 0x0555;

*(deminaddr+addbias) = 0x0080;

addbias = 0x0555;

*(deminaddr+addbias) = 0x00aa;

addbias = 0x02aa;

*(deminaddr+addbias) = 0x0055;

addbias = 0x0555;

*(deminaddr+addbias) = 0x0010;

delay(100);

fstatus = *(deminaddr+addbias);

fstatus &= 0x0040;

fstatus2 = *(deminaddr+addbias);

if((fstatus&fstatus2)!=0)

{

Flash_disCS();

return 0;

}

else

{

while(fstatus!=0x00ff)

? ?{

ddelay(500);

fstatus = *(deminaddr+addbias);

fstatus &= 0x00ff;

? ?}

Flash_disCS();

return 1;

}

}


Uint16 Flash_Erase_sector() ?//AM29LV800分段擦除

{

return 1;

}


void Flash_Write_init() ?//AM29LV800烧写初始化

{

Flash_CS();


deminaddr = (int *)CESECT1;

addbias = 0x0555;

*(deminaddr+addbias) = 0x00aa;

addbias = 0x02aa;

*(deminaddr+addbias) = 0x0055;

addbias = 0x0555;

*(deminaddr+addbias) = 0x0020;

}


Uint16 Flash_Write(Uint16 waddr,Uint16 wdata) //AM29LV800烧写

{

? ? *(fwaddr+waddr) = 0x00a0;

*(fwaddr+waddr) = wdata;

delay(10000);

fstatus = *(fwaddr+waddr);

? ? while(fstatus!=wdata)

{

delay(10000);

fstatus = *(fwaddr+waddr);

}

return 1;

}


void Flash_Write_end() ?//AM29LV800烧写结束

{

deminaddr = (int *)CESECT1;

*deminaddr = 0x0090;

*deminaddr = 0x0000;

Flash_disCS();

}


Uint16 Flash_Read(Uint16 raddr) ?//AM29LV800读

{

Uint16 frtemp;

frtemp = *(fraddr+raddr);

return frtemp;

}


main()

{

? ? CSL_init();

? ? CHIP_RSET(XBSR,0x0a01);

? ? ?//设置系统的运行速度为144MHz*/

? ? PLL_config(&myConfig);

? ? //初始化DSP的外部SDRAM*/

? ? EMIF_config(&emiffig);

Flash_Reset();

? ? //Flash_Erase_all运行大约为14s以上,为节约时间注释掉,用户可自行根据需要取消注释

success = Flash_Erase_all();



//以下程序为烧写AM29LV800

Flash_Write_init();

fwaddr = (int *)CESECT1; ?//地址首先指向5509的CE1空间(AM29LV800所在)

fwaddr += 0x10000; ? ? ? ?//指向AM29LV800的1扇区

for(datacount=0;datacount<1000;datacount++)

{

success = Flash_Write(datacount,datacount);

}

Flash_Write_end();


//以下程序为读AM29LV800

for(datacount=0;datacount<1000;datacount++)

{

databuffer[datacount]=0;

}

Flash_CS();

fraddr = fwaddr;

for(datacount=0;datacount<1000;datacount++)

{

databuffer[datacount] = Flash_Read(datacount);

}

Flash_disCS();

//运行到此处,在view--memory里查看databuffer开始地址的数据,看是否所写即所读

? ? while(1);

}?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读