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


C++ RTC_SetPrescaler函数代码示例

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


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

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

#ifdef RTCClockSource_LSI
  /* Enable LSI */ 
  RCC_LSICmd(ENABLE);
  /* Wait till LSI is ready */
  while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
  {
  }

  /* Select LSI as RTC Clock Source */
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);  
#elif defined	RTCClockSource_LSE
  	/* 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);
#endif
  	/* 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 */
      /* Set RTC prescaler: set RTC period to 1sec */
#ifdef RTCClockSource_LSI
  		RTC_SetPrescaler(31999); /* RTC period = RTCCLK/RTC_PR = (32.000 KHz)/(31999+1) */
#elif defined	RTCClockSource_LSE
  		RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
#endif

  //	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:weimingtom,项目名称:stm32-gui,代码行数:59,代码来源:rtc.c

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

示例3: rtcConfig

static void rtcConfig(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 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);

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

#ifndef PRECISION_IN_MS
    /* Set RTC prescaler: set RTC period to 1 sec */
    RTC_SetPrescaler(40000); //LSI default is 40k HZ
#else
    /* Set RTC prescaler: set RTC period to 1ms */
    RTC_SetPrescaler(40); //LSI default is 40k HZ
#endif

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

    /* To output second signal on Tamper pin, the tamper functionality
     * must be disabled (by default this functionality is disabled)
     */
    //BKP_TamperPinCmd(DISABLE);

    /* Enable the RTC Second Output on Tamper Pin */
    //BKP_RTCOutputConfig(BKP_RTCOutputSource_Second);
}
开发者ID:running1919,项目名称:qianlab,代码行数:54,代码来源:clock.c

示例4: RTC_Init

/*
************************************************************
*	函数名称:	RTC_Init
*
*	函数功能:	RTC初始化
*
*	入口参数:	无
*
*	返回参数:	无
*
*	说明:		
************************************************************
*/
_Bool RTC_Init(void)
{
	
#if(USE_EXT_RCC == 1)
	unsigned char errCount = 0;
#endif

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //使能PWR和BKP外设时钟   
	PWR_BackupAccessCmd(ENABLE); //使能后备寄存器访问
	
	BKP_DeInit();	//复位备份区域
#if(USE_EXT_RCC == 1)
	RCC_LSEConfig(RCC_LSE_ON);	//设置外部低速晶振(LSE),使用外设低速晶振
	while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET && errCount < 250)	//检查指定的RCC标志位设置与否,等待低速晶振就绪
	{
		errCount++;
		DelayMs(10);
	}
	if(errCount >= 250)
		return 1; //初始化时钟失败,晶振有问题
#endif
	
#if(USE_EXT_RCC == 1)
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); 		//设置RTC时钟(RTCCLK),选择LSE作为RTC时钟
#else
	RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div128);	//设置RTC时钟(HSE/128),选择HES作为RTC时钟
#endif
	RCC_RTCCLKCmd(ENABLE); //使能RTC时钟
	RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成
	RTC_WaitForSynchro(); //等待RTC寄存器同步
	
	RTC_ITConfig(RTC_IT_ALR, ENABLE); //使能RTC闹钟中断
	RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成
	
	RTC_EnterConfigMode(); //允许配置
#if(USE_EXT_RCC == 1)
	RTC_SetPrescaler(32767); //设置RTC预分频的值
#else
	RTC_SetPrescaler(HSE_VALUE / 128 - 1); //设置RTC预分频的值
#endif
	RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成
	
	RTC_SetCounter(0); //设置RTC计数器的值
	RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成
	
	RTC_ExitConfigMode(); //退出配置模式
	
	RTC_NVIC_Init();
	
	return 0;

}
开发者ID:yzfcer,项目名称:wind-os,代码行数:65,代码来源:rtc.c

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

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

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

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

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

示例10: RTC_AutoTest

uint8_t RTC_AutoTest(void)
{

	uint8_t i = 0;
	/* 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)
	{	
		Delay_us(50000);
		i++;
		
		if(i>100) //5秒都还没起振,坏了
		{
			return 0;
		}
	}	

	/* Select LSE as RTC Clock Source */
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
	
	/* Enable RTC Clock */
	RCC_RTCCLKCmd(ENABLE);
	
	/* Wait for RTC registers synchronization 
	 * 因为RTC时钟是低速的,内环时钟是高速的,所以要同步
	 */
	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) = 1HZ */
	
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();
	
	return 1;


}
开发者ID:FanNiu,项目名称:wildfire_stm32_iso_mini,代码行数:58,代码来源:bsp_rtc.c

示例11: rtc_timer_start

