• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PWR_BackupAccessCmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PWR_BackupAccessCmd函数的典型用法代码示例。如果您正苦于以下问题:C++ PWR_BackupAccessCmd函数的具体用法?C++ PWR_BackupAccessCmd怎么用?C++ PWR_BackupAccessCmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PWR_BackupAccessCmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PIOS_WDG_Init

/** 
 * @brief Initialize the watchdog timer for a specified timeout
 *
 * It is important to note that this function returns the achieved timeout 
 * for this hardware.  For hardware independence this should be checked when
 * scheduling updates.  Other hardware dependent details may need to be 
 * considered such as a window time which sets a minimum update time, 
 * and this function should return a recommended delay for clearing.  
 *
 * For the STM32 nominal clock rate is 32 khz, but for the maximum clock rate of
 * 60 khz and a prescaler of 4 yields a clock rate of 15 khz.  The delay that is
 * set in the watchdog assumes the nominal clock rate, but the delay for FreeRTOS
 * to use is 75% of the minimal delay.
 *
 * @returns Maximum recommended delay between updates based on PIOS_WATCHDOG_TIMEOUT constant
 */
uint16_t PIOS_WDG_Init()
{
	uint16_t delay = ((uint32_t) PIOS_WATCHDOG_TIMEOUT * 60) / 16;
	if (delay > 0x0fff)
		delay = 0x0fff;
#if defined(PIOS_INCLUDE_WDG)
	DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE);	// make the watchdog stop counting in debug mode
	IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
	IWDG_SetPrescaler(IWDG_Prescaler_16);
	IWDG_SetReload(delay);
	IWDG_ReloadCounter();
	IWDG_Enable();

	// watchdog flags now stored in backup registers
	PWR_BackupAccessCmd(ENABLE);

	wdg_configuration.bootup_flags = RTC_ReadBackupRegister(PIOS_WDG_REGISTER);

	/*
	 * Start from an empty set of registered flags so previous boots
	 * can't influence the current one
	 */
	RTC_WriteBackupRegister(PIOS_WDG_REGISTER, 0);
#endif
	return delay;
}
开发者ID:1heinz,项目名称:TauLabs,代码行数:42,代码来源:pios_wdg.c


示例2: rtc_init

void rtc_init() {
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

	if(BKP->DR1 != BKP_MAGIC) {
		PWR_BackupAccessCmd(ENABLE);                        /* Allow write access to BKP Domain */

		RCC_BackupResetCmd(ENABLE);                         /* Reset Backup Domain */
		RCC_BackupResetCmd(DISABLE);

		RCC_LSEConfig(RCC_LSE_ON);                          /* Enable LSE */
		while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); /* Wait till LSE is ready */
		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);             /* Select LSE as RTC Clock Source */
		RCC_RTCCLKCmd(ENABLE);                              /* Enable RTC Clock */

		RTC_WaitForSynchro();                               /* Wait for RTC registers synchronization */
		RTC_WaitForLastTask();
		RTC_SetPrescaler(32767);                            /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
		RTC_WaitForLastTask();

		BKP->DR1 = BKP_MAGIC;

		PWR_BackupAccessCmd(DISABLE);                       /* Protect backup registers */

		rtc_is_valid = 0;
	} else {
		/* Wait for RTC registers synchronization */
		RTC_WaitForSynchro();
	}
}
开发者ID:e-asphyx,项目名称:tomatobox,代码行数:29,代码来源:rtc.c


示例3: RTC_cfg

