Skip to content

[NUCLEO_F103RB] Use HSI/LSI instead of HSE/LSE (board rev C constraint) #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@

#if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
/* #define SYSCLK_FREQ_HSE HSE_VALUE */
#define SYSCLK_FREQ_24MHz 24000000
/* #define SYSCLK_FREQ_24MHz 24000000 */
#else
/* #define SYSCLK_FREQ_HSE HSE_VALUE */
/* #define SYSCLK_FREQ_24MHz 24000000 */
/* #define SYSCLK_FREQ_36MHz 36000000 */
/* #define SYSCLK_FREQ_48MHz 48000000 */
/* #define SYSCLK_FREQ_56MHz 56000000 */
#define SYSCLK_FREQ_72MHz 72000000
/* #define SYSCLK_FREQ_72MHz 72000000 */
#endif

/*!< Uncomment the following line if you need to use external SRAM mounted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,28 @@ void rtc_init(void) {

BKP_DeInit(); // Reset Backup Domain

// Uncomment these lines if you use the LSE
// Enable LSE and wait till it's ready
RCC_LSEConfig(RCC_LSE_ON);
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {}

RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Select LSE as RTC Clock Source
//RCC_LSEConfig(RCC_LSE_ON);
//while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {}
//RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Select LSE as RTC Clock Source

// Uncomment these lines if you use the LSI
// Enable LSI and wait till it's ready
RCC_LSICmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {}
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); // Select LSI as RTC Clock Source

RCC_RTCCLKCmd(ENABLE); // Enable RTC Clock

RTC_WaitForSynchro(); // Wait for RTC registers synchronization

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

// Set RTC period to 1 sec
// RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1)
RTC_SetPrescaler(32767);
// For LSE: prescaler = RTCCLK/RTC period = 32768Hz/1Hz = 32768
// For LSI: prescaler = RTCCLK/RTC period = 40000Hz/1Hz = 40000
RTC_SetPrescaler(39999);

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

Expand Down