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

AT24C512 + BMI160 + NRF52

Hi,

I am using nRF52832 soc to develop my project. with nRF5_SDK_15.3 . SES file

I need to connect both BMI160 accelerometer sensor and AT24C512 EEPROM ic in TWI.

how to use TWI with this. guide me to use both at a time.

BMI160 separately i can read the data.

but i can't read while connect to AT24C512

Parents
  • Hi, 

    I recommend reading the TWIM chapter and the TWIS chapter in the product specification for nRF52832.

    The master device (TWIM) is in your case the nRF58832, while sensor and EEPROM are slaves. 

    If your nRF52832 will work as a slave (TWIS), then you need another microcontroller functioning as a master.

    You will find a suitable example to communicate with two devices in the TWI Transaction Manager Example which I linked to yesterday.

    Kind regards,
    Øyvind

  • Hi, Can you please tell me what is the difference of  TWI0 and TWI1

    #ifndef TWI0_ENABLED
    #define TWI0_ENABLED 1
    #endif
    // <q> TWI0_USE_EASY_DMA  - Use EasyDMA (if present)
     
    
    #ifndef TWI0_USE_EASY_DMA
    #define TWI0_USE_EASY_DMA 1
    #endif
    
    // </e>
    
    // <e> TWI1_ENABLED - Enable TWI1 instance
    //==========================================================
    #ifndef TWI1_ENABLED
    #define TWI1_ENABLED 0
    #endif
    // <q> TWI1_USE_EASY_DMA  - Use EasyDMA (if present)
     
    
    #ifndef TWI1_USE_EASY_DMA
    #define TWI1_USE_EASY_DMA 0
    #endif

    shall i enable both twi instance.

    what is

    TWI0_USE_EASY_DMA 1  - use case?

    #define TWI1_USE_EASY_DMA 0 - use case?

    if i enable both twi instance

    means

    the EASY_DMA of TWI1 also be '1' or '0'

  • Thank you,

    i understand what awneil going to tell. but my concern is to make multiple slaves for a one master is getting complexes.

    can yu please explain how this example works.

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html&cp=5_0

    can you please how these functions are working:

    NRF_TWI_MNGR_DEF(m_nrf_twi_mngr, MAX_PENDING_TRANSACTIONS, TWI_INSTANCE_ID);
    APP_TIMER_DEF(m_timer);
    
    
    
     err_code = nrf_twi_mngr_init(&m_nrf_twi_mngr, &config);
        APP_ERROR_CHECK(err_code);
        
        
        
         APP_ERROR_CHECK(nrf_twi_mngr_perform(&m_nrf_twi_mngr, NULL, lm75b_init_transfers,
            LM75B_INIT_TRANSFER_COUNT, NULL));
            
        APP_ERROR_CHECK(nrf_twi_mngr_perform(&m_nrf_twi_mngr, NULL, mma7660_init_transfers,
            MMA7660_INIT_TRANSFER_COUNT, NULL));
    

  • Sunil vignesh said:
    but my concern is to make multiple slaves for a one master is getting complexes.

     In your case, you should only need to configure one master. As long as the sensor and EEPROM are connected and powered correctly, you should only need to issue their address and then the command (as per the I2C standard).

     

    Sunil vignesh said:
    can yu please explain how this example works.

     Not sure what example you mean, as the link points to the start of the SDK documentation.

     

    Sunil vignesh said:
    can you please how these functions are working:

     These are part of the Common Application Error Handler, more information here and here.

    Kind regards,

    Øyvind

  • Not sure what example you mean, as the link points to the start of the SDK documentation.

    is this TWI Transaction Manager Example 

    <InstallFolder>\examples\peripheral\twi_master_using_nrf_twi_mngr

  • The application communicates over the two-wire interface (TWI) with two devices: the MMA7660 triple axis accelerometer and the LM75B temperature sensor.

    The example uses the RTC peripheral to generate regular tick events (32 per second). The interrupt handler, executed in reaction to each tick event, schedules data transfers to read the current values from the devices. The obtained values are averaged and printed every 500 milliseconds or when the tilting status reported by the accelerometer changes. Additionally, the user can generate asynchronous data transfer requests (reading all registers available in the devices) by pressing Button 1 or Button 4. Such additional transfer requests show that the TWI transaction manager library can schedule transfer requests from different contexts and realize them in the order they were scheduled.

  • the TWI transaction manager library can schedule transfer requests from different contexts and realize them in the order they were scheduled

    obviously, that adds a layer of complexity.

    The alternative is that you have to manage the bus accesses yourself in your own code so that the 2 sensors do not interfere with each other.

    If you have a simple use case, with only the 2 sensors, it may not be (too) difficult to manage this "manually"...

    But only you know the details of your application - so only you can decide what's appropriate to it.

Reply
  • the TWI transaction manager library can schedule transfer requests from different contexts and realize them in the order they were scheduled

    obviously, that adds a layer of complexity.

    The alternative is that you have to manage the bus accesses yourself in your own code so that the 2 sensors do not interfere with each other.

    If you have a simple use case, with only the 2 sensors, it may not be (too) difficult to manage this "manually"...

    But only you know the details of your application - so only you can decide what's appropriate to it.

Children
No Data
Related