2018-04-17 09:43 PM
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:
My clock settings
My SPI settings
My Hardware:
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!
2018-04-18 04:42 AM
Hi,
I found what's wrong. Bad idea use timer with 1MHz interrupt frequency.
Thank you!
2018-04-18 05:02 AM
Why is the question now assumed to be answered ... ?
I would check what the LL code does, i.e. what flags it actually checks.
At least the Cube code is notorious for it's generous use of busy-wait loops.
I did no project with either (Cube or LL lib) of them, for that and other reasons.
2018-04-18 05:32 AM
Prescaler seems high.
Initial communications can be at 400 KHz but once card is up you could presumably clock at 25 or 50 MHz, but SPI is going to be relatively slow compared to 4-bit SDR/DDR modes.
>>I see 55Mbps
What does this mean?
You have an SDIO/SDMMC clock of 55 MHz? At 4-bit that would be 220 Mbps (27.5 MBps)
2018-04-18 07:45 AM
No, SPI for transfer data over RF module not for SD card.
I use example SD card project for STM32L476-EVAL for write data to a microSD card. I can write 100MB file by 15 seconds. SD data transfer around 55Mbps. SDIO clock was 24MHz.2018-04-18 07:46 AM
My post premoderated. I already found what happens and mark as solved.