CH32V203C8T6 RTC例程每次重新上電時間都會被重置

CH32V203C8T6 RTC例程每次重新上電時間都會被重置,請問怎么操作才能避免?

你好,后備寄存器是Vbat供電的,數(shù)據(jù)可以保持,可以判斷標(biāo)志位確定,VDD掉電后,要確保Vbat由電池供電。

u8?RTC_Init(void)
{
????u8?temp?=?0;
????RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR?|?RCC_APB1Periph_BKP,?ENABLE);
????PWR_BackupAccessCmd(ENABLE);

????/*?Is?it?the?first?configuration?*/
????if(BKP_ReadBackupRegister(BKP_DR1)?!=?0XA1A1){
????BKP_DeInit();
????RCC_LSEConfig(RCC_LSE_ON);
????while(RCC_GetFlagStatus(RCC_FLAG_LSERDY)?==?RESET?&&?temp?<?250)
????{
????????????temp++;
????????????Delay_Ms(20);
????}
????if(temp?>=?250)
????return?1;
????RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
????RCC_RTCCLKCmd(ENABLE);
????RTC_WaitForLastTask();
????RTC_WaitForSynchro();
????//		RTC_ITConfig(RTC_IT_ALR,?ENABLE);
????RTC_ITConfig(RTC_IT_SEC,?ENABLE);
????RTC_WaitForLastTask();
????RTC_EnterConfigMode();
????RTC_SetPrescaler(32767);
????RTC_WaitForLastTask();
????RTC_Set(2019,?10,?8,?13,?58,?55);?/*?Setup?Time?*/
????RTC_ExitConfigMode();
????BKP_WriteBackupRegister(BKP_DR1,?0XA1A1);

????RTC_NVIC_Config();
????RTC_Get();}
????else{
????????????RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR?|?RCC_APB1Periph_BKP,?ENABLE);
????????????PWR_WakeUpPinCmd(DISABLE);
????????????RTC_WaitForSynchro();
????????????//?RTC_ITConfig(RTC_IT_ALR,?ENABLE);
????????????RTC_ITConfig(RTC_IT_SEC,?ENABLE);
????????????RTC_WaitForLastTask();
????????}

????????//?nvic
????????????RTC_NVIC_Config();
????????return?0;
????return?0;
}



只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频