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

nrfx twis drivers on nrf9160 (Zephyr)

Hello,

I want to use I2C slave on nrf9160, but there is no I2C slave driver implementation.

So I read that instead of this, I can use nrfx twis drivers on nrf9160.

I followed this thread https://github.com/zephyrproject-rtos/zephyr/issues/21445 to use nrfx twis drivers on zephyr.

prj.conf

CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_NRFX_TWIS=y
CONFIG_NRFX_TWIS0=y

nrf9160_pca10090ns.overlay

&i2c0 {
	compatible = "nordic,nrf-twis";
	status = "okay";
	sda-pin = < 19 >;
	scl-pin = < 18 >;
};

When I open the project with these prj.conf and overlay file, I am getting this error:

Loading solution twis_040820.emProject
Executing load commands
cmake -GNinja -DBOARD=nrf9160_pca10090ns -DBOARD_DIR=C:/ncs/zephyr/boards/arm/nrf9160_pca10090 -DZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb -DGNUARMEMB_TOOLCHAIN_PATH=C:/gnuarmemb -BC:/ncs/nrf/samples/jagruti_codes/twis_040820/build_nrf9160_pca10090ns -HC:/ncs/nrf/samples/jagruti_codes/twis_040820 -DDTC_OVERLAY_FILE=C:/ncs/nrf/samples/jagruti_codes/twis_040820/nrf9160_pca10090ns.overlay -DEXTRA_KCONFIG_TARGETS=menuconfig_ses -DEXTRA_KCONFIG_TARGET_COMMAND_FOR_menuconfig_ses=D:/nRF9160-DK/EmbeddedStudio_ARM_Nordic_v420a_win_x64/arm_segger_embedded_studio_v420a_win_x64_nordic/html/configure_nordic_project_menuconfig.py
-- Using application from 'C:/ncs/nrf/samples/jagruti_codes/twis_040820'
Zephyr version: 2.0.99
-- Selected BOARD nrf9160_pca10090ns
-- Found west: C:/Python37/Scripts/west.exe (found suitable version "0.6.2", minimum required is "0.6.0")
-- Cache files will be written to: C:\Users\b.carre\AppData\Local/.cache/zephyr
-- Loading C:/ncs/zephyr/boards/arm/nrf9160_pca10090/nrf9160_pca10090ns.dts as base
-- Overlaying C:/ncs/zephyr/dts/common/common.dts
-- Overlaying C:/ncs/nrf/samples/jagruti_codes/twis_040820/nrf9160_pca10090ns.overlay
device tree error: 'clock-frequency' appears in /soc/peripheral@40000000/i2c@8000 in nrf9160_pca10090ns.dts.pre.tmp, but is not declared in 'properties:' in C:/ncs/zephyr/dts/bindings\i2c\nordic,nrf-twis.yaml
CMake Error at C:/ncs/zephyr/cmake/dts.cmake:182 (message):
  new extractor failed with return code: 1
Call Stack (most recent call first):
  C:/ncs/zephyr/cmake/app/boilerplate.cmake:559 (include)
  CMakeLists.txt:2 (include)


-- Configuring incomplete, errors occurred!
Project load failed
Reported error: solution load command failed (1)

If I remove the compatible = "nordic,nrf-twis"; from overlay file, then there is no error but twis does not work.

Also while adding the IRQ handler, 

        IRQ_CONNECT(DT_NORDIC_NRF_I2C_I2C_2_IRQ_0, 
                            DT_NORDIC_NRF_I2C_I2C_2_IRQ_0_PRIORITY, 
                            nrfx_isr, nrfx_twis_2_irq_handler, 0);

I have these above options available.

But I should use:

IRQ_CONNECT(DT_NORDIC_NRF_TWIS_I2C_0_IRQ_0,
	    DT_NORDIC_NRF_TWIS_I2C_0_IRQ_0_PRIORITY,
	    nrfx_isr, nrfx_twis_0_irq_handler, 0);

But using this, I get the error.

How to solve this problem?

Parents
  • Hi

    Glad you were able to solve the initial issue. What kind of error are you seeing now then? Could it be that the I2C 0 instance is already used by the SPI or some other part of your application? The SPI and TWI can not use the same instance, as they share certain resources and therefore can not be used at the same time.

    Best regards,

    Simon

Reply
  • Hi

    Glad you were able to solve the initial issue. What kind of error are you seeing now then? Could it be that the I2C 0 instance is already used by the SPI or some other part of your application? The SPI and TWI can not use the same instance, as they share certain resources and therefore can not be used at the same time.

    Best regards,

    Simon

Children
Related