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.
Hi All,
I would like to ask a question on I2C configuration.
SPRU911a, Inter-Intergrated (I2C) Peripheral UG, said that the prescaled module clock must be set to 7-12 MHz. However, in Spectrum's EVMDM6437_I2C_init( ) function:
/* ------------------------------------------------------------------------ *
* *
* _I2C_init( ) *
* *
* Enable and initalize the I2C module *
* The I2C clk is set to run at 100 KHz *
* *
* ------------------------------------------------------------------------ */
Int16 EVMDM6437_I2C_init( )
{
I2C_ICMDR = 0; // Reset I2C
I2C_ICPSC = 13; // Config prescaler for 27MHz
I2C_ICCLKL = 5; // Config clk LOW for 100 kHz
I2C_ICCLKH = 5; // Config clk HIGH for 100 kHz
I2C_ICMDR |= ICMDR_IRS; // Release I2C from reset
return 0;
}
ICPSC is set ot 13, and since I2C input clock is 27MHz, the prescaled module clock frequency is then 27M /(13+1)= 1.93 MHz, which does not fall within the range of 7-12 MHz.
What is wrong here? Have I made any mistake in the calculation?
Another question is on the value of d. What is the purposes of d here? Why it is related to the IPSC value in the way as shown in the table above and takes only three values (7, 6, and 5)?
In table 8 above, does the "period of the module clock" refer to "I2C serial clock frequency" in Fig 3 above? If yes, then since "I2C serial clock frequency" is obtained by dividing "prescaled module clock frequency" by (ICCL+d) + (ICCH+d), an "multiplication" as described in Table 8 will generate the low-time duration value, and similarly for high-time duration value from ICCH. By setting different ICCL and ICCH value, we can control the ratio between low-time and high-time duration so that they two are not necessarily equal, is that true? Is the purpose of this design simply to allow more flexibility to the user?
And in practice, are ICCL and ICCH nearly always set to the same value to make both low-time and high-time duration 50% of the whole I2C serial clock period?
Thanks,
Zheng
Hi Zheng,
Some of the input clock sources to the I2C controller are higher clock frequencies and some are not. I did not spend much time on this but when I looked at the subsystem guide for this peripheral, it seems to me that the input clock souce frequency to the I2C controller is AUXCLK which is the Reference Clock in PLL Bypass mode which tells me that it is 27MHz. So, your initial finding seems to be correct.
However, having said that, you are also correct that the I2C input clock frequency is not within the range that is recommended. This does not mean that it would not work. This means that if you have a noisy line then you might have a problem. The analog logic within the controller is designed to reject noise optimally within the suggested frequency range.
One thing that we have noticed is that customers copy EVM h/w and s/w design. They should not do that as you have figured out. It is OK to use EVM resource as a guideline but not as a reference.
In summary, the contnet of the User's Guide is correct.
Best regards, Zegeye
Dear Zegeye,
I still need some time to understand it. Thanks for the detailed answer.
Zheng