![](https://csdnimg.cn/release/download_crawler_static/86214916/bg1.jpg)
评:驱动程序对于所有的铁电系列 I2C FRAM 都是适用的,只是容量、电平(3V 和 5V)的不同,驱动程序
是针对 51MCU 的,但对其他 MCU 只要稍微修改就可使用。
在存贮数据量不大,而且读写次数频繁时,可选择 I2C FRAM。
//THIS CODE WAS DESIGNED TO DEMONSTRATE HOW THE FM24C04/FM24C04A SERIAL FRAM COULD
//BE INTERFACED TO THE 8051 MICROCONTROLLER. THE INTERFACE USES 2 LINES
//FROM PORT 2 (P2.7 AND P2.6) TO COMMUNICATE.
//THE CODE SHOWN DEMONSTRATES A 'RANDOM READ' AND 'BYTE WRITE'. THE OTHER *
//MODES OF OPERATION CAN BE CREATED BY EXPANDING UPON THESE ROUTINES.
//深圳市华胄科技有限公司
//the first date writed:2003-11-20
//email:gaoqiang@huazhoucn.com
//by:tiger
//=============================
#i nclude<reg52.h>
#i nclude<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define IIC_READ 0XA1 //定义读指令
#define IIC_WRITE 0XA0 //定义写指令
#define NOP _nop_()
//#define SDA INT0
//#define SCL T0
//==============================
uchar idata buff[32]; //save the byte read out form iic device in test operation
uchar idata readbuff[32];//测试数组,暂存写入读出数据
//uchar writebuff[32];
//===============================
sbit SDA=P1^4;//P2^7; //THE SDA BIT IS PORT 2 BIT 7
sbit SCL=P1^7;//P2^6; //THE SCL BIT IS PORT 2 BIT 6
//sbit WP=P2^5;
//sbit test=P1^0;
//===============================
//define a bit_operation byte to use in shift operation
//use this mode can achieve high operation speed
uchar bdata bbyte;//定义位操作用数组,采用此方法可提高位操作速度
sbit a0=bbyte^0;
sbit a1=bbyte^1;
sbit a2=bbyte^2;
sbit a3=bbyte^3;
sbit a4=bbyte^4;
sbit a5=bbyte^5;
sbit a6=bbyte^6;
sbit a7=bbyte^7;