因为需要个32位的计时器,计时单位要准确的1ms,所以用最便宜的办法,把F107VCT6的TIM输出脚输出给RTC的OSC32_in,32kHz的方波是看到了,可是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 */
// 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(32-1);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
RTC_SetCounter(0x0);
RTC_WaitForLastTask();
}
程序在第一个 RTC_WaitForSynchro()处死循环。 |