Re: I2C running on NRF52840


Andrzej G??bek
 

Hi Diana,

 

Writing "release 1.12.0" I meant this: https://github.com/zephyrproject-rtos/zephyr/releases.

Hence, I referred to the commit f58d9ca.

 

And as I wrote earlier, when you base on this commit, the only thing you need to build the "i2c_fujitsu_fram" sample is to use the following "prj.conf" file:

 

CONFIG_STDOUT_CONSOLE=y

CONFIG_PRINTK=y

 

CONFIG_I2C=y

CONFIG_I2C_NRF5=y

CONFIG_I2C_0=y

CONFIG_I2C_NRF5_0_GPIO_SDA_PIN=26

CONFIG_I2C_NRF5_0_GPIO_SCL_PIN=27

 

The value for CONFIG_I2C_0_IRQ_PRI will be taken from Device Tree, so there is no point in writing it in “prj.conf” as it will be discarded anyway.

If it does not work for you, make sure you have no other files modified and the build directory is clean. Nothing else comes to my mind, why it would not work.

 

But you cannot use the same configuration with the recent commits from master. Starting with the commit 1aa61d6, the old driver (i2c_nrf5.c) is not available, and you must use one of the new drivers, actually shims that use nrfx drivers underneath (either TWI or TWIM). Therefore, for the repository version that you cloned (commit 16ff8ca) you'll need the following "prj.conf":

 

CONFIG_STDOUT_CONSOLE=y

CONFIG_PRINTK=y

 

CONFIG_I2C=y

CONFIG_I2C_NRFX=y

CONFIG_I2C_0=y

CONFIG_I2C_0_NRF_TWI=y

 

And in the version you were using earlier (commit be52e3c) the issue was that the "i2c0" node was not enabled in DTS for the nrf52840_pca10056 board. Hence, labels NORDIC_NRF5_I2C_40003000_* were not generated. To make this work, a DTS overlay is needed, i.e. a file named “nrf52840_pca10056.overlay” placed in the same directory as “prj.conf” with the following content:

 

&i2c0 {

       status = "ok";

};

 

 

Best regards,

Andrzej

 

 

From: Diana Rivera [mailto:drv3007@...]
Sent: Monday, July 16, 2018 7:20 PM
To: Głąbek, Andrzej <Andrzej.Glabek@...>
Cc: Cufi, Carles <Carles.Cufi@...>; users@...
Subject: Re: [Zephyr-users] I2C running on NRF52840

 

Hi Andrzej,

Thanks a lot for your reply. I checked the version I was using, and it was: v1.11.0-244-gbe52e3c

However, I have just cloned the latest release: v1.12.0-803-g16ff8ca, and I'm unfortunately still getting the same error, as seen in the screen capture attached. Is there something else that I can try or that might be wrong? I have even tried that commit (f58d9ca) in particular, and have the same results.

Once again, thanks in advance for your help.

Best regards,

Diana

 

On Mon, Jul 16, 2018 at 10:48 AM, Głąbek, Andrzej <Andrzej.Glabek@...> wrote:

Hi Diana,

 

The config you provided is fine and you don’t need any other modifications to build the i2c_fujitsu_fram sample for the nrf52840_pca10056 board. You haven’t specified on which commit from the Zephyr repository you based your work on, so I tried with commit f58d9ca (i.e. release 1.12.0), and the sample built fine. I modified only the “prj.conf” file in this sample and used exactly the settings that you specified.

Can you try the same and see if it works for you?

 

Best regards,

Andrzej

 

From: Cufi, Carles
Sent: Friday, July 13, 2018 6:36 PM
To: Diana Rivera <drv3007@...>; users@...; Głąbek, Andrzej <Andrzej.Glabek@...>
Subject: RE: [Zephyr-users] I2C running on NRF52840

 

+Andrzej

 

From: users@... <users@...> On Behalf Of Diana Rivera
Sent: 13 July 2018 15:26
To: users@...
Subject: [Zephyr-users] I2C running on NRF52840

 

Hello everyone!

I am currently working on trying to use I2C to read some Grove sensors using the NRF52840 Preview Development Kit. I'm planning on writing an application based on Zephyr's sample code i2c_fujitsu_fram, as instructed in some other replies I've seen.
I have created a prj.conf file which includes the following:

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y

CONFIG_I2C=y
CONFIG_I2C_NRF5=y
CONFIG_I2C_0=y
CONFIG_I2C_NRF5_0_GPIO_SDA_PIN=26
CONFIG_I2C_NRF5_0_GPIO_SCL_PIN=27
CONFIG_I2C_0_IRQ_PRI=7

However, when I try to compile the code, I get the error:

In function ‘main’:
/home/diana/zephyr/apps/i2c_fujitsu_fram/src/main.c:85:31: error: ‘I2C_DEV’ undeclared (first use in this function)
  i2c_dev = device_get_binding(I2C_DEV);

I've seen this question from someone who seems to have the same problem. But there was no clear solution to the problem.
https://lists.zephyrproject.org/g/users/topic/16761518#677

And I've also tried solving the problem by following the advice in this post:
https://lists.zephyrproject.org/g/users/topic/16761401#364

And replacing:
#define I2C_DEV CONFIG_I2C_0_NAME

By:
#define I2C_DEV CONFIG_GPIO_NRF5_P0_DEV_NAME

Which doesn't make much sense to me, but in any case I get the error shown in the screen shot attached.

Could someone point out what I'm doing wrong, or guide me on the right direction to get I2C running on the NRF52840 board, please?

I've already gone through this post as well, and still can't figure out my problem:
https://lists.zephyrproject.org/g/users/topic/16761404#378

Thank you in advance for your help,
Diana

 

Join {users@lists.zephyrproject.org to automatically receive all group messages.