2022-02-24 08:21 PM
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.
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 */
2022-02-25 01:51 AM
Thank you, @XP.1acheco, for bringing this to our attention.
In mainc of the examples, the comments have probably been swapped, but the function names are correct:
We will check this again and correct it in one of the next updates if necessary.
Regards
/Peter
@Imen DAHMEN
@Amel NASRI
2022-02-25 05:58 AM
Even if the comments are swapped, for some reason I'm still seeing that void HAL_PWREx_PVD_PVM_Rising_Callback is being called during the falling edge and vice versa.
2022-02-25 05:07 PM
The code which calls those checks the correct flags. Perhaps recheck assumptions.
2022-02-25 05:20 PM
I will recheck again, but I have done so multiple times and can't understand why the code is behaving backwards. I'm doing real tests varying the supply voltage.
2022-02-25 05:25 PM
I'd suggest setting a breakpoint in the IRQ handler itself and verifying the correct flags are set. That would avoid any HAL nonsense. It would be weird for the flags to be misdefined in the header file, but possible.
2022-02-28 07:31 AM
I tried in different Nucleo Boards and the issue remains so it's not my custom board. I will try to check the flags.
2024-11-27 05:13 AM
hello!
i have the same behaviour..
with the nucleo-g0b1re i'm powering with the external pin 3v3 (removed JP3) with an external adjustable power supply
i have made PVD detection low level 2.8V and PVD detection high level 3.0 volt
external interrupt mode whit rising7falling edge trigger detection
and.. when i adjust the power supply from a value above 2.8 to a value under 2.8 HAL_PWREx_PVD_PVM_Rising_Callback is triggered
when i adjust the power supply from a value under 3.0 to a value above 3.0 HAL_PWREx_PVD_PVM_Falling_Callback is triggered
whi??
did you find an answer?
best reguards