Skip to main content
Lee3
Associate III
September 12, 2022
Question

How can I synchronize a timer to USB SOF?

  • September 12, 2022
  • 1 reply
  • 1157 views

I'm interested in trying to synchronize my system to USB start of frame packets. I'm using the CRS system to generate an HSI48 clock. I've considered running that HSI48 clock into MCO and using that as an external clock for a timer. This would enable that timer to be frequency synchronized with the USB clock, but no way to actually set the phase on that clock from what I can find. I'd like my timer to run at 10 kHz, but be phase synchronized to the USB SOF. Any ideas?

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
September 13, 2022

What is the purpose of that timer?

One straightforward solution is to use the SOF through the slave-mode controller in reset mode (I don't know what the connections are, whether the SOF inputs into timer as CH1 or CH2 allowing this).

Another possibility is to use SOF to capture the timer's counter, and adjust timer in software accordingly. It may be difficult to adjust the counter itself; if you need the timer to generate a signal through its compare, I'd simply "acknowledge" whatever is the phase shift, by shifting the compare value accordingly.

Note, that there are undefined latencies of one-two timer cycles in the way, so you may need to fine-tune things.

JW