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

can I use 3 uart and 2 i2c

in ~/ncs/zephyr/samples/hello_world/prj.conf
CONFIG_I2C=y

//////////// 2 uart + 2 i2c build OK
in nrf9160dk_nrf9160ns.overlay
/ {
    chosen {
        zephyr,console = &uart0;
        zephyr,shell-uart = &uart0;
        zephyr,uart-mcumgr = &uart0;
        zephyr,bt-mon-uart = &uart0;
    };
};

&uart0 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <1>;
        rx-pin = <0>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&uart1 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <26>;
        rx-pin = <25>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&i2c2 {
        compatible = "nordic,nrf-twim";
    status = "okay";
    sda-gpios = < &gpio0 0x0e 0x0 >;
        scl-gpios = < &gpio0 0x0f 0x0 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
};

&i2c3 {
        compatible = "nordic,nrf-twim";
    status = "okay";
    sda-gpios = < &gpio0 0x1e 0x0 >;
        scl-gpios = < &gpio0 0x1f 0x0 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
};

build OK

//////////// 3 uart + 1 i2c build OK
in nrf9160dk_nrf9160ns.overlay
&uart0 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <1>;
        rx-pin = <0>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&uart1 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <26>;
        rx-pin = <25>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&uart2 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <28>;
        rx-pin = <27>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&i2c2 {
    status = "disabled";
        sda-gpios = < &gpio0 0xFFFFFFFF 0x0 >;
        scl-gpios = < &gpio0 0xFFFFFFFF 0x0 >;
};

&i2c3 {
        compatible = "nordic,nrf-twim";
    status = "okay";
    sda-pin = < 30 >;
    scl-pin = < 31 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
};

///////////////////3 uart + 2 i2c build error

&uart0 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <1>;
        rx-pin = <0>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&uart1 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <26>;
        rx-pin = <25>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&uart2 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <28>;
        rx-pin = <27>;
        rts-pin = <0xFFFFFFFF>;
        cts-pin = <0xFFFFFFFF>;
};

&i2c2 {
        compatible = "nordic,nrf-twim";
    status = "okay";
    sda-gpios = < &gpio0 0x0e 0x0 >;
        scl-gpios = < &gpio0 0x0f 0x0 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
};

&i2c3 {
        compatible = "nordic,nrf-twim";
    status = "okay";
    sda-gpios = < &gpio0 0x1e 0x0 >;
        scl-gpios = < &gpio0 0x1f 0x0 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
};

error message:
static assertion failed: "Only one of the following peripherals can be enabled: SPI2, SPIM2, SPIS2, TWI2, TWIM2, TWIS2, UARTE2. Check nodes with status \"okay\" in zephyr.dts."

how to make it pass

Parents
  • more info for IRQ

    ~/ncs/modules/hal/nordic/nrfx/drivers/nrfx_common.h
    #define NRFX_IRQ_NUMBER_GET(base_addr)  NRFX_PERIPHERAL_ID_GET(base_addr)

    ~/ncs/nrf/subsys/spm/spm.c
    //#define NRFX_PERIPHERAL_ID_GET(base_addr) (uint8_t)((uint32_t)(base_addr) >> 12)

    ////////////////////////////////////////////////////////////////////////////////
    ~/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_twim.c
    NRFX_IRQ_ENABLE(nrfx_get_irq_number(p_instance->p_twim));

    ~/ncs/zephyr/arch/arm/core/aarch32/irq_manage.c
    void arch_irq_enable(unsigned int irq)
    {
        NVIC_EnableIRQ((IRQn_Type)irq);
    }

Reply
  • more info for IRQ

    ~/ncs/modules/hal/nordic/nrfx/drivers/nrfx_common.h
    #define NRFX_IRQ_NUMBER_GET(base_addr)  NRFX_PERIPHERAL_ID_GET(base_addr)

    ~/ncs/nrf/subsys/spm/spm.c
    //#define NRFX_PERIPHERAL_ID_GET(base_addr) (uint8_t)((uint32_t)(base_addr) >> 12)

    ////////////////////////////////////////////////////////////////////////////////
    ~/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_twim.c
    NRFX_IRQ_ENABLE(nrfx_get_irq_number(p_instance->p_twim));

    ~/ncs/zephyr/arch/arm/core/aarch32/irq_manage.c
    void arch_irq_enable(unsigned int irq)
    {
        NVIC_EnableIRQ((IRQn_Type)irq);
    }

Children
No Data
Related