K82 : qspi_polling example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

K82 : qspi_polling example

跳至解决方案
1,762 次查看
EugeneHiihtaja
Senior Contributor I

Hello !

I would like to write data to NOT type of memory in small chunks 4-16 bytes long.

I'm looking example qspi_polling in latest SDK and can see the next implementation of function for write complete page :

/* Program page into serial flash using QSPI polling way */
void program_page(uint32_t dest_addr, uint32_t *src_addr)
{
.....

/* First write some data into TXFIFO to prevent from underrun */
QSPI_WriteBlocking(EXAMPLE_QSPI, src_addr, FSL_FEATURE_QSPI_TXFIFO_DEPTH * 4);  // 64 bytes ?
src_addr += FSL_FEATURE_QSPI_TXFIFO_DEPTH;

/* Start the program */
QSPI_SetIPCommandSize(EXAMPLE_QSPI, FLASH_PAGE_SIZE);
QSPI_ExecuteIPCommand(EXAMPLE_QSPI, 16U);

leftLongWords = FLASH_PAGE_SIZE - 16 * sizeof(uint32_t);


QSPI_WriteBlocking(EXAMPLE_QSPI, src_addr, leftLongWords);

....
}

What it means on practice ?

Can it be so than usage of QSPI features limits minimal data chunk to 64 bytes  ( 32 bytes ) ?

And if I would like to write data by small chunks, I should use just SPI driver and NOR  memory driver ?

It looks like for me that usage of QSPI and EDMA bring limitations for size of data chunks and for my case

it is little bit problematic to use those.

How long can be minimal data chunk in case of QSPI and EDMA usage ?

I can use minimal possible buffer and fill extra bytes with 0xFF for avoid writing. Some data alignment can be kept as well.

Regards,

Eugene

0 项奖励
回复
1 解答
1,619 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi Eugene,

Yes, I think it's fine.

Regards,

Jing

在原帖中查看解决方案

5 回复数
1,617 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi Eugene,

You can write to QSPI flash in any size. Attachment shows how to write in word or byte.

Regards,

Jing

0 项奖励
回复
1,617 次查看
EugeneHiihtaja
Senior Contributor I

Hi Jing !

could you post attachment again. It is not visible.

Thank you !

Eugene

0 项奖励
回复
1,617 次查看
jingpan
NXP TechSupport
NXP TechSupport

Ok, I try again.

0 项奖励
回复
1,617 次查看
EugeneHiihtaja
Senior Contributor I

Hi Jing !

I have review one more time our requirement and find out that we can write data by 32 bytes aligned chunks only.

So what ever we write it always 32*n byte long and it help to cross page boundary.

For fullfll this requirement I follow your example and common sense and modify LUT table and create write 32 byte routine.

Could you look code below. How it is looks like ?

/* Seq4: Data Program */
/* CMD: 0x02 - Page Program, Single pad */
/* ADDR: 0x18 - 24bit address, Single pad */
[16] = QSPI_LUT_SEQ(QSPI_CMD, QSPI_PAD_1, 0x02, QSPI_ADDR, QSPI_PAD_1, 0x18),
[17] = QSPI_LUT_SEQ(QSPI_WRITE, QSPI_PAD_1, 32, 0, 0, 0),  // 32 bytes only

/* Program 32byte into serial flash using QSPI polling way */
void program_data_32(uint32_t dest_addr, uint32_t *src_addr, size_t size) // size = 32 bytes always
{
   assert(!(dest_addr % 32));
   assert(!(size % 32));

   while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & kQSPI_Busy)
   {
   }
   QSPI_ClearFifo(EXAMPLE_QSPI, kQSPI_TxFifo);

   QSPI_SetIPCommandAddress(EXAMPLE_QSPI, dest_addr);
   cmd_write_enable();
   while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & kQSPI_Busy)
   {
   }

   /* Put data to fifo */
   QSPI_WriteBlocking(EXAMPLE_QSPI, src_addr, size); // 32

   /* Start the program */
   QSPI_SetIPCommandSize(EXAMPLE_QSPI, size);
   QSPI_ExecuteIPCommand(EXAMPLE_QSPI, 16U);

   /* Wait until flash finished program */
   check_if_finished();
   while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & (kQSPI_Busy | kQSPI_IPAccess))
   {
   }
}

Thank you !

Regards,

Eugene

0 项奖励
回复
1,620 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi Eugene,

Yes, I think it's fine.

Regards,

Jing