This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541: Double Buffering on SPI with DMA

Part Number: CC2541

Hello,

I'm using SPI to communicate with a CC2541 (while receiving packets in proprietary mode).
Using DMA in single mode, I handle incoming SPI "packets" when the DMA interrupt occurs, and then re-arm the channel.
During the time spent handling the packet, the channel is thus not armed - meaning SPI data may be lost.
The obvious solution would be to use single repeat mode, but from what I've read in the PDF - there's no double buffering available for the DMA.
This means I have to switch the destination buffer in the DMA configuration before re-arming.
I've thought about using two DMA channels (both configured with the same SPI RX trigger, but with different buffers) and setting up an interrupt when the CS pin goes active to switch buffers, but this seems a bit cumbersome.
Is there a proper way to do this? Am I missing something?
Thank you.
  • Hi,

    The documentation shows that the Data Buffer register is already double buffered, and coupling that with DMA should be ok - I think the larger problem here is the time handling incoming packets before rearming. (esp if it's longer than 2 SPI RX cycles)

    You could try generating a queue system to hold onto received packets until time is freed up. (If the RX commands are infrequent or periodic). Or create simpler commands/break commands apart to fit into the maximum time to rearm.

    You could try the double buffered DMA, it'd effectively be a third buffer if the Data Buffer is already double buffered.

    Regards,
    Rebel