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.

[参考译文] CC1312R:I2C 运行不正常

Guru**** 2481465 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1312920/cc1312r-i2c-is-not-working-well

器件型号:CC1312R

您好!
我正在测试与 I2C 连接的 MAX31334 RTC 芯片。
我的代码如下。
但是、卡在第一个 I2C_TRANSMIT ()中。 只 发送2个字节(地址和1个字节)。

我使用了回调、返回第一个 I2C_TRANSMIT 并发送地址和1个字节。
但是、第二次传输是无效的。


问题是什么?

  uint8_t txBuffer[7];
  uint8_t rxBuffer[7];

  I2C_Params_init(&i2cParams);
  i2cParams.bitRate = I2C_400kHz;
  i2c               = I2C_open(CONFIG_I2C, &i2cParams);
	if (i2c == NULL)
		{
		DBG ("Error Initializing I2C\n");
		while (1) {}
		}

  /* Common I2C transaction setup */
  i2cTransaction.writeBuf   = txBuffer;
  i2cTransaction.writeCount = 1;
  i2cTransaction.readBuf    = rxBuffer;
  i2cTransaction.readCount  = 0;

  i2cTransaction.targetAddress = MAX31334_I2C_ADDR;
  txBuffer[0]                  = 0x1;	// from INT_EN

	I2C_transfer(i2c, &i2cTransaction);
	//Task_sleep (_TO_TICK(10));

	i2cTransaction.writeBuf   = txBuffer;
  i2cTransaction.writeCount = 4;
  i2cTransaction.readBuf    = rxBuffer;
  i2cTransaction.readCount  = 0;

  txBuffer [0] = 0x01;				// INT_EN (0x1)
  txBuffer [1] = 0;						// RTC_RESET (0x2)
  txBuffer [2] = 0b00010011;	// RTC_CONFIG1 (0x3). Alarm1 auto clear after 100msec, interrupt low active, Enables I2C timeout, osc enable
  txBuffer [3] = 0b00000011;	// RTC_CONFIG2 (0x4). Alarm1->/INTB pin

	if (I2C_transfer(i2c, &i2cTransaction))
		{
		}
  I2C_close(i2c);