Hello,
First of all, I'm not a hw-engineer
I've 2 evaluation devices of nRF52840 (BL654-DVK) and I'm trying to test the SPI communication between them (one as master, other as slave).
I've based on the spi & spis examples from here: https://github.com/sigurdnev/ncs-playground
1) The examples do not compile "off the shelf", to compile properly, I've to comment out prj.conf the directives "CONFIG_SPI_1" & "CONFIG_DEPRECATED_ZEPHYR_INT_TYPES", otherwise they fail with the following error:
> Executing task: nRF Connect: Generate config nrf52840dk_nrf52840 for c:\work\repo\nordic\ncs-playground\samples\spi_test < Building spi_test west build --build-dir c:\work\repo\nordic\ncs-playground\samples\spi_test\build_1 c:\work\repo\nordic\ncs-playground\samples\spi_test --pristine --board nrf52840dk_nrf52840 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="c:/work/repo/SurgicalWirelessProtocol/EVB/spi;c:/work/repo/SurgicalWirelessProtocol/EVB/spi_loopback;c:/work/repo/SurgicalWirelessProtocol/EVB/spi_comm/spi_master" -- west build: generating a build system Including boilerplate (Zephyr base): C:/Users/vagner.landskron/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake -- Application: C:/work/repo/nordic/ncs-playground/samples/spi_test -- Zephyr version: 2.7.99 (C:/Users/vagner.landskron/ncs/v1.9.1/zephyr), build: v2.7.99-ncs1-1 -- Found Python3: C:/Users/vagner.landskron/ncs/v1.9.1/toolchain/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter -- Found west (found suitable version "0.12.0", minimum required is "0.7.1") -- Board: nrf52840dk_nrf52840 -- Cache files will be written to: C:/Users/vagner.landskron/ncs/v1.9.1/zephyr/.cache -- Found dtc: C:/Users/vagner.landskron/ncs/v1.9.1/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") -- Found toolchain: gnuarmemb (c:/Users/vagner.landskron/ncs/v1.9.1/toolchain/opt) -- Found BOARD.dts: C:/Users/vagner.landskron/ncs/v1.9.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts -- Found devicetree overlay: C:/work/repo/nordic/ncs-playground/samples/spi_test/nrf52840dk_nrf52840.overlay -- Generated zephyr.dts: C:/work/repo/nordic/ncs-playground/samples/spi_test/build_1/zephyr/zephyr.dts -- Generated devicetree_unfixed.h: C:/work/repo/nordic/ncs-playground/samples/spi_test/build_1/zephyr/include/generated/devicetree_unfixed.h -- Generated device_extern.h: C:/work/repo/nordic/ncs-playground/samples/spi_test/build_1/zephyr/include/generated/device_extern.h -- Including generated dts.cmake file: C:/work/repo/nordic/ncs-playground/samples/spi_test/build_1/zephyr/dts.cmake C:\work\repo\nordic\ncs-playground\samples\spi_test\prj.conf:12: warning: attempt to assign the value 'y' to the undefined symbol SPI_1 C:\work\repo\nordic\ncs-playground\samples\spi_test\prj.conf:14: warning: attempt to assign the value 'y' to the undefined symbol DEPRECATED_ZEPHYR_INT_TYPES error: Aborting due to Kconfig warnings Parsing C:/Users/vagner.landskron/ncs/v1.9.1/zephyr/Kconfig Loaded configuration 'C:/Users/vagner.landskron/ncs/v1.9.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig' Merged configuration 'C:/work/repo/nordic/ncs-playground/samples/spi_test/prj.conf' CMake Error at C:\Users\vagner.landskron\ncs\v1.9.1\zephyr\cmake\kconfig.cmake:272 (message): command failed with return code: 1 Call Stack (most recent call first): C:\Users\vagner.landskron\ncs\v1.9.1\zephyr\cmake\app\boilerplate.cmake:544 (include) C:\Users\vagner.landskron\ncs\v1.9.1\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:24 (include) C:\Users\vagner.landskron\ncs\v1.9.1\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:35 (include_boilerplate) c:\work\repo\nordic\ncs-playground\samples\spi_test\build_1\CMakeLists.txt:27 (find_package) -- Configuring incomplete, errors occurred! FATAL ERROR: command exited with status 1: 'c:\Users\vagner.landskron\ncs\v1.9.1\toolchain\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\Users\vagner.landskron\ncs\v1.9.1\toolchain\opt\bin\python.exe' '-Bc:\work\repo\nordic\ncs-playground\samples\spi_test\build_1' '-Sc:\work\repo\nordic\ncs-playground\samples\spi_test' -GNinja -DBOARD=nrf52840dk_nrf52840 -DNCS_TOOLCHAIN_VERSION:STRING=NONE '-DBOARD_ROOT:STRING=c:/work/repo/SurgicalWirelessProtocol/EVB/spi;c:/work/repo/SurgicalWirelessProtocol/EVB/spi_loopback;c:/work/repo/SurgicalWirelessProtocol/EVB/spi_comm/spi_master' The terminal process terminated with exit code: 1. Terminal will be reused by tasks, press any key to close it.
2) My Setup:
NCS: v1.9.1
Visual Code project;
I'm taking the SPI Master as a base and setting my own pinnage as follows (app.overlay):
&zephyr_udc0 {
cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM_0";
};
};
&spi1 {
compatible = "nordic,nrf-spim";
status = "okay";
sck-pin = <14>;
mosi-pin = <13>;
miso-pin = <12>;
cs-gpios = <&gpio0 28 0>;
};
And here is my prj.conf:
CONFIG_BOOT_BANNER=y CONFIG_SPI=y CONFIG_SPI_ASYNC=y CONFIG_SPI_LOG_LEVEL_INF=y CONFIG_LOG=y CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_UART_LINE_CTRL=y CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM sample" CONFIG_SPI_1_NRF_ORC=0x00 CONFIG_SPI_LOOPBACK_DRV_NAME="SPI_1" CONFIG_SPI_LOOPBACK_CS_GPIO=y CONFIG_SPI_LOOPBACK_CS_CTRL_GPIO_DRV_NAME="GPIO_0" CONFIG_SPI_LOOPBACK_CS_CTRL_GPIO_PIN=28
This is the generated zephyr.dts
spi1: spi@40004000 {
compatible = "nordic,nrf-spim";
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40004000 0x1000 >;
interrupts = < 0x4 0x1 >;
status = "okay";
label = "SPI_1";
sck-pin = < 0xe >;
mosi-pin = < 0xd >;
miso-pin = < 0xc >;
cs-gpios = < &gpio0 0x1c 0x0 >;
mx25r6435f@0 {
compatible = "jedec,spi-nor";
reg = < 0x0 >;
spi-max-frequency = < 0x4c4b400 >;
label = "MX25R64";
jedec-id = [ C2 28 17 ];
size = < 0x4000000 >;
wp-gpios = < &gpio0 0x16 0x0 >;
hold-gpios = < &gpio0 0x17 0x0 >;
};
};
Problem:
According to the schematics, I should get the CLK on J47-pin4, but I'm actually getting it on J47-pin9 (checked using Oscilloscope).
Same for MOSI, I'm getting data on J47-pin7 instead of J47-pin5.
I'm trying to understand where I've messed...