Skip to main content
JLiao
Associate
February 19, 2023
Solved

How to get the PVD state on the STM32L4xx ?

Sir,

I am using the STM32L432 for my project.

How to get the PVD state ?

I want to know the power voltage that is above the level or under the level.

Thanks.

void HAL_PWR_PVDCallback(void) {
 if ( __HAL_PWR_PVD_EXTI_GET_FLAG() ) {
 // TODO: get PVD state
 }
}
}
 
void PVD_Init() {
 PWR_PVDTypeDef pvdStruct;
 
 __HAL_RCC_PWR_CLK_ENABLE();
 
 HAL_PWR_DeInit();
 
 pvdStruct.PVDLevel = PWR_PVDLEVEL_6; // 2.9v
 pvdStruct.Mode = PWR_PVD_MODE_IT_RISING_FALLING; // pvd 下�? = 電�?上�?�
 HAL_PWR_ConfigPVD(&pvdStruct);
 HAL_PWR_EnablePVD();
 
 HAL_NVIC_SetPriority(PVD_PVM_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(PVD_PVM_IRQn);
}

This topic has been closed for replies.
KnarfB
KnarfBBest answer
Super User
February 19, 2023

according to stm32l4xx_hal_pwr.h:

__HAL_PWR_GET_FLAG(PWR_FLAG_PVDO)

There are other flags too..

hth

KnarfB

2 replies

KnarfB
KnarfBBest answer
Super User
February 19, 2023

according to stm32l4xx_hal_pwr.h:

__HAL_PWR_GET_FLAG(PWR_FLAG_PVDO)

There are other flags too..

hth

KnarfB

JLiao
JLiaoAuthor
Associate
February 19, 2023

Hi KnarfB,

Thank you for your answer,

Your solution works correctly.

Best Regards,