ataradov / usb-sniffer-lite

A simple USB sniffer based on Raspberry Pi RP2040
BSD 3-Clause "New" or "Revised" License
523 stars 45 forks source link

PIO frequency #16

Open 1250364116 opened 1 month ago

1250364116 commented 1 month ago

Hello,

I would like to know the PIO clock frequency. From what I understand, in low-speed mode the PIO clock divider is set to 8, and in full-speed mode, the divider is set to 1. Given that the system clock frequency is 120 MHz, this means that the PIO clock would be 120 MHz in full-speed mode and 15 MHz in low-speed mode.Similarly, for the USB clock, in low-speed mode, the frequency is 1.5 MHz, and in full-speed mode, it is 12 MHz. Is this correct? If so, why is the PIO frequency ten times higher than the USB clock frequency?

ataradov commented 1 month ago

Your understanding is correct. It needs to be 10 times faster because PIO does not know where the bit centers are. It works with the raw captured pin samples, so it needs extra to synchronize and track the bit centers.

Fixed hardware implementations do the same exact thing. You will typically see that FS devices required 48 MHz clock. This is 4 times faster than the bit rate.