用单片机实现对SST39VF040的操作.docx

上传人:b****8 文档编号:11124392 上传时间:2023-02-25 格式:DOCX 页数:20 大小:315.17KB
下载 相关 举报
用单片机实现对SST39VF040的操作.docx_第1页
第1页 / 共20页
用单片机实现对SST39VF040的操作.docx_第2页
第2页 / 共20页
用单片机实现对SST39VF040的操作.docx_第3页
第3页 / 共20页
用单片机实现对SST39VF040的操作.docx_第4页
第4页 / 共20页
用单片机实现对SST39VF040的操作.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

用单片机实现对SST39VF040的操作.docx

《用单片机实现对SST39VF040的操作.docx》由会员分享,可在线阅读,更多相关《用单片机实现对SST39VF040的操作.docx(20页珍藏版)》请在冰豆网上搜索。

用单片机实现对SST39VF040的操作.docx

用单片机实现对SST39VF040的操作

AT89C51对SST之FLASH的编程操作详述

Flash又名闪存,属于EEPROM,即电可擦除可编程的存储器。

由于具有电可擦除的特性,并且其数据可保留上百年,所以它的应用范围非常广泛。

非常适用于作为MicroChip以及DSP的外部程序存储器,或者作为需要存储大量数据的外部EEPROM。

SST公司设计之39系列Multi-PurposeFlash,按照其存储的空间主要分以下几种:

64Kx8/128Kx8/256Kx8/512Kx8Byte,各自代表的芯片型号有:

39系列Flash之特性:

SST39LF512/010/020/040工作电压为3.0-3.6V;SST39VF512/010/020/040工作电压为2.7V~3.6V;数据保留时间>100年;工作电流典型值为10mA,待机电流为1uA;快速擦除芯片时间为70ms,字节编程时间为14us。

对芯片有如下操作:

chipEraseoperation;sectorEraseoperation;byteprogramoperation;bytereadoperation;writeoperationstatusdetection。

通过软件对芯片的操作可以访问到SST制造商的ID;以及芯片的ID,各芯片ID如下表:

TABLE1:

PRODUCTIDENTIFICATION

Address

Data

Manufacturer’sID

0000H

BFH

DeviceID

SST39LF/VF512

SST39LF/VF010

SST39LF/VF020

SST39LF/VF040

0001H

0001H

0001H

0001H

D4H

D5H

D6H

D7H

注意:

当通过软件访问了ProductIdentification后,必须采用软件命令退出该模式才能对芯片进行擦除、读写的操作.

 

下面给出各软件操作指令的时序图:

 

 

1.WE控制的字节编程时序:

 

2.CE控制的字节编程时序图:

3.编程操作的状态检测时序图:

4.WE控制的扇区擦除时序图:

5.WE控制的芯片擦除时序图:

6.软件访问ID的时序图:

7.退出软件访问ID&复位命令的时序图:

根据上面的时序图,下面给出各种软件指令操作的流程图:

1.字节编程流程图:

2.读取ID流程图:

3.复位命令流程图:

4.芯片擦除命令流程图:

5.扇区擦除命令流程图:

 

下面以SST39VF040为列,给出AT89C51对其做编程动作的sourcecode:

SST39VF040地址线为A0…A18,数据线为DQ0…DQ7,片选线CE,数据写使能线WE,数据读使能线OE。

#defineucharunsignedchar

#defineuintunsignedint

#defineulongunsignedlong

sfrDataOut=0x80;//定义P0口接SST39VF040的数据线

sfrAddress7_0=0x90;//定义P1口接SST39VF040的地址线A0…A7

sfrAddress15_8=0xa0;//定义P2口接SST39VF040的地址线A8…A15

sbitAddress16=P3^2;//定义P3.2接SST39VF040的地址线A16

sbitAddress17=P3^3;//定义P3.3接SST39VF040的地址线A17

sbitAddress18=P3^4;//定义P3.4接SST39VF040的地址线A18

sbitSst39vf040_Ce=P3^5;//定义P3.5接SST39VF040的片选线线CE

sbitSst39vf040_We=P3^6;//定义P3.6接SST39VF040的写使能线WE

sbitSst39vf040_Oe=P3^7;//定义P3.7接SST39VF040的读使能线OE

structFlash

{

ucharmanufacturer_id;

uchardevice_id;

ulongaddress;

}Sst39vf040;

//读FLASHID的函数,入口参数:

FLASH的manfacturer_ID,device_ID,出口参数返回1,0

ucharRead_Id(ucharmanfa_id,uchardevi_id)

{

Sst39vf040_Ce=1;

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Sst39vf040_Oe=1;

Sst39vf040_Ce=0;

Sst39vf040_We=0;

DataOut=0xaa;

Sst39vf040_We=1;

Address7_0=0xaa;

Address15_8=0x2a;

Delay10us();

Sst39vf040_We=0;

DataOut=0x55;

Delay10us();

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Delay10us();

Sst39vf040_We=0;

DataOut=0x90;

Sst39vf040_We=1;

Sst39vf040_Ce=1;

Delay10us();

Address7_0=0x00;

Address15_8=0x00;

Sst39vf040_Ce=0;

Sst39vf040_Oe=0;

DataOut=0xff;

Sst39vf040.manufacturer_id=DataOut;

Address7_0=0x01;

Delay10us();

Sst39vf040.device_id=DataOut;

Sst39vf040_Ce=1;

if((Sst39vf040.manufacturer_id==manuf_ID)&&(Sst39vf040.device_id==devi_ID))

return1;

else

return0;

}

