I2C communication between Renesas MCU(master) -> nRF5340(slave).

Hello Nordic Team,

I am using nRF5340 DK as a debugger/programmer to develop firmware for the Fanstel EV-WT02C40C module.
My goal is to do i2c communication between Renesas MCU and  EV-WT02C40C board with nRF Connect SDK.

I have a few i2c communication related questions and would appreciate clarification.

SDK:         nRF Connect SDK v3.2.1
Toolchain: nRF Connect SDK Toolchain v3.2.1

here i'm considering renesas MCU as master and nrf5340 MCU as slave. renesas mcu send data to nrf5340 mcu which i will publish on server with the help of wifi and MQTT

which sample code should i refer for my i2c communication query? 

  • hi,

    still im facing same problem, data writing from master to slave is working fine
    but when master(controller) trying to read data from slave, slave is not sending data on bus.

    during reading from slave,  just address + ack bit is coming. data is missing

    i tried with both method 
    buffer method and non-buffer method. both method giving same result

  • Hi,

    Do you still get the hard-fault ? Can you show me the full logs, to see if they are the exact same?

    Have you updated the main.c, the prj.conf and the nrf5340dk_nrf5340_cpuapp.overlay with the code that I sent you?

    It sounds strange that it still happens, because I tried the reading and writing on this sample, and it worked on my end... Can you maybe also show me the firmware that you use as a master ?

    Best regards,

    Simon D-M

  • Hey Simon D-M,

    Thank you very much for your help.

    I managed to fix the I2C master transmit and receive issue. The problem was actually coming from the code snippet below:

    static int sample_target_buf_read_requested_cb(struct i2c_target_config *config,
                                                   uint8_t **data, uint32_t *size)
    {
        // printk("sample target buffer read requested\n");
        // static uint8_t buffer[1] = {0x44};
        *data = rx_buf;
        *size = sizeof(rx_buf);
        return 0;
    }

    When these two lines were enabled:

    printk("sample target buffer read requested\n");
    static uint8_t buffer[1] = {0x44};

    they introduced a small delay. Since this function is executed inside a callback context, the delay was not acceptable and the I2C read operation was failing.

    After commenting out these lines, the code works perfectly and the I2C master can now transmit and receive data correctly.

    Thanks again for your support!



Related