flexio_i2c length overflow issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

flexio_i2c length overflow issue

Jump to solution
2,144 Views
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 Solution
1,802 Views
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

View solution in original post

4 Replies
1,802 Views
zzqq
Contributor III

32个赞

0 Kudos
Reply
1,803 Views
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

1,802 Views
cheney
Contributor III

Get it.

Thanks a lot.

1,802 Views
zzqq
Contributor III

32个赞