AnsweredAssumed Answered

Slow SPI data transfer B-L475E-IOT01A kit

Question asked by Dmitriy Belimov on Apr 18, 2018
Latest reply on Apr 18, 2018 by Dmitriy Belimov

Hi

 

After looong work with Microchip's PICs we are moving our desing on the fly to STM32L4 series MCU because it has hardware SDIO core. After some tests I see 55Mbps on STM32L476-EVAL with microSD Class 10 and 32KB buffer. It's great. But I need transfer fast data over SPI too. With SPI I see wery sloooow transfer.

 

My Software:

 

  • MXCube 4.25,
  • TrueStudio 9.0

 

My clock settings

MXCube clock settings

 

My SPI settings

 

My Hardware:

 

  • B-L475E-IOT01A kit
  • Salea Logic Analyzer
  • RF module

 

Just for test transfer over SPI I used LL functions with monopoly MCU using. No any other tasks.

 

void _SPI_WriteBlock(const uint8_t* pData, const uint16_t pDataSize)
{
    uint16_t i;
    uint8_t * lc_ptr;

 

    lc_ptr = (uint8_t*)pData;

 

    for (i = 0; i < pDataSize; i++)
    {
        while(!LL_SPI_IsActiveFlag_TXE(RF_SPI));
        LL_SPI_TransmitData8 (RF_SPI, *lc_ptr++);
    }

 

    while(LL_SPI_IsActiveFlag_BSY(RF_SPI));
}

 

 

For write 1024 bytes buffer of data

 

_SPI_CS(true);
_SPI_WriteBlock(_test_buf, 1024);
_SPI_CS(false);

 

All looks good and working. But what I see over Logic Analyzer? It's terrible:

 

For write 1024 bytes need spend 50ms, data rate is 20KB too slow.

Let's looking what happens:

 

 

Period of byte writing is huge, around 51us

 

But for write single byte SPI spended only 2us. Other 49us we waste.

 

I don't understand why and what happens? Write function waiting only TXE flag. The TXE flag will be set when data moved from DR register to internal shifter. Main core works on 80MHz, one tick is around 12ns. Let's we spend 10 ticks for move data to shifter and set TXE flag it's 120ns but not 48us.

 

What happens and how to I can fix it.

 

Thank you!

Outcomes