1 / 6
文档名称:

AT45DB041存储芯片读写程序,适用于51单片机.doc

格式:doc   页数:6
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

AT45DB041存储芯片读写程序,适用于51单片机.doc

上传人:策划大师 2011/12/29 文件大小:0 KB

下载得到文件列表

AT45DB041存储芯片读写程序,适用于51单片机.doc

文档介绍

文档介绍:/******************************************************************************
这个程序原本是从论坛上下载的,但是用到51单片机中不能使用,只能一次写一个字节,
经过高手的修改,已经能够用在51中。

******************************************************************************/
/******************************************************************************/
/*~,(正常*/
/*的状态字节值为9D),并且读写数据均不准确,所以应当保证卡片的供电电压不超过*/
/*。*/
/*SPI规范:Data is always clocked into the device on the rising edge of SCK a-*/
/* nd clocked out of the device on the falling edge of instruction-*/
/* s,addresses and data are transferred with the most significant bit(MSB) */
/* first. */
/* 2005-06-02*/
/******************************************************************************/
#include <>
#include <>
#include <>
#include <>
#define UCHAR unsigned char
#define UINT unsigned int
//===================
sfr P4 = 0xe8;
//===================
sbit SPI_CS = P4^1;
sbit SPI_SCK = P4^0;
sbit SPI_SO = P4^3;
sbit SPI_SI = P4^2;
unsigned char aaa;
void dyms20(void)
{unsigned char i;
for(i=0;i<30;i++) i++;
}
unsigned char SPI_HostReadByte(void)
{
unsigned char i,rByte=0;
for(i=0;i<8;i++)
{
SPI_SCK=0;
dyms20();
SPI_SCK=1;
rByte<<=1;
if(SPI_SO) rByte |= 0x01;
else rByte &= ~0x01;
}
return rByte;
}
void SPI_Host