标题:
【晒FRAM铁电存储器样片】+新唐M058S测试读写FRAM MB85RS64
[打印本页]
作者:
springvirus
时间:
2014-6-13 09:14
标题:
【晒FRAM铁电存储器样片】+新唐M058S测试读写FRAM MB85RS64
前一阵子申请了富士通的SPI 铁电片子MB85RS64,很快邮寄到了,给厂商赞一个! 看资料,铁电存储器吸收了Flash和RAM二者的优点于一身,耐擦写次数可达到10的12次方, 写数据耗时也比Flash和EEPROM要少,片子在3.3V下操作,运行和待机功耗也做得很棒。 这次的方案是用M058S的IO模拟SPI,完成读写,看了资料,主要就是注意6个 OP-CODE在操作时完成的功能。
在读状态寄存器之前,先赋值0xab,arraydata[]是读取buffer,writedata[]是写入 buffer,之前,测试时是这样,写入,由于使能了写使能1次,然后连续写,发现只在 0x00地址处写入了0xaa,细读手册,发现,每次写之后,片子都会复位写使能,所以 每次写之前都要使能写使能,有点拗口,之后的测试向地址0x00~0x04,写入0xaa~0xee ,再读出,与写入的一样,读写成功。
片子操作不复杂,使用起来容易上手,性能不错,值得推荐!!
下面是图和源码
下载
(390.56 KB)
2014-6-13 09:14
下载
(663.62 KB)
2014-6-13 09:14
图片附件:
023b5bb5c9ea15ce17c1e08bb4003af33a87b200.jpg
(2014-6-13 09:14, 390.56 KB) / 下载次数 781
http://bbs.eccn.com/attachment.php?aid=45367&k=61d0e6889c975cc4b15034a9dc531b99&t=1732222436&sid=vGbKZV
图片附件:
4e4a20a4462309f796c9ac90700e0cf3d6cad689.jpg
(2014-6-13 09:14, 663.62 KB) / 下载次数 811
http://bbs.eccn.com/attachment.php?aid=45368&k=f83a7c6ca17f1b6f006ac08a1a92dd2e&t=1732222436&sid=vGbKZV
作者:
springvirus
时间:
2014-6-13 09:21
uint8_t SpiRead(void)
//主机在SCK下降沿,从MISO上读取1字节
{
uint8_t i;
for(i=0;i<8;i++)
{
DATA_BUF = DATA_BUF<<1;
MB85RS64_SCK = 1;
if(MB85RS64_MISO)
{
DATA_BUF+=1;
}
else
{
DATA_BUF+=0;
}
MB85RS64_SCK = 0;
}
return DATA_BUF;
}
void SpiWrite(uint8_t byte)
//主机向MOSI写1字节,设备在SCK上升沿读取
{
uint8_t i;
DATA_BUF = byte;
MB85RS64_SCK = 0;
for(i=0;i<8;i++)
{
if(DATA_BUF >> 7)
{
MB85RS64_MOSI = 1;
}
else
{
MB85RS64_MOSI = 0;
}
#if 1
MB85RS64_SCK = 1;
DATA_BUF = DATA_BUF << 1;
MB85RS64_SCK = 0;
#else
MB85RS64_SCK = 0;
MB85RS64_SCK = 1;
DATA_BUF = DATA_BUF << 1;
#endif
}
}
void SetWriteEnableLatch(void)
//OP CODE: 0000 0110
{
MB85RS64_CS = 0;
SpiWrite(0x06);
MB85RS64_CS = 1;
}
void ResetWriteEnableLatch(void)
//OP CODE: 0000 0100
{
MB85RS64_CS = 0;
SpiWrite(0x04);
MB85RS64_CS = 1;
}
uint8_t ReadStatusRegister(void)
//OP CODE: 0000 0101
{
uint8_t rsr_byte;
MB85RS64_CS = 0;
SpiWrite(0x05);
rsr_byte = SpiRead();
MB85RS64_CS = 1;
return rsr_byte;
}
void WriteStatusRegister(uint8_t wsr_byte)
//OP CODE: 0000 0001
{
uint8_t rsr_byte;
MB85RS64_CS = 0;
SpiWrite(0x01);
SpiWrite(wsr_byte);
MB85RS64_CS = 1;
}
uint8_t ReadMemoryCode(uint16_t addr)
//OP CODE: 0000 0011
{
uint8_t rmc_byte;
uint8_t addr_high, addr_low;
addr_high = (uint8_t)(addr&0xff00)>>8;
addr_low = (uint8_t)(addr&0x00ff);
MB85RS64_CS = 0;
SpiWrite(0x03);
SpiWrite(addr_high);
SpiWrite(addr_low);
rmc_byte = SpiRead();
MB85RS64_CS = 1;
return rmc_byte;
}
void WriteMemoryCode(uint16_t addr, uint8_t wmc_byte)
//OP CODE: 0000 0010
{
uint8_t addr_high, addr_low;
addr_high = (uint8_t)(addr&0xff00)>>8;
addr_low = (uint8_t)(addr&0x00ff);
MB85RS64_CS = 0;
SpiWrite(0x02);
SpiWrite(addr_high);
SpiWrite(addr_low);
SpiWrite(wmc_byte);
MB85RS64_CS = 1;
}
void FRAM_Operate(void)
{
uint8_t status = 0xab;
uint8_t arraydata[5];
uint8_t writedata[5];
uint16_t i;
memcpy(writedata, "\xaa\xbb\xcc\xdd\xee", 5);
memcpy(arraydata, "\x01\x02\x03\x04\x05", 5);
TRACE("------- before Read ---------\r\n");
TRACE("status = 0x%02x", status);
printbuf("arraydata", arraydata, sizeof(arraydata));
SetWriteEnableLatch();
status = ReadStatusRegister();
for(i=0;i<sizeof(arraydata);i++)
{
arraydata[i] = ReadMemoryCode(i);
}
TRACE("------- after Read ---------\r\n");
TRACE("status = 0x%02x", status);
printbuf("arraydata", arraydata, sizeof(arraydata));
for(i=0;i<sizeof(writedata);i++)
{
SetWriteEnableLatch();
WriteMemoryCode(i, writedata[i]);
}
TRACE("\r\n------- after Write writedata ---------");
printbuf("writedata", writedata, sizeof(writedata));
TRACE("------- after Read again ---------");
memset(arraydata, 0x00, sizeof(arraydata));
for(i=0;i<sizeof(arraydata);i++)
{
arraydata[i] = ReadMemoryCode(i);
}
printbuf("arraydata", arraydata, sizeof(arraydata));
}
作者:
springvirus
时间:
2014-6-13 09:23
既然是模拟SPI,涉及到的CS, MOSI, MISO, SCK可以自由设定了,注意MISO,设置成输入模式
作者:
sfwang666
时间:
2014-7-15 17:06
铁电存储器擦写次数可达到10的12次方,性能稳定,可靠性比较好.
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0