上传者: hyuming2002
|
上传时间: 2021-09-13 11:18:57
|
文件大小: 2KB
|
文件类型: TXT
FM25L16铁电存储器与F020读写
unsigned char SpiReadWrite(unsigned char c)
{
SPIF = 0;
SPI0DAT = c;
while (SPIF == 0);
return SPI0DAT;
}
/*
unsigned char FMRead(unsigned int addr)
{
unsigned char b;
fm0();
_nop_();
_nop_();
_nop_();
_nop_();
SpiReadWrite(EE_READ);
SpiReadWrite(addr >> 8);
SpiReadWrite(addr & 0xff);
b = SpiReadWrite(0);
_nop_();
_nop_();
fm1();
_nop_();
_nop_();
return b;
}
void FMWrite(unsigned int addr, unsigned char b)
{
fm0();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
SpiReadWrite(EE_WREN);
_nop_();
_nop_();
_nop_();
fm1();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
fm0();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
SpiReadWrite(EE_WRITE);
SpiReadWrite(addr >> 8);
SpiReadWrite(addr & 0xff);
SpiReadWrite(b);
_nop_();
_nop_();
fm1();
_nop_();
_nop_();
}
*/
void FMReadPage(unsigned int addr, unsigned char * index, unsigned char n)
{
unsigned char i;
fm0();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
SpiReadWrite(EE_READ);
SpiReadWrite(addr >> 8);
SpiReadWrite(addr & 0xff);
for(i=0;i> 8);
SpiReadWrite(addr & 0xff);
for(i=0;i