Trimming the clock from the USB bus

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
david-given
Level 4
Level 4
10 sign-ins 5 sign-ins First solution authored

I am (simplified explanation follows) measuring the frequency of a signal using an unmodified CYCKIT-059 connected as a USB device. I'm finding that it routinely registers incorrectly: a 500kHz signal is consistently reported as 512kHz. However, if I try it with a different CYCKIT-059 I get a consistent but different value. The way I'm measuring the frequency is with a counter between events that increments based on a higher-frequency clock which is based on the IMO. The symptoms I'm seeing sound like the IMO hasn't been properly trimmed.

My understanding is that when the device is connected to a USB bus, then the IMO syncs to the high-accuracy 48MHz clock provided by the host, and so should be +/- 0.25%. However, the inaccuracy I'm seeing is way more than that, which makes me think that it's actually using the internal oscillator, which is +/- 4%. But if that were the case, then surely USB transfers would fail...

Is there anything specifically I need to do to get the high-accuracy internal clock? Or is it completely automatic?

0 Likes
1 Solution

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!

View solution in original post

0 Likes
5 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

DaGi,

The Clock configuration with USB trim enabled should look like this. With that, the clock should be stable to 0.25%

USB_clock_configuration.png

For high-accuracy frequency measurement you can use this custom frequency meter component and demo project:

Re: HELP, with example of frequency measurement Error

/odissey1

Frequency+meter_2x_1a.png

0 Likes

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.

0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello DaGi_900591

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:

pastedImage_1.png

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?

Best Regards

Ekta

0 Likes

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!

0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello DaGi_900591

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.

Best Regards

Ekta

0 Likes