void rtc_timer_start(u32 alarmValue) 
{
    //enable BKP and PWR, Clock
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP|RCC_APB1Periph_PWR , ENABLE);
    
    // RTC clock source configuration 
    PWR_BackupAccessCmd(ENABLE);                      //Allow access to BKP Domain
    RCC_LSEConfig(RCC_LSE_ON);                        //Enable LSE OSC
    while(RCC_GetFlagStatus(RCC_FLAG_LSERDY)==RESET); //Wait till LSE is ready
    RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);           //Select the RTC Clock Source
    RCC_RTCCLKCmd(ENABLE);                            //enable RTC
    
    // RTC configuration 
    // Wait for RTC APB registers synchronisation 
    RTC_WaitForSynchro();
    
    RTC_SetPrescaler(0);                              //Set the RTC time base to 30.5us
    RTC_WaitForLastTask();                            //Wait until last write operation on RTC registers has finished

    //Set the RTC time counter to 0
    RTC_SetCounter(0);
    RTC_WaitForLastTask();

    // Set the RTC time alarm(the length of slot)
    RTC_SetAlarm(alarmValue);
    RTC_WaitForLastTask();
    
    //interrupt when reach alarm value
    RTC_ClearFlag(RTC_IT_ALR);
    RTC_ITConfig(RTC_IT_ALR, ENABLE);
   
    //Configures EXTI line 17 to generate an interrupt on rising edge(alarm interrupt to wakeup board)
    EXTI_ClearITPendingBit(EXTI_Line17);
    EXTI_InitTypeDef  EXTI_InitStructure; 
    EXTI_InitStructure.EXTI_Line    = EXTI_Line17;
    EXTI_InitStructure.EXTI_Mode    = EXTI_Mode_Interrupt; 
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
    EXTI_InitStructure.EXTI_LineCmd = ENABLE; 
    EXTI_Init(&EXTI_InitStructure);
   
    //Configure RTC global interrupt:
    //Configure NVIC: Preemption Priority = 1 and Sub Priority = 1
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_InitStructure.NVIC_IRQChannel                    = RTC_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority  = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority         = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd                 = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    
    //Configure RTC Alarm interrupt:
    //Configure NVIC: Preemption Priority = 0 and Sub Priority = 1
    NVIC_InitStructure.NVIC_IRQChannel                    = RTCAlarm_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority  = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority         = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd                 = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}
开发者ID:Babody,项目名称:openwsn-fw,代码行数:57,代码来源:rtc_timer.c

示例12: RTC_Configuration

/*********************************************************************************************************//**
 * @brief Configures the RTC.
 * @retval None
 * @details RTC configuration as following:
 *  - S/W reset backup domain.
 *  - Configure RTC.
 *    - Select LSI as RTC Clock Source.
 *    - Enable the RTC Second interrupt.
 *    - RTC prescaler = 32768 to generate 1 second interrupt.
 *    - Enable clear RTC counter by match function.
 *
 ************************************************************************************************************/
void RTC_Configuration(void)
{
    /* Reset Backup Domain */
    PWRCU_DeInit();

    RTC_ClockSourceConfig(RTC_SRC_LSI);
    RTC_IntConfig(RTC_INT_CSEC, ENABLE);
    RTC_SetPrescaler(RTC_RPRE_32768);

    /* Restart counter when match event occured */
    RTC_CMPCLRCmd(ENABLE) ;
}
开发者ID:afxstar,项目名称:Mplib,代码行数:24,代码来源:Calendar.c

示例13: RTC_Configuration

/*******************************************************************************
* Function Name  : RTC_Configuration
* Description    : Configures the RTC.
* Input          : None
* Output         : None
* Return         : 0 reday,-1 error.
*******************************************************************************/
int RTC_Configuration(void)
{
    u32 count=0x200000;

    /* 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) && (--count) );
    if ( count == 0 )
    {
		rt_kprintf("RTC no init!");
        return -1;
    }

    /* 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的秒中断 */	
	//RTC_ITConfig(RTC_IT_SEC, ENABLE);

	/* Wait until last write operation on RTC registers has finished */
	/* 等待上一次对RTC寄存器的写操作完成 */	
	//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();

    return 0;
}
开发者ID:cahill123,项目名称:shenzhou-iv-stm32f107-rt-thread,代码行数:58,代码来源:rt_rtc.c

示例14: RTC_Configuration

/*
 * 函数名:RTC_Configuration
 * 描述  :配置RTC
 * 输入  :无
 * 输出  :无
 * 调用  :外部调用
 */
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 
	 *打开外部低速晶振,RTC可以选择的时钟源是外部和内部低速晶振及外部高速晶振,这里我们选择外部低速晶振32768HZ */
	RCC_LSEConfig(RCC_LSE_ON);
	/* Wait till LSE is ready 
	 *等待外部低速晶振准备就序 */
	while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
	{}
	
	/* Select LSE as RTC Clock Source 
	 * 选择外部低速晶振为RTC的时钟源 */
	RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
	
	/* Enable RTC Clock */
	RCC_RTCCLKCmd(ENABLE);
	
	/* Wait for RTC registers synchronization
	 * 等待RTC寄存器与RTC的APB时钟同步 */
	RTC_WaitForSynchro();
	
	/* Wait until last write operation on RTC registers has finished
	 * 等待上次对RTC寄存器配置完成 */
	RTC_WaitForLastTask();
	
	/* Enable the RTC Second
	 * 使能RTC中断_秒中断 */
	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的预分频值,因为外部低速晶振是32768,所以选择RTC计数器计数频率
	 * = RTCCLK/RTC_PR =(32.768 KHz)/(32767+1) */
	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:vcheung,项目名称:STM32,代码行数:58,代码来源:rtc.c

示例15: RTC_STOP_WakeUp

void RTC_STOP_WakeUp(void)
{
    /* Enable PWR and BKP clocks */
    /* PWR时钟(电源控制)与BKP时钟(RTC后备寄存器)使能 */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

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

    /* RTC clock source configuration ----------------------------------------*/
    /* Reset Backup Domain */
    BKP_DeInit();

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

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

    /* Enable the RTC Alarm interrupt */
    RTC_ITConfig(RTC_IT_ALR, ENABLE);
    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();

    RTC_ClearFlag(RTC_FLAG_SEC);
    while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);

    /* Alarm in 5 second */
    RTC_SetAlarm(RTC_GetCounter()+ 5);
    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();
}
开发者ID:congallenwang,项目名称:107vc-iap,代码行数:48,代码来源:PwrMode.c


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