Author Topic: USE_SNTP vs USE_TIME_SERVER  (Read 5624 times)

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
USE_SNTP vs USE_TIME_SERVER
« on: November 11, 2017, 02:02:44 AM »
Mark,

What is the difference between USE_SNTP and USE_TIME_SERVER?

Each uses different time server IP addresses within the parameter list but both seem to update the local RTC clocks.

My UTC is off by 1 hour. Probably a daylight savings flag somewhere.

Regards,

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #1 on: November 11, 2017, 07:15:33 PM »
Phil

Time server gives a response in seconds. SNTP allows sub-second resolution.
For general time synchronisation both should be fine, although  have heard that time server is something that will be phased out - there seem to be enough on linen still though.

The following flag
if ((temp_pars->temp_parameters.ucTimeZoneFlags & DAYLIGHT_SAVING_SUMMER) != 0) { // if being disabled
controls daylight saving time. If you set it accordingly you can probably compensate the 1 hour offset.
I presume that you have already used the time zone setting to get your local time compensation.

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #2 on: November 11, 2017, 08:38:01 PM »
Mark,

Understood. This tells me that the RTC is being adjusted by local observance of DAYLIGHT_SAVINGS_SUMMER. However, the UTC code should always be referenced without this type of adjustment, correct?

Thanks.

Phil

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #3 on: November 11, 2017, 10:17:58 PM »
Mark,

Just to clarify, fnSynchroniseLocalTime() synchronizes the SNTP received UTC time to the RTC. At this point, RTC should be taking over and keeping the date/time current until the next SNTP packet request is initiated and updates the RTC once again.

fnSetShowTime(DISPLAY_RTC_TIME, cTimeDateBuf) should be return cTimeDateBuf with the current date/time.

In my testing, fnSetShowTime() returns the last UTC timestamp received and remains the same until the next SNTP update. It indicates that the RTC is not running.

What am I missing?

Thanks.

Phil


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #4 on: November 13, 2017, 09:01:59 AM »
Phil

The time keeping document should include the details: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

Essentially UTC is reference to GMT and so the value should be independent of time zone and day light saving time. The local time accesses should perform the necessary adjustments so that the application "thinks " in local time only.

 Check the RTC settings - do you have a 32kHz crystal connected? Alternatively it can run from internal sources (although less accurate - eg- http://www.utasker.com/kinetis/KL_RTC.html)

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #5 on: November 13, 2017, 07:04:47 PM »
Mark,

You were correct. Although we had the 32 kHz clock in the schematic, our team decided NOT to populate this clock unless needed. I switched to the software clock because the LPO didn't work. I don't need a high degree of accuracy at the moment but will probably come back to it later.  In the meantime, I am getting a good consistent clock that gets updated every minute or so.

Thank you once again.

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #6 on: November 13, 2017, 08:14:47 PM »
Phil

Which project version are you using and on which processor?
If it is not an old version that possibly doesn't allow LPO operation I'll check why it didn't work. SW based RTC is however more accurate than LPO - LPO just has the advantage that it can keep the clock going when the processor in in low leakage (very low power) modes.

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #7 on: November 13, 2017, 09:09:49 PM »
This is V1.4.10 running on a MK64FX512VLL12 MCU.
Everything is working fine with the SUPPORT_SW_RTC define.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #8 on: November 14, 2017, 12:33:00 AM »
Phil

V1.4.10 (Kinetis) is quite old so I will assume that it doesn't have the LPO RTC support needed.
If you update at some time and still discover a problem with LPO RTC in the working version we can take a look at it then.

Regards

Mark

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: USE_SNTP vs USE_TIME_SERVER
« Reply #9 on: November 14, 2017, 01:24:51 AM »
I need to update this code at some point anyway. This is a good time.

Thanks, Mark.

Phil