I can read any memory position, including the Eletronic Signature through an instruction. But my writes appear don't have effect. I also erased all memory using Erase Bulk. So, I just can read 0xFF. I use the same routine for read and write: u8 BPSI_DataSendReceive ( u8 data ) { u8 ret_value; while( BSPI1->CSR2 & BSPI_Rx_FIFO_NOT_EMPTY ) ret_value = BSPI1->RXR; // Clear Rx FIFO // Wait until the Transmit FIFO is empty while( !( BSPI1->CSR2 & BSPI_Tx_FIFO_EMPTY ) ); // Send data to Transmit buffer BSPI1->TXR = (data< // Wait until the Transmit FIFO is empty while( !( BSPI1->CSR2 & BSPI_Tx_FIFO_EMPTY ) ); // Wait until the end of transmission while( !(BSPI1->CSR2 & BSPI_Rx_FIFO_FULL) ); ret_value = (BSPI1->RXR)>>8; // Read the received data return ret_value; } And SW7 and SW8 are OK! Memory is not hold neither hardware protected against write. That's it! Tks!
Sure! Actually my source is a little different now! But the main reason is that I was verifying the WIP (Write in progress) bit of serial flash in a wrong way. Because I forgot to discard some dummy byte after the Read Status register command. The correct way to verify is:
void Spi_Flash_WaitBusy() { u8 status = (Spi_Flash_ReadStatusRegister() | M25_WIP); while ( (status & M25_WIP) ) status = Spi_Flash_ReadStatusRegister(); } u8 Spi_Flash_ReadStatusRegister() { u8 ret_value; // Select device Spi_Flash_SSN_Low(); // Send instruction to Transmit buffer and receive Status Register Spi_Flash_SendInstruction ( M25_RDSR ); ret_value = Spi_Flash_ReceiveData(); // Deselect device Spi_Flash_SSN_High (); return ret_value; } That's it RISC! Tks!
Can you please give me your source code for using the spi flash...I also am using the spi flash M25P32.Is there any difference??? I would be thankfull to you. Thanks in advance. Sany