Analog window watchdog
Hi Guys,
I have STM32L071 and I want to use analog window watchdog for detecting if voltage on channel 2 is bellow my threshold. I use it and it works really nice.
I use this settings for ADC:
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/ hadc.Instance = ADC1; hadc.Init.OversamplingMode = DISABLE; hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; hadc.Init.Resolution = ADC_RESOLUTION_12B; hadc.Init.SamplingTime = ADC_SAMPLETIME_39CYCLES_5; hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD; hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc.Init.ContinuousConvMode = ENABLE; hadc.Init.DiscontinuousConvMode = DISABLE; hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc.Init.DMAContinuousRequests = ENABLE; hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV; hadc.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; hadc.Init.LowPowerAutoWait = DISABLE; hadc.Init.LowPowerFrequencyMode = DISABLE; hadc.Init.LowPowerAutoPowerOff = DISABLE; if (HAL_ADC_Init(&hadc) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }/**Configure the analog watchdog
*/ AnalogWDGConfig.WatchdogMode = ADC_ANALOGWATCHDOG_SINGLE_REG; AnalogWDGConfig.Channel = ADC_CHANNEL_2; AnalogWDGConfig.ITMode = ENABLE; AnalogWDGConfig.HighThreshold = 4095; AnalogWDGConfig.LowThreshold = 2808; if (HAL_ADC_AnalogWDGConfig(&hadc, &AnalogWDGConfig) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }And whenever the voltage is bellow the level threshold onchannel 2 so interrupt occurs.
But now I want to use also classical measuring on channel 1.
I want to the analog watchdog works still independenty on CPU performance. And in some time I want to read voltage on channel 1. But it does not work with nalog watchdog. How to combine this 2 methods?
#awd #adc #analog-watchdog