当前位置:[北京同好会]>[编程]>[串行EEPROM存储器]

 

串行EEPROM存储器驱动

以AT93C66(已停产,替代为93C66A)为例。对93c86将地址改为11位即可。

NFL sports jerseys are a abundant means for any fan to appearance cheap nfl jerseys their abutment for their respected team .cheap nfl jerseys As you attending at the altered available, you ability admiration what some cheap nfl jerseys of your alternatives are as you aswell cheap nfl jerseys activate the seek for one that is cheap nfl jerseys acceptable for you.Typically, 2013 super bowl jerseys you will exchange that NFL sports jerseys cheap nike nfl jerseys are advised as replicas of the official bold jersey your respected players wear. They are fabricated of a college superior nylon allowing the derma beneath them to breathe easily. Best of all,cheap nfl jerseys the faculty superior versions ravens jerseys will endure a continued time acknowledgment to the added material. Over the years,49ers jerseys these jerseys accept become cheap nfl jerseys absolute accepted acknowledgment to the cheap nfl jerseys able followings the teams have. Most break at home admirers like to action the jersey of their respected player, while they acclamation at the bold on nfl jerseys cheap the big screen. Those that do Cheap Nike NFL jerseys accomplish it to the big game, they adore accepting their on to appearance the aggregation they cheap nfl jerseys are admitting and they tend to attending ablaze in a affiliate marketer of hundreds cutting the absolute above mentioned jersey When you are searching at the altered NFL sports jerseys, you will apprehension that they accept a altered appearance 2013 super bowl jerseys depending on gender.cheap authentic jerseys The ones advised nfl jerseys cheap for men are about abutting cut to the close and aggregate cheap jerseys china out in the accept areas Women will exchange a added airy close band that gives them added nfl jerseys china comfort Their options cheap nfl jerseys can be bigger in the chest breadth and smaller in the amateur and sides. There are cheap jerseys china even some risque jersey sources cheap nfl jerseys of the added adventuresome women to wear.

管脚排列(extracted from datasheet):

ORG接地,为8位模式。

写操作时DO做检测位,输入完成后变低,写入完成后变高。平时高阻,所以应加上拉电阻(或用51管脚内的)。在检测到DO变高后CS需要复位以开始下一次操作。

SK上升沿读取数据。

指令集(extracted from datasheet)

C51编程:

文件头

//串行存储芯片声明开始----------------
//定义三线制Microware串行总线管脚 Three-wire Serial Interface TSI
sbit CS=P3^2;
sbit SK=P3^3;
sbit DI=P3^4;
sbit DO=P3^5;

//定义指令
#define IS93c86 0 //如果为93c86,置1
#if IS93c86 //6位,用于93c86,最高位地址加在最后3位
#define TSI_READ 0x30
#define TSI_EWEN 0x27
#define TSI_EWDS 0x20
#define TSI_WRITE 0x28
#else //4位,用于93c66,最高位地址加在最后1位
#define TSI_READ 0x0C
#define TSI_EWEN 0x09
#define TSI_EWDS 0x08
#define TSI_WRITE 0x0A
#endif

//定义数据类型(三线串行通信指针)
union intbyte{
unsigned char c[2];
unsigned short int i;
};

//函数声明
void tsiwrite(unsigned short int address,unsigned char value);
unsigned char tsiread(unsigned short int address);
void tsien(unsigned char en);
void tsisendcmd(unsigned char cmd);
void tsisendbyte(unsigned char value);
unsigned char tsireadbyte();

//存储位置指针变量
unsigned short int tsiptr;

//串行存储芯片声明结束----------------

 

主程序


//存储芯片初始化开始---------------
tsien(1);
//存储芯片初始化结束---------------

调用

......
tsiptr=200;
for(i=0;i<8;i++){
while(flag_uart_busy){
;}
flag_uart_busy=1;
SBUF=tsiread(tsiptr);
tsiptr=tsiptr+1;
.......
tsiptr=200;
for(i=0;i<8;i++){
c=clk[i];
tsiwrite(tsiptr,c);
tsiptr=tsiptr+1;
}
......

子程序

//存储芯片驱动代码开始----------------

/***************************************************
Three-wire Serial Interface TSI
发送四位指令,最后一位是地址最高位
完成后 CS处于置位状态,需要后续的sendbyte或readbyte复位
****************************************************/
void tsisendcmd(unsigned char cmd) {
unsigned char i;
DO=1;
SK=0;
CS=0;
CS=1;
while(!DO){ //检测上次写入是否完成
;
}
CS=0;
CS=1;
#if(IS93c86)
for(i=0;i<6;i++){
SK=0;
if(0x20&cmd) DI=1;
#else
for(i=0;i<4;i++){
SK=0;
if(0x08&cmd) DI=1;
#endif
else DI=0;
SK=1;
cmd<<=1;
}
SK=0;
}

/***************************************************
Three-wire Serial Interface TSI
发送1个字节
完成后 CS处于置位状态,
****************************************************/
void tsisendbyte(unsigned char value){
unsigned char i;
for(i=0;i<8;i++){
SK=0;
if(0x80&value) DI=1;
else DI=0;
SK=1;
value<<=1;
}
SK=0;
DI=0;
}

/***************************************************
Three-wire Serial Interface TSI
读1个字节
完成后 CS处于置位状态,
****************************************************/
unsigned char tsireadbyte(){
unsigned char i,res=0;
SK=0;
for(i=0;i<8;i++){
SK=1;
res*=2;
if (DO==1) res++;
SK=0;
}
return res;
}

/***************************************************
Three-wire Serial Interface TSI
允许/禁止tsi
***************************************************/
void tsien(unsigned char en){
DO=1;
if(en){
tsisendcmd(TSI_EWEN);
tsisendbyte(0xFF);
}
else{
tsisendcmd(TSI_EWDS);
tsisendbyte(0);
}
CS=0;
}

/***************************************************
Three-wire Serial Interface TSI
在地址address处写入value
***************************************************/
void tsiwrite(unsigned short int address,unsigned char value){
union intbyte add;
add.i=address;
#if(IS93c86)
add.c[0]&=0x07;//高字节在前
#else
add.c[0]&=0x01;//高字节在前
#endif
tsisendcmd(TSI_WRITE+add.c[0]);
tsisendbyte(add.c[1]);
tsisendbyte(value);
CS=0;
}

/***************************************************
Three-wire Serial Interface TSI
从地址address读出一个字节
返回读出值
***************************************************/
unsigned char tsiread(unsigned short int address){
union intbyte add;
unsigned char res;
add.i=address;
#if(IS93c86)
add.c[0]&=0x07;//高字节在前
#else
add.c[0]&=0x01;//高字节在前
#endif
tsisendcmd(TSI_READ+add.c[0]);
tsisendbyte(add.c[1]);
res=tsireadbyte();
CS=0;
return res;
}

//存储芯片驱动代码结束----------------