cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Time/Date register not reset in first attempt

cabhinav
Associate
Posted on August 06, 2014 at 09:15

Hi,

I am trying to reset the Time and Date (TR/DR) registers in STM32F2xx using a logic as below:

reset_func()

{

// Disable write protection

// Enter init mode

RTC->TR = 0;    // Reset TR

// Exit init mode

// Wait for synchroniation

// Enable write protection

}

It turns out sometimes a call to this reset_function returns without the TR being actually reset. Now if I run this function in a loop until the TR is actually reset, I can get it working.

However when I add the loop inside the function like this:

reset_func()

{

   unsigned int register;

// Disable write protection

// Enter init mode

    RTC->TR = 0;

// While not reset, loop

do {

    register = RTC->TR;

}

while (register != 0);    // Reset TR

// Exit init mode

// Wait for synchroniation

// Enable write protection

}

the system gets stuck.

Is there anything that prevents us from looping a read inside init mode and with write protection disabled?
0 REPLIES 0