Why is a Schmitt trigger useful for SPI

schmitt-triggersensorsignalspi

I understand Schmitt triggers are a great way to convert a floating or noisy signal to either HIGH or LOW depending on a threshold. It is mentioned in other threads that a Schmitt trigger can help with long SPI signals. In my case, I would like to transport a SPI signal over 1 meter, at a 10 MHz clock rate, with each SPI wire twisted with a ground wire, no differential signal, 33 Ohms terminations, 26 or 28AWG wires and the entire cable of wires shielded and connected to Earth. The SPI device is a BME680 temperature, pressure and humidity sensor.

However, why is a Schmitt trigger helpful for communicating with SPI, since the microprocessor already reads a signal as either HIGH or LOW depending on a threshold value? Or are Schmitt triggers only supposed to be integrated on the SPI device end, in my case, the BME680? If so, which SPI pins benefit from a Schmitt trigger?

Best Answer

SPI is a synchronous bus, which means that the number of clock cycles generated by the controller needs to exactly match the number seen by the device.

Running a 20-MHz square wave over a meter of unbalanced cable can result in all kinds of signal integrity issues arising from random noise, internal reflections and crosstalk. If these effects occur on the rising or falling edge of the clock, the device might interpret them as extra clock cycles and get out of sync with the controller.

A Schmitt trigger is much more resistant to that kind of noise on rising and falling edges than an ordinary buffer. It'll basically reject anything that falls within its hysteresis "window". So the most important place for it is at the device end of the SPI clock signal. You might also use one on the MOSI signal to keep the delays more-or-less equalized.

As a side note, it doesn't seem like there's much point to running a temperature, etc. sensor at such a high clock rate to begin with. With long serial buses, lower speeds are advantageous.