Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous clock frequency #41

Open
andreireanu opened this issue Apr 9, 2020 · 8 comments
Open

Erroneous clock frequency #41

andreireanu opened this issue Apr 9, 2020 · 8 comments

Comments

@andreireanu
Copy link

Hello, I'm having a bit of trouble setting the clock frequency. For example if I create the I2C object using a 2 MHz frequency (TWO_MHZ parameter), the real observed frequency is 1,33 MHz. This ratio appears no matter the frequency I set, the real frequency is always 2/3 out of the frequency I set. Any reason for this?

Screenshot from 2020-04-09 12-22-16

@l29ah
Copy link

l29ah commented Apr 9, 2020

Check that your logic analyzer measures periods correctly. I had similar problems with another FX2-based LA that lied to me.

@andreireanu
Copy link
Author

Thanks for the reply! The thing is I used a different library at some point (pyftdi) and the real frequency was recorded correctly by the analyser, so I don't think there's an issue with it.

@l29ah
Copy link

l29ah commented Apr 9, 2020

Oh, interesting. By the way, on your screenshot i observe clock blanks being twice as long as the pulses; is it the same with pyftdi?

@andreireanu
Copy link
Author

Nope, the blanks were the same size as the ones.

Screenshot from 2020-04-09 13-38-46

@andreireanu
Copy link
Author

I seem to have found the problem:

To make I2C working, FTDI needs to enable what they call a "3 phase clock". PyFtdi implements this feature. The issue with this mode is that it requires 3 clock phase for each clock period, hence the 2:3 ratio. PyFtdi hides this setting from the user, and silently tweaks the specified clock to match what the users expects. libmpsse seems not to do it.

Is anyone aware of the inner working of the libmpsse library and how I could make this change to it? Thanks!

@l29ah
Copy link

l29ah commented Apr 9, 2020 via email

@l29ah
Copy link

l29ah commented Apr 9, 2020

Also i see it being enabled in SetMode().

@andreireanu
Copy link
Author

Can you please be more specific on where I can find this part of code? I searched for the definitions of the frequency constants and this led me to the compiled _pylibmpsse.so file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants