AnsweredAssumed Answered

flexio_i2c length overflow issue

Question asked by 何纯 陈 on Aug 2, 2017
Latest reply on Aug 6, 2017 by zzqq

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?

Outcomes