Hi!
I was working on the setting of frequency of clock for I2C module.
Starting from a macro, I've found these instructions:
static void setup_I2C0 (void)
{
// Place I2C in Reset
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_IRS, DISABLE);
// Configure I2C Mode (Select 7-Bit Addressing & Transfer 8 Bits)
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_XA, 7BIT);
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_BC, 8BIT);
// Disable Other I2C Modes (Repeat, Loopback, Free Data, Start Byte)
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_RM, DISABLE);
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_DLB, DISABLE);
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_FDF, DISABLE);
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_STB, DISABLE);
// Configure I2C Clock Operation Freq (MUST BE BETWEEN 6.7 AND 13.3 MHz)
CSL_FINS(i2c0Regs->ICPSC, I2C_ICPSC_IPSC, DIVto12MHZ);
// Configure Clock Low/High Time (20 kHz)
CSL_FINS(i2c0Regs->ICCLKL, I2C_ICCLKL_ICCL, 294);
CSL_FINS(i2c0Regs->ICCLKH, I2C_ICCLKH_ICCH, 294);
// Disable and Clear Pending I2C Interrupts
i2c0Regs->ICIMR = CSL_I2C_ICIMR_RESETVAL;
i2c0Regs->ICSTR = i2c0Regs->ICSTR;
// Remove I2C from Reset
CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_IRS, ENABLE);
}/* setup_I2C0 */
On the document about I2C registers (spru877e) I read that the frequency of clock is calculated by this formula:
I2C serial clock frequency = Prescaled module clock frequency/((ICCL+d)+(ICCH+d))
If I understood:
1) CSL_FINS(i2c0Regs->ICCLKL, I2C_ICCLKL_ICCL, 294);
CSL_FINS(i2c0Regs->ICCLKH, I2C_ICCLKH_ICCH, 294);
With these two instructions I define ICCL and ICCH
2) CSL_FINS(i2c0Regs->ICPSC, I2C_ICPSC_IPSC, DIVto12MHZ);
With this instruction I define IPSC value
But I dot understand how I have to set the prescaled frequency.
How I can do?
This example is contained into quickStartOMAPL1x_rCSL
Thanks!
Giuseppe