cancel
Showing results for 
Search instead for 
Did you mean: 

Problems writing RTC_PRL at runtime

mhabermann74
Associate II
Posted on January 20, 2010 at 02:58

Problems writing RTC_PRL at runtime

2 REPLIES 2
mhabermann74
Associate II
Posted on May 17, 2011 at 13:38

I intend to calibrate the RTC by adjusting the prescaler in the RTC_PLR register. But any write to this register while enabled RTC, causes the RTOFF bit to hang.

This code hangs:

RTC_WaitForSynchro();

RTC_WaitForLastTask();

RTC_SetPrescaler(ReoTime_maxRtcPrl);

RTC_WaitForLastTask(); //hangs forever

This code also:

RTC_WaitForLastTask();

RTC_EnterConfigMode();

RTC->PRLL = (u16)ReoTime_maxRtcPrl;

RTC_ExitConfigMode();

RTC_WaitForLastTask(); //hangs forever

Without writing to RTC_PRL, i.e. using the configuration created with STM32_Init.c unmodified, the RTC works as expected.

mhabermann74
Associate II
Posted on May 17, 2011 at 13:38

I found the solution. Writing to the backup and RTC registers must be enabled with:

PWR_BackupAccessCmd(ENABLE);