unsigned int RTC_cfg(void)
{
	unsigned int ret;
	RTC_DateTypeDef   RTC_DateStruct;
	RTC_TimeTypeDef   RTC_TimeStruct;
	
	ret = 0;

	if (RTC_ReadBackupRegister(RTC_BKP_DR1) != 0xA5A5)
	{
	  	ret = 1;
		
		/* Allow access to BKP Domain */
		PWR_BackupAccessCmd(ENABLE);
	 
		/* Reset Backup Domain */
		RTC_DeInit();
	 
		/* Enable LSE */
		RCC_LSEConfig(RCC_LSE_ON);
		
		/* Wait till LSE is ready */
		while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
		{}
	 
		/* Select LSE as RTC Clock Source */
		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
	 
		/* Enable RTC Clock */
		RCC_RTCCLKCmd(ENABLE);
	 
		/* Wait for RTC registers synchronization */
		RTC_WaitForSynchro();
	 
		/* Adjust time */
		RTC_DateStruct.RTC_Year = 13;
		RTC_DateStruct.RTC_Month = 05;
		RTC_DateStruct.RTC_Date = 29;
		RTC_DateStruct.RTC_WeekDay = 3;
		RTC_TimeStruct.RTC_Hours = 11;
		RTC_TimeStruct.RTC_Minutes = 0;	
		RTC_TimeStruct.RTC_Seconds = 0;
		RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);	
		RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
			
		RTC_WriteBackupRegister(RTC_BKP_DR1, 0xA5A5);
	}
	else
	{
	
		/* Allow access to BKP Domain */
		PWR_BackupAccessCmd(ENABLE);

		/* Wait for RTC registers synchronization */
		RTC_WaitForSynchro();
		while (RTC_GetFlagStatus(RTC_FLAG_RSF) == RESET);
		
	}
	return ret;
}
开发者ID:ADTL,项目名称:AFGUI,代码行数:60,代码来源:hw_init.c


示例4: PVD_IRQHandler

