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

Best TWI I2C driver for the nRF52832

Hi there,

I am trying to get I2C communication up and running with the nRF52832 (specifically configuring the nRF52832 as a master to communicate with 3 slave devices), and have been having some trouble. So far I have been working with the example code twi_sensor (twi_sensor_pca10040.emProject) and have tried running it with the initialy included nrf_dvr_twi functions, as well as altering it to use TWI and TWIM. I have been getting a large variety of errors and haven't really been able to narrow in on the cause. Before I spend more time on this, I want to make sure I am using the appropriate driver. Both the TWI and TWIM look as if they will work for my application, but it seems like the TWI is more complicated due to its relation with the legacy drivers? I do not need backwards compatibility so can I use TWIM as a standalone? Also, so far I've been unable to find any I2C/TWI examples using TWIM, does anyone know where I might be able to find some? Any advice would be greatly appreciated.

Thanks,

Charlie

Parents
  • Hi,

    If you want to stick with the drivers in the SDK, using nrf_drv_twi is the simplest to get started with as this is the one we provide examples for. The nrf_drv_twi is mainly a legacy layer to map the APIs to new nrfx driver implementations. Legacy driver integrates support for TWI and TWIM peripherals, while these are split into separate driver in nrfx (nrfx_twi and nrfx_twim). All implementation should work similar, but they have some changed APIs.

    Difference between TWI and TWIM peripherals is primarily the support for EasyDMA in TWIM (transfer/receive directly from/to RAM), for operations without CPU being involved.

    Best regards,
    Jørgen

Reply
  • Hi,

    If you want to stick with the drivers in the SDK, using nrf_drv_twi is the simplest to get started with as this is the one we provide examples for. The nrf_drv_twi is mainly a legacy layer to map the APIs to new nrfx driver implementations. Legacy driver integrates support for TWI and TWIM peripherals, while these are split into separate driver in nrfx (nrfx_twi and nrfx_twim). All implementation should work similar, but they have some changed APIs.

    Difference between TWI and TWIM peripherals is primarily the support for EasyDMA in TWIM (transfer/receive directly from/to RAM), for operations without CPU being involved.

    Best regards,
    Jørgen

Children
Related