cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 : ADC DMA Multichannels only read rank1

HugoSTM32
Associate II

Hi,

Im new to STM and trying to use 1 adc with DMA with 2 input and reading value.

Board :
STM32H753XI  EVAL

ADC 1 :
INP0 rank 1
INP1 rank 2

Functions : 

void adc_dma_multi(void)

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

 

Results :

HugoSTM32_0-1762428785275.png

I tried to swap rank between INP0 and INP1 to check if my second entry was read correctly and there were no hardware problems, and the result is the same: rank1 is read correctly but rank2 = 0.

 

I have attached main.c and IOC.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Khaled_DHIF
ST Employee

Hello @HugoSTM32 , 

Welcome to ST's community! 

To resolve the issue where the second ADC channel consistently reads zero, please use a buffer of type uint16_t for the ADC DMA data, as recommended by @TDK . This type ensures proper data size and will naturally be aligned to a 4-byte boundary, which is important for reliable DMA operation on STM32H7 devices.

Additionally, verify that the GPIO pins corresponding to ADC_CHANNEL_0 and ADC_CHANNEL_1 are correctly configured in analog mode with no pull-up or pull-down resistors, for example:

GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1; //PA0 and PA1 as an example
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
For more guidance on configuring the ADC on STM32H7 devices, please refer to the application note AN5354.
We look forward to hearing about your progress and are here to assist you further if needed.
 
Kind regards, 
DHIF Khaled
Please mark my answer as best by clicking on the “Accept as solution" button if it fully answered your question. This will help other users find this solution faster.​

View solution in original post

2 REPLIES 2
TDK
Super User

adc_buffer should be an array of uint16_t, not uint32_t.

 

Not the main issue here, but adc_buffer needs to be cache-aligned, otherwise SCB_InvalidateDCache_by_Addr will clobber other variables as well.

If you feel a post has answered your question, please click "Accept as Solution".
Khaled_DHIF
ST Employee

Hello @HugoSTM32 , 

Welcome to ST's community! 

To resolve the issue where the second ADC channel consistently reads zero, please use a buffer of type uint16_t for the ADC DMA data, as recommended by @TDK . This type ensures proper data size and will naturally be aligned to a 4-byte boundary, which is important for reliable DMA operation on STM32H7 devices.

Additionally, verify that the GPIO pins corresponding to ADC_CHANNEL_0 and ADC_CHANNEL_1 are correctly configured in analog mode with no pull-up or pull-down resistors, for example:

GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1; //PA0 and PA1 as an example
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
For more guidance on configuring the ADC on STM32H7 devices, please refer to the application note AN5354.
We look forward to hearing about your progress and are here to assist you further if needed.
 
Kind regards, 
DHIF Khaled
Please mark my answer as best by clicking on the “Accept as solution" button if it fully answered your question. This will help other users find this solution faster.​