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

I2C communication problem with nRF9160

My project has successfully debugged the communication of SPI_2, SPI_3 and UART_1. Now I need to debug the interface communication of I2C, when I turn on the macro switch related to I2C, it can't get binding of SPI_ 2 and UART_ 1. What is the reason?

my prj.conf file is like this:

#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

# General config
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_NEWLIB_LIBC=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y
CONFIG_GPIO=y
CONFIG_LOG=y
CONFIG_LOG_IMMEDIATE=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# Modem info
CONFIG_MODEM_INFO=y

# BSD library
CONFIG_BSD_LIBRARY=y
CONFIG_BSD_LIBRARY_TRACE_ENABLED=n

# Library for buttons and LEDs
CONFIG_DK_LIBRARY=y
CONFIG_DK_LIBRARY_INVERT_LEDS=n

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_HW_STACK_PROTECTION=y

# MCUBOOT
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y

# SPI
CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_SPI_2=y
CONFIG_SPI_2_NRF_SPIM=y
CONFIG_SPI_3=y
CONFIG_SPI_3_NRF_SPIM=y

# I2C
#CONFIG_I2C=y
#CONFIG_I2C_NRFX=y
#CONFIG_I2C_1=y
#CONFIG_I2C_1_NRF_TWIM=y
#CONFIG_I2C_INIT_PRIORITY=60

# Flash
CONFIG_FLASH=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# NVS
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_LOG=y
CONFIG_NVS_LOG_LEVEL_DBG=y
CONFIG_REBOOT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# UART
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
#CONFIG_UART_0_NRF_UARTE=y
#CONFIG_UART_0_NRF_FLOW_CONTROL=n
CONFIG_UART_1_NRF_UARTE=y
CONFIG_UART_1_NRF_FLOW_CONTROL=n

# Use smaller buffers for net_buf as CANBUS packets are quite small.
CONFIG_NET_BUF_DATA_SIZE=64
CONFIG_NET_BUF_USER_DATA_SIZE=1

Parents
  • And the dts file is like this:

    /*
     * Copyright (c) 2018 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    / {
    	model = "Nordic PCA10090 Dev Kit";
    	compatible = "nordic,pca10090-dk", "nordic,nrf9160-sica",
    		     "nordic,nrf9160";
    
    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    	};
    
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = <&gpio0 2 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 0";
    		};
    		led1: led_1 {
    			gpios = <&gpio0 3 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 1";
    		};
    		led2: led_2 {
    			gpios = <&gpio0 4 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 2";
    		};
    		led3: led_3 {
    			gpios = <&gpio0 5 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 3";
    		};
    	};
    
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 2>;
    		};
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		button0: button_0 {
    			gpios = <&gpio0 8 GPIO_PUD_PULL_UP>;
    			label = "Switch 1";
    		};
    		button1: button_1 {
    			gpios = <&gpio0 9 GPIO_PUD_PULL_UP>;
    			label = "Switch 2";
    		};
    		button2: button_2 {
    			gpios = <&gpio0 6 GPIO_PUD_PULL_UP>;
    			label = "Push button 1";
    		};
    		button3: button_3 {
    			gpios = <&gpio0 7 GPIO_PUD_PULL_UP>;
    			label = "Push button 2";
    		};
    	};
    
    	/* These aliases are provided for compatibility with samples */
    	aliases {
    		led0 = &led0;
    		led1 = &led1;
    		led2 = &led2;
    		led3 = &led3;
    		pwm-led0 = &pwm_led0;
    		sw0 = &button2;
    		sw1 = &button3;
    		sw2 = &button0;
    		sw3 = &button1;
    	};
    };
    
    &adc {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <29>;
    	rx-pin = <28>;
    	rts-pin = <27>;
    	cts-pin = <26>;
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <31>;
    	rx-pin = <30>;
    	rts-pin = <14>;
    	cts-pin = <15>;
    };
    
    &uart2 {
    	tx-pin = <24>;
    	rx-pin = <23>;
    };
    
    &i2c1 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = <11>;
    	scl-pin = <12>;
    };
    
    &i2c2 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = <30>;
    	scl-pin = <31>;
    };
    
    &pwm0 {
    	status = "okay";
    	ch0-pin = <2>;
    };
    
    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <19>;
    	mosi-pin = <18>;
    	miso-pin = <17>;
    };
    
    &timer0 {
    	status = "okay";
    };
    
    &timer1 {
    	status = "okay";
    };
    
    &timer2 {
    	status = "okay";
    };
    
    &flash0 {
    	/*
    	 * For more information, see:
    	 * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
    	 */
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    		};
    		slot0_ns_partition: partition@40000 {
    			label = "image-0-nonsecure";
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    		};
    		slot1_ns_partition: partition@b0000 {
    			label = "image-1-nonsecure";
    		};
    		scratch_partition: partition@f0000 {
    			label = "image-scratch";
    			reg = <0x000f0000 0xa000>;
    		};
    		storage_partition: partition@fa000 {
    			label = "storage";
    			reg = <0x000fa000 0x00006000>;
    		};
    	};
    };
    
    / {
    	/* SRAM allocated and used by the BSD library */
    	sram0_bsd: memory@20010000 {
    		compatible = "mmio-sram";
    	};
    
    	/* SRAM allocated to the Non-Secure image */
    	sram0_ns: memory@20020000 {
    		compatible = "mmio-sram";
    	};
    };
    
    /* Include partition configuration file */
    #include "nrf9160_pca10090_partition_conf.dts"
    

