高级会员

- 积分
- 658
- 金钱
- 658
- 注册时间
- 2012-10-21
- 在线时间
- 45 小时
|
1金钱
void RTC_Configuration(void) //RCTÅäÖÃ
{
/* 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_LSICmd(ENABLE);//¿aÆôÄú2¿μíËùê±ÖóLSI
/* Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
{iwdg_feed();}
iwdg_feed();
/* Select LSE as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
iwdg_feed();
/* Enable RTC Clock */
RCC_RTCCLKCmd(ENABLE);
iwdg_feed();
RTC_WaitForLastTask();
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
iwdg_feed();
/* Wait until last write operation on RTC registers has finished */
RTC_EnterConfigMode();
RTC_WaitForLastTask();
RTC_SetPrescaler(40000);
RTC_WaitForLastTask();
RTC_WaitForLastTask();
RTC_ExitConfigMode();
}
上边的代码 是配置成内部时钟,程序仿真RTC正常运行。。。我是为了避免会影响到PC13的使用 才改为内部时钟的 ,那也不好使,PC13职高或者拉低都在1.5V左右,只要把RTC初始话注释掉 ,IO引脚就能正常。。。
int main(void)
{
delay_init();
// RTC_Init();
io_init();
usart_init();
init320240();
while(1)
{
Time_Display(RTC_GetCounter());
LED_8 = 0;
delay_ms(1000);
delay_ms(1000);
LED_8 = 1;
delay_ms(1000);
delay_ms(1000);
}
}
网上查到 如下解决方案也不好使:最后四句话是查到的不好使也。主要问题是在SYS_RCT_Conf();函数里 ,
void RTC_Init(void)
{
NVIC_RTC();
SYS_RCT_Conf();
PWR_BackupAccessCmd(ENABLE);
RCC_LSEConfig(RCC_LSE_OFF);
BKP_TamperPinCmd(DISABLE);
BKP_ITConfig(DISABLE);
}
SYS_RCT_Conf();代码如下 ,借用原子的代码 。
void SYS_RCT_Conf(void)
{
iwdg_feed();
RTC_Configuration();
Time_Adjust();
BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
iwdg_feed();
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
{iwdg_feed();
}
else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
{iwdg_feed();
}
iwdg_feed();
RTC_WaitForSynchro();
iwdg_feed();
RTC_ITConfig(RTC_IT_SEC, ENABLE);
iwdg_feed();
RTC_WaitForLastTask();
iwdg_feed();
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
iwdg_feed();//Î11·
PWR_BackupAccessCmd(ENABLE);
iwdg_feed();
BKP_TamperPinCmd(DISABLE);
iwdg_feed();
BKP_RTCOutputConfig(BKP_RTCOutputSource_CalibClock);
iwdg_feed();
RCC_ClearFlag();
}
这个代码没有改动 ,我该怎么整才能正常用PC13,而却保证RTC正常能用。。。。
|
最佳答案
查看完整内容[请看2#楼]
学会论坛搜索:http://www.openedv.com/forum.php?mod=viewthread&tid=15906
|