cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H753 ADC with DMA

HugoSTM32
Associate

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

2 REPLIES 2
AScha.3
Super User

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".

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