I am building a motor controller board (Based on an STM32) driving a motor with a switching frequency of 70KHz. That same board (master) communicates with a sensor (Slave) on another board with short 20cm wires at a frequency of 1.5MHz.

Everything looks pretty clean (and working) when the motor idles.

However when the motor is controlled, the switching noise from the mosfets are triggering weird patterns on the MOSI and CLK lines.

On the oscilloscopes, while the switching noise is there all on 4 lines, only CLK/MOSI are reacting weirdly. CS and MISO both have pull up/down (respectively) which probably explains why they're not affected. During the actual data transmission (CLK/MOSI doing their thing) neither seems affected by the issue that much. As a matter of fact I have decoded a bunch of frames ignoring everything before a clean clock signal and everything is correct on MOSI - MISO is obviously junk due to the sensor seeing garbage in.

I have never encountered a scenario where pull up/down on CLK/MOSI were implemented but I did try to set a pull down on both CLK and MOSI with no visible improvement.

I am driving the NCS line through a GPIO (not using a hardware NSS) and it takes a few microseconds after NCS is brought low and CLK starts the clock. During that time, the erratic behavior of CLK and MOSI is causing the sensor to try to interpret an incoming command and obviously fails.

I have tried to focus on cleaning the switching noise as much as possible, I can continue to try to improve this but I suspect it will never perfect. So I am trying if instead I should try to focus more on understanding what's going on CLK/MOSI.

Has anyone ever seen anything like this?


edit: Hardware pull downs on CLK/MOSI helps getting those ripple down faster but it still doesn't prevent these jumps from triggering the sensor into trying to interpret the incoming data.

-1st screenshot is motor idle -2nd screenshot is motor active

enter image description here enter image description here

  • \$\begingroup\$ Have you tried the same sort of pulldown on CLK and MOSI? What does the datasheet/user guide say the Master does with those signals outside an SPI transmission? If it tristates them, or makes them a GPIO input, you'd expect to see that sort of noise (If it could make them an output, should be OK) \$\endgroup\$
    – user16324
    Commented Oct 23, 2020 at 19:24
  • \$\begingroup\$ Yes I have tried internal pull down's and external's. I didn't have the oscilloscope hooked up on the test with external pull down's so I'll have to redo that. I have to look at the datasheet of H743 again \$\endgroup\$
    – zytra
    Commented Oct 23, 2020 at 19:48

2 Answers 2


I found the fix for this. In CubeMX (SPI configuration) there is an option called "Master Keep IO State", by default it is disabled.

Enabling it fixed the floating levels of CLK/MOSI and the sensor is no longer getting triggered by randoms levels on CLK/MOSI.

I am now left with switching noise issues, which are beyond the scope of that question.

Hopefully this will help someone else.

enter image description here


I would say you may have problems with ground connection? My opinion is a little amateur, but this is how I see it and this is what I would consider among other things (maybe): at some point your ground current from motor (with all its spikes) interferes with the signal return current: the ground currents of the motor and signal flow in the same place on ground plane. I would try to separate ground path for SPI connection and connect it to power ground only in strictly one place. No idea if it helps, your problem is a kind of open question thing where you just need to inspect and try stuff and see what helps. But I would start with looking at ground connections here. Maybe some ferrite beads on the communicating chips' power lines too.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.