The Clock configuration with USB trim enabled should look like this. With that, the clock should be stable to 0.25%
For high-accuracy frequency measurement you can use this custom frequency meter component and demo project:
The USBFS Component has stringent clock requirements. You are correct that the following conditions must be met for a valid USB design:
▪ The USB clock must be 48 MHz.
▪ The accuracy of the USB clock must be within +/-0.25%
Perform the following changes to use the internal PSoC clocks to drive the USB.
For PSoC 3 and PSoC 5LP:
IMO at 24 MHz, doubler for USB.
1. IMO: Set to 24 MHz.
2. ILO: Set to 100 kHz
3. USB: Enable and select IMOx2 to achieve 48 MHz.
This setting is shown in the image posted by BoTa_264741
For more details please refer to the USBFS datasheet(page): https://www.cypress.com/file/376416/download
Making the above configurations would enable generating a 48MHz clock with an accuracy of +/-0.25%. This clock would be provided to the USB block.
After making the above configuration could you please let us know if you are still facing the issue with the clock accuracy.
Just to be absolutely clear: I'm not concerned about the USB clock speed, because I know that's right or USB wouldn't work --- I'm concerned about the IMO clock speed. Is the configuration described above (IMO to 24MHz, USB clock enabled at IMOx2, ILO to 100kHz) adequate to lock the IMO clock to the USB bus, or is there anything else I need to do? Is it possible to disable this clock locking, and how? (So I can check I haven't done this by accident.)
I should add just in case it's relevant, although I don't think it is: my master clock and bus clock is running at 64MHz, driven from the PLL which is derived from the IMO.
With the above configuration (IMO to 24MHz, USB Clock enabled at IMO*2 and ILO set to 100kHz) the IMO will operate at a frequency of 24MHZ with an accuracy of +/-0.25. The USB clock is obtained by multiplying the IMO clock by 2 (using frequency doubler) as shown in the figure below:
In order to get this high accuracy for IMO it must be run with the oscillator locking function enabled, in which case it self tunes to the required USB accuracy when USB traffic arrives at the device. This feature allows the PSoC 3 or PSoC 5LP to achieve a USB accurate clock using only the IMO and USB traffic with a host as a reference. This accuracy is achieved by adjusting the IMO’s trim setting after measuring the IMO frequency, using host USB start of frame events as a timing reference.
Apart from the settings mentioned in the previous post no other setting is required to achieve the accuracy.
Is it possible for you to measure the frequency using an oscilloscope?
Problem resolved --- it turned out to be an incredibly stupid off-by-one error in both the code which measures the frequency and a related piece of test code (which was why I didn't notice it at first). So there's nothing wrong with the clock at all.
Thanks for the help!