2020-10-13 12:18 AM
Hi all,
I'm triybg to send data to a TFT from an external flash memory.
I read than it is possible to comunicate 2 SPI peripherals trough DMA.
I dont understand all the thing yet. Please can someone answer this:
Lets say Flash is in SPI1 and TFT in SPI2
1.-Set a DMA_CMAR with the SPI1_DR.
2.-Set a DMA_CPAR with the SPI2_DR.
3.-Set DMA_CCR PINC & MINC to 0 (disable increment)
4.-Set DMA_CCR MEM2MEM to enable??
5.-Set DMA_CCR EN
Then you send 1 dummy byte to SPI1, and the receiving byte, from SPI1_RX starts the DMA and "resend" to the SPI2_TX. I'm right?
2020-10-13 01:06 AM
Which STM32?
In 'F2/'F4/'F7, you can use only DMA2, so you have to use a stream/channel for SPI1_RX. But you probably don't use these.
Don't use memory-to-memory. Set the source to peripheral side (i.e. SPI1_DR into DMA_CPAR), and then set DMA to Peripheral-to-Memory.
JW
2020-10-13 01:41 AM
Thanks for your answer.
I'm using a STM32F303xC.
2020-10-13 01:45 AM
An important distinction between peripheral-to-memory/memory-to-peripheral and memory-to-memory transfers is that it is the peripheral that tells the DMA when it is ready to transfer.
Memory-to-memory transfers take place as fast as memory can be read and written.
But you cannot read data out of a peripheral faster/slower than it is arriving at that peripheral, and expect what you read to make sense.
If you can ensure that one of your SPIs is no faster than the other, then you could tell the DMA that is the peripheral and have that SPI control the transfer-rate.
Also you'd have to configure the FLASH SPI to be a SIMPLEX RECEIVER so it does not wait for you to send bytes for it to receive.
Hope this helps,
Danish