Sensor integration issue

Hello ,

- We are using DA14531 for our development.

- Have interface TPMS pressure sensor with DA14531 over I2C . and we are using DA14531 as I2C slave.-

- Firstly I have interfaced sensor with only peripheral I2C code and its working fine, can able to read the data.(E:\Dialog\Multilink\SW_Examples\DA145xx_SDK\6.0.14.1114\projects\target_apps\peripheral_examples\I2C-Master-Slave\I2C_Slave)

- the I merged my I2C code with central code of software example below is the path, when i try to run its stuck at assert warning path, not able to read the data. Please suggest why code getting hang when i merge with BLE Central code.

E:\Dialog\Multilink\SW_Examples\BLE_SDK6_examples-main_c\connectivity\central

Please suggest.

Thanks in advance

Pavan S K

Parents
  • Hi Pavan,

    Thank you for posting your question online.
    Have you configured your I2C pins and initialization inside the user_periph_setup.c/h files?
    Did you just copy the files you were interested inside the central example?
    Your projects get this assert warning during initialization?

    Kind Regards,
    OV_Renesas

  • Hi,

    Yes , I have initialized in user_periph_setup.h, Yes i have merged working I2C program into the cental and yes project gets asser warning in initialization.

    Thanks in advance

    Pavan S K3276.central.zip

  • Hi,

    Waiting for your reply.

    Thanks in advance

    Pavan S K

  • Hi Pavan,

    Thank you for the reply. 
    I downloaded your project and placed it inside the SDK v6.0.14. 
    I used the python script available for the GitRepo examples in order to set the paths correctly but I am not able to compile your project. 
    I am getting errors regarding the user_periph_setup.c/h files.
    Can you explain what these variables do and from where you have used extern for them?

    extern uint8_t transmit_buffer[16];
    extern uint8_t receive_buffer[16];

    I can also see you had undefined the GPIO_reservations function by keeping undefined the DEVELOPMENT_DEBUG macro. 
    You have not initialzied your I2C pins inside the GPIO_reservations function and on the set_pad_functions as well.
    I am not sure what the write_buffer_initialization does as well.
    And instead of this:
     memset(&i2c_configuration, 0, sizeof(i2c_configuration));
        i2c_configuration.speed = I2C_SPEED_MODE;
        i2c_configuration.mode = I2C_MODE_SLAVE;
        i2c_configuration.addr_mode = I2C_ADDRESS_MODE;
        i2c_configuration.address = I2C_TARGET_ADDRESS;
        i2c_configuration.clock_cfg.fs_hcnt = I2C_FS_SCL_HCNT_REG_RESET;
        i2c_configuration.clock_cfg.fs_lcnt = I2C_FS_SCL_LCNT_REG_RESET;
        i2c_configuration.clock_cfg.ss_hcnt = I2C_SS_SCL_HCNT_REG_RESET;
        i2c_configuration.clock_cfg.ss_lcnt = I2C_SS_SCL_LCNT_REG_RESET;

    You should use this:
       // Configuration struct for I2C
        static const i2c_cfg_t i2c_cfg = {
        .clock_cfg.ss_hcnt = I2C_SS_SCL_HCNT_REG_RESET,
        .clock_cfg.ss_lcnt = I2C_SS_SCL_LCNT_REG_RESET,
        .clock_cfg.fs_hcnt = I2C_FS_SCL_HCNT_REG_RESET,
        .clock_cfg.fs_lcnt = I2C_FS_SCL_LCNT_REG_RESET,
        .restart_en = I2C_RESTART_ENABLE,
        .speed = I2C_SPEED_MODE,
        .mode = I2C_MODE_SLAVE,
        .addr_mode = I2C_ADDRESS_MODE,
        .address = I2C_TARGET_ADDRESS,
        .tx_fifo_level = 1,
        .rx_fifo_level = 1,
        };

    And place it inside your periph_init function before the GPIO_set_pad_latch_en function.

    Kind Regards,
    OV_Renesas

  • Hi sir,

    Thanks for your input. we have done the suggested change. Now we are not getting ASSERT_WARNING. But in I2C function have one counter(variable) which need to be incremented but it is not happening.  

    MCU is not coming out from highlighted while loop. As a result MCU is going to nmi_handlerc as shown below.

    please find the attached code link below.

    https://smetgroup-my.sharepoint.com/:u:/g/personal/ravi_mysmindia_com/ESI5TrQuaIlDn04IcpBgIrYBlw49gqEs1mk9uVKdVtmkRw?e=PyV9Gs 

    Please suggest the required changes. 

    Thanks in Advance

    Ravi Kumar Anand.

  • Hi ,

    Sunny has  updated the issue behalf of me please suggest.

    Thanks in advance

    Pavan S K

  • Hi Ravi, Pavan,

    Thank you for the reply.
    Let me check on this and I will get back to you.

    Kind Regards,
    OV_Renesas

  • Hi,

    Waiting for your inputs.

    Thanks, in advance.

    Pavan s k

  • Hi Pavan, Ravi,

    Apologies for the delay.
    I was not able to build the project you have shared.
    I tried on SDK v6.0.18, v6.0.16, v6.0.14 and I always get this error:

    Also I am not able to find the i2c_slave_receive_transmit function anywhere inside the project you have shared. 
    Have you made any modifications inside the i2c.c/h files? 
    Can you share more infromation regarding your project idea?
    You have a central device, that is constantly reading data from a I2C sensor? Have you implemented any interrupt for this? 
    Could you please probe a logic analyzer on the Pins you have configured for I2C communication so we can see exactly what is happening?
    Also, from my understanding this I2C implementation was working on each own, but when merged with the central project leads on this NMI handler. Please correct me if I am mistaken.
    I can also see from your project that you have enabled Extended Sleep mode. Are you handling the sleep mode when you are trying to read the sensor data via I2C?

    Kind Regards,
    OV_Renesas

  • Hi sir,

    Thanks for your information.

    Please find the attached link for SDK where we have configured i2c slave in the below path.

    link - https://smetgroup-my.sharepoint.com/:f:/g/personal/ravi_mysmindia_com/EnL-STLNG6xDnEOkpM1W4TsB-P6_FNOFHbO9zb8-UVh-pQ?e=A53RWT

    File path - DA145xx_SDK\6.0.16.1144\projects\target_apps\peripheral_examples\i2c\i2c_eeprom

    Kind helps us to merge i2c slave(from the attached link above) with the central code. it's bit urgent for us.  

    Thanks for your support in advance. 

  • Hi Ravi,

    Thank you for the reply.
    I was able to build your project. 
    You have modified the sdk folders. 
    We highly recommend to NOT modify the SDK_folders unless it is necessary.
    You have heavily modified the main function inside the arch_main.c file.
    The SDK is supported as it is.
    You should not have added the i2c_slave_receive_transmit function there.By doing that you are messing with the scheduler. 
    You should start and call the I2C initialization and transmit/receive functions inside the user folders. 
    The i2c_slave_receive_transmit function you have added in the arch_main.c file should be moved on the user folders as well.
    Could you also kindly share a high-level overview of the project steps? I can see you have the default_app_on_init callback function enabled, so when do you want to start to get sensor reading via I2C?
    How often are you going to get measurements? Do you want to implement any sleep-mode into your project? 

    Kind Regards,
    OV_Renesas

