Is there a difference between the MISO/MOSI pins and the DI/DO pins? Is it true that MISO/MOSI is for SPI communication where DI/DO is for USI communication? What is the difference exactly?
-
\$\begingroup\$ It is unclear to me what you are referring to. What device or board are you talking about ? In general MISO/MOSI DI/DO are just names given to pins. In general you can program the pins to do whatever you want. So there is no difference. \$\endgroup\$– BimpelrekkieJun 3, 2015 at 14:15
-
\$\begingroup\$ I am using the ATtiny 861a with two slaves. It communicates via USI but can be programmed for SPI communication(along with making a pin a Chip Select). How would I wire my circuit? Should I look at the DI/DO pins or just use the MISO/MOSI pins? \$\endgroup\$– TherusscherJun 3, 2015 at 14:22
-
\$\begingroup\$ I think it is common to use MISO/MOSI on the master and DI/DO on the slaves. But again, they're just inputs/outputs and can be programmed to do almost anything. \$\endgroup\$– BimpelrekkieJun 3, 2015 at 14:29
-
\$\begingroup\$ So if both of my slaves use SPI communication would I be connecting the slaves MISO line to the MISO line of my MCU or would I need to connect the MISO lines of my slaves to the DI/DO pin of the MCU? Is the DI pin the input to the MCU or the input to the slave? \$\endgroup\$– TherusscherJun 3, 2015 at 14:46
-
\$\begingroup\$ Perhaps you should study: learn.sparkfun.com/tutorials/i2c \$\endgroup\$– BimpelrekkieJun 3, 2015 at 14:56
1 Answer
Follow along in the datasheet.
Chapter 13: USI means Universal Serial Interface. It's a peripheral that can be programmed for either three-wire (SPI) or two-wire (I2C) communications. This ability to be configured for either serial protocol is why it's called "universal". USI is not a communications protocol, it's the configurable peripheral.
Chapter 13.3.1: The USI three-wire protocol is compatible with SPI. Use pins DI, DO, and USCK in this mode. This is for when you are using the microcontroller as an SPI master (13.3.2) or slave (13.3.3) for your application.
Chapter 18.6: The MISO and MOSI pins are used during serial programming of the microcontroller's flash and EEPROM memories. Here the microcontroller is acting as a slave to some external programmer that is the master.
Chapter 10.2.2: The MISO pin really the same pin as DO on Port B. And MOSI is the same as DI on port B. When you've configured port B for serial programming of the internal memories then the microcontroller is acting as a slave and the pins are referred to as MISO and MOSI. When you've configured port B for SPI communications with other devices for your application then the microcontroller could be a master or a slave. In this case the pins are referred to as DO and DI because only data direction is known and whether the microcontroller is a master or slave is application dependent.
To use the microcontroller as a master and communicate with a slave SPI device connect:
- The microcontroller's DI (input) pin to the slave device's MISO (slave output) pin.
- The microcontroller's DO (output) pin to the slave device's MOSI (slave input) pin.
- The microcontroller's USCK pint to the appropriate clock pin on the slave device