cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Multichannel - DMA on STM32U545

Marc3
Associate

Good afternoon, 

I have some questions for reading multiple channels of the ADC in continuous mode and map the results in the DMA.

I have been able to monitor the voltage coming from a potentiometer and map it into the DMA and i can see the values in the "Live expression window". For doing so i have had to creater an ADCQueue and an ADCNode for the channel I am monitoring. 

Now, the problem arises when i try to monitor multiple channels. Do i have to create as many Queues and Nodes as channels i have? Do i have to create as many buffers as channels i have and therefore all the links? 

Find attached the part of the code where I declare the buffers: 

/* USER CODE BEGIN 0 */



#define ADC_CONVERTED_DATA_BUFFER_SIZE ((uint32_t) 32)



uint32_t aADCxConvertedData[ADC_CONVERTED_DATA_BUFFER_SIZE];

uint32_t secondVariable[ADC_CONVERTED_DATA_BUFFER_SIZE];



/* USER CODE END 0 */



MX_ADCQueue_Config();

__HAL_LINKDMA(&hadc4, DMA_Handle, handle_GPDMA1_Channel10);



if (HAL_DMAEx_List_LinkQ(&handle_GPDMA1_Channel10, &ADCQueue) != HAL_OK)

{

Error_Handler();

}

if (HAL_ADC_Start_DMA(&hadc4, (uint32_t *)aADCxConvertedData, (ADC_CONVERTED_DATA_BUFFER_SIZE) ) != HAL_OK)

{

Error_Handler();

}
4 REPLIES 4
SofLit
ST Employee

Hello @Marc3 and welcome to the community,

First, please use </> button to paste your code. See this link. I've edited your post then.

Second, did you solved your issue in this thread?

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.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.

Hi, 

 

Thank you for your answer. 

 

No, i have not solved the issue in my past thread. 

 

I am currently trying to read with the ADC4 peripheral 5 channels to monitor voltages comming from 5 potientiometers. The idea is to trigger the ADC4 with a TIM and read the ADC values in the DMA.

After posting the first thread you mentioned i thought it would be better to go step by step to try to read first the values from the 5 channels from the DMA and then trigger the ADC with the timer, thats why there are 2 posts ...

 

Marc

Did you configure ADC in Scan mode?

 

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.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.

Hello, 

 

I will try to give you as much info as possible.

 

Following the example of the ADC DMA Transfer provided in the U575...

 

In CONFIGURATION section of ADC4:

- ADC4 clock prescaler is set to divided by 4.

- Scan conversion Mode is enabled (automatically set when nº of conversions is increased).

- Continuous conversion mode is enabled since at this time im not triggering the ADC with a timer.

DMA Continuous requests is enabled.

- Sampling time Common 1 & 2 is set to 79.5 Cycles.

- Rank 1 channel is Channel 4 and Rank 2 channel is Channel 3.

- ADC4 global interrupt in the NVIC Settings is not enabled.

 

In MODE section of ADC4:

- IN3 is ennabled.

- IN4 is enabled.

 

In MODE section of GPDMA1:

Channel 10 - 2 Words Internal FIFO is in Linked-List Mode.

Channel 3 - 2 Words Internal FIFO is in Linked-List Mode.

 

In CONFIGURATION section of GPDMA1 both channels:

- Priority is set to low.

- Execution Mode is set to circular

- Linked list Execution Mode is set to fully executed

- Port for Transfer is set to Port 1

 

Now, I have to configure the Linkedlist. In the example provided an ADCQueue is created and an ADCNode as well. The settings are set just as in the example. 

 

My questions are: In the scenario where i have to use multiple channels, do i have to use multiple Queue and multiple nodes in the linked section? In the code, in the case the previous question is affirmative, do i have to declare multiple buffers and link the diverse channels to the GPDMA1 channel ... 

 

How are this situations usually handled? 

 

Thank you, 

 

In the case something is not clear enough please say so 

 

Marc