Big latency in i2c writes

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

Big latency in i2c writes

跳至解决方案
1,405 次查看
Eximius
Contributor III

Hello,

I'm doing some latency tests with the i2c communication on the Imx8m Plus, measuring by software the wall time of the i2cwrite function (i2c_smbus_write_byte_data).

When setting the clock speed to 100KHz, single writes take about 500µs. With clock @400KHz, about 300µs.

I was expecting a single write to take something like 280µs (@100KHz) or 70µs (@400KHz). So I always get an overhead of about 220µs, independent of the clock frequency.

I also tried other I2C Buses and other I2C slaves, I always get a similar latency.

Can you advise how we can get closer of the 320kbps (Imx8m specification)?

标签 (1)
0 项奖励
回复
1 解答
1,354 次查看
Yuri
NXP Employee
NXP Employee

@Eximius 
Hello,

   generally it would be possible to use DMA with I2C, but NXP Linux does not support it.

  Nevertheless, according to i.MX Linux Reference Manual:

"It is strongly recommended not to use I2C SDMA mode when sending small amounts of data.
If there is a special case that needs to send a large amount of I2C data, contact NXP Pro-support
to get the patchset."

Regards,
Yuri

在原帖中查看解决方案

4 回复数
1,365 次查看
Eximius
Contributor III

@Yuri 

Hi,

thank you for your answer. I measured the i2c timings. For a whole i2c reg write it needs 115µs, this seems to be okay. And then there is pause of 176µs for the next SCL burst.

Can we optimize this?

0 项奖励
回复
1,355 次查看
Yuri
NXP Employee
NXP Employee

@Eximius 
Hello,

   generally it would be possible to use DMA with I2C, but NXP Linux does not support it.

  Nevertheless, according to i.MX Linux Reference Manual:

"It is strongly recommended not to use I2C SDMA mode when sending small amounts of data.
If there is a special case that needs to send a large amount of I2C data, contact NXP Pro-support
to get the patchset."

Regards,
Yuri

1,348 次查看
ceggers
Contributor V

SDMA support for I2C requires SDMA firmware 3.6/4.6. It is included in firmware-imx-8.12.bin. Additionally you need some small changes in the Linux drivers.

For larger transfers (I2C eeprom), I could increase performance by about 20%. For small transfers, I don't expect much benefit.

regards,
Christian

1,383 次查看
Yuri
NXP Employee
NXP Employee

@Eximius 
Hello,

   Is it possible to verify (using oscilloscope) if the latency takes place
because of incorrect I2C frequency setting or because of delays between
I2C bursts (with correct frequency)? The recent is quite expectable -
taking into account internal i.MX8 complexity.

Regards,
Yuri.

0 项奖励
回复