Page 1 of 1

ESP-NOW timestamp relation to TSF?

Posted: Sat Jan 18, 2025 7:13 pm
by robiwan
The ESP-NOW timestamp in the esp_now_recv_info struct is 32 bit (usec resolution). How is this timestamp related to the TSF counter of the WiFi interface?

ESP-NOW comes without any sources so there's no way to check how the timestamp is acquired.

I need to be able to create a timestamp in the same manner, for implementing PTP.

Re: ESP-NOW timestamp relation to TSF?

Posted: Sun Jan 19, 2025 3:06 pm
by ahsrabrifat
You can use the esp_timer_get_time() function to approximate a timestamp.

Re: ESP-NOW timestamp relation to TSF?

Posted: Mon Jan 20, 2025 7:01 am
by robiwan
Already tried that, and it doesn't cut it. I need the *same* timer as that used for the wifi_pkt_rx_ctrl_t.timestamp field, or a similar APB based timer within microseconds.

Re: ESP-NOW timestamp relation to TSF?

Posted: Sun Jan 26, 2025 11:27 am
by robiwan
Using the WiFi promiscuous callback (for beacon/probe) I can see that the relation between the TSF and the rx_ctrl.timestamp is very stable, so with that, I can deduce a difference between those and then use the TSF value to start a secondary (APB based) usec timer which has (very close to) the same value as the timestamp counter.