Question
RTC Offset by milliseconds + and -
I am trying to offset the RTC by milliseconds. I have read through the documentation on this and this has lead me to RTC_SHIFTR. I have looked for examples how to set this up and what maths I need to use. However I am still unable to see the results I am expecting. Can someone please help me and tell me where I am going wrong.
void offsetMiliseconds(uint32_t miliseconds, bool add)
{
GetTime(&local_time);
sprintf(time,"Before: Time: %02d:%02d:%02d : %03d\r\n",local_time.tm_hour,local_time.tm_min,local_time.tm_sec, (((32766-sTime.SubSeconds)*1000)/32766));
WriteToSerialPort(time);
__HAL_RTC_WRITEPROTECTION_DISABLE(&hrtc);
if(add)
hrtc.Instance->SHIFTR = 1 - miliseconds;
else
hrtc.Instance->SHIFTR = miliseconds;
__HAL_RTC_WRITEPROTECTION_ENABLE(&hrtc);
GetTime(&local_time);
sprintf(time,"After : Time: %02d:%02d:%02d : %03d\r\n\r\n",local_time.tm_hour,local_time.tm_min,local_time.tm_sec, (((32766-sTime.SubSeconds)*1000)/32766));
WriteToSerialPort(time);
}
