cancel
Showing results for 
Search instead for 
Did you mean: 

Multichannel conversion in Interrupt mode STM32G474

JPiet.3
Associate II

Hello,

I wan't to read out a few ADC Channels, timer based in single convertion mode as a sequence. From my perspective, it is correct configured with CubeMX (Ver 1.16.0). But the result is not as expected. From my perspective and when I compare it with the diagram from RM0440 pg. 640, if I have 4 ranks in my ADC configured, I expect in my code below, the variable for EOC is 4 times higher than the EOS conter. 

But both have the same value. I set also an GPIO, when the timer starts the ADC_IT. If conversion is finishedand the GPIO is pulled low, I see even two pulses, one from EOS, one from EOC. Can somebody explain, what happen here? My strategy was to count the index at each EOC trigger ad grab the ADC-Values, than reset the counter with EOS. 

My ADC1 configuration from CubeMX, you see below.

Before someone is suggesting, use the DMA, of course, it is working here. But I will do the same on STM32H745, and here the DMA is not working. Because of some reasons, I use the STM32G474 just es test environment.

 

Thanks for help in advance

 

 

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
	static __IO uint16_t cnt_adc1=0, cnt_adc2=0;
	if (hadc->Instance == ADC1)
	{
		ADC_FLAG++;
		if ( __HAL_ADC_GET_FLAG(hadc, ADC_FLAG_EOS))
		{
			  HAL_GPIO_WritePin(ADC_INT_GPIO_Port, ADC_INT_Pin, GPIO_PIN_SET);
			myEOS_FLAG++;
			HAL_GPIO_WritePin(ADC_INT_GPIO_Port, ADC_INT_Pin, GPIO_PIN_RESET);
		}
		if ( __HAL_ADC_GET_FLAG(hadc, ADC_FLAG_EOC))
		{
			HAL_GPIO_WritePin(ADC_INT_GPIO_Port, ADC_INT_Pin, GPIO_PIN_SET);
			myEOC_FLAG++;
			HAL_GPIO_WritePin(ADC_INT_GPIO_Port, ADC_INT_Pin, GPIO_PIN_RESET);
		}
		HAL_GPIO_WritePin(GPIOA, ADC_TEST_Pin, GPIO_PIN_RESET);
}
}

 

 

 

 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc1.Init.GainCompensation = 0;
 hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
 hadc1.Init.LowPowerAutoWait = DISABLE;
 hadc1.Init.ContinuousConvMode = DISABLE;
 hadc1.Init.NbrOfConversion = 4;
 hadc1.Init.DiscontinuousConvMode = DISABLE;
 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc1.Init.DMAContinuousRequests = DISABLE;
 hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
 hadc1.Init.OversamplingMode = DISABLE;

 

  

0 REPLIES 0