diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c index 4e8be5a5ac4..24091b659d3 100644 --- a/arch/arm/src/stm32/stm32_rtcc.c +++ b/arch/arm/src/stm32/stm32_rtcc.c @@ -415,12 +415,12 @@ static int rtc_setup(void) /* Configure RTC pre-scaler with the required values */ #ifdef CONFIG_STM32_RTC_HSECLOCK - /* For a 1 MHz clock this yields 0.9999360041 Hz on the second - * timer - which is pretty close. + /* STMicro app note AN4759 suggests using 7999 and 124 to + * get exactly 1MHz when using the RTC at 8MHz. */ - putreg32(((uint32_t)7182 << RTC_PRER_PREDIV_S_SHIFT) | - ((uint32_t)0x7f << RTC_PRER_PREDIV_A_SHIFT), + putreg32(((uint32_t)7999 << RTC_PRER_PREDIV_S_SHIFT) | + ((uint32_t)124 << RTC_PRER_PREDIV_A_SHIFT), STM32_RTC_PRER); #else /* Correct values for 32.768 KHz LSE clock and inaccurate LSI clock */ diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index 5ad9228abaf..4a04586e39e 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -483,12 +483,12 @@ static int rtc_setup(void) /* Configure RTC pre-scaler with the required values */ #ifdef CONFIG_STM32_RTC_HSECLOCK - /* For a 1 MHz clock this yields 0.9999360041 Hz on the second - * timer - which is pretty close. + /* STMicro app note AN4759 suggests using 7999 and 124 to + * get exactly 1MHz when using the RTC at 8MHz. */ - putreg32(((uint32_t)7182 << RTC_PRER_PREDIV_S_SHIFT) | - ((uint32_t)0x7f << RTC_PRER_PREDIV_A_SHIFT), + putreg32(((uint32_t)7999 << RTC_PRER_PREDIV_S_SHIFT) | + ((uint32_t)124 << RTC_PRER_PREDIV_A_SHIFT), STM32_RTC_PRER); #else /* Correct values for 32.768 KHz LSE clock and inaccurate LSI clock */ diff --git a/arch/arm/src/stm32f7/stm32_rtc.c b/arch/arm/src/stm32f7/stm32_rtc.c index 30618d91bd2..3d30a3dce9d 100644 --- a/arch/arm/src/stm32f7/stm32_rtc.c +++ b/arch/arm/src/stm32f7/stm32_rtc.c @@ -490,12 +490,12 @@ static int rtc_setup(void) /* Configure RTC pre-scaler with the required values */ #ifdef CONFIG_STM32F7_RTC_HSECLOCK - /* For a 1 MHz clock this yields 0.9999360041 Hz on the second - * timer - which is pretty close. + /* STMicro app note AN4759 suggests using 7999 and 124 to + * get exactly 1MHz when using the RTC at 8MHz. */ - putreg32(((uint32_t)7182 << RTC_PRER_PREDIV_S_SHIFT) | - ((uint32_t)0x7f << RTC_PRER_PREDIV_A_SHIFT), + putreg32(((uint32_t)7999 << RTC_PRER_PREDIV_S_SHIFT) | + ((uint32_t)124 << RTC_PRER_PREDIV_A_SHIFT), STM32_RTC_PRER); #else /* Correct values for 32.768 KHz LSE clock and inaccurate LSI clock */ diff --git a/arch/arm/src/stm32h7/stm32_rtc.c b/arch/arm/src/stm32h7/stm32_rtc.c index 3d77b1b3e88..a826e0c9bf8 100644 --- a/arch/arm/src/stm32h7/stm32_rtc.c +++ b/arch/arm/src/stm32h7/stm32_rtc.c @@ -490,12 +490,12 @@ static int rtc_setup(void) /* Configure RTC pre-scaler with the required values */ #ifdef CONFIG_STM32H7_RTC_HSECLOCK - /* For a 1 MHz clock this yields 0.9999360041 Hz on the second - * timer - which is pretty close. + /* STMicro app note AN4759 suggests using 7999 and 124 to + * get exactly 1MHz when using the RTC at 8MHz. */ - putreg32(((uint32_t)7182 << RTC_PRER_PREDIV_S_SHIFT) | - ((uint32_t)0x7f << RTC_PRER_PREDIV_A_SHIFT), + putreg32(((uint32_t)7999 << RTC_PRER_PREDIV_S_SHIFT) | + ((uint32_t)124 << RTC_PRER_PREDIV_A_SHIFT), STM32_RTC_PRER); #else /* Correct values for 32.768 KHz LSE clock and inaccurate LSI clock */