Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

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 AVR microcontroller is clocked at 16MHz then SPI clock may reach 8MHz in master mode. SPI communication interface is standard way to talk to other peripherals around MCU like flash, EEPROM, sensors and even other microcontrollers. Generally speaking, devices communicate over 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 SS line is omitted while 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 SPI interface there are options in selecting right slave device: one is to use dedicated SS pins for each slave or if slave supports this use address byte in data packets to pick one (for instance in MCP23S17 I/O expanders). Continue reading