void PVD_IRQHandler(void)
{
	unsigned poweroff_cnt;
	unsigned long time;

	EXTI->PR = EXTI_Line16; //EXTI_ClearITPendingBit(EXTI_Line16);

	/* 系统上电前500ms, 不认为是掉电; 若已处于系统掉电状态, 将不再处理 */
	if ((rt_tick_get() < 50) || (NULL == rtc_dev) || is_system_powerdown) {
		return;
	}

	/*
		lcd_bl_led_off();
		buzzer_off(buzzer_gpio, buzzer_pin);
	*/
	is_system_powerdown = 1;
	sys_powerdown_delay4confirm = rt_tick_get();

	PWR_BackupAccessCmd(ENABLE);

	poweroff_cnt = BKP_ReadBackupRegister(RX_POWEROFF_CNT_BKP16BITS);
	BKP_WriteBackupRegister(RX_POWEROFF_CNT_BKP16BITS, ++poweroff_cnt);

	rt_device_control(rtc_dev, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
	BKP_WriteBackupRegister(RX_POWEROFF_N_BKP16BITS_H, (time>>16) & 0xffff);
	BKP_WriteBackupRegister(RX_POWEROFF_N_BKP16BITS_L, (time) & 0xffff);

	PWR_BackupAccessCmd(DISABLE);

	//rt_kprintf("%s", __FUNCTION__);

	return;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:34,代码来源:stm32f10x_it.c


示例5: rtc_set

void rtc_set(uint32_t val) {
	PWR_BackupAccessCmd(ENABLE);

	RTC_SetCounter(val);
	RTC_WaitForLastTask();

	PWR_BackupAccessCmd(DISABLE);
}
开发者ID:e-asphyx,项目名称:tomatobox,代码行数:8,代码来源:rtc.c


示例6: setRtcTime

void setRtcTime(time_t current) {
  PWR_BackupAccessCmd(ENABLE);
  RTC_WaitForLastTask();
  RTC_SetCounter(current);
  RTC_WaitForLastTask();
  PWR_BackupAccessCmd(DISABLE);
  RTC_WaitForLastTask();
  gSecondFlag = 1;
}
开发者ID:arantius,项目名称:vfd-clock,代码行数:9,代码来源:main.c


示例7: backupSave

void backupSave() {
  PWR_BackupAccessCmd(ENABLE);
  BKP_ClearFlag();

  BKP_WriteBackupRegister(BKP_DR1, BACKUP_MARKER);
  BKP_WriteBackupRegister(BKP_DR2, (gUtcOffset >> 16) & 0xFFFF);
  BKP_WriteBackupRegister(BKP_DR3, gUtcOffset & 0xFFFF);
  BKP_WriteBackupRegister(BKP_DR4, gGridOc.TIM_Pulse);

  PWR_BackupAccessCmd(DISABLE);
}
开发者ID:arantius,项目名称:vfd-clock,代码行数:11,代码来源:main.c


示例8: btn_enter_pressed_in_set_chk_interval

void btn_enter_pressed_in_set_chk_interval(){
	/* Allow access to BKP Domain */
	PWR_BackupAccessCmd(ENABLE);

	BKP_WriteBackupRegister(CHECK_INTERVAL_BKP, chk_int);

	PWR_BackupAccessCmd(DISABLE);

	regim = DISPLAY_REGIM_MENU;		//выходим в меню
	lcd_set_state(LCD_ENABLE, CURSOR_DISABLE);
}
开发者ID:drovosekov,项目名称:AutoWatering,代码行数:11,代码来源:set_chk_interval.c


示例9: Backup_SRAM_Write_Reg

void Backup_SRAM_Write_Reg(void *backup_reg, void *source_reg,uint8_t reg_size)
{
	  uint8_t i=0;
	  PWR_BackupAccessCmd(ENABLE);        // set PWR->CR.dbp = 1;
	  PWR_BackupRegulatorCmd(ENABLE);     // set PWR->CSR.bre = 1;

	  for(i=0;i<reg_size;i++)
	  {
		  *((uint8_t*)backup_reg+i)=*((uint8_t*)source_reg+i);
	  }
	  PWR_BackupAccessCmd(DISABLE);                     // reset PWR->CR.dbp = 0;
}
开发者ID:glocklueng,项目名称:STM32_PILORAMA,代码行数:12,代码来源:backup_sram.c


示例10: SWRB_TimeSettingsChangeConfirmProc

void SWRB_TimeSettingsChangeConfirmProc(void)
{
    gSwrbDialogSelectFlag = SWRB_DIALOG_SELECT_NONE;
    gSwrbTestSetSelectFlag = SWRB_TEST_SET_SELECT_NONE;
    
    TimeStr_Comb(hWin_SWRB_TIMESET, ID_TIMESET_EDIT_SETVALUE);
    
    PWR_BackupAccessCmd(ENABLE);
    while(!(RTC_SetDate(RTC_Format_BIN, &rtcDate)));
    while(!(RTC_SetTime(RTC_Format_BIN, &rtcTime)));
    while(!RTC_WaitForSynchro());
    PWR_BackupAccessCmd(DISABLE);
}
开发者ID:bleuelotus,项目名称:SweepRobot_Testing_Host_STemWin,代码行数:13,代码来源:EJE_SWRB_TEST_TimeSettingDLG.c


示例11: rt_rtc_control

static rt_err_t rt_rtc_control(rt_device_t dev, rt_uint8_t cmd, void *args)
{
    //rt_time_t *time;
    RT_ASSERT(dev != RT_NULL);

    switch (cmd)
    {
    case RT_DEVICE_CTRL_RTC_GET_TIME:
       // time = (rt_time_t *)args;
        /* read device */
        RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
        break;

    case RT_DEVICE_CTRL_RTC_SET_TIME:
    {
//        time = (rt_time_t *)args;

        /* Enable PWR and BKP clocks */
        //RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
        /* Allow access to BKP Domain */
        //PWR_BackupAccessCmd(ENABLE);
        PWR_BackupAccessCmd(ENABLE);
        /* Wait until last write operation on RTC registers has finished */
        //RTC_WaitForLastTask();
	 RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure);
				
	 RTC_WaitForSynchro();
			
        /* Change the current time */
        //RTC_SetCounter(*time);

        /* Wait until last write operation on RTC registers has finished */
        //RTC_WaitForLastTask();

    }
    break;
		case RT_DEVICE_CTRL_RTC_SET_DATE:
		{
			RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 
			PWR_BackupAccessCmd(ENABLE);
			RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure);
	 	
			RTC_WaitForSynchro();
    }
		break;
    }

    return RT_EOK;
}
开发者ID:nathanlnw,项目名称:tw705_shanxi_J,代码行数:50,代码来源:rtc.c


示例12: rtc_settime

/*******************************************************************************
* Function Name  : rtc_settime
* Description    : sets HW-RTC with values from time-struct, takes DST into
*                  account, HW-RTC always running in non-DST time
* Input          : None
* Output         : None
* Return         : not used
*******************************************************************************/
void rtc_settime (const RTC_t *rtc)
{
	uint32_t cnt;
	volatile uint16_t i;
	RTC_t ts;

	cnt = struct_to_counter( rtc ); // non-DST counter-value
	counter_to_struct( cnt, &ts );  // normalize struct (for weekday)
	if ( isDST( &ts ) ) {
		cnt -= 60*60; // Subtract one hour
	}
	PWR_BackupAccessCmd(ENABLE);
	my_RTC_SetCounter( cnt );
	PWR_BackupAccessCmd(DISABLE);
}
开发者ID:ljh665577,项目名称:stm32_prj_template,代码行数:23,代码来源:rtc.c


示例13: RTC_Config

