cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
520 Views
Registered: ‎11-29-2019

Zedboard EMAC PTP example change counter

Jump to solution

Hello,

I have 2 ZedBoards (7z020clg484-1) which are connected via Ethernet. I implemented the EMAC example using Vivado and the SDK (2018.3). The example itself works just fine. The 2 boards communicate using IEEE1588 PTPv2. However, the example uses its own Clock/Counter to create timestamps. I am planning to get an external timestamp using the FMC connectors and then set this timestamp for the software. I already have an AXI connected core that is connected to the processing system. It can't currently read from the FMC, but that does not matter, since that part of the connection is secondary to the forwarding of the received timestamp.

Is there a simple way to replace the EMACs clock/counter without explicitly rewriting the example code to use my core? I don't feel like rewriting every reference to the current clock/counter would be an efficient way to do this. Is there a way to simply redirect the software to my core?

 

PTP Timestamping.png

This is kinda what I had in mind instead of using the internal clock/counter.

Thanks in advance.

Kind regards,

Christian

0 Kudos
Reply
1 Solution

Accepted Solutions
378 Views
Registered: ‎11-29-2019

So here is my progress so far: Before the Master sends its SYNC message (in the handler called XEmacPs_MasterSendSync), I read out my own clock and then set the main clock of the PTP system

/* Read the timestamps from my device */
u32 ns = NanoSec();
u32 s = Sec0();
/*
* Write the RTC with the custom values
* */
XEmacPs_WriteReg (
InstancePtr->EmacPsInstance->Config.BaseAddress,
XEMACPS_1588_SEC_OFFSET, s);

XEmacPs_WriteReg (
InstancePtr->EmacPsInstance->Config.BaseAddress,
XEMACPS_1588_NANOSEC_OFFSET, ns);

While this does work, it is kinda slow (for some reason I haven't figured out yet). But I guess it works for now.

View solution in original post

3 Replies
379 Views
Registered: ‎11-29-2019

So here is my progress so far: Before the Master sends its SYNC message (in the handler called XEmacPs_MasterSendSync), I read out my own clock and then set the main clock of the PTP system

/* Read the timestamps from my device */
u32 ns = NanoSec();
u32 s = Sec0();
/*
* Write the RTC with the custom values
* */
XEmacPs_WriteReg (
InstancePtr->EmacPsInstance->Config.BaseAddress,
XEMACPS_1588_SEC_OFFSET, s);

XEmacPs_WriteReg (
InstancePtr->EmacPsInstance->Config.BaseAddress,
XEMACPS_1588_NANOSEC_OFFSET, ns);

While this does work, it is kinda slow (for some reason I haven't figured out yet). But I guess it works for now.

View solution in original post

363 Views
Registered: ‎11-29-2019

I could increase the precision by a lot, by (additionally) setting the Tx timestamp:

 

 

	XEmacPs_WriteReg (
			InstancePtr->EmacPsInstance->Config.BaseAddress,
			XEMACPS_PTP_TXSEC_OFFSET, s);

	XEmacPs_WriteReg (
			InstancePtr->EmacPsInstance->Config.BaseAddress,
			XEMACPS_PTP_TXNANOSEC_OFFSET, ns);

 

 

Doing this will set the Sync timestamp and actually allow us to get the needed precision. But something is still missing since the RtcError value increases over time. It seems like something is still drifting them apart.

0 Kudos
Reply
268 Views
Registered: ‎11-29-2019

It seems like I made some mistakes while changing the driver. I could not replicate the increased precision. It seems like a lowered precision is the price one has to pay for setting the clock via Software. I marked my own answer as a solution since it resolves the problem I had, although the precision is lacking (~37ms).

0 Kudos
Reply