Hello,
I am trying to use DMA with SPI (Flexcomm0) on LPC550x. I have this current setup:
- set up peripheral -> memory DMA transfer to read 10 bytes from FIFORD
- trigger the transfer
- set up memory -> peripheral DMA transfer to write 10 bytes to FIFOWR
- trigger the transfer
My DMA requests all have PERIPHREQEN enabled and the Flexcomm has DMA enabled for both FIFOs. They use normal 8-bit transfer descriptors without linked descriptors, so just one-off transfers.
When I do this, I get a 0xFF byte at the beginning of my output buffer (read from SPI). I do not see this byte on the wire, so it looks like the DMA channel has tried to read from an empty FIFORD.
However, when I change the order to this, where I trigger the TX DMA first:
- set up memory -> peripheral DMA transfer to write 10 bytes to FIFOWR
- trigger the transfer
- set up peripheral -> memory DMA transfer to read 10 bytes from FIFORD
- trigger the transfer
Then everything works properly and I read 10 correct bytes.
My question: does the DMA controller look at the DMA request line from the peripheral on the first transfer, immediately after triggering the channel, or does it ignore it? Because according to the tests above it looks like the controller will always read FIFORD immediately on triggering the RX channel, even if the FIFO is empty.
I think this is the case because the issue occurring seems to depend on the ratio between the SPI clock and the DMA clock (AHB clock), so it seems that the RX DMA channel is racing the SPI peripheral on the first transfer without looking at the request line.
Thanks!