I want to make Comparator's output inversely.
Hello, I am using STM32 L031K6 & its low power Comparator, which is running in stop mode.
What I want to Comparator is:
when pin PA3's input voltage is bigger than reference Voltage, then Comparator give interrupt to the system. so after wake up from its Stop mode, System make buzzer sound. after that, entering sleep again.
Luckily I can make Comparator run in stop mode, so Comparator is always comparing PA3 and Vref/4 (referenceVoltage/4) .
In my intension, I wish my Comparator give interrupt when PA3 voltage >Vref, but my Comparator is always making interrupt when PA3<Vref
how can I make my Comparator work as My intension?
thank you for read.
*********************************************************************
here is my config code:
hcomp2.Instance = COMP2;
hcomp2.Init.NonInvertingInput = COMP_INPUT_PLUS_IO1;
hcomp2.Init.InvertingInput = COMP_INPUT_MINUS_1_4VREFINT;
hcomp2.Init.LPTIMConnection = COMP_LPTIMCONNECTION_IN1_ENABLED; //PA7
hcomp2.Init.OutputPol = COMP_OUTPUTPOL_INVERTED;
//I tried OUTPUTPOL_NONINVERTED , but result was same
hcomp2.Init.Mode = COMP_POWERMODE_ULTRALOWPOWER;
hcomp2.Init.WindowMode = COMP_WINDOWMODE_DISABLE;
hcomp2.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING;
if (HAL_COMP_Init(&hcomp2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN COMP2_Init 2 */
/* USER CODE END COMP2_Init 2 */
if(HAL_COMP_Start_IT(&hcomp2) != HAL_OK){
while(1){
}