Unexpected COMP1 behavior on STM32H723
Hello,
I need to detect input when it goes over REF/2 (1.65V). I do supply VREF+ pin with 3.3000V.
My signal has offset of 1.2V, and it will go over 2V when I apply signal to it.
Everything is working, but it has unexpected behavior. I can only use negative input as VREF, if I set it to anything else, I get constant 1.
I tested my VREF+ input, and it is 3.3000V ( 0.5% REF chip). Also testes signal on PB0 pin, and it is 1.200 or >2.00V
With debugger I do see BRGEN and SCALEN bits enabled. But it just does not act as it suppose to. What do I am missing. is Vrefint needs to be enabled? I was unable to find this information... Also I am using LL libs.
Does any one has experience regarding this ?
void EXTREF_DETECT_Init(void)
{
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
LL_APB4_GRP1_EnableClock(LL_APB4_GRP1_PERIPH_COMP12);
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOB);
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOC);
GPIO_InitStruct.Pin = LL_GPIO_PIN_7|LL_GPIO_PIN_8;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_0, LL_GPIO_MODE_ANALOG);
LL_COMP_SetPowerMode(COMP1,LL_COMP_POWERMODE_HIGHSPEED);
LL_COMP_ConfigInputs(COMP1,LL_COMP_INPUT_MINUS_1_2VREFINT,LL_COMP_INPUT_PLUS_IO1);
LL_COMP_SetInputHysteresis(COMP1,LL_COMP_HYSTERESIS_LOW);
__IO uint32_t wait_loop_index = 0;
for(uint32_t startup = 0x1FFFF; startup>0 ; startup--)
{
__asm("nop;");
}
LL_COMP_Enable(COMP1);
}RM is so ambiguous about this VREFINT signal....
