NRFX_TWIM_EVT_OVERRUN when reading 256 bytes from I2C device

Hi,

I am working on a project using the nrf52832 with Zephyr.

I have an EEPROM-like device on an I2C bus connected to my nrf52832. The communication with the I2C device works fine when I read a couple of bytes or write a couple of bytes.

For reading, I use the i2c_write_read function from zephyr, with a num_write of 2 and a write_buf containing my register (0x2008 as little endian).

When I read 255 Bytes it works fine.

When I want to read 256 Bytes I get an NRFX_TWIM_EVT_OVERRUN  event from the TWIM driver.

If I read 128 Bytes from 0x2008 and then 128 Bytes from 0x2008+128 it works fine.

Is there any reason why I should not be able to read more than 255 Bytes from an I2C device using TWIM driver ?

Regards

Parents
  • Hi Nathan

    This is a hardware limitation in the TWIM (I2C master) peripheral of the nRF52832. The registers used to configure the length of the data buffer is only 8 bits in size which means it is limited to 255 bytes in one transaction, which you can see here.

    In the larger nRF52 series devices like the nRF52833 and nRF52840 this was increased to 16 bits. 

    As long as you are on the nRF52832 you would need to split larger transactions into multiple small ones, of size 255 or less (not including the I2C address). 

    Best regards
    Torbjørn

  • Is that case, maybe the I2C function should return errors like -EINVAL when the use tries to read or write more than 255 bytes ?

    I would expect this limitation to be contained and shown by the driver, especially with a hardware abstraction heavy environnement like Zephyr.

Reply Children
Related