Skip to main content
Visitor II
September 29, 2016
Question

how to get PVD (programmable voltage detector) interrupt working ?

  • September 29, 2016
  • 5 replies
  • 3426 views
Posted on September 29, 2016 at 10:26

hello dear forum,

I want sense F103 Power Down to save a variable to the flash of the micro however it doesnot save - doesnot work accordingly ( I tried saving to flash in another program - it works ) I am using following code

main(){
---------------------------------
---------------------------------
NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 6;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);}
-------------------------------------
EXTI16init();
-------------------------------------
FLASH_Unlock();
EE_Init();
EEread_params();
----------------------------------
/* Configure the PVD Level to 2.9V */
PWR_PVDLevelConfig(PWR_PVDLevel_2V9);
/* Enable the PVD Output */
PWR_PVDCmd(ENABLE);
---------------------------------------------
}
---------------------------------------------
void
EXTI16init(
void
)
{
EXTI_InitTypeDef EXTI_InitStructure;
/* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and
falling edges */
EXTI_ClearITPendingBit(EXTI_Line16);
EXTI_InitStructure.EXTI_Line = EXTI_Line16;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
----------------------------------
void
PVD_IRQHandler(
void
)
{
EXTI_ClearITPendingBit(EXTI_Line16);
EXTI_ClearFlag(EXTI_Line16);
EEsave_param();
while
(1){Delay(100);IWDG_ReloadCounter();}
}

what point am I missing ? thank you #stm32f103-pvd
    This topic has been closed for replies.

    5 replies

    Visitor II
    September 29, 2016
    Posted on September 29, 2016 at 10:56

    Hi karakaya.mehmet, 

    You should enable the PWR peripheral before using PVD.

    -Hannibal-

    Visitor II
    September 29, 2016
    Posted on September 29, 2016 at 11:21

    Hello thank you ,

    I already enabled - I forgot to add to the first post

    main(){
    ----------------------------
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
    ----------------------------

    Visitor II
    September 29, 2016
    Posted on September 29, 2016 at 14:38

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

    I also enabled AFIO - no change - PVD still not triggering interrupt
    Visitor II
    October 8, 2016
    Posted on October 08, 2016 at 10:20

    nobody has an idea ?

    Visitor II
    October 17, 2016
    Posted on October 17, 2016 at 11:59

    Hi karakaya.mehmet,

    Try to configurate in the same order like the following : (same like the example ''PVD'' in standard peripheral library):

    /* Enable PWR and BKP clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
    /* Configure EXTI Line to generate an interrupt on falling edge */
    EXTI_Configuration();
    /* NVIC configuration */
    NVIC_Configuration();
    /* Configure the PVD Level to 2.9V */
    PWR_PVDLevelConfig(PWR_PVDLevel_2V9);
    /* Enable the PVD Output */
    PWR_PVDCmd(ENABLE);

    -Hannibal-
    Graduate II
    November 6, 2024

    What include is necessary for these functions? I pasted this code on main.c and these functions were not found.