/*
*********************************************************************************************************
*	函 数 名: RTC_Config
*	功能说明: 配置RTC用于跑表
*	形    参:无
*	返 回 值: 无
*********************************************************************************************************
*/
static void RTC_Config(void)
{
	/* 使能PWR时钟 */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

	/* 允许访问RTC */
	PWR_BackupAccessCmd(ENABLE);

//	/* 复位备份域 */
//	RCC_BackupResetCmd(ENABLE);
//	RCC_BackupResetCmd(DISABLE);
	 
    /* 选择RTC时钟源 LSI或者LSE */	
	#if defined (RTC_CLOCK_SOURCE_LSI) 
		RCC_LSICmd(ENABLE);
		while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
		{
		}
		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

	#elif defined (RTC_CLOCK_SOURCE_LSE) 
		RCC_LSEConfig(RCC_LSE_ON);
		while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
		{
		}
		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
	#else
		#error Please select the RTC Clock source inside the main.c file
	#endif
}
开发者ID:dasuimao,项目名称:DTS-2500_HMI0030_BOOT,代码行数:38,代码来源:bsp_rtc.c


示例14: RTC_SetUp

void RTC_SetUp(void)
{
  /* Allow access to RTC */
	PWR_BackupAccessCmd(ENABLE);
	RCC_LSICmd(ENABLE); // LSI is used as RTC clock source
	while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
		; // Wait till LSI is ready

	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); // Select RTC clock source
// Enable RTC clock
	RCC_RTCCLKCmd(ENABLE);

	RTC_WaitForSynchro(); // Wait until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock.

	  // Set RTC calendar clock to 1 HZ (1 second)
	RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
	RTC_InitStructure.RTC_AsynchPrediv = 88;
	RTC_InitStructure.RTC_SynchPrediv = 470;
  
	if (RTC_Init(&RTC_InitStructure) == ERROR)
	{
		while (1)
			;
	}
}
开发者ID:Bigboy20769,项目名称:TCode,代码行数:25,代码来源:RTC.cpp


示例15: RTC_Configuration

void RTC_Configuration(void)
{
 	/* Enable PWR and BKP clocks */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
 	/* Allow access to BKP Domain */
	PWR_BackupAccessCmd(ENABLE);
 	/* Reset Backup Domain */
	BKP_DeInit();
 	// Select HSE/128 as RTC Clock Source
	RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div128);  
	/* Enable RTC Clock */
	RCC_RTCCLKCmd(ENABLE);
	/* Wait for RTC registers synchronization */
	RTC_WaitForSynchro();
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
	/* Enable the RTC Second */  
//	RTC_ITConfig(RTC_IT_SEC, ENABLE);
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
	/* Set RTC prescaler: set RTC period to 1sec  1ms */
	RTC_SetPrescaler(62); /*62499 RTC period = RTCCLK/RTC_PR = 8M / 128 = 62.5kHz ) -> (62499+1) */
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
}
开发者ID:bg8wj,项目名称:icar-firmware,代码行数:25,代码来源:init.c


示例16: RTC_Config

//RTC设置成内部或者外部时钟
void RTC_Config(rtc_clk rtcclk)
{
  RTC_InitTypeDef RTC_InitStructure;
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
  PWR_BackupAccessCmd(ENABLE);

	if(rtcclk == extrnal)
	{
		/* Enable the LSE OSC */
		RCC_LSEConfig(RCC_LSE_ON);
		/* Wait till LSE is ready */  
		while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
		/* Select the RTC Clock Source */
		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
		/* Enable the RTC Clock */
		RCC_RTCCLKCmd(ENABLE);
		/* Wait for RTC APB registers synchronisation */
		RTC_WaitForSynchro();
	}
	if(rtcclk == inner)
	{
		RCC_LSICmd(ENABLE); //开启内部低速
		while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);

		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
		RCC_RTCCLKCmd(ENABLE);
		RTC_WaitForSynchro();
	}
	
	RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
	RTC_InitStructure.RTC_SynchPrediv = 0xFF;
	RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
	RTC_Init(&RTC_InitStructure);
}
开发者ID:big-big,项目名称:RD15002WV,代码行数:35,代码来源:bsp_rtc.c


示例17: RTC_Configuration

/**
  * @brief  Configures the RTC.
  * @param  None
  * @retval : None
  */
