11.07.2015 Views

ATMega chip full datasheet - UCSD Department of Physics

ATMega chip full datasheet - UCSD Department of Physics

ATMega chip full datasheet - UCSD Department of Physics

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ATmega48A/PA/88A/PA/168A/PA/328/PFigure 19-1. SPI Block Diagram (1)DIVIDER/2/4/8/16/32/64/128SPI2XSPI2XNote: 1. Refer to Figure 1-1 on page 2, and Table 14-3 on page 84 for SPI pin placement.The interconnection between Master and Slave CPUs with SPI is shown in Figure 19-2 on page170. The system consists <strong>of</strong> two shift Registers, and a Master clock generator. The SPI Masterinitiates the communication cycle when pulling low the Slave Select SS pin <strong>of</strong> the desired Slave.Master and Slave prepare the data to be sent in their respective shift Registers, and the Mastergenerates the required clock pulses on the SCK line to interchange data. Data is always shiftedfrom Master to Slave on the Master Out – Slave In, MOSI, line, and from Slave to Master on theMaster In – Slave Out, MISO, line. After each data packet, the Master will synchronize the Slaveby pulling high the Slave Select, SS, line.When configured as a Master, the SPI interface has no automatic control <strong>of</strong> the SS line. Thismust be handled by user s<strong>of</strong>tware before communication can start. When this is done, writing abyte to the SPI Data Register starts the SPI clock generator, and the hardware shifts the eightbits into the Slave. After shifting one byte, the SPI clock generator stops, setting the end <strong>of</strong>Transmission Flag (SPIF). If the SPI Interrupt Enable bit (SPIE) in the SPCR Register is set, aninterrupt is requested. The Master may continue to shift the next byte by writing it into SPDR, orsignal the end <strong>of</strong> packet by pulling high the Slave Select, SS line. The last incoming byte will bekept in the Buffer Register for later use.When configured as a Slave, the SPI interface will remain sleeping with MISO tri-stated as longas the SS pin is driven high. In this state, s<strong>of</strong>tware may update the contents <strong>of</strong> the SPI DataRegister, SPDR, but the data will not be shifted out by incoming clock pulses on the SCK pinuntil the SS pin is driven low. As one byte has been completely shifted, the end <strong>of</strong> TransmissionFlag, SPIF is set. If the SPI Interrupt Enable bit, SPIE, in the SPCR Register is set, an interrupt8271D–AVR–05/11169

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!