2016-09-29 01:26 AM
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 codemain(){
---------------------------------
---------------------------------
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
2016-09-29 01:56 AM
Hi karakaya.mehmet,
You should enable the PWR peripheral before using PVD.-Hannibal-2016-09-29 02:21 AM
Hello thank you ,
I already enabled - I forgot to add to the first postmain(){
----------------------------
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
----------------------------
2016-09-29 05:38 AM
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
I also enabled AFIO - no change - PVD still not triggering interrupt
2016-10-08 01:20 AM
nobody has an idea ?
2016-10-17 02:59 AM
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-