RTC Initialisierung auf STM32F4 geht nicht :-(

OP #2628760
Lesenswert?
• ▲
▼
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
1
 void RTC_INIT(void)
 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
}
OP #2628879
Lesenswert?
• ▲
▼
Danke für die Antwort.
Leider komme ich immer noch nicht weiter.
Ich habe den Code so abgeändert:
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 LSI OSC */
16
  RCC_LSICmd(ENABLE);
17

18

19
  /* Wait till LSI is ready */
20
  while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
21
  {
22
  }
23

24
  /* Select the RTC Clock Source */
25
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
26

27
  /* Configure the RTC data register and RTC prescaler */
28
  RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
29
  RTC_InitStructure.RTC_SynchPrediv  = 0xFF;
30
  RTC_InitStructure.RTC_HourFormat   = RTC_HourFormat_24;
31
  RTC_Init(&RTC_InitStructure);
32

33
  /* Set the time to 00h 00mn 00s AM */
34
  RTC_TimeStruct.RTC_H12     = RTC_H12_AM;
35
  RTC_TimeStruct.RTC_Hours   = 0x03;
36
  RTC_TimeStruct.RTC_Minutes = 0x03;
37
  RTC_TimeStruct.RTC_Seconds = 0x03;
38
  RTC_SetTime(RTC_Format_BCD, &RTC_TimeStruct);
39

40

41
}
An dieser Stelle versuche ich die Zeit auszulesen:
1
char* dat_time::getTimeString()
2
{
3

4
  RTC_TimeTypeDef  RTC_TimeStruct;
5
  RTC_GetTime(RTC_Format_BCD, &RTC_TimeStruct );
6
  sprintf(buffer, "xx2 %02u:%02u:%02u", RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
7
  return buffer;
8

9
}

Dabei tickt die Uhr nicht :-(


Ich weiß dass es schnell albern werden kann, aber vielleicht kann mir 
jemand weiter helfen.

Gruß
Denis

Antwort schreiben

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.