Solved
SHPF flag not getting cleared by hardware (Shift operation pending) after writing to RTC_SHIFTR register
I am using STM32F779 and trying to use its RTC sub second functionality. Also, using a network time to synchronize with RTC. The issue I am having is as follows along with what I have already tried:
- In order to advance SSR register to synchronize with network clock first set RTC_SHIFTR_ADD1S bit and then put advance value into the SUBF (at the moment in order to test code i am just using constant lets say "4"
- Also tried with Delaying SSR (to test if RTC is faster than network clock) by same value of constant "4" after checking there is not RTC Register->RTC_SHIFTR.Set(Any_value); // tried various values to
- Code is as follows for synchronization
if (precise_offset > prediv_s)
{
/* We check SS[15] is equal to 0 to avoid overflow */
if ((RTCRegisters_m->RTC_SSR.Get() & 0x1000) == 0)
{
/* We set an advance */
RTCRegisters_m->RTC_SHIFTR.Set(RTC_SHIFTR_ADD1S_MSK);
rtc_shiftr_temp |= (0x00000004& RTC_SHIFTR_SUBFS_MASK)|RTC_SHIFTR_ADD1S_MSK;
// rtc_shiftr_temp |= ((((precise_sub_second * 255) / 1000000)) & (RTC_SHIFTR_SUBFS_MASK));
RTCRegisters_m->RTC_SHIFTR.Set(rtc_shiftr_temp);
}
}
if (precise_offset < prediv_s)
{
/* We check SS[15] is equal to 0 to avoid overflow */
if ((RTCRegisters_m->RTC_SSR.Get() & 0x1000) == 0)
{
/* We set a delay */
rtc_shiftr_temp |= (0x4 &RTC_SHIFTR_SUBFS_MASK);
RTCRegisters_m->RTC_SHIFTR.Set(rtc_shiftr_temp);
}
}
while ( (RTCRegisters_m->RTC_ISR.Get() & RTC_ISR_SHPF_MSK ) != 0)
{
__NOP();
}Problem:
- Problem is SHPF flag not getting cleared by hardware (Shift operation pending) after writing to RTC_SHIFTR register. It is right that it should get set after writing to the SHIFTR register but based on Ref Manual it gets cleared automatically after getting performing shift operation.
Code gets stuck forever here:
while ( (RTCRegisters_m->RTC_ISR.Get() & RTC_ISR_SHPF_MSK ) != 0)
{
__NOP();
}- Is there anything which I am missing?
Any help will be much appreciated.
