Hi Florin,
I tried to merge NTP software with UDP_Send software to get atomic time from internet
and send the output time string to my PC, using UDP protocol.
As you can see this is the output.
1970-01-01 00:01:04
1970-01-01 00:01:07
1970-01-01 00:01:10
1970-01-01 00:01:13
1970-01-01 00:01:16
1970-01-01 00:01:19
1970-01-01 00:01:22
1970-01-01 00:01:25
1970-01-01 00:01:28
I tried to change the NTP server IP address also.
This is the partial code I used:
Code: Select all
Sub Procedure Eth_SetParameters ' set your parameters here
Str2Ip("192.168.0.110",eth_ip_addr)
Str2Ip("192.168.0.2",eth_gateway)
Str2Ip("85.120.220.254",eth_ntp_addr) '
Str2Ip("255.255.255.0",eth_mask)
Str2Mac("0004A3008080",eth_mac)
Str2Ip("192.168.0.14",user_ip_addr)
eth_port = 10001
dest_port = 10001
end sub
Code: Select all
main:
ADCON1 = ADCON1 or 0x07 ' turn off analog inputs
ADCON1.3 = 0
TRISD = %00000000
PORTD = 0
TRISB.0 = 1
PORTB.0 = 0
GreenLed = false
Btn = false
Init
Spi_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH)
Eth_SetParameters
Eth_Init_(PORTB, 3, PORTB, 5)'(ENC_Port_CS, CS, ENC_Port_Reset, Reset)
Wait_For_Lan
if NTP_Sync = false then Ntp_query end if
counter1 = 0
while true
Eth_DoPacket ' process incoming packets
if counter1 > 5000 then ' repeat at 5000 ms
counter1 = 0
if NTP_Sync = false then Ntp_query end if
Get_Time
Success = Send_UDP(user_ip_addr, dest_port,
eth_port,
Str_Len(TTime.Str),
TTime.Str)
end if
wend
end.
I don't know the problem is my modifications in software or maybe
my hardware/software firewall
Thank you in advance,
Max