5
\$\begingroup\$

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)?

\$\endgroup\$
  • 2
    \$\begingroup\$ Study the MSSP module. \$\endgroup\$ – Matt Young Nov 19 '14 at 14:04
  • 3
    \$\begingroup\$ Don't just look at the pin labels. Read the datasheet for the PIC. \$\endgroup\$ – jwygralak67 Nov 19 '14 at 19:16
  • \$\begingroup\$ When you say "the PIC", are you talking about a 200MHz 144-pin PIC32, or a 4MHz 8-pin PIC12? \$\endgroup\$ – davidcary Nov 19 '14 at 21:30
  • \$\begingroup\$ im takliking about PIC18F4550 \$\endgroup\$ – Makhlouf GHARBI Nov 20 '14 at 5:01
  • \$\begingroup\$ As jwygralak67 suggested, you might consider reading what page 1 and pages 197-206 of the PIC18F4550 datasheet say about SPI. \$\endgroup\$ – davidcary Dec 1 '14 at 17:09
14
\$\begingroup\$

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.

\$\endgroup\$
  • 5
    \$\begingroup\$ "SPI interface" would be a manifestation of RAS syndrome. \$\endgroup\$ – ntoskrnl Nov 19 '14 at 16:55
  • \$\begingroup\$ Definitely a better way of putting it @ntoskrnl. \$\endgroup\$ – Mark Booth Nov 25 '14 at 17:38
7
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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