//退出读ID的状态以及命令FLASH复位的函数

voidRead_Id_Exit(void)

{

Sst39vf040_Ce=1;

Sst39vf040_Oe=0;

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Sst39vf040_Ce=0;

Sst39vf040_Oe=1;

Sst39vf040_We=0;

Delay10us();

DataOut=0xaa;

Sst39vf040_We=1;

Delay10us();

Address7_0=0xaa;

Address15_8=0x2a;

Delay10us();

Sst39vf040_We=0;

Delay10us();

DataOut=0x55;

Sst39vf040_We=1;

Delay10us();

Address7_0=0x55;

Address15_8=0x55;

Delay10us();

Sst39vf040_We=0;

Delay10us();

DataOut=0xf0;

Sst39vf040_We=1;

Sst39vf040_Ce=1;

Delay10us();

Sst39vf040_Ce=0;

}

//芯片擦除函数

voidChip_Erase(void)

{

Sst39vf040_Ce=1;

Sst39vf040_Oe=0;

Sst39vf040_We=1;

Address18=0;

Address17=0;

Address16=0;

Address7_0=0x55;

Address15_8=0x55;

Sst39vf040_Ce=0;

Sst39vf040_Oe=1;

Sst39vf040_We=0;

DataOut=0xaa;

Delay10us();

Sst39vf040_We=1;

Address7_0=0xaa;

Address15_8=0x2a;

Delay10us();

Sst39vf040_We=0;

DataOut=0x55;

Delay10us();

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Delay10us();

Sst39vf040_We=0;

DataOut=0x80;

Delay10us();

Sst39vf040_We=1;

Delay10us();

Sst39vf040_We=0;

DataOut=0xaa;

Delay10us();

Sst39vf040_We=1;

Address7_0=0xaa;

Address15_8=0x2a;

Delay10us();

Sst39vf040_We=0;

DataOut=0x55;

Delay10us();

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Delay10us();

Sst39vf040_We=0;

DataOut=0x10;

Delay10us();

Sst39vf040_We=1;

while(!

Wait_Data_Pulling());

}

//检测FLASH编程,擦除操作过程中是否完成的函数,完成后返回值1

ucharWait_Data_Pulling(void)

{

ucharoutdata;

Sst39vf040_Ce=1;

Sst39vf040_We=1;

Sst39vf040_Oe=1;

Delay10us();

Sst39vf040_Ce=0;

Sst39vf040_Oe=0;

Delay10us();

DataOut=0xff;

outdata=DataOut;

Sst39vf040_Ce=1;

Sst39vf040_Oe=1;

if((outdata&0x80)==0x80)

return1;

else

return0;

}

//字节编程函数,入口参数:

(byte_address:

Ams~A0=A18~A0,待写的数据:

byte_data),

voidWe_Byte_Program(ulongbyte_address,ucharbyte_data)

{

ulongtemp_address;

Sst39vf040_Ce=1;

Sst39vf040_Oe=0;

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Address16=0;

Address17=0;

Address18=0;

Sst39vf040_Ce=0;

Sst39vf040_Oe=1;

Sst39vf040_We=0;

DataOut=0xaa;

Delay10us();

Sst39vf040_We=1;

Address7_0=0xaa;

Address15_8=0x2a;

Delay10us();

Sst39vf040_We=0;

DataOut=0x55;

Delay10us();

Sst39vf040_We=1;

Address7_0=0x55;

Address15_8=0x55;

Delay10us();

Sst39vf040_We=0;

DataOut=0xa0;

Delay10us();

Sst39vf040_We=1;

temp_address=byte_address;

Address7_0=temp_address&0x0000ff;

temp_address=byte_address;

Address15_8=(temp_address&0x00ff00)>>8;

temp_address=byte_address;

if((temp_address&0x010000)!

=0)

Address16=1;

else

Address16=0;

temp_address=byte_address;

if((temp_address&0x020000)!

=0)

Address17=1;

else

Address17=0;

temp_address=byte_address;

if((temp_address&0x040000)!

=0)

Address18=1;

else

Address18=0;

Delay10us();

Sst39vf040_We=0;

DataOut=byte_data;

Delay10us();

Sst39vf040_We=1;

while(!

Wait_Data_Pulling());

}

//字节读函数入口参数:

待读的字节地址byte_address,返回参数值:

读出的数据

ucharByte_Read(ulongbyte_address)

{

ulongtemp_address;

uchartemp_data;

temp_address=byte_address;

Sst39vf040_Ce=1;

Sst39vf040_Oe=1;

Sst39vf040_We=1;

Address7_0=temp_address&0x000000ff;

temp_address=byte_address;

Address15_8=(temp_address&0x0000ff00)>>8;

temp_address=byte_address;

if((temp_address&0x00010000)!

=0)

Address16=1;

else

Address16=0;

temp_address=byte_address;

if((temp_address&0x00020000)!

=0)

Address17=1;

else

Address17=0;

temp_address=byte_address;

if((temp_address&0x00040000)!

=0)

Address18=1;

else

Address18=0;

Delay10us();

Sst39vf040_Ce=0;

Sst39vf040_Oe=0;

Delay10us();

DataOut=0xff;

temp_data=DataOut;

Sst39vf040_Ce=1;

Sst39vf040_Oe=1;

returntemp_data;

}

以上给出了读写SST39VF040的C51源程式,其他几个型号的FLASH读写都可以调用这些函数,只要改变入口参数即可,读者可以灵活应用。

(注:

文档可能无法思考全面,请浏览后下载,供参考。

可复制、编制,期待你的好评与关注!

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 政史地

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1