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.

CC2540 DMA with SPI

Other Parts Discussed in Thread: CC2540

Hello everyone!

I've got doubt with DMA functions. In my project i've some peripherals that are accessed through SPI protocol, such as external memories, other digital accelerometers and gyroscopes, all controlled by SPI. My program reads all sensors one by one in one function, so Is it possible do this function with DMA? ie dma could read other devices through SPI?

Thanks for your help

Martín Romero

  • Hey,

    DMA can be configured in such way where one channel of DMA is responsible for

    transferring a byte of data from memory (i.e internal RAM) to SPI buffer and trigger SPI for transmission.

    Another channel (triggered by the end of transmission) will be responsible for transferring

    incoming data from SPI buffer to internal RAM. Later it can be retrigerred and a cyclic passing of

    data between SPI and internal memory can be achieved. So basically, you'll have to set up two

    arrays, one for transmit and another for receive. once you finished reading all data from the

    sensors, memories etc. you can copy the data from receive array to some other location and

    process it.

    As you probably have noticed, DMA is not a "smart" tool, therefore jobs with varying number

    of data bytes per transaction are hard to maintain with DMA.

    (transaction->accessing to all peripheral devices at least one time per round) 

    So, even if you have a single peripheral like external memory, working with DMA may

    be impossible due to varying length of data transferred per access.

    One more thing, in case you are using BLE, I think that OSAL already uses one of the DMA channels to carry out

    access to NV memory, and may be one more channel is used by the UART. 

  • Hi,

    I am using DMA on channel 0 to receive continous data with a CC2540 slave . But I have a weird issue. The DMA channel rearms properly if I call HAL_DMA_ARM (HAL_DMA_CH_RX1) in any regular function, but it doesn't work if I call it in the DMA  ISR (below). In this case, I get one DMA interrupt only, the channel never seems to rearm. Any idea of what might be going on?

    HAL_ISR_FUNCTION(spiPort0Isr, DMA_VECTOR)
    {
               DMAIF = 0;
              if ( HAL_DMA_CHECK_IRQ( HAL_DMA_CH_RX1 ) )
              {
                         HAL_DMA_CLEAR_IRQ(HAL_DMA_CH_RX1);
                         done1 =1;
               }
              if (!HAL_DMA_CH_ARMED(HAL_DMA_CH_RX1))
                         HAL_DMA_ARM_CH(HAL_DMA_CH_RX1);
              while (!HAL_DMA_CH_ARMED(HAL_DMA_CH_RX1));

     }