a Serial Peripheral Interace (SPI). Embedded RISC Microcontroller Core Peripheral

Similar documents
UART. Embedded RISC Microcontroller Core Peripheral

When is Data Susceptible to Corruption

Interrupt Controlled UART

Secure Microcontrollers for Smart Cards. AT90SC Summary

8-bit RISC Microcontroller. Application Note. AVR151: Setup And Use of The SPI

Preparations. Creating a New Project

Product Description. Application Note. AVR360: XmodemCRC Receive Utility for the AVR. Features. Theory of Operation. Introduction

AT17A Series FPGA Configuration EEPROM Memory. Application Note. FPGAs. AT17A Series Conversions from Altera FPGA Serial Configuration Memories

OrCAD Support for Atmel PLDs. Application Note. OrCAD Support for Atmel PLDs. Overview

AT94K Series Field Programmable System Level Integrated Circuit. Application Note. FPSLIC Baud Rate Generator

Parallel EEPROM Die Products. Die Products. Features. Description. Testing

8-bit RISC Microcontroller. Application Note. AVR 305: Half Duplex Compact Software UART

spi 1 Fri Oct 13 13:04:

P_D_OUT[31:0] SPI_INT SPI_MOSI_OUT SPI_MOSI_OEN

2-wire Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 AT24C16

2-wire Serial EEPROM AT24C512. Preliminary. 2-Wire Serial EEPROM 512K (65,536 x 8) Features. Description. Pin Configurations.

Battery-Voltage. 16K (2K x 8) Parallel EEPROMs AT28BV16. Features. Description. Pin Configurations

Atmel-Synario CPLD/PLD Design Software ATDS1100PC ATDS1120PC ATDS1130PC ATDS1140PC. Features. Description

2-wire Serial EEPROM AT24C512

design cycle involving simulation, synthesis

EPROM. Application Note CMOS EPROM. Interfacing Atmel LV/BV EPROMs on a Mixed 3-Volt/5- Volt Data Bus

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

2-wire Serial EEPROMs AT24C128 AT24C256. Features. Description. Pin Configurations. 128K (16,384 x 8) 256K (32,768 x 8)

1-Megabit (128K x 8) Low Voltage Paged Parallel EEPROMs

3-wire Serial EEPROMs AT93C46 AT93C56 AT93C57 AT93C66

hex file. The example described in this application note is written for the AT94K using the FPSLIC Starter Kit. Creating a New Project

Serial DataFlash. Application Note. Using Atmel s Serial DataFlash. Introduction (AN-4)

2-wire Serial EEPROM Smart Card Modules AT24C32SC AT24C64SC

AT91 ARM Thumb Microcontrollers. Application Note. AT91M55800A Clock Switching Considerations using Advanced Power Management Controller.

ATICE10... User Guide

FPGA Configuration EEPROM Memory AT17C020A AT17LV020A

MARC4. Application Note. Hints and Tips for Hard- and Software Developments with MARC4 Microcontrollers

FPGA Configuration EEPROM Memory. Application Note. Programming Atmel s EEPROMs: AT17LV020(A) vs. AT17LV002(A) Introduction.

AT40K FPGA IP Core AT40K-FFT. Features. Description

TSC695. Application Note. Annulled Cycle Management on the TSC695. References

256K (32K x 8) 3-volt Only Flash Memory

SPI Serial EEPROMs AT25010 AT25020 AT SPI, 1K Serial E 2 PROM. Features. Description. Pin Configurations 8-Pin PDIP. 1K (128 x 8) 2K (256 x 8)

Battery-Voltage. 256K (32K x 8) Parallel EEPROMs AT28BV256. Features. Description. Pin Configurations

AT17 Series FPGA. Configuration Memory. Application Note. In-System Programming Circuits for AT17 Series Configurators with Atmel and Xilinx FPGAs

AT17(A) Series FPGA Configuration Memory. Application Note

8-bit Microcontroller. Application Note. AVR031: Getting Started with ImageCraft C for AVR

8-bit Microcontroller. Application Note. AVR320: Software SPI Master

AT89C5131 Starter Kit... Software User Guide

DIP Top View VCC WE A17 NC A16 A15 A12 A14 A13 A8 A9 A11 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 A10 CE I/O7 I/O6 I/O5 I/O4 I/O3 I/O1 I/O2 GND.

MP3 Player Reference Design Based on AT89C51SND1 Microcontroller... User Guide

