Who has Blocking Transfer LPSPI demo?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Who has Blocking Transfer LPSPI demo?

1,268 Views
1920844004
Contributor III

Who has  Blocking  Transfer LPSPI demo? now, i use LPSPI  to read and write data from w25q64 (as dataflash),read data is fast,but written data is incorrect ,cannot be written successfully,how can i use LPSPI_MasterTransferBlocking() to complete write task successfully?

following is read function,is OK :

void  W25QXX_Read_Boost(u8* pBuffer,u32 ReadAddr,u32 NumByteToRead)

{

lpspi_transfer_t spi_tranxfer;

 spi_tranxfer.configFlags = kLPSPI_MasterPcs1|kLPSPI_MasterPcsContinuous;

spi_tranxfer.txData   = spitxdata;                 //要发送的数据

spi_tranxfer.rxData   = pBuffer;                 //接收到的数据

spi_tranxfer.dataSize = NumByteToRead;                        //数据长度

 LPSPI_MasterTransferBlocking(LPSPI3,&spi_tranxfer);     //SPI阻塞发送

W25QXX_CS(SET);

}

following is write function (cannot be written successfully) :

void W25QXX_Write_Page(const u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite)

{

lpspi_transfer_t spi_tranxfer;

W25QXX_Write_Enable();    

LPSPI3_ReadWriteByte((u8)WriteAddr);

..

..

spi_tranxfer.configFlags = kLPSPI_MasterPcs1|kLPSPI_MasterPcsContinuous;

spi_tranxfer.txData   = pBuffer;

 spi_tranxfer.rxData   = spirxdata;  

spi_tranxfer.dataSize = NumByteToWrite;

LPSPI_MasterTransferBlocking(LPSPI3,&spi_tranxfer);

W25QXX_CS(SET);

W25QXX_Wait_Busy();

}

Anyone with similar experience, or driver code, please give me some guidance. Thank you.

Tags (1)
0 Kudos
3 Replies

905 Views
1920844004
Contributor III

In fact, my post doesn't have the full code.Now, I'll publish the code as an attachment,Please check。

if use "u8 LPSPI3_ReadWriteByte(u8 TxData)//LPSPI3 读写一个字节"

Read or Write speed is very slow,

if i directly use LPSPI_MasterTransferBlocking(),such as:

图片1.png

such,reading is fast,but cannot write.

0 Kudos

905 Views
emb01_jtronix
Contributor II

I have same issue but i am facing problem in reading data. Are you able to write data? 

0 Kudos

905 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Zhihui Liu,

    I don't have the directly sample code which use the SDK to communicate with the W25Q64 for your reference.

    But, from your description,  you already make read works, so your hardware connection should don't have problems, then you have write problems, the main problem should still in the software side.  Actually it is easy to check it.

   From the W25Q64 datasheet, we can know this information:

  Before do the page program instruction, you need to write enable instruction at first, then use the following wave to send the data:

pastedImage_1.png

    From your attached code for page write, after the write enable function, you are calling:

LPSPI3_ReadWriteByte((u8)WriteAddr);

   Do you send the 0X02 write instruction at first? Besides, your write addr is u8, but from my above figure, you can find it is the 24 bit address.

   So, the useful method to check your problem is find a logic Analyzer tool to check your page write wave, whether it is meet he W25Q64 demand, then modify the code, actually it is very simple, please try it on your side.

    If you still have question about it, please send me your SPI bus wave for page write.

   On my side, there has some bare metal function for other MCU, you can refer the flow:

//page write
int w25qxx_write_page(uint32_t addr, uint8_t *buf, uint32_t len)
{
    w25qxx_write_enable();

    /* send addr */
    spi_xfer(W25X_PageProgram, W25QXX_CS_LOW);
    spi_xfer((uint8_t)((addr)>>16), W25QXX_CS_LOW);
    spi_xfer((uint8_t)((addr)>>8), W25QXX_CS_LOW);
    spi_xfer((uint8_t)addr, W25QXX_CS_LOW);
    
    w25_dev.ops.xfer(NULL, buf, len, W25QXX_CS_HIGH);
    while(w25_dev.ops.get_reamin() != 0)
    {
        w25_dev.ops.delayms(10);
    }

    
    /* wait busy */
    while((w25qxx_read_sr() & 0x01) == 0x01)
    {
        w25_dev.ops.delayms(1);
    }
    return 0;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

   Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos