当前位置: 首页>>代码示例>>C++>>正文


C++ RCC_RTCCLKCmd函数代码示例

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


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

示例1: 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

示例2: EXTI15_10_IRQHandler

/**
  * @brief  This function handles External line 10 to 15 interrupts request.
  * @param  None
  * @retval None
  */
void EXTI15_10_IRQHandler(void)
{
  if((EXTI_GetITStatus(KEY_BUTTON_EXTI_LINE) != RESET))
  {
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);

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

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

    /* Enable the alarmA */
    RTC_AlarmCmd(RTC_Alarm_A, ENABLE);

    /* Clear the LEFT EXTI  pending bit */
    EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE);  
  }
  else if((EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET))
  {
    /* Disable the RTC Clock */
    RCC_RTCCLKCmd(DISABLE);
    
    /* Wait for RTC APB registers synchronisation */
    RTC_WaitForSynchro();
    
    /* Clear the TAMPER EXTI pending bit */
    EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE);  
  }
}
开发者ID:JackABK,项目名称:STM32_FreeRTOS8.0.1,代码行数:36,代码来源:stm32f4xx_it.c

示例3: RTC_Calibrate

// 通过直接计算校准RTC时钟(使用0.01ms周期的systick测量再修正RTC预分频系数)。
void RTC_Calibrate(void)
{
	unsigned int systick_sta;
	unsigned int rtctick_lmt;
	unsigned int prescaler 	= 0;	

	// 在使用systick测量RTC tick的周期长度之前,初始化systick
	NVIC_SetPriority(SysTick_IRQn, 0);	
	
	SysTick_Init();
	
	// 开始rtcalarm计数并使能rtcalarm中断
	SysTick_Enable();

	// 先设置默认的RTC预分频系数(rtc tike = ~1ms)
	RTC_SetPrescaler(DEF_RTC_PRESCALER);

	/* 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();

	// 测量RTC单周期长度持续~1秒
	rtctick_lmt = systick+1000/SYSTICK_PERIOD;

	// 记录测量前的systick值
	systick_sta = systick;

	// 测量1000个周期的rtc tick(~1s)
	while(systick < rtctick_lmt);

	prescaler = (DEF_RTC_PRESCALER * 1000)/((systick-systick_sta)/100);

	// printf("prescaler = %d.\r\n", prescaler);	

	// 重新设置RTC预分频系数
	RTC_SetPrescaler(prescaler);

	/* 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();

	// 校准完RTC时钟后,停止rtcalarm计数并禁止rtcalarm中断
	SysTick_Disable();

	// printf("RTC Clock calibrated.\r\n");
}
开发者ID:jianblin,项目名称:learngit,代码行数:57,代码来源:mcu_rtc.c

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: rtc_init

void rtc_init(void) {
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); // Enable PWR clock

    PWR_RTCAccessCmd(ENABLE); // Enable access to RTC

    // Note: the LSI is used as RTC source clock
    // The RTC Clock may vary due to LSI frequency dispersion.  
   
    RCC_LSICmd(ENABLE); // Enable LSI
  
    while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {} // Wait until ready
    
    RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); // Select LSI as RTC Clock Source
  
    RCC_RTCCLKCmd(ENABLE); // Enable RTC Clock 
      
    RTC_WaitForSynchro(); // Wait for RTC registers synchronization

    uint32_t lsi_freq = 40000; // [TODO] To be measured precisely using a timer input capture

    RTC_InitTypeDef RTC_InitStructure;
    RTC_InitStructure.RTC_AsynchPrediv = 127;
    RTC_InitStructure.RTC_SynchPrediv	 = (lsi_freq / 128) - 1;
    RTC_InitStructure.RTC_HourFormat   = RTC_HourFormat_24;
    RTC_Init(&RTC_InitStructure);
    
    PWR_RTCAccessCmd(DISABLE); // Disable access to RTC
      
    rtc_inited = 1;
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:30,代码来源:rtc_api.c

示例9: 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

示例10: rtc_init

void rtc_init(){
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
	PWR_BackupAccessCmd(ENABLE); //needed?
	/* use LSE-clock X3=32768 KHz, C 
	RCC_LSEConfig(RCC_LSE_ON);

	while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET){};
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
	
	RCC_RTCCLKCmd(ENABLE);
	RTC_WaitForSynchro();

	RTC_InitTypeDef rtc_init;

	rtc_init.RTC_AsynchPrediv = 0xFF;
	rtc_init.RTC_SynchPrediv = 0x7F;
	rtc_init.RTC_HourFormat = RTC_HourFormat_24; */

	RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div32);
	
	RCC_RTCCLKCmd(ENABLE);
	RTC_WaitForSynchro();

	RTC_InitTypeDef rtc_init;

	rtc_init.RTC_SynchPrediv = 0x7a0;
	rtc_init.RTC_AsynchPrediv = 0x7F;
	rtc_init.RTC_HourFormat = RTC_HourFormat_24;

	RTC_Init(&rtc_init);
}
开发者ID:powertomato,项目名称:cocktailbot,代码行数:31,代码来源:rtc.c

