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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ATmega48A/PA/88A/PA/168A/PA/328/P19.5 Register Description19.5.1 SPCR – SPI Control RegisterBit 7 6 5 4 3 2 1 00x2C (0x4C) SPIE SPE DORD MSTR CPOL CPHA SPR1 SPR0 SPCRRead/Write R/W R/W R/W R/W R/W R/W R/W R/WInitial Value 0 0 0 0 0 0 0 0• Bit 7 – SPIE: SPI Interrupt EnableThis bit causes the SPI interrupt to be executed if SPIF bit in the SPSR Register is set and the ifthe Global Interrupt Enable bit in SREG is set.• Bit 6 – SPE: SPI EnableWhen the SPE bit is written to one, the SPI is enabled. This bit must be set to enable any SPIoperations.• Bit 5 – DORD: Data OrderWhen the DORD bit is written to one, the LSB <strong>of</strong> the data word is transmitted first.When the DORD bit is written to zero, the MSB <strong>of</strong> the data word is transmitted first.• Bit 4 – MSTR: Master/Slave SelectThis bit selects Master SPI mode when written to one, and Slave SPI mode when written logiczero. If SS is configured as an input and is driven low while MSTR is set, MSTR will be cleared,and SPIF in SPSR will become set. The user will then have to set MSTR to re-enable SPI Mastermode.• Bit 3 – CPOL: Clock PolarityWhen this bit is written to one, SCK is high when idle. When CPOL is written to zero, SCK is lowwhen idle. Refer to Figure 19-3 and Figure 19-4 for an example. The CPOL functionality is summarizedbelow:Table 19-3.CPOL FunctionalityCPOL Leading Edge Trailing Edge0 Rising Falling1 Falling Rising• Bit 2 – CPHA: Clock PhaseThe settings <strong>of</strong> the Clock Phase bit (CPHA) determine if data is sampled on the leading (first) ortrailing (last) edge <strong>of</strong> SCK. Refer to Figure 19-3 and Figure 19-4 for an example. The CPOLfunctionality is summarized below:Table 19-4.CPHA FunctionalityCPHA Leading Edge Trailing Edge0 Sample Setup1 Setup Sample8271D–AVR–05/11175

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

Saved successfully!

Ooh no, something went wrong!