2014-03-30 10:33 AM
Dear community,
Knowing that the RTC manual stated that the LSI is not suitable for the RTC, I am trying to use the HSE clock source for the RTC.
I initialized the clock and RTC but the i was unable to read the time. Can you please help?
I initialized the clock as follows:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_BackupAccessCmd(ENABLE); RCC_HSEConfig( RCC_HSE_ON ); while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET) {} RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div8); RCC_RTCCLKCmd(ENABLE); RTC_WaitForSynchro(); RTC_InitStructure.RTC_AsynchPrediv = 0x7C; RTC_InitStructure.RTC_SynchPrediv = 0x1F3F; RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; RTC_Init(&RTC_InitStructure); RTC_TimeStructure.RTC_H12 = RTC_H12_AM; RTC_TimeStructure.RTC_Hours = 1; RTC_TimeStructure.RTC_Minutes = 0; RTC_TimeStructure.RTC_Seconds = 0; RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure); In order to read the clock i am using the following:RTC_GetTime(RTC_Format_BCD, &RTC_TimeStructure);
uwMin = RTC_TimeStructure.RTC_Minutes; uwSecond = RTC_TimeStructure.RTC_Seconds; uwSecond_h = (((uint8_t)(RTC_TimeStructure.RTC_Seconds & 0xF0) >> 0x04)+ 0x30); uwSecond_l = (((uint8_t)(RTC_TimeStructure.RTC_Seconds & 0x0F)) + 0x30); uwSecondfraction = 1000 - ((uint32_t)((uint32_t)RTC_GetSubSecond() * 1000) / (uint32_t)0x3FF); Unfortunately all the variables (uwMin, uwSecond, uwSecond_h, uwSecond_l, uwSecondfraction) has 0 as value.Thank you in advance for the help.
Best regards,
Marc
#stm32f407discovery-rcc-hse-rtc2014-03-31 05:47 AM
[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/STM32F4Discovery%20%20Using%20HSE%20clock%20source%20for%20RTC&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx¤tviews=3]Cross-Posted