Uhr Konfiguration der RTC in Stm32L in LSI/LSE/HSE nur?
Ich die Umsetzung der Echtzeit-Uhr auf STM32L152RB Discovery board mit IAR-compiler. Ich habe implementiert die Clock-Konfiguration auf HSI und mit PLL ich habe es multipliziert durch 4. Code -->
/* Enable HSI Clock */
RCC_HSICmd(ENABLE);
/*!< Wait till HSI is ready */
while (RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);
RCC_PLLConfig(RCC_PLLSource_HSI,RCC_PLLMul_4,RCC_PLLDiv_2);
RCC_PLLCmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
/* Set HSI as sys clock*/
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
Das problem ist bei der Konfiguration von Real-Time-clock habe ich die nebenuhr LSE als die RTC-Clock-Quelle, die in meinem Fall die Quelle meiner Uhr ist HSI. Restlichen Schritte umfasst enable PWR-controller aktivieren rtc-domain-access, rtc clock-Quelle, rtc_init(), dann settime und gettime, sind in Ordnung, wie pro, die ich kenne. Hier ist der code, den ich ausprobiert -->
/* Enable RTC clocks and rtc related functions */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_RTCAccessCmd(ENABLE);
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); //This part I think is wrong
RCC_RTCCLKCmd(ENABLE);
RTC_InitTypeStructure.RTC_HourFormat=RTC_HourFormat_12;
RTC_InitTypeStructure.RTC_AsynchPrediv=0x7F;
RTC_InitTypeStructure.RTC_SynchPrediv=0xFF;
RTC_Init(&RTC_InitTypeStructure);
/* End RTC Clock */
RTC_TimeTypeTime.RTC_Hours=18;
RTC_TimeTypeTime.RTC_Minutes=11;
RTC_TimeTypeTime.RTC_Seconds=4;
RTC_TimeTypeTime.RTC_H12=RTC_H12_PM;
RTC_SetTime(RTC_Format_BIN, &RTC_TimeTypeTime);
while(1){
f_SleepMs(10);
RTC_GetTime(RTC_Format_BIN, &RTC_TimeTypeTime);
RELEASE_MSG("\r%d:%d:%d",RTC_TimeTypeTime.RTC_Hours,RTC_TimeTypeTime.RTC_Minutes,RTC_TimeTypeTime.RTC_Seconds);
}
Ausgabe die ich bekomme, ist 0:0:0
InformationsquelleAutor Ishmeet | 2013-09-02
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
Gelöst, dies zu tun,
LSE kann nur mit Externer Quarz oder Oszillator. Für den internen crystal-LSI verwendet werden kann.
Kann ich bestätigen, dass diese Werke für die STM32F051 (STM32F0Discovery):