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
  • Hi,

    The reason why your code is not working, is that you are initializing two TWI interfaces on the same serial interface. One address only support one interface at the time. You can see which addresses support which interfaces on this page.

    You need to change the line:

    static const nrf_drv_twi_t m_twi_bio = NRF_DRV_TWI_INSTANCE(0);
    

    to:

    static const nrf_drv_twi_t m_twi_bio = NRF_DRV_TWI_INSTANCE(1);
    

    Best regards,

    Jørgen

  • 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!

Reply
  • 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!

Children
No Data
Related