I have problems with RTC. I am using STM8L051F3 microcontroller which is low power. Once I turn it on RTC works well, it means uC is waken up after 30 seconds, but other time I turn it on it works other way, it wakes up after shorter time which is for example 3 seconds. I checked registers and I found that sometimes wake up clock source does not switch to SPRE. I know that these bits are protected by write protection bits and this may be a problem, that they do not change.