Send more than 8192 bytes on nrf9160 using nrfx_twim

This has been asked before i2c message max buffer size but I need a little more info on the the proposed solution "break it up into chunks" from Oyvind.

Using nrfConnect SDK 1.6.1

The MAX32664 requires 8210 bytes in a flash write message between START and STOP conditions. Using the "drivers/i2c" this results in 18 bytes being sent due to TX.MAXCNT overflow.

Using the "drivers/i2c" driver provided you can send two chunks (4000 say, then 4210 bytes)- 1st without STOP and second with a STOP but this results in a repeated start being generated between the two transactions and the MAX32664 doesn't seem to like it.

is there a way to use the nrfx_twim.c driver to send the second chunk without the "repeated START". If anyone has done this with MAX32664 and nrf9160 and I'm sure someone has - any pointers or code fragments would be appreciated.

Mark

Parents
  • Hello Mark,

    For nRF9160, the MAXCNT registers are 13 bits wide (0-12) that means you should be able to transfer up to 8192 bytes (which also mentioned in your referred ticket). We do not have any example code when sensor cannot perform the repeated start.  In nRF52, one could use the legacy TWI peripheral, which does not have the same limitation on transfer length like nRF9160 (but would need to update data for each byte being transferred)

    You may try i2c_transfer function (this you can control by yourself, i2c_write has always a stop flag to stop) instead of i2c_write. 

    https://github.com/crfosse/ncs_projects/blob/main/peripheral_zephyr/i2c/src/main.c 

    Thanks.

    Best Regards,

    Kazi

  • Hi Kazi

    I tried your suggestion:

        // send more than 8192 bytes
        #if 1
       void I2C_longwrite_TWIM1( uint8_t address,  uint8_t *buffer, uint32_t length )
        {
            struct i2c_msg msg[2];

            nrf_gpio_pin_set(DBG_IO_1);
            msg[0].buf = (uint8_t *)&buffer[0];
            msg[0].len = length/2;
            msg[0].flags = I2C_MSG_WRITE ;

            msg[1].buf = (uint8_t *)&buffer[length/2];
            msg[1].len = length/2;
            msg[1].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

            i2c_transfer( i2c_dev1, &msg[0], 2, 0x55 );
            nrf_gpio_pin_clear(DBG_IO_1);
        }
        #endif
    But this sends [START][ADDR] [1st half of buffer] .... [START][ADDR][2nd half of buffer][STOP]
    Status read from the MAX32664 after this reports Error code.
    I need to send [START][ADDR][8192 bytes of data] [18 bytes of data] [STOP] to be successful. Any ideas on how you would get the TWIM to do that?
    Thanks
    Mark
Reply
  • Hi Kazi

    I tried your suggestion:

        // send more than 8192 bytes
        #if 1
       void I2C_longwrite_TWIM1( uint8_t address,  uint8_t *buffer, uint32_t length )
        {
            struct i2c_msg msg[2];

            nrf_gpio_pin_set(DBG_IO_1);
            msg[0].buf = (uint8_t *)&buffer[0];
            msg[0].len = length/2;
            msg[0].flags = I2C_MSG_WRITE ;

            msg[1].buf = (uint8_t *)&buffer[length/2];
            msg[1].len = length/2;
            msg[1].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

            i2c_transfer( i2c_dev1, &msg[0], 2, 0x55 );
            nrf_gpio_pin_clear(DBG_IO_1);
        }
        #endif
    But this sends [START][ADDR] [1st half of buffer] .... [START][ADDR][2nd half of buffer][STOP]
    Status read from the MAX32664 after this reports Error code.
    I need to send [START][ADDR][8192 bytes of data] [18 bytes of data] [STOP] to be successful. Any ideas on how you would get the TWIM to do that?
    Thanks
    Mark
Children
No Data
Related