cancel
Showing results for 
Search instead for 
Did you mean: 

How to do DMA chaining for data transfer with 2 seperate SPI's

Karthick008
Associate II

Hi, I'm using STM32G47 MCU. I'm facing problem in my system, where I have to read data from two SPI_ADC's, one after one. Both are connected in a same SPI bus, with each have separate CS pin connected to MCU. The problem is that, I want to do everything using only by DMA. No cpu intervention or no isr should be used. The steps to be done are,

 

1. make CS1 low, CS2 high.

2. Start reading ADC1 ic, using spi_dma.

3. once the read completed, make the CS1 high, and CS2 low.

4. Now start reading the ADC2 ic. and repeat the process.

 

Here the above steps should happen continuously without any software processing. The data has to be updated in the background in the buffer. The dma has to be chained in such a way that, it happens in a sequence above. I have checked some posts, they suggesting to do using timers, but i don't think it's reliable. So, kindly provide me the best suitable solution available. Thanks in advance. 

3 REPLIES 3
Saket_Om
ST Employee

Hello @Karthick008 

The best solution is to use timer. 


@Karthick008 wrote:

. I have checked some posts, they suggesting to do using timers, but i don't think it's reliable. 


 Why it is not reliable ? 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
Karthick008
Associate II

Yes thanks, but in my case, I want to avoid the timer based triggering of SPI tx. Since, the two ADC ic will send data with different delay, so I want to chain the DMA , based on the completion of one after the another. Also, can you provide how to configure them so that I can use it timer based triggering. Thanks.

Hello @Karthick008 

You can refer to the example below as starting point. 

STM32CubeG0/Projects/NUCLEO-G071RB/Examples/ADC/ADC_SingleConversion_TriggerTimer_DMA at master · STMicroelectronics/STM32CubeG0 · GitHub

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om