cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the PVD state on the STM32L4xx ?

JLiao
Associate II

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);
}

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

according to stm32l4xx_hal_pwr.h:

__HAL_PWR_GET_FLAG(PWR_FLAG_PVDO)

There are other flags too..

hth

KnarfB

View solution in original post

2 REPLIES 2
KnarfB
Principal III

according to stm32l4xx_hal_pwr.h:

__HAL_PWR_GET_FLAG(PWR_FLAG_PVDO)

There are other flags too..

hth

KnarfB

Hi KnarfB,

Thank you for your answer,

Your solution works correctly.

Best Regards,