Few tips for building reliable SPI interface

Many SPI tutorials use the standard notation of bus design where each device is directly in parallel connected to SCK, MISO, MOSI, and CS lines. This usually works without a problem, but there can be problems when more than one SPI device is on the bus. There might be several issues that can occur on poor design. Here are three suggestions for better SPI improvements: Pull up resistor helps to prevent the response from multiple devices at once. This might come from poor software design when CS pins aren’t appropriately initialized. The second problem is with MISO pin. Some SPI devices don’t enter tri-state even when CS is pulled high. So when talking to other SPI devices this will cause failures. Be sure to check if SPI device supports tri-state when inactive; otherwise, add external tri-state buffer like 74AHC1G125. And last thing is SPI transactions. In systems where multiple SPI devices are used, there is a risk of using different settings that were selected on different devices. Most importantly, transactions can ensure exclusive use of the SPI bus when needed….

Continue reading

Serial peripheral interface in AVR microcontrollers

Serial Peripheral Interface (SPI) is the fastest synchronous communication interface allowing data transfer speeds up to half of the core clock. If the AVR microcontroller is clocked at 16MHz, then the SPI clock may reach 8MHz in master mode. SPI communication interface is a standard way to talk to other peripherals around MCU like a flash, EEPROM, sensors, and even other microcontrollers. Generally speaking, devices communicate over the SPI interface using four wires MISO (Master In Slave Out), MOSI (Master Out Slave In), SCK (synchronization clock), and SS (Slave Select). Usually, if only one slave device is used, the SS line is omitted while the slave chip select pin is connected to the GND. However, this is a particular case. In all other cases SS pin has to be controlled manually in software – this isn’t handled automatically. If more slaves are connected to the SPI interface, there are options in selecting the suitable slave device: one is to use dedicated SS pins for each slave, or if the slave supports this, use the address byte in data packets to…

Continue reading