cancel
Showing results for 
Search instead for 
Did you mean: 

ADCy_AWDx_OUT signal do not work correct for single regular channel, when more channels are sampled in regular sequence. ADC5 AWD1 of STM32G474 .

MMatj.1
Associate II

 Hello ST community,

I use ADC5 of STM32G474 for sampling 2 internal channels in regular sequence, VOPAMP4 and 5 and store data over DMA.

I use ADC5 AWD1 configured for single regular channel VOPAMP5 (tried change to VOPAMP4).

I use ADC5_AWD1_OUT as HRTIM capture trigger reacting on rising edge .

Awaiting behavior to capture time when ADC VOPAMP5 captured signal got out of watchdog window.

Problem is that ADC5_AWD1_OUT go low when ADC finish conversion of another channel (wrong behavior), like AWD1 is configured for all regular channels, but it's configured for single regular channel.

When ADC sampling same channel regularly or same channel in regular sequence, then ADC5_AWD1_OUT stay high for as long as signal is out of watchdog window (correct behavior).

I do check ADC SFR registers in debug mode, all looks correct.

Here will be ADC generated initialization code :

/* ADC5 init function */
void MX_ADC5_Init(void)
{
  ADC_AnalogWDGConfTypeDef AnalogWDGConfig = {0};
  ADC_ChannelConfTypeDef sConfig = {0};
 
  /** Common config 
  */
  hadc5.Instance = ADC5;
  hadc5.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
  hadc5.Init.Resolution = ADC_RESOLUTION_12B;
  hadc5.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc5.Init.GainCompensation = 0;
  hadc5.Init.ScanConvMode = ADC_SCAN_ENABLE;
  hadc5.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc5.Init.LowPowerAutoWait = DISABLE;
  hadc5.Init.ContinuousConvMode = DISABLE;
  hadc5.Init.NbrOfConversion = 2;
  hadc5.Init.DiscontinuousConvMode = DISABLE;
  hadc5.Init.ExternalTrigConv = ADC_EXTERNALTRIG_HRTIM_TRG1;
  hadc5.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
  hadc5.Init.DMAContinuousRequests = ENABLE;
  hadc5.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  hadc5.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc5) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Analog WatchDog 1 
  */
  AnalogWDGConfig.WatchdogNumber = ADC_ANALOGWATCHDOG_1;
  AnalogWDGConfig.WatchdogMode = ADC_ANALOGWATCHDOG_SINGLE_REG;
  AnalogWDGConfig.Channel = ADC_CHANNEL_VOPAMP5;
  AnalogWDGConfig.ITMode = ENABLE;
  AnalogWDGConfig.HighThreshold = HIGH_THRESHOLD;
  AnalogWDGConfig.LowThreshold = LOW_THRESHOLD;
  AnalogWDGConfig.FilteringConfig = ADC_AWD_FILTERING_NONE;
  if (HAL_ADC_AnalogWDGConfig(&hadc5, &AnalogWDGConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Regular Channel 
  */
  sConfig.Channel = ADC_CHANNEL_VOPAMP4;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
  sConfig.SingleDiff = ADC_SINGLE_ENDED;
  sConfig.OffsetNumber = ADC_OFFSET_NONE;
  sConfig.Offset = 0;
  if (HAL_ADC_ConfigChannel(&hadc5, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Regular Channel 
  */
  sConfig.Channel = ADC_CHANNEL_VOPAMP5;
  sConfig.Rank = ADC_REGULAR_RANK_2;
  if (HAL_ADC_ConfigChannel(&hadc5, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
 
}

Best regards,

Maksims M.

1 REPLY 1
MMatj.1
Associate II

Visualized problem description:

0690X00000DAWoyQAH.png

Image from :

en.DM00355726.pdf

RM0440

Reference manual

STM32G4 Series

32-bit MCUs

Rev 2 , October 2019