Reply
  • Hi Ravi,

    Thank you for the reply.
    I was able to build your project. 
    You have modified the sdk folders. 
    We highly recommend to NOT modify the SDK_folders unless it is necessary.
    You have heavily modified the main function inside the arch_main.c file.
    The SDK is supported as it is.
    You should not have added the i2c_slave_receive_transmit function there.By doing that you are messing with the scheduler. 
    You should start and call the I2C initialization and transmit/receive functions inside the user folders. 
    The i2c_slave_receive_transmit function you have added in the arch_main.c file should be moved on the user folders as well.
    Could you also kindly share a high-level overview of the project steps? I can see you have the default_app_on_init callback function enabled, so when do you want to start to get sensor reading via I2C?
    How often are you going to get measurements? Do you want to implement any sleep-mode into your project? 

    Kind Regards,
    OV_Renesas

Children
  • Hi,

    Since were not much aware of the SDK modifications. We did above configurations. Below are our requirements,

    1) We want to implement hibernation sleep mode in central profile with I2C_slave integrated.

    2) Sensor will wake up the DA14531 withy GPIO interrupt at every 1 minute, then DA14531 will wake up reads the sensor data and send it to the peripheral and goes to hibernation mode again, same procedure will repeat every time.

    3) please help to add my I2C_slave code as per your method into the Central profile with low power modes.

    link - https://smetgroup-my.sharepoint.com/:f:/g/personal/ravi_mysmindia_com/EnL-STLNG6xDnEOkpM1W4TsB-P6_FNOFHbO9zb8-UVh-pQ?e=A53RWT

    File path - DA145xx_SDK\6.0.16.1144\projects\target_apps\peripheral_examples\i2c\i2c_eeprom

    Thanks, in advance.

    Ravi

  • Hi Ravi,

    Thank you for the reply.
    Let me try to help you with your requirements:
    1) We want to implement hibernation sleep mode in central profile with I2C_slave integrated.
    For the Hibernation Sleep Mode please refer on the prox_reporter example.
    Please refer on the following guides:
    7. Hibernation Mode configuration — DA145XX Tutorial Sleep Modes (renesas.com)
    3. BLE Development Environment and First Application — DA14585/DA14531 SW Platform Reference Manual (renesas.com)
    And on our Hibernation Git Example:
    BLE_SDK6_examples/connectivity/hibernation_and_stateaware_hibernation at main · dialog-semiconductor/BLE_SDK6_examples · GitHub
    Regarding the I2C slave sensor you can check our available I2C sensor examples from our GitRepo:
    BLE_SDK6_examples/connectivity/ble_pressure_sensor_bmp388 at main · dialog-semiconductor/BLE_SDK6_examples · GitHub
    BLE_SDK6_examples/interfaces/accel-Sensor at main · dialog-semiconductor/BLE_SDK6_examples · GitHub
    BLE_SDK6_examples/interfaces/I2C-Master-Slave at main · dialog-semiconductor/BLE_SDK6_examples · GitHub
    Regarding I2C implementation:
    Make sure you have declared the Pins you want on user_periph_setup.h file and that you reserve/configure the Pins with the appropriate functions on the user_periph_setup.c file.
    You can see how the examples above configured the I2C in order to achieve communication. 
    Check the datasheet of your sensor in order to configure the Sensor sleep modes accordingly.
    Keep in mind that you cannot have I2C communication with any sleep mode enabled. Each time you want to get an I2C measurement, you will have to wake-up, disable the sleep modes, get the measurement and get back to sleep.
    2)Sensor will wake up the DA14531 withy GPIO interrupt at every 1 minute, then DA14531 will wake up reads the sensor data and send it to the peripheral and goes to hibernation mode again, same procedure will repeat every time.
    As stated before, check the prox_reporter example in order to see how you can go into Hibernation Sleep mode and how to configure a GPIO in order to wake-up. You will have to configure the wake-up controller and when the wake-up procedure is over, you should start scanning in order to find your peripheral. After connection is established, you can wake-up your I2C sensor and enable the I2C. After that you can send your sensor data by updating a characteristic or multiple characteristics. 
    After that, you should terminate the connection and go to hibernation sleep mode. 
    My main concern is that you stated that the GPIO interrupt will happen every 1 minute, how are you going to implement this? If you want to wake-up exactly every 1 minute you can consider the Deep Sleep mode which can wake-up via RTC or Timer1. (Both those implementations are inside the prox_reporter example).

    3)help to add my I2C_slave code as per your method into the Central profile with low power modes.
    From my understanding, you have already managed to have an I2C communication with your sensor and you just want to implement this into the central example. I will have to highlight again, that you should build your application only on the user_folders. If you modify the sdk folders you might end up messing the timings and features of the SDK.

    You should create sensor_i2c.h/.c files which will have all the appropriate configuration for your sensor. The functions to get the measurements , the function to get the sensor into sleep mode, the function to get the sensor to wake-up etc.
    Follow the examples I shared above to see how to implement the I2C configuration on the user_periph_setup.h/.c files and after that use the functions you have created for your sensor to get the measurements when you have established a connection.

    Kind Regards,
    OV_Renesas

  • Hi sir, 

    Thanks for your input. We have tried multiple times to merge I2C slave with Central profile and hibernation sleep mode. we are not able to do it. Please help to merge above attached I2C with central profile.