flexio_i2c length overflow issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

flexio_i2c length overflow issue

跳至解决方案
3,734 次查看
cheney
Contributor III

Hi,

   I use flexio_iic to read the eeprom. and  I found a issue when the reading length is over 13 using flexio_i2c.

   I traced the code. i found there's a overflow in function <FLEXIO_I2C_DRV_MasterSetBytesNo>.

static void FLEXIO_I2C_DRV_MasterSetBytesNo(FLEXIO_Type *baseAddr, const flexio_i2c_master_state_t *master)
{
1     uint16_t timerCmp;
 2    uint32_t bytesNo;
 3    uint8_t resourceIndex;    /* Index of first used internal resource instance (shifter and timer) */

 4    resourceIndex = master->flexioCommon.resourceIndex;
 5    /* Compute number of SCL ticks, including address */
 6    bytesNo = master->txRemainingBytes;
 7    bytesNo = (bytesNo * 18U) + 1U;
 8    /* Set number of ticks in low part of timer compare register */
 9    timerCmp = FLEXIO_HAL_GetTimerCompare(baseAddr, SCL_TIMER(resourceIndex));
 10   timerCmp = (uint16_t)((timerCmp & 0x00FFU) | (uint16_t)((bytesNo & 0xFFU) << 8U));
  11  FLEXIO_HAL_SetTimerCompare(baseAddr, SCL_TIMER(resourceIndex), timerCmp);
}

  According to the reading length 14, the master->txRemainingBytes is 15 and  we can calculate the final bytesNo 0x10f(271).But after excute the line 10, we can see the higher 8 bits of bytesNo is ignored.And it leads to a error execution.

   So how can i read bytes over 13?

1 解答
3,392 次查看
raresvasile
NXP Employee
NXP Employee

Hi,

This is a known limitation of FlexIO I2C driver, it cannot handle transfers larger than 13 bytes.

In order to transfer data larger than 13 bytes you can perform multiple transfers with data size <= 13 in order to send/receive the desired amount of payload.

If there are constraints of the slave device that restricts the transfer to be performed only once with the whole data you can use the LPI2C driver.

Best regards,

Rares

在原帖中查看解决方案

4 回复数
3,392 次查看
zzqq
Contributor III

32个赞

0 项奖励
回复
3,393 次查看
raresvasile
NXP Employee
NXP Employee

Hi,

This is a known limitation of FlexIO I2C driver, it cannot handle transfers larger than 13 bytes.

In order to transfer data larger than 13 bytes you can perform multiple transfers with data size <= 13 in order to send/receive the desired amount of payload.

If there are constraints of the slave device that restricts the transfer to be performed only once with the whole data you can use the LPI2C driver.

Best regards,

Rares

3,392 次查看
cheney
Contributor III

Get it.

Thanks a lot.

3,391 次查看
zzqq
Contributor III

32个赞