Hallo, da ein Problem das nächste jagt wende ich mich nochmals an die
Community.
Mittlerweile habe ich dank der Tipps die RTC auch zum laufen gebracht
mit plausiblen Werten, nur leider läuft sie etwas zu schnell, obwohl die
Prescaler laut Datenblatt richtig gesetzt wurden.
Ist die Abweichung erfahrungsgemäß wirklich so groß, dass bei der Wahl
des LSI Taktes die RTC nach einer Minute schon 4 Sekunden zu schnell
ist?
Da ich das erste mal mit der RTC arbeite, kann ich die Abweichungen noch
nicht wirklich einschätzen.
1 | void ur_sh_rtc_init(void){
|
2 |
|
3 | RTC_InitTypeDef RTC_InitStructure;
|
4 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
5 |
|
6 | PWR_BackupAccessCmd(ENABLE);
|
7 |
|
8 | RCC_BackupResetCmd(ENABLE);
|
9 | RCC_BackupResetCmd(DISABLE);
|
10 |
|
11 | RCC_LSICmd(ENABLE);
|
12 |
|
13 | while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) { }
|
14 |
|
15 | RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
|
16 |
|
17 | RCC_RTCCLKCmd(ENABLE);
|
18 |
|
19 | RTC_WaitForSynchro();
|
20 |
|
21 | //Prescaler wählen
|
22 | //LSI = 32 kHz 127 249 1Hz
|
23 | RTC_InitStructure.RTC_AsynchPrediv = 127;
|
24 | RTC_InitStructure.RTC_SynchPrediv = 249; // (32KHz / 128) - 1 = 249
|
25 | RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
|
26 | RTC_Init(&RTC_InitStructure);
|
27 |
|
28 | }
|