Hallo zusammen,
ich versuche grade auf einem STM32F4 Discovery den RTC ans Laufen zu
bringen. Vergeblich!!!
Das Programm verlässt die schleife einfach nicht!
1 | /* Wait till LSE is ready */
|
2 | while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
|
3 | {
|
4 | }
|
Man muss auch dazu sagen das das Board keine BackUp Batterie hat.
Also die Verzweiflung ist sehr groß!!!
Gruß
Denis
p.s.
ich muss dazu sagen das das Gesamte Programm in C++ geschrieben wird.
die h – Datei mit der
wird allerdings über
extern „c“ eingebunden.
Code:
1 | void RTC_INIT(void)
|
2 | {
|
3 |
|
4 | /* Enable the PWR clock */
|
5 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR , ENABLE);
|
6 |
|
7 | /* Allow access to RTC */
|
8 | PWR_BackupAccessCmd(ENABLE);
|
9 |
|
10 | /* Reset RTC Domain */
|
11 | RCC_BackupResetCmd(ENABLE);
|
12 | RCC_BackupResetCmd(DISABLE);
|
13 |
|
14 |
|
15 | /* Enable the LSE OSC */
|
16 | RCC_LSEConfig(RCC_LSE_ON);
|
17 |
|
18 | /* Wait till LSE is ready */
|
19 | while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
|
20 | {
|
21 | }
|
22 |
|
23 | /* Select the RTC Clock Source */
|
24 | RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
25 |
|
26 | /* Configure the RTC data register and RTC prescaler */
|
27 | RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
|
28 | RTC_InitStructure.RTC_SynchPrediv = 0xFF;
|
29 | RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
|
30 | RTC_Init(&RTC_InitStructure);
|
31 |
|
32 | /* Set the time to 00h 00mn 00s AM */
|
33 | RTC_TimeStruct.RTC_H12 = RTC_H12_AM;
|
34 | RTC_TimeStruct.RTC_Hours = 0x00;
|
35 | RTC_TimeStruct.RTC_Minutes = 0x00;
|
36 | RTC_TimeStruct.RTC_Seconds = 0x00;
|
37 | RTC_SetTime(RTC_Format_BCD, &RTC_TimeStruct);
|
38 |
|
39 | }
|