Ваши комментарии нечитаемы, а зачем 3 раза нули посылаете после чтения ID?
Загляните в тему что вверху форума прикреплена
http://electronix.ru/forum/index.php?showtopic=10934 там этих библиотек для датафлеши как собак...
У меня такие функции когда то работали прекрасно
Код
/*****************************************************************************
*
* Function name : DF_SPI_RW
*
* Returns : Byte read from SPI data register (any value)
*
* Parameters : Byte to be written to SPI data register (any value)
*
* Purpose : Read and writes one byte from/to SPI master
*
******************************************************************************/
unsigned char DF_SPI_RW (unsigned char output)
{
unsigned char input;
SPDR = output; //put byte 'output' in SPI data register
while(!(SPSR & 0x80)); //wait for transfer complete, poll SPIF-flag
input = SPDR; //read value in SPI data reg.
return input; //return the byte clocked in from SPI slave
}
/*****************************************************************************
*
* Function name : Read_DF_status
*
* Returns : One status byte. Consult Dataflash datasheet for further
* decoding info
*
* Parameters : None
*
* Purpose : Status info concerning the Dataflash is busy or not.
* Status info concerning compare between buffer and flash page
* Status info concerning size of actual device
*
******************************************************************************/
unsigned char Read_DF_status (void)
{
unsigned char result, index_copy;
DF_CS_inactive; //make sure to toggle CS signal in order
DF_CS_active; //to reset dataflash command decoder
result = DF_SPI_RW(StatusReg); //send status register read op-code
result = DF_SPI_RW(0x00); //dummy write to get result
index_copy = ((result & 0x38) >> 3); //get the size info from status register
PageBits = DF_pagebits[index_copy]; //get number of internal page address bits from look-up table
return result; //return the read status register value
}