Skip to content

Commit 1eec522

Browse files
committed
Merge pull request #131 from bcostm/master
[NUCLEO_F103RB] Use HSI/LSI instead of HSE/LSE (board rev C constraint)
2 parents c560db3 + 9702a13 commit 1eec522

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/system_stm32f10x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@
105105

106106
#if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
107107
/* #define SYSCLK_FREQ_HSE HSE_VALUE */
108-
#define SYSCLK_FREQ_24MHz 24000000
108+
/* #define SYSCLK_FREQ_24MHz 24000000 */
109109
#else
110110
/* #define SYSCLK_FREQ_HSE HSE_VALUE */
111111
/* #define SYSCLK_FREQ_24MHz 24000000 */
112112
/* #define SYSCLK_FREQ_36MHz 36000000 */
113113
/* #define SYSCLK_FREQ_48MHz 48000000 */
114114
/* #define SYSCLK_FREQ_56MHz 56000000 */
115-
#define SYSCLK_FREQ_72MHz 72000000
115+
/* #define SYSCLK_FREQ_72MHz 72000000 */
116116
#endif
117117

118118
/*!< Uncomment the following line if you need to use external SRAM mounted

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/rtc_api.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,28 @@ void rtc_init(void) {
2424

2525
BKP_DeInit(); // Reset Backup Domain
2626

27+
// Uncomment these lines if you use the LSE
2728
// Enable LSE and wait till it's ready
28-
RCC_LSEConfig(RCC_LSE_ON);
29-
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {}
30-
31-
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Select LSE as RTC Clock Source
29+
//RCC_LSEConfig(RCC_LSE_ON);
30+
//while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {}
31+
//RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Select LSE as RTC Clock Source
3232

33+
// Uncomment these lines if you use the LSI
34+
// Enable LSI and wait till it's ready
35+
RCC_LSICmd(ENABLE);
36+
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {}
37+
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); // Select LSI as RTC Clock Source
38+
3339
RCC_RTCCLKCmd(ENABLE); // Enable RTC Clock
3440

3541
RTC_WaitForSynchro(); // Wait for RTC registers synchronization
3642

3743
RTC_WaitForLastTask(); // Wait until last write operation on RTC registers has finished
3844

3945
// Set RTC period to 1 sec
40-
// RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1)
41-
RTC_SetPrescaler(32767);
46+
// For LSE: prescaler = RTCCLK/RTC period = 32768Hz/1Hz = 32768
47+
// For LSI: prescaler = RTCCLK/RTC period = 40000Hz/1Hz = 40000
48+
RTC_SetPrescaler(39999);
4249

4350
RTC_WaitForLastTask(); // Wait until last write operation on RTC registers has finished
4451

0 commit comments

Comments
 (0)