FPGA Configurator Programming Kit (Enhanced) ATDH2200E. Features. Description

8-Megabit 5-volt Only Serial DataFlash AT45D081. Features. Description

AVR -based Bridge between Full-speed USB and Fast Serial Asynchronous Interfaces AT76C711

8051 Microcontrollers. Application Note. Migration from AT89C5131 & AT89C5131A-L to AT89C5131A-M

8-bit Microcontroller. Application Note. AVR030: Getting Started with C for AVR

Application Note Microcontrollers. C Flash Drivers for T89C51RC/RB/IC2 and AT89C51RC/RB/IC2 for Keil Compilers

ATAVRAUTO User Guide

Section 1 ATAVRAUTOEK1 Getting Started

shown in Figure 3. An example where the command 0x35 is sent to system 5 is shown in Figure 4. Figure 2. RC5 Frame Format Figure 3.

4-Megabit (512K x 8) 5-volt Only 256-Byte Sector Flash Memory AT29C040A. Features. Description. Pin Configurations

AT89ISP Programmer Cable Introduction AT89ISP Programmer Cable Parallel Port Settings Application Note AT89ISP Software AT89ISP Cable polarized

CAN Microcontrollers. Application Note. Migrating from T89C51CC01 to AT89C51CC03. Feature Comparison

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

64K (8K x 8) Low-voltage Parallel EEPROM with Page Write and Software Data Protection AT28LV64B. 3-Volt, 64K E 2 PROM with Data Protection

Two-wire Serial EEPROM Smart Card Modules 128K (16,384 x 8) 256 (32,768 x 8) AT24C128SC AT24C256SC. Features. Description VCC NC

Bluetooth General Information White Paper

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

ATAVRAUTO User Guide

AVR32 UC3 Software Framework... User Manual

System Designer. Programmable SLI AT94K/AT94S Series. Features. Description

Migration From AT89C51SND1C to AT83C51SDN1C. Application Note. MP3 Microcontrollers

a clock signal and a bi-directional data signal (SCL, SDA)

Embedded RISC Microcontroller Core ARM7TDMI

4-megabit (512K x 8) Single 2.7-volt Battery-Voltage Flash Memory AT49BV040 AT49BV040T AT49LV040 AT49LV040T

1-Megabit (128K x 8) 5-volt Only Flash Memory AT29C010A. Features. Description. Pin Configurations

AT91 ARM Thumb Microcontrollers. Application Note. AT91 Host Flash Loader. 1. Package Contents. 2. Definition of Terms. 3.

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

CAN, 80C51, AVR, Microcontroller. Application Note

FPGA Configuration EEPROM Memory AT17C65 AT17LV65 AT17C128 AT17LV128 AT17C256 AT17LV256

AT45DB Megabit 2.7-Volt Only Serial DataFlash AT45DB041. Features. Description. Pin Configurations

EE 456 Fall, Table 1 SPI bus signals. Figure 1 SPI Bus exchange of information between a master and a slave.

AT89STK-09 Starter Kit for AT83C26... User Guide

System Designer. Programmable SLI AT94K/AT94S Series. Features. Description

Serial Peripheral Interface (SPI)

Programming Flash Devices

Two-wire Serial EEPROM Smart Card Modules 1K (128 x 8) 2K (256 x 8) 4K (512 x 8) 8K (1024 x 8) 16K (2048 x 8)

AT17F Series. Application Note. Programming Circuits for AT17F Series Configurators with Xilinx FPGAs. 1. Introduction

Section 5 SERCOM. Tasks SPI. In this section you will learn:

SPI Serial EEPROMs AT25010 AT25020 AT SPI, 1K Serial E 2 PROM

Serial Peripheral Interface (SPI) Host Controller Data Sheet

AVR32401: AVR32 AP7 Linux Interfacing DataFlash. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

80C51 MCUs T89C51AC2. Errata Sheet

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

SOIC VCC RESET A11 A10 A9 A8 A7 A6 A5 A4 A12 A13 A14 A15 A16 A17 A18 A19 NC NC NC NC I/O0 RDY/BUSY I/O1 I/O7 I/O6 I/O5 I/O4 VCC I/O2 I/O3 GND GND

The 9S12 Serial Peripheral Inteface (SPI) Huang Section 10.2 through 10.6 SPI Block User Guide

1-megabit (64K x 16) 5-volt Only Flash Memory AT49F1024 AT49F1025

