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.

求助6713 的I2C口初始化问题



我已经单独做了个初始化I2C口的工程 I2C_read16(hI2C,0,0x00);在这个函数就不运行了。程序见附件

  • 这个你可以先用示波器测量一下SCL,SDA引脚的信号,看看是什么情况

  • SCL,SDA引脚的信号一直是高电平

    时钟用的是内部时钟 配置如下

     PLL_bypass();
     PLLDelay(20);
     /* Reset PLL */
     PLL_reset();
     PLLDelay(20);
     /* Set main multiplier/divisor */
      PLL_RSET(PLLM, 18);                         // 25MHz  x 18 = 450MHz
      PLL_RSET(PLLDIV0, PLL_PLLDIV0_RMK(1, 0));  // 450MHz / 1 = 450MHz
      PLL_RSET(OSCDIV1, PLL_OSCDIV1_RMK(1, 4));  // 25MHz  / 5 = 5Mhz
      /* Set DSP clock */
      PLL_RSET(PLLDIV1, PLL_PLLDIV1_RMK(1, 1));  // 450MHz / 2 = 225MHz
      PLLDelay(20);
      /* Set peripheral clock */
      PLL_RSET(PLLDIV2, PLL_PLLDIV2_RMK(1, 2));  // 450MHz / 3 = 150MHz
      PLLDelay(20);
      /* Set EMIF clock */
      PLL_RSET(PLLDIV3, PLL_PLLDIV3_RMK(1, 4));  // 450MHz / 5 = 90MHz
      PLLDelay(20);
      /* Take PLL out of reset */
      PLL_deassert();
      PLLDelay(1500);
      /* Enalbe PLL */
      PLL_enable();
      PLLDelay(20);

  • 你好,对应于你的程序,单步调试一下,看看I2CPSCx,I2CCLKHx,等等这些I2C寄存器里的值,都赋值正确了吗

  • 另外,I2C模块的初始化

    7.1.1 State After Reset
    1) Program the I2C prescaler register (I2CPSC) to obtain the desired prescaled
    module clock for the operation of the I2C module (see section 8.11).
    This value is to be calculated and is dependent on the CPU frequency.
    2) Take the I2C module out of reset (IRS = 1).
    a) If using interrupt for transmit/receive data, enable the appropriate
    interrupt in I2CIER.
    b) If using the EDMA controller for transmit/receive data, enable the
    EDMA and program the EDMA controller.
    7.1.2 Initialization Procedure
    Configure the I2C mode register (I2CMDR) (see section 8.9).
    7.1.3 Program Clock Control Registers (I2CCLKL and I2CCLKH)
    Program the I2C prescaled module clock (I2CCLKL and I2CCLKH) to obtain
    the desired SCL clock timing (see section 8.4). These values are to be calculated
    and are dependent on the CPU frequency.
    7.1.4 Configure Address Registers
    1) Configure its own address register (I2COAR) (see section 8.1)
    2) Configure the slave address register (I2CSAR) (see section 8.7)

    等等,这些I2C初始化步骤,可以在下面资料30页中查看

    http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=spru175&fileType=pdf

  • 我下载了这个6116.i2c_6713_example.zip例程 这个是配置的I2C1口吧,我现在硬件上用的是I2C0口,需要改变哪些设置吗?

  • 您好!我是新手,刚使用DSP,我在VIEW->REGISTERS中没有找到这两个寄存器的值?

  • 这个例子不错,是配合C6713 dsk板的。

    /*Opening I2C Handle */
    hI2CA=I2C_open(I2C_DEV0, I2C_OPEN_RESET);

    这里使用的就是I2C0

  • 寄存器地址看这里

  • 您好!

    void main(void)
    {
             
            int i=3;
            /* set core to 200MHz */
            setPLLto200MHz();
           
            /*Enable I2C1 */
            DEVCFG_ENABLE_I2C1();
           
            /*Opening I2C Handle */  
            hI2CA=I2C_open(I2C_DEV0, I2C_OPEN_RESET);

    这个是打开的I2C0口,但是上一个语句是/*Enable I2C1 */使能的I2C1口。这有什么影响吗?

  • 您好,这里没有影响的,两个是相互独立的。

  • 这里可能是因为I2C1有管脚复用的关系,所以这里设置一下,以免用户使用时忘了。