本帖最后由 zheng522 于 2014-1-10 11:15 编辑 已经开始进行测试了,下面给大家汇报下,个人感觉MB85RC256的特点中,我最看重的是写的次数几乎认为是无限次。这样在一些需要存一定的数据,便又频繁的进行写操作的应用中,它的优点就得到最大的体现。其它特点,如速度快,一次可以写N个数据等,使用其它的EEPROM也能实现。所以我看好它的近乎无限次的写特点。另外就是低功耗的特性,我在应用中就是通过单片机的IO口对MB85RC256提供电源,灵活方便,更好的进行低功耗的设计,和AT24Cxx系列的无缝替换也会在更多的场合得到更多的应用,上手更加的方便。最后就是价格相对较高,在一般的应用中,这样的价格和EEPROM相比还是有些。。。最后要说在选封装是要多看一下,别选错了,焊不上去了。总的来说,感觉很不错!谢谢EEWORLD,谢谢武汉力源。
先介绍一下这个芯片:MB85RC256V 是一种具有串行接口的 256K 位 FRAM (I2C),通过铁电工艺和 CMOS 工艺技术形成非易失存储单元。
FRAM 既是非易失性存储器,也可以实现高速写入,因此,它适用于日志管理和恢复数据等。
特点
位配置 :32,768 字 × 8 位
二线串行接口 :通过两个端口利用串行时钟 (SCL) 和串行数据(SDA) 实现完全可控。
工作频率 :2.7V 到 4.5V 400 kHz(最大) 4.5V 到 5.5V 1 MHz(最大)
读/写耐久性 :10^10(100 亿)次/字节
数据保持 :10 年 (+70℃)
工作电源电压 :2.7V 到 5.5V
低功耗 :工作电流待定(1MHz 下的典型值),待机电流待定(典型值)
工作温度范围 :-40℃ 到 +85℃
封装 :塑料/SOP,8 引脚 (FPT-8P-M02):塑料/SOP,8 引脚 (FPT-8P-M08)
符合 RoHS
附图是芯片的引脚图我选用的单片机是MSP430F2132,通过硬件I2C口和FRAM进行通信,由于是以前的一个板子,把以前的AT24C02换成MB85RC256V资源分配是:
/*-------------------------------------------------------
硬件资源分配:
MB85RC256 MSP430F2132
Vcc---------------------------P3.4
WP ---------------------------P3.3
SDA---------------------------P3.1
SCL---------------------------P3.2
A0 ---------------------------GND
A1 ---------------------------GND
A2 ---------------------------GND
Vss---------------------------GND
用MSP430单片机的硬件I2C,我用的是以前的一个板子(24C02)
当时将EEPROM的电源通过IO进行控制。由上面的接线可知MB85RC256
的器件地址为0x50(1010 000 x),1010为默认值(和AT24Cxx系列一
样),000为地址(A0,A1,A2接地)。接收和发送都采用中断的方
式,此程序最大的发送数据字符长度为64(MAXPAGEWRITE)。
-------------------------------------------------------*/
/*-------------------------------------------------------
include
-------------------------------------------------------*/
#include "msp430x21x2.h"
/*-------------------------------------------------------
define
-------------------------------------------------------*/
#define EEPROM_POWER_PxOUT P3OUT
#define EEPROM_POWER_PxDIR P3DIR
#define EEPROM_POWER_PxIN P3IN
#define EEPROM_POWER_PIN BIT4
#define EEPROM_WP_PxOUT P3OUT
#define EEPROM_WP_PxDIR P3DIR
#define EEPROM_WP_PxIN P3IN
#define EEPROM_WP_PIN BIT3
#define EEPROM_POWER_ON EEPROM_POWER_PxOUT |= EEPROM_POWER_PIN;
#define EEPROM_POWER_OFF EEPROM_POWER_PxOUT &= ~EEPROM_POWER_PIN;
#define EEPROM_WP_ON EEPROM_WP_PxOUT |= EEPROM_WP_PIN;
#define EEPROM_WP_OFF EEPROM_WP_PxOUT &= ~EEPROM_WP_PIN;
#define MAXPAGEWRITE 64
#define I2C_PORT_SEL P3SEL
#define I2C_PORT_OUT P3OUT
#define I2C_PORT_REN P3REN
#define I2C_PORT_DIR P3DIR
#define SDA_PIN BIT1 // UCB0SDA pin
#define SCL_PIN BIT2 // UCB0SCL pin
#define SCL_CLOCK_DIV 0x12 // SCL clock devider
/*-------------------------------------------------------
global val
-------------------------------------------------------*/
unsigned char WR_BUF[64];
unsigned char RD_buf[64];
char Index = 0;
int PtrTransmit;
unsigned char I2CBufferArray[66];
unsigned char I2CBuffer;
/*-------------------------------------------------------
declare fun
-------------------------------------------------------*/
/*-------------------------------------------------------
fun
-------------------------------------------------------*/
/*******************************************
函数名称:InitI2C
功 能:I2C初始化
参 数:无
返回值 :无
********************************************/
void InitI2C(unsigned char eeprom_i2c_address)
{
I2C_PORT_SEL |= SDA_PIN + SCL_PIN; // Assign I2C pins to USCI_B0
// Recommended initialisation steps of I2C module as shown in User Guide:
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCTR + UCSWRST; // Use SMCLK, TX mode, keep SW reset
UCB0BR0 = SCL_CLOCK_DIV; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = eeprom_i2c_address; // define Slave Address
// In this case the Slave Address
// defines the control byte that is
// sent to the EEPROM.
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
if (UCB0STAT & UCBBUSY) // test if bus to be free
{ // otherwise a manual Clock on is
// generated
I2C_PORT_SEL &= ~SCL_PIN; // Select Port function for SCL
I2C_PORT_OUT &= ~SCL_PIN; //
I2C_PORT_DIR |= SCL_PIN; // drive SCL low
I2C_PORT_SEL |= SDA_PIN + SCL_PIN; // select module function for the
// used I2C pins
};
}
/*******************************************
函数名称:I2CWriteInit
功 能:MB85RC256写初始化
参 数:无
返回值 :无
********************************************/
void I2CWriteInit(void)
{
UCB0CTL1 |= UCTR; // UCTR=1 => Transmit Mode (R/W bit = 0)
IFG2 &= ~UCB0TXIFG;
IE2 &= ~UCB0RXIE; // disable Receive ready interrupt
IE2 |= UCB0TXIE; // enable Transmit ready interrupt
}
/*******************************************
函数名称:I2CReadInit
功 能:MB85RC256读初始化
参 数:无
返回值 :无
********************************************/
void I2CReadInit(void)
{
UCB0CTL1 &= ~UCTR; // UCTR=0 => Receive Mode (R/W bit = 1)
IFG2 &= ~UCB0RXIFG;
IE2 &= ~UCB0TXIE; // disable Transmit ready interrupt
IE2 |= UCB0RXIE; // enable Receive ready interrupt
}
/*******************************************
函数名称:EEPROM_ByteWrite
功 能:MB85RC256一个字节写
参 数:Address要写的起始地址
返回值 :无
********************************************/
void EEPROM_ByteWrite(unsigned int Address, unsigned char Data)
{
unsigned char adr_hi;
unsigned char adr_lo;
while (UCB0STAT & UCBUSY); // wait until I2C module has
// finished all operations.
adr_hi = Address >> 8; // calculate high byte
adr_lo = Address & 0xFF; // and low byte of address
I2CBufferArray[2] = adr_hi; // Low byte address.
I2CBufferArray[1] = adr_lo; // High byte address.
I2CBufferArray[0] = Data;
PtrTransmit = 2; // set I2CBufferArray Pointer
I2CWriteInit();
UCB0CTL1 |= UCTXSTT; // start condition generation
// => I2C communication is started
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
UCB0CTL1 |= UCTXSTP; // I2C stop condition
while(UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
}
/*******************************************
函数名称:EEPROM_PageWrite
功 能:MB85RC256多个字节写
参 数:Address要写的起始地址,* Data要写
数据指针,Size要写数据的个数
返回值 :无
********************************************/
void EEPROM_PageWrite(unsigned int StartAddress, unsigned char * Data, unsigned int Size)
{
unsigned int l = 0;
unsigned int address = StartAddress;
EEPROM_WP_OFF; //允许写
for(l = 0;l < 100;l++);
for(l = 0;l < Size;l++)
{
if((address + l)>32768)
{
return;
}
EEPROM_ByteWrite(address,Data[l]);
address++;
}
EEPROM_WP_ON; //写保护
}
/*******************************************
函数名称:EEPROM_RandomRead
功 能:MB85RC256一个字节读
参 数:Address要读的起始地址
返回值 :无
********************************************/
unsigned char EEPROM_RandomRead(unsigned int Address)
{
unsigned char adr_hi;
unsigned char adr_lo;
while (UCB0STAT & UCBUSY); // wait until I2C module has
// finished all operations
adr_hi = Address >> 8; // calculate high byte
adr_lo = Address & 0xFF; // and low byte of address
I2CBufferArray[1] = adr_hi; // store single bytes that have to
I2CBufferArray[0] = adr_lo; // be sent in the I2CBuffer.
PtrTransmit = 1; // set I2CBufferArray Pointer
// Write Address first
I2CWriteInit();
UCB0CTL1 |= UCTXSTT; // start condition generation
// => I2C communication is started
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
// Read Data byte
I2CReadInit();
UCB0CTL1 |= UCTXSTT; // I2C start condition
while(UCB0CTL1 & UCTXSTT); // Start condition sent?
UCB0CTL1 |= UCTXSTP; // I2C stop condition
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
while(UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
return I2CBuffer;
}
/*******************************************
函数名称:EEPROM_SequentialRead
功 能:MB85RC256多个字节读
参 数:Address要读的起始地址,* Data要存放
数据的地址指针,Size要读数据的个数
返回值 :无
********************************************/
void EEPROM_SequentialRead(unsigned int Address , unsigned char * Data , unsigned int Size)
{
unsigned char adr_hi;
unsigned char adr_lo;
unsigned int counterSize;
while (UCB0STAT & UCBUSY); // wait until I2C module has
// finished all operations
adr_hi = Address >> 8; // calculate high byte
adr_lo = Address & 0xFF; // and low byte of address
I2CBufferArray[1] = adr_hi; // store single bytes that have to
I2CBufferArray[0] = adr_lo; // be sent in the I2CBuffer.
PtrTransmit = 1; // set I2CBufferArray Pointer
// Write Address first
I2CWriteInit();
UCB0CTL1 |= UCTXSTT; // start condition generation
// => I2C communication is started
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
// Read Data byte
I2CReadInit();
UCB0CTL1 |= UCTXSTT; // I2C start condition
while(UCB0CTL1 & UCTXSTT); // Start condition sent?
for(counterSize = 0 ; counterSize < Size ; counterSize++)
{
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
Data[counterSize] = I2CBuffer;
}
UCB0CTL1 |= UCTXSTP; // I2C stop condition
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
while(UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
}
/*******************************************
函数名称:TX_ISR_I2C
功 能:中断服务函数,进行I2C数据的收发。
参 数:无
返回值 :无
********************************************/
#pragma vector=USCIAB0TX_VECTOR
__interrupt void TX_ISR_I2C(void)
{
if(UCB0TXIFG & IFG2)
{
UCB0TXBUF = I2CBufferArray[PtrTransmit];// Load TX buffer
PtrTransmit--; // Decrement TX byte counter
if(PtrTransmit < 0)
{
while(!(IFG2 & UCB0TXIFG));
IE2 &= ~UCB0TXIE; // disable interrupts.
IFG2 &= ~UCB0TXIFG; // Clear USCI_B0 TX int flag
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
}
}
else if(UCB0RXIFG & IFG2)
{
I2CBuffer = UCB0RXBUF; // store received data in buffer
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
}
}
/*******************************************
函数名称:InitSys
功 能:系统初始化,初始化时钟,端口
参 数:无
返回值 :无
********************************************/
void InitSys(void)
{
/*********************************************
初始化时钟,MCLK = SMCLK = 1Mhz
ACLK=32768(外部晶振)
*********************************************/
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
/*********************************************
初始化MB85RC256,端口初始化,
*********************************************/
EEPROM_POWER_PxDIR |= EEPROM_POWER_PIN;
EEPROM_POWER_ON; //给MB85RC256供电
EEPROM_WP_PxDIR |= EEPROM_WP_PIN;
EEPROM_WP_OFF; //WP=0,MB85RC256可以写操作
}
/************主程序**************/
void main(void)
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
unsigned int i = 0;
InitSys(); //初始化
InitI2C(0x50); //初始化MB85RC256,写器件地址0x50
_EINT(); //开中断
for(int j = 0;j < 64;j++) //初始化发送数组WR_BUF,初始化数据为0~63
{
WR_BUF[j] = j;
}
EEPROM_PageWrite(1000,WR_BUF,50); //向MB85RC256起始地址1000写50个WR_BUF的字符
EEPROM_SequentialRead(1000,RD_buf,sizeof RD_buf); //从地址1000读64个字符
//将所有的地址都写为0
for(i = 0;i < 32768;i++)
{
EEPROM_ByteWrite(i , 0); //写一个字节
}
EEPROM_SequentialRead(1000,RD_buf,sizeof RD_buf); //读数据
Index = EEPROM_RandomRead(890); //读一个字节
__bis_SR_register(LPM3_bits + GIE); // Enter LPM0 w/ interrupt
}