示例11: TM_RTC_Config

void TM_RTC_Config(TM_RTC_ClockSource_t source) {
	if (source == TM_RTC_ClockSource_Internal) {
		/* Enable the LSI OSC */
		RCC_LSICmd(ENABLE);

		/* Wait till LSI is ready */
		while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);

		/* Select the RTC Clock Source */
		RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
	} else if (source == TM_RTC_ClockSource_External) {
		/* 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 register synchronization */
	RTC_WaitForSynchro();

	/* Write status */
	RTC_WriteBackupRegister(RTC_STATUS_REG, RTC_STATUS_INIT_OK);
}
开发者ID:Mars55,项目名称:stm32f429,代码行数:30,代码来源:tm_stm32f4_rtc.c

示例12: RTC_Configuration

void RTC_Configuration(void)
{
	/* 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();

  /* 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:JanusErasmus,项目名称:stm-discovery-feeder,代码行数:30,代码来源:rtc.c

示例13: RTC_Configuration

/****************************************************************************
* 名    称:void RTC_Configuration(void)
* 功    能:RTC配置函数
* 入口参数:无
* 出口参数:无
* 说    明:
* 调用方法:
****************************************************************************/
static void RTC_Configuration(void)
{ 
    /* Enable the PWR clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
    /* Allow access to RTC */
    PWR_RTCAccessCmd(ENABLE);
     /*!< Reset RTC Domain */
    RCC_RTCResetCmd(ENABLE);
    RCC_RTCResetCmd(DISABLE);

#if defined (RTC_CLOCK_SOURCE_LSI)  /* LSI used as RTC source clock*/
    /* The RTC Clock may varies due to LSI frequency dispersion. */   
    /* Enable the LSI OSC */ 
    RCC_LSICmd(ENABLE);
    /* Wait till LSI is ready */  
    while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {}
    /* Select the RTC Clock Source */
    RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
  
#elif defined (RTC_CLOCK_SOURCE_LSE) /* LSE used as RTC source clock *///外部32.378K晶振
    /* 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);
#else
    #error Please select the RTC Clock source inside the main.c file
#endif /* RTC_CLOCK_SOURCE_LSI */
  
    /* Enable the RTC Clock */
    RCC_RTCCLKCmd(ENABLE);
    /* Wait for RTC APB registers synchronisation */
    RTC_WaitForSynchro();
}
开发者ID:Lejacming,项目名称:The-sea-water-temperature-acquisition-system,代码行数:43,代码来源:RTC.c

示例14: RTC_Config

/*******************************************************************************
* Function Name  : RTC_Configuration
* Description    : Configures the RTC.
* Input          : None
* Output         : None
* Return         : 0 reday,-1 error.
*******************************************************************************/
int RTC_Config(void)
{
    u32 count=0x250000;
  /* Enable the PWR clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

  /* Allow access to RTC */
  PWR_BackupAccessCmd(ENABLE);
    
  RCC_LSEConfig(RCC_LSE_ON);

  /* Wait till LSE is ready */  
  while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET && (--count) );
  if ( count == 0 )
    {
        return -1;
    }

  /* Select the RTC Clock Source */
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
  
  SynchPrediv = 0xFF;
  AsynchPrediv = 0x7F;
  
  /* Enable the RTC Clock */
  RCC_RTCCLKCmd(ENABLE);

  /* Wait for RTC APB registers synchronisation */
  RTC_WaitForSynchro();
  return 0;
}
开发者ID:nathanlnw,项目名称:tw705_shanxi_J,代码行数:38,代码来源:rtc.c

示例15: 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


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