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