2019-09-10 02:37 AM
I am trying to implement a star SPI interface, using STM32F4 as a single master, and interfaces with multiple STM32F4 MCU using SW managed NSS.
I have made sure that SSI is cleared when NSS is activated and set when NSS is deactivated so that the SCK on the common line will not shift the data out of the deselected slave. However, I am still having corrupted data received by the master and I think the problem is due to the fact that the MISO pin of deselected slave is not in High Impedance state.
While searching through the forum, I stumbled upon a similar post https://community.st.com/s/question/0D50X00009XkZWvSAN/multislave-spi-using-stm32f7s, in which it is mentioned that the MISO of all slaves should be configured in Alternate Function Open Drain mode instead of Alternate Function Push Pull, in the Reference Manual of STM32F7.
I gave it a try but the Master was then not able to read any data from the selected slave anymore.
My questions are:
End note: I did try to toggle the MISO pins between input mode when deselected and AF_PP when selected, as a workaround and it does work. Just wish to have the fastest approach. Using HW managed NSS did not seem to work.
Thanks in advance for answering
Solved! Go to Solution.
2019-09-10 04:01 AM
> I changed the GPIO mode of NSS pin to EXTI on falling edge instead of AF_PP
There is no separate EXTI and AF_PP mode. This is a Cube nonsense; we see it here in forum way too often. EXTI is independent of MODER setting; as long as the pin is not set to Analog, you can use it as EXTI in parallel to whatever other setting you have.
JW
2019-09-10 03:16 AM
> I think the problem is due to the fact that the MISO pin of deselected slave is not in High Impedance state.
Confirm that by observing the levels on the bus by oscilloscope.
> I have made sure that SSI is cleared when NSS is activated and set when NSS is deactivated
In Slaves? You don't need to do that.
SSM is set how?
> I stumbled upon a similar post https://community.st.com/s/question/0D50X00009XkZWvSAN/multislave-spi-using-stm32f7s, in which it is mentioned
> that the MISO of all slaves should be configured in Alternate Function Open Drain mode instead of Alternate Function Push Pull, in the Reference Manual of STM32F7.
Yes, it is; and in the forked thread https://community.st.com/s/question/0D50X00009XkaBbSAJ/does-spi-in-slave-mode-threestate-miso-on-inactive-nss-or-not the answer (from somebody whom I suspect is/was from the Prague support crew) clearly indicates it is nonsense. @Amel NASRI @Imen DAHMEN can you please confirm that it's a nonsense, and if so, can you please initiate purging this from the RMs (I've seen itin more than just one)?
JW
2019-09-10 03:50 AM
>> I think the problem is due to the fact that the MISO pin of deselected slave is not in High Impedance state.
>Confirm that by observing the levels on the bus by oscilloscope.
It is tedious at the moment as the PCB made by our hardware engineer omitted test points on the SPI lines. My hypothesis is made on the experiments that the interface works when I toggle the MISO between Input and AF_PP.
>> I have made sure that SSI is cleared when NSS is activated and set when NSS is deactivated
>In Slaves? You don't need to do that.
Yes you are right.
I said that in my OP I did try to use HW to manage NSS in slave but MISO did not seem to change to Hi-Z, I did not tell the complete story. My application requires the NSS to trigger an interrupt when pulled low on the slave, so I changed the GPIO mode of NSS pin to EXTI on falling edge instead of AF_PP, and am thinking whether this may have rendered MISO not being abled to be tri-stated when NSS is high...will try to confirm this when I have the chance.
2019-09-10 04:01 AM
> I changed the GPIO mode of NSS pin to EXTI on falling edge instead of AF_PP
There is no separate EXTI and AF_PP mode. This is a Cube nonsense; we see it here in forum way too often. EXTI is independent of MODER setting; as long as the pin is not set to Analog, you can use it as EXTI in parallel to whatever other setting you have.
JW
2019-09-10 05:18 AM
Hi JW,
Thanks for the tip and I tried to change the slaves' NSS to be HW managed, and having them triggering EXTI as well. It now works as expected. Indeed I was misled by MXCube.
So I would like to:
Thanks a lot!