使用SPI接口的FLASH时,MCU的SPI接口设置有什么特别的吗?我现在使用ATMEL的FLASH AT45DB041B,读状态寄存器时是对的:0X9C,但是如果进行PAGE PROGRAM或PAGE READ等操作后,读状态寄存器返回:0XFF,再读一次又是0X9C了。根据说明,状态寄存器里有些固定位,它的值不可能是全1。怎么回事?
读状态寄存器的程序如下:
uchar readflashstatus()
{
uchar mid;
//initial a transaction
csd=0;//FLASH 的CS#
SPSR=0x00;
//send the instruction to read the status of flash
SPDR=0xd7; //send the opcode,denote the instuction of "STATUS REGISTER READ"
//wait for SPI receive data
while(!(SPSR&0x80));
SPSR=0x00;
SPDR=0x00;
while(!(SPSR&0x80));
mid=SPDR;
SPSR=0x00;
csd=1;
return mid;
}