K82: QSPI writing to flash memory small chunks

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

K82: QSPI writing to flash memory small chunks

848 Views
EugeneHiihtaja
Senior Contributor I

Hello !

I have taken qspi_edma transfer example for FRDMK82 board from latest SDK and it work fine.

By default it write PAGE_SIZE data chunks to flash memory but I need smaller once.

I have modified  function program_page for support smaller chunks of data :

/* Program data into serial flash using QSPI polling way */
void program_page(uint32_t dest_addr, uint32_t *src_addr, size_t size)
{
qspi_transfer_t xfer = {0};

xfer.data = (uint32_t *)src_addr;
xfer.dataSize = size; //FLASH_PAGE_SIZE; //
while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & kQSPI_Busy)
{
}

QSPI_ClearFifo(EXAMPLE_QSPI, kQSPI_TxFifo);
QSPI_SetIPCommandAddress(EXAMPLE_QSPI, dest_addr);
QSPI_SetIPCommandSize(EXAMPLE_QSPI, size /*FLASH_PAGE_SIZE*/); //
cmd_write_enable();

.....

and it work fine with 32 byte chunks ( and bigger once ).

But not with 16 bytes long.

What can be problem ?

Can it be some QSPI Fifo size limitations or someting else ?

I think used NOR flash memory ( MX25U3235F ) supports writes from 1 byte up to page size long.

I should be able to fill sector by using 4,8 and 16 byte long chunks.

Could you advice what is QSPI controller limitations for read/write operations ?

Regards,

Eugene

0 Kudos
Reply
3 Replies

769 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Eugene,

This is because the demo code default set the QSPI TX buffer watermark to 8. That means 32 bytes. When EDMA_PrepareTransfer() check it's parameter, it will found that bytesEachRequest big than transferBytes. Then it will hold the code or report error.

If you want DMA to send 16 byte each time, you should set config->txWatermark=4.

If you want DMA to send 8 byte each time, you should set config->txWatermark=1.

Regards,

Jing

0 Kudos
Reply

769 Views
EugeneHiihtaja
Senior Contributor I

Hi Jing !

Does it mean if DMA in use, minimal data chunk is 8 byte long ?

And if 4 bytes is need, I can compose hybrid driver where 4 bytes and less is written by polling and 8 byes and up - by DMA ?

Regards,

Eugene

0 Kudos
Reply

769 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

Yes, DMA need 4 byte minimum.

Regards,

Jing

0 Kudos
Reply