SPI Chip Select Toggling Problem on imx8mplus

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI Chip Select Toggling Problem on imx8mplus

285 Views
Baha_Yenioglu
Contributor II

Greetings,
I’m currently trying to communicate between the i.MX 8M Plus and some module via SPI. However, I’m seeing that the chip-select line toggles on each byte transfer, when it should stay low for the entire transaction for the command and its arguments. Is this the default behavior? If so, how can I keep CS asserted throughout the whole communication? Also, what's the default SPI_MODE in terms of phase and polarity of the clock ?

Baha_Yenioglu_0-1754317519462.png

 

0 Kudos
Reply
2 Replies

275 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @Baha_Yenioglu!

Thank you for reaching out to NXP Support!

 

Could you please share your device tree configuration?
I've encountered similar behavior before when the configuration doesn't follow the structure shown in the example below:

&ecspi2 {
    #address-cells = <1>;
    #size-cells = <0>;
    fsl,spi-num-chipselects = <1>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;
    cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;
    status = "okay";

    spidev1: spi@0 {
        reg = <0>;
        compatible = "rohm,dh2228fv";
        spi-max-frequency = <500000>;
    };
};

...

pinctrl_ecspi2: ecspi2grp {
    fsl,pins = <
        MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK      0x82
        MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI      0x82
        MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO      0x82
    >;
};

pinctrl_ecspi2_cs: ecspi2cs {
    fsl,pins_SS0__GPIO5_IO13        0x40000
    >;
};

 

Let me know if your configuration differs or if you need help adapting it.

Best regards,
Chavira

0 Kudos
Reply

262 Views
Baha_Yenioglu
Contributor II
After I applied this structure to my dts, CS stayed stay low for the entire transaction.
Thanks..
%3CLINGO-SUB%20id%3D%22lingo-sub-2146245%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ESPI%20Chip%20Select%20Toggling%20Problem%20on%20imx8mplus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2146245%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EGreetings%2C%3CBR%20%2F%3EI%E2%80%99m%20currently%20trying%20to%20communicate%20between%20the%20i.MX%208M%20Plus%20and%20some%20module%20via%20SPI.%20However%2C%20I%E2%80%99m%20seeing%20that%20the%20chip-select%20line%20toggles%20on%20each%20byte%20transfer%2C%20when%20it%20should%20stay%20low%20for%20the%20entire%20transaction%20for%20the%20command%20and%20its%20arguments.%20Is%20this%20the%20default%20behavior%3F%20If%20so%2C%20how%20can%20I%20keep%20CS%20asserted%20throughout%20the%20whole%20communication%3F%20Also%2C%20what's%20the%20default%20SPI_MODE%20in%20terms%20of%20phase%20and%20polarity%20of%20the%20clock%20%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Baha_Yenioglu_0-1754317519462.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Baha_Yenioglu_0-1754317519462.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F350826i4E5E49604FC712A9%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Baha_Yenioglu_0-1754317519462.png%22%20alt%3D%22Baha_Yenioglu_0-1754317519462.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2146592%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SPI%20Chip%20Select%20Toggling%20Problem%20on%20imx8mplus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2146592%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EAfter%20I%20applied%20this%20structure%20to%20my%20dts%2C%20CS%20stayed%20stay%20low%20for%20the%20entire%20transaction.%3CBR%20%2F%3EThanks..%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2146314%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SPI%20Chip%20Select%20Toggling%20Problem%20on%20imx8mplus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2146314%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F251546%22%20target%3D%22_blank%22%3E%40Baha_Yenioglu%3C%2FA%3E!%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20reaching%20out%20to%20NXP%20Support!%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ECould%20you%20please%20share%20your%20device%20tree%20configuration%3F%3CBR%20%2F%3EI've%20encountered%20similar%20behavior%20before%20when%20the%20configuration%20doesn't%20follow%20the%20structure%20shown%20in%20the%20example%20below%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%26amp%3Becspi2%20%7B%0A%20%20%20%20%23address-cells%20%3D%20%26lt%3B1%26gt%3B%3B%0A%20%20%20%20%23size-cells%20%3D%20%26lt%3B0%26gt%3B%3B%0A%20%20%20%20fsl%2Cspi-num-chipselects%20%3D%20%26lt%3B1%26gt%3B%3B%0A%20%20%20%20pinctrl-names%20%3D%20%22default%22%3B%0A%20%20%20%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_ecspi2%20%26amp%3Bpinctrl_ecspi2_cs%26gt%3B%3B%0A%20%20%20%20cs-gpios%20%3D%20%26lt%3B%26amp%3Bgpio5%2013%20GPIO_ACTIVE_LOW%26gt%3B%3B%0A%20%20%20%20status%20%3D%20%22okay%22%3B%0A%0A%20%20%20%20spidev1%3A%20spi%400%20%7B%0A%20%20%20%20%20%20%20%20reg%20%3D%20%26lt%3B0%26gt%3B%3B%0A%20%20%20%20%20%20%20%20compatible%20%3D%20%22rohm%2Cdh2228fv%22%3B%0A%20%20%20%20%20%20%20%20spi-max-frequency%20%3D%20%26lt%3B500000%26gt%3B%3B%0A%20%20%20%20%7D%3B%0A%7D%3B%0A%0A...%0A%0Apinctrl_ecspi2%3A%20ecspi2grp%20%7B%0A%20%20%20%20fsl%2Cpins%20%3D%20%26lt%3B%0A%20%20%20%20%20%20%20%20MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK%20%20%20%20%20%200x82%0A%20%20%20%20%20%20%20%20MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI%20%20%20%20%20%200x82%0A%20%20%20%20%20%20%20%20MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO%20%20%20%20%20%200x82%0A%20%20%20%20%26gt%3B%3B%0A%7D%3B%0A%0Apinctrl_ecspi2_cs%3A%20ecspi2cs%20%7B%0A%20%20%20%20fsl%2Cpins_SS0__GPIO5_IO13%20%20%20%20%20%20%20%200x40000%0A%20%20%20%20%26gt%3B%3B%0A%7D%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3ELet%20me%20know%20if%20your%20configuration%20differs%20or%20if%20you%20need%20help%20adapting%20it.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EChavira%3C%2FP%3E%3C%2FLINGO-BODY%3E