I2C/ TWI example for nRF Connect SDK

I am using a I2C based sensor for my project. I referred to the example projects in the nRF Connect SDK as well as online tutorial for this. 

I have 2 questions on the same.

1. My sensor has no default driver available for nRF platform, so can I still use this example. https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-6-serial-com-i2c/topic/exercise-1-6-2/ . The reason I am asking because, if I use this, I am not able to read/ write to 8-bit register address of the sensor. Getting the below error.

Can you help me fix this or guide me through appropriate examples for my use case.

2. I see that there is a major difference in the way I2C/ TWI is handled between the examples provided in the IDE (tx_rx_blocking, tx_rx_non_blocking, txrx, txtx) and this example: https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-6-serial-com-i2c/topic/exercise-1-6-2/

The way I2C/ TWI is configured and the APIs used are totally different between the two. Wanted to understand the use case of both types of examples so that I can choose the example appropriately.

I am using nRF53 series board with nRF Connect SDK IDE.

  • Hi Dessksha

    1. I would recommend having a look at the custom driver section in the NCS intermediate course 

    Just to start with, from what I can see in top of your image. You are using NCS 2.5 RC1? I would recommend upgrading to 2.6 or at least 2.5.2 as release candidates are not recommend for development. 

    Could you show me your overlay and i2c implementation? As of now I don't really have much to go with. 

    2. 

    "Blocking communication means that the MCU stalls until the byte is transferred from the data register. In the code, this is usually implemented as checking of the status bit in the “while” loop. However, this approach might not be applicable for some time-critical applications"

    Note: TX-RX and TX-TX transfers are supported only in non-blocking mode.

    You can read about them here and I honestly don't think they will be relevant for you

    Regards

    Runar

Related