ccortex-mntp

Get time from NTP server (Cortex M3, Stellaris LM3S6965)


I'm working with Cortex M3, Stellaris® LM3S6965 Evaluation Board. I want to display the time of a NTP server on my oled screen.

I searched and found that a server NTP server sends you timestamps. These timestamps are stored as seconds since January 1, 1900. 32 bits for the number of seconds, and 32 bits for the fractions of a second.

But how do I get the timestamp from a NTP server? (example: http://time.windows.com/)


Solution

  • What you are looking for is the NTP (Network Time Protocol). You should be able to find a library for that protocol in C.

    If there is no library available, you will have to implement it yourself. More info here: http://en.wikipedia.org/wiki/Network_Time_Protocol

    Pay attention to the references to the RFCs.

    I also found a small implementation in C: http://www.abnormal.com/~thogard/ntp/ntpdate.c found on http://www.abnormal.com/~thogard/ntp/