Skip to main content
Associate III
November 5, 2025
Solved

STM32H753 ADC with DMA

  • November 5, 2025
  • 2 replies
  • 335 views

Hi,

Im new to STM and trying to use ADC with DMA in circular mode but the value of my ADC remains at 0. I also tested it with Polling, which works.

ICache and DCache : Enable

 

void menu_adc(void)

uint32_t adc_buffer[1];
uint16_t adc0;
uint8_t flag_adc;

 

void menu_adc(void)
{

	 char buf[30];
 	HAL_ADC_Start_DMA(&hadc1, adc_buffer, 1);
	 while(1){

	 	if (flag_adc == 1)
	 	{
	 		flag_adc =0;
				int len = snprintf(buf, sizeof(buf), "ADC0: %u\r\n", adc0);
				HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);
				HAL_Delay(200);
	 	}
	 if (HAL_ADC_PollForConversion(&hadc1, 100) == HAL_OK)
	 {
	 uint32_t adc_value = HAL_ADC_GetValue(&hadc1);
	 int len = snprintf(buf, sizeof(buf), "ADC0: %lu\r\n", adc_value);
	 HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);
	 }

	 }
}

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
 if(hadc->Instance == ADC1)
 {
 adc0 = adc_buffer[0]; // ADC1_INP0
 flag_adc = 1;
 }
}

Results: 

HugoSTM32_0-1762339483269.png

 

I am also attaching the IOC so that you can look at the configuration of the ADC and DMA.

thank you

Best answer by Saket_Om

Hello @HugoSTM32,

Please try to invalidate the DCache in HAL_ADC_ConvCpltCallback and HAL_ADC_ConvHalfCpltCallback like in the example below.

STM32CubeH7/Projects/NUCLEO-H743ZI/Examples/ADC/ADC_DMA_Transfer/Src/main.c at master · STMicroelectronics/STM32CubeH7

2 replies

AScha.3
Super User
November 5, 2025

Hi,

at first try without D-cache, I-cache ON .  And D-cache OFF.

To see if this is just a problem with the D-cache.

"If you feel a post has answered your question, please click ""Accept as Solution""."
HugoSTM32Author
Associate III
November 5, 2025

I disable DCache, that blocked in HAL_ADC_Start_DMA(), it was a problem i found that why i enable ICache and DCache :

HugoSTM32_0-1762348995907.png

I will sent you the whole main.c and its the 

void adc_dma(void) function

 



 

Saket_OmBest answer
Technical Moderator
November 5, 2025

Hello @HugoSTM32,

Please try to invalidate the DCache in HAL_ADC_ConvCpltCallback and HAL_ADC_ConvHalfCpltCallback like in the example below.

STM32CubeH7/Projects/NUCLEO-H743ZI/Examples/ADC/ADC_DMA_Transfer/Src/main.c at master · STMicroelectronics/STM32CubeH7

"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"
HugoSTM32Author
Associate III
November 5, 2025

Ok thank you, that worked, here my new Callback :

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
 if(hadc->Instance == ADC1)
 {
 SCB_InvalidateDCache_by_Addr((uint32_t*)adc_buffer, sizeof(adc_buffer));
 adc0_dma = adc_buffer[0]; // ADC1_INP0
 flag_adc = 1;

 }
 if(hadc->Instance == ADC2)
 {
 	adc0_it = HAL_ADC_GetValue(hadc);
 	flag_adc = 1;
 }
}
void adc_dma(void)
{
 char buf[30];
	HAL_ADC_Start_DMA(&hadc1, adc_buffer, 1);
 while(1){

 	if (flag_adc == 1)
 	{
 		flag_adc =0;
			int len = snprintf(buf, sizeof(buf), "ADC0: %u\r\n", adc0_dma);
			HAL_UART_Transmit(&huart1, (uint8_t*)buf, len, HAL_MAX_DELAY);
 	}
 }
}

Result :

HugoSTM32_0-1762354935596.png

Have a good day