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程序移植问题

我用F28335的I2C外扩的M41T81 程序通过,移植到F28069上,只改了I2C的引脚初始化,其他没变,程序过不去了,总停留在while(I2caRegs.I2CMDR.bit.STP == 1);不知道什么原因,难道F28069和F28335的I2C不一样?

  • F28335和F28069的I2C有一点区别就是335的FIFO是16个FIFO,069只有4个。你要确定GPIO初始化没问题。

    Eric

  • 您好,我确认了一下,确实是FIFO的事,我需要一下接收7个bytes,在28335里有16个FIFO就成功,在28069里只有4个FIFO就不行了,于是我在28069里关闭了接收的FIFO,采用普通接收模式,程序如下

    void I2cReadData(Uint16 add)
    {
          int i= 0;
          while(I2caRegs.I2CMDR.bit.STP == 1);
          while(I2caRegs.I2CSTR.bit.BB == 1); 
          I2caRegs.I2CCNT = 1; 
           I2caRegs.I2CDXR = add;                   // Send out the address
           I2caRegs.I2CMDR.all = 0x6e20;       // Master, Transmitter, STT, STP

          while(I2caRegs.I2CMDR.bit.STP == 1); 
          while(I2caRegs.I2CSTR.bit.BB == 1); 
          I2caRegs.I2CCNT = 7;                       // Set count to characters plus 1 address bytes
          I2caRegs.I2CMDR.all = 0x6c20;

         for(i=0; i<7; i++)
        {
              while(I2caRegs.I2CSTR.bit.RRDY == 0){};
              Data[i] = I2caRegs.I2CDRR & 0x00ff;
         }
    }

    程序就一直停在红色查询处,请问程序哪里有问题吗,谢谢?


  • 请各位专家解答一下

  • 楼主问题有解决吗?相信你已经搞定啦,能不能分享一下 啊,遇到同样的问题!