Topics

[Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)


vikrant8051 <vikrant8051@...>
 

Hi Rodrigo,
Currently trying to build zephyr/samples/drivers/i2c_fujitsu_fram/ demo eg.
to test i2c for nRF52840_pca10056.

As per your previous email, I added following things in prj.conf

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_0_NRF_TWI=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_I2C_0=y

But still getting following error,

../src/main.c:16:17: error: ‘CONFIG_I2C_0_NAME’ undeclared (first use in this function)
 #define I2C_DEV CONFIG_I2C_0_NAME
                 ^
../src/main.c:84:31: note: in expansion of macro ‘I2C_DEV’
  i2c_dev = device_get_binding(I2C_DEV);
                               ^~~~~~~
../src/main.c:16:17: note: each undeclared identifier is reported only once for each function it appears in
 #define I2C_DEV CONFIG_I2C_0_NAME
                 ^
../src/main.c:84:31: note: in expansion of macro ‘I2C_DEV’
  i2c_dev = device_get_binding(I2C_DEV);
                               ^~~~~~~
[19/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/mempool/mempool.c.obj
ninja: build stopped: subcommand failed.

Please help me to sort out this issue.

Thank You !!

On Wed, Oct 24, 2018 at 2:01 AM Rodrigo Peixoto <rodrigopex@...> wrote:
Hi,
I am trying to use the i2c on my custom board. I can read data from the devices, but (oddly) I cannot write to any of the 3 devices "attached" to the i2c line. I am using SDA on pin P0.06 and SCL on pin P0.07. Any clue? I have already spent a lot of time trying to fix this and nothing seems to work in this direction. 

Zephyr version: 1.13

i2c configs:
prj file (begin)
...
CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_0_NRF_TWI=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_SYS_LOG_I2C_LEVEL=4
CONFIG_I2C_0=y
...
prj file (end)

board.dts (begin)
...
&i2c0 {
status = "ok";
sda-pin = <6>;
scl-pin = <7>;
};
...
board.dts (end)

I am using the commands like: 
error = i2c_burst_read(i2c_dev, ACC_I2C_ADDR, reg, &temp, 1);
error = i2c_burst_read16(i2c_dev, ADE_I2C_ADDR, reg, &buf, 4);

error = i2c_burst_write(i2c_dev, ACC_I2C_ADDR, reg, &setup, 1);
error = i2c_burst_write16(i2c_dev, ADE_I2C_ADDR, reg, &buf, 3);

All the reading commands work and the writing ones do not show an error and seem to make no effect.  


Thank you.
Best regards,
Rodrigo Peixoto
Co-founder and Technical advisor

+55 (82) 98144-8585
http://ayna.tech | Skype: rodrigopex



lairdjm
 

Run ninja menuconfig, go through the settings and set the various I2C options up then it should build.


lairdjm
 

Works fine with those lines added to prj.conf

 

[0/1] Re-running CMake...

CMake Deprecation Warning at C:/test/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):

  The OLD behavior for policy CMP0000 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

Call Stack (most recent call first):

  CMakeLists.txt:1 (include)

 

 

-- Selected BOARD nrf52840_pca10056

Zephyr version: 1.12.99

Parsing Kconfig tree in C:/test/zephyr//Kconfig

Using C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build/zephyr/.config as base

fatal: No tags can describe '02addfff50f936af41dfc71ab2d6140ace86f455'.

Try --always, or create some tags.

-- Generating zephyr/include/generated/generated_dts_board.h

-- Cache files will be written to: C:\Users\jamie.mccrae\AppData\Local/.cache/zephyr

-- Configuring done

-- Generating done

-- Build files have been written to: C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build

[129/134] Linking C executable zephyr\zephyr_prebuilt.elf

Memory region         Used Size  Region Size  %age Used

           FLASH:       48292 B         1 MB      4.61%

            SRAM:       11220 B       256 KB      4.28%

        IDT_LIST:         136 B         2 KB      6.64%

[134/134] Linking C executable zephyr\zephyr.elf

 


vikrant8051 <vikrant8051@...>
 

Hi to all,
I renamed driver name from CONFIG_I2C_0_NAME to DT_I2C_0_NAME.
Plus add following Kconfig things in prj.conf. Now everything is working fine.

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_NRFX_TWI=y
CONFIG_I2C_0_NRF_TWI=y
CONFIG_HAS_HW_NRF_TWI0=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_I2C_0=y

Thanks & Regards,
vikrant


On Wed, Nov 28, 2018 at 3:03 PM Vikrant More <vikrant8051@...> wrote:
Hi Jamie,
It seen that it is working with 1.12.99 which is your case.

But with latest master branch, it is not.

Issue is in driver name
#define I2C_DEV CONFIG_I2C_0_NAME

Thanks for support !!

On Wed, Nov 28, 2018 at 2:48 PM Jamie Mccrae <Jamie.Mccrae@...> wrote:

Attached

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: 28 November 2018 09:10
To: Jamie Mccrae <Jamie.Mccrae@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Cannot write with i2c NRF52832 (TWI and TWIM)

 

Hi Jamie,

Please share your .config file to me so that I can compare for

what I've missed.

 

Thanks !!

 

On Wed, Nov 28, 2018 at 2:33 PM lairdjm <jamie.mccrae@...> wrote:

Works fine with those lines added to prj.conf

 

[0/1] Re-running CMake...

CMake Deprecation Warning at C:/test/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):

  The OLD behavior for policy CMP0000 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

Call Stack (most recent call first):

  CMakeLists.txt:1 (include)

 

 

-- Selected BOARD nrf52840_pca10056

Zephyr version: 1.12.99

Parsing Kconfig tree in C:/test/zephyr//Kconfig

Using C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build/zephyr/.config as base

fatal: No tags can describe '02addfff50f936af41dfc71ab2d6140ace86f455'.

Try --always, or create some tags.

-- Generating zephyr/include/generated/generated_dts_board.h

-- Cache files will be written to: C:\Users\jamie.mccrae\AppData\Local/.cache/zephyr

-- Configuring done

-- Generating done

-- Build files have been written to: C:/test/zephyr/samples/drivers/i2c_fujitsu_fram/build

[129/134] Linking C executable zephyr\zephyr_prebuilt.elf

Memory region         Used Size  Region Size  %age Used

           FLASH:       48292 B         1 MB      4.61%

            SRAM:       11220 B       256 KB      4.28%

        IDT_LIST:         136 B         2 KB      6.64%

[134/134] Linking C executable zephyr\zephyr.elf