Menu. What is SPI? EEL 3744 EEL 3744 SPI

8-bit Microcontroller. Application Note. AVR033: Getting Started with the CodeVisionAVR C Compiler

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Design with Microprocessors

Application Note. Microcontrollers. Using Keil FlashMon Emulator with AT89C51CC01/03 AT89C51CC01/ Summary. 2. Background overview

Interfacing the internal serial EEPROM

Rad Hard FPGA. AT40KEL-DK Design Kit Content. Description. Kit Content. Reference Material. Support

Programmable SLI AT40K AT40KAL AT94K. Application Note. Implementing a Single-coefficient Multiplier

8-bit Microcontroller. Application Note. AVR033: Getting Started with the CodeVisionAVR C Compiler

Transcription:

Features Full-duplex, 3-wire Synchronous Data Transfer Master or Slave Operation Maximum Bit Frequency of f CLOCK /4 (in M-bits/second) LSB First or MSB First Data Transfer Four Programmable Bit Rates End of Transmission Interrupt Flag Write Collision Flag Protection Wakeup from Idle Mode (Slave Mode Only) Description The AVR embedded RISC microcontroller core is a low-power, CMOS 8-bit microprocessor based on the AVR enhanced RISC architecture. With this core, Atmel proposes a Serial Peripheral Interace (SPI). The SPI allows high-speed synchronous data transfers between the AVR core and peripheral devices or between the AVR core and other cores. Serial Peripheral Interface (SPI) Figure 1. SPI Pin Configuration AVR Control adr[5:0] cp2 dbus_in[7:0] iore iowe ireset dbus_out[7:0] out_en AVR Control Embedded RISC Microcontroller Core Peripheral SPI misoi mosii scki ss_b SPI misoo mosio scko spe spimaster SPI Slave Programming Mode IRQ Scan Test por spiextload spiack test_se test_si1 test_si2 spidwrite spiload spirq test_so1 test_so2 Slave Programming Mode IRQ Scan Test Rev. 1127A 10/99 1

P Table 1. Pin Description Pin Name Description Direction Comments cp2 CPU clock Input ireset Synchronous reset Input AVR Control Any register in the SPI will update its contents only on the positive edge of cp2 When high, ireset will reset internal registers by reading the value on dbus_in which is forced to zero by the AVR Core dbus_out[7: 0] Data bus output Output Valid only when accompanied by a strobe on out_en dbus_in[7:0] Data bus input Input out_en Output enable strobe Output When high, out_en indicates that the SPI requires control of the data bus adr[5:0] I/O address inputs Input Valid only when accompanied by a strobe on iore or iowe iore I/O read strobe Input Used to read the contents of the I/O location addressed by adr iowe I/O write strobe Input Used to update the contents of the I/O location addressed by adr ss_b SPI slave select Input spe SPI enable Output spimaster SPI is master Output SPI Used to select SPI activity, slave or master. If active, turns off the SPI master flag (SPCR[4]) When high, spe indicates that the SPI peripheral is enabled. This mirrors the spi enable flag (SPCR[6]) When high, indicates that SPI peripheral is in master mode. This mirrors the SPI master flag (SPCR[4]) scko SPI clock ouput Output Used to generate SPI clock in master mode scki SPI clock input Input Used to latch SPI data (MOSII and MISOO) in SPI slave mode mosio Master out, slave in output Output Used for data output in master mode misoi Master in, slave out input Input Used for data input in master mode misoo Master in, slave out output Output Used for data output in slave mode mosii Master out, slave in input Input Used for data input in slave mode spirq SPI irq line Output spiack SPI interrupt acknowledge Input Used to reset SPI interrupt flag IRQ When high, indicates that the SPI interrupt flag is set (SPSR[7]) and that SPI interrupt is enabled (SPCR[7]) Test Scan test_se Scan enable input Input Active high. Enable scan shift. test_mode Test mode input Input Active high. Must be set during scan testing. test_si1 Scan chain 1 input Input Scan chain 1 input. test_si2 Scan chain 2 input Input Scan chain 2 input. test_so1 Scan chain 1 output Output Scan chain 1 input. test_so2 Scan chain 2 output Output Scan chain 2 output. 2 SPI Core

