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 definition for C6748 DSP

 

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

 

 

  • Giuseppe Aliperti said:

    But I dot understand how I have to set the prescaled frequency.

    How I can do?

    First you need to know the speed of the clock feeding the I2C peripheral.  This information can be found in Figure 6-1 "Overall Clocking Diagram" of the 6748 System Reference Guide.  Specifically:

    • I2C0 is clocked by PLL0_AUXCLK
    • I2C1 is clocked by PLL0_SYSCLK4

    If that's still a bit confusing you might also look at Figure 5-9 "PLL Topology" in the data sheet.  This diagram makes it clearer that PLL0_AUXCLK is simply your input clock frequency to the entire processor (e.g. 24 MHz or whatever you're using) and PLL0_SYSCLK4 is simply SYSCLK1/4 (CPU/4).

    From there it's a bit more straight-forward.  You just need to divide that input clock down into the range of 6.7 - 13.3 MHz.  So for I2C0 if you have a 24 MHz input clock you set IPSC = 1, which will give you a /2 to result in a 12 MHz prescaled module clock.  For I2C1, let's say you're running the CPU at 375 MHz. In that case you could set IPSC = 36 which would result in a prescaled frequency of 375/37 = 10.135 MHz.

    Brad