Enable SPIM0 and TWIM1 Drivers in KConfig NCS

Hello,

I am trying to enable the SPIM0 and TWIM1 drivers for my current project. Under the VS Code GUI for KConfig, I see the options, but they are grayed out and cannot be selected. Can someone guide me as to how to enable them? Maybe I have something enabled/disabled that is causing this. Manually adding them in the KConfig only produces compile errors. I am using nRF Connect SDK v2.1.2 and have the nRF52 DK (nRF52832) board for eval purposes.

Thanks,

Adnan

Parents
  • Hi,

    Are you using other peripherals with the same peripheral ID?

    Also, check the status of the peripherals in the devicetree.

    Regards,
    Sigurd Hellesvik

  • Hello,

    I am trying to use a peripheral, camera module, that's why I need access to the drivers. No other peripheral.

    I am modifying the Peripheral_UART example for this. I did add a custom overlay file but that has only GPIOs and ADC mappings. I have not touched any of the IDs.

    Thanks,

    Adnan

  • Hello Siguard,

    Thank you for getting back to me on this. Please review the requested info below:

    // To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.
    
    // You can also use the buttons in the sidebar to perform actions on nodes.
    // Actions currently available include:
    
    // * Enabling / disabling the node
    // * Adding the bus to a bus
    // * Removing the node
    // * Connecting ADC channels
    
    // For more help, browse the DeviceTree documentation at https://docs.zephyrproject.org/latest/guides/dts/index.html
    // You can also visit the nRF DeviceTree extension documentation at https://nrfconnect.github.io/vscode-nrf-connect/devicetree/nrfdevicetree.html
    &pinctrl {
    	pwm0_default: pwm0_default {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 11)>;
    			nordic,invert;
    		};
    	};
    
    	pwm0_sleep: pwm0_sleep {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 11)>;
    			low-power-enable;
    		};
    	};
    
        pwm1_default: pwm1_default {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 12)>;
    			nordic,invert;
    		};
    	};
    
    	pwm1_sleep: pwm1_sleep {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 12)>;
    			low-power-enable;
    		};
    	};
    
        pwm2_default: pwm2_default {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 13)>;
    			nordic,invert;
    		};
    	};
    
    	pwm2_sleep: pwm2_sleep {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT0, 0, 13)>;
    			low-power-enable;
    		};
    	};
    };
    
    / {
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    		};
            pwm_led1: pwm_led_1 {
    			pwms = <&pwm1 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    		};
            pwm_led2: pwm_led_2 {
    			pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    		};
    	};
    
        aliases {
            pwm-led0 = &pwm_led0;
            pwm-led1 = &pwm_led1;
            pwm-led2 = &pwm_led2;
    		adcctrl = &adc;
        };
    };
    
    &pwm0 {
    	status = "okay";
    	pinctrl-0 = <&pwm0_default>;
    	pinctrl-1 = <&pwm0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    &pwm1 {
    	status = "okay";
    	pinctrl-0 = <&pwm1_default>;
    	pinctrl-1 = <&pwm1_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    &pwm2 {
    	status = "okay";
    	pinctrl-0 = <&pwm2_default>;
    	pinctrl-1 = <&pwm2_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &adc { /* ADC */
        label = "adc";
        status = "okay";
       };

    zephyr.dts

    I cannot see the peripherals in this file.

    KCONFIG compile issues:

    warning: BT_SMP (defined at C:/TPR-Nordicsemi-
    Sources/ncs/v2.1.2/zephyr/subsys/bluetooth/host/Kconfig:317, subsys/bluetooth\host/Kconfig:317) was
    assigned the value 'n' but got the value 'y'. See
    docs.zephyrproject.org/.../kconfig.html and/or look up BT_SMP in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.


    warning: NRFX_SPIM0 (defined at C:/TPR-Nordicsemi-
    Sources/ncs/v2.1.2/zephyr/modules/hal_nordic\nrfx/Kconfig:193, modules\hal_nordic\nrfx/Kconfig:193)
    was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: n (=n). See
    docs.zephyrproject.org/.../kconfig.html and/or look up NRFX_SPIM0 in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.


    warning: NRFX_TWIM1 (defined at C:/TPR-Nordicsemi-
    Sources/ncs/v2.1.2/zephyr/modules/hal_nordic\nrfx/Kconfig:298, modules\hal_nordic\nrfx/Kconfig:298)
    was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: n (=n). See
    docs.zephyrproject.org/.../kconfig.html and/or look up NRFX_TWIM1 in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

    -- The C compiler identification is GNU 10.3.0
    -- The CXX compiler identification is GNU 10.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/TPR-Nordicsemi-Sources/ncs/toolchains/v2.1.2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at C:/TPR-Nordicsemi-Sources/ncs/v2.1.2/zephyr/CMakeLists.txt:1839 (message):
    __ASSERT() statements are globally ENABLED

  • Hi,

    adnankhalid said:
    I cannot see the peripherals in this file.

    If you can not see the peripherals in this zephyr.dts, it means that your devicetree overlay was not included properly.

    How did you include your overlay into your project?

    For later reference: Which developement kit are you using?

    Regards,
    Sigurd Hellesvik

  • Hello Sigurd,

    My apologies, I misunderstood the question. Yes the peripherals (GPIO and ADC) from my custom overlay file are indeed represented in the zephyr.dts file. 

    Further proof of this is that my control code in main is working. I can control the GPIOs and the read from the desired ADC input.

    The kit I am using is the nRF52 DK (nRF52832). I am trying to integrate a camera module and need access to the SPIM and TWIM drivers, hence the original question.

    Please advise.

    Thanks,

    Adnan

  • Hi Adnan,

    Ah, then we know that the devicetree is correct.

    The errors below is that Kconfigs are not set.
    You can check their dependencies of Kconfig options in VS Code using the Kconfig feature:

    Then check the value of the dependencies:

    Does this show you what you are missing with your options?

    Regards,
    Sigurd Hellesvik

  • Hi Siguard,

    So when I look into the dependencies of the SPIM0 and TWIM1 in the KCONGIH GUI. They are both grayed out, so cannot be selected, and the only thing it says for dependencies is =n.

    I need to, some how, enable the NRFX SPIM0 and NRFX TWIM1 drivers to move forward with my project.

    Thanks,

    Adnan

Reply Children
  • Hello Siguard,

    So the sample builds, compiles and flashes but I get nothing on the NRF RTT Terminal. A look at the prj.conf file shows 2 problems:

    1) CONFIG_NRFX_SPIM0 was assigned the value y, but got the value n. Missing dependencies:

    n
    2) CONFIG_NRFX_TWIM1 was assigned the value y, but got the value n. Missing dependencies:
    n
    I am running nRF Connect SDK v2.1.2 with nRF52 DK (nRF52832) eval board: PCA10040, 2.1.0, 2021.02.
    Please advise. Thanks!
    Adnan
  • Hi Adnan,

    You  are right, I forgot to check the build log.

    Instead of using CONFIG_NRFX_SPIM and CONFIG_NRFX_TWIM1, can you instead try to only set spi0/i2c1  in the devicetree?
    And enable CONFIG_SPI and CONFIG_I2C.

    Then I think the configuration system might handle the rest.

    Regards,
    Sigurd Hellesvik

  • Hello Siguard,

    So in the echo_bot example I commented out the CONFIG_NRFX_SPIM0 and CONFIG_NRFX_TWIM1 configs in the prj.conf file and the overlay file already had the spi0 and i2c1 enabled as follows:

    &spi0 {
        status = "okay";
    };

    &spi1 {
        status = "disabled";
    };

    &i2c1 {
        status = "okay";
    };

    &i2c0 {
        status = "disabled";
    };
    I built and flashed the sample to the board but again I do not get anything on the RTT.
    Please advise.
     
    Adnan

     

  • Hello,

    So I added the following to the overlay file:

    &spi0 {

        compatible = "nordic,nrf-spim";
        status = "okay";
        sck-pin = <23>;
        mosi-pin = <25>;
        miso-pin = <24>;
        cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
    };
    &spi1 {
        status = "disabled";
    };

    &i2c0 {
        status = "disabled";
    };

    &i2c1 {
        compatible = "nordic,nrf-twim";
        status = "okay";
    };
    I added the following to the prj.conf:
    #Enable SPI and I2C
    CONFIG_SPI=y
    CONFIG_I2C=y
    CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58=y
    The following to the KCONFIG:
    config CONFIG_SPI_NRFX
        bool "Enable SPI NRFX"
        default y
        select CONFIG_SPI

    config CONFIG_I2C_NRFX
        bool "Enable SPI NRFX"
        default y
        select CONFIG_I2C
    Now I seem to have access to the SPIM and TWIM drivers!
    Please advise if this is the right approach?
    Now I am trying to find the equivalent in NCS for the following:
    Get image data over the SPI/TWI and send it over BLE to device
    Any help/sample code to get this done would be most helpful.
    Thanks!
Related