SPI Core Table 1. Pin Description (Continued) Pin Name Description Direction Comments Slave Programming Mode por Power on reset Input spiextload External data load enable Input spiload Active data load Output spidwrite Active data write Output Used to select SPI Flash/EEPROM programming slave mode. This mode is enabled with por low and ireset high. Enable parallel load of transmit shift register from dbus_in during slave programming mode. Indicates that the transmit shift register is updated on rising edge of cp2 with dbus_in value. This strobe will remain active until spiextload goes low. Indicates that a byte has been sent and data on dbus_out is valid for reading. Figure 2. SPI Block Diagram misoo misoi MISO cp2 mosio mosii MOSI scki scko ss_b SCK spimaster SS spe 3

Description The SPI is a fully synchronous peripheral. It can run at a F CP2 /4 maximum baud rate which is controlled by SPCR[1:0]. The SPI has one interrupt request output called spirq. This interrupt is controlled as follows: Cleared by ireset Set when receive FIFO is full Cleared by acknowledge (spiack high) Cleared by a read in the SPI Status Register (SPSR) followed by an access to SPI Data Register (SPDR), read or write The interconnection between master and slave CPUs with SPI is shown in Figure 3. The SCK pin is the clock output in the master mode and is the clock input in the slave mode. Writing to the SPI data register of the master CPU starts the SPI clock generator, and the data written shifts out of the MOSI pin and into the MOSI pin of the slave CPU. After shifting one byte, the SPI clock generator stops, setting the end of transmission flag (SPIF). If the SPI interrupt enable bit (SPIE) in the SPCR register becomes set, an interrupt is requested. The Slave Select input, SS, is set low to select an individual SPI device as a slave. The two shift registers in the Master and the Slave can be considered as one distributed 16-bit circular shift register. This is shown in Figure 3. When data is shifted from the master to the slave, data is also shifted in the opposite direction simultaneously. This means that during one shift cycle, data in the master and the slave are interchanged. Figure 3. SPI Master-Slave Interconnection The system is single buffered in the transmit direction and double buffered in the receive direction. This means that characters to be transmitted cannot be written to the SPI Data Register before the entire shift cycle is completed. When receiving data, however, a received character must be read from the SPI Data Register before the next character has been completely shifted in. Otherwise, the first character is lost. When the SPI is enabled, the data direction of the MOSI, MISO, SCK and SS pins is overriden according to the following table: Table 2. SPI Pin Overrides Pin Direction, Master SPI Direction, Slave SPI MOSI Output Input MISO Input Output SCK Output Input SS Input 4 SPI Core

SPI Core SS Pin Functionality When the SPI is configured as a master (MSTR in SPCR is set), the user can determine the direction of the SS pin. If SS is configured as an output, the pin is a general output pin which does not affect the SPI system. If SS is configured as an input, it must be held high to ensure Master SPI operation. If, in master mode, the SS pin is input, and is driven low by peripheral circuitry, the SPI system interprets this as that another master selects the SPI as a slave and will start sending data to it. To avoid bus contention, the SPI system takes the following actions: 1. The MSTR bit in SPCR is cleared and the SPI system becomes a slave. As a result of the SPI becoming a slave, the MOSI and SCK pins become inputs. 2. The SPIF flag in SPSR is set, and if the SPI interrupt is enabled, the interrupt routine will be executed. Thus, when interrupt-driven SPI transmision is used in master mode, and there is a possibility that SS is driven low, the interrupt should always check that the MSTR bit is still set. Once the MSTR bit has been cleared by a slave select, it must be set by the user. When the SPI is configured as a slave, the SS is always input. When SS is held low, the SPI is activated and MISO becomes an output if configured so by the user. All other pins are inputs. When SS is driven low, all pins are inputs, and the SPI is passive, which means that it will not receive incoming data. Data Modes There are four combinations of SCK phase and polarity with respect to serial data, which are determined by control bits CPHA and CPOL. The SPI data transfer formats are shown in Figure 4 and Figure 5. Figure 4. SPI Transfer Format with CPHA = 0 Figure 5. SPI Transfer Format with CPHA = 1 5

