How to configure i2c rx71m using smart configurator

Hi,

I am working on a master with multiple slave devices. In one configuration, my temperature and humidity sensor are working correctly, but my pressure sensor is not responding with the same configuration.

I have attached a screenshot of my configuration for reference. Could you please guide me on the I2C configuration?

Thanks and regards,
Ashok

  • Hello Ashok,

    It seems that you want to use low level Code Generator (CG) I2C Master Mode on channel 0. Nevertheless that I don't know your pressure sensor model available, the settings seem to be ok.

    From my side, I would enable the user callbacks of transfer end, receive end and error, in order to have access on them, when they will be triggered.

    Also, check the Chapter 4.2.18 from the manual below that shows how to use correctly the available APIs:

    Smart Configurator User's Manual RX API Reference (renesas.com)

    Αlso, on page 235, you will find a simple example for RIIC.

    Regards,

    AL_Renesas

  • Hi AL_Renesas,

    The provided example used in code, but I want the configuration image.

    I'm not using FIT module.

    Thanks and regards
    Ashok

  • Dear ashok,

    Your configuration settings seem ok to me, but can you please send your pressure sensor model?

    Thanks

  • Hi AL_Renesas,

    Thanks for your response. I have attached my project below please find.

    Pressure sensor - MS5837-02BA21

    here i'm getting error bus busy error

    Thanks and regards,

     

    pressure.zip

  • Hello ashok,

    I cannot debug your project, but after checking it and based on the error that you receive, I have some comments:

    First of all, a typical digital analyzer would help you and us to debug your issue easier and faster.

    Secondly, the ICCR2.BIT.BUSY that you receive, happens from the first I2C_write function or  after some I2C writings/readings?

    In general, this error declares that the SDA line has already been driven low from something else, by another master device or maybe by a faulty hardware configuration.

    Are you sure that you have connected the SCL, SDA pins with pull up resistors to the Vcc and nothing else is used on the same circuit that can affects the SDA line?

    Regards,

    AL_Renesas

  • Hi AL_Renesas,

    I checked the SCL and SDA pins, and they have pull-up resistors connected to VCC.

    Thanks and regards,
    Ashok

  • Can you please check using an oscilloscope the state of the SDA before starting I2C communication?

    Also, can you please answer to my previous question, if you can observe it on the start of the communication or after sending/receiving some data with the device?

    Thanks

  • Hello ashok,

    Any update about this issue?

    Regards,

    AL_Renesas

  • Hi AL_Renesas,

    Sorry for the delay,I'm trying to read another sensor ls LSM6DSO but in this case i'm not getting any i2c frame 

    can you please suggest one example of i2c configuration.

    i have attached logic analyzer frames and configuration of i2c also.

    /***********************************************************************
    *
    * FILE : dem.c
    * DATE : 2024-09-12
    * DESCRIPTION : Main Program
    *
    * NOTE:THIS IS A TYPICAL EXAMPLE.
    *
    ***********************************************************************/
    #include "r_smc_entry.h"
    #include "lsm6dso_reg.h"
    #include "stdlib.h"
    #include "string.h"


    #define SENSOR_BUS LSM6DSO_I2C_ADD_L

    uint8_t txbuff[10];

    //txbuff[0] = reg;
    //memcpy(&txbuff[1],bufp,len);

    //ms5837_t sensor = { 0 };

    static int16_t data_raw_acceleration[3];
    static int16_t data_raw_angular_rate[3];
    static int16_t data_raw_temperature;
    static float acceleration_mg[3];
    static float angular_rate_mdps[3];
    static float temperature_degC;
    static uint8_t whoamI, rst;
    static uint8_t tx_buffer[1000];

    void main(void);
    static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
    uint16_t len);
    static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
    uint16_t len);

    /*
    * @brief Write generic device register (platform dependent)
    *
    * @param handle customizable argument. In this examples is used in
    * order to select the correct sensor bus handler.
    * @param reg register to write
    * @param bufp pointer to data to write in register reg
    * @param len number of consecutive register to write
    *
    */
    static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
    uint16_t len)
    {
    uint8_t txbuff[3];
    txbuff[0] = reg;
    memcpy(&txbuff[1],bufp,len);

    R_Config_RIIC0_Master_Send_Without_Stop(LSM6DSO_I2C_ADD_L,txbuff,len);
    return 0;
    }

    /*
    * @brief Read generic device register (platform dependent)
    *
    * @param handle customizable argument. In this examples is used in
    * order to select the correct sensor bus handler.
    * @param reg register to read
    * @param bufp pointer to buffer that store the data read
    * @param len number of consecutive register to read
    *
    */
    static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
    uint16_t len)
    {
    uint8_t rxbuff[3] = {0};
    uint8_t txbuff[3] = {0};
    txbuff[0] = reg;
    R_Config_RIIC0_Master_Send(LSM6DSO_I2C_ADD_L,txbuff,len);
    R_BSP_SoftwareDelay(20, BSP_DELAY_MILLISECS);
    R_Config_RIIC0_Master_Receive(LSM6DSO_I2C_ADD_L,rxbuff,len);

    return 0;
    }


    void main(void)
    {

    R_Config_PORT_Create();
    R_Config_RIIC0_Create();
    R_Config_RIIC0_Start();

    stmdev_ctx_t dev_ctx;
    /* Initialize mems driver interface */
    dev_ctx.write_reg = platform_write;
    dev_ctx.read_reg = platform_read;
    // dev_ctx.handle = LSM6DSO_I2C_ADD_L;

    R_BSP_SoftwareDelay(10, BSP_DELAY_MILLISECS);

    lsm6dso_device_id_get(&dev_ctx, &whoamI);

    if (whoamI != LSM6DSO_ID)
    while (1);

    /* Restore default configuration */
    lsm6dso_reset_set(&dev_ctx, PROPERTY_ENABLE);

    do {
    lsm6dso_reset_get(&dev_ctx, &rst);
    } while (rst);

    /* Disable I3C interface */
    lsm6dso_i3c_disable_set(&dev_ctx, LSM6DSO_I3C_DISABLE);
    /* Enable Block Data Update */
    lsm6dso_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
    /* Set Output Data Rate */
    lsm6dso_xl_data_rate_set(&dev_ctx, LSM6DSO_XL_ODR_12Hz5);
    lsm6dso_gy_data_rate_set(&dev_ctx, LSM6DSO_GY_ODR_12Hz5);
    /* Set full scale */
    lsm6dso_xl_full_scale_set(&dev_ctx, LSM6DSO_2g);
    lsm6dso_gy_full_scale_set(&dev_ctx, LSM6DSO_2000dps);
    /* Configure filtering chain(No aux interface)
    * Accelerometer - LPF1 + LPF2 path
    */
    lsm6dso_xl_hp_path_on_out_set(&dev_ctx, LSM6DSO_LP_ODR_DIV_100);
    lsm6dso_xl_filter_lp2_set(&dev_ctx, PROPERTY_ENABLE);

    /* Read samples in polling mode (no int) */
    while (1) {
    uint8_t reg;
    /* Read output only if new xl value is available */
    lsm6dso_xl_flag_data_ready_get(&dev_ctx, &reg);

    if (reg) {
    /* Read acceleration field data */
    memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
    lsm6dso_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
    acceleration_mg[0] =
    lsm6dso_from_fs2_to_mg(data_raw_acceleration[0]);
    acceleration_mg[1] =
    lsm6dso_from_fs2_to_mg(data_raw_acceleration[1]);
    acceleration_mg[2] =
    lsm6dso_from_fs2_to_mg(data_raw_acceleration[2]);
    sprintf((char *)tx_buffer,
    "Acceleration [mg]:%4.2f\t%4.2f\t%4.2f\r\n",
    acceleration_mg[0], acceleration_mg[1], acceleration_mg[2]);
    }

    lsm6dso_gy_flag_data_ready_get(&dev_ctx, &reg);

    if (reg) {
    /* Read angular rate field data */
    memset(data_raw_angular_rate, 0x00, 3 * sizeof(int16_t));
    lsm6dso_angular_rate_raw_get(&dev_ctx, data_raw_angular_rate);
    angular_rate_mdps[0] =
    lsm6dso_from_fs2000_to_mdps(data_raw_angular_rate[0]);
    angular_rate_mdps[1] =
    lsm6dso_from_fs2000_to_mdps(data_raw_angular_rate[1]);
    angular_rate_mdps[2] =
    lsm6dso_from_fs2000_to_mdps(data_raw_angular_rate[2]);
    sprintf((char *)tx_buffer,
    "Angular rate [mdps]:%4.2f\t%4.2f\t%4.2f\r\n",
    angular_rate_mdps[0], angular_rate_mdps[1], angular_rate_mdps[2]);
    // tx_com(tx_buffer, strlen((char const *)tx_buffer));
    }

    lsm6dso_temp_flag_data_ready_get(&dev_ctx, &reg);

    if (reg) {
    /* Read temperature data */
    memset(&data_raw_temperature, 0x00, sizeof(int16_t));
    lsm6dso_temperature_raw_get(&dev_ctx, &data_raw_temperature);
    temperature_degC =
    lsm6dso_from_lsb_to_celsius(data_raw_temperature);
    sprintf((char *)tx_buffer,
    "Temperature [degC]:%6.2f\r\n", temperature_degC);
    // tx_com(tx_buffer, strlen((char const *)tx_buffer));
    }
    }


    while(1)
    {

    }
    }

    receive i2c part going in bus is busy.

    Above code is working with stm32 borad please suggest me this part.

    Thanks and regards,

    Ashok