1

I was using a device (1) to intercept and read the SPI communication between a microcontroller and a LCD of another device (2). So, I did the conections as showed in the figure below. They use the same voltage level and SPI communication have the same voltage levelas well and I read LCD communication everyday without problems.

sketch of schematic

But, I have some questions:

  1. I think the connections are right, is that correct ? Do you think there is another way, a better way ?

  2. Today, I energized the device 1 before to energize the device 2 (device2 not energized), could this do some harm to device 2 ?

  3. If I energize device 1 before device 2 (device 2 not energized), and somehow the GND line is not connected properly, can I damage device 2 ?

Sorry, about my doubt, but, I made this connection and everything was fine during days, but today, I power on the two and the LCD stayed blank... not responding anymore. I think some connection became falty or, maybe what happened can have something to do with another issue

I'm very sad about it. I don't know what happened . Any help would be great

Daniel
  • 917
  • 1
  • 10
  • 35

2 Answers2

2

If you are just sniffing the signals you don't need the output from the "sniffer". It will conflict with the master. That will not likely cause damage but it could corrupt the signals.

You should connect the grounds together more directly, rather than at the power supply.

Always try adding series resistors (in this case maybe 1K or 470R depending on how high frequency the SPI signal is) to the signals.

It will help protect both ends, especially if your power supply sequencing is not ideal. Otherwise you can cause latch-up and destruction of the chip that gets power later.

P.S. Don't be sad, think of it as a tiny bit of tuition.

Spehro Pefhany
  • 397,265
  • 22
  • 337
  • 893
  • 1
    First, he does need connection to MOSI to read slave responses, that's why the wire is there, not to output anything from the sniffer. Second, I can see the grounds are connected directly on the schematics. Fully supporting adding resistors. – Maple Jun 07 '18 at 23:10
  • Thanks Spehro, but, I always thought putting resistors on communication lines was not a good idea. The arguments to that are: There will be a drop voltage over the resistors and, furthermore, there will be inductive effects too, all this things together can distort and corrupt the signal or maybe there will be no signal with suficient strength to be detected . Am I wrong ? – Daniel Jun 08 '18 at 11:32
  • 2
    If they are too high they may delay the signal/clock too much, but they do provide a measure of protection when used between boards if there are power sequencing issues or the grounds are not connected by a short wire, or the signals go off-board. It's not uncommon, particularly in the clock line, to add a small series resistor even on-board (maybe 33 Ohms) to reduce ringing, but that's a bit different. – Spehro Pefhany Jun 08 '18 at 11:43
  • @Maple the long wires between grounds (back to the power supply) are not acceptable. The sniffer should not drive the MISO pin and contend with the other slave when sniffing any responses. Often communication to an LCD module is mostly or entirely one-way so he will be looking at MOSI. – Spehro Pefhany Jun 08 '18 at 11:50
  • 1
    What is too high? When the product of R and the input+stray capacitances is no longer << the maximum SPI clock period. So you want to keep the wires short. If C=25pF and R is 470 you should be good to a few MHz, maybe more than 10. – Spehro Pefhany Jun 08 '18 at 11:59
  • @Sphero Pefhany ,the SPI clock that I measured was about 2.8us, it is about 356.125 Hz. I will try to put the resistor that you mentioned. I liked very much the information you gave, "When the product of R and the input+stray capacitances is no longer << the maximum SPI clock period" . I understood and it make sense, but, do you have a good reference about it ? I really need to concern about current and voltage drop, I'm really affraid with problems like that I mentioned in the post – Daniel Jun 08 '18 at 16:49
  • 2
    @SpehroPefhany why are you talking about "long wires back to power supply" if there is clear GND connection along with data lines on the schematics? – Maple Jun 08 '18 at 17:58
  • 1
    @Maple Good point. ;-) – Spehro Pefhany Jun 08 '18 at 17:58
  • 1
    @Daniel If the R is too high it won't work reliably. So reduce it. You can check it on an oscilloscope if you have one. If it still works at R*2 it's probably pretty reliable at R. – Spehro Pefhany Jun 08 '18 at 18:18
2

Re: order of powering up. It might be a good idea to always power up your sniffer first. Most of the chips can tolerate Vcc + some small voltage on inputs, but if Vcc is 0 then you have a problem. Adding resistors as @spehro-pefhany suggested could reduce the chance of damage in this case.

And, of course, you should make sure the sniffer does not output anything to SPI bus, i.e. where sniffer is concerned it is not SPI at all, it is 4-bit parallel bus that has to be sampled. What this means is that the pins on sniffer MCU should be configured as regular inputs, not SPI port. You can use interrupts though.

Taking all of the above into account, disconnected ground is no more harmful to device 1 than powering device 2 first, i.e. better not do it. As for harm to device 2, since sniffer does not output anything then it does not matter whether ground connected or not.

Maple
  • 12,567
  • 2
  • 22
  • 60
  • 1
    If the sniffer is a hardware SPI module of an MCU in slave mode (my assumption), the sniffer slave output should not be connected anywhere. It is not read by the hardware so it can only cause trouble. There are two inputs- clock in and MOSI data, so only one line can be monitored at a time. Anything else would probably require either an FPGA or a very fast MCU since clock frequencies can be rather high. LCD displays usually don't say much of interest. ;-) Powering the sniffer first is correct. +1 – Spehro Pefhany Jun 08 '18 at 12:19
  • 1
    I was thinking more of a logic analyzer kind of device. And while fast MCU is required it does not have to be very fast, since parallel data buffer driven by interrupt-on-change should be sufficient for off-line analysis. Since LCDs that do not support read operations usually have pins named SCK/SDI I've assumed OP has either more advanced display or adapter board, both supporting MISO. if OP is not interested in that then, of course, hardware SPI can simplify things. – Maple Jun 08 '18 at 17:54
  • To clarify the above - Two very fast IRQs, one on SS switching logging flag on/off, another on SCLK shifting one byte from port to RAM if flag is set. – Maple Jun 08 '18 at 18:11