The SPI Control Register - SPCR Bit 7 6 5 4 3 2 1 0 $0D ($2D) SPIE SPE DORD MSTR CPOL CPHA SPR1 SPR0 SPCR Read/Write R/W R/W R/W R/W R/W R/W R/W R/W Initial value 0 0 0 0 0 0 0 0 Bit 7 - SPIE : SPI Interrupt Enable: This bit causes setting of the SPIF bit in the SPSR register to execute the SPI interrupt provided that global interrupts are enabled. Bit 6 - SPE : SPI Enable: When the SPE bit is set (one), the SPI is enabled. This bit must be set to enable any SPI operations. Bit 5 - DORD : Data ORDer: When the DORD bit is set (one), the LSB of the data word is transmitted first. When the DORD bit is cleared (zero), the MSB of the data word is transmitted first. Bit 4 - MSTR : Master/Slave Select: This bit selects Master SPI mode when set (one), and Slave SPI mode when cleared (zero). 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 master mode. Bit 3 - CPOL : Clock POLarity: When this bit is set (one), SCK is high when idle. When CPOL is cleared (zero), SCK is low when idle. Refer to Figure 4 and Figure 5 for additional information. Bit 2 - CPHA : Clock PHAse: Refer to Figure 4 or Figure 5 for the functionality of this bit. Bits 1,0 - SPR1, SPR0 : SPI Clock Rate Select 1 and 0: These two bits control the SCK rate of the device configured as a master. SPR1 and SPR2 have no effect on the slave. The relationship between SCK and the Oscillator Clock frequency f CP2 is shown in the following table: Table 3. Relationship Between SCK and the Oscillator Frequency SPR1 SPR0 SCK Frequency 0 0 f CP2 / 4 0 1 f CP2 / 16 1 0 f CP2 / 64 1 1 f CP2 / 128 The SPI Status Register - SPSR Bit 7 6 5 4 3 2 1 0 $0E ($2E) SPIF WCOL - - - - - - SPSR Read/Write R R R R R R R R Initial value 0 0 0 0 0 0 0 0 Bit 7 - SPIF : SPI Interrupt Flag: When a serial transfer is complete, the SPIF bit is set (one) and an interrupt is generated if SPIE in SPCR is set (one) and global interrupts are enabled. If SS is an input and is driven low when the SPI is in master mode, this will also set the SPIF flag. SPIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, the SPIF bit is cleared by first reading the SPI status register with SPIF set (one), then accessing the SPI Data Register (SPDR). 6 SPI Core

SPI Core Bit 6 - WCOL : Write COLlision flag: The WCOL bit is set if the SPI data register (SPDR) is written during a data transfer. During data transfer, the result of reading the SPDR register may be incorrect, and writing to it will have no effect. The WCOL bit (and the SPIF bit) are cleared (zero) by first reading the SPI Status Register with WCOL set (one), and then accessing the SPI Data Register. Bit 5..0 - Res : Reserved bits: These bits are reserved bits and will always read as zero. The SPI interface may also be used for program memory and EEPROM downloading or uploading controlled by por, spiextload, spidload and spidwrite signals. The SPI Data Register - SPDR Bit 7 6 5 4 3 2 1 0 $0F ($2F) MSB LSB SPDR Read/Write R/W R/W R/W R/W R/W R/W R/W R/W Initial value Undefined The SPI Data Register is a read/write register used for data transfer between the register file and the SPI Shift register. Writing to the register initiates data transmission. Reading the register causes the Shift Register Receive buffer to be read. 7

Atmel Headquarters Corporate Headquarters 2325 Orchard Parkway San Jose, CA 95131 TEL (408) 441-0311 FAX (408) 487-2600 Europe Atmel U.K., Ltd. Coliseum Business Centre Riverside Way Camberley, Surrey GU15 3YL England TEL (44) 1276-686-677 FAX (44) 1276-686-697 Atmel Operations Atmel Colorado Springs 1150 E. Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL (719) 576-3300 FAX (719) 540-1759 Atmel Rousset Zone Industrielle 13106 Rousset Cedex France TEL (33) 4-4253-6000 FAX (33) 4-4253-6001 Asia Atmel Asia, Ltd. Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimhatsui East Kowloon Hong Kong TEL (852) 2721-9778 FAX (852) 2722-1369 Japan Atmel Japan K.K. 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan TEL (81) 3-3523-3551 FAX (81) 3-3523-7581 Fax-on-Demand North America: 1-(800) 292-8635 International: 1-(408) 441-0732 e-mail literature@atmel.com Web Site http://www.atmel.com BBS 1-(408) 436-4309 Atmel Corporation 1999. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. Marks bearing and/or are registered trademarks and trademarks of Atmel Corporation. Terms and product names in this document may be trademarks of others. Printed on recycled paper. 1127A 10/99/0M