I'm checking the PVD example from STM32G0 repository in CubeMx and something looks backwards to me unless I'm misunderstanding it. I'm expecting the rising callback when the voltage is ABOVE the threshold not below like the code shows. Likewise, I'm expecting the falling callback when the voltage is BELOW threshold. But the code behaves the opposite, that is, the falling callback comes in when the voltage is above ~2.6V and rising callback when is below ~2.5V.
Here is part of the code:
/* Configure the PVD Level to 3 and generate an interrupt on rising and falling
edges(PVD detection level set to 2.5V, refer to the electrical characteristics
of you device datasheet for more details) */
sConfigPVD.PVDLevel = PWR_PVDLEVEL_3;
sConfigPVD.Mode = PWR_PVD_MODE_IT_RISING_FALLING;
void HAL_PWREx_PVD_PVM_Rising_Callback(void)
{
/* Turn Off LED1 as voltage is below threshold */
BSP_LED_Off(LED1);
/* Set uwToggleOn global variable to zero to disable toggle */
uwToggleOn = 0u;
}
void HAL_PWREx_PVD_PVM_Falling_Callback(void)
{
/* Turn On LED1 as voltage is above threshold */
BSP_LED_On(LED1);
/* Set uwToggleOn global variable to one to disable toggle */
uwToggleOn = 1u;
}