Skip to main content
Tim Michals
Associate II
July 31, 2017
Solved

HAL_SPI_TransmitReceive_DMA (STM32_FW_V1.7.0)

  • July 31, 2017
  • 2 replies
  • 976 views
Posted on July 31, 2017 at 22:35

In STM32Cube_FW_F7_V1.7.0/Projects/STM32746G-Discovery/Examples/SPI/SPI_FullDuplex_ComDMA example shows a simple DMA transfer with data cache on. 

How can aRxBuffer buffer can be updated correctly without a region defined non-cacheable?

    This topic has been closed for replies.
    Best answer by David Littell
    Posted on August 01, 2017 at 14:28

    Allocate your receive buffers such that they're on a cache line boundary and extend an integral number of cache lines.  In the DMA completion call SCB_InvalidateDCache_by_Addr() before expecting the data to be valid.

    2 replies

    David Littell
    David LittellBest answer
    Senior II
    August 1, 2017
    Posted on August 01, 2017 at 14:28

    Allocate your receive buffers such that they're on a cache line boundary and extend an integral number of cache lines.  In the DMA completion call SCB_InvalidateDCache_by_Addr() before expecting the data to be valid.

    Tim Michals
    Associate II
    August 1, 2017
    Posted on August 01, 2017 at 15:07

    After looking at the code more, the reason why this works once is aRxBuffer is not in the data cache since it has not been read.  I would hope the examples for the F7/H7 would be updated to reflect cache issues, not just 'lucky' code,

    David Littell
    Senior II
    August 1, 2017
    Posted on August 01, 2017 at 17:47

    Well, hope but don't count on it.  Treat all example code as just that: a very specific, narrow example.  Once you incorporate any example code you own it...and its 'luck'.  ;)