TI E2E™ 设计支持论坛将于 5 月 30 日至 6 月 1 日进行维护。如果您在此期间需要技术支持,请联系 TI 的客户支持中心寻求帮助。

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.

CC2630 I2C调试问题

Other Parts Discussed in Thread: TMP007

基于home1.2版本的门锁例程

测试对E2PROM的读操作

初始化如下:

bspI2cInit();

引脚分配为:

/* I2C */
#define Board_I2C0_SDA0             IOID_7
#define Board_I2C0_SCL0             IOID_27

读操作如下,测量没有任何波形,是不是哪里配置不正确?

 bspI2cSelect(0,0x50);//7位地址为0x50

 sensorReadReg(0, &buf, 1);//读一个字节

 bspI2cDeselect();

  • API 應該是用I2C_open和I2C_transfer,你的bspI2cInit,bspI2cSelect,sensorReadReg,以及bspI2cDeselect是哪來的?
  • SensorTag里面的

    void bspI2cInit(void)
    {
      Semaphore_Params semParamsMutex;
    
      // Create protection semaphore
      Semaphore_Params_init(&semParamsMutex);
      semParamsMutex.mode = Semaphore_Mode_BINARY;
      Semaphore_construct(&mutex, 1, &semParamsMutex);
    
      // Reset the I2C controller
      HapiResetPeripheral(PRCM_PERIPH_I2C0);
    
      I2C_init();
      I2C_Params_init(&i2cParams);
      i2cParams.bitRate = I2C_100kHz;
      i2cHandle = I2C_open(Board_I2C, &i2cParams);
    
      // Initialise local variables
      slaveAddr = 0xFF;
      interface = BSP_I2C_INTERFACE_0;
    
      if (i2cHandle == NULL)
      {
        Task_exit();
      }
    }

    bool bspI2cWriteRead(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen)
    {
    I2C_Transaction masterTransaction;

    masterTransaction.writeCount = wlen;
    masterTransaction.writeBuf = wdata;
    masterTransaction.readCount = rlen;
    masterTransaction.readBuf = rdata;
    masterTransaction.slaveAddress = slaveAddr;

    return I2C_transfer(i2cHandle, &masterTransaction) == TRUE;
    }

    如果用你说的I2C_open和I2C_transfer,参数怎么写?

  • 你的bspI2cInit和bspI2cWriteRead就有用到I2C_open和I2C_transfer,你應該先檢查看看I2C_open後的i2cHandle是不是NULL
  • 有个I2C控制TMP007的例程,可以参考下: dev.ti.com/.../