How do I use HAL_SPI_Receive_DMA in conjunction with a receive buffer on the stack and caching enabled?
I am working with the STM32F760I-EVAL board and caching (SCB_EnableICache() and SCB_EnableDCache() are called) and MPU (MPU_Config() is called) are enabled. I am using DMA with SPI and if I transmit data, HAL_SPI_Transmit_DMA, I need to call SCB_CleanDCache() to see any MOSI-data on the oscilloscope. What if want to receive data using HAL_SPI_TransmitReceive_DMA, what function do I need to call and at what point? I tried calling SCB_InvalidateDCache() when my receive is finished, but I then got stuck in an infinite loop inside SCB_InvalidateDCache():
do {
ways = (uint32_t)(CCSIDR_WAYS(ccsidr));
do {
SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) |
((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) );
#if defined ( __CC_ARM )
__schedule_barrier();
#endif
} while (ways--);
I'm aware that I could use fixed buffers allocated within TCMRAM to avoid the caching problems, but I would like to use buffers on the stack for the SPI and I don't see how I can make my stack buffers appear in TCMRAM. Can someone please help me?
