cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F217 and analog watch dog

samj
Associate
Posted on November 07, 2016 at 18:40

I use TIM8 for start of conversion  and ADC_EXTERNALTRIGCONV_T8_TRG event for get a value of ADC in recycle mode with analog WDG. analog watchdog. I set both AWDIE and EOCIE. It work fine. An interrupt occurs every time in the end of conversion process. But i do not want it. I want to an interrupt occurred in case when ADC value will be higher or lower some level. If i reset EOCIE an interrupt does  not occure never. AWD does not call an interrupt of ADC. Is it my mistake or it should be? May be there are an example with analog wath dog for HAL?

My config code is bellow.

  ADC_AnalogWDGConfTypeDef AnalogWDGConfig;

  ADC_ChannelConfTypeDef sConfig;

  /* ADC Initialization */

  AdcHandle.Instance          = ADC1; //

  AdcHandle.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;

  AdcHandle.Init.Resolution = ADC_RESOLUTION12b;

  AdcHandle.Init.ScanConvMode = DISABLE;

  AdcHandle.Init.ContinuousConvMode = ENABLE;

  AdcHandle.Init.DiscontinuousConvMode = DISABLE; 

  AdcHandle.Init.NbrOfDiscConversion = 0;

  AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;

  AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T8_TRGO; 

  AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;

  AdcHandle.Init.NbrOfConversion = 1;

  AdcHandle.Init.DMAContinuousRequests = ENABLE;

  AdcHandle.Init.EOCSelection = DISABLE;

  if (HAL_ADC_Init(&AdcHandle) != HAL_OK) 

  {

    /* ADC Initiliazation Error */

    Error_Handler();

  }

/**Configure the analog watchdog 

    */

  AnalogWDGConfig.WatchdogMode = ADC_ANALOGWATCHDOG_SINGLE_REG;

  AnalogWDGConfig.HighThreshold = 1500; //1,19V

  AnalogWDGConfig.LowThreshold = 500; //0,4V

  AnalogWDGConfig.Channel = ADC_CHANNEL_6;

  AnalogWDGConfig.ITMode = ENABLE;

  HAL_ADC_AnalogWDGConfig(&AdcHandle, &AnalogWDGConfig);

  /* Configure ADC1 regular channel */

  sConfig.Channel = ADCx_CHANNEL;

  sConfig.Rank = 1;

  sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;

  sConfig.Offset = 0;

  if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK)

  {

    /* Channel Configuration Error */

    Error_Handler();

  }

#stm32f217-analog-watch-dog
1 REPLY 1
samj
Associate
Posted on November 07, 2016 at 20:14

Sorry Guys, it is my mistake. I has corrected  HAL driver stm32f2xx_hal_adc.c and all work correct now.