I'm using an ADSP-SC573.
What is the proper way to flush the memory cache when using SPI DMA (in ARM core)?
I have a txBuffer[] array that contains the data I want to send on the SPI. And I have an rxBuffer[] array that will collect all received data from SPI.
I have setup the SPI and DMA using register level coding.
The problem I have is that the rxBuffer[] only gets updated once. I suspect it is a cache problem.
Is this the proper way?
- Update txBuffer[] with new data to be sent on SPI
- Call flush_data_buffer() så DMA will read the new data from txBuffer[]
- Setup SPI as master transmitter/receiver and DMA to send txBuffer[] and receive data to rxBuffer[]
- Call flush_data_buffer() so CPU can see the new data in rxBuffer.
It didn't work, rxBuffer[] is only updated once I suspect I must call flush_data_buffer() with another argument. I will try it tomorrow.
Any tips?
**Update**
I got Rx and Tx to work today by doing this:
- Update txBuffer[] with new data to be sent on SPI
- Call flush_data_buffer((void *)pFlushStartaddr, (void *)pFlushEndaddr, ADI_FLUSH_DATA_NOINV) så DMA will read the new data from txBuffer[]
- Setup SPI as master transmitter/receiver and DMA to send txBuffer[] and receive data to rxBuffer[]
- Call flush_data_buffer(*pREG_DMA27_ADDRSTART, (void *)((uint32_t)*pREG_DMA27_ADDR_CUR - 1), ADI_FLUSH_DATA_INV); so CPU can see the new data in rxBuffer.
So before sending data i called flush_data_buffer() with ADI_FLUSH_DATA_NOINV. And after receiving the SPI data I called flush_data_buffer() with ADI_FLUSH_DATA_INV.
What is the technical difference between ADI_FLUSH_DATA_NOINV and ADI_FLUSH_DATA_INV?
And is this the correct way to do this?
Added more information.
[edited by: masip at 7:47 AM (GMT -4) on 9 Sep 2022]