5

I want to use the SPI interface between a PIC and an ENC28J60. However, there are no pins on the PIC called MISO or MOSI that I can use for SPI.

So is SPI just a protocol, which I can use with any PIC pin (by just using any I/O pin, for example, in the same way to communicate with a DH22 sensor), or is SPI hardware (like UART)?

George
  • 1,396
  • 4
  • 16
  • 33
bouqbouq
  • 583
  • 8
  • 27

3 Answers3

14

SPI is a protocol [de facto] standard developed by Motorola. It doesn't define any special hardware, only how signals are used and interpreted.

SPI can be implemented using software (known as "Bit Banging"), or using dedicated hardware, sometimes as part of a "USART" interface (Universal Synchronous/Asynchronous Receive/Transmit).

A hardware implementation is invariably more efficient, since the CPU is free to do other things while a byte of SPI data is being transferred. Also, in chips with DMA the whole SPI subsystem can be completely decoupled from the CPU to run with absolute minimal overhead.

By the way, "SPI Interface" is an example of RAS syndrome. SPI stands for "Serial Peripheral Interface", so "SPI Interface" would equate to "Serial Peripheral Interface Interface". But I digress.

Mark Booth
  • 1,635
  • 3
  • 24
  • 45
Majenko
  • 55,955
  • 9
  • 105
  • 187
7

Try looking for SCK, SDI and SDO - these are commonly used as names for the clock, input and output ports on some micros. I'm not saying that all micros have an SPI interface but a lot do and they are implemented (usually) in hardware just like a UART is implemented in hardware.

Of course, just like a UART you can make a soft UART and you can make a soft SPI interface.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
3

The term "SPI" is a non-trademarked term describing the a connection scheme where one master controller sends information to an arbitrary number of slave devices using a common clock wire and data-output wire, as well as one select wire per slave device, and receives data back using a common data-input wire. A "real" SPI slave device will only pay attention to its clock and data inputs when selected, and will asynchronously float its data output whenever it's deselected (allowing the same pin to be used by other devices). The kind of hardware that's useful for a processor to serve as an SPI master, however, is useful not only for talking to "real" SPI slave devices, but to many other things as well.

For example, if the master only needs to talk to one slave, it won't matter if the slave doesn't float its data output wire when deselected. Further, in many situations it won't matter if a slave continuously captures data which is intended for other devices if it includes a signal which indicates when it should do something with the most recent data it has captured. Consequently, it's very common to use SPI ports to talk to a wide variety of devices which use a clock wire and a data wire, but don't otherwise really "fit" the SPI communications model.

supercat
  • 45,939
  • 2
  • 84
  • 143