This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C clock frequency division

Other Parts Discussed in Thread: MSP430F6659

Hi everyone,


I'm working on the configuration of an I2C communication (as master) with my MSP430F6659
I have troubles obtaining the expected clock frequency.

I source UCB clock to ACLK (4MHz) that I also monitor on the P1.0 pin.
ACLK is directly set to the frequency of my quartz (DIVA = 0 = /1) and looks fine on external pin.

I have set UCSSEL to 01b = ACLK then tried different prescale divisions at UCB peripheral level.

The user manual (§39.3.7) states that I can clock the I2C up to source clock /4 (single master)
I'm not sure if the hardware has a maximum frequency limitation (that might be the answer), but i have strange results of actual I2C clock frequency depending on my UCB BR prescaler settings.

I seem to find that the division by the BR prescaler (UCBxBRW Register) has a precision 'error' that decreases with higher BR values, but always stays anyway. I have measured clock periods according to BR setting and found the following frequencies:

ACLK
(kHZ)
BR Period
(µs)
actual frequency
(KHz)
Theoretical / expected frequency 'Error' ratio
4000 4 3,7 270,27027 1000 3,7
4000 8 4,23 236,40662 500 2,115
4000 16 6,2 161,29032 250 1,55
4000 32 12,2 81,967213 125 1,525
4000 64 18,2 54,945055 62,5 1,1375
4000 128 34,2 29,239766 31,25 1,06875

I have also tested with a 1MHz SMCKL source but I still have SMCLK / 8 when I set BR = SMCLK /4, and SMCLK/10 when i select BR = SMCLK/8, then the error is exactly reduced by 2 each time I increase BR

I don't see what factor can interfere with the very clear formula fBitClock = fBRCLK/UCBRx of user manual §39.3.7

- Am I clocking my I2C too fast ? ( it didn't seem to be great with speed around the standard 100kHz )

- Is it possible that external hardware elements could slow down my clock ?

- Or did I miss something that can affect frequency in the settings ?

Thanks for your help

  • Hello,

    It looks like you used the UCBxBRW register, but this is the eUSCI_Bx bit rate control register.  The MSP430F6659 only has USCI, so you should be using UCBxBR0 and UCBxBR1 baud rate control registers instead.  Try this (along with changing any other eUSCI registers to their USCI variant) and see if it makes any difference.

    Thanks,

    Ryan

  • Ryan,

    I'm using my own definition of microcontroller registers, linked at the correct address, and not the keywords provided in TI resources.

    The user's guide of "MSP430x5xx and MSP430x6xx family" SLAU208M only mentions eUSCI modules (and no USCI) so I figured it was the same. If there are any differences, I'm interested in knowing which. The datasheet doesn't seem to show any difference and the manual doesn't mention limitations of USCI over eUSCI.

    Anyway I've used the mapping specified in the datasheet (so USCI places), and in both datasheet and user manual, UCBxBR0 and UCBxBR1 are the same as UCBxBRW register (just a byte or word view of the same place), so that's what I'm talking about and what I used. (address 05E0 and 05E1)

    Same for other registers, I access them manually, and I don't see what else could modify the clock frequency.

  • The User's Guide mentions both eUSCI and USCI modules as either can be found in different MSP430s of the same family.  SLAA522 discusses the differences between the two.

    It does appear that the registers are the same.  Therefore, I would check the UCBxBRx registers inside of your debugger to ensure that the values you want are being set correctly.  It wouldn't hurt to also check the UCSSELx bits under the UCBxCTL1 control register to make sure that the USCI module is being sourced by ACLK.

    Thanks,

    Ryan

  • “The user manual (§39.3.7) states that I can clock the I2C up to source clock /4 (single master)”
    However, the datasheet states that the maximum I2C clock speed is 400kHz (which would require at least 1.6MHz input clock, but with higher clock than 1.6MHz, clock/4 can't be used then).

    So for the first two lines, you’re operating outside the specs.

    For the rest, I guess you have an improper bus setup. I2C requires a sufficiently strong but not too strong external pull-up. If the pull-up is too weak, the clock signal doesn’t rise fast enough once released, and the USCI will stretch the clock cycles by the rise time (sort of clock wait states in source clock cycles, so the effective divider is larger than what you configured). That’s probably what happens to you. This is expected behavior and complies with the standard - normally this is caused actively by a slave that requires some waitstates before proceeding.

  • Jens-Michael Gross said:
    So for the first two lines, you’re operating outside the specs.

    True: I first tried the whole table with 1MHz source clock then did it again with 4MHz to see the impact of frequency, that's when I got out of spec.

    Jens-Michael Gross said:
    . If the pull-up is too weak, the clock signal doesn’t rise fast enough once released, and the USCI will stretch the clock cycles by the rise time

    This must be it indeed, I have an ulgy rising time so it must be happening to me. That answers the question "- Is it possible that external hardware elements could slow down my clock ?" and that solves my problem.

    A shame the clock stretching chapter doesn't mention this case of 'self stretching', I had disregarded it as the slave had nothing to do with it and there is no other master.

    Thanks a lot for your help Jens on this one, and on all threads where you've answered someone else's problem that was happening to me too.

    PS: I hope TI pays you ^^

  • Guillaume Sarrot said:
    PS: I hope TI pays you ^^

    Ha. They should but don't. There are perks and other recognitions though.

  • Guillaume, you’re right, the implications of some things are not always obvious, like this ‘self-stretching’. You need to read between the lines and also have a look at the ‘big whole’. It is easy to forget that even in the digital world, signals are still transported on an analog way (except for quantum-mechanical links). And interpretation of these analog signals into digital signals on the other end may be ambiguous.

     I’m indeed not paid for my work here. However, I got a lifelong free access to any MSP tools for winning the 2010 contributor of the year award. And a trip to Dallas last year. And as Brian commented, there are a few other ”perks and recognitions” too.
    But I don’t do this for money anyway. Even though I could make good use of some additional bucks.

    However, as a TI employee, I wouldn’t be as free as I am now, regarding the way I sometimes answer to some rather annoying posts. :)

**Attention** This is a public forum