The latest TWI example I can find is from 4 SDK revisions ago and uses old libraries. Is there a sample using the nrf_drv_twi library that is recommended for current development?
The latest TWI example I can find is from 4 SDK revisions ago and uses old libraries. Is there a sample using the nrf_drv_twi library that is recommended for current development?
Hi
I have made a simple example using the latest TWI driver in SDK 9. It is very basic;
I have used this example for a while myself just to get me started on a new TWI project. It is simple, but very handy just to see if you have everything connected and set up correctly.
Test examples for SDK 0.9.2, 10.0.0, and 11.0.0: twi-find-devices-on-bus.
EDIT: The folder path to your example .uvprojx file should look like this: "your_SDK9_folder\examples\peripheral\twi_simple_SDK9.0.0_v2\pca10028\arm5_no_packs\twi_simple_SDK9.0.0_v2.uvprojx". The example is meant to be used with the SDK folder structure in the .zip file here. It is not intended for use with the pack installer.
EDIT 2: Updated example: twi_simple_SDK9.0.0_v3.zip
EDIT 3: Response to the questions and comments below regarding build errors:
@NewToNordic is right in his answer below. The latest pack driver and library versions are v3.1.0 with e.g. new TWI drivers that are not compatible with the older examples. This is how I solved it:
#define TWI1_ENABLED 1.
This worked for me with the 2nd version example in my initial answer and my nRF51 DK kit.
The driver in SDK 9 configures the SDA and SCL pins with internal pullups. However, the pull ups are 13 kOhm, which is quite high, so I would recommend a couple of external ones as well. Especially if you are going to use clock speeds above 100 kHz.
The driver in SDK 9 configures the SDA and SCL pins with internal pullups. However, the pull ups are 13 kOhm, which is quite high, so I would recommend a couple of external ones as well. Especially if you are going to use clock speeds above 100 kHz.