cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 Programmable Voltage Detector working backwards?

xpp07
Senior

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 */

7 REPLIES 7
Peter BENSCH
ST Employee

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:

  • Projects\NUCLEO-G0B1RE\Examples\PWR\PWR_PVDPWR_PVD/src
  • Projects\STM32G0C1E-EV\Examples\PWR\PWR_PVD\Src

We will check this again and correct it in one of the next updates if necessary.

Regards

/Peter

@Imen DAHMEN​

@Amel NASRI​ 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
xpp07
Senior

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.

TDK
Guru

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.

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.

If you feel a post has answered your question, please click "Accept as Solution".

I tried in different Nucleo Boards and the issue remains so it's not my custom board. I will try to check the flags.

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