Jump to content
Sign in to follow this  
OppaErich

I2C SCK always 1.6 MHz - TPR setting ?

Recommended Posts

Hi,

 

somehow they use a different math in Texas than here. I've tried alt least a dozen different settings for TPR, SCK is running at 1.6 MHz no matter what. In the end I tried just random numbers that came to mind. Lucky me, the BMP085 is rated up to 3.4 MHz in any mode so it works.

 

Could someone explain how this is calculated and set ? I'm running at full speed, 80 MHz.

Share this post


Link to post
Share on other sites

I use this here (recalculates the real speed after rouding/truncating as well):

 

    /*
     * speed = SystemCoreClock / (20 * (1 + TPR))
     * TPR = (SystemCoreClock / (20 * speed)) - 1;
     */
 
    speed = 400000;
    
    tpr = (SystemCoreClock / (20 * speed)) - 1;
 
    speed = SystemCoreClock / (20 * (1 + tpr));

Share this post


Link to post
Share on other sites

Odd. 9 is what the reference manual says as well for 400kHz. 

 

Just to be sure, you did not enable high speed mode in either I2CMTPR or I2CPC ? This would change how TPR is used as a frequency divider.

 

How do you measure the frequency of SCL ? Have you measured another clock to make sure your CPU is running at 80MHz (yes, I screwed that up once ...).

 

I am asking because if your CPU runs at 120MHz (like them TM4C129) and you used high speed mode and TPR of 9 ... then you'd see 2.0MHz on SCL ...

 

- Thomas

Share this post


Link to post
Share on other sites

Well, it's a 123 so I guess it would not run at 120 MHz. I2C clock rate is taken from the logic analyzer. I spotted a HS field it the status register, I did not set this but it was '1'.

 

If I got that right from the datasheet, the '20' in your formula is 2 * (6+4) for normal speed and would get 2 * (3 + 1) = 8 for high speed. Tried both, doesn't make a difference. Maybe I have to grab the scope and watch SCL.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...