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