diff --git a/ChangeLog b/ChangeLog index 8c36342ec25..44a9e909b08 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10253,6 +10253,7 @@ Parikh. This initial commit is incomplete. This is quite a bit more hub logic that needs to come in before the port is complete (2015-04-18). + * arch/arm/src/stm32/stm32_rtcounter.c: Now need to enable backup + domain write access when setting the time. From Darcy Gong (2015-04-19). * include/nuttx/usb/usbhost.h: Bring in more logic from - https://github.com/kaushalparikh/nuttx (2015-04-19). - + https://github.com/kaushalparikh/nuttx (2015-04-19). diff --git a/arch/arm/src/stm32/stm32_rtcounter.c b/arch/arm/src/stm32/stm32_rtcounter.c index 28efd296bbf..815d654acbc 100644 --- a/arch/arm/src/stm32/stm32_rtcounter.c +++ b/arch/arm/src/stm32/stm32_rtcounter.c @@ -589,25 +589,37 @@ int up_rtc_settime(FAR const struct timespec *tp) { struct rtc_regvals_s regvals; irqstate_t flags; + uint16_t cntl; /* Break out the time values */ stm32_rtc_breakout(tp, ®vals); + /* Enable write access to the backup domain */ + + (void)stm32_pwr_enablebkp(true); + /* Then write the broken out values to the RTC counter and BKP overflow register * (hi-res mode only) */ flags = irqsave(); - stm32_rtc_beginwr(); - putreg16(regvals.cnth, STM32_RTC_CNTH); - putreg16(regvals.cntl, STM32_RTC_CNTL); - stm32_rtc_endwr(); + do + { + stm32_rtc_beginwr(); + putreg16(regvals.cnth, STM32_RTC_CNTH); + putreg16(regvals.cntl, STM32_RTC_CNTL); + cntl = getreg16(STM32_RTC_CNTL); + stm32_rtc_endwr(); + } + while (cntl != regvals.cntl); #ifdef CONFIG_RTC_HIRES putreg16(regvals.ovf, RTC_TIMEMSB_REG); #endif irqrestore(flags); + + (void)stm32_pwr_enablebkp(false); return OK; }