This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Twi configuration for multiple slave devices

Hello,

I'm trying to configure two TWI slave devices on the same TWI bus on my custom board(nRF52832). One slave is RTC, and the other is a biosensor. The TWI configuration for RTC seems to work. So I adopt the similar configuration and switch to corresponding SCL, SDA pins for biosensor, but the initialization of custom board just stuck at bio_twi_init().

I've searched the devzone for relevant issues but still can't find the solution. TWI initialization sample code is as two_twi_slaves_main.c, please ignore whether it can be compiled.

Any suggestion would be great appreciated!

Many Thanks in advance!

Parents Reply Children
  • Thank you for your reply and reference.

    As a matter of fact, I just want to utilize the current TWI instance(i.e. NRF_DRV_TWI_INSTANCE(0)), so it's no need to initiate a new TWI instance. So what I've done was unnecessary. Finally, I figure out that all I have to do is to send i2c write/read with slave address of biosensor. ;) And the biosensor is ams as7000.

    But here comes another problem. When I try to send data(intel hex file) repeatedly (amount to 80KBytes) via I2C to biosensor, only about 40KBytes were transmitted successfully because of I2C timeout (i.e. NACK from as7000; maybe it's busy), I've tried to increase/decrease i2c timeout but still got 40KBytes at most. Do you have any ideas that I can try? Thanks a lot!

  • Are you able to provide a trace of the transfer from a logic analyzer? I haven't worked with AS7000, but if the transmission is aborted due to a NACK, it might be busy. Maybe you can ask the developer of the sensor?

  • i have two slaves connected on the same I2C pins on NRF52-DK, i created two I2C instances but i am unable to read/write to the two slaves, if i enable the two instances I2C stops working, does this mean that i need to share the same I2C instance for both slaves?

  • Tested my case with one TWI instance shared for both slaves, it works... So for future reference for everyone interested, if you are using only two I2C pins to connect multiple slaves you need only one TWI instance, otherwise if you are connecting the slaves on different I2C pins you need multiple TWI instances...

  • So, as I understand it, in Nordic Thingy 52 application,

    - all sensors except the motion sensor (lis2dh12) are interfaced on one TWI bus (TWI_SCL and TWI_SDA)

    - while the motion sensor is interfaced to a different TWI bus (TWI_SCL_EXT andd TWI_SDA_EXT)

    For each instance a dedicated nrf_drv_twi_init() is required?

    For each individual sensor on a TWI bus a dedicated event handler is also required so that it works in non-blocking mode.

    So, suppose I want to interface an I2C sensor to the default Nordic Thingy 52 application:

    1. I should physically connect the sensor with TWI external bus (TWI_SCL_EXT and TWI_SDA_EXT)

    2. I should use the TWI external bus instance to initialize the config params and event handler.

    How come the Nordic Thingy 52 application have same twi_instance for motion sensor as that of other sensors?

Related