Reply
  • And the dts file is like this:

    /*
     * Copyright (c) 2018 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    / {
    	model = "Nordic PCA10090 Dev Kit";
    	compatible = "nordic,pca10090-dk", "nordic,nrf9160-sica",
    		     "nordic,nrf9160";
    
    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    	};
    
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = <&gpio0 2 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 0";
    		};
    		led1: led_1 {
    			gpios = <&gpio0 3 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 1";
    		};
    		led2: led_2 {
    			gpios = <&gpio0 4 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 2";
    		};
    		led3: led_3 {
    			gpios = <&gpio0 5 GPIO_INT_ACTIVE_HIGH>;
    			label = "Green LED 3";
    		};
    	};
    
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 2>;
    		};
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		button0: button_0 {
    			gpios = <&gpio0 8 GPIO_PUD_PULL_UP>;
    			label = "Switch 1";
    		};
    		button1: button_1 {
    			gpios = <&gpio0 9 GPIO_PUD_PULL_UP>;
    			label = "Switch 2";
    		};
    		button2: button_2 {
    			gpios = <&gpio0 6 GPIO_PUD_PULL_UP>;
    			label = "Push button 1";
    		};
    		button3: button_3 {
    			gpios = <&gpio0 7 GPIO_PUD_PULL_UP>;
    			label = "Push button 2";
    		};
    	};
    
    	/* These aliases are provided for compatibility with samples */
    	aliases {
    		led0 = &led0;
    		led1 = &led1;
    		led2 = &led2;
    		led3 = &led3;
    		pwm-led0 = &pwm_led0;
    		sw0 = &button2;
    		sw1 = &button3;
    		sw2 = &button0;
    		sw3 = &button1;
    	};
    };
    
    &adc {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <29>;
    	rx-pin = <28>;
    	rts-pin = <27>;
    	cts-pin = <26>;
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <31>;
    	rx-pin = <30>;
    	rts-pin = <14>;
    	cts-pin = <15>;
    };
    
    &uart2 {
    	tx-pin = <24>;
    	rx-pin = <23>;
    };
    
    &i2c1 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = <11>;
    	scl-pin = <12>;
    };
    
    &i2c2 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = <30>;
    	scl-pin = <31>;
    };
    
    &pwm0 {
    	status = "okay";
    	ch0-pin = <2>;
    };
    
    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <19>;
    	mosi-pin = <18>;
    	miso-pin = <17>;
    };
    
    &timer0 {
    	status = "okay";
    };
    
    &timer1 {
    	status = "okay";
    };
    
    &timer2 {
    	status = "okay";
    };
    
    &flash0 {
    	/*
    	 * For more information, see:
    	 * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
    	 */
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    		};
    		slot0_ns_partition: partition@40000 {
    			label = "image-0-nonsecure";
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    		};
    		slot1_ns_partition: partition@b0000 {
    			label = "image-1-nonsecure";
    		};
    		scratch_partition: partition@f0000 {
    			label = "image-scratch";
    			reg = <0x000f0000 0xa000>;
    		};
    		storage_partition: partition@fa000 {
    			label = "storage";
    			reg = <0x000fa000 0x00006000>;
    		};
    	};
    };
    
    / {
    	/* SRAM allocated and used by the BSD library */
    	sram0_bsd: memory@20010000 {
    		compatible = "mmio-sram";
    	};
    
    	/* SRAM allocated to the Non-Secure image */
    	sram0_ns: memory@20020000 {
    		compatible = "mmio-sram";
    	};
    };
    
    /* Include partition configuration file */
    #include "nrf9160_pca10090_partition_conf.dts"
    

Children
No Data
Related