This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294NCPDT: spi flash issue

Part Number: TM4C1294NCPDT


arm: TM4C1294NCPDT

sp flash: N25Q128

follow the spi_Flash.c

1. SPIFlashSectorErase ,

2. SPIFlashFastRead

code:

for(i=0;i<4096;i++)

SPIFlashSectorErase(i*4096);

for(i=0;i<4096;i++)

{

  SPIFlashFastRead(i*4096,buff,4096);

  for(j=0;j>4096;j++)

   if(buff[j]!=0xff)

      break;

}

i found the i=128,then the buff[j] is not equal 0xff,

i donot know the reason ,would you please give some suggestions?

 

  

  • Hi,

      The SPIFlashFasRead() API takes 4 arguments but your code is missing the ui32Base.  

  • sorry for mistake.

    my code including the ui32Base.

    SSI1_BASE
    CFG AS FOLLOWS:
    1. MAP_SSIConfigSetExpClk(SSI1_BASE,120000000,SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER,10000000,8);

    ---------------------------------------------------------------------------------------------------------------------------------------------------------

    code:

    for(i=0;i<4096;i++)

    SPIFlashSectorErase(SSI1_BASE,i*4096);

    for(i=0;i<4096;i++)

    {

    SPIFlashFastRead(SSI1_BASE,i*4096,buff,4096);

    for(j=0;j>4096;j++)

    if(buff[j]!=0xff)

    break;

    }

    i found the i=128,then the buff[j] is not equal 0xff,

    i donot know the reason ,would you please give some suggestions?

  • Hi,
    So when i=128, what did you read from the buff? Is the entire buff not equal to 0xff or only partial. When you do SPIFlashSectorErase(), you must also call SPIFlashReadStatus() to query the SPI flash to determine when the sector erase operation has completed.
  • thanks.

    sector 128 ,whole buf  are not equal oxff.

    when i use SPIFlashSectorErase,:

    1) enablewrite

    2) sector erase.

    3) poll the status.

    the result show the status is correct.

  • Hi,

    Are you doing something like below to wait for the current sector erase completion before starting the next sector erase?

    for(i=0;i<4096;i++)
    {

    SPIFlashSectorErase(SSI1_BASE,i*4096);

    while ((SPIFlashReadStatus() & 0x01) == 0x01); // wait until the current sector operation is complete

    }

    Also which SPI flash are you using? What is the sector size and how large is the flash?
  • thanks , the same to you.

    n25q128

    subsector : 4096byte

    flash size: 16MByte.

  • Hi,
    Since you said the problem is when i is equal to 128, can you try some experiment?

    Instead of looping from i=0 to 4096 , can you just read one sector which is the sector 128 only. Can you try the below sequence?

    1. Erase sector for only sector 128
    2. Wait until the sector erase is complete by polling the status
    3. Read from sector 128. While reading, please use the scope to observe what is the returned data. You might want to read just one byte instead of the 4096 bytes for easier debugging.

    You mentioned that for i=0 to 127 it is working. If this is the case, can you also repeat the above sequence but for sector 127. You can then compare the scope captures between sector 127 and 128 to see what is the difference.
  • Hi,
    Is this issue resolved?
  • Hi,
    I have not heard back from you. I will close this thread for now. If you have new questions you can create a new thread.