AnsweredAssumed Answered

Flash AT45DB interfaing with KW41z

Question asked by Abhijeet Tippanna on Mar 12, 2019
Latest reply on Mar 14, 2019 by Estephania Martinez

Hiii , 

I am using AT45DB041E flash which are available on FRDM-KW41Z evaluation borad ,

Interfacing of AT45DB041E using SPI communication , using this Read Manufacturer ID and Device ID successfully , but for read data it always read FF or 00

 

 

unsigned char RdFlashByte(unsigned int BuffAddr)
{
unsigned char rddata = 0 ;
unsigned char t1[5]={0};

 

PRINTF("\nRdFlashByte\r\n");

 

while(!FlashReadBusy()); //wait if device is busy

t1[0] = BUFFER_1_READ; //or 0xD1
t1[1] = 0x00;
t1[2] = ((unsigned char)(BuffAddr>>8));
t1[3] = ((unsigned char)(BuffAddr));
t1[4] = 0x00;


isTransferCompleted = false ;

dspi_transfer_t masterXfer;

masterXfer.txData = &t1[0] ;
masterXfer.rxData = NULL ;
masterXfer.dataSize = 5 ;
masterXfer.configFlags = kDSPI_MasterCtar1 | EXAMPLE_DSPI_MASTER_PCS_FOR_TRANSFER | kDSPI_MasterPcsContinuous;

DSPI_MasterTransferNonBlocking(EXAMPLE_DSPI_MASTER_BASEADDR, &g_m_handle, &masterXfer);

/* Wait transfer complete */
while (!isTransferCompleted)
{
}

/* Delay to wait slave is ready */
for (i = 0; i < EXAMPLE_DSPI_DEALY_COUNT; i++)
{
__NOP();
}


isTransferCompleted = false ;

masterXfer.txData = NULL ;
masterXfer.rxData = &rddata ;
masterXfer.dataSize = 1 ;
masterXfer.configFlags = kDSPI_MasterCtar1 | EXAMPLE_DSPI_MASTER_PCS_FOR_TRANSFER | kDSPI_MasterActiveAfterTransfer;

DSPI_MasterTransferNonBlocking(EXAMPLE_DSPI_MASTER_BASEADDR, &g_m_handle, &masterXfer);

/* Wait transfer complete */
while (!isTransferCompleted)
{
}

/* Delay to wait slave is ready */
for (i = 0; i < EXAMPLE_DSPI_DEALY_COUNT; i++)
{
__NOP();
}

PRINTF("\n Rx data :%d \r\n,",rddata);

return rddata;

} //End of RdFlashByte Function

 

please give some idea.

Outcomes