Access to Low Level Fine Timing Measurement (FTM) Clock Registers?

ChrisESP32
Posts: 2
Joined: Thu Jun 01, 2023 9:25 pm

Access to Low Level Fine Timing Measurement (FTM) Clock Registers?

Postby ChrisESP32 » Thu Jun 01, 2023 10:03 pm

I would like to wirelessly synchronize 2x ESP32-S3-DevKitC-1 to within much less than 10 microseconds using Fine Timing Measurement (FTM) (Wi-Fi RTT).

As far as I can tell, the access to the FTM system is through the "esp_wifi_ftm_initiate_session" function which generates an FTM report with clock counter timestamps for the station and access point which are 48 and 52 bit integers with picosecond resolution (actual timestamp resolution seems to be about 1.5 ns).

I grep'd for "esp_wifi_ftm_initiate_session" to find the counter registers, but the only hits I get back are to the binary blob:

components/esp_wifi/lib/esp32s3/libnet80211.a

I would like to adjust the station's FTM clock to be synchronized with the access point's FTM clock.

How can I access the FTM clock registers to adjust the clocks? Thanks!

MicroController
Posts: 1136
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Access to Low Level Fine Timing Measurement (FTM) Clock Registers?

Postby MicroController » Fri Jun 02, 2023 12:05 pm

I would like to adjust the station's FTM clock to be synchronized with the access point's FTM clock.
Why do you want to set the FTM clock?
You say you want to synchronize two ESPs. Do you need the FTMs to be in sync or can you use another timer (or the CPU cycle counter) for time keeping? Both ESPs would set their local timer/counter to the respective FTM value received from the AP and should then have a somewhat common timebase.

ChrisESP32
Posts: 2
Joined: Thu Jun 01, 2023 9:25 pm

Re: Access to Low Level Fine Timing Measurement (FTM) Clock Registers?

Postby ChrisESP32 » Fri Jun 02, 2023 3:44 pm

Why do you want to set the FTM clock?
I thought the solution could be more straightforward and elegant if I can synch the FTM clocks. The FTM reports show the clock counters for the station and access points. An elegant solution would be to make a feedback loop so that the station clock counter matches the access point counter in the reports (minus RTT time). Then I know for certain the clocks are in synch very precisely. Since there are multiple readings in the FTM report I can also see the clock bias drift. The feedback loop also needs to correct for the clock bias drift between STA and AP, because I need a local clock in the STA that is aligned precisely with the AP.

Also, I need the AP to be a "master" clock that synchronizes many STAs. As far as I can tell from the FTM example, the AP does not create an interrupt when it receives an FTM initiation request from a STA, so the AP is not "aware" of the FTM requests to generate a local clock.

I could grab the system timer/counter before and after the "esp_wifi_ftm_initiate_session" and use that to sync another timer/counter, but it strikes me as kind of a kludge. There could be random delays during the FTM session that are much greater than 10 microseconds. This clock "jitter" could be too high and make it impossible for a synch << 10 us.

I'm still in the early stages of coming up with a solution and I think being able to access and adjust the FTM timer/counters would make for a much more elegant solution so I thought I'd ask Espressif and the forum members. I appreciate any feedback and ideas that you'd be willing to share. Thanks!

Who is online

Users browsing this forum: No registered users and 126 guests