I'm trying to connect the same SPI instance to multiple devices in parallel(besides CS GPIO of course) - however, I tried multiple combinations without great success.
I'm using NCS v2.2.0, nRF52840 / nRF5340 as my main target MCUs
I'm trying to connect the same SPI instance to multiple devices in parallel(besides CS GPIO of course) - however, I tried multiple combinations without great success.
I'm using NCS v2.2.0, nRF52840 / nRF5340 as my main target MCUs
Hello,
As Rune mentions: could you please clarify whether you mean to have multiple secondary devices on the same SPI bus (communicating with each one in series with the other), or are you looking to communicate in parallel with all the devices?
Based on the wording of your post I will assume the former.
If you are using the SPIM driver then you will need to control the SS gpio yourself, since this is not done by the driver directly.
I.e asserting the SS gpio for the specific device you are looking to communicate to, before starting the transfer.
however, I tried multiple combinations without great success.
Could you elaborate on what you have tried, and what the results have been?
Best regards,
Karl
This is a good illustration of my desired use case Karl Ylvisaker.
Could you elaborate on what you have tried, and what the results have been?
I tried to do something like this:
&spi1 { status = "okay"; pinctrl-0 = <&spi1_pins>; #address-cells = <1>; #size-cells = <0>; adg731_1: adg731_1@0 { compatible = "adi,adg731"; reg = <0>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_1"; cs-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>; }; adg731_2: adg731_2@1 { compatible = "adi,adg731"; reg = <1>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_2"; cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>; }; adg731_3: adg731_3@2 { compatible = "adi,adg731"; reg = <2>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_3"; cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; }; adg731_4: adg731_4@3 { compatible = "adi,adg731"; reg = <3>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_4"; cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; }; };
This is a good illustration of my desired use case Karl Ylvisaker.
Could you elaborate on what you have tried, and what the results have been?
I tried to do something like this:
&spi1 { status = "okay"; pinctrl-0 = <&spi1_pins>; #address-cells = <1>; #size-cells = <0>; adg731_1: adg731_1@0 { compatible = "adi,adg731"; reg = <0>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_1"; cs-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>; }; adg731_2: adg731_2@1 { compatible = "adi,adg731"; reg = <1>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_2"; cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>; }; adg731_3: adg731_3@2 { compatible = "adi,adg731"; reg = <2>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_3"; cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; }; adg731_4: adg731_4@3 { compatible = "adi,adg731"; reg = <3>; spi-max-frequency = <DT_FREQ_KHZ(1000)>; label = "ADG731_4"; cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; }; };
Hello again,
Thank you for clarifying.
What do you see when you attempt to communicate with each of these devices, using this setup?
Do you have access to a logic analyzer, so that you can scope what is happening on the SPI lines, and to verify that the correct CS-gpio is being asserted as expected?
Best regards,
Karl
I have access to a logic analyzer, but I'm getting errors that prevent even the build of this code
Hello,
Could you include the full errors from your build?
Please use the Insert -> Code option when sharing code or logs here on DevZone.
Best regards,
Karl