Changing max i2c transfer byte size (Zephyr + nRF Connect SDK)

Hi there,

 

I am running nRF Connect SDK 2.5.2 using the nrfx i2c TWI driver with Zephyr.

 

I have a sensor device over i2c that I am communicating with. This device’s driver needs to send 32k data chunks over i2c. Since the data needing to be sent is stored in ROM, I modified the device tree’s zephyr,concat-buf-size and zephyr,flash-buf-max-size to be 64kB in the i2c instance to allocate the data in RAM during sending. The full max size that I thought was supported was 64kB (uint16_t max), as per the i2c_nrfx_twim_config struct’s msg_buf_size config variable used in i2c_nrfx_twim_transfer()

 

During the i2c transfers of the 32k writes, I am now getting the error message “<err> i2c_nrfx_twim: Need to use the internal driver buffer but its size is insufficient (2 + 32768 > 2048). Adjust the zephyr,concat-buf-size or zephyr,flash-buf-max-size property (the one with greater value) in the "i2c@40004000" node.”, showing that the i2c max size is only at 2k, and that im trying to send just over 32k. My questions are:

 

  1. Why do the device tree changes (64k) only allow the buffer size to go to 2k? See devicetree screenshot:
  2. Is the true max size 64k? I have seen other places on the Nordic forums saying it was anything from 255 Bytes to 64kB?
Parents
  • Hi,

    Why do the device tree changes (64k) only allow the buffer size to go to 2k? See devicetree screenshot:

    A uint16_t can't hold the number 65536, it can only hold numbers from 0 to 65535. Can you check if reducing it by 1 makes any difference? If this does not work, please check that the overlay is actually being applied to the build (you can check the generated devicetree in build/zephyr/zephyr.dts).

    Is the true max size 64k? I have seen other places on the Nordic forums saying it was anything from 255 Bytes to 64kB?

    The TWIM HW peripheral in nRF52840 has a 16-bit wide MAXCNT register, which means it can support up to 65535 bytes in each transfer. The size of the MAXCNT register differs between chip variant and peripheral, you can see an overview on this page.

    Best regards,
    Jørgen

  • My mistake! Of course, was my error; range 0-65535. I assumed the .dts field zephyr,concat-buf-size/zephyr,flash-buf-max-size "size" was a size, but its more of a "max value".

    Great reference for the max supported link, thank you. 

    Large transfers (~32k) are working for me now, thanks.

Reply Children
No Data
Related