void RTC_Configuration(void)
{
	/* Enable PWR and BKP clocks */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
	/* Allow access to BKP Domain */
	PWR_BackupAccessCmd(ENABLE);
	/* Reset Backup Domain */
	BKP_DeInit();
	/* Enable LSE */
	RCC_LSEConfig(RCC_LSE_ON);
	/* Wait till LSE is ready */
	while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
	{} 
	/* Select LSE as RTC Clock Source */
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
	/* Enable RTC Clock */
	RCC_RTCCLKCmd(ENABLE);
	/* Wait for RTC registers synchronization */
	RTC_WaitForSynchro();
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
	/* Enable the RTC Second */
	RTC_ITConfig(RTC_IT_SEC, ENABLE);
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
	/* Set RTC prescaler: set RTC period to 1sec */
	RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
}
开发者ID:zxynk666666,项目名称:bluenergy_wn,代码行数:35,代码来源:system_init.c


示例18: RTC_Configuration

/**
  * @brief  Configures RTC clock source and prescaler.
  * @param  None
  * @retval None
  */
void RTC_Configuration(void)
{
    /* RTC clock source configuration ----------------------------------------*/
	/* Allow access to BKP Domain */
  	PWR_BackupAccessCmd(ENABLE);
	
    /* Reset Backup Domain */
    BKP_DeInit();
  
    /* Enable LSE OSC */
	RCC_LSICmd(ENABLE);
    /* Wait till LSE is ready */
	while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
    {
    }

    /* Select the RTC Clock Source */
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

    /* Enable the RTC Clock */
    RCC_RTCCLKCmd(ENABLE);

    /* RTC configuration -----------------------------------------------------*/
    /* Wait for RTC APB registers synchronisation */
    RTC_WaitForSynchro();

    /* Set the RTC time base to 1s */
    RTC_SetPrescaler(32767);  
    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();
	RTC_ITConfig(RTC_IT_ALR, ENABLE);
	RTC_WaitForLastTask();
  
}
开发者ID:idaohang,项目名称:stm32gps-stop,代码行数:39,代码来源:stm32gps_config.c


示例19: test

void test(void)
{
	//Reads data from the specified RTC Backup data Register.
	//入侵检测
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2)
  {
    /* RTC configuration  */
    RTC_Config();
    /* Configure the time&date register */
    RTC_TimeRegulate(); 
  }
else
  {
    /* Enable the PWR clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
    /* Allow access to RTC */
    PWR_BackupAccessCmd(ENABLE);
    /* Wait for RTC APB registers synchronisation */
    RTC_WaitForSynchro();
    /* Clear the RTC Alarm Flag */
    RTC_ClearFlag(RTC_FLAG_ALRAF);
    /* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */
    EXTI_ClearITPendingBit(EXTI_Line17);
  }
  while (1);
}
开发者ID:big-big,项目名称:ucosiii,代码行数:26,代码来源:bsp_rtc.c


示例20: RTC_Configuration

 /**
  * @file   RTC_Configuration
  * @brief  Configures the RTC.
  * @param  无
  * @retval 无
  */
static void RTC_Configuration(void)
{
  //启用PWR和BKP的时钟(from APB1)
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
  //后备域解锁
  PWR_BackupAccessCmd(ENABLE);
  //备份寄存器模块复位
  BKP_DeInit();
  //外部32.768K时钟使能
  RCC_LSEConfig(RCC_LSE_ON);
  //等待稳定
  while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
  {}
  //RTC时钟源配置成LSE(外部32.768K)
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
  //RTC开启
  RCC_RTCCLKCmd(ENABLE);
  //开启后需要等待APB1时钟与RTC时钟同步,才能读写寄存器
  RTC_WaitForSynchro();
  //读写寄存器前,要确定上一个操作已经结束
  RTC_WaitForLastTask();
  //使能秒中断
  RTC_ITConfig(RTC_IT_SEC, ENABLE);
  //等待寄存器写入完成
  RTC_WaitForLastTask();
  //设置RTC分频器,使RTC时钟为1Hz
  //RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1)
  RTC_SetPrescaler(32767); 
  //等待写入完成
  RTC_WaitForLastTask();
}
开发者ID:pyjhhh,项目名称:stm32_f1x,代码行数:37,代码来源:rtc.c



注:本文中的PWR_BackupAccessCmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PWR_GetFlagStatus函数代码示例发布时间:2022-05-30
下一篇:
C++ PWMPulseWidthSet函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap