6222
6222
6222
ARM
Thumb
Processor
High-performance 32-bit RISC Architecture
High-density 16-bit Instruction Set
Leader in MIPS/Watt
EmbeddedICE
and
ECC-enabled NAND Flash
Memory Controller (MC)
Embedded Flash Controller
Memory Protection Unit
Abort Status and Misalignment Detection
Reset Controller (RSTC)
Based on Power-on Reset Cells and Low-power Factory-calibrated Brownout
Detector
Provides External Reset Signal Shaping and Reset Source Status
Clock Generator (CKGR)
Low-power RC Oscillator, 3 to 20 MHz On-chip Oscillator and One PLL
Power Management Controller (PMC)
Power Optimization Capabilities, Including Slow Clock Mode (Down to 500 Hz) and
Idle Mode
Three Programmable External Clock Signals
Advanced Interrupt Controller (AIC)
Individually Maskable, Eight-level Priority, Vectored Interrupt Sources
Two External Interrupt Sources and One Fast Interrupt Source, Spurious Interrupt
Protected
Debug Unit (DBGU)
Two-wire UART and Support for Debug Communication Channel interrupt,
Programmable ICE Access Prevention
Mode for General Purpose Two-wire UART Serial Communication
Periodic Interval Timer (PIT)
20-bit Programmable Counter plus 12-bit Interval Counter
Windowed Watchdog (WDT)
12-bit key-protected Programmable Counter
AT91SAM
ARM-based
Flash MCU
SAM7SE512
SAM7SE256
SAM7SE32
6222HATARM25-Jan-12
2
6222HATARM25-Jan-12
SAM7SE512/256/32
Provides Reset or Interrupt Signals to the System
Counter May Be Stopped While the Processor is in Debug State or in Idle Mode
Real-time Timer (RTT)
32-bit Free-running Counter with Alarm
Runs Off the Internal RC Oscillator
Three Parallel Input/Output Controllers (PIO)
Eighty-eight Programmable I/O Lines Multiplexed with up to Two Peripheral I/Os
Input Change Interrupt Capability on Each I/O Line
Individually Programmable Open-drain, Pull-up Resistor and Synchronous Output
Schmitt Trigger on All inputs
Eleven Peripheral DMA Controller (PDC) Channels
One USB 2.0 Full Speed (12 Mbits per second) Device Port
On-chip Transceiver, Eight Endpoints, 2688-byte Configurable Integrated FIFOs
One Synchronous Serial Controller (SSC)
Independent Clock and Frame Sync Signals for Each Receiver and Transmitter
IS Analog Interface Support, Time Division Multiplex Support
High-speed Continuous Data Stream Capabilities with 32-bit Data Transfer
Two Universal Synchronous/Asynchronous Receiver Transmitters (USART)
Individual Baud Rate Generator, IrDA
Infrared Modulation/Demodulation
Support for ISO7816 T0/T1 Smart Card, Hardware Handshaking, RS485 Support
Full Modem Line Support on USART1
One Master/Slave Serial Peripheral Interfaces (SPI)
8- to 16-bit Programmable Data Length, Four External Peripheral Chip Selects
One Three-channel 16-bit Timer/Counter (TC)
Three External Clock Inputs, Two Multi-purpose I/O Pins per Channel
Double PWM Generation, Capture/Waveform Mode, Up/Down Capability
One Four-channel 16-bit PWM Controller (PWMC)
One Two-wire Interface (TWI)
Master, Multi-Master and Slave Mode Support, All Two-wire Atmel EEPROMs Supported
General Call Supported in Slave Mode
One 8-channel 10-bit Analog-to-Digital Converter, Four Channels Multiplexed with Digital I/Os
SAM-BA
Boot
The SAM-BA Boot is a default Boot Program which provides an easy way to program in-situ the
on-chip Flash memory.
The SAM-BA Boot Assistant supports serial communication via the DBGU or the USB Device
Port.
Communication via the DBGU supports a wide range of crystals from 3 to 20 MHz via
software auto-detection.
Communication via the USB Device Port is limited to an 18.432 MHz crystal.
The SAM-BA Boot provides an interface with SAM-BA Graphic User Interface (GUI).
The SAM-BA Boot is in ROM and is mapped in Flash at address 0x0 when GPNVM bit 2 is set to
0.
8.2 External Memories
The external memories are accessed through the External Bus Interface.
Refer to the memory map in Figure 8-1 on page 22.
28
6222HATARM25-Jan-12
SAM7SE512/256/32
9. System Controller
The System Controller manages all vital blocks of the microcontroller: interrupts, clocks, power,
time, debug and reset.
The System Controller peripherals are all mapped to the highest 4 Kbytes of address space,
between addresses 0xFFFF F000 and 0xFFFF FFFF.
Figure 9-1 on page 29 shows the System Controller Block Diagram.
Figure 8-1 on page 22 shows the mapping of the User Interface of the System Controller periph-
erals. Note that the Memory Controller configuration user interface is also mapped within this
address space.
29
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 9-1. System Controller Block Diagram
NRST
SLCK
Advanced
Interrupt
Controller
Real-Time
Timer
Periodic
Interval
Timer
Reset
Controller
PA0-PA31
periph_nreset
System Controller
Watchdog
Timer
wdt_fault
WDRPROC
PIO
Controller
POR
BOD
RCOSC
gpnvm[0]
cal
en
Power
Management
Controller
OSC
PLL
XIN
XOUT
PLLRC
MAINCK
PLLCK
pit_irq
MCK
proc_nreset
wdt_irq
periph_irq{2-3] periph_nreset
periph_clk[2..18]
PCK
MCK
pmc_irq
UDPCK
nirq
nfiq
rtt_irq
Embedded
Peripherals
periph_clk[2-3]
pck[0-3]
in
out
enable
ARM7TDMI
SLCK
SLCK
irq0-irq1
fiq
irq0-irq1
fiq
periph_irq[4..18]
periph_irq[2..18]
int
int
periph_nreset
periph_clk[4..18]
Embedded
Flash
flash_poe
jtag_nreset
flash_poe
gpnvm[0..2]
flash_wrdis
flash_wrdis
proc_nreset
periph_nreset
dbgu_txd
dbgu_rxd
pit_irq
rtt_irq
dbgu_irq
pmc_irq
rstc_irq
wdt_irq
rstc_irq
SLCK
gpnvm[1]
Boundary Scan
TAP Controller
jtag_nreset
debug
PCK
debug
idle
debug
Memory
Controller
MCK
proc_nreset
bod_rst_en
proc_nreset
power_on_reset
periph_nreset
idle
Debug
Unit
dbgu_irq MCK
dbgu_rxd
periph_nreset
force_ntrst
dbgu_txd
USB Device
Port
UDPCK
periph_nreset
periph_clk[11]
periph_irq[11]
usb_suspend
usb_suspend
Voltage
Regulator
standby
Voltage
Regulator
Mode
Controller
security_bit
cal
power_on_reset
power_on_reset
force_ntrst
cal
PB0-PB31
PC0-PC29
30
6222HATARM25-Jan-12
SAM7SE512/256/32
9.1 Reset Controller
Based on one power-on reset cell and a double brownout detector
Status of the last reset, either Power-up Reset, Software Reset, User Reset, Watchdog
Reset, Brownout Reset
Controls the internal resets and the NRST pin output
Allows to shape a signal on the NRST line, guaranteeing that the length of the pulse meets
any requirement.
9.1.1 Brownout Detector and Power On Reset
The SAM7SE512/256/32 embeds one brownout detection circuit and a power-on reset cell. The
power-on reset is supplied with and monitors VDDCORE.
Both signals are provided to the Flash to prevent any code corruption during power-up or power-
down sequences or if brownouts occur on the VDDCORE power supply.
The power-on reset cell has a limited-accuracy threshold at around 1.5V. Its output remains low
during power-up until VDDCORE goes over this voltage level. This signal goes to the reset con-
troller and allows a full re-initialization of the device.
The brownout detector monitors the VDDCORE and VDDFLASH levels during operation by
comparing it to a fixed trigger level. It secures system operations in the most difficult environ-
ments and prevents code corruption in case of brownout on the VDDCORE or VDDFLASH.
When the brownout detector is enabled and VDDCORE decreases to a value below the trigger
level (Vbot18-, defined as Vbot18 - hyst/2), the brownout output is immediately activated.
When VDDCORE increases above the trigger level (Vbot18+, defined as Vbot18 + hyst/2), the
reset is released. The brownout detector only detects a drop if the voltage on VDDCORE stays
below the threshold voltage for longer than about 1s.
The VDDCORE threshold voltage has a hysteresis of about 50 mV, to ensure spike free brown-
out detection. The typical value of the brownout detector threshold is 1.68V with an accuracy of
2% and is factory calibrated.
When the brownout detector is enabled and VDDFLASH decreases to a value below the trigger
level (Vbot33-, defined as Vbot33 - hyst/2), the brownout output is immediately activated.
When VDDFLASH increases above the trigger level (Vbot33+, defined as Vbot33 + hyst/2), the
reset is released. The brownout detector only detects a drop if the voltage on VDDCORE stays
below the threshold voltage for longer than about 1s.
The VDDFLASH threshold voltage has a hysteresis of about 50 mV, to ensure spike free brown-
out detection. The typical value of the brownout detector threshold is 2.80V with an accuracy of
3.5% and is factory calibrated.
The brownout detector is low-power, as it consumes less than 20 A static current. However, it
can be deactivated to save its static current. In this case, it consumes less than 1A. The deac-
tivation is configured through the GPNVM bit 0 of the Flash.
9.2 Clock Generator
The Clock Generator embeds one low-power RC Oscillator, one Main Oscillator and one PLL
with the following characteristics:
RC Oscillator ranges between 22 KHz and 42 KHz
31
6222HATARM25-Jan-12
SAM7SE512/256/32
Main Oscillator frequency ranges between 3 and 20 MHz
Main Oscillator can be bypassed
PLL output ranges between 80 and 220 MHz
It provides SLCK, MAINCK and PLLCK.
Figure 9-2. Clock Generator Block Diagram
9.3 Power Management Controller
The Power Management Controller uses the Clock Generator outputs to provide:
the Processor Clock PCK
the Master Clock MCK
the USB Clock UDPCK
all the peripheral clocks, independently controllable
three programmable clock outputs
The Master Clock (MCK) is programmable from a few hundred Hz to the maximum operating fre-
quency of the device.
The Processor Clock (PCK) switches off when entering processor idle mode, thus allowing
reduced power consumption while waiting for an interrupt.
Power
Management
Controller
XIN
XOUT
PLLRC
Slow Clock
SLCK
Main Clock
MAINCK
PLL Clock
PLLCK
Control Status
Embedded
RC
Oscillator
Main
Oscillator
PLL and
Divider
Clock Generator
32
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 9-3. Power Management Controller Block Diagram
9.4 Advanced Interrupt Controller
Controls the interrupt lines (nIRQ and nFIQ) of an ARM Processor
Individually maskable and vectored interrupt sources
Source 0 is reserved for the Fast Interrupt Input (FIQ)
Source 1 is reserved for system peripherals (RTT, PIT, EFC, PMC, DBGU, etc.)
Other sources control the peripheral interrupts or external interrupts
Programmable edge-triggered or level-sensitive internal sources
Programmable positive/negative edge-triggered or high/low level-sensitive external
sources
8-level Priority Controller
Drives the normal interrupt nIRQ of the processor
Handles priority of the interrupt sources
Higher priority interrupts can be served during service of lower priority interrupt
Vectoring
Optimizes interrupt service routine branch and execution
One 32-bit vector register per interrupt source
Interrupt vector register reads the corresponding current interrupt vector
Protect Mode
Easy debugging by preventing automatic operations
Fast Forcing
Permits redirecting any interrupt source on the fast interrupt
General Interrupt Mask
Provides processor synchronization on events without triggering an interrupt
MCK
periph_clk[2..14]
int
UDPCK
SLCK
MAINCK
PLLCK
Prescaler
/1,/2,/4,...,/64
PCK
Processor
Clock
Controller
Idle Mode
Master Clock Controller
Peripherals
Clock Controller
ON/OFF
USB Clock Controller
ON/OFF
SLCK
MAINCK
PLLCK
Prescaler
/1,/2,/4,...,/64
Programmable Clock Controller
PLLCK
Divider
/1,/2,/4
pck[0..2]
usb_suspend
33
6222HATARM25-Jan-12
SAM7SE512/256/32
9.5 Debug Unit
Comprises:
One two-pin UART
One Interface for the Debug Communication Channel (DCC) support
One set of Chip ID Registers
One Interface providing ICE Access Prevention
Two-pin UART
USART-compatible User Interface
Programmable Baud Rate Generator
Parity, Framing and Overrun Error
Automatic Echo, Local Loopback and Remote Loopback Channel Modes
Debug Communication Channel Support
Offers visibility of COMMRX and COMMTX signals from the ARM Processor
Chip ID Registers
Identification of the device revision, sizes of the embedded memories, set of
peripherals
Chip ID is 0x272A 0A40 (VERSION 0) for SAM7SE512
Chip ID is 0x272A 0940 (VERSION 0) for SAM7SE256
Chip ID is 0x2728 0340 (VERSION 0) for SAM7SE32
9.6 Periodic Interval Timer
20-bit programmable counter plus 12-bit interval counter
9.7 Watchdog Timer
12-bit key-protected Programmable Counter running on prescaled SLCK
Provides reset or interrupt signals to the system
Counter may be stopped while the processor is in debug state or in idle mode
9.8 Real-time Timer
32-bit free-running counter with alarm running on prescaled SLCK
Programmable 16-bit prescaler for SLCK accuracy compensation
9.9 PIO Controllers
Three PIO Controllers. PIO A and B each control 32 I/O lines and PIO C controls 24 I/O lines.
Fully programmable through set/clear registers
Multiplexing of two peripheral functions per I/O line
For each I/O line (whether assigned to a peripheral or used as general-purpose I/O)
Input change interrupt
Half a clock period glitch filter
Multi-drive option enables driving in open drain
Programmable pull-up on each I/O line
Pin data status register, supplies visibility of the level on the pin at any time
34
6222HATARM25-Jan-12
SAM7SE512/256/32
Synchronous output, provides Set and Clear of several I/O lines in a single write
9.10 Voltage Regulator Controller
The purpose of this controller is to select the Power Mode of the Voltage Regulator between
Normal Mode (bit 0 is cleared) or Standby Mode (bit 0 is set).
35
6222HATARM25-Jan-12
SAM7SE512/256/32
10. Peripherals
10.1 User Interface
The User Peripherals are mapped in the 256 MBytes of the address space between
0xF000 0000 and 0xFFFF EFFF. Each peripheral is allocated 16 Kbytes of address space.
A complete memory map is presented in Figure 8-1 on page 22.
10.2 Peripheral Identifiers
The SAM7SE512/256/32 embeds a wide range of peripherals. Table 10-1 defines the Peripheral
Identifiers of the SAM7SE512/256/32. Unique peripheral identifiers are defined for both the
Advanced Interrupt Controller and the Power Management Controller.
Note: 1. Setting SYSC and ADC bits in the clock set/clear registers of the PMC has no effect. The Sys-
tem Controller is continuously clocked. The ADC clock is automatically started for the first
conversion. In Sleep Mode the ADC clock is automatically stopped after each conversion.
Table 10-1. Peripheral Identifiers
Peripheral
ID
Peripheral
Mnemonic
Peripheral
Name
External
Interrupt
0 AIC Advanced Interrupt Controller FIQ
1 SYSC
(1)
2 PIOA Parallel I/O Controller A
3 PIOB Parallel I/O Controller B
4 PIOC Parallel I/O Controller C
5 SPI Serial Peripheral Interface 0
6 US0 USART 0
7 US1 USART 1
8 SSC Synchronous Serial Controller
9 TWI Two-wire Interface
10 PWMC PWM Controller
11 UDP USB Device Port
12 TC0 Timer/Counter 0
13 TC1 Timer/Counter 1
14 TC2 Timer/Counter 2
15 ADC
(1)
Analog-to Digital Converter
16-28 reserved
29 AIC Advanced Interrupt Controller IRQ0
30 AIC Advanced Interrupt Controller IRQ1
36
6222HATARM25-Jan-12
SAM7SE512/256/32
10.3 Peripheral Multiplexing on PIO Lines
The SAM7SE512/256/32 features three PIO controllers, PIOA, PIOB and PIOC, that multiplex
the I/O lines of the peripheral set.
PIO Controller A and B control 32 lines; PIO Controller C controls 24 lines. Each line can be
assigned to one of two peripheral functions, A or B. Some of them can also be multiplexed with
the analog inputs of the ADC Controller.
Table 10-2 on page 37 defines how the I/O lines of the peripherals A and B or the analog inputs
are multiplexed on the PIO Controller A, B and C. The two columns Function and Comments
have been inserted for the users own comments; they may be used to track how pins are
defined in an application.
Note that some peripheral functions that are output only may be duplicated in the table.
At reset, all I/O lines are automatically configured as input with the programmable pull-up
enabled, so that the device is maintained in a static state as soon as a reset is detected.
37
6222HATARM25-Jan-12
SAM7SE512/256/32
10.4 PIO Controller A Multiplexing
Table 10-2. Multiplexing on PIO Controller A
PIO Controller A Application Usage
I/O Line Peripheral A Peripheral B Comments Function Comments
PA0 PWM0 A0/NBS0 High-Drive
PA1 PWM1 A1/NBS2 High-Drive
PA2 PWM2 A2 High-Drive
PA3 TWD A3 High-Drive
PA4 TWCK A4
PA5 RXD0 A5
PA6 TXD0 A6
PA7 RTS0 A7
PA8 CTS0 A8
PA9 DRXD A9
PA10 DTXD A10
PA11 NPCS0 A11
PA12 MISO A12
PA13 MOSI A13
PA14 SPCK A14
PA15 TF A15
PA16 TK A16/BA0
PA17 TD A17/BA1 AD0
PA18 RD NBS3/CFIOW AD1
PA19 RK NCS4/CFCS0 AD2
PA20 RF NCS2/CFCS1 AD3
PA21 RXD1 NCS6/CFCE2
PA22 TXD1 NCS5/CFCE1
PA23 SCK1 NWR1/NBS1/CFIOR
PA24 RTS1 SDA10
PA25 CTS1 SDCKE
PA26 DCD1 NCS1/SDCS
PA27 DTR1 SDWE
PA28 DSR1 CAS
PA29 RI1 RAS
PA30 IRQ1 D30
PA31 NPCS1 D31
38
6222HATARM25-Jan-12
SAM7SE512/256/32
10.5 PIO Controller B Multiplexing
Table 10-3. Multiplexing on PIO Controller B
PIO Controller B Application Usage
I/O Line Peripheral A Peripheral B Comments Function Comments
PB0 TIOA0 A0/NBS0
PB1 TIOB0 A1/NBS2
PB2 SCK0 A2
PB3 NPCS3 A3
PB4 TCLK0 A4
PB5 NPCS3 A5
PB6 PCK0 A6
PB7 PWM3 A7
PB8 ADTRG A8
PB9 NPCS1 A9
PB10 NPCS2 A10
PB11 PWM0 A11
PB12 PWM1 A12
PB13 PWM2 A13
PB14 PWM3 A14
PB15 TIOA1 A15
PB16 TIOB1 A16/BA0
PB17 PCK1 A17/BA1
PB18 PCK2 D16
PB19 FIQ D17
PB20 IRQ0 D18
PB21 PCK1 D19
PB22 NPCS3 D20
PB23 PWM0 D21
PB24 PWM1 D22
PB25 PWM2 D23
PB26 TIOA2 D24
PB27 TIOB2 D25
PB28 TCLK1 D26
PB29 TCLK2 D27
PB30 NPCS2 D28
PB31 PCK2 D29
39
6222HATARM25-Jan-12
SAM7SE512/256/32
10.6 PIO Controller C Multiplexing
10.7 Serial Peripheral Interface
Supports communication with external serial devices
Four chip selects with external decoder allow communication with up to 15
peripherals
Serial memories, such as DataFlash
NCS1/SDCS CS CS CS CS
NCS2/CFCS1 CS CS CS CFCS1
(4)
CFCS1
(4)
NCS3/NANDCS CS CS CS CE
(7)
NCS4/CFCS0 CS CS CS CFCS0
(4)
CFCS0
(4)
Boot is then executed. It waits for transactions either on the USB device, or on the
DBGU serial port.
25.2 Flow Diagram
The Boot Program implements the algorithm in Figure 25-1.
Figure 25-1. Boot Program Algorithm Flow Diagram
25.3 Device Initialization
Initialization follows the steps described below:
1. FIQ initialization
1. Stack setup for ARM supervisor mode
2. Setup the Embedded Flash Controller
3. External Clock detection
4. Main oscillator frequency detection if no external clock detected
5. Switch Master Clock on Main Oscillator
6. Copy code into SRAM
7. C variable initialization
8. PLL setup: PLL is initialized to generate a 48 MHz clock necessary to use the USB
Device
9. Disable of the Watchdog and enable of the user reset
10. Initialization of the USB Device Port
11. Jump to SAM-BA Boot sequence (see SAM-BA Boot on page 230)
Device
Setup
AutoBaudrate
Sequence Successful ?
Run SAM-BA Boot Run SAM-BA Boot
USB Enumeration
Successful ?
Yes Yes
No
No
230
6222FATARM10-Jan-11
SAM7SE512/256/32 Preliminary
25.4 SAM-BA Boot
The SAM-BA boot principle is to:
Check if USB Device enumeration has occurred
Check if the AutoBaudrate sequence has succeeded (see Figure 25-2)
Figure 25-2. AutoBaudrate Flow Diagram
Once the communication interface is identified, the application runs in an infinite
loop waiting for different commands as in Table 25-1.
Device
Setup
Character '0x80'
received ?
No
Yes
Character '0x80'
received ?
No
Yes
Character '#'
received ?
Yes
Run SAM-BA Boot
Send Character '>'
No
1st measurement
2nd measurement
Test Communication
UART operational
231
6222FATARM10-Jan-11
SAM7SE512/256/32 Preliminary
Write commands: Write a byte (O), a halfword (H) or a word (W) to the target.
Address: Address in hexadecimal.
Value: Byte, halfword or word to write in hexadecimal.
Output: >.
Read commands: Read a byte (o), a halfword (h) or a word (w) from the target.
Address: Address in hexadecimal
Output: The byte, halfword or word read in hexadecimal following by >
Send a file (S): Send a file to a specified address
Address: Address in hexadecimal
Output: >.
Note: There is a time-out on this command which is reached when the prompt > appears before the
end of the command execution.
Receive a file (R): Receive data into a file from a specified address
Address: Address in hexadecimal
NbOfBytes: Number of bytes in hexadecimal to receive
Output: >
Go (G): Jump to a specified address and execute the code
Address: Address to jump in hexadecimal
Output: >
Get Version (V): Return the SAM-BA boot version
Output: >
25.4.1 DBGU Serial Port
Communication is performed through the DBGU serial port initialized to 115200 Baud, 8, n, 1.
The Send and Receive File commands use the Xmodem protocol to communicate. Any terminal
performing this protocol can be used to send the application file to the target. The size of the
binary file to send depends on the SRAM size embedded in the product. In all cases, the size of
Table 25-1. Commands Available through the SAM-BA Boot
Command Action Argument(s) Example
O write a byte Address, Value# O200001,CA#
o read a byte Address,# o200001,#
H write a half word Address, Value# H200002,CAFE#
h read a half word Address,# h200002,#
W write a word Address, Value# W200000,CAFEDECA#
w read a word Address,# w200000,#
S send a file Address,# S200000,#
R receive a file Address, NbOfBytes# R200000,1234#
G go Address# G200200#
V display version No argument V#
232
6222FATARM10-Jan-11
SAM7SE512/256/32 Preliminary
the binary file must be lower than the SRAM size because the Xmodem protocol requires some
SRAM memory to work.
25.4.2 Xmodem Protocol
The Xmodem protocol supported is the 128-byte length block. This protocol uses a two-charac-
ter CRC-16 to guarantee detection of a maximum bit error.
Xmodem protocol with CRC is accurate provided both sender and receiver report successful
transmission. Each block of the transfer looks like:
<SOH><blk #><255-blk #><--128 data bytes--><checksum> in which:
<SOH> = 01 hex
<blk #> = binary number, starts at 01, increments by 1, and wraps 0FFH to 00H (not
to 01)
<255-blk #> = 1s complement of the blk#.
<checksum> = 2 bytes CRC16
Figure 25-3 shows a transmission using this protocol.
Figure 25-3. Xmodem Transfer Example
25.4.3 USB Device Port
A 48 MHz USB clock is necessary to use the USB Device port. It has been programmed earlier
in the device initialization procedure with PLLB configuration.
The device uses the USB communication device class (CDC) drivers to take advantage of the
installed PC RS-232 software to talk over the USB. The CDC class is implemented in all
releases of Windows
3 x PLL Clock +
5 x SLCK
PLL Clock
0.5 x Main Clock +
4 x SLCK +
PLLCOUNT x SLCK +
2.5 x PLLx Clock
2.5 x PLL Clock +
5 x SLCK +
PLLCOUNT x SLCK
2.5 x PLL Clock +
4 x SLCK +
PLLCOUNT x SLCK
Slow Clock
LOCK
MCKRDY
Master Clock
Write PMC_MCKR
PLL Clock
282
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 29-4. Switch Master Clock from Main Clock to Slow Clock
Figure 29-5. Change PLL Programming
Slow Clock
Main Clock
MCKRDY
Master Clock
Write PMC_MCKR
Main Clock
Main Clock
PLL Clock
LOCK
MCKRDY
Master Clock
Write CKGR_PLLR
283
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 29-6. Programmable Clock Output Programming
PLL Clock
PCKRDY
PCKx Output
Write PMC_PCKx
Write PMC_SCER
Write PMC_SCDR PCKx is disabled
PCKx is enabled
PLL Clock is selected
284
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9 Power Management Controller (PMC) User Interface
Table 29-2. Register Mapping
Offset Register Name Access Reset Value
0x0000 System Clock Enable Register PMC_SCER Write-only
0x0004 System Clock Disable Register PMC_SCDR Write-only
0x0008 System Clock Status Register PMC _SCSR Read-only 0x01
0x000C Reserved
0x0010 Peripheral Clock Enable Register PMC _PCER Write-only
0x0014 Peripheral Clock Disable Register PMC_PCDR Write-only
0x0018 Peripheral Clock Status Register PMC_PCSR Read-only 0x0
0x001C Reserved
0x0020 Main Oscillator Register CKGR_MOR Read-write 0x0
0x0024 Main Clock Frequency Register CKGR_MCFR Read-only 0x0
0x0028 Reserved
0x002C PLL Register CKGR_PLLR Read-write 0x3F00
0x0030 Master Clock Register PMC_MCKR Read-write 0x0
0x0038 Reserved
0x003C Reserved
0x0040 Programmable Clock 0 Register PMC_PCK0 Read-write 0x0
0x0044 Programmable Clock 1 Register PMC_PCK1 Read-write 0x0
... ... ... ... ...
0x0060 Interrupt Enable Register PMC_IER Write-only --
0x0064 Interrupt Disable Register PMC_IDR Write-only --
0x0068 Status Register PMC_SR Read-only 0x08
0x006C Interrupt Mask Register PMC_IMR Read-only 0x0
0x0070 - 0x007C Reserved
285
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.1 PMC System Clock Enable Register
Name: PMC_SCER
Access: Write-only
UDP: USB Device Port Clock Enable
0 = No effect.
1 = Enables the 48 MHz clock of the USB Device Port.
PCKx: Programmable Clock x Output Enable
0 = No effect.
1 = Enables the corresponding Programmable Clock output.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCK2 PCK1 PCK0
7 6 5 4 3 2 1 0
UDP
286
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.2 PMC System Clock Disable Register
Name: PMC_SCDR
Access: Write-only
PCK: Processor Clock Disable
0 = No effect.
1 = Disables the Processor clock. This is used to enter the processor in Idle Mode.
UDP: USB Device Port Clock Disable
0 = No effect.
1 = Disables the 48 MHz clock of the USB Device Port.
PCKx: Programmable Clock x Output Disable
0 = No effect.
1 = Disables the corresponding Programmable Clock output.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCK2 PCK1 PCK0
7 6 5 4 3 2 1 0
UDP PCK
287
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.3 PMC System Clock Status Register
Name: PMC_SCSR
Access: Read-only
PCK: Processor Clock Status
0 = The Processor clock is disabled.
1 = The Processor clock is enabled.
UDP: USB Device Port Clock Status
0 = The 48 MHz clock (UDPCK) of the USB Device Port is disabled.
1 = The 48 MHz clock (UDPCK) of the USB Device Port is enabled.
PCKx: Programmable Clock x Output Status
0 = The corresponding Programmable Clock output is disabled.
1 = The corresponding Programmable Clock output is enabled.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCK2 PCK1 PCK0
7 6 5 4 3 2 1 0
UDP PCK
288
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.4 PMC Peripheral Clock Enable Register
Name: PMC_PCER
Access: Write-only
PIDx: Peripheral Clock x Enable
0 = No effect.
1 = Enables the corresponding peripheral clock.
Note: PID2 to PID31 refer to identifiers as defined in the section Peripheral Identifiers in the product datasheet.
Note: Programming the control bits of the Peripheral ID that are not implemented has no effect on the behavior of the PMC.
31 30 29 28 27 26 25 24
PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24
23 22 21 20 19 18 17 16
PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16
15 14 13 12 11 10 9 8
PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8
7 6 5 4 3 2 1 0
PID7 PID6 PID5 PID4 PID3 PID2
289
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.5 PMC Peripheral Clock Disable Register
Name: PMC_PCDR
Access: Write-only
PIDx: Peripheral Clock x Disable
0 = No effect.
1 = Disables the corresponding peripheral clock.
Note: PID2 to PID31 refer to identifiers as defined in the section Peripheral Identifiers in the product datasheet.
29.9.6 PMC Peripheral Clock Status Register
Name: PMC_PCSR
Access: Read-only
PIDx: Peripheral Clock x Status
0 = The corresponding peripheral clock is disabled.
1 = The corresponding peripheral clock is enabled.
Note: PID2 to PID31 refer to identifiers as defined in the section Peripheral Identifiers in the product datasheet.
31 30 29 28 27 26 25 24
PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24
23 22 21 20 19 18 17 16
PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16
15 14 13 12 11 10 9 8
PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8
7 6 5 4 3 2 1 0
PID7 PID6 PID5 PID4 PID3 PID2
31 30 29 28 27 26 25 24
PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24
23 22 21 20 19 18 17 16
PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16
15 14 13 12 11 10 9 8
PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8
7 6 5 4 3 2 1 0
PID7 PID6 PID5 PID4 PID3 PID2
290
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.7 PMC Clock Generator Main Oscillator Register
Name: CKGR_MOR
Access: Read-write
MOSCEN: Main Oscillator Enable
A crystal must be connected between XIN and XOUT.
0 = The Main Oscillator is disabled.
1 = The Main Oscillator is enabled. OSCBYPASS must be set to 0.
When MOSCEN is set, the MOSCS flag is set once the Main Oscillator startup time is achieved.
OSCBYPASS: Oscillator Bypass
0 = No effect.
1 = The Main Oscillator is bypassed. MOSCEN must be set to 0. An external clock must be connected on XIN.
When OSCBYPASS is set, the MOSCS flag in PMC_SR is automatically set.
Clearing MOSCEN and OSCBYPASS bits allows resetting the MOSCS flag.
OSCOUNT: Main Oscillator Start-up Time
Specifies the number of Slow Clock cycles multiplied by 8 for the Main Oscillator start-up time.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
OSCOUNT
7 6 5 4 3 2 1 0
OSCBYPASS MOSCEN
291
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.8 PMC Clock Generator Main Clock Frequency Register
Name: CKGR_MCFR
Access: Read-only
MAINF: Main Clock Frequency
Gives the number of Main Clock cycles within 16 Slow Clock periods.
MAINRDY: Main Clock Ready
0 = MAINF value is not valid or the Main Oscillator is disabled.
1 = The Main Oscillator has been enabled previously and MAINF value is available.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
MAINRDY
15 14 13 12 11 10 9 8
MAINF
7 6 5 4 3 2 1 0
MAINF
292
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.9 PMC Clock Generator PLL Register
Name: CKGR_PLLR
Access: Read-write
Possible limitations on PLL input frequencies and multiplier factors should be checked before using the PMC.
DIV: Divider
PLLCOUNT: PLL Counter
Specifies the number of slow clock cycles before the LOCK bit is set in PMC_SR after CKGR_PLLR is written.
OUT: PLL Clock Frequency Range
To optimize clock performance, this field must be programmed as specified in PLL Characteristics in the Electrical Char-
acteristics section of the product datasheet.
MUL: PLL Multiplier
0 = The PLL is deactivated.
1 up to 2047 = The PLL Clock frequency is the PLL input frequency multiplied by MUL+ 1.
USBDIV: Divider for USB Clock
31 30 29 28 27 26 25 24
USBDIV MUL
23 22 21 20 19 18 17 16
MUL
15 14 13 12 11 10 9 8
OUT PLLCOUNT
7 6 5 4 3 2 1 0
DIV
DIV Divider Selected
0 Divider output is 0
1 Divider is bypassed
2 - 255 Divider output is the selected clock divided by DIV.
USBDIV Divider for USB Clock(s)
0 0 Divider output is PLL clock output.
0 1 Divider output is PLL clock output divided by 2.
1 0 Divider output is PLL clock output divided by 4.
1 1 Reserved.
293
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.10 PMC Master Clock Register
Name: PMC_MCKR
Access: Read-write
CSS: Master Clock Selection
PRES: Processor Clock Prescaler
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PRES CSS
CSS Clock Source Selection
0 0 Slow Clock is selected
0 1 Main Clock is selected
1 0 Reserved
1 1 PLL Clock is selected.
PRES Processor Clock
0 0 0 Selected clock
0 0 1 Selected clock divided by 2
0 1 0 Selected clock divided by 4
0 1 1 Selected clock divided by 8
1 0 0 Selected clock divided by 16
1 0 1 Selected clock divided by 32
1 1 0 Selected clock divided by 64
1 1 1 Reserved
294
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.11 PMC Programmable Clock Register
Name: PMC_PCKx
Access: Read-write
CSS: Master Clock Selection
PRES: Programmable Clock Prescaler
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PRES CSS
CSS Clock Source Selection
0 0 Slow Clock is selected
0 1 Main Clock is selected
1 0 Reserved
1 1 PLL Clock is selected
PRES Programmable Clock
0 0 0 Selected clock
0 0 1 Selected clock divided by 2
0 1 0 Selected clock divided by 4
0 1 1 Selected clock divided by 8
1 0 0 Selected clock divided by 16
1 0 1 Selected clock divided by 32
1 1 0 Selected clock divided by 64
1 1 1 Reserved
295
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.12 PMC Interrupt Enable Register
Name: PMC_IER
Access: Write-only
MOSCS: Main Oscillator Status Interrupt Enable
LOCK: PLL Lock Interrupt Enable
MCKRDY: Master Clock Ready Interrupt Enable
PCKRDYx: Programmable Clock Ready x Interrupt Enable
0 = No effect.
1 = Enables the corresponding interrupt.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY LOCK MOSCS
296
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.13 PMC Interrupt Disable Register
Name: PMC_IDR
Access: Write-only
MOSCS: Main Oscillator Status Interrupt Disable
LOCK: PLL Lock Interrupt Disable
MCKRDY: Master Clock Ready Interrupt Disable
PCKRDYx: Programmable Clock Ready x Interrupt Disable
0 = No effect.
1 = Disables the corresponding interrupt.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY
LOCK MOSCS
297
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.14 PMC Status Register
Name: PMC_SR
Access: Read-only
MOSCS: MOSCS Flag Status
0 = Main oscillator is not stabilized.
1 = Main oscillator is stabilized.
LOCK: PLL Lock Status
0 = PLL is not locked
1 = PLL is locked.
MCKRDY: Master Clock Status
0 = Master Clock is not ready.
1 = Master Clock is ready.
PCKRDYx: Programmable Clock Ready Status
0 = Programmable Clock x is not ready.
1 = Programmable Clock x is ready.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY
LOCK MOSCS
298
6222HATARM25-Jan-12
SAM7SE512/256/32
29.9.15 PMC Interrupt Mask Register
Name: PMC_IMR
Access: Read-only
MOSCS: Main Oscillator Status Interrupt Mask
LOCK: PLL Lock Interrupt Mask
MCKRDY: Master Clock Ready Interrupt Mask
PCKRDYx: Programmable Clock Ready x Interrupt Mask
0 = The corresponding interrupt is enabled.
1 = The corresponding interrupt is disabled.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY
LOCK MOSCS
299
6222HATARM25-Jan-12
SAM7SE512/256/32
30. Debug Unit (DBGU)
30.1 Overview
The Debug Unit provides a single entry point from the processor for access to all the debug
capabilities of Atmels ARM-based systems.
The Debug Unit features a two-pin UART that can be used for several debug and trace purposes
and offers an ideal medium for in-situ programming solutions and debug monitor communica-
tions. The Debug Unit two-pin UART can be used stand-alone for general purpose serial
communication. Moreover, the association with two peripheral data controller channels permits
packet handling for these tasks with processor time reduced to a minimum.
The Debug Unit also makes the Debug Communication Channel (DCC) signals provided by the
In-circuit Emulator of the ARM processor visible to the software. These signals indicate the sta-
tus of the DCC read and write registers and generate an interrupt to the ARM processor, making
possible the handling of the DCC under interrupt control.
Chip Identifier registers permit recognition of the device and its revision. These registers inform
as to the sizes and types of the on-chip memories, as well as the set of embedded peripherals.
Finally, the Debug Unit features a Force NTRST capability that enables the software to decide
whether to prevent access to the system via the In-circuit Emulator. This permits protection of
the code, stored in ROM.
300
6222HATARM25-Jan-12
SAM7SE512/256/32
30.2 Block Diagram
Figure 30-1. Debug Unit Functional Block Diagram
Debug Unit Application Example
Peripheral DMA Controller
Baud Rate
Generator
DCC
Handler
ICE
Access
Handler
Transmit
Receive
Chip ID
Interrupt
Control
Peripheral
Bridge
Parallel
Input/
Output
DTXD
DRXD
Power
Management
Controller
ARM
Processor
force_ntrst
COMMRX
COMMTX
MCK
nTRST
Power-on
Reset
dbgu_irq
APB
Debug Unit
R
Table 30-1. Debug Unit Pin Description
Pin Name Description Type
DRXD Debug Receive Data Input
DTXD Debug Transmit Data Output
Debug Unit
RS232 Drivers
Programming Tool Trace Console Debug Console
Boot Program Debug Monitor Trace Manager
301
6222HATARM25-Jan-12
SAM7SE512/256/32
30.3 Product Dependencies
30.3.1 I/O Lines
Depending on product integration, the Debug Unit pins may be multiplexed with PIO lines. In this
case, the programmer must first configure the corresponding PIO Controller to enable I/O lines
operations of the Debug Unit.
30.3.2 Power Management
Depending on product integration, the Debug Unit clock may be controllable through the Power
Management Controller. In this case, the programmer must first configure the PMC to enable the
Debug Unit clock. Usually, the peripheral identifier used for this purpose is 1.
30.3.3 Interrupt Source
Depending on product integration, the Debug Unit interrupt line is connected to one of the inter-
rupt sources of the Advanced Interrupt Controller. Interrupt handling requires programming of
the AIC before configuring the Debug Unit. Usually, the Debug Unit interrupt line connects to the
interrupt source 1 of the AIC, which may be shared with the real-time clock, the system timer
interrupt lines and other system peripheral interrupts, as shown in Figure 30-1. This sharing
requires the programmer to determine the source of the interrupt when the source 1 is triggered.
30.4 UART Operations
The Debug Unit operates as a UART, (asynchronous mode only) and supports only 8-bit charac-
ter handling (with parity). It has no clock pin.
The Debug Unit's UART is made up of a receiver and a transmitter that operate independently,
and a common baud rate generator. Receiver timeout and transmitter time guard are not imple-
mented. However, all the implemented features are compatible with those of a standard USART.
30.4.1 Baud Rate Generator
The baud rate generator provides the bit period clock named baud rate clock to both the receiver
and the transmitter.
The baud rate clock is the master clock divided by 16 times the value (CD) written in
DBGU_BRGR (Baud Rate Generator Register). If DBGU_BRGR is set to 0, the baud rate clock
is disabled and the Debug Unit's UART remains inactive. The maximum allowable baud rate is
Master Clock divided by 16. The minimum allowable baud rate is Master Clock divided by (16 x
65536).
Baud Rate
MCK
16 CD
---------------------- =
302
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 30-2. Baud Rate Generator
30.4.2 Receiver
30.4.2.1 Receiver Reset, Enable and Disable
After device reset, the Debug Unit receiver is disabled and must be enabled before being used.
The receiver can be enabled by writing the control register DBGU_CR with the bit RXEN at 1. At
this command, the receiver starts looking for a start bit.
The programmer can disable the receiver by writing DBGU_CR with the bit RXDIS at 1. If the
receiver is waiting for a start bit, it is immediately stopped. However, if the receiver has already
detected a start bit and is receiving the data, it waits for the stop bit before actually stopping its
operation.
The programmer can also put the receiver in its reset state by writing DBGU_CR with the bit
RSTRX at 1. In doing so, the receiver immediately stops its current operations and is disabled,
whatever its current state. If RSTRX is applied when data is being processed, this data is lost.
30.4.2.2 Start Detection and Data Sampling
The Debug Unit only supports asynchronous operations, and this affects only its receiver. The
Debug Unit receiver detects the start of a received character by sampling the DRXD signal until
it detects a valid start bit. A low level (space) on DRXD is interpreted as a valid start bit if it is
detected for more than 7 cycles of the sampling clock, which is 16 times the baud rate. Hence, a
space that is longer than 7/16 of the bit period is detected as a valid start bit. A space which is
7/16 of a bit period or shorter is ignored and the receiver continues to wait for a valid start bit.
When a valid start bit has been detected, the receiver samples the DRXD at the theoretical mid-
point of each bit. It is assumed that each bit lasts 16 cycles of the sampling clock (1-bit period)
so the bit sampling point is eight cycles (0.5-bit period) after the start of the bit. The first sampling
point is therefore 24 cycles (1.5-bit periods) after the falling edge of the start bit was detected.
Each subsequent bit is sampled 16 cycles (1-bit period) after the previous one.
MCK 16-bit Counter
0
Baud Rate
Clock
CD
CD
OUT
Divide
by 16
0
1
>1
Receiver
Sampling Clock
303
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 30-3. Start Bit Detection
Figure 30-4. Character Reception
30.4.2.3 Receiver Ready
When a complete character is received, it is transferred to the DBGU_RHR and the RXRDY sta-
tus bit in DBGU_SR (Status Register) is set. The bit RXRDY is automatically cleared when the
receive holding register DBGU_RHR is read.
Figure 30-5. Receiver Ready
30.4.2.4 Receiver Overrun
If DBGU_RHR has not been read by the software (or the Peripheral Data Controller) since the
last transfer, the RXRDY bit is still set and a new character is received, the OVRE status bit in
DBGU_SR is set. OVRE is cleared when the software writes the control register DBGU_CR with
the bit RSTSTA (Reset Status) at 1.
Figure 30-6. Receiver Overrun
30.4.2.5 Parity Error
Each time a character is received, the receiver calculates the parity of the received data bits, in
accordance with the field PAR in DBGU_MR. It then compares the result with the received parity
Sampling Clock
DRXD
True Start
Detection
D0
Baud Rate
Clock
D0 D1 D2 D3 D4 D5 D6 D7
DRXD
True Start Detection
Sampling
Parity Bit
Stop Bit
Example: 8-bit, parity enabled 1 stop
1 bit
period
0.5 bit
period
D0 D1 D2 D3 D4 D5 D6 D7 P S S D0 D1 D2 D3 D4 D5 D6 D7 P DRXD
Read DBGU_RHR
RXRDY
D0 D1 D2 D3 D4 D5 D6 D7 P S S D0 D1 D2 D3 D4 D5 D6 D7 P DRXD
RSTSTA
RXRDY
OVRE
stop stop
304
6222HATARM25-Jan-12
SAM7SE512/256/32
bit. If different, the parity error bit PARE in DBGU_SR is set at the same time the RXRDY is set.
The parity bit is cleared when the control register DBGU_CR is written with the bit RSTSTA
(Reset Status) at 1. If a new character is received before the reset status command is written,
the PARE bit remains at 1.
Figure 30-7. Parity Error
30.4.2.6 Receiver Framing Error
When a start bit is detected, it generates a character reception when all the data bits have been
sampled. The stop bit is also sampled and when it is detected at 0, the FRAME (Framing Error)
bit in DBGU_SR is set at the same time the RXRDY bit is set. The bit FRAME remains high until
the control register DBGU_CR is written with the bit RSTSTA at 1.
Figure 30-8. Receiver Framing Error
30.4.3 Transmitter
30.4.3.1 Transmitter Reset, Enable and Disable
After device reset, the Debug Unit transmitter is disabled and it must be enabled before being
used. The transmitter is enabled by writing the control register DBGU_CR with the bit TXEN at 1.
From this command, the transmitter waits for a character to be written in the Transmit Holding
Register DBGU_THR before actually starting the transmission.
The programmer can disable the transmitter by writing DBGU_CR with the bit TXDIS at 1. If the
transmitter is not operating, it is immediately stopped. However, if a character is being pro-
cessed into the Shift Register and/or a character has been written in the Transmit Holding
Register, the characters are completed before the transmitter is actually stopped.
The programmer can also put the transmitter in its reset state by writing the DBGU_CR with the
bit RSTTX at 1. This immediately stops the transmitter, whether or not it is processing
characters.
30.4.3.2 Transmit Format
The Debug Unit transmitter drives the pin DTXD at the baud rate clock speed. The line is driven
depending on the format defined in the Mode Register and the data stored in the Shift Register.
One start bit at level 0, then the 8 data bits, from the lowest to the highest bit, one optional parity
bit and one stop bit at 1 are consecutively shifted out as shown on the following figure. The field
stop D0 D1 D2 D3 D4 D5 D6 D7 P S DRXD
RSTSTA
RXRDY
PARE
Wrong Parity Bit
D0 D1 D2 D3 D4 D5 D6 D7 P S DRXD
RSTSTA
RXRDY
FRAME
Stop Bit
Detected at 0
stop
305
6222HATARM25-Jan-12
SAM7SE512/256/32
PARE in the mode register DBGU_MR defines whether or not a parity bit is shifted out. When a
parity bit is enabled, it can be selected between an odd parity, an even parity, or a fixed space or
mark bit.
Figure 30-9. Character Transmission
30.4.3.3 Transmitter Control
When the transmitter is enabled, the bit TXRDY (Transmitter Ready) is set in the status register
DBGU_SR. The transmission starts when the programmer writes in the Transmit Holding Regis-
ter DBGU_THR, and after the written character is transferred from DBGU_THR to the Shift
Register. The bit TXRDY remains high until a second character is written in DBGU_THR. As
soon as the first character is completed, the last character written in DBGU_THR is transferred
into the shift register and TXRDY rises again, showing that the holding register is empty.
When both the Shift Register and the DBGU_THR are empty, i.e., all the characters written in
DBGU_THR have been processed, the bit TXEMPTY rises after the last stop bit has been
completed.
Figure 30-10. Transmitter Control
30.4.4 Peripheral Data Controller
Both the receiver and the transmitter of the Debug Unit's UART are generally connected to a
Peripheral Data Controller (PDC) channel.
The peripheral data controller channels are programmed via registers that are mapped within
the Debug Unit user interface from the offset 0x100. The status bits are reported in the Debug
Unit status register DBGU_SR and can generate an interrupt.
D0 D1 D2 D3 D4 D5 D6 D7
DTXD
Start
Bit
Parity
Bit
Stop
Bit
Example: Parity enabled
Baud Rate
Clock
DBGU_THR
Shift Register
DTXD
TXRDY
TXEMPTY
Data 0 Data 1
Data 0
Data 0
Data 1
Data 1 S S P P
Write Data 0
in DBGU_THR
Write Data 1
in DBGU_THR
stop
stop
306
6222HATARM25-Jan-12
SAM7SE512/256/32
The RXRDY bit triggers the PDC channel data transfer of the receiver. This results in a read of
the data in DBGU_RHR. The TXRDY bit triggers the PDC channel data transfer of the transmit-
ter. This results in a write of a data in DBGU_THR.
30.4.5 Test Modes
The Debug Unit supports three tests modes. These modes of operation are programmed by
using the field CHMODE (Channel Mode) in the mode register DBGU_MR.
The Automatic Echo mode allows bit-by-bit retransmission. When a bit is received on the DRXD
line, it is sent to the DTXD line. The transmitter operates normally, but has no effect on the
DTXD line.
The Local Loopback mode allows the transmitted characters to be received. DTXD and DRXD
pins are not used and the output of the transmitter is internally connected to the input of the
receiver. The DRXD pin level has no effect and the DTXD line is held high, as in idle state.
The Remote Loopback mode directly connects the DRXD pin to the DTXD line. The transmitter
and the receiver are disabled and have no effect. This mode allows a bit-by-bit retransmission.
Figure 30-11. Test Modes
30.4.6 Debug Communication Channel Support
The Debug Unit handles the signals COMMRX and COMMTX that come from the Debug Com-
munication Channel of the ARM Processor and are driven by the In-circuit Emulator.
Receiver
Transmitter
Disabled
RXD
TXD
Receiver
Transmitter
Disabled
RXD
TXD
V
DD
Disabled
Receiver
Transmitter
Disabled
RXD
TXD
Disabled
Automatic Echo
Local Loopback
Remote Loopback
VDD
307
6222HATARM25-Jan-12
SAM7SE512/256/32
The Debug Communication Channel contains two registers that are accessible through the ICE
Breaker on the JTAG side and through the coprocessor 0 on the ARM Processor side.
As a reminder, the following instructions are used to read and write the Debug Communication
Channel:
MRC p14, 0, Rd, c1, c0, 0
Returns the debug communication data read register into Rd
MCR p14, 0, Rd, c1, c0, 0
Writes the value in Rd to the debug communication data write register.
The bits COMMRX and COMMTX, which indicate, respectively, that the read register has been
written by the debugger but not yet read by the processor, and that the write register has been
written by the processor and not yet read by the debugger, are wired on the two highest bits of
the status register DBGU_SR. These bits can generate an interrupt. This feature permits han-
dling under interrupt a debug link between a debug monitor running on the target system and a
debugger.
30.4.7 Chip Identifier
The Debug Unit features two chip identifier registers, DBGU_CIDR (Chip ID Register) and
DBGU_EXID (Extension ID). Both registers contain a hard-wired value that is read-only. The first
register contains the following fields:
EXT - shows the use of the extension identifier register
NVPTYP and NVPSIZ - identifies the type of embedded non-volatile memory and its size
ARCH - identifies the set of embedded peripheral
SRAMSIZ - indicates the size of the embedded SRAM
EPROC - indicates the embedded ARM processor
VERSION - gives the revision of the silicon
The second register is device-dependent and reads 0 if the bit EXT is 0.
30.4.8 ICE Access Prevention
The Debug Unit allows blockage of access to the system through the ARM processor's ICE
interface. This feature is implemented via the register Force NTRST (DBGU_FNR), that allows
assertion of the NTRST signal of the ICE Interface. Writing the bit FNTRST (Force NTRST) to 1
in this register prevents any activity on the TAP controller.
On standard devices, the FNTRST bit resets to 0 and thus does not prevent ICE access.
This feature is especially useful on custom ROM devices for customers who do not want their
on-chip code to be visible.
308
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5 Debug Unit User Interface
Table 30-2. Debug Unit Memory Map
Offset Register Name Access Reset Value
0x0000 Control Register DBGU_CR Write-only
0x0004 Mode Register DBGU_MR Read/Write 0x0
0x0008 Interrupt Enable Register DBGU_IER Write-only
0x000C Interrupt Disable Register DBGU_IDR Write-only
0x0010 Interrupt Mask Register DBGU_IMR Read-only 0x0
0x0014 Status Register DBGU_SR Read-only
0x0018 Receive Holding Register DBGU_RHR Read-only 0x0
0x001C Transmit Holding Register DBGU_THR Write-only
0x0020 Baud Rate Generator Register DBGU_BRGR Read/Write 0x0
0x0024 - 0x003C Reserved
0x0040 Chip ID Register DBGU_CIDR Read-only
0x0044 Chip ID Extension Register DBGU_EXID Read-only
0x0048 Force NTRST Register DBGU_FNR Read/Write 0x0
0x004C - 0x00FC Reserved
0x0100 - 0x0124 PDC Area
309
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.1 Debug Unit Control Register
Name: DBGU_CR
Access: Write-only
RSTRX: Reset Receiver
0 = No effect.
1 = The receiver logic is reset and disabled. If a character is being received, the reception is aborted.
RSTTX: Reset Transmitter
0 = No effect.
1 = The transmitter logic is reset and disabled. If a character is being transmitted, the transmission is aborted.
RXEN: Receiver Enable
0 = No effect.
1 = The receiver is enabled if RXDIS is 0.
RXDIS: Receiver Disable
0 = No effect.
1 = The receiver is disabled. If a character is being processed and RSTRX is not set, the character is completed before the
receiver is stopped.
TXEN: Transmitter Enable
0 = No effect.
1 = The transmitter is enabled if TXDIS is 0.
TXDIS: Transmitter Disable
0 = No effect.
1 = The transmitter is disabled. If a character is being processed and a character has been written the DBGU_THR and
RSTTX is not set, both characters are completed before the transmitter is stopped.
RSTSTA: Reset Status Bits
0 = No effect.
1 = Resets the status bits PARE, FRAME and OVRE in the DBGU_SR.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RSTSTA
7 6 5 4 3 2 1 0
TXDIS TXEN RXDIS RXEN RSTTX RSTRX
310
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.2 Debug Unit Mode Register
Name: DBGU_MR
Access: Read/Write
PAR: Parity Type
Parity Type
CHMODE: Channel Mode
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CHMODE PAR
7 6 5 4 3 2 1 0
PAR
0 0 0 Even parity
0 0 1 Odd parity
0 1 0 Space: parity forced to 0
0 1 1 Mark: parity forced to 1
1 x x No parity
CHMODE Mode Description
0 0 Normal Mode
0 1 Automatic Echo
1 0 Local Loopback
1 1 Remote Loopback
311
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.3 Debug Unit Interrupt Enable Register
Name: DBGU_IER
Access: Write-only
RXRDY: Enable RXRDY Interrupt
TXRDY: Enable TXRDY Interrupt
ENDRX: Enable End of Receive Transfer Interrupt
ENDTX: Enable End of Transmit Interrupt
OVRE: Enable Overrun Error Interrupt
FRAME: Enable Framing Error Interrupt
PARE: Enable Parity Error Interrupt
TXEMPTY: Enable TXEMPTY Interrupt
TXBUFE: Enable Buffer Empty Interrupt
RXBUFF: Enable Buffer Full Interrupt
COMMTX: Enable COMMTX (from ARM) Interrupt
COMMRX: Enable COMMRX (from ARM) Interrupt
0 = No effect.
1 = Enables the corresponding interrupt.
31 30 29 28 27 26 25 24
COMMRX COMMTX
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
312
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.4 Debug Unit Interrupt Disable Register
Name: DBGU_IDR
Access: Write-only
RXRDY: Disable RXRDY Interrupt
TXRDY: Disable TXRDY Interrupt
ENDRX: Disable End of Receive Transfer Interrupt
ENDTX: Disable End of Transmit Interrupt
OVRE: Disable Overrun Error Interrupt
FRAME: Disable Framing Error Interrupt
PARE: Disable Parity Error Interrupt
TXEMPTY: Disable TXEMPTY Interrupt
TXBUFE: Disable Buffer Empty Interrupt
RXBUFF: Disable Buffer Full Interrupt
COMMTX: Disable COMMTX (from ARM) Interrupt
COMMRX: Disable COMMRX (from ARM) Interrupt
0 = No effect.
1 = Disables the corresponding interrupt.
31 30 29 28 27 26 25 24
COMMRX COMMTX
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
313
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.5 Debug Unit Interrupt Mask Register
Name: DBGU_IMR
Access: Read-only
RXRDY: Mask RXRDY Interrupt
TXRDY: Disable TXRDY Interrupt
ENDRX: Mask End of Receive Transfer Interrupt
ENDTX: Mask End of Transmit Interrupt
OVRE: Mask Overrun Error Interrupt
FRAME: Mask Framing Error Interrupt
PARE: Mask Parity Error Interrupt
TXEMPTY: Mask TXEMPTY Interrupt
TXBUFE: Mask TXBUFE Interrupt
RXBUFF: Mask RXBUFF Interrupt
COMMTX: Mask COMMTX Interrupt
COMMRX: Mask COMMRX Interrupt
0 = The corresponding interrupt is disabled.
1 = The corresponding interrupt is enabled.
31 30 29 28 27 26 25 24
COMMRX COMMTX
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
314
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.6 Debug Unit Status Register
Name: DBGU_SR
Access: Read-only
RXRDY: Receiver Ready
0 = No character has been received since the last read of the DBGU_RHR or the receiver is disabled.
1 = At least one complete character has been received, transferred to DBGU_RHR and not yet read.
TXRDY: Transmitter Ready
0 = A character has been written to DBGU_THR and not yet transferred to the Shift Register, or the transmitter is disabled.
1 = There is no character written to DBGU_THR not yet transferred to the Shift Register.
ENDRX: End of Receiver Transfer
0 = The End of Transfer signal from the receiver Peripheral Data Controller channel is inactive.
1 = The End of Transfer signal from the receiver Peripheral Data Controller channel is active.
ENDTX: End of Transmitter Transfer
0 = The End of Transfer signal from the transmitter Peripheral Data Controller channel is inactive.
1 = The End of Transfer signal from the transmitter Peripheral Data Controller channel is active.
OVRE: Overrun Error
0 = No overrun error has occurred since the last RSTSTA.
1 = At least one overrun error has occurred since the last RSTSTA.
FRAME: Framing Error
0 = No framing error has occurred since the last RSTSTA.
1 = At least one framing error has occurred since the last RSTSTA.
PARE: Parity Error
0 = No parity error has occurred since the last RSTSTA.
1 = At least one parity error has occurred since the last RSTSTA.
TXEMPTY: Transmitter Empty
0 = There are characters in DBGU_THR, or characters being processed by the transmitter, or the transmitter is disabled.
1 = There are no characters in DBGU_THR and there are no characters being processed by the transmitter.
31 30 29 28 27 26 25 24
COMMRX COMMTX
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
315
6222HATARM25-Jan-12
SAM7SE512/256/32
TXBUFE: Transmission Buffer Empty
0 = The buffer empty signal from the transmitter PDC channel is inactive.
1 = The buffer empty signal from the transmitter PDC channel is active.
RXBUFF: Receive Buffer Full
0 = The buffer full signal from the receiver PDC channel is inactive.
1 = The buffer full signal from the receiver PDC channel is active.
COMMTX: Debug Communication Channel Write Status
0 = COMMTX from the ARM processor is inactive.
1 = COMMTX from the ARM processor is active.
COMMRX: Debug Communication Channel Read Status
0 = COMMRX from the ARM processor is inactive.
1 = COMMRX from the ARM processor is active.
316
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.7 Debug Unit Receiver Holding Register
Name: DBGU_RHR
Access: Read-only
RXCHR: Received Character
Last received character if RXRDY is set.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RXCHR
317
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.8 Debug Unit Transmit Holding Register
Name: DBGU_THR
Access: Write-only
TXCHR: Character to be Transmitted
Next character to be transmitted after the current character if TXRDY is not set.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TXCHR
318
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.9 Debug Unit Baud Rate Generator Register
Name: DBGU_BRGR
Access: Read/Write
CD: Clock Divisor
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CD
7 6 5 4 3 2 1 0
CD
CD Baud Rate Clock
0 Disabled
1 MCK
2 to 65535 MCK / (CD x 16)
319
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.10 Debug Unit Chip ID Register
Name: DBGU_CIDR
Access: Read-only
VERSION: Version of the Device
EPROC: Embedded Processor
NVPSIZ: Nonvolatile Program Memory Size
31 30 29 28 27 26 25 24
EXT NVPTYP ARCH
23 22 21 20 19 18 17 16
ARCH SRAMSIZ
15 14 13 12 11 10 9 8
NVPSIZ2 NVPSIZ
7 6 5 4 3 2 1 0
EPROC VERSION
EPROC Processor
0 0 1 ARM946ES
0 1 0 ARM7TDMI
1 0 0 ARM920T
1 0 1 ARM926EJS
NVPSIZ Size
0 0 0 0 None
0 0 0 1 8K bytes
0 0 1 0 16K bytes
0 0 1 1 32K bytes
0 1 0 0 Reserved
0 1 0 1 64K bytes
0 1 1 0 Reserved
0 1 1 1 128K bytes
1 0 0 0 Reserved
1 0 0 1 256K bytes
1 0 1 0 512K bytes
1 0 1 1 Reserved
1 1 0 0 1024K bytes
1 1 0 1 Reserved
1 1 1 0 2048K bytes
1 1 1 1 Reserved
320
6222HATARM25-Jan-12
SAM7SE512/256/32
NVPSIZ2 Second Nonvolatile Program Memory Size
SRAMSIZ: Internal SRAM Size
NVPSIZ2 Size
0 0 0 0 None
0 0 0 1 8K bytes
0 0 1 0 16K bytes
0 0 1 1 32K bytes
0 1 0 0 Reserved
0 1 0 1 64K bytes
0 1 1 0 Reserved
0 1 1 1 128K bytes
1 0 0 0 Reserved
1 0 0 1 256K bytes
1 0 1 0 512K bytes
1 0 1 1 Reserved
1 1 0 0 1024K bytes
1 1 0 1 Reserved
1 1 1 0 2048K bytes
1 1 1 1 Reserved
SRAMSIZ Size
0 0 0 0 Reserved
0 0 0 1 1K bytes
0 0 1 0 2K bytes
0 0 1 1 6K bytes
0 1 0 0 112K bytes
0 1 0 1 4K bytes
0 1 1 0 80K bytes
0 1 1 1 160K bytes
1 0 0 0 8K bytes
1 0 0 1 16K bytes
1 0 1 0 32K bytes
1 0 1 1 64K bytes
1 1 0 0 128K bytes
1 1 0 1 256K bytes
1 1 1 0 96K bytes
1 1 1 1 512K bytes
321
6222HATARM25-Jan-12
SAM7SE512/256/32
ARCH: Architecture Identifier
NVPTYP: Nonvolatile Program Memory Type
EXT: Extension Flag
0 = Chip ID has a single register definition without extension
1 = An extended Chip ID exists.
ARCH
Architecture Hex Bin
0x19 0001 1001 AT91SAM9xx Series
0x29 0010 1001 AT91SAM9XExx Series
0x34 0011 0100 AT91x34 Series
0x37 0011 0111 CAP7 Series
0x39 0011 1001 CAP9 Series
0x3B 0011 1011 CAP11 Series
0x40 0100 0000 AT91x40 Series
0x42 0100 0010 AT91x42 Series
0x55 0101 0101 AT91x55 Series
0x60 0110 0000 AT91SAM7Axx Series
0x61 0110 0001 AT91SAM7AQxx Series
0x63 0110 0011 AT91x63 Series
0x70 0111 0000 AT91SAM7Sxx Series
0x71 0111 0001 AT91SAM7XCxx Series
0x72 0111 0010 AT91SAM7SExx Series
0x73 0111 0011 AT91SAM Lxx Series
0x75 0111 0101 AT91SAM7Xxx Series
0x92 1001 0010 AT91x92 Series
0xF0 1111 0000 AT75Cxx Series
NVPTYP Memory
0 0 0 ROM
0 0 1 ROMless or on-chip Flash
1 0 0 SRAM emulating ROM
0 1 0 Embedded Flash Memory
0 1 1
ROM and Embedded Flash Memory
NVPSIZ is ROM size
NVPSIZ2 is Flash size
322
6222HATARM25-Jan-12
SAM7SE512/256/32
30.5.11 Debug Unit Chip ID Extension Register
Name: DBGU_EXID
Access: Read-only
EXID: Chip ID Extension
Reads 0 if the bit EXT in DBGU_CIDR is 0.
30.5.12 Debug Unit Force NTRST Register
Name: DBGU_FNR
Access: Read/Write
FNTRST: Force NTRST
0 = NTRST of the ARM processors TAP controller is driven by the power_on_reset signal.
1 = NTRST of the ARM processors TAP controller is held low.
31 30 29 28 27 26 25 24
EXID
23 22 21 20 19 18 17 16
EXID
15 14 13 12 11 10 9 8
EXID
7 6 5 4 3 2 1 0
EXID
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FNTRST
323
6222HATARM25-Jan-12
SAM7SE512/256/32
31. Serial Peripheral Interface (SPI)
31.1 Overview
The Serial Peripheral Interface (SPI) circuit is a synchronous serial data link that provides com-
munication with external devices in Master or Slave Mode. It also enables communication
between processors if an external processor is connected to the system.
The Serial Peripheral Interface is essentially a shift register that serially transmits data bits to
other SPIs. During a data transfer, one SPI system acts as the master' which controls the data
flow, while the other devices act as slaves'' which have data shifted into and out by the master.
Different CPUs can take turn being masters (Multiple Master Protocol opposite to Single Master
Protocol where one CPU is always the master while all of the others are always slaves) and one
master may simultaneously shift data into multiple slaves. However, only one slave may drive its
output to write data back to the master at any given time.
A slave device is selected when the master asserts its NSS signal. If multiple slave devices
exist, the master generates a separate slave select signal for each slave (NPCS).
The SPI system consists of two data lines and two control lines:
Master Out Slave In (MOSI): This data line supplies the output data from the master shifted
into the input(s) of the slave(s).
Master In Slave Out (MISO): This data line supplies the output data from a slave to the input
of the master. There may be no more than one slave transmitting data during any particular
transfer.
Serial Clock (SPCK): This control line is driven by the master and regulates the flow of the
data bits. The master may transmit data at a variety of baud rates; the SPCK line cycles once
for each bit that is transmitted.
Slave Select (NSS): This control line allows slaves to be turned on and off by hardware.
324
6222HATARM25-Jan-12
SAM7SE512/256/32
31.2 Block Diagram
Figure 31-1. Block Diagram
31.3 Application Block Diagram
Figure 31-2. Application Block Diagram: Single Master/Multiple Slave Implementation
SPI Interface
Interrupt Control
PIO
PDC
PMC
MCK
SPI Interrupt
SPCK
MISO
MOSI
NPCS0/NSS
NPCS1
NPCS2
NPCS3
APB
SPI Master
SPCK
MISO
MOSI
NPCS0
NPCS1
NPCS2
SPCK
MISO
MOSI
NSS
Slave 0
SPCK
MISO
MOSI
NSS
Slave 1
SPCK
MISO
MOSI
NSS
Slave 2
NC
NPCS3
325
6222HATARM25-Jan-12
SAM7SE512/256/32
31.4 Signal Description
31.5 Product Dependencies
31.5.1 I/O Lines
The pins used for interfacing the compliant external devices may be multiplexed with PIO lines.
The programmer must first program the PIO controllers to assign the SPI pins to their peripheral
functions.
31.5.2 Power Management
The SPI may be clocked through the Power Management Controller (PMC), thus the program-
mer must first configure the PMC to enable the SPI clock.
31.5.3 Interrupt
The SPI interface has an interrupt line connected to the Advanced Interrupt Controller (AIC).
Handling the SPI interrupt requires programming the AIC before configuring the SPI.
Table 31-1. Signal Description
Pin Name Pin Description
Type
Master Slave
MISO Master In Slave Out Input Output
MOSI Master Out Slave In Output Input
SPCK Serial Clock Output Input
NPCS1-NPCS3 Peripheral Chip Selects Output Unused
NPCS0/NSS Peripheral Chip Select/Slave Select Output Input
326
6222HATARM25-Jan-12
SAM7SE512/256/32
31.6 Functional Description
31.6.1 Modes of Operation
The SPI operates in Master Mode or in Slave Mode.
Operation in Master Mode is programmed by writing at 1 the MSTR bit in the Mode Register.
The pins NPCS0 to NPCS3 are all configured as outputs, the SPCK pin is driven, the MISO line
is wired on the receiver input and the MOSI line driven as an output by the transmitter.
If the MSTR bit is written at 0, the SPI operates in Slave Mode. The MISO line is driven by the
transmitter output, the MOSI line is wired on the receiver input, the SPCK pin is driven by the
transmitter to synchronize the receiver. The NPCS0 pin becomes an input, and is used as a
Slave Select signal (NSS). The pins NPCS1 to NPCS3 are not driven and can be used for other
purposes.
The data transfers are identically programmable for both modes of operations. The baud rate
generator is activated only in Master Mode.
31.6.2 Data Transfer
Four combinations of polarity and phase are available for data transfers. The clock polarity is
programmed with the CPOL bit in the Chip Select Register. The clock phase is programmed with
the NCPHA bit. These two parameters determine the edges of the clock signal on which data is
driven and sampled. Each of the two parameters has two possible states, resulting in four possi-
ble combinations that are incompatible with one another. Thus, a master/slave pair must use the
same parameter pair values to communicate. If multiple slaves are used and fixed in different
configurations, the master must reconfigure itself each time it needs to communicate with a dif-
ferent slave.
Table 31-2 shows the four modes and corresponding parameter settings.
Figure 31-3 and Figure 31-4 show examples of data transfers.
Table 31-2. SPI Bus Protocol Mode
SPI Mode CPOL NCPHA
0 0 1
1 0 0
2 1 1
3 1 0
327
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 31-3. SPI Transfer Format (NCPHA = 1, 8 bits per transfer)
Figure 31-4. SPI Transfer Format (NCPHA = 0, 8 bits per transfer)
6
*
SPCK
(CPOL = 0)
SPCK
(CPOL = 1)
MOSI
(from master)
MISO
(from slave)
NSS
(to slave)
SPCK cycle (for reference)
MSB
MSB
LSB
LSB
6
6
5
5
4
4
3
3
2
2
1
1
* Not defined, but normally MSB of previous character received.
1 2 3 4 5 7 8 6
*
SPCK
(CPOL = 0)
SPCK
(CPOL = 1)
1 2 3 4 5 7
MOSI
(from master)
MISO
(from slave)
NSS
(to slave)
SPCK cycle (for reference)
8
MSB
MSB
LSB
LSB
6
6
5
5
4
4
3
3
1
1
* Not defined but normally LSB of previous character transmitted.
2
2
6
328
6222HATARM25-Jan-12
SAM7SE512/256/32
31.6.3 Master Mode Operations
When configured in Master Mode, the SPI operates on the clock generated by the internal pro-
grammable baud rate generator. It fully controls the data transfers to and from the slave(s)
connected to the SPI bus. The SPI drives the chip select line to the slave and the serial clock
signal (SPCK).
The SPI features two holding registers, the Transmit Data Register and the Receive Data Regis-
ter, and a single Shift Register. The holding registers maintain the data flow at a constant rate.
After enabling the SPI, a data transfer begins when the processor writes to the SPI_TDR (Trans-
mit Data Register). The written data is immediately transferred in the Shift Register and transfer
on the SPI bus starts. While the data in the Shift Register is shifted on the MOSI line, the MISO
line is sampled and shifted in the Shift Register. Transmission cannot occur without reception.
Before writing the TDR, the PCS field must be set in order to select a slave.
If new data is written in SPI_TDR during the transfer, it stays in it until the current transfer is
completed. Then, the received data is transferred from the Shift Register to SPI_RDR, the data
in SPI_TDR is loaded in the Shift Register and a new transfer starts.
The transfer of a data written in SPI_TDR in the Shift Register is indicated by the TDRE bit
(Transmit Data Register Empty) in the Status Register (SPI_SR). When new data is written in
SPI_TDR, this bit is cleared. The TDRE bit is used to trigger the Transmit PDC channel.
The end of transfer is indicated by the TXEMPTY flag in the SPI_SR register. If a transfer delay
(DLYBCT) is greater than 0 for the last transfer, TXEMPTY is set after the completion of said
delay. The master clock (MCK) can be switched off at this time.
The transfer of received data from the Shift Register in SPI_RDR is indicated by the RDRF bit
(Receive Data Register Full) in the Status Register (SPI_SR). When the received data is read,
the RDRF bit is cleared.
If the SPI_RDR (Receive Data Register) has not been read before new data is received, the
Overrun Error bit (OVRES) in SPI_SR is set. As long as this flag is set, data is loaded in
SPI_RDR. The user has to read the status register to clear the OVRES bit.
Figure 31-5 on page 329 shows a block diagram of the SPI when operating in Master Mode. Fig-
ure 31-6 on page 330 shows a flow chart describing how transfers are handled.
329
6222HATARM25-Jan-12
SAM7SE512/256/32
31.6.3.1 Master Mode Block Diagram
Figure 31-5. Master Mode Block Diagram
Shift Register
SPCK
MOSI
LSB MSB
MISO
SPI_RDR
RD
SPI
Clock
TDRE
SPI_TDR
TD
RDRF
OVRES
SPI_CSR0..3
CPOL
NCPHA
BITS
MCK
Baud Rate Generator
SPI_CSR0..3
SCBR
NPCS3
NPCS0
NPCS2
NPCS1
NPCS0
0
1
PS
SPI_MR
PCS
SPI_TDR
PCS
MODF
Current
Peripheral
SPI_RDR
PCS
SPI_CSR0..3
CSAAT
PCSDEC
MODFDIS
MSTR
330
6222HATARM25-Jan-12
SAM7SE512/256/32
31.6.3.2 Master Mode Flow Diagram
Figure 31-6. Master Mode Flow Diagram S
SPI Enable
CSAAT ?
PS ?
1
0
0
1
1
NPCS = SPI_TDR(PCS) NPCS = SPI_MR(PCS)
Delay DLYBS
Serializer = SPI_TDR(TD)
TDRE = 1
Data Transfer
SPI_RDR(RD) = Serializer
RDRF = 1
TDRE ?
NPCS = 0xF
Delay DLYBCS
Fixed
peripheral
Variable
peripheral
Delay DLYBCT
0
1
CSAAT ?
0
TDRE ?
1
0
PS ?
0
1
SPI_TDR(PCS)
= NPCS ?
no
yes
SPI_MR(PCS)
= NPCS ?
no
NPCS = 0xF
Delay DLYBCS
NPCS = SPI_TDR(PCS)
NPCS = 0xF
Delay DLYBCS
NPCS = SPI_MR(PCS),
SPI_TDR(PCS)
Fixed
peripheral
Variable
peripheral
- NPCS defines the current Chip Select
- CSAAT, DLYBS, DLYBCT refer to the fields of the
Chip Select Register corresponding to the Current Chip Select
- When NPCS is 0xF, CSAAT is 0.
331
6222HATARM25-Jan-12
SAM7SE512/256/32
31.6.3.3 Clock Generation
The SPI Baud rate clock is generated by dividing the Master Clock (MCK), by a value between 1
and 255.
This allows a maximum operating baud rate at up to Master Clock and a minimum operating
baud rate of MCK divided by 255.
Programming the SCBR field at 0 is forbidden. Triggering a transfer while SCBR is at 0 can lead
to unpredictable results.
At reset, SCBR is 0 and the user has to program it at a valid value before performing the first
transfer.
The divisor can be defined independently for each chip select, as it has to be programmed in the
SCBR field of the Chip Select Registers. This allows the SPI to automatically adapt the baud
rate for each interfaced peripheral without reprogramming.
31.6.3.4 Transfer Delays
Figure 31-7 shows a chip select transfer change and consecutive transfers on the same chip
select. Three delays can be programmed to modify the transfer waveforms:
The delay between chip selects, programmable only once for all the chip selects by writing
the DLYBCS field in the Mode Register. Allows insertion of a delay between release of one
chip select and before assertion of a new one.
The delay before SPCK, independently programmable for each chip select by writing the field
DLYBS. Allows the start of SPCK to be delayed after the chip select has been asserted.
The delay between consecutive transfers, independently programmable for each chip select
by writing the DLYBCT field. Allows insertion of a delay between two transfers occurring on
the same chip select
These delays allow the SPI to be adapted to the interfaced peripherals and their speed and bus
release time.
Figure 31-7. Programmable Delays
31.6.3.5 Peripheral Selection
The serial peripherals are selected through the assertion of the NPCS0 to NPCS3 signals. By
default, all the NPCS signals are high before and after each transfer.
The peripheral selection can be performed in two different ways:
Fixed Peripheral Select: SPI exchanges data with only one peripheral
DLYBCS DLYBS DLYBCT DLYBCT
Chip Select 1
Chip Select 2
SPCK
332
6222HATARM25-Jan-12
SAM7SE512/256/32
Variable Peripheral Select: Data can be exchanged with more than one peripheral
Fixed Peripheral Select is activated by writing the PS bit to zero in SPI_MR (Mode Register). In
this case, the current peripheral is defined by the PCS field in SPI_MR and the PCS field in the
SPI_TDR has no effect.
Variable Peripheral Select is activated by setting PS bit to one. The PCS field in SPI_TDR is
used to select the current peripheral. This means that the peripheral selection can be defined for
each new data.
The Fixed Peripheral Selection allows buffer transfers with a single peripheral. Using the PDC is
an optimal means, as the size of the data transfer between the memory and the SPI is either 8
bits or 16 bits. However, changing the peripheral selection requires the Mode Register to be
reprogrammed.
The Variable Peripheral Selection allows buffer transfers with multiple peripherals without repro-
gramming the Mode Register. Data written in SPI_TDR is 32 bits wide and defines the real data
to be transmitted and the peripheral it is destined to. Using the PDC in this mode requires 32-bit
wide buffers, with the data in the LSBs and the PCS and LASTXFER fields in the MSBs, how-
ever the SPI still controls the number of bits (8 to16) to be transferred through MISO and MOSI
lines with the chip select configuration registers. This is not the optimal means in term of mem-
ory size for the buffers, but it provides a very effective means to exchange data with several
peripherals without any intervention of the processor.
31.6.3.6 Peripheral Chip Select Decoding
The user can program the SPI to operate with up to 15 peripherals by decoding the four Chip
Select lines, NPCS0 to NPCS3 with an external logic. This can be enabled by writing the PCS-
DEC bit at 1 in the Mode Register (SPI_MR).
When operating without decoding, the SPI makes sure that in any case only one chip select line
is activated, i.e. driven low at a time. If two bits are defined low in a PCS field, only the lowest
numbered chip select is driven low.
When operating with decoding, the SPI directly outputs the value defined by the PCS field of
either the Mode Register or the Transmit Data Register (depending on PS).
As the SPI sets a default value of 0xF on the chip select lines (i.e. all chip select lines at 1) when
not processing any transfer, only 15 peripherals can be decoded.
The SPI has only four Chip Select Registers, not 15. As a result, when decoding is activated,
each chip select defines the characteristics of up to four peripherals. As an example, SPI_CRS0
defines the characteristics of the externally decoded peripherals 0 to 3, corresponding to the
PCS values 0x0 to 0x3. Thus, the user has to make sure to connect compatible peripherals on
the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14.
31.6.3.7 Peripheral Deselection
When operating normally, as soon as the transfer of the last data written in SPI_TDR is com-
pleted, the NPCS lines all rise. This might lead to runtime error if the processor is too long in
responding to an interrupt, and thus might lead to difficulties for interfacing with some serial
peripherals requiring the chip select line to remain active during a full set of transfers.
To facilitate interfacing with such devices, the Chip Select Register can be programmed with the
CSAAT bit (Chip Select Active After Transfer) at 1. This allows the chip select lines to remain in
their current state (low = active) until transfer to another peripheral is required.
333
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 31-8 shows different peripheral deselection cases and the effect of the CSAAT bit.
Figure 31-8. Peripheral Deselection
31.6.3.8 Mode Fault Detection
A mode fault is detected when the SPI is programmed in Master Mode and a low level is driven
by an external master on the NPCS0/NSS signal. NPCS0, MOSI, MISO and SPCK must be con-
figured in open drain through the PIO controller, so that external pull up resistors are needed to
guarantee high level.
When a mode fault is detected, the MODF bit in the SPI_SR is set until the SPI_SR is read and
the SPI is automatically disabled until re-enabled by writing the SPIEN bit in the SPI_CR (Con-
trol Register) at 1.
By default, the Mode Fault detection circuitry is enabled. The user can disable Mode Fault
detection by setting the MODFDIS bit in the SPI Mode Register (SPI_MR).
31.6.4 SPI Slave Mode
When operating in Slave Mode, the SPI processes data bits on the clock provided on the SPI
clock pin (SPCK).
The SPI waits for NSS to go active before receiving the serial clock from an external master.
When NSS falls, the clock is validated on the serializer, which processes the number of bits
A
NPCS[0..3]
Write SPI_TDR
TDRE
NPCS[0..3]
Write SPI_TDR
TDRE
NPCS[0..3]
Write SPI_TDR
TDRE
DLYBCS
PCS = A
DLYBCS
DLYBCT
A
PCS = B
B
DLYBCS
PCS = A
DLYBCS
DLYBCT
A
PCS = B
B
DLYBCS
DLYBCT
PCS=A
A
DLYBCS
DLYBCT
A
PCS = A
A A
DLYBCT
A A
CSAAT = 0
DLYBCT
A A
CSAAT = 1
A
334
6222HATARM25-Jan-12
SAM7SE512/256/32
defined by the BITS field of the Chip Select Register 0 (SPI_CSR0). These bits are processed
following a phase and a polarity defined respectively by the NCPHA and CPOL bits of the
SPI_CSR0. Note that BITS, CPOL and NCPHA of the other Chip Select Registers have no
effect when the SPI is programmed in Slave Mode.
The bits are shifted out on the MISO line and sampled on the MOSI line.
When all the bits are processed, the received data is transferred in the Receive Data Register
and the RDRF bit rises. If RDRF is already high when the data is transferred, the Overrun bit
rises and the data transfer to SPI_RDR is aborted.
When a transfer starts, the data shifted out is the data present in the Shift Register. If no data
has been written in the Transmit Data Register (SPI_TDR), the last data received is transferred.
If no data has been received since the last reset, all bits are transmitted low, as the Shift Regis-
ter resets at 0.
When a first data is written in SPI_TDR, it is transferred immediately in the Shift Register and the
TDRE bit rises. If new data is written, it remains in SPI_TDR until a transfer occurs, i.e. NSS falls
and there is a valid clock on the SPCK pin. When the transfer occurs, the last data written in
SPI_TDR is transferred in the Shift Register and the TDRE bit rises. This enables frequent
updates of critical variables with single transfers.
Then, a new data is loaded in the Shift Register from the Transmit Data Register. In case no
character is ready to be transmitted, i.e. no character has been written in SPI_TDR since the last
load from SPI_TDR to the Shift Register, the Shift Register is not modified and the last received
character is retransmitted.
Figure 31-9 shows a block diagram of the SPI when operating in Slave Mode.
Figure 31-9. Slave Mode Functional Block Diagram
Shift Register
SPCK
SPIENS
LSB MSB
NSS
MOSI
SPI_RDR
RD
SPI
Clock
TDRE
SPI_TDR
TD
RDRF
OVRES
SPI_CSR0
CPOL
NCPHA
BITS
SPIEN
SPIDIS
MISO
335
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7 Serial Peripheral Interface (SPI) User Interface
Table 31-3. SPI Register Mapping
Offset Register Register Name Access Reset
0x00 Control Register SPI_CR Write-only ---
0x04 Mode Register SPI_MR Read/Write 0x0
0x08 Receive Data Register SPI_RDR Read-only 0x0
0x0C Transmit Data Register SPI_TDR Write-only ---
0x10 Status Register SPI_SR Read-only 0x000000F0
0x14 Interrupt Enable Register SPI_IER Write-only ---
0x18 Interrupt Disable Register SPI_IDR Write-only ---
0x1C Interrupt Mask Register SPI_IMR Read-only 0x0
0x20 - 0x2C Reserved
0x30 Chip Select Register 0 SPI_CSR0 Read/Write 0x0
0x34 Chip Select Register 1 SPI_CSR1 Read/Write 0x0
0x38 Chip Select Register 2 SPI_CSR2 Read/Write 0x0
0x3C Chip Select Register 3 SPI_CSR3 Read/Write 0x0
0x004C - 0x00F8 Reserved
0x004C - 0x00FC Reserved
0x100 - 0x124 Reserved for the PDC
336
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.1 SPI Control Register
Name: SPI_CR
Access: Write-only
SPIEN: SPI Enable
0 = No effect.
1 = Enables the SPI to transfer and receive data.
SPIDIS: SPI Disable
0 = No effect.
1 = Disables the SPI.
As soon as SPIDIS is set, SPI finishes its transfer.
All pins are set in input mode and no data is received or transmitted.
If a transfer is in progress, the transfer is finished before the SPI is disabled.
If both SPIEN and SPIDIS are equal to one when the control register is written, the SPI is disabled.
SWRST: SPI Software Reset
0 = No effect.
1 = Reset the SPI. A software-triggered hardware reset of the SPI interface is performed.
The SPI is in slave mode after software reset.
PDC channels are not affected by software reset.
LASTXFER: Last Transfer
0 = No effect.
1 = The current NPCS will be deasserted after the character written in TD has been transferred. When CSAAT is set, this
allows to close the communication with the current serial peripheral by raising the corresponding NPCS line as soon as TD
transfer has completed.
31 30 29 28 27 26 25 24
LASTXFER
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SWRST SPIDIS SPIEN
337
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.2 SPI Mode Register
Name: SPI_MR
Access: Read/Write
MSTR: Master/Slave Mode
0 = SPI is in Slave mode.
1 = SPI is in Master mode.
PS: Peripheral Select
0 = Fixed Peripheral Select.
1 = Variable Peripheral Select.
PCSDEC: Chip Select Decode
0 = The chip selects are directly connected to a peripheral device.
1 = The four chip select lines are connected to a 4- to 16-bit decoder.
When PCSDEC equals one, up to 15 Chip Select signals can be generated with the four lines using an external 4- to 16-bit
decoder. The Chip Select Registers define the characteristics of the 15 chip selects according to the following rules:
SPI_CSR0 defines peripheral chip select signals 0 to 3.
SPI_CSR1 defines peripheral chip select signals 4 to 7.
SPI_CSR2 defines peripheral chip select signals 8 to 11.
SPI_CSR3 defines peripheral chip select signals 12 to 14.
MODFDIS: Mode Fault Detection
0 = Mode fault detection is enabled.
1 = Mode fault detection is disabled.
LLB: Local Loopback Enable
0 = Local loopback path disabled.
1 = Local loopback path enabled.
LLB controls the local loopback on the data serializer for testing in Master Mode only. (MISO is internally connected on
MOSI.)
31 30 29 28 27 26 25 24
DLYBCS
23 22 21 20 19 18 17 16
PCS
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
LLB MODFDIS PCSDEC PS MSTR
338
6222HATARM25-Jan-12
SAM7SE512/256/32
PCS: Peripheral Chip Select
This field is only used if Fixed Peripheral Select is active (PS = 0).
If PCSDEC = 0:
PCS = xxx0 NPCS[3:0] = 1110
PCS = xx01 NPCS[3:0] = 1101
PCS = x011 NPCS[3:0] = 1011
PCS = 0111 NPCS[3:0] = 0111
PCS = 1111 forbidden (no peripheral is selected)
(x = dont care)
If PCSDEC = 1:
NPCS[3:0] output signals = PCS.
DLYBCS: Delay Between Chip Selects
This field defines the delay from NPCS inactive to the activation of another NPCS. The DLYBCS time guarantees non-over-
lapping chip selects and solves bus contentions in case of peripherals having long data float times.
If DLYBCS is less than or equal to six, six MCK periods will be inserted by default.
Otherwise, the following equation determines the delay:
Delay Between Chip Selects
DLYBCS
MCK
----------------------- =
339
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.3 SPI Receive Data Register
Name: SPI_RDR
Access: Read-only
RD: Receive Data
Data received by the SPI Interface is stored in this register right-justified. Unused bits read zero.
PCS: Peripheral Chip Select
In Master Mode only, these bits indicate the value on the NPCS pins at the end of a transfer. Otherwise, these bits read
zero.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
PCS
15 14 13 12 11 10 9 8
RD
7 6 5 4 3 2 1 0
RD
340
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.4 SPI Transmit Data Register
Name: SPI_TDR
Access: Write-only
TD: Transmit Data
Data to be transmitted by the SPI Interface is stored in this register. Information to be transmitted must be written to the
transmit data register in a right-justified format.
PCS: Peripheral Chip Select
This field is only used if Variable Peripheral Select is active (PS = 1).
If PCSDEC = 0:
PCS = xxx0 NPCS[3:0] = 1110
PCS = xx01 NPCS[3:0] = 1101
PCS = x011 NPCS[3:0] = 1011
PCS = 0111 NPCS[3:0] = 0111
PCS = 1111 forbidden (no peripheral is selected)
(x = dont care)
If PCSDEC = 1:
NPCS[3:0] output signals = PCS
LASTXFER: Last Transfer
0 = No effect.
1 = The current NPCS will be deasserted after the character written in TD has been transferred. When CSAAT is set, this
allows to close the communication with the current serial peripheral by raising the corresponding NPCS line as soon as TD
transfer has completed.
This field is only used if Variable Peripheral Select is active (PS = 1).
31 30 29 28 27 26 25 24
LASTXFER
23 22 21 20 19 18 17 16
PCS
15 14 13 12 11 10 9 8
TD
7 6 5 4 3 2 1 0
TD
341
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.5 SPI Status Register
Name: SPI_SR
Access: Read-only
RDRF: Receive Data Register Full
0 = No data has been received since the last read of SPI_RDR
1 = Data has been received and the received data has been transferred from the serializer to SPI_RDR since the last read
of SPI_RDR.
TDRE: Transmit Data Register Empty
0 = Data has been written to SPI_TDR and not yet transferred to the serializer.
1 = The last data written in the Transmit Data Register has been transferred to the serializer.
TDRE equals zero when the SPI is disabled or at reset. The SPI enable command sets this bit to one.
MODF: Mode Fault Error
0 = No Mode Fault has been detected since the last read of SPI_SR.
1 = A Mode Fault occurred since the last read of the SPI_SR.
OVRES: Overrun Error Status
0 = No overrun has been detected since the last read of SPI_SR.
1 = An overrun has occurred since the last read of SPI_SR.
An overrun occurs when SPI_RDR is loaded at least twice from the serializer since the last read of the SPI_RDR.
ENDRX: End of RX buffer
0 = The Receive Counter Register has not reached 0 since the last write in SPI_RCR
(1)
or SPI_RNCR
(1)
.
1 = The Receive Counter Register has reached 0 since the last write in SPI_RCR
(1)
or SPI_RNCR
(1)
.
ENDTX: End of TX buffer
0 = The Transmit Counter Register has not reached 0 since the last write in SPI_TCR
(1)
or SPI_TNCR
(1)
.
1 = The Transmit Counter Register has reached 0 since the last write in SPI_TCR
(1)
or SPI_TNCR
(1)
.
RXBUFF: RX Buffer Full
0 = SPI_RCR
(1)
or SPI_RNCR
(1)
has a value other than 0.
1 = Both SPI_RCR
(1)
and SPI_RNCR
(1)
have a value of 0.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
SPIENS
15 14 13 12 11 10 9 8
TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
342
6222HATARM25-Jan-12
SAM7SE512/256/32
TXBUFE: TX Buffer Empty
0 = SPI_TCR
(1)
or SPI_TNCR
(1)
has a value other than 0.
1 = Both SPI_TCR
(1)
and SPI_TNCR
(1)
have a value of 0.
NSSR: NSS Rising
0 = No rising edge detected on NSS pin since last read.
1 = A rising edge occurred on NSS pin since last read.
TXEMPTY: Transmission Registers Empty
0 = As soon as data is written in SPI_TDR.
1 = SPI_TDR and internal shifter are empty. If a transfer delay has been defined, TXEMPTY is set after the completion of
such delay.
SPIENS: SPI Enable Status
0 = SPI is disabled.
1 = SPI is enabled.
Note: 1. SPI_RCR, SPI_RNCR, SPI_TCR, SPI_TNCR are physically located in the PDC.
343
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.6 SPI Interrupt Enable Register
Name: SPI_IER
Access: Write-only
RDRF: Receive Data Register Full Interrupt Enable
TDRE: SPI Transmit Data Register Empty Interrupt Enable
MODF: Mode Fault Error Interrupt Enable
OVRES: Overrun Error Interrupt Enable
ENDRX: End of Receive Buffer Interrupt Enable
ENDTX: End of Transmit Buffer Interrupt Enable
RXBUFF: Receive Buffer Full Interrupt Enable
TXBUFE: Transmit Buffer Empty Interrupt Enable
TXEMPTY: Transmission Registers Empty Enable
NSSR: NSS Rising Interrupt Enable
0 = No effect.
1 = Enables the corresponding interrupt.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
344
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.7 SPI Interrupt Disable Register
Name: SPI_IDR
Access: Write-only
RDRF: Receive Data Register Full Interrupt Disable
TDRE: SPI Transmit Data Register Empty Interrupt Disable
MODF: Mode Fault Error Interrupt Disable
OVRES: Overrun Error Interrupt Disable
ENDRX: End of Receive Buffer Interrupt Disable
ENDTX: End of Transmit Buffer Interrupt Disable
RXBUFF: Receive Buffer Full Interrupt Disable
TXBUFE: Transmit Buffer Empty Interrupt Disable
TXEMPTY: Transmission Registers Empty Disable
NSSR: NSS Rising Interrupt Disable
0 = No effect.
1 = Disables the corresponding interrupt.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
345
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.8 SPI Interrupt Mask Register
Name: SPI_IMR
Access: Read-only
RDRF: Receive Data Register Full Interrupt Mask
TDRE: SPI Transmit Data Register Empty Interrupt Mask
MODF: Mode Fault Error Interrupt Mask
OVRES: Overrun Error Interrupt Mask
ENDRX: End of Receive Buffer Interrupt Mask
ENDTX: End of Transmit Buffer Interrupt Mask
RXBUFF: Receive Buffer Full Interrupt Mask
TXBUFE: Transmit Buffer Empty Interrupt Mask
TXEMPTY: Transmission Registers Empty Mask
NSSR: NSS Rising Interrupt Mask
0 = The corresponding interrupt is not enabled.
1 = The corresponding interrupt is enabled.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
346
6222HATARM25-Jan-12
SAM7SE512/256/32
31.7.9 SPI Chip Select Register
Name: SPI_CSR0... SPI_CSR3
Access: Read/Write
CPOL: Clock Polarity
0 = The inactive state value of SPCK is logic level zero.
1 = The inactive state value of SPCK is logic level one.
CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with NCPHA to produce the
required clock/data relationship between master and slave devices.
NCPHA: Clock Phase
0 = Data is changed on the leading edge of SPCK and captured on the following edge of SPCK.
1 = Data is captured on the leading edge of SPCK and changed on the following edge of SPCK.
NCPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. NCPHA is
used with CPOL to produce the required clock/data relationship between master and slave devices.
CSAAT: Chip Select Active After Transfer
0 = The Peripheral Chip Select Line rises as soon as the last transfer is achieved.
1 = The Peripheral Chip Select does not rise after the last transfer is achieved. It remains active until a new transfer is
requested on a different chip select.
BITS: Bits Per Transfer
The BITS field determines the number of data bits transferred. Reserved values should not be used.
31 30 29 28 27 26 25 24
DLYBCT
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
7 6 5 4 3 2 1 0
BITS CSAAT NCPHA CPOL
BITS Bits Per Transfer
0000 8
0001 9
0010 10
0011 11
0100 12
0101 13
0110 14
0111 15
1000 16
347
6222HATARM25-Jan-12
SAM7SE512/256/32
SCBR: Serial Clock Baud Rate
In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the Master Clock MCK. The
Baud rate is selected by writing a value from 1 to 255 in the SCBR field. The following equations determine the SPCK baud
rate:
Programming the SCBR field at 0 is forbidden. Triggering a transfer while SCBR is at 0 can lead to unpredictable results.
At reset, SCBR is 0 and the user has to program it at a valid value before performing the first transfer.
DLYBS: Delay Before SPCK
This field defines the delay from NPCS valid to the first valid SPCK transition.
When DLYBS equals zero, the NPCS valid to SPCK transition is 1/2 the SPCK clock period.
Otherwise, the following equations determine the delay:
DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select.
The delay is always inserted after each transfer and before removing the chip select if needed.
When DLYBCT equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the
character transfers.
Otherwise, the following equation determines the delay:
1001 Reserved
1010 Reserved
1011 Reserved
1100 Reserved
1101 Reserved
1110 Reserved
1111 Reserved
BITS Bits Per Transfer
SPCK Baudrate
MCK
SCBR
--------------- =
Delay Before SPCK
DLYBS
MCK
------------------- =
Delay Between Consecutive Transfers
32 DLYBCT
MCK
------------------------------------- =
348
6222HATARM25-Jan-12
SAM7SE512/256/32
349
6222HATARM25-Jan-12
SAM7SE512/256/32
32. Two Wire Interface (TWI)
32.1 Overview
The Atmel Two-wire Interface (TWI) interconnects components on a unique two-wire bus, made
up of one clock line and one data line with speeds of up to 400 Kbits per second, based on a
byte-oriented transfer format. It can be used with any Atmel Two-wire Interface bus Serial
EEPROM and IC compatible device such as Real Time Clock (RTC), Dot Matrix/Graphic LCD
Controllers and Temperature Sensor, to name but a few. The TWI is programmable as a master
or a slave with sequential or single-byte access. Multiple master capability is supported. Arbitra-
tion of the bus is performed internally and puts the TWI in slave mode automatically if the bus
arbitration is lost.
A configurable baud rate generator permits the output data rate to be adapted to a wide range of
core clock frequencies.
Below, Table 32-1 lists the compatibility level of the Atmel Two-wire Interface in Master Mode and
a full I2C compatible device.
Note: 1. START + b000000001 + Ack + Sr
32.2 List of Abbreviations
Table 32-1. Atmel TWI compatibility with i2C Standard
I2C Standard Atmel TWI
Standard Mode Speed (100 KHz) Supported
Fast Mode Speed (400 KHz) Supported
7 or 10 bits Slave Addressing Supported
START BYTE
(1)
Not Supported
Repeated Start (Sr) Condition Supported
ACK and NACK Management Supported
Slope control and input filtering (Fast mode) Not Supported
Clock stretching Supported
Table 32-2. Abbreviations
Abbreviation Description
TWI Two-wire Interface
A Acknowledge
NA Non Acknowledge
P Stop
S Start
Sr Repeated Start
SADR Slave Address
ADR Any address except SADR
R Read
W Write
350
6222HATARM25-Jan-12
SAM7SE512/256/32
32.3 Block Diagram
Figure 32-1. Block Diagram
32.4 Application Block Diagram
Figure 32-2. Application Block Diagram
32.4.1 I/O Lines Description
APB Bridge
PMC
MCK
Two-wire
Interface
PIO
AIC
TWI
Interrupt
TWCK
TWD
Host with
TWI
Interface
TWD
TWCK
Atmel TWI
Serial EEPROM
IC RTC
IC LCD
Controller
Slave 1 Slave 2 Slave 3
VDD
IC Temp.
Sensor
Slave 4
Rp: Pull up value as given by the IC Standard
Rp Rp
Table 32-3. I/O Lines Description
Pin Name Pin Description Type
TWD Two-wire Serial Data Input/Output
TWCK Two-wire Serial Clock Input/Output
351
6222HATARM25-Jan-12
SAM7SE512/256/32
32.5 Product Dependencies
32.5.1 I/O Lines
Both TWD and TWCK are bidirectional lines, connected to a positive supply voltage via a current
source or pull-up resistor (see Figure 32-2 on page 350). When the bus is free, both lines are
high. The output stages of devices connected to the bus must have an open-drain or open-col-
lector to perform the wired-AND function.
TWD and TWCK pins may be multiplexed with PIO lines. To enable the TWI, the programmer
must perform the following steps:
Program the PIO controller to:
Dedicate TWD and TWCK as peripheral lines.
Define TWD and TWCK as open-drain.
32.5.2 Power Management
Enable the peripheral clock.
The TWI interface may be clocked through the Power Management Controller (PMC), thus the
programmer must first configure the PMC to enable the TWI clock.
32.5.3 Interrupt
The TWI interface has an interrupt line connected to the Advanced Interrupt Controller (AIC). In
order to handle interrupts, the AIC must be programmed before configuring the TWI.
352
6222HATARM25-Jan-12
SAM7SE512/256/32
32.6 Functional Description
32.6.1 Transfer Format
The data put on the TWD line must be 8 bits long. Data is transferred MSB first; each byte must
be followed by an acknowledgement. The number of bytes per transfer is unlimited (see Figure
32-4).
Each transfer begins with a START condition and terminates with a STOP condition (see Figure
32-3).
A high-to-low transition on the TWD line while TWCK is high defines the START condition.
A low-to-high transition on the TWD line while TWCK is high defines a STOP condition.
Figure 32-3. START and STOP Conditions
Figure 32-4. Transfer Format
32.6.2 Modes of Operation
The TWI has six modes of operations:
Master transmitter mode
Master receiver mode
Multi-master transmitter mode
Multi-master receiver mode
Slave transmitter mode
Slave receiver mode
These modes are described in the following chapters.
TWD
TWCK
Start Stop
TWD
TWCK
Start Address R/W Ack Data Ack Data Ack Stop
353
6222HATARM25-Jan-12
SAM7SE512/256/32
32.7 Master Mode
32.7.1 Definition
The Master is the device which starts a transfer, generates a clock and stops it.
32.7.2 Application Block Diagram
Figure 32-5. Master Mode Typical Application Block Diagram
32.7.3 Programming Master Mode
The following registers have to be programmed before entering Master mode:
1. DADR (+ IADRSZ + IADR if a 10 bit device is addressed): The device address is used
to access slave devices in read or write mode.
2. CKDIV + CHDIV + CLDIV: Clock Waveform.
3. SVDIS: Disable the slave mode.
4. MSEN: Enable the master mode.
32.7.4 Master Transmitter Mode
After the master initiates a Start condition when writing into the Transmit Holding Register,
TWI_THR, it sends a 7-bit slave address, configured in the Master Mode register (DADR in
TWI_MMR), to notify the slave device. The bit following the slave address indicates the transfer
direction, 0 in this case (MREAD = 0 in TWI_MMR).
The TWI transfers require the slave to acknowledge each received byte. During the acknowl-
edge clock pulse (9th pulse), the master releases the data line (HIGH), enabling the slave to pull
it down in order to generate the acknowledge. The master polls the data line during this clock
pulse and sets the Not Acknowledge bit (NACK) in the status register if the slave does not
acknowledge the byte. As with the other status bits, an interrupt can be generated if enabled in
the interrupt enable register (TWI_IER). If the slave acknowledges the byte, the data written in
the TWI_THR, is then shifted in the internal shifter and transferred. When an acknowledge is
detected, the TXRDY bit is set until a new write in the TWI_THR. When no more data is written
into the TWI_THR, the master generates a stop condition to end the transfer. The end of the
complete transfer is marked by the TWI_TXCOMP bit set to one. See Figure 32-6, Figure 32-7,
and Figure 32-8.
Host with
TWI
Interface
TWD
TWCK
Atmel TWI
Serial EEPROM
IC RTC
IC LCD
Controller
Slave 1 Slave 2 Slave 3
VDD
IC Temp.
Sensor
Slave 4
Rp: Pull up value as given by the IC Standard
Rp Rp
354
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-6. Master Write with One Data Byte
Figure 32-7. Master Write with Multiple Data Byte
Figure 32-8. Master Write with One Byte Internal Address and Multiple Data Bytes
32.7.5 Master Receiver Mode
The read sequence begins by setting the START bit. After the start condition has been sent, the
master sends a 7-bit slave address to notify the slave device. The bit following the slave address
indicates the transfer direction, 1 in this case (MREAD = 1 in TWI_MMR). During the acknowl-
edge clock pulse (9th pulse), the master releases the data line (HIGH), enabling the slave to pull
it down in order to generate the acknowledge. The master polls the data line during this clock
pulse and sets the NACK bit in the status register if the slave does not acknowledge the byte.
If an acknowledge is received, the master is then ready to receive data from the slave. After data
has been received, the master sends an acknowledge condition to notify the slave that the data
has been received except for the last data, after the stop condition. See Figure 32-9. When the
RXRDY bit is set in the status register, a character has been received in the receive-holding reg-
ister (TWI_RHR). The RXRDY bit is reset when reading the TWI_RHR.
TXCOMP
TXRDY
Write THR (DATA) STOP sent automaticaly
(ACK received and TXRDY = 1)
TWD A DATA A S DADR W P
A DATA n A S DADR W DATA n+5 A P DATA n+x A
TXCOMP
TXRDY
Write THR (Data n) Write THR (Data n+1) Write THR (Data n+x)
Last data sent
STOP sent automaticaly
(ACK received and TXRDY = 1)
TWD
A IADR(7:0) A DATA n A S DADR W DATA n+5 A P DATA n+x A
TXCOMP
TXRDY
TWD
Write THR (Data n) Write THR (Data n+1) Write THR (Data n+x)
Last data sent
STOP sent automaticaly
(ACK received and TXRDY = 1)
355
6222HATARM25-Jan-12
SAM7SE512/256/32
When a single data byte read is performed, with or without internal address (IADR), the START
and STOP bits must be set at the same time. See Figure 32-9. When a multiple data byte read is
performed, with or without internal address (IADR), the STOP bit must be set after the next-to-
last data received. See Figure 32-10. For Internal Address usage see Section 32.7.6.
Figure 32-9. Master Read with One Data Byte
Figure 32-10. Master Read with Multiple Data Bytes
32.7.6 Internal Address
The TWI interface can perform various transfer formats: Transfers with 7-bit slave address
devices and 10-bit slave address devices.
32.7.6.1 7-bit Slave Addressing
When Addressing 7-bit slave devices, the internal address bytes are used to perform random
address (read or write) accesses to reach one or more data bytes, within a memory page loca-
tion in a serial memory, for example. When performing read operations with an internal address,
the TWI performs a write operation to set the internal address into the slave device, and then
switch to Master Receiver mode. Note that the second start condition (after sending the IADR) is
sometimes called repeated start (Sr) in I2C fully-compatible devices. See Figure 32-12. See
Figure 32-11 and Figure 32-13 for Master Write operation with internal address.
The three internal address bytes are configurable through the Master Mode register
(TWI_MMR).
If the slave device supports only a 7-bit address, i.e. no internal address, IADRSZ must be set to
0.
A S DADR R DATA N P
TXCOMP
Write START &
STOP Bit
RXRDY
Read RHR
TWD
N A S DADR R DATA n A A DATA (n+1) A DATA (n+m) DATA (n+m)-1 P TWD
TXCOMP
Write START Bit
RXRDY
Write STOP Bit
after next-to-last data read
Read RHR
DATA n
Read RHR
DATA (n+1)
Read RHR
DATA (n+m)-1
Read RHR
DATA (n+m)
356
6222HATARM25-Jan-12
SAM7SE512/256/32
In the figures below the following abbreviations are used:
Figure 32-11. Master Write with One, Two or Three Bytes Internal Address and One Data Byte
Figure 32-12. Master Read with One, Two or Three Bytes Internal Address and One Data Byte
32.7.6.2 10-bit Slave Addressing
For a slave address higher than 7 bits, the user must configure the address size (IADRSZ) and
set the other slave address bits in the internal address register (TWI_IADR). The two remaining
Internal address bytes, IADR[15:8] and IADR[23:16] can be used the same as in 7-bit Slave
Addressing.
Example: Address a 10-bit device (10-bit device address is b1 b2 b3 b4 b5 b6 b7 b8 b9 b10)
1. Program IADRSZ = 1,
2. Program DADR with 1 1 1 1 0 b1 b2 (b1 is the MSB of the 10-bit address, b2, etc.)
3. Program TWI_IADR with b3 b4 b5 b6 b7 b8 b9 b10 (b10 is the LSB of the 10-bit
address)
S
Start
Sr
Repeated Start
P
Stop
W
Write
R
Read
A
Acknowledge
N
Not Acknowledge
DADR
Device Address
IADR
Internal Address
S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A DATA A P
S DADR W A IADR(15:8) A IADR(7:0) A P DATA A
A IADR(7:0) A P DATA A S DADR W
TWD
Three bytes internal address
Two bytes internal address
One byte internal address
TWD
TWD
S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A
S DADR W A IADR(15:8) A IADR(7:0) A
A IADR(7:0) A S DADR W
DATA N P
Sr DADR R A
Sr DADR R A DATA N P
Sr DADR R A DATA N P
TWD
TWD
TWD
Three bytes internal address
Two bytes internal address
One byte internal address
357
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-13 below shows a byte write to an Atmel AT24LC512 EEPROM. This demonstrates
the use of internal addresses to access the device.
Figure 32-13. Internal Address Usage
S
T
A
R
T
M
S
B
Device
Address
0
L
S
B
R
/
W
A
C
K
M
S
B
W
R
I
T
E
A
C
K
A
C
K
L
S
B
A
C
K
FIRST
WORD ADDRESS
SECOND
WORD ADDRESS DATA
S
T
O
P
358
6222HATARM25-Jan-12
SAM7SE512/256/32
32.7.7 Read-write Flowcharts
The following flowcharts shown in Figure 32-14, Figure 32-15 on page 359, Figure 32-16 on
page 360, Figure 32-17 on page 361, Figure 32-18 on page 362 and Figure 32-19 on page 363
give examples for read and write operations. A polling or interrupt method can be used to check
the status bits. The interrupt method requires that the interrupt enable register (TWI_IER) be
configured first.
Figure 32-14. TWI Write Operation with Single Data Byte without Internal Address
Set TWI clock
(CLDIV, CHDIV, CKDIV) in TWI_CWGR
(Needed only once)
Set the Control register:
- Master enable
TWI_CR = MSEN + SVDIS
Set the Master Mode register:
- Device slave address (DADR)
- Transfer direction bit
Write ==> bit MREAD = 0
Load Transmit register
TWI_THR = Data to send
Read Status register
TXRDY = 1?
Read Status register
TXCOMP = 1?
Transfer finished
Yes
Yes
BEGIN
No
No
359
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-15. TWI Write Operation with Single Data Byte and Internal Address
BEGIN
Set TWI clock
(CLDIV, CHDIV, CKDIV) in TWI_CWGR
(Needed only once)
Set the Control register:
- Master enable
TWI_CR = MSEN + SVDIS
Set the Master Mode register:
- Device slave address (DADR)
- Internal address size (IADRSZ)
- Transfer direction bit
Write ==> bit MREAD = 0
Load transmit register
TWI_THR = Data to send
Read Status register
TXRDY = 1?
Read Status register
TXCOMP = 1?
Transfer finished
Set the internal address
TWI_IADR = address
Yes
Yes
No
No
360
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-16. TWI Write Operation with Multiple Data Bytes with or without Internal Address
Set the Control register:
- Master enable
TWI_CR = MSEN + SVDIS
Set the Master Mode register:
- Device slave address
- Internal address size (if IADR used)
- Transfer direction bit
Write ==> bit MREAD = 0
Internal address size = 0?
Load Transmit register
TWI_THR = Data to send
Read Status register
TXRDY = 1?
Data to send?
Read Status register
TXCOMP = 1?
END
BEGIN
Set the internal address
TWI_IADR = address
Yes
TWI_THR = data to send
Yes
Yes
Yes
No
No
No
Set TWI clock
(CLDIV, CHDIV, CKDIV) in TWI_CWGR
(Needed only once)
361
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-17. TWI Read Operation with Single Data Byte without Internal Address
Set the Control register:
- Master enable
TWI_CR = MSEN + SVDIS
Set the Master Mode register:
- Device slave address
- Internal address size (IADRSZ)
- Transfer direction bit
Read ==> bit MREAD = 1
Read Status register
TXCOMP = 1?
END
BEGIN
Yes
Set TWI clock
(CLDIV, CHDIV, CKDIV) in TWI_CWGR
(Needed only once)
Yes
Set the internal address
TWI_IADR = address
Start the transfer
TWI_CR = START | STOP
Read Status register
RXRDY = 1?
Read Receive Holding register
No
No
362
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-18. TWI Read Operation with Single Data Byte and Internal Address
Set the Control register:
- Master enable
TWI_CR = MSEN + SVDIS
Set the Master Mode register:
- Device slave address
- Internal address size (IADRSZ)
- Transfer direction bit
Read ==> bit MREAD = 1
Read Status register
TXCOMP = 1?
END
BEGIN
Yes
Set TWI clock
(CLDIV, CHDIV, CKDIV) in TWI_CWGR
(Needed only once)
Yes
Set the internal address
TWI_IADR = address
Start the transfer
TWI_CR = START | STOP
Read Status register
RXRDY = 1?
Read Receive Holding register
No
No
363
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-19. TWI Read Operation with Multiple Data Bytes with or without Internal Address
Internal address size = 0?
Start the transfer
TWI_CR = START
Stop the transfer
TWI_CR = STOP
Read Status register
RXRDY = 1?
Last data to read
but one?
Read status register
TXCOMP = 1?
END
Set the internal address
TWI_IADR = address
Yes
Yes
Yes
No
Yes
Read Receive Holding register (TWI_RHR)
No
Set the Control register:
- Master enable
TWI_CR = MSEN + SVDIS
Set the Master Mode register:
- Device slave address
- Internal address size (if IADR used)
- Transfer direction bit
Read ==> bit MREAD = 1
BEGIN
Set TWI clock
(CLDIV, CHDIV, CKDIV) in TWI_CWGR
(Needed only once)
No
Read Status register
RXRDY = 1?
Yes
Read Receive Holding register (TWI_RHR)
No
364
6222HATARM25-Jan-12
SAM7SE512/256/32
32.8 Multi-master Mode
32.8.1 Definition
More than one master may handle the bus at the same time without data corruption by using
arbitration.
Arbitration starts as soon as two or more masters place information on the bus at the same time,
and stops (arbitration is lost) for the master that intends to send a logical one while the other
master sends a logical zero.
As soon as arbitration is lost by a master, it stops sending data and listens to the bus in order to
detect a stop. When the stop is detected, the master who has lost arbitration may put its data on
the bus by respecting arbitration.
Arbitration is illustrated in Figure 32-21 on page 365.
32.8.2 Different Multi-master Modes
Two multi-master modes may be distinguished:
1. TWI is considered as a Master only and will never be addressed.
2. TWI may be either a Master or a Slave and may be addressed.
Note: In both Multi-master modes arbitration is supported.
32.8.2.1 TWI as Master Only
In this mode, TWI is considered as a Master only (MSEN is always at one) and must be driven
like a Master with the ARBLST (ARBitration Lost) flag in addition.
If arbitration is lost (ARBLST = 1), the programmer must reinitiate the data transfer.
If the user starts a transfer (ex.: DADR + START + W + Write in THR) and if the bus is busy, the
TWI automatically waits for a STOP condition on the bus to initiate the transfer (see Figure 32-
20 on page 365).
Note: The state of the bus (busy or free) is not indicated in the user interface.
32.8.2.2 TWI as Master or Slave
The automatic reversal from Master to Slave is not supported in case of a lost arbitration.
Then, in the case where TWI may be either a Master or a Slave, the programmer must manage
the pseudo Multi-master mode described in the steps below.
1. Program TWI in Slave mode (SADR + MSDIS + SVEN) and perform Slave Access (if
TWI is addressed).
2. If TWI has to be set in Master mode, wait until TXCOMP flag is at 1.
3. Program Master mode (DADR + SVDIS + MSEN) and start the transfer (ex: START +
Write in THR).
4. As soon as the Master mode is enabled, TWI scans the bus in order to detect if it is
busy or free. When the bus is considered as free, TWI initiates the transfer.
5. As soon as the transfer is initiated and until a STOP condition is sent, the arbitration
becomes relevant and the user must monitor the ARBLST flag.
6. If the arbitration is lost (ARBLST is set to 1), the user must program the TWI in Slave
mode in the case where the Master that won the arbitration wanted to access the TWI.
7. If TWI has to be set in Slave mode, wait until TXCOMP flag is at 1 and then program the
Slave mode.
365
6222HATARM25-Jan-12
SAM7SE512/256/32
Note: In the case where the arbitration is lost and TWI is addressed, TWI will not acknowledge even if it
is programmed in Slave mode as soon as ARBLST is set to 1. Then, the Master must repeat
SADR.
Figure 32-20. Programmer Sends Data While the Bus is Busy
Figure 32-21. Arbitration Cases
The flowchart shown in Figure 32-22 on page 366 gives an example of read and write operations
in Multi-master mode.
TWCK
TWD DATA sent by a master
STOP sent by the master START sent by the TWI
DATA sent by the TWI
Bus is busy
Bus is free
A transfer is programmed
(DADR + W + START + Write THR)
Transfer is initiated
TWI DATA transfer
Transfer is kept
Bus is considered as free
TWCK
Bus is busy Bus is free
A transfer is programmed
(DADR + W + START + Write THR)
Transfer is initiated
TWI DATA transfer
Transfer is kept
Bus is considered as free
Data from a Master
Data from TWI S 0
S 0 0
1
1
1
ARBLST
S 0
S 0 0
1
1
1
TWD S 0 0 1
1 1
1 1
Arbitration is lost
TWI stops sending data
P
S 0 1
P 0
1 1
1 1
Data from the master
Data from the TWI
Arbitration is lost
The master stops sending data
Transfer is stopped
Transfer is programmed again
(DADR + W + START + Write THR)
TWCK
TWD
366
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-22. Multi-master Flowchart
Programm the SLAVE mode:
SADR + MSDIS + SVEN
SVACC = 1 ?
TXCOMP = 1 ?
GACC = 1 ?
Decoding of the
programming sequence
Prog seq
OK ?
Change SADR
SVREAD = 0 ?
Read Status Register
RXRDY= 0 ?
Read TWI_RHR
TXRDY= 1 ? EOSACC = 1 ?
Write in TWI_THR
Need to perform
a master access ?
Program the Master mode
DADR + SVDIS + MSEN + CLK + R / W
Read Status Register
ARBLST = 1 ?
MREAD = 1 ?
TXRDY= 0 ?
Write in TWI_THR Data to send ?
RXRDY= 0 ?
Read TWI_RHR Data to read?
Stop transfer
Read Status Register
TXCOMP = 0 ?
GENERAL CALL TREATMENT
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
START
367
6222HATARM25-Jan-12
SAM7SE512/256/32
32.9 Slave Mode
32.9.1 Definition
The Slave Mode is defined as a mode where the device receives the clock and the address from
another device called the master.
In this mode, the device never initiates and never completes the transmission (START,
REPEATED_START and STOP conditions are always provided by the master).
32.9.2 Application Block Diagram
Figure 32-23. Slave Mode Typical Application Block Diagram
32.9.3 Programming Slave Mode
The following fields must be programmed before entering Slave mode:
1. SADR (TWI_SMR): The slave device address is used in order to be accessed by mas-
ter devices in read or write mode.
2. MSDIS (TWI_CR): Disable the master mode.
3. SVEN (TWI_CR): Enable the slave mode.
As the device receives the clock, values written in TWI_CWGR are not taken into account.
32.9.4 Receiving Data
After a Start or Repeated Start condition is detected and if the address sent by the Master
matches with the Slave address programmed in the SADR (Slave ADdress) field, SVACC (Slave
ACCess) flag is set and SVREAD (Slave READ) indicates the direction of the transfer.
SVACC remains high until a STOP condition or a repeated START is detected. When such a
condition is detected, EOSACC (End Of Slave ACCess) flag is set.
32.9.4.1 Read Sequence
In the case of a Read sequence (SVREAD is high), TWI transfers data written in the TWI_THR
(TWI Transmit Holding Register) until a STOP condition or a REPEATED_START + an address
different from SADR is detected. Note that at the end of the read sequence TXCOMP (Transmis-
sion Complete) flag is set and SVACC reset.
As soon as data is written in the TWI_THR, TXRDY (Transmit Holding Register Ready) flag is
reset, and it is set when the shift register is empty and the sent data acknowledged or not. If the
data is not acknowledged, the NACK flag is set.
Host with
TWI
Interface
TWD
TWCK
LCD Controller
Slave 1 Slave 2 Slave 3
R R
VDD
Host with TWI
Interface
Host with TWI
Interface
Master
368
6222HATARM25-Jan-12
SAM7SE512/256/32
Note that a STOP or a repeated START always follows a NACK.
See Figure 32-24 on page 369.
32.9.4.2 Write Sequence
In the case of a Write sequence (SVREAD is low), the RXRDY (Receive Holding Register
Ready) flag is set as soon as a character has been received in the TWI_RHR (TWI Receive
Holding Register). RXRDY is reset when reading the TWI_RHR.
TWI continues receiving data until a STOP condition or a REPEATED_START + an address dif-
ferent from SADR is detected. Note that at the end of the write sequence TXCOMP flag is set
and SVACC reset.
See Figure 32-25 on page 369.
32.9.4.3 Clock Synchronization Sequence
In the case where TWI_THR or TWI_RHR is not written/read in time, TWI performs a clock
synchronization.
Clock stretching information is given by the SCLWS (Clock Wait state) bit.
See Figure 32-27 on page 371 and Figure 32-28 on page 372.
32.9.4.4 General Call
In the case where a GENERAL CALL is performed, GACC (General Call ACCess) flag is set.
After GACC is set, it is up to the programmer to interpret the meaning of the GENERAL CALL
and to decode the new address programming sequence.
See Figure 32-26 on page 370.
32.9.5 Data Transfer
32.9.5.1 Read Operation
The read mode is defined as a data requirement from the master.
After a START or a REPEATED START condition is detected, the decoding of the address
starts. If the slave address (SADR) is decoded, SVACC is set and SVREAD indicates the direc-
tion of the transfer.
Until a STOP or REPEATED START condition is detected, TWI continues sending data loaded
in the TWI_THR register.
If a STOP condition or a REPEATED START + an address different from SADR is detected,
SVACC is reset.
Figure 32-24 on page 369 describes the write operation.
369
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 32-24. Read Access Ordered by a MASTER
Notes: 1. When SVACC is low, the state of SVREAD becomes irrelevant.
2. TXRDY is reset when data has been transmitted from TWI_THR to the shift register and set when this data has been
acknowledged or non acknowledged.
32.9.5.2 Write Operation
The write mode is defined as a data transmission from the master.
After a START or a REPEATED START, the decoding of the address starts. If the slave address
is decoded, SVACC is set and SVREAD indicates the direction of the transfer (SVREAD is low in
this case).
Until a STOP or REPEATED START condition is detected, TWI stores the received data in the
TWI_RHR register.
If a STOP condition or a REPEATED START + an address different from SADR is detected,
SVACC is reset.
Figure 32-25 on page 369 describes the Write operation.
Figure 32-25. Write Access Ordered by a Master
Notes: 1. When SVACC is low, the state of SVREAD becomes irrelevant.
2. RXRDY is set when data has been transmitted from the shift register to the TWI_RHR and reset when this data is read.
Write THR
Read RHR
SVREAD has to be taken into account only while SVACC is active
TWD
TXRDY
NACK
SVACC
SVREAD
EOSVACC
SADR S ADR R NA R A DATA A A DATA NA S/Sr DATA NA P/S/Sr
SADR matches,
TWI answers with an ACK
SADR does not match,
TWI answers with a NACK
ACK/NACK from the Master
RXRDY
Read RHR
SVREAD has to be taken into account only while SVACC is active
TWD
SVACC
SVREAD
EOSVACC
SADR does not match,
TWI answers with a NACK
SADR S ADR W NA W A DATA A A DATA NA S/Sr DATA NA P/S/Sr
SADR matches,
TWI answers with an ACK
370
6222HATARM25-Jan-12
SAM7SE512/256/32
32.9.5.3 General Call
The general call is performed in order to change the address of the slave.
If a GENERAL CALL is detected, GACC is set.
After the detection of General Call, it is up to the programmer to decode the commands which
come afterwards.
In case of a WRITE command, the programmer has to decode the programming sequence and
program a new SADR if the programming sequence matches.
Figure 32-26 on page 370 describes the General Call access.
Figure 32-26. Master Performs a General Call
Note: This method allows the user to create an own programming sequence by choosing the program-
ming bytes and the number of them. The programming sequence has to be provided to the
master.
0000000 +W
GENERAL CALL
P
S
A
GENERAL CALL Reset or write DADD
A New SADR
DATA1
A DATA2 A A
New SADR
Programming sequence
TXD
GCACC
SVACC
RESET command = 00000110X
WRITE command = 00000100X
Reset after read
371
6222HATARM25-Jan-12
SAM7SE512/256/32
32.9.5.4 Clock Synchronization
In both read and write modes, it may happen that TWI_THR/TWI_RHR buffer is not filled /emp-
tied before the emission/reception of a new character. In this case, to avoid sending/receiving
undesired data, a clock stretching mechanism is implemented.
Clock Synchronization in Read Mode
The clock is tied low if the shift register is empty and if a STOP or REPEATED START condition
was not detected. It is tied low until the shift register is loaded.
Figure 32-27 on page 371 describes the clock synchronization in Read mode.
Figure 32-27. Clock Synchronization in Read Mode
Notes: 1. TXRDY is reset when data has been written in the TWI_TH to the shift register and set when this data has been acknowl-
edged or non acknowledged.
2. At the end of the read sequence, TXCOMP is set after a STOP or after a REPEATED_START + an address different from
SADR.
3. SCLWS is automatically set when the clock synchronization mechanism is started.
DATA1
The clock is stretched after the ACK, the state of TWD is undefined during clock stretching
SCLWS
SVACC
SVREAD
TXRDY
TWCK
TWI_THR
TXCOMP
The data is memorized in TWI_THR until a new value is written
TWI_THR is transmitted to the shift register Ack or Nack from the master
DATA0 DATA0 DATA2
1
2
1
CLOCK is tied low by the TWI
as long as THR is empty
S SADR S R DATA0 A A DATA1 A DATA2 NA S
XXXXXXX
2
Write THR
As soon as a START is detected
372
6222HATARM25-Jan-12
SAM7SE512/256/32
Clock Synchronization in Write Mode
The cl ock i s t i ed l ow i f t he shi f t regi st er and t he TWI _RHR i s f ul l . I f a STOP or
REPEATED_START condition was not detected, it is tied low until TWI_RHR is read.
Figure 32-28 on page 372 describes the clock synchronization in Read mode.
Figure 32-28. Clock Synchronization in Write Mode
Notes: 1. At the end of the read sequence, TXCOMP is set after a STOP or after a REPEATED_START + an address different from
SADR.
2. SCLWS is automatically set when the clock synchronization mechanism is started and automatically reset when the mecha-
nism is finished.
Rd DATA0
Rd DATA1
Rd DATA2
SVACC
SVREAD
RXRDY
SCLWS
TXCOMP
DATA1 DATA2
SCL is stretched on the last bit of DATA1
As soon as a START is detected
TWCK
TWD
TWI_RHR
CLOCK is tied low by the TWI as long as RHR is full
DATA0 is not read in the RHR
ADR S SADR W A DATA0 A A DATA2 DATA1 S NA
373
6222HATARM25-Jan-12
SAM7SE512/256/32
32.9.5.5 Reversal after a Repeated Start
Reversal of Read to Write
The master initiates the communication by a read command and finishes it by a write command.
Figure 32-29 on page 373 describes the repeated start + reversal from Read to Write mode.
Figure 32-29. Repeated Start + Reversal from Read to Write Mode
1. TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
Reversal of Write to Read
The master initiates the communication by a write command and finishes it by a read com-
mand.Figure 32-30 on page 373 describes the repeated start + reversal from Write to Read
mode.
Figure 32-30. Repeated Start + Reversal from Write to Read Mode
Notes: 1. In this case, if TWI_THR has not been written at the end of the read command, the clock is automatically stretched before
the ACK.
2. TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
S SADR R A DATA0 A DATA1 SADR Sr NA W A DATA2 A DATA3 A P
Cleared after read
DATA0 DATA1
DATA2 DATA3
SVACC
SVREAD
TWD
TWI_THR
TWI_RHR
EOSACC
TXRDY
RXRDY
TXCOMP
As soon as a START is detected
S SADR W A DATA0 A DATA1 SADR Sr A R A DATA2 A DATA3 NA P
Cleared after read
DATA0
DATA2 DATA3
DATA1
TXCOMP
TXRDY
RXRDY
As soon as a START is detected
Read TWI_RHR
SVACC
SVREAD
TWD
TWI_RHR
TWI_THR
EOSACC
374
6222HATARM25-Jan-12
SAM7SE512/256/32
32.9.6 Read Write Flowcharts
The flowchart shown in Figure 32-31 on page 374 gives an example of read and write operations
in Slave mode. A polling or interrupt method can be used to check the status bits. The interrupt
method requires that the interrupt enable register (TWI_IER) be configured first.
Figure 32-31. Read Write Flowchart in Slave Mode
Set the SLAVE mode:
SADR +MSDIS +SVEN
SVACC =1 ?
TXCOMP =1 ?
GACC =1 ?
Decoding of the
programming sequence
Prog seq
OK ?
Change SADR
SVREAD =0 ?
Read Status Register
RXRDY=0 ?
Read TWI_RHR
TXRDY=1 ?
EOSACC =1 ?
Write in TWI_THR
END
GENERAL CALL TREATMENT
375
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10 Two-wire Interface (TWI) User Interface
Table 32-4. Register Mapping
Offset Register Name Access Reset
0x00 Control Register TWI_CR Write-only N / A
0x04 Master Mode Register TWI_MMR Read-write 0x00000000
0x08 Slave Mode Register TWI_SMR Read-write 0x00000000
0x0C Internal Address Register TWI_IADR Read-write 0x00000000
0x10 Clock Waveform Generator Register TWI_CWGR Read-write 0x00000000
0x20 Status Register TWI_SR Read-only 0x0000F009
0x24 Interrupt Enable Register TWI_IER Write-only N / A
0x28 Interrupt Disable Register TWI_IDR Write-only N / A
0x2C Interrupt Mask Register TWI_IMR Read-only 0x00000000
0x30 Receive Holding Register TWI_RHR Read-only 0x00000000
0x34 Transmit Holding Register TWI_THR Write-only 0x00000000
0x38 - 0xFC Reserved
376
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.1 TWI Control Register
Name: TWI_CR
Access: Write-only
Reset Value: 0x00000000
START: Send a START Condition
0 = No effect.
1 = A frame beginning with a START bit is transmitted according to the features defined in the mode register.
This action is necessary when the TWI peripheral wants to read data from a slave. When configured in Master Mode with a
write operation, a frame is sent as soon as the user writes a character in the Transmit Holding Register (TWI_THR).
STOP: Send a STOP Condition
0 = No effect.
1 = STOP Condition is sent just after completing the current byte transmission in master read mode.
In single data byte master read, the START and STOP must both be set.
In multiple data bytes master read, the STOP must be set after the last data received but one.
In master read mode, if a NACK bit is received, the STOP is automatically performed.
In multiple data write operation, when both THR and shift register are empty, a STOP condition is automatically
sent.
MSEN: TWI Master Mode Enabled
0 = No effect.
1 = If MSDIS = 0, the master mode is enabled.
Note: Switching from Slave to Master mode is only permitted when TXCOMP = 1.
MSDIS: TWI Master Mode Disabled
0 = No effect.
1 = The master mode is disabled, all pending data is transmitted. The shifter and holding characters (if it contains data) are
transmitted in case of write operation. In read operation, the character being transferred must be completely received
before disabling.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SWRST SVDIS SVEN MSDIS MSEN STOP START
377
6222HATARM25-Jan-12
SAM7SE512/256/32
SVEN: TWI Slave Mode Enabled
0 = No effect.
1 = If SVDIS = 0, the slave mode is enabled.
Note: Switching from Master to Slave mode is only permitted when TXCOMP = 1.
SVDIS: TWI Slave Mode Disabled
0 = No effect.
1 = The slave mode is disabled. The shifter and holding characters (if it contains data) are transmitted in case of read oper-
ation. In write operation, the character being transferred must be completely received before disabling.
SWRST: Software Reset
0 = No effect.
1 = Equivalent to a system reset.
378
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.2 TWI Master Mode Register
Name: TWI_MMR
Access: Read-write
Reset Value: 0x00000000
IADRSZ: Internal Device Address Size
MREAD: Master Read Direction
0 = Master write direction.
1 = Master read direction.
DADR: Device Address
The device address is used to access slave devices in read or write mode. Those bits are only used in Master mode.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
DADR
15 14 13 12 11 10 9 8
MREAD IADRSZ
7 6 5 4 3 2 1 0
IADRSZ[9:8]
0 0 No internal device address
0 1 One-byte internal device address
1 0 Two-byte internal device address
1 1 Three-byte internal device address
379
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.3 TWI Slave Mode Register
Name: TWI_SMR
Access: Read-write
Reset Value: 0x00000000
SADR: Slave Address
The slave device address is used in Slave mode in order to be accessed by master devices in read or write mode.
SADR must be programmed before enabling the Slave mode or after a general call. Writes at other times have no effect.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
SADR
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
380
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.4 TWI Internal Address Register
Name: TWI_IADR
Access: Read-write
Reset Value: 0x00000000
IADR: Internal Address
0, 1, 2 or 3 bytes depending on IADRSZ.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
IADR
15 14 13 12 11 10 9 8
IADR
7 6 5 4 3 2 1 0
IADR
381
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.5 TWI Clock Waveform Generator Register
Name: TWI_CWGR
Access: Read-write
Reset Value: 0x00000000
TWI_CWGR is only used in Master mode.
CLDIV: Clock Low Divider
The SCL low period is defined as follows:
CHDIV: Clock High Divider
The SCL high period is defined as follows:
CKDIV: Clock Divider
The CKDIV is used to increase both SCL high and low periods.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
CKDIV
15 14 13 12 11 10 9 8
CHDIV
7 6 5 4 3 2 1 0
CLDIV
T
low
CLDIV ( 2
CKDIV
( ) 4) + T
MCK
=
T
high
CHDIV ( 2
CKDIV
( ) 4) + T
MCK
=
382
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.6 TWI Status Register
Name: TWI_SR
Access: Read-only
Reset Value: 0x0000F009
TXCOMP: Transmission Completed (automatically set / reset)
TXCOMP used in Master mode:
0 = During the length of the current frame.
1 = When both holding and shifter registers are empty and STOP condition has been sent.
TXCOMP behavior in Master mode can be seen in Figure 32-8 on page 354 and in Figure 32-10 on page 355.
TXCOMP used in Slave mode:
0 = As soon as a Start is detected.
1 = After a Stop or a Repeated Start + an address different from SADR is detected.
TXCOMP behavior in Slave mode can be seen in Figure 32-27 on page 371, Figure 32-28 on page 372, Figure 32-29 on
page 373 and Figure 32-30 on page 373.
RXRDY: Receive Holding Register Ready (automatically set / reset)
0 = No character has been received since the last TWI_RHR read operation.
1 = A byte has been received in the TWI_RHR since the last read.
RXRDY behavior in Master mode can be seen in Figure 32-10 on page 355.
RXRDY behavior in Slave mode can be seen in Figure 32-25 on page 369, Figure 32-28 on page 372, Figure 32-29 on
page 373 and Figure 32-30 on page 373.
TXRDY: Transmit Holding Register Ready (automatically set / reset)
TXRDY used in Master mode:
0 = The transmit holding register has not been transferred into shift register. Set to 0 when writing into TWI_THR register.
1 = As soon as a data byte is transferred from TWI_THR to internal shifter or if a NACK error is detected, TXRDY is set at
the same time as TXCOMP and NACK. TXRDY is also set when MSEN is set (enable TWI).
TXRDY behavior in Master mode can be seen in Figure 32-8 on page 354.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
EOSACC SCLWS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC SVREAD TXRDY RXRDY TXCOMP
383
6222HATARM25-Jan-12
SAM7SE512/256/32
TXRDY used in Slave mode:
0 = As soon as data is written in the TWI_THR, until this data has been transmitted and acknowledged (ACK or NACK).
1 = It indicates that the TWI_THR is empty and that data has been transmitted and acknowledged.
If TXRDY is high and if a NACK has been detected, the transmission will be stopped. Thus when TRDY = NACK = 1, the
programmer must not fill TWI_THR to avoid losing it.
TXRDY behavior in Slave mode can be seen in Figure 32-24 on page 369, Figure 32-27 on page 371, Figure 32-29 on
page 373 and Figure 32-30 on page 373.
SVREAD: Slave Read (automatically set / reset)
This bit is only used in Slave mode. When SVACC is low (no Slave access has been detected) SVREAD is irrelevant.
0 = Indicates that a write access is performed by a Master.
1 = Indicates that a read access is performed by a Master.
SVREAD behavior can be seen in Figure 32-24 on page 369, Figure 32-25 on page 369, Figure 32-29 on page 373 and
Figure 32-30 on page 373.
SVACC: Slave Access (automatically set / reset)
This bit is only used in Slave mode.
0 = TWI is not addressed. SVACC is automatically cleared after a NACK or a STOP condition is detected.
1 = Indicates that the address decoding sequence has matched (A Master has sent SADR). SVACC remains high until a
NACK or a STOP condition is detected.
SVACC behavior can be seen in Figure 32-24 on page 369, Figure 32-25 on page 369, Figure 32-29 on page 373 and Fig-
ure 32-30 on page 373.
GACC: General Call Access (clear on read)
This bit is only used in Slave mode.
0 = No General Call has been detected.
1 = A General Call has been detected. After the detection of General Call, the programmer decoded the commands that fol-
low and the programming sequence.
GACC behavior can be seen in Figure 32-26 on page 370.
OVRE: Overrun Error (clear on read)
This bit is only used in Master mode.
0 = TWI_RHR has not been loaded while RXRDY was set
1 = TWI_RHR has been loaded while RXRDY was set. Reset by read in TWI_SR when TXCOMP is set.
NACK: Not Acknowledged (clear on read)
NACK used in Master mode:
0 = Each data byte has been correctly received by the far-end side TWI slave component.
1 = A data byte has not been acknowledged by the slave component. Set at the same time as TXCOMP.
384
6222HATARM25-Jan-12
SAM7SE512/256/32
NACK used in Slave Read mode:
0 = Each data byte has been correctly received by the Master.
1 = In read mode, a data byte has not been acknowledged by the Master. When NACK is set the programmer must not fill
TWI_THR even if TXRDY is set, because it means that the Master will stop the data transfer or re initiate it.
Note that in Slave Write mode all data is acknowledged by the TWI.
ARBLST: Arbitration Lost (clear on read)
This bit is only used in Master mode.
0: Arbitration won.
1: Arbitration lost. Another master of the TWI bus has won the multi-master arbitration. TXCOMP is set at the same time.
SCLWS: Clock Wait State (automatically set / reset)
This bit is only used in Slave mode.
0 = The clock is not stretched.
1 = The clock is stretched. TWI_THR / TWI_RHR buffer is not filled / emptied before the emission / reception of a new
character.
SCLWS behavior can be seen in Figure 32-27 on page 371 and Figure 32-28 on page 372.
EOSACC: End Of Slave Access (clear on read)
This bit is only used in Slave mode.
0 = A slave access is being performing.
1 = The Slave Access is finished. End Of Slave Access is automatically set as soon as SVACC is reset.
EOSACC behavior can be seen in Figure 32-29 on page 373 and Figure 32-30 on page 373
385
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.7 TWI Interrupt Enable Register
Name: TWI_IER
Access: Write-only
Reset Value: 0x00000000
TXCOMP: Transmission Completed Interrupt Enable
RXRDY: Receive Holding Register Ready Interrupt Enable
TXRDY: Transmit Holding Register Ready Interrupt Enable
SVACC: Slave Access Interrupt Enable
GACC: General Call Access Interrupt Enable
OVRE: Overrun Error Interrupt Enable
NACK: Not Acknowledge Interrupt Enable
ARBLST: Arbitration Lost Interrupt Enable
SCL_WS: Clock Wait State Interrupt Enable
EOSACC: End Of Slave Access Interrupt Enable
0 = No effect.
1 = Enables the corresponding interrupt.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
EOSACC SCL_WS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC TXRDY RXRDY TXCOMP
386
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.8 TWI Interrupt Disable Register
Name: TWI_IDR
Access: Write-only
Reset Value: 0x00000000
TXCOMP: Transmission Completed Interrupt Disable
RXRDY: Receive Holding Register Ready Interrupt Disable
TXRDY: Transmit Holding Register Ready Interrupt Disable
SVACC: Slave Access Interrupt Disable
GACC: General Call Access Interrupt Disable
OVRE: Overrun Error Interrupt Disable
NACK: Not Acknowledge Interrupt Disable
ARBLST: Arbitration Lost Interrupt Disable
SCL_WS: Clock Wait State Interrupt Disable
EOSACC: End Of Slave Access Interrupt Disable
0 = No effect.
1 = Disables the corresponding interrupt.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
EOSACC SCL_WS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC TXRDY RXRDY TXCOMP
387
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.9 TWI Interrupt Mask Register
Name: TWI_IMR
Access: Read-only
Reset Value: 0x00000000
TXCOMP: Transmission Completed Interrupt Mask
RXRDY: Receive Holding Register Ready Interrupt Mask
TXRDY: Transmit Holding Register Ready Interrupt Mask
SVACC: Slave Access Interrupt Mask
GACC: General Call Access Interrupt Mask
OVRE: Overrun Error Interrupt Mask
NACK: Not Acknowledge Interrupt Mask
ARBLST: Arbitration Lost Interrupt Mask
SCL_WS: Clock Wait State Interrupt Mask
EOSACC: End Of Slave Access Interrupt Mask
0 = The corresponding interrupt is disabled.
1 = The corresponding interrupt is enabled.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
EOSACC SCL_WS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC TXRDY RXRDY TXCOMP
388
6222HATARM25-Jan-12
SAM7SE512/256/32
32.10.10 TWI Receive Holding Register
Name: TWI_RHR
Access: Read-only
Reset Value: 0x00000000
RXDATA: Master or Slave Receive Holding Data
32.10.11 TWI Transmit Holding Register
Name: TWI_THR
Access: Read-write
Reset Value: 0x00000000
TXDATA: Master or Slave Transmit Holding Data
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RXDATA
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TXDATA
389
6222HATARM25-Jan-12
SAM7SE512/256/32
33. Universal Synchronous Asynchronous Receiver Transceiver (USART)
33.1 Overview
The Universal Synchronous Asynchronous Receiver Transceiver (USART) provides one full
duplex universal synchronous asynchronous serial link. Data frame format is widely programma-
ble (data length, parity, number of stop bits) to support a maximum of standards. The receiver
implements parity error, framing error and overrun error detection. The receiver time-out enables
handling variable-length frames and the transmitter timeguard facilitates communications with
slow remote devices. Multidrop communications are also supported through address bit han-
dling in reception and transmission.
The USART features three test modes: remote loopback, local loopback and automatic echo.
The USART supports specific operating modes providing interfaces on RS485 buses, with
ISO7816 T = 0 or T = 1 smart card slots, infrared transceivers and connection to modem ports.
The hardware handshaking feature enables an out-of-band flow control by automatic manage-
ment of the pins RTS and CTS.
The USART supports the connection to the Peripheral DMA Controller, which enables data
transfers to the transmitter and from the receiver. The PDC provides chained buffer manage-
ment without any intervention of the processor.
390
6222HATARM25-Jan-12
SAM7SE512/256/32
33.2 Block Diagram
Figure 33-1. USART Block Diagram
Peripheral DMA
Controller
Channel Channel
AIC
Receiver
USART
Interrupt
RXD
TXD
SCK
USART
PIO
Controller
CTS
RTS
DTR
DSR
DCD
RI
Transmitter
Modem
Signals
Control
Baud Rate
Generator
User Interface
PMC
MCK
SLCK
DIV
MCK/DIV
APB
391
6222HATARM25-Jan-12
SAM7SE512/256/32
33.3 Application Block Diagram
Figure 33-2. Application Block Diagram
33.4 I/O Lines Description
Table 33-1. I/O Line Description
Name Description Type Active Level
SCK Serial Clock I/O
TXD Transmit Serial Data I/O
RXD Receive Serial Data Input
RI Ring Indicator Input Low
DSR Data Set Ready Input Low
DCD Data Carrier Detect Input Low
DTR Data Terminal Ready Output Low
CTS Clear to Send Input Low
RTS Request to Send Output Low
Smart
Card
Slot
USART
RS232
Drivers
Modem
RS485
Drivers
Differential
Bus
IrDA
Transceivers
Modem
Driver
Field Bus
Driver
EMV
Driver
IrDA
Driver
IrLAP
RS232
Drivers
Serial
Port
Serial
Driver
PPP
PSTN
392
6222HATARM25-Jan-12
SAM7SE512/256/32
33.5 Product Dependencies
33.5.1 I/O Lines
The pins used for interfacing the USART may be multiplexed with the PIO lines. The program-
mer must first program the PIO controller to assign the desired USART pins to their peripheral
function. If I/O lines of the USART are not used by the application, they can be used for other
purposes by the PIO Controller.
To prevent the TXD line from falling when the USART is disabled, the use of an internal pull up
is mandatory.
All the pins of the modems may or may not be implemented on the USART. Only USART1 is
fully equipped with all the modem signals. On USARTs not equipped with the corresponding pin,
the associated control bits and statuses have no effect on the behavior of the USART.
33.5.2 Power Management
The USART is not continuously clocked. The programmer must first enable the USART Clock in
the Power Management Controller (PMC) before using the USART. However, if the application
does not require USART operations, the USART clock can be stopped when not needed and be
restarted later. In this case, the USART will resume its operations where it left off.
Configuring the USART does not require the USART clock to be enabled.
33.5.3 Interrupt
The USART interrupt line is connected on one of the internal sources of the Advanced Interrupt
Controller. Using the USART interrupt requires the AIC to be programmed first. Note that it is not
recommended to use the USART interrupt line in edge sensitive mode.
393
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6 Functional Description
The USART is capable of managing several types of serial synchronous or asynchronous
communications.
It supports the following communication modes:
5- to 9-bit full-duplex asynchronous serial communication
MSB- or LSB-first
1, 1.5 or 2 stop bits
Parity even, odd, marked, space or none
By 8 or by 16 over-sampling receiver frequency
Optional hardware handshaking
Optional modem signals management
Optional break management
Optional multidrop serial communication
High-speed 5- to 9-bit full-duplex synchronous serial communication
MSB- or LSB-first
1 or 2 stop bits
Parity even, odd, marked, space or none
By 8 or by 16 over-sampling frequency
Optional hardware handshaking
Optional modem signals management
Optional break management
Optional multidrop serial communication
RS485 with driver control signal
ISO7816, T0 or T1 protocols for interfacing with smart cards
NACK handling, error counter with repetition and iteration limit
InfraRed IrDA Modulation and Demodulation
Test modes
Remote loopback, local loopback, automatic echo
33.6.1 Baud Rate Generator
The Baud Rate Generator provides the bit period clock named the Baud Rate Clock to both the
receiver and the transmitter.
The Baud Rate Generator clock source can be selected by setting the USCLKS field in the Mode
Register (US_MR) between:
the Master Clock MCK
a division of the Master Clock, the divider being product dependent, but generally set to 8
the external clock, available on the SCK pin
The Baud Rate Generator is based upon a 16-bit divider, which is programmed with the CD field
of the Baud Rate Generator Register (US_BRGR). If CD is programmed at 0, the Baud Rate
Generator does not generate any clock. If CD is programmed at 1, the divider is bypassed and
becomes inactive.
394
6222HATARM25-Jan-12
SAM7SE512/256/32
If the external SCK clock is selected, the duration of the low and high levels of the signal pro-
vided on the SCK pin must be longer than a Master Clock (MCK) period. The frequency of the
signal provided on SCK must be at least 4.5 times lower than MCK.
Figure 33-3. Baud Rate Generator
33.6.1.1 Baud Rate in Asynchronous Mode
If the USART is programmed to operate in asynchronous mode, the selected clock is first
divided by CD, which is field programmed in the Baud Rate Generator Register (US_BRGR).
The resulting clock is provided to the receiver as a sampling clock and then divided by 16 or 8,
depending on the programming of the OVER bit in US_MR.
If OVER is set to 1, the receiver sampling is 8 times higher than the baud rate clock. If OVER is
cleared, the sampling is performed at 16 times the baud rate clock.
The following formula performs the calculation of the Baud Rate.
This gives a maximum baud rate of MCK divided by 8, assuming that MCK is the highest possi-
ble clock and that OVER is programmed at 1.
MCK/DIV
16-bit Counter
0
Baud Rate
Clock
CD
CD
Sampling
Divider
0
1
>1
Sampling
Clock
Reserved
MCK
SCK
USCLKS
OVER
SCK
SYNC
SYNC
USCLKS = 3
1
0
2
3
0
1
0
1
FIDI
Baudrate
SelectedClock
8 2 Over ( )CD ( )
-------------------------------------------- =
395
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.1.2 Baud Rate Calculation Example
Table 33-2 shows calculations of CD to obtain a baud rate at 38400 bauds for different source
clock frequencies. This table also shows the actual resulting baud rate and the error.
The baud rate is calculated with the following formula:
The baud rate error is calculated with the following formula. It is not recommended to work with
an error higher than 5%.
33.6.1.3 Fractional Baud Rate in Asynchronous Mode
The Baud Rate generator previously defined is subject to the following limitation: the output fre-
quency changes by only integer multiples of the reference frequency. An approach to this
problem is to integrate a fractional N clock generator that has a high resolution. The generator
architecture is modified to obtain Baud Rate changes by a fraction of the reference source clock.
This fractional part is programmed with the FP field in the Baud Rate Generator Register
Table 33-2. Baud Rate Example (OVER = 0)
Source Clock
Expected Baud
Rate Calculation Result CD Actual Baud Rate Error
MHz Bit/s Bit/s
3 686 400 38 400 6.00 6 38 400.00 0.00%
4 915 200 38 400 8.00 8 38 400.00 0.00%
5 000 000 38 400 8.14 8 39 062.50 1.70%
7 372 800 38 400 12.00 12 38 400.00 0.00%
8 000 000 38 400 13.02 13 38 461.54 0.16%
12 000 000 38 400 19.53 20 37 500.00 2.40%
12 288 000 38 400 20.00 20 38 400.00 0.00%
14 318 180 38 400 23.30 23 38 908.10 1.31%
14 745 600 38 400 24.00 24 38 400.00 0.00%
18 432 000 38 400 30.00 30 38 400.00 0.00%
24 000 000 38 400 39.06 39 38 461.54 0.16%
24 576 000 38 400 40.00 40 38 400.00 0.00%
25 000 000 38 400 40.69 40 38 109.76 0.76%
32 000 000 38 400 52.08 52 38 461.54 0.16%
32 768 000 38 400 53.33 53 38 641.51 0.63%
33 000 000 38 400 53.71 54 38 194.44 0.54%
40 000 000 38 400 65.10 65 38 461.54 0.16%
50 000 000 38 400 81.38 81 38 580.25 0.47%
60 000 000 38 400 97.66 98 38 265.31 0.35%
70 000 000 38 400 113.93 114 38 377.19 0.06%
BaudRate MCK CD 16 =
Error 1
ExpectedBaudRate
ActualBaudRate
-------------------------------------------------- -
=
396
6222HATARM25-Jan-12
SAM7SE512/256/32
(US_BRGR). If FP is not 0, the fractional part is activated. The resolution is one eighth of the
clock divider. This feature is only available when using USART normal mode. The fractional
Baud Rate is calculated using the following formula:
The modified architecture is presented below:
Figure 33-4. Fractional Baud Rate Generator
33.6.1.4 Baud Rate in Synchronous Mode
If the USART is programmed to operate in synchronous mode, the selected clock is simply
divided by the field CD in US_BRGR.
In synchronous mode, if the external clock is selected (USCLKS = 3), the clock is provided
directly by the signal on the USART SCK pin. No division is active. The value written in
US_BRGR has no effect. The external clock frequency must be at least 4.5 times lower than the
system clock.
When either the external clock SCK or the internal clock divided (MCK/DIV) is selected, the
value programmed in CD must be even if the user has to ensure a 50:50 mark/space ratio on the
SCK pin. If the internal clock MCK is selected, the Baud Rate Generator ensures a 50:50 duty
cycle on the SCK pin, even if the value programmed in CD is odd.
33.6.1.5 Baud Rate in ISO 7816 Mode
The ISO7816 specification defines the bit rate with the following formula:
Baudrate
SelectedClock
8 2 Over ( ) CD
FP
8
------- +
----------------------------------------------------------------- =
MCK/DIV
16-bit Counter
0
Baud Rate
Clock
CD
CD
Sampling
Divider
0
1
>1
Sampling
Clock
Reserved
MCK
SCK
USCLKS
OVER
SCK
SYNC
SYNC
USCLKS = 3
1
0
2
3
0
1
0
1
FIDI
glitch-free
logic
Modulus
Control
FP
FP
BaudRate
SelectedClock
CD
-------------------------------------- =
397
6222HATARM25-Jan-12
SAM7SE512/256/32
where:
B is the bit rate
Di is the bit-rate adjustment factor
Fi is the clock frequency division factor
f is the ISO7816 clock frequency (Hz)
Di is a binary value encoded on a 4-bit field, named DI, as represented in Table 33-3.
Fi is a binary value encoded on a 4-bit field, named FI, as represented in Table 33-4.
Table 33-5 shows the resulting Fi/Di Ratio, which is the ratio between the ISO7816 clock and the
baud rate clock.
If the USART is configured in ISO7816 Mode, the clock selected by the USCLKS field in the
Mode Register (US_MR) is first divided by the value programmed in the field CD in the Baud
Rate Generator Register (US_BRGR). The resulting clock can be provided to the SCK pin to
feed the smart card clock inputs. This means that the CLKO bit can be set in US_MR.
This clock is then divided by the value programmed in the FI_DI_RATIO field in the FI_DI_Ratio
register (US_FIDI). This is performed by the Sampling Divider, which performs a division by up
to 2047 in ISO7816 Mode. The non-integer values of the Fi/Di Ratio are not supported and the
user must program the FI_DI_RATIO field to a value as close as possible to the expected value.
The FI_DI_RATIO field resets to the value 0x174 (372 in decimal) and is the most common
divider between the ISO7816 clock and the bit rate (Fi = 372, Di = 1).
Figure 33-5 shows the relation between the Elementary Time Unit, corresponding to a bit time,
and the ISO 7816 clock.
B
Di
Fi
------ f =
Table 33-3. Binary and Decimal Values for Di
DI field 0001 0010 0011 0100 0101 0110 1000 1001
Di (decimal) 1 2 4 8 16 32 12 20
Table 33-4. Binary and Decimal Values for Fi
FI field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101
Fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048
Table 33-5. Possible Values for the Fi/Di Ratio
Fi/Di 372 558 774 1116 1488 1806 512 768 1024 1536 2048
1 372 558 744 1116 1488 1860 512 768 1024 1536 2048
2 186 279 372 558 744 930 256 384 512 768 1024
4 93 139.5 186 279 372 465 128 192 256 384 512
8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256
16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128
32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64
12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6
20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4
398
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-5. Elementary Time Unit (ETU)
33.6.2 Receiver and Transmitter Control
After reset, the receiver is disabled. The user must enable the receiver by setting the RXEN bit
in the Control Register (US_CR). However, the receiver registers can be programmed before the
receiver clock is enabled.
After reset, the transmitter is disabled. The user must enable it by setting the TXEN bit in the
Control Register (US_CR). However, the transmitter registers can be programmed before being
enabled.
The Receiver and the Transmitter can be enabled together or independently.
At any time, the software can perform a reset on the receiver or the transmitter of the USART by
setting the corresponding bit, RSTRX and RSTTX respectively, in the Control Register
(US_CR). The reset commands have the same effect as a hardware reset on the corresponding
logic. Regardless of what the receiver or the transmitter is performing, the communication is
immediately stopped.
The user can also independently disable the receiver or the transmitter by setting RXDIS and
TXDIS respectively in US_CR. If the receiver is disabled during a character reception, the
USART waits until the end of reception of the current character, then the reception is stopped. If
the transmitter is disabled while it is operating, the USART waits the end of transmission of both
the current character and character being stored in the Transmit Holding Register (US_THR). If
a timeguard is programmed, it is handled normally.
33.6.3 Synchronous and Asynchronous Modes
33.6.3.1 Transmitter Operations
The transmitter performs the same in both synchronous and asynchronous operating modes
(SYNC = 0 or SYNC = 1). One start bit, up to 9 data bits, one optional parity bit and up to two
stop bits are successively shifted out on the TXD pin at each falling edge of the programmed
serial clock.
The number of data bits is selected by the CHRL field and the MODE 9 bit in the Mode Register
(US_MR). Nine bits are selected by setting the MODE 9 bit regardless of the CHRL field. The
parity bit is set according to the PAR field in US_MR. The even, odd, space, marked or none
parity bit can be configured. The MSBF field in US_MR configures which data bit is sent first. If
written at 1, the most significant bit is sent first. At 0, the less significant bit is sent first. The num-
ber of stop bits is selected by the NBSTOP field in US_MR. The 1.5 stop bit is supported in
asynchronous mode only.
1 ETU
ISO7816 Clock
on SCK
ISO7816 I/O Line
on TXD
FI_DI_RATIO
ISO7816 Clock Cycles
399
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-6. Character Transmit
The characters are sent by writing in the Transmit Holding Register (US_THR). The transmitter
reports two status bits in the Channel Status Register (US_CSR): TXRDY (Transmitter Ready),
which indicates that US_THR is empty and TXEMPTY, which indicates that all the characters
written in US_THR have been processed. When the current character processing is completed,
the last character written in US_THR is transferred into the Shift Register of the transmitter and
US_THR becomes empty, thus TXRDY raises.
Both TXRDY and TXEMPTY bits are low since the transmitter is disabled. Writing a character in
US_THR while TXRDY is active has no effect and the written character is lost.
Figure 33-7. Transmitter Status
33.6.3.2 Asynchronous Receiver
If the USART is programmed in asynchronous operating mode (SYNC = 0), the receiver over-
samples the RXD input line. The oversampling is either 16 or 8 times the Baud Rate clock,
depending on the OVER bit in the Mode Register (US_MR).
The receiver samples the RXD line. If the line is sampled during one half of a bit time at 0, a start
bit is detected and data, parity and stop bits are successively sampled on the bit rate clock.
If the oversampling is 16, (OVER at 0), a start is detected at the eighth sample at 0. Then, data
bits, parity bit and stop bit are sampled on each 16 sampling clock cycle. If the oversampling is 8
(OVER at 1), a start bit is detected at the fourth sample at 0. Then, data bits, parity bit and stop
bit are sampled on each 8 sampling clock cycle.
The number of data bits, first bit sent and parity mode are selected by the same fields and bits
as the transmitter, i.e. respectively CHRL, MODE9, MSBF and PAR. For the synchronization
mechanism only, the number of stop bits has no effect on the receiver as it considers only one
stop bit, regardless of the field NBSTOP, so that resynchronization between the receiver and the
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Example: 8-bit, Parity Enabled One Stop
Baud Rate
Clock
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Start
Bit
Write
US_THR
D0 D1 D2 D3 D4 D5 D6 D7
Parity
Bit
Stop
Bit
TXRDY
TXEMPTY
400
6222HATARM25-Jan-12
SAM7SE512/256/32
transmitter can occur. Moreover, as soon as the stop bit is sampled, the receiver starts looking
for a new start bit so that resynchronization can also be accomplished when the transmitter is
operating with one stop bit.
Figure 33-8 and Figure 33-9 illustrate start detection and character reception when USART
operates in asynchronous mode.
Figure 33-8. Asynchronous Start Detection
Figure 33-9. Asynchronous Character Reception
33.6.3.3 Synchronous Receiver
In synchronous mode (SYNC = 1), the receiver samples the RXD signal on each rising edge of
the Baud Rate Clock. If a low level is detected, it is considered as a start. All data bits, the parity
bit and the stop bits are sampled and the receiver waits for the next start bit. Synchronous mode
operations provide a high speed transfer capability.
Configuration fields and bits are the same as in asynchronous mode.
Figure 33-10 illustrates a character reception in synchronous mode.
Sampling
Clock (x16)
RXD
Start
Detection
Sampling
Baud Rate
Clock
RXD
Start
Rejection
Sampling
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 0 1 2 3 4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
D0
Sampling
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Parity
Bit
Stop
Bit
Example: 8-bit, Parity Enabled
Baud Rate
Clock
Start
Detection
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
16
samples
401
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-10. Synchronous Mode Character Reception
33.6.3.4 Receiver Operations
When a character reception is completed, it is transferred to the Receive Holding Register
(US_RHR) and the RXRDY bit in the Status Register (US_CSR) rises. If a character is com-
pleted while the RXRDY is set, the OVRE (Overrun Error) bit is set. The last character is
transferred into US_RHR and overwrites the previous one. The OVRE bit is cleared by writing
the Control Register (US_CR) with the RSTSTA (Reset Status) bit at 1.
Figure 33-11. Receiver Status
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Sampling
Parity Bit
Stop Bit
Example: 8-bit, Parity Enabled 1 Stop
Baud Rate
Clock
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
US_CR
RXRDY
OVRE
D0 D1 D2 D3 D4 D5 D6 D7
Start
Bit
Parity
Bit
Stop
Bit
RSTSTA = 1
Read
US_RHR
402
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.3.5 Parity
The USART supports five parity modes selected by programming the PAR field in the Mode
Register (US_MR). The PAR field also enables the Multidrop mode, see Multidrop Mode on
page 403. Even and odd parity bit generation and error detection are supported.
If even parity is selected, the parity generator of the transmitter drives the parity bit at 0 if a num-
ber of 1s in the character data bit is even, and at 1 if the number of 1s is odd. Accordingly, the
receiver parity checker counts the number of received 1s and reports a parity error if the sam-
pled parity bit does not correspond. If odd parity is selected, the parity generator of the
transmitter drives the parity bit at 1 if a number of 1s in the character data bit is even, and at 0 if
the number of 1s is odd. Accordingly, the receiver parity checker counts the number of received
1s and reports a parity error if the sampled parity bit does not correspond. If the mark parity is
used, the parity generator of the transmitter drives the parity bit at 1 for all characters. The
receiver parity checker reports an error if the parity bit is sampled at 0. If the space parity is
used, the parity generator of the transmitter drives the parity bit at 0 for all characters. The
receiver parity checker reports an error if the parity bit is sampled at 1. If parity is disabled, the
transmitter does not generate any parity bit and the receiver does not report any parity error.
Table 33-6 shows an example of the parity bit for the character 0x41 (character ASCII A)
depending on the configuration of the USART. Because there are two bits at 1, 1 bit is added
when a parity is odd, or 0 is added when a parity is even.
When the receiver detects a parity error, it sets the PARE (Parity Error) bit in the Channel Status
Register (US_CSR). The PARE bit can be cleared by writing the Control Register (US_CR) with
the RSTSTA bit at 1. Figure 33-12 illustrates the parity bit status setting and clearing.
Table 33-6. Parity Bit Examples
Character Hexa Binary Parity Bit Parity Mode
A 0x41 0100 0001 1 Odd
A 0x41 0100 0001 0 Even
A 0x41 0100 0001 1 Mark
A 0x41 0100 0001 0 Space
A 0x41 0100 0001 None None
403
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-12. Parity Error
33.6.3.6 Multidrop Mode
If the PAR field in the Mode Register (US_MR) is programmed to the value 0x6 or 0x07, the
USART runs in Multidrop Mode. This mode differentiates the data characters and the address
characters. Data is transmitted with the parity bit at 0 and addresses are transmitted with the
parity bit at 1.
If the USART is configured in multidrop mode, the receiver sets the PARE parity error bit when
the parity bit is high and the transmitter is able to send a character with the parity bit high when
the Control Register is written with the SENDA bit at 1.
To handle parity error, the PARE bit is cleared when the Control Register is written with the bit
RSTSTA at 1.
The transmitter sends an address byte (parity bit set) when SENDA is written to US_CR. In this
case, the next byte written to US_THR is transmitted as an address. Any character written in
US_THR without having written the command SENDA is transmitted normally with the parity at
0.
33.6.3.7 Transmitter Timeguard
The timeguard feature enables the USART interface with slow remote devices.
The timeguard function enables the transmitter to insert an idle state on the TXD line between
two characters. This idle state actually acts as a long stop bit.
The duration of the idle state is programmed in the TG field of the Transmitter Timeguard Regis-
ter (US_TTGR). When this field is programmed at zero no timeguard is generated. Otherwise,
the transmitter holds a high level on TXD after each transmitted byte during the number of bit
periods programmed in TG in addition to the number of stop bits.
As illustrated in Figure 33-13, the behavior of TXRDY and TXEMPTY status bits is modified by
the programming of a timeguard. TXRDY rises only when the start bit of the next character is
sent, and thus remains at 0 during the timeguard transmission if a character has been written in
US_THR. TXEMPTY remains low until the timeguard transmission is completed as the time-
guard is part of the current character being transmitted.
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Bit
Bad
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
US_CR
PARE
RXRDY
RSTSTA = 1
404
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-13. Timeguard Operations
Table 33-7 indicates the maximum length of a timeguard period that the transmitter can handle
in relation to the function of the Baud Rate.
33.6.3.8 Receiver Time-out
The Receiver Time-out provides support in handling variable-length frames. This feature detects
an idle condition on the RXD line. When a time-out is detected, the bit TIMEOUT in the Channel
Status Register (US_CSR) rises and can generate an interrupt, thus indicating to the driver an
end of frame.
The time-out delay period (during which the receiver waits for a new character) is programmed
in the TO field of the Receiver Time-out Register (US_RTOR). If the TO field is programmed at
0, the Receiver Time-out is disabled and no time-out is detected. The TIMEOUT bit in US_CSR
remains at 0. Otherwise, the receiver loads a 16-bit counter with the value programmed in TO.
This counter is decremented at each bit period and reloaded each time a new character is
received. If the counter reaches 0, the TIMEOUT bit in the Status Register rises. Then, the user
can either:
Stop the counter clock until a new character is received. This is performed by writing the
Control Register (US_CR) with the STTTO (Start Time-out) bit at 1. In this case, the idle state
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Start
Bit
TG = 4
Write
US_THR
D0 D1 D2 D3 D4 D5 D6 D7
Parity
Bit
Stop
Bit
TXRDY
TXEMPTY
TG = 4
Table 33-7. Maximum Timeguard Length Depending on Baud Rate
Baud Rate Bit time Timeguard
Bit/sec s ms
1 200 833 212.50
9 600 104 26.56
14400 69.4 17.71
19200 52.1 13.28
28800 34.7 8.85
33400 29.9 7.63
56000 17.9 4.55
57600 17.4 4.43
115200 8.7 2.21
405
6222HATARM25-Jan-12
SAM7SE512/256/32
on RXD before a new character is received will not provide a time-out. This prevents having
to handle an interrupt before a character is received and allows waiting for the next idle state
on RXD after a frame is received.
Obtain an interrupt while no character is received. This is performed by writing US_CR with
the RETTO (Reload and Start Time-out) bit at 1. If RETTO is performed, the counter starts
counting down immediately from the value TO. This enables generation of a periodic interrupt
so that a user time-out can be handled, for example when no key is pressed on a keyboard.
If STTTO is performed, the counter clock is stopped until a first character is received. The idle
state on RXD before the start of the frame does not provide a time-out. This prevents having to
obtain a periodic interrupt and enables a wait of the end of frame when the idle state on RXD is
detected.
If RETTO is performed, the counter starts counting down immediately from the value TO. This
enables generation of a periodic interrupt so that a user time-out can be handled, for example
when no key is pressed on a keyboard.
Figure 33-14 shows the block diagram of the Receiver Time-out feature.
Figure 33-14. Receiver Time-out Block Diagram
Table 33-8 gives the maximum time-out period for some standard baud rates.
Table 33-8. Maximum Time-out Period
Baud Rate Bit Time Time-out
bit/sec s ms
600 1 667 109 225
1 200 833 54 613
2 400 417 27 306
4 800 208 13 653
9 600 104 6 827
14400 69 4 551
19200 52 3 413
28800 35 2 276
33400 30 1 962
16-bit Time-out
Counter
0
TO
TIMEOUT
Baud Rate
Clock
=
Character
Received
RETTO
Load
Clock
16-bit
Value
STTTO
D Q
1
Clear
406
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.3.9 Framing Error
The receiver is capable of detecting framing errors. A framing error happens when the stop bit of
a received character is detected at level 0. This can occur if the receiver and the transmitter are
fully desynchronized.
A framing error is reported on the FRAME bit of the Channel Status Register (US_CSR). The
FRAME bit is asserted in the middle of the stop bit as soon as the framing error is detected. It is
cleared by writing the Control Register (US_CR) with the RSTSTA bit at 1.
Figure 33-15. Framing Error Status
33.6.3.10 Transmit Break
The user can request the transmitter to generate a break condition on the TXD line. A break con-
dition drives the TXD line low during at least one complete character. It appears the same as a
0x00 character sent with the parity and the stop bits at 0. However, the transmitter holds the
TXD line at least during one character until the user requests the break condition to be removed.
A break is transmitted by writing the Control Register (US_CR) with the STTBRK bit at 1. This
can be performed at any time, either while the transmitter is empty (no character in either the
Shift Register or in US_THR) or when a character is being transmitted. If a break is requested
while a character is being shifted out, the character is first completed before the TXD line is held
low.
Once STTBRK command is requested further STTBRK commands are ignored until the end of
the break is completed.
The break condition is removed by writing US_CR with the STPBRK bit at 1. If the STPBRK is
requested before the end of the minimum break duration (one character, including start, data,
parity and stop bits), the transmitter ensures that the break condition completes.
56000 18 1 170
57600 17 1 138
200000 5 328
Table 33-8. Maximum Time-out Period (Continued)
Baud Rate Bit Time Time-out
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
US_CR
FRAME
RXRDY
RSTSTA = 1
407
6222HATARM25-Jan-12
SAM7SE512/256/32
The transmitter considers the break as though it is a character, i.e. the STTBRK and STPBRK
commands are taken into account only if the TXRDY bit in US_CSR is at 1 and the start of the
break condition clears the TXRDY and TXEMPTY bits as if a character is processed.
Writing US_CR with the both STTBRK and STPBRK bits at 1 can lead to an unpredictable
result. All STPBRK commands requested without a previous STTBRK command are ignored. A
byte written into the Transmit Holding Register while a break is pending, but not started, is
ignored.
After the break condition, the transmitter returns the TXD line to 1 for a minimum of 12 bit times.
Thus, the transmitter ensures that the remote receiver detects correctly the end of break and the
start of the next character. If the timeguard is programmed with a value higher than 12, the TXD
line is held high for the timeguard period.
After holding the TXD line for this period, the transmitter resumes normal operations.
Figure 33-16 illustrates the effect of both the Start Break (STTBRK) and Stop Break (STPBRK)
commands on the TXD line.
Figure 33-16. Break Transmission
33.6.3.11 Receive Break
The receiver detects a break condition when all data, parity and stop bits are low. This corre-
sponds to detecting a framing error with data at 0x00, but FRAME remains low.
When the low stop bit is detected, the receiver asserts the RXBRK bit in US_CSR. This bit may
be cleared by writing the Control Register (US_CR) with the bit RSTSTA at 1.
An end of receive break is detected by a high level for at least 2/16 of a bit period in asynchro-
nous operating mode or one sample at high level in synchronous operating mode. The end of
break detection also asserts the RXBRK bit.
33.6.3.12 Hardware Handshaking
The USART features a hardware handshaking out-of-band flow control. The RTS and CTS pins
are used to connect with the remote device, as shown in Figure 33-17.
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
Write
US_CR
TXRDY
TXEMPTY
STPBRK = 1
STTBRK = 1
Break Transmission End of Break
408
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-17. Connection with a Remote Device for Hardware Handshaking
Setting the USART to operate with hardware handshaking is performed by writing the
USART_MODE field in the Mode Register (US_MR) to the value 0x2.
The USART behavior when hardware handshaking is enabled is the same as the behavior in
standard synchronous or asynchronous mode, except that the receiver drives the RTS pin as
described below and the level on the CTS pin modifies the behavior of the transmitter as
described below. Using this mode requires using the PDC channel for reception. The transmitter
can handle hardware handshaking in any case.
Figure 33-18 shows how the receiver operates if hardware handshaking is enabled. The RTS
pin is driven high if the receiver is disabled and if the status RXBUFF (Receive Buffer Full) com-
ing from the PDC channel is high. Normally, the remote device does not start transmitting while
its CTS pin (driven by RTS) is high. As soon as the Receiver is enabled, the RTS falls, indicating
to the remote device that it can start transmitting. Defining a new buffer to the PDC clears the
status bit RXBUFF and, as a result, asserts the pin RTS low.
Figure 33-18. Receiver Behavior when Operating with Hardware Handshaking
Figure 33-19 shows how the transmitter operates if hardware handshaking is enabled. The CTS
pin disables the transmitter. If a character is being processing, the transmitter is disabled only
after the completion of the current character and transmission of the next character happens as
soon as the pin CTS falls.
Figure 33-19. Transmitter Behavior when Operating with Hardware Handshaking
USART
TXD
CTS
Remote
Device
RXD
TXD RXD
RTS
RTS
CTS
RTS
RXBUFF
Write
US_CR
RXEN = 1
RXD
RXDIS = 1
CTS
TXD
409
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.4 ISO7816 Mode
The USART features an ISO7816-compatible operating mode. This mode permits interfacing
with smart cards and Security Access Modules (SAM) communicating through an ISO7816 link.
Both T = 0 and T = 1 protocols defined by the ISO7816 specification are supported.
Setting the USART in ISO7816 mode is performed by writing the USART_MODE field in the
Mode Register (US_MR) to the value 0x4 for protocol T = 0 and to the value 0x5 for protocol T =
1.
33.6.4.1 ISO7816 Mode Overview
The ISO7816 is a half duplex communication on only one bidirectional line. The baud rate is
determined by a division of the clock provided to the remote device (see Baud Rate Generator
on page 393).
The USART connects to a smart card as shown in Figure 33-20. The TXD line becomes bidirec-
tional and the Baud Rate Generator feeds the ISO7816 clock on the SCK pin. As the TXD pin
becomes bidirectional, its output remains driven by the output of the transmitter but only when
the transmitter is active while its input is directed to the input of the receiver. The USART is con-
sidered as the master of the communication as it generates the clock.
Figure 33-20. Connection of a Smart Card to the USART
When operating in ISO7816, either in T = 0 or T = 1 modes, the character format is fixed. The
configuration is 8 data bits, even parity and 1 or 2 stop bits, regardless of the values pro-
grammed in the CHRL, MODE9, PAR and CHMODE fields. MSBF can be used to transmit LSB
or MSB first. Parity Bit (PAR) can be used to transmit in normal or inverse mode. Refer to
USART Mode Register on page 421 and PAR: Parity Type on page 422.
The USART cannot operate concurrently in both receiver and transmitter modes as the commu-
nication is unidirectional at a time. It has to be configured according to the required mode by
enabling or disabling either the receiver or the transmitter as desired. Enabling both the receiver
and the transmitter at the same time in ISO7816 mode may lead to unpredictable results.
The ISO7816 specification defines an inverse transmission format. Data bits of the character
must be transmitted on the I/O line at their negative value. The USART does not support this for-
mat and the user has to perform an exclusive OR on the data before writing it in the Transmit
Holding Register (US_THR) or after reading it in the Receive Holding Register (US_RHR).
33.6.4.2 Protocol T = 0
In T = 0 protocol, a character is made up of one start bit, eight data bits, one parity bit and one
guard time, which lasts two bit times. The transmitter shifts out the bits and does not drive the
I/O line during the guard time.
If no parity error is detected, the I/O line remains at 1 during the guard time and the transmitter
can continue with the transmission of the next character, as shown in Figure 33-21.
Smart
Card
SCK
CLK
TXD
I/O
USART
410
6222HATARM25-Jan-12
SAM7SE512/256/32
If a parity error is detected by the receiver, it drives the I/O line at 0 during the guard time, as
shown in Figure 33-22. This error bit is also named NACK, for Non Acknowledge. In this case,
the character lasts 1 bit time more, as the guard time length is the same and is added to the
error bit time which lasts 1 bit time.
When the USART is the receiver and it detects an error, it does not load the erroneous character
in the Receive Holding Register (US_RHR). It appropriately sets the PARE bit in the Status Reg-
ister (US_SR) so that the software can handle the error.
Figure 33-21. T = 0 Protocol without Parity Error
Figure 33-22. T = 0 Protocol with Parity Error
33.6.4.3 Receive Error Counter
The USART receiver also records the total number of errors. This can be read in the Number of
Error (US_NER) register. The NB_ERRORS field can record up to 255 errors. Reading US_NER
automatically clears the NB_ERRORS field.
33.6.4.4 Receive NACK Inhibit
The USART can also be configured to inhibit an error. This can be achieved by setting the
INACK bit in the Mode Register (US_MR). If INACK is at 1, no error signal is driven on the I/O
line even if a parity bit is detected, but the INACK bit is set in the Status Register (US_SR). The
INACK bit can be cleared by writing the Control Register (US_CR) with the RSTNACK bit at 1.
Moreover, if INACK is set, the erroneous received character is stored in the Receive Holding
Register, as if no error occurred. However, the RXRDY bit does not raise.
33.6.4.5 Transmit Character Repetition
When the USART is transmitting a character and gets a NACK, it can automatically repeat the
charact er bef ore movi ng on t o t he next one. Repet i t i on i s enabl ed by wri t i ng t he
MAX_ITERATION field in the Mode Register (US_MR) at a value higher than 0. Each character
can be transmitted up to eight times; the first transmission plus seven repetitions.
If MAX_ITERATION does not equal zero, the USART repeats the character as many times as
the value loaded in MAX_ITERATION.
D0 D1 D2 D3 D4 D5 D6 D7
RXD
Parity
Bit
Baud Rate
Clock
Start
Bit
Guard
Time 1
Next
Start
Bit
Guard
Time 2
D0 D1 D2 D3 D4 D5 D6 D7
I/O
Parity
Bit
Baud Rate
Clock
Start
Bit
Guard
Time 1
Start
Bit
Guard
Time 2
D0 D1
Error
Repetition
411
6222HATARM25-Jan-12
SAM7SE512/256/32
When the USART repetition number reaches MAX_ITERATION, the ITERATION bit is set in the
Channel Status Register (US_CSR). If the repetition of the character is acknowledged by the
receiver, the repetitions are stopped and the iteration counter is cleared.
The ITERATION bit in US_CSR can be cleared by writing the Control Register with the RSIT bit
at 1.
33.6.4.6 Disable Successive Receive NACK
The receiver can limit the number of successive NACKs sent back to the remote transmitter.
This is programmed by setting the bit DSNACK in the Mode Register (US_MR). The maximum
number of NACK transmitted is programmed in the MAX_ITERATION field. As soon as
MAX_ITERATION is reached, the character is considered as correct, an acknowledge is sent on
the line and the ITERATION bit in the Channel Status Register is set.
33.6.4.7 Protocol T = 1
When operating in ISO7816 protocol T = 1, the transmission is similar to an asynchronous for-
mat with only one stop bit. The parity is generated when transmitting and checked when
receiving. Parity error detection sets the PARE bit in the Channel Status Register (US_CSR).
33.6.5 IrDA Mode
The USART features an IrDA mode supplying half-duplex point-to-point wireless communica-
tion. It embeds the modulator and demodulator which allows a glueless connection to the
infrared transceivers, as shown in Figure 33-23. The modulator and demodulator are compliant
with the IrDA specification version 1.1 and support data transfer speeds ranging from 2.4 Kb/s to
115.2 Kb/s.
The USART IrDA mode is enabled by setting the USART_MODE field in the Mode Register
(US_MR) to the value 0x8. The IrDA Filter Register (US_IF) allows configuring the demodulator
filter. The USART transmitter and receiver operate in a normal asynchronous mode and all
parameters are accessible. Note that the modulator and the demodulator are activated.
Figure 33-23. Connection to IrDA Transceivers
The receiver and the transmitter must be enabled or disabled according to the direction of the
transmission to be managed.
IrDA
Transceivers
RXD RX
TXD
TX
USART
Demodulator
Modulator
Receiver
Transmitter
412
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.5.1 IrDA Modulation
For baud rates up to and including 115.2 Kbits/sec, the RZI modulation scheme is used. 0 is
represented by a light pulse of 3/16th of a bit time. Some examples of signal pulse duration are
shown in Table 33-9.
Figure 33-24 shows an example of character transmission.
Figure 33-24. IrDA Modulation
33.6.5.2 IrDA Baud Rate
Table 33-10 gives some examples of CD values, baud rate error and pulse duration. Note that
the requirement on the maximum acceptable error of 1.87% must be met.
Table 33-9. IrDA Pulse Duration
Baud Rate Pulse Duration (3/16)
2.4 Kb/s 78.13 s
9.6 Kb/s 19.53 s
19.2 Kb/s 9.77 s
38.4 Kb/s 4.88 s
57.6 Kb/s 3.26 s
115.2 Kb/s 1.63 s
Bit Period Bit Period
3
16
Start
Bit
Data Bits Stop
Bit
0 0 0 0
0 1 1 1 1
1
Transmitter
Output
TXD
Table 33-10. IrDA Baud Rate Error
Peripheral Clock Baud Rate CD Baud Rate Error Pulse Time
3 686 400 115 200 2 0.00% 1.63
20 000 000 115 200 11 1.38% 1.63
32 768 000 115 200 18 1.25% 1.63
40 000 000 115 200 22 1.38% 1.63
3 686 400 57 600 4 0.00% 3.26
20 000 000 57 600 22 1.38% 3.26
32 768 000 57 600 36 1.25% 3.26
40 000 000 57 600 43 0.93% 3.26
3 686 400 38 400 6 0.00% 4.88
20 000 000 38 400 33 1.38% 4.88
413
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.5.3 IrDA Demodulator
The demodulator is based on the IrDA Receive filter comprised of an 8-bit down counter which is
loaded with the value programmed in US_IF. When a falling edge is detected on the RXD pin,
the Filter Counter starts counting down at the Master Clock (MCK) speed. If a rising edge is
detected on the RXD pin, the counter stops and is reloaded with US_IF. If no rising edge is
detected when the counter reaches 0, the input of the receiver is driven low during one bit time.
Figure 33-25 illustrates the operations of the IrDA demodulator.
Figure 33-25. IrDA Demodulator Operations
As the IrDA mode uses the same logic as the ISO7816, note that the FI_DI_RATIO field in
US_FIDI must be set to a value higher than 0 in order to assure IrDA communications operate
correctly.
32 768 000 38 400 53 0.63% 4.88
40 000 000 38 400 65 0.16% 4.88
3 686 400 19 200 12 0.00% 9.77
20 000 000 19 200 65 0.16% 9.77
32 768 000 19 200 107 0.31% 9.77
40 000 000 19 200 130 0.16% 9.77
3 686 400 9 600 24 0.00% 19.53
20 000 000 9 600 130 0.16% 19.53
32 768 000 9 600 213 0.16% 19.53
40 000 000 9 600 260 0.16% 19.53
3 686 400 2 400 96 0.00% 78.13
20 000 000 2 400 521 0.03% 78.13
32 768 000 2 400 853 0.04% 78.13
Table 33-10. IrDA Baud Rate Error (Continued)
Peripheral Clock Baud Rate CD Baud Rate Error Pulse Time
MCK
RXD
Receiver
Input
Pulse
Rejected
6 5 4 3 2 6 1 6 5 4 3 2 0
Pulse
Accepted
Counter
Value
414
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.6 RS485 Mode
The USART features the RS485 mode to enable line driver control. While operating in RS485
mode, the USART behaves as though in asynchronous or synchronous mode and configuration
of all the parameters is possible. The difference is that the RTS pin is driven high when the
transmitter is operating. The behavior of the RTS pin is controlled by the TXEMPTY bit. A typical
connection of the USART to a RS485 bus is shown in Figure 33-26.
Figure 33-26. Typical Connection to a RS485 Bus
The USART is set in RS485 mode by programming the USART_MODE field in the Mode Regis-
ter (US_MR) to the value 0x1.
The RTS pin is at a level inverse to the TXEMPTY bit. Significantly, the RTS pin remains high
when a timeguard is programmed so that the line can remain driven after the last character com-
pletion. Figure 33-27 gives an example of the RTS waveform during a character transmission
when the timeguard is enabled.
Figure 33-27. Example of RTS Drive with Timeguard
USART
RTS
TXD
RXD
Differential
Bus
D0 D1 D2 D3 D4 D5 D6 D7
TXD
Start
Bit
Parity
Bit
Stop
Bit
Baud Rate
Clock
TG = 4
Write
US_THR
TXRDY
TXEMPTY
RTS
415
6222HATARM25-Jan-12
SAM7SE512/256/32
33.6.7 Modem Mode
The USART features modem mode, which enables control of the signals: DTR (Data Terminal
Ready), DSR (Data Set Ready), RTS (Request to Send), CTS (Clear to Send), DCD (Data Car-
rier Detect) and RI (Ring Indicator). While operating in modem mode, the USART behaves as a
DTE (Data Terminal Equipment) as it drives DTR and RTS and can detect level change on DSR,
DCD, CTS and RI.
Setting the USART in modem mode is performed by writing the USART_MODE field in the Mode
Register (US_MR) to the value 0x3. While operating in modem mode the USART behaves as
though in asynchronous mode and all the parameter configurations are available.
Table 33-11 gives the correspondence of the USART signals with modem connection standards.
The control of the DTR output pin is performed by writing the Control Register (US_CR) with the
DTRDIS and DTREN bits respectively at 1. The disable command forces the corresponding pin
to its inactive level, i.e. high. The enable command forces the corresponding pin to its active
level, i.e. low. RTS output pin is automatically controlled in this mode
The level changes are detected on the RI, DSR, DCD and CTS pins. If an input change is
detected, the RIIC, DSRIC, DCDIC and CTSIC bits in the Channel Status Register (US_CSR)
are set respectively and can trigger an interrupt. The status is automatically cleared when
US_CSR is read. Furthermore, the CTS automatically disables the transmitter when it is
detected at its inactive state. If a character is being transmitted when the CTS rises, the charac-
ter transmission is completed before the transmitter is actually disabled.
33.6.8 Test Modes
The USART can be programmed to operate in three different test modes. The internal loopback
capability allows on-board diagnostics. In the loopback mode the USART interface pins are dis-
connected or not and reconfigured for loopback internally or externally.
33.6.8.1 Normal Mode
Normal mode connects the RXD pin on the receiver input and the transmitter output on the TXD
pin.
Table 33-11. Circuit References
USART Pin V24 CCITT Direction
TXD 2 103 From terminal to modem
RTS 4 105 From terminal to modem
DTR 20 108.2 From terminal to modem
RXD 3 104 From modem to terminal
CTS 5 106 From terminal to modem
DSR 6 107 From terminal to modem
DCD 8 109 From terminal to modem
RI 22 125 From terminal to modem
416
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-28. Normal Mode Configuration
33.6.8.2 Automatic Echo Mode
Automatic echo mode allows bit-by-bit retransmission. When a bit is received on the RXD pin, it
is sent to the TXD pin, as shown in Figure 33-29. Programming the transmitter has no effect on
the TXD pin. The RXD pin is still connected to the receiver input, thus the receiver remains
active.
Figure 33-29. Automatic Echo Mode Configuration
33.6.8.3 Local Loopback Mode
Local loopback mode connects the output of the transmitter directly to the input of the receiver,
as shown in Figure 33-30. The TXD and RXD pins are not used. The RXD pin has no effect on
the receiver and the TXD pin is continuously driven high, as in idle state.
Figure 33-30. Local Loopback Mode Configuration
33.6.8.4 Remote Loopback Mode
Remote loopback mode directly connects the RXD pin to the TXD pin, as shown in Figure 33-31.
The transmitter and the receiver are disabled and have no effect. This mode allows bit-by-bit
retransmission.
Receiver
Transmitter
RXD
TXD
Receiver
Transmitter
RXD
TXD
Receiver
Transmitter
RXD
TXD
1
417
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 33-31. Remote Loopback Mode Configuration
Receiver
Transmitter
RXD
TXD
1
418
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7 USART User Interface
Table 33-12. USART Memory Map
Offset Register Name Access Reset State
0x0000 Control Register US_CR Write-only
0x0004 Mode Register US_MR Read/Write
0x0008 Interrupt Enable Register US_IER Write-only
0x000C Interrupt Disable Register US_IDR Write-only
0x0010 Interrupt Mask Register US_IMR Read-only 0x0
0x0014 Channel Status Register US_CSR Read-only
0x0018 Receiver Holding Register US_RHR Read-only 0x0
0x001C Transmitter Holding Register US_THR Write-only
0x0020 Baud Rate Generator Register US_BRGR Read/Write 0x0
0x0024 Receiver Time-out Register US_RTOR Read/Write 0x0
0x0028 Transmitter Timeguard Register US_TTGR Read/Write 0x0
0x2C - 0x3C Reserved
0x0040 FI DI Ratio Register US_FIDI Read/Write 0x174
0x0044 Number of Errors Register US_NER Read-only
0x0048 Reserved
0x004C IrDA Filter Register US_IF Read/Write 0x0
0x5C - 0xFC Reserved
0x100 - 0x128 Reserved for PDC Registers
419
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.1 USART Control Register
Name: US_CR
Access: Write-only
RSTRX: Reset Receiver
0: No effect.
1: Resets the receiver.
RSTTX: Reset Transmitter
0: No effect.
1: Resets the transmitter.
RXEN: Receiver Enable
0: No effect.
1: Enables the receiver, if RXDIS is 0.
RXDIS: Receiver Disable
0: No effect.
1: Disables the receiver.
TXEN: Transmitter Enable
0: No effect.
1: Enables the transmitter if TXDIS is 0.
TXDIS: Transmitter Disable
0: No effect.
1: Disables the transmitter.
RSTSTA: Reset Status Bits
0: No effect.
1: Resets the status bits PARE, FRAME, OVRE, and RXBRK in US_CSR.
STTBRK: Start Break
0: No effect.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
RTSDIS RTSEN DTRDIS DTREN
15 14 13 12 11 10 9 8
RETTO RSTNACK RSTIT SENDA STTTO STPBRK STTBRK RSTSTA
7 6 5 4 3 2 1 0
TXDIS TXEN RXDIS RXEN RSTTX RSTRX
420
6222HATARM25-Jan-12
SAM7SE512/256/32
1: Starts transmission of a break after the characters present in US_THR and the Transmit Shift Register have been trans-
mitted. No effect if a break is already being transmitted.
STPBRK: Stop Break
0: No effect.
1: Stops transmission of the break after a minimum of one character length and transmits a high level during 12-bit periods.
No effect if no break is being transmitted.
STTTO: Start Time-out
0: No effect.
1: Starts waiting for a character before clocking the time-out counter. Resets the status bit TIMEOUT in US_CSR.
SENDA: Send Address
0: No effect.
1: In Multidrop Mode only, the next character written to the US_THR is sent with the address bit set.
RSTIT: Reset Iterations
0: No effect.
1: Resets ITERATION in US_CSR. No effect if the ISO7816 is not enabled.
RSTNACK: Reset Non Acknowledge
0: No effect
1: Resets NACK in US_CSR.
RETTO: Rearm Time-out
0: No effect
1: Restart Time-out
DTREN: Data Terminal Ready Enable
0: No effect.
1: Drives the pin DTR at 0.
DTRDIS: Data Terminal Ready Disable
0: No effect.
1: Drives the pin DTR to 1.
RTSEN: Request to Send Enable
0: No effect.
1: Drives the pin RTS to 0.
RTSDIS: Request to Send Disable
0: No effect.
1: Drives the pin RTS to 1.
421
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.2 USART Mode Register
Name: US_MR
Access: Read/Write
USART_MODE
USCLKS: Clock Selection
CHRL: Character Length.
31 30 29 28 27 26 25 24
FILTER MAX_ITERATION
23 22 21 20 19 18 17 16
DSNACK INACK OVER CLKO MODE9 MSBF
15 14 13 12 11 10 9 8
CHMODE NBSTOP PAR SYNC
7 6 5 4 3 2 1 0
CHRL USCLKS USART_MODE
USART_MODE Mode of the USART
0 0 0 0 Normal
0 0 0 1 RS485
0 0 1 0 Hardware Handshaking
0 0 1 1 Modem
0 1 0 0 IS07816 Protocol: T = 0
0 1 0 1 Reserved
0 1 1 0 IS07816 Protocol: T = 1
0 1 1 1 Reserved
1 0 0 0 IrDA
1 1 x x Reserved
USCLKS Selected Clock
0 0 MCK
0 1 MCK/DIV (DIV = 8)
1 0 Reserved
1 1 SCK
CHRL Character Length
0 0 5 bits
0 1 6 bits
1 0 7 bits
1 1 8 bits
422
6222HATARM25-Jan-12
SAM7SE512/256/32
SYNC: Synchronous Mode Select
0: USART operates in Asynchronous Mode.
1: USART operates in Synchronous Mode.
PAR: Parity Type
NBSTOP: Number of Stop Bits
CHMODE: Channel Mode
MSBF: Bit Order
0: Least Significant Bit is sent/received first.
1: Most Significant Bit is sent/received first.
MODE9: 9-bit Character Length
0: CHRL defines character length.
1: 9-bit character length.
CLKO: Clock Output Select
0: The USART does not drive the SCK pin.
1: The USART drives the SCK pin if USCLKS does not select the external clock SCK.
OVER: Oversampling Mode
0: 16x Oversampling.
PAR Parity Type
0 0 0 Even parity
0 0 1 Odd parity
0 1 0 Parity forced to 0 (Space)
0 1 1 Parity forced to 1 (Mark)
1 0 x No parity
1 1 x Multidrop mode
NBSTOP Asynchronous (SYNC = 0) Synchronous (SYNC = 1)
0 0 1 stop bit 1 stop bit
0 1 1.5 stop bits Reserved
1 0 2 stop bits 2 stop bits
1 1 Reserved Reserved
CHMODE Mode Description
0 0 Normal Mode
0 1 Automatic Echo. Receiver input is connected to the TXD pin.
1 0 Local Loopback. Transmitter output is connected to the Receiver Input..
1 1 Remote Loopback. RXD pin is internally connected to the TXD pin.
423
6222HATARM25-Jan-12
SAM7SE512/256/32
1: 8x Oversampling.
INACK: Inhibit Non Acknowledge
0: The NACK is generated.
1: The NACK is not generated.
DSNACK: Disable Successive NACK
0: NACK is sent on the ISO line as soon as a parity error occurs in the received character (unless INACK is set).
1: Successive parity errors are counted up to the value specified in the MAX_ITERATION field. These parity errors gener-
ate a NACK on the ISO line. As soon as this value is reached, no additional NACK is sent on the ISO line. The flag
ITERATION is asserted.
MAX_ITERATION
Defines the maximum number of iterations in mode ISO7816, protocol T= 0.
FILTER: Infrared Receive Line Filter
0: The USART does not filter the receive line.
1: The USART filters the receive line using a three-sample filter (1/16-bit clock) (2 over 3 majority).
424
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.3 USART Interrupt Enable Register
Name: US_IER
Access: Write-only
RXRDY: RXRDY Interrupt Enable
TXRDY: TXRDY Interrupt Enable
RXBRK: Receiver Break Interrupt Enable
ENDRX: End of Receive Transfer Interrupt Enable
ENDTX: End of Transmit Interrupt Enable
OVRE: Overrun Error Interrupt Enable
FRAME: Framing Error Interrupt Enable
PARE: Parity Error Interrupt Enable
TIMEOUT: Time-out Interrupt Enable
TXEMPTY: TXEMPTY Interrupt Enable
ITERATION: Iteration Interrupt Enable
TXBUFE: Buffer Empty Interrupt Enable
RXBUFF: Buffer Full Interrupt Enable
NACK: Non Acknowledge Interrupt Enable
RIIC: Ring Indicator Input Change Enable
DSRIC: Data Set Ready Input Change Enable
DCDIC: Data Carrier Detect Input Change Interrupt Enable
CTSIC: Clear to Send Input Change Interrupt Enable
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITERATION TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
425
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.4 USART Interrupt Disable Register
Name: US_IDR
Access: Write-only
RXRDY: RXRDY Interrupt Disable
TXRDY: TXRDY Interrupt Disable
RXBRK: Receiver Break Interrupt Disable
ENDRX: End of Receive Transfer Interrupt Disable
ENDTX: End of Transmit Interrupt Disable
OVRE: Overrun Error Interrupt Disable
FRAME: Framing Error Interrupt Disable
PARE: Parity Error Interrupt Disable
TIMEOUT: Time-out Interrupt Disable
TXEMPTY: TXEMPTY Interrupt Disable
ITERATION: Iteration Interrupt Disable
TXBUFE: Buffer Empty Interrupt Disable
RXBUFF: Buffer Full Interrupt Disable
NACK: Non Acknowledge Interrupt Disable
RIIC: Ring Indicator Input Change Disable
DSRIC: Data Set Ready Input Change Disable
DCDIC: Data Carrier Detect Input Change Interrupt Disable
CTSIC: Clear to Send Input Change Interrupt Disable
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITERATION TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
426
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.5 USART Interrupt Mask Register
Name: US_IMR
Access: Read-only
RXRDY: RXRDY Interrupt Mask
TXRDY: TXRDY Interrupt Mask
RXBRK: Receiver Break Interrupt Mask
ENDRX: End of Receive Transfer Interrupt Mask
ENDTX: End of Transmit Interrupt Mask
OVRE: Overrun Error Interrupt Mask
FRAME: Framing Error Interrupt Mask
PARE: Parity Error Interrupt Mask
TIMEOUT: Time-out Interrupt Mask
TXEMPTY: TXEMPTY Interrupt Mask
ITERATION: Iteration Interrupt Mask
TXBUFE: Buffer Empty Interrupt Mask
RXBUFF: Buffer Full Interrupt Mask
NACK: Non Acknowledge Interrupt Mask
RIIC: Ring Indicator Input Change Mask
DSRIC: Data Set Ready Input Change Mask
DCDIC: Data Carrier Detect Input Change Interrupt Mask
CTSIC: Clear to Send Input Change Interrupt Mask
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITERATION TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
427
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.6 USART Channel Status Register
Name: US_CSR
Access: Read-only
RXRDY: Receiver Ready
0: No complete character has been received since the last read of US_RHR or the receiver is disabled. If characters were
being received when the receiver was disabled, RXRDY changes to 1 when the receiver is enabled.
1: At least one complete character has been received and US_RHR has not yet been read.
TXRDY: Transmitter Ready
0: A character is in the US_THR waiting to be transferred to the Transmit Shift Register, or an STTBRK command has been
requested, or the transmitter is disabled. As soon as the transmitter is enabled, TXRDY becomes 1.
1: There is no character in the US_THR.
RXBRK: Break Received/End of Break
0: No Break received or End of Break detected since the last RSTSTA.
1: Break Received or End of Break detected since the last RSTSTA.
ENDRX: End of Receiver Transfer
0: The End of Transfer signal from the Receive PDC channel is inactive.
1: The End of Transfer signal from the Receive PDC channel is active.
ENDTX: End of Transmitter Transfer
0: The End of Transfer signal from the Transmit PDC channel is inactive.
1: The End of Transfer signal from the Transmit PDC channel is active.
OVRE: Overrun Error
0: No overrun error has occurred since the last RSTSTA.
1: At least one overrun error has occurred since the last RSTSTA.
FRAME: Framing Error
0: No stop bit has been detected low since the last RSTSTA.
1: At least one stop bit has been detected low since the last RSTSTA.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
CTS DCD DSR RI CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITERATION TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
428
6222HATARM25-Jan-12
SAM7SE512/256/32
PARE: Parity Error
0: No parity error has been detected since the last RSTSTA.
1: At least one parity error has been detected since the last RSTSTA.
TIMEOUT: Receiver Time-out
0: There has not been a time-out since the last Start Time-out command (STTTO in US_CR) or the Time-out Register is 0.
1: There has been a time-out since the last Start Time-out command (STTTO in US_CR).
TXEMPTY: Transmitter Empty
0: There are characters in either US_THR or the Transmit Shift Register, or the transmitter is disabled.
1: There are no characters in US_THR, nor in the Transmit Shift Register.
ITERATION: Max number of Repetitions Reached
0: Maximum number of repetitions has not been reached since the last RSIT.
1: Maximum number of repetitions has been reached since the last RSIT.
TXBUFE: Transmission Buffer Empty
0: The signal Buffer Empty from the Transmit PDC channel is inactive.
1: The signal Buffer Empty from the Transmit PDC channel is active.
RXBUFF: Reception Buffer Full
0: The signal Buffer Full from the Receive PDC channel is inactive.
1: The signal Buffer Full from the Receive PDC channel is active.
NACK: Non Acknowledge
0: No Non Acknowledge has not been detected since the last RSTNACK.
1: At least one Non Acknowledge has been detected since the last RSTNACK.
RIIC: Ring Indicator Input Change Flag
0: No input change has been detected on the RI pin since the last read of US_CSR.
1: At least one input change has been detected on the RI pin since the last read of US_CSR.
DSRIC: Data Set Ready Input Change Flag
0: No input change has been detected on the DSR pin since the last read of US_CSR.
1: At least one input change has been detected on the DSR pin since the last read of US_CSR.
DCDIC: Data Carrier Detect Input Change Flag
0: No input change has been detected on the DCD pin since the last read of US_CSR.
1: At least one input change has been detected on the DCD pin since the last read of US_CSR.
CTSIC: Clear to Send Input Change Flag
0: No input change has been detected on the CTS pin since the last read of US_CSR.
1: At least one input change has been detected on the CTS pin since the last read of US_CSR.
429
6222HATARM25-Jan-12
SAM7SE512/256/32
RI: Image of RI Input
0: RI is at 0.
1: RI is at 1.
DSR: Image of DSR Input
0: DSR is at 0
1: DSR is at 1.
DCD: Image of DCD Input
0: DCD is at 0.
1: DCD is at 1.
CTS: Image of CTS Input
0: CTS is at 0.
1: CTS is at 1.
430
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.7 USART Receive Holding Register
Name: US_RHR
Access: Read-only
RXCHR: Received Character
Last character received if RXRDY is set.
RXSYNH: Received Sync
0: Last Character received is a Data.
1: Last Character received is a Command.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXSYNH RXCHR
7 6 5 4 3 2 1 0
RXCHR
431
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.8 USART Transmit Holding Register
Name: US_THR
Access: Write-only
TXCHR: Character to be Transmitted
Next character to be transmitted after the current character if TXRDY is not set.
TXSYNH: Sync Field to be transmitted
0: The next character sent is encoded as a data. Start Frame Delimiter is DATA SYNC.
1: The next character sent is encoded as a command. Start Frame Delimiter is COMMAND SYNC.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXSYNH TXCHR
7 6 5 4 3 2 1 0
TXCHR
432
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.9 USART Baud Rate Generator Register
Name: US_BRGR
Access: Read/Write
CD: Clock Divider
FP: Fractional Part
0: Fractional divider is disabled.
1 - 7: Baudrate resolution, defined by FP x 1/8.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
FP
15 14 13 12 11 10 9 8
CD
7 6 5 4 3 2 1 0
CD
CD
USART_MODE ISO7816
USART_MODE =
ISO7816
SYNC = 0 SYNC = 1
OVER = 0 OVER = 1
0 Baud Rate Clock Disabled
1 to 65535
Baud Rate =
Selected Clock/16/CD
Baud Rate =
Selected Clock/8/CD
Baud Rate =
Selected Clock /CD
Baud Rate = Selected
Clock/CD/FI_DI_RATIO
433
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.10 USART Receiver Time-out Register
Name: US_RTOR
Access: Read/Write
TO: Time-out Value
0: The Receiver Time-out is disabled.
1 - 65535: The Receiver Time-out is enabled and the Time-out delay is TO x Bit Period.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TO
7 6 5 4 3 2 1 0
TO
434
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.11 USART Transmitter Timeguard Register
Name: US_TTGR
Access: Read/Write
TG: Timeguard Value
0: The Transmitter Timeguard is disabled.
1 - 255: The Transmitter timeguard is enabled and the timeguard delay is TG x Bit Period.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TG
435
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.12 USART FI DI RATIO Register
Name: US_FIDI
Access: Read/Write
Reset Value : 0x174
FI_DI_RATIO: FI Over DI Ratio Value
0: If ISO7816 mode is selected, the Baud Rate Generator generates no signal.
1 - 2047: If ISO7816 mode is selected, the Baud Rate is the clock provided on SCK divided by FI_DI_RATIO.
33.7.13 USART Number of Errors Register
Name: US_NER
Access: Read-only
NB_ERRORS: Number of Errors
Total number of errors that occurred during an ISO7816 transfer. This register automatically clears when read.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FI_DI_RATIO
7 6 5 4 3 2 1 0
FI_DI_RATIO
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
NB_ERRORS
436
6222HATARM25-Jan-12
SAM7SE512/256/32
33.7.14 USART IrDA FILTER Register
Name: US_IF
Access: Read/Write
IRDA_FILTER: IrDA Filter
Sets the filter of the IrDA demodulator.
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
IRDA_FILTER
437
6222HATARM25-Jan-12
SAM7SE512/256/32
34. Parallel Input Output Controller (PIO)
34.1 Overview
The Parallel Input/Output Controller (PIO) manages up to 32 fully programmable input/output
lines. Each I/O line may be dedicated as a general-purpose I/O or be assigned to a function of
an embedded peripheral. This assures effective optimization of the pins of a product.
Each I/O line is associated with a bit number in all of the 32-bit registers of the 32-bit wide User
Interface.
Each I/O line of the PIO Controller features:
An input change interrupt enabling level change detection on any I/O line.
A glitch filter providing rejection of pulses lower than one-half of clock cycle.
Multi-drive capability similar to an open drain I/O line.
Control of the pull-up of the I/O line.
Input visibility and output control.
The PIO Controller also features a synchronous output providing up to 32 bits of data output in a
single write operation.
438
6222HATARM25-Jan-12
SAM7SE512/256/32
34.2 Block Diagram
Figure 34-1. Block Diagram
Figure 34-2. Application Block Diagram
Embedded
Peripheral
Embedded
Peripheral
PIO Interrupt
PIO Controller
Up to 32 pins
PMC
Up to 32
peripheral IOs
Up to 32
peripheral IOs
PIO Clock
APB
AIC
Data, Enable
PIN 31
PIN 1
PIN 0
Data, Enable
On-Chip Peripherals
PIO Controller
On-Chip Peripheral Drivers
Control & Command
Driver
Keyboard Driver
Keyboard Driver General Purpose I/Os External Devices
439
6222HATARM25-Jan-12
SAM7SE512/256/32
34.3 Product Dependencies
34.3.1 Pin Multiplexing
Each pin is configurable, according to product definition as either a general-purpose I/O line
only, or as an I/O line multiplexed with one or two peripheral I/Os. As the multiplexing is hard-
ware-defined and thus product-dependent, the hardware designer and programmer must
carefully determine the configuration of the PIO controllers required by their application. When
an I/O line is general-purpose only, i.e. not multiplexed with any peripheral I/O, programming of
the PIO Controller regarding the assignment to a peripheral has no effect and only the PIO Con-
troller can control how the pin is driven by the product.
34.3.2 External Interrupt Lines
The interrupt signals FIQ and IRQ0 to IRQn are most generally multiplexed through the PIO
Controllers. However, it is not necessary to assign the I/O line to the interrupt function as the
PIO Controller has no effect on inputs and the interrupt lines (FIQ or IRQs) are used only as
inputs.
34.3.3 Power Management
The Power Management Controller controls the PIO Controller clock in order to save power.
Writing any of the registers of the user interface does not require the PIO Controller clock to be
enabled. This means that the configuration of the I/O lines does not require the PIO Controller
clock to be enabled.
However, when the clock is disabled, not all of the features of the PIO Controller are available.
Note that the Input Change Interrupt and the read of the pin level require the clock to be
validated.
After a hardware reset, the PIO clock is disabled by default.
The user must configure the Power Management Controller before any access to the input line
information.
34.3.4 Interrupt Generation
For interrupt handling, the PIO Controllers are considered as user peripherals. This means that
the PIO Controller interrupt lines are connected among the interrupt sources 2 to 31. Refer to the
PIO Controller peripheral identifier in the product description to identify the interrupt sources
dedicated to the PIO Controllers.
The PIO Controller interrupt can be generated only if the PIO Controller clock is enabled.
440
6222HATARM25-Jan-12
SAM7SE512/256/32
34.4 Functional Description
The PIO Controller features up to 32 fully-programmable I/O lines. Most of the control logic asso-
ciated to each I/O is represented in Figure 34-3. In this description each signal shown
represents but one of up to 32 possible indexes.
Figure 34-3. I/O Line Control Logic
1
0
1
0
1
0
Glitch
Filter
Peripheral B
Input
Peripheral A
Input
1
0
PIO_IFDR[0]
PIO_IFSR[0]
PIO_IFER[0]
Edge
Detector
PIO_PDSR[0] PIO_ISR[0]
PIO_IDR[0]
PIO_IMR[0]
PIO_IER[0]
PIO Interrupt
(Up to 32 possible inputs)
PIO_ISR[31]
PIO_IDR[31]
PIO_IMR[31]
PIO_IER[31]
Pad
1
0
PIO_PUDR[0]
PIO_PUSR[0]
PIO_PUER[0]
PIO_MDDR[0]
PIO_MDSR[0]
PIO_MDER[0]
PIO_CODR[0]
PIO_ODSR[0]
PIO_SODR[0]
PIO_PDR[0]
PIO_PSR[0]
PIO_PER[0]
1
0
1
0
PIO_BSR[0]
PIO_ABSR[0]
PIO_ASR[0]
Peripheral B
Output Enable
Peripheral A
Output Enable
Peripheral B
Output
Peripheral A
Output
PIO_ODR[0]
PIO_OSR[0]
PIO_OER[0]
441
6222HATARM25-Jan-12
SAM7SE512/256/32
34.4.1 Pull-up Resistor Control
Each I/O line is designed with an embedded pull-up resistor. The pull-up resistor can be enabled
or disabled by writing respectively PIO_PUER (Pull-up Enable Register) and PIO_PUDR (Pull-
up Disable Resistor). Writing in these registers results in setting or clearing the corresponding bit
in PIO_PUSR (Pull-up Status Register). Reading a 1 in PIO_PUSR means the pull-up is dis-
abled and reading a 0 means the pull-up is enabled.
Control of the pull-up resistor is possible regardless of the configuration of the I/O line.
After reset, all of the pull-ups are enabled, i.e. PIO_PUSR resets at the value 0x0.
34.4.2 I/O Line or Peripheral Function Selection
When a pin is multiplexed with one or two peripheral functions, the selection is controlled with
the registers PIO_PER (PIO Enable Register) and PIO_PDR (PIO Disable Register). The regis-
ter PIO_PSR (PIO Status Register) is the result of the set and clear registers and indicates
whether the pin is controlled by the corresponding peripheral or by the PIO Controller. A value of
0 indicates that the pin is controlled by the corresponding on-chip peripheral selected in the
PIO_ABSR (AB Select Status Register). A value of 1 indicates the pin is controlled by the PIO
controller.
If a pin is used as a general purpose I/O line (not multiplexed with an on-chip peripheral),
PIO_PER and PIO_PDR have no effect and PIO_PSR returns 1 for the corresponding bit.
After reset, most generally, the I/O lines are controlled by the PIO controller, i.e. PIO_PSR
resets at 1. However, in some events, it is important that PIO lines are controlled by the periph-
eral (as in the case of memory chip select lines that must be driven inactive after reset or for
address lines that must be driven low for booting out of an external memory). Thus, the reset
value of PIO_PSR is defined at the product level, depending on the multiplexing of the device.
34.4.3 Peripheral A or B Selection
The PIO Controller provides multiplexing of up to two peripheral functions on a single pin. The
selection is performed by writing PIO_ASR (A Select Register) and PIO_BSR (Select B Regis-
ter). PIO_ABSR (AB Select Status Register) indicates which peripheral line is currently selected.
For each pin, the corresponding bit at level 0 means peripheral A is selected whereas the corre-
sponding bit at level 1 indicates that peripheral B is selected.
Note that multiplexing of peripheral lines A and B only affects the output line. The peripheral
input lines are always connected to the pin input.
After reset, PIO_ABSR is 0, thus indicating that all the PIO lines are configured on peripheral A.
However, peripheral A generally does not drive the pin as the PIO Controller resets in I/O line
mode.
Writing in PIO_ASR and PIO_BSR manages PIO_ABSR regardless of the configuration of the
pin. However, assignment of a pin to a peripheral function requires a write in the corresponding
peripheral selection register (PIO_ASR or PIO_BSR) in addition to a write in PIO_PDR.
34.4.4 Output Control
When the I/0 line is assigned to a peripheral function, i.e. the corresponding bit in PIO_PSR is at
0, the drive of the I/O line is controlled by the peripheral. Peripheral A or B, depending on the
value in PIO_ABSR, determines whether the pin is driven or not.
When the I/O line is controlled by the PIO controller, the pin can be configured to be driven. This
is done by writing PIO_OER (Output Enable Register) and PIO_ODR (Output Disable Register).
442
6222HATARM25-Jan-12
SAM7SE512/256/32
The results of these write operations are detected in PIO_OSR (Output Status Register). When
a bit in this register is at 0, the corresponding I/O line is used as an input only. When the bit is at
1, the corresponding I/O line is driven by the PIO controller.
The level driven on an I/O line can be determined by writing in PIO_SODR (Set Output Data
Register) and PIO_CODR (Clear Output Data Register). These write operations respectively set
and clear PIO_ODSR (Output Data Status Register), which represents the data driven on the I/O
lines. Writing in PIO_OER and PIO_ODR manages PIO_OSR whether the pin is configured to
be controlled by the PIO controller or assigned to a peripheral function. This enables configura-
tion of the I/O line prior to setting it to be managed by the PIO Controller.
Similarly, writing in PIO_SODR and PIO_CODR effects PIO_ODSR. This is important as it
defines the first level driven on the I/O line.
34.4.5 Synchronous Data Output
Controlling all parallel busses using several PIOs requires two successive write operations in the
PIO_SODR and PIO_CODR registers. This may lead to unexpected transient values. The PIO
controller offers a direct control of PIO outputs by single write access to PIO_ODSR (Output
Data Status Register). Only bits unmasked by PIO_OWSR (Output Write Status Register) are
written. The mask bits in the PIO_OWSR are set by writing to PIO_OWER (Output Write Enable
Register) and cleared by writing to PIO_OWDR (Output Write Disable Register).
After reset, the synchronous data output is disabled on all the I/O lines as PIO_OWSR resets at
0x0.
34.4.6 Multi Drive Control (Open Drain)
Each I/O can be independently programmed in Open Drain by using the Multi Drive feature. This
feature permits several drivers to be connected on the I/O line which is driven low only by each
device. An external pull-up resistor (or enabling of the internal one) is generally required to guar-
antee a high level on the line.
The Multi Drive feature is controlled by PIO_MDER (Multi-driver Enable Register) and
PIO_MDDR (Multi-driver Disable Register). The Multi Drive can be selected whether the I/O line
is controlled by the PIO controller or assigned to a peripheral function. PIO_MDSR (Multi-driver
Status Register) indicates the pins that are configured to support external drivers.
After reset, the Multi Drive feature is disabled on all pins, i.e. PIO_MDSR resets at value 0x0.
34.4.7 Output Line Timings
Figure 34-4 shows how the outputs are driven either by writing PIO_SODR or PIO_CODR, or by
directly writing PIO_ODSR. This last case is valid only if the corresponding bit in PIO_OWSR is
set. Figure 34-4 also shows when the feedback in PIO_PDSR is available.
443
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 34-4. Output Line Timings
34.4.8 Inputs
The level on each I/O line can be read through PIO_PDSR (Pin Data Status Register). This reg-
ister indicates the level of the I/O lines regardless of their configuration, whether uniquely as an
input or driven by the PIO controller or driven by a peripheral.
Reading the I/O line levels requires the clock of the PIO controller to be enabled, otherwise
PIO_PDSR reads the levels present on the I/O line at the time the clock was disabled.
34.4.9 Input Glitch Filtering
Optional input glitch filters are independently programmable on each I/O line. When the glitch fil-
ter is enabled, a glitch with a duration of less than 1/2 Master Clock (MCK) cycle is automatically
rejected, while a pulse with a duration of 1 Master Clock cycle or more is accepted. For pulse
durations between 1/2 Master Clock cycle and 1 Master Clock cycle the pulse may or may not
be taken into account, depending on the precise timing of its occurrence. Thus for a pulse to be
visible it must exceed 1 Master Clock cycle, whereas for a glitch to be reliably filtered out, its
duration must not exceed 1/2 Master Clock cycle. The filter introduces one Master Clock cycle
latency if the pin level change occurs before a rising edge. However, this latency does not
appear if the pin level change occurs before a falling edge. This is illustrated in Figure 34-5.
The glitch filters are controlled by the register set; PIO_IFER (Input Filter Enable Register),
PIO_IFDR (Input Filter Disable Register) and PIO_IFSR (Input Filter Status Register). Writing
PIO_IFER and PIO_IFDR respectively sets and clears bits in PIO_IFSR. This last register
enables the glitch filter on the I/O lines.
When the glitch filter is enabled, it does not modify the behavior of the inputs on the peripherals.
It acts only on the value read in PIO_PDSR and on the input change interrupt detection. The
glitch filters require that the PIO Controller clock is enabled.
2 cycles
APB Access
2 cycles
APB Access
MCK
Write PIO_SODR
Write PIO_ODSR at 1
PIO_ODSR
PIO_PDSR
Write PIO_CODR
Write PIO_ODSR at 0
444
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 34-5. Input Glitch Filter Timing
34.4.10 Input Change Interrupt
The PIO Controller can be programmed to generate an interrupt when it detects an input change
on an I/O line. The Input Change Interrupt is controlled by writing PIO_IER (Interrupt Enable
Register) and PIO_IDR (Interrupt Disable Register), which respectively enable and disable the
input change interrupt by setting and clearing the corresponding bit in PIO_IMR (Interrupt Mask
Register). As Input change detection is possible only by comparing two successive samplings of
the input of the I/O line, the PIO Controller clock must be enabled. The Input Change Interrupt is
available, regardless of the configuration of the I/O line, i.e. configured as an input only, con-
trolled by the PIO Controller or assigned to a peripheral function.
When an input change is detected on an I/O line, the corresponding bit in PIO_ISR (Interrupt
Status Register) is set. If the corresponding bit in PIO_IMR is set, the PIO Controller interrupt
line is asserted. The interrupt signals of the thirty-two channels are ORed-wired together to gen-
erate a single interrupt signal to the Advanced Interrupt Controller.
When the software reads PIO_ISR, all the interrupts are automatically cleared. This signifies that
all the interrupts that are pending when PIO_ISR is read must be handled.
Figure 34-6. Input Change Interrupt Timings
34.5 I/O Lines Programming Example
The programing example as shown in Table 34-1 below is used to define the following
configuration.
4-bit output port on I/O lines 0 to 3, (should be written in a single write operation), open-drain,
with pull-up resistor
MCK
Pin Level
PIO_PDSR
if PIO_IFSR = 0
PIO_PDSR
if PIO_IFSR = 1
1 cycle 1 cycle 1 cycle
up to 1.5 cycles
2 cycles
up to 2.5 cycles up to 2 cycles
1 cycle
1 cycle
MCK
Pin Level
Read PIO_ISR APB Access
PIO_ISR
APB Access
445
6222HATARM25-Jan-12
SAM7SE512/256/32
Four output signals on I/O lines 4 to 7 (to drive LEDs for example), driven high and low, no
pull-up resistor
Four input signals on I/O lines 8 to 11 (to read push-button states for example), with pull-up
resistors, glitch filters and input change interrupts
Four input signals on I/O line 12 to 15 to read an external device status (polled, thus no input
change interrupt), no pull-up resistor, no glitch filter
I/O lines 16 to 19 assigned to peripheral A functions with pull-up resistor
I/O lines 20 to 23 assigned to peripheral B functions, no pull-up resistor
I/O line 24 to 27 assigned to peripheral A with Input Change Interrupt and pull-up resistor
Table 34-1. Programming Example
Register Value to be Written
PIO_PER 0x0000 FFFF
PIO_PDR 0x0FFF 0000
PIO_OER 0x0000 00FF
PIO_ODR 0x0FFF FF00
PIO_IFER 0x0000 0F00
PIO_IFDR 0x0FFF F0FF
PIO_SODR 0x0000 0000
PIO_CODR 0x0FFF FFFF
PIO_IER 0x0F00 0F00
PIO_IDR 0x00FF F0FF
PIO_MDER 0x0000 000F
PIO_MDDR 0x0FFF FFF0
PIO_PUDR 0x00F0 00F0
PIO_PUER 0x0F0F FF0F
PIO_ASR 0x0F0F 0000
PIO_BSR 0x00F0 0000
PIO_OWER 0x0000 000F
PIO_OWDR 0x0FFF FFF0
446
6222HATARM25-Jan-12
SAM7SE512/256/32
34.6 PIO User Interface
Each I/O line controlled by the PIO Controller is associated with a bit in each of the PIO Control-
ler User Interface registers. Each register is 32 bits wide. If a parallel I/O line is not defined,
writing to the corresponding bits has no effect. Undefined bits read zero. If the I/O line is not mul-
tiplexed with any peripheral, the I/O line is controlled by the PIO Controller and PIO_PSR returns
1 systematically.
Table 34-2. PIO Register Mapping
Offset Register Name Access Reset Value
0x0000 PIO Enable Register PIO_PER Write-only
0x0004 PIO Disable Register PIO_PDR Write-only
0x0008 PIO Status Register PIO_PSR Read-only
(1)
0x000C Reserved
0x0010 Output Enable Register PIO_OER Write-only
0x0014 Output Disable Register PIO_ODR Write-only
0x0018 Output Status Register PIO_OSR Read-only 0x0000 0000
0x001C Reserved
0x0020 Glitch Input Filter Enable Register PIO_IFER Write-only
0x0024 Glitch Input Filter Disable Register PIO_IFDR Write-only
0x0028 Glitch Input Filter Status Register PIO_IFSR Read-only 0x0000 0000
0x002C Reserved
0x0030 Set Output Data Register PIO_SODR Write-only
0x0034 Clear Output Data Register PIO_CODR Write-only
0x0038 Output Data Status Register PIO_ODSR
Read-only
or
(2)
Read/Write
C
M
Motional capacitance 8 fF
C
SHUNT
Shunt capacitance 7 pF
Table 40-12. XIN Clock Electrical Characteristics
Symbol Parameter Conditions Min Max Units
1/(t
CPXIN
) XIN Clock Frequency
(1)
50.0 MHz
t
CPXIN
XIN Clock Period
(1)
20.0 ns
t
CHXIN
XIN Clock High Half-period
(1)
8.0 ns
t
CLXIN
XIN Clock Low Half-period
(1)
8.0 ns
t
CLCH
Rise Time
(1)
400 ns
t
CHCL
Fall Time
(1)
400 ns
C
IN
XIN Input Capacitance (SAM7SE512/256)
(1)
46 pF
C
IN
XIN Input Capacitance (SAM7SE32)
(1)
26 pF
R
IN
XIN Pull-down Resistor
(1)
500 k
V
XIN_IL
V
XIN
Input Low-level Voltage
(1)
-0.3 0.3 x V
DDPLL
V
V
XIN_IH
V
XIN
Input High-level Voltage
(1)
0.7 x V
DDPLL
1.95 V
I
DDBP
Bypass Current Consumption
(1)
15 W/MHz
t
CPXIN
t
CPXIN
t
CPXIN
t
CHXIN
t
CLCH
t
CHCL
V
XIN_IL
V
XIN_IH
624
6222HATARM25-Jan-12
SAM7SE512/256/32
40.5 PLL Characteristics
Note: Startup time depends on PLL RC filter. A calculation tool is provided by Atmel.
Table 40-13. Phase Lock Loop Characteristics
Symbol Parameter Conditions Min Typ Max Unit
F
OUT
Output Frequency Field OUT of CKGR_PLL is:
00 80 160 MHz
10 150 220 MHz
F
IN
Input Frequency 1 32 MHz
I
PLL
Current Consumption
Active mode 4 mA
Standby mode 1 A
625
6222HATARM25-Jan-12
SAM7SE512/256/32
40.6 USB Transceiver Characteristics
40.6.1 Electrical Characteristics
40.6.2 Switching Characteristics
Table 40-14. Electrical Parameters
Symbol Parameter Conditions Min Typ Max Unit
Input Levels
V
IL
Low Level 0.8 V
V
IH
High Level 2.0 V
V
DI
Differential Input Sensitivity |(D+) - (D-)| 0.2 V
V
CM
Differential Input Common Mode
Range
0.8 2.5 V
C
IN
Transceiver capacitance Capacitance to ground on each line 9.18 pF
I Hi-Z State Data Line Leakage 0V < V
IN
< 3.3V -10 +10 A
R
EXT
Recommended External USB
Series Resistor
In series with each USB pin with 5% 27
Output Levels
V
OL
Low Level Output
Measured with R
L
of 1.425 kOhm tied
to 3.6V
0.0 0.3 V
V
OH
High Level Output
Measured with R
L
of 14.25 kOhm tied
to GND
2.8 3.6 V
V
CRS
Output Signal Crossover Voltage
Measure conditions described in
Figure 40-3
1.3 2.0 V
Consumption
I
VDDIO
Current Consumption
Transceiver enabled in input mode
DDP=1 and DDM=0
105 200 A
I
VDDCORE
Current Consumption 80 150 A
Pull-up Resistor
R
PUI
Bus Pull-up Resistor on
Upstream Port (idle bus)
0.900 1.575 k
R
PUA
Bus Pull-up Resistor on
Upstream Port (upstream port
receiving)
1.425 3.090 k
Table 40-15. In Full Speed
Symbol Parameter Conditions Min Typ Max Unit
t
FR
Transition Rise Time C
LOAD
= 50 pF 4 20 ns
t
FE
Transition Fall Time C
LOAD
= 50 pF 4 20 ns
t
FRFM
Rise/Fall time Matching 90 111.11 %
626
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 40-3. USB Data Signal Rise and Fall Times
10% 10%
90%
V
CRS
t
R
t
F
Differential
Data Lines
Rise Time Fall Time
Fosc = 6MHz/750kHz
R
EXT
=27 ohms
C
load
Buffer
(b)
(a)
627
6222HATARM25-Jan-12
SAM7SE512/256/32
40.7 ADC Characteristics
Notes: 1. Corresponds to 13 clock cycles at 5 MHz: 3 clock cycles for track and hold acquisition time and 10 clock cycles for
conversion.
2. Corresponds to 15 clock cycles at 8 MHz: 5 clock cycles for track and hold acquisition time and 10 clock cycles for
conversion.
The user can drive ADC input with impedance up to:
Z
OUT
(SHTIM -470) x 10 in 8-bit resolution mode
Z
OUT
(SHTIM -589) x 7.69 in 10-bit resolution mode
with SHTIM (Sample and Hold Time register) expressed in ns and Z
OUT
expressed in ohms.
Table 40-16. Channel Conversion Time and ADC Clock
Parameter Conditions Min Typ Max Units
ADC Clock Frequency
10-bit resolution mode 5
MHz
8-bit resolution mode 8
Startup Time Return from Idle Mode 20 s
Track and Hold Acquisition Time 600 ns
Conversion Time
ADC Clock = 5 MHz 2
s
ADC Clock = 8 MHz 1.25
Throughput Rate
ADC Clock = 5 MHz 384
(1)
kSPS
ADC Clock = 8 MHz 533
(2)
Table 40-17. External Voltage Reference Input
Parameter Conditions Min Typ Max Units
ADVREF Input Voltage Range
2.6
V
DDIN
V
8-bit resolution mode 2.5
ADVREF Average Current On 13 samples with ADC Clock = 5 MHz 200 250 A
Current Consumption on VDDIN 0.55 1 mA
Table 40-18. Analog Inputs
Parameter Min Typ Max Units
Input Voltage Range 0 V
ADVREF
Input Leakage Current 1 A
Input Capacitance 12 14 pF
Table 40-19. Transfer Characteristics
Parameter Conditions Min Typ Max Units
Resolution 10 Bit
Integral Non-linearity 2 LSB
Differential Non-linearity No missing code 1 LSB
Offset Error 2 LSB
Gain Error 2 LSB
Absolute Accuracy 4 LSB
628
6222HATARM25-Jan-12
SAM7SE512/256/32
For more information on data converter terminology, please refer to the application note: Data
Converter Terminology, Atmel lit6022.
40.8 AC Characteristics
40.8.1 Master Clock Characteristics
40.8.2 I/O Characteristics
Criteria used to define the maximum frequency of the I/Os:
output duty cycle (30%-70%)
minimum output swing: 100mV to VDDIO - 100mV
Addition of rising and falling time inferior to 75% of the period
Notes: 1. Pin Group 1 = SDCK
2. Pin Group 2 = PA4 to PA31, PB0 to PB31 and PC0-PC23
Table 40-20. Master Clock Waveform Parameters
Symbol Parameter Conditions Min Max Units
1/(t
CPMCK
) Master Clock Frequency V
DDCORE
= 1.8V 55 MHz
1/(t
CPMCK
) Master Clock Frequency V
DDCORE
= 1.65V 48 MHz
Table 40-21. I/O Characteristics
Symbol Parameter Conditions Min Max Units
FreqMax
I01
Pin Group 1
(1)
frequency
Load: 30 pF
(4)
48.2 MHz
Load: 30 pF
(5)
25 MHz
PulseminH
I01
Pin Group 1
(1)
High Level Pulse Width
Load: 30 pF
(4)
20 ns
Load: 30 pF
(5)
40
PulseminL
I01
Pin Group 1
(1)
Low Level Pulse Width
Load: 30 pF
(4)
20 ns
Load: 30 pF
(5)
40
FreqMax
I02
Pin Group 2
(2)
frequency
Load: 40 pF
(4)
25 MHz
Load: 40 pF
(5)
16 MHz
PulseminH
I02
Pin Group 2
(2)
High Level Pulse Width
Load: 40 pF
(4)
20 ns
Load: 40 pF
(5)
31 ns
PulseminL
I02
Pin Group 2
(2)
Low Level Pulse Width
Load: 40 pF
(4)
20 ns
Load: 40 pF
(5)
31 ns
FreqMax
I03
Pin Group 3
(3)
frequency
Load: 40 pF
(4)
30 MHz
Load: 40 pF
(5)
20 MHz
PulseminH
I03
Pin Group 3
(3)
High Level Pulse Width
Load: 40 pF
(4)
16.6 ns
Load: 40 pF
(5)
31 ns
PulseminL
I03
Pin Group 3
(3)
Low Level Pulse Width
Load: 40 pF
(4)
16.6 ns
Load: 40 pF
(5)
31 ns
629
6222HATARM25-Jan-12
SAM7SE512/256/32
3. Pin Group 3 = PA0 to PA3
4. V
VDDIO
from 3.0V to 3.6V, maximum external capacitor = 40 pF
5. V
VDDIO
from 1.65V to 1.95V, maximum external capacitor = 40 pF
40.8.3 SPI Characteristics
Figure 40-4. SPI Master Mode with (CPOL= NCPHA = 0) or (CPOL= NCPHA= 1)
Figure 40-5. SPI Master Mode with (CPOL = 0 and NCPHA=1) or (CPOL=1 and NCPHA= 0)
Figure 40-6. SPI Slave Mode with (CPOL=0 and NCPHA=1) or (CPOL=1 and NCPHA=0)
SPCK
MISO
MOSI
SPI
2
SPI
0
SPI
1
SPCK
MISO
MOSI
SPI
5
SPI
3
SPI
4
SPCK
MISO
MOSI
SPI
6
SPI
7
SPI
8
630
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 40-7. SPI Slave Mode with (CPOL = NCPHA = 0) or (CPOL= NCPHA= 1)
Notes: 1. 3.3V domain: V
VDDIO
from 3.0V to 3.6V, maximum external capacitor = 40 pF.
2. 1.8V domain: V
VDDIO
from 1.65V to 1.95V, maximum external capacitor = 20 pF.
3. t
CPMCK
: Master Clock period in ns.
SPCK
MISO
MOSI
SPI
9
SPI
10
SPI
11
Table 40-22. SAM7SE512/256 SPI Timings
Symbol Parameter Conditions Min Max Units
SPI
0
MISO Setup time before SPCK rises (master)
3.3V domain
(1)
26 + (t
CPMCK
)/2
(3)
ns
1.8V domain
(2)
34 + (t
CPMCK
)/2
(3)
ns
SPI
1
MISO Hold time after SPCK rises (master)
3.3V domain
(1)
0 ns
1.8V domain
(2)
0 ns
SPI
2
SPCK rising to MOSI Delay (master)
3.3V domain
(1)
7 ns
1.8V domain
(2)
10 ns
SPI
3
MISO Setup time before SPCK falls (master)
3.3V domain
(1)
26 + (t
CPMCK
)/2
(3)
ns
1.8V domain
(2)
34 + (t
CPMCK
)/2
(3)
ns
SPI
4
MISO Hold time after SPCK falls (master)
3.3V domain
(1)
0 ns
1.8V domain
(2)
0 ns
SPI
5
SPCK falling to MOSI Delay (master)
3.3V domain
(1)
7 ns
1.8V domain
(2)
10 ns
SPI
6
SPCK falling to MISO Delay (slave)
3.3V domain
(1)
22.5 ns
1.8V domain
(2)
30.5 ns
SPI
7
MOSI Setup time before SPCK rises (slave)
3.3V domain
(1)
1 ns
1.8V domain
(2)
2.5 ns
SPI
8
MOSI Hold time after SPCK rises (slave)
3.3V domain
(1)
2 ns
1.8V domain
(2)
2 ns
SPI
9
SPCK rising to MISO Delay (slave)
3.3V domain
(1)
23 ns
1.8V domain
(2)
28 ns
SPI
10
MOSI Setup time before SPCK falls (slave)
3.3V domain
(1)
1 ns
1.8V domain
(2)
1
SPI
11
MOSI Hold time after SPCK falls (slave)
3.3V domain
(1)
2 ns
1.8V domain
(2)
2 ns
631
6222HATARM25-Jan-12
SAM7SE512/256/32
Notes: 1. 3.3V domain: V
VDDIO
from 3.0V to 3.6V, maximum external capacitor = 40 pF.
2. 1.8V domain: V
VDDIO
from 1.65V to 1.95V, maximum external capacitor = 20 pF.
3. t
CPMCK
: Master Clock period in ns.
Note that in SPI master mode the ATSAM7SE512/256/32 does not sample the data (MISO) on
the opposite edge where data clocks out (MOSI) but the same edge is used as shown in Figure
40-4 and Figure 40-5.
SAM7SE32 SPI Timings
Symbol Parameter Conditions Min Max Units
SPI
0
MISO Setup time before SPCK rises (master)
3.3V domain
(1)
26 + (t
CPMCK
)/2
(3)
ns
1.8V domain
(2)
45 + (t
CPMCK
)/2
(3)
ns
SPI
1
MISO Hold time after SPCK rises (master)
3.3V domain
(1)
0 ns
1.8V domain
(2)
0 ns
SPI
2
SPCK rising to MOSI Delay (master)
3.3V domain
(1)
4 ns
1.8V domain
(2)
12 ns
SPI
3
MISO Setup time before SPCK falls (master)
3.3V domain
(1)
26 + (t
CPMCK
)/2
(3)
ns
1.8V domain
(2)
34 + (t
CPMCK
)/2
(3)
ns
SPI
4
MISO Hold time after SPCK falls (master)
3.3V domain
(1)
0 ns
1.8V domain
(2)
0 ns
SPI
5
SPCK falling to MOSI Delay (master)
3.3V domain
(1)
4 ns
1.8V domain
(2)
6 ns
SPI
6
SPCK falling to MISO Delay (slave)
3.3V domain
(1)
23.7 ns
1.8V domain
(2)
42 ns
SPI
7
MOSI Setup time before SPCK rises (slave)
3.3V domain
(1)
1 ns
1.8V domain
(2)
1 ns
SPI
8
MOSI Hold time after SPCK rises (slave)
3.3V domain
(1)
3 ns
1.8V domain
(2)
3 ns
SPI
9
SPCK rising to MISO Delay (slave)
3.3V domain
(1)
24 ns
1.8V domain
(2)
40 ns
SPI
10
MOSI Setup time before SPCK falls (slave)
3.3V domain
(1)
1 ns
1.8V domain
(2)
1
SPI
11
MOSI Hold time after SPCK falls (slave)
3.3V domain
(1)
3 ns
1.8V domain
(2)
3 ns
632
6222HATARM25-Jan-12
SAM7SE512/256/32
40.8.4 SMC Signals
These timings are given for a maximum 10 pF load on SDCK and a maximum 50 pF load on the
databus.
Note: 1. n = Number of standard Wait States inserted.
Note: 1. n = Number of standard Wait States inserted.
.
Table 40-23. SAM7SE512/256 General-purpose SMC Signals
Symbol Parameter Conditions Min Max Units
SMC
7
NCS Minimum Pulse Width
(Address to Chip Select Setup)
3.3V domain (n + 1) x t
CPMCK
- 2.5
(1)
ns
1.8V domain (n + 1) x t
CPMCK
- 3.0
(1)
ns
SMC
8
NWAIT Minimum Pulse Width t
CPMCK
ns
Table 40-24. SAM7SE32 General-purpose SMC Signals
Symbol Parameter Conditions Min Max Units
SMC
7
NCS Minimum Pulse Width
(Address to Chip Select Setup)
3.3V domain (n + 1) x t
CPMCK
- 2.5
(1)
ns
1.8V domain (n + 1) x t
CPMCK
- 5.0
(1)
ns
SMC
8
NWAIT Minimum Pulse Width t
CPMCK
ns
Table 40-25. SAM7SE512/256 SMC Write Signals
Symbol Parameter Conditions Min Max Units
SMC
15
NWR High to NUB Change
(3)
3.3V domain 7.0 ns
1.8V domain 9.5 ns
SMC
16
NWR High to NLB/A0 Change
(3)
3.3V domain 7.5 ns
1.8V domain 10 ns
SMC
17
NWR High to A1 - A22 Change
(3)
3.3V domain 8 ns
1.8V domain 8.5 ns
SMC
18
NWR High to Chip Select Inactive
(3)
3.3V domain 7.0 ns
1.8V domain 9.0 ns
SMC
19
Data Out Valid before NWR High
(No Wait States)
(3)
3.3V domain 0.5 * t
CPMCK
- 0.5 ns
1.8V domain 0.5 * t
CPMCK
- 1 ns
SMC
20
Data Out Valid before NWR High
(Wait States)
(3)
3.3V domain n x t
CPMCK
- 0.5
(1)
ns
1.8V domain n x t
CPMCK
- 1
(1)
ns
SMC
21
Data Out Valid after NWR High
(No Wait States)
(3))
3.3V domain 0.5 * t
CPMCK
- 5.7 ns
1.8V domain 0.5 * t
CPMCK
- 8 ns
SMC
22
Data Out Valid after NWR High
(Wait States without Hold Cycles)
(3)
3.3V domain 0.5 * t
CPMCK
- 5.2 ns
1.8V domain 0.5 * t
CPMCK
- 8 ns
SMC
23
Data Out Valid after NWR High
(Wait States with Hold Cycles)
(3)
3.3V domain h x t
CPMCK
- 5.7
(2)
ns
1.8V domain h x t
CPMCK
- 8.0
(2)
ns
633
6222HATARM25-Jan-12
SAM7SE512/256/32
Notes: 1. n = Number of standard Wait States inserted.
2. h = Number of Hold Cycles inserted.
3. Not applicable when Address to Chip Select Setup Cycles are inserted.
.
Notes: 1. n = Number of standard Wait States inserted.
2. h = Number of Hold Cycles inserted.
3. Not applicable when Address to Chip Select Setup Cycles are inserted.
SMC
26
NWR Minimum Pulse Width
(No Wait States)
(3)
3.3V domain 0.5 * t
CPMCK
- 1 ns
1.8V domain 0.5 * t
CPMCK
- 1.5 ns
SMC
27
NWR Minimum Pulse Width
(Wait States)
(3)
3.3V domain n x t
CPMCK
- 1.5
(1)
ns
1.8V domain n x t
CPMCK
- 1.5
(1)
ns
Table 40-25. SAM7SE512/256 SMC Write Signals (Continued)
Symbol Parameter Conditions Min Max Units
Table 40-26. SAM7SE32 SMC Write Signals
Symbol Parameter Conditions Min Max Units
SMC
15
NWR High to NUB Change
(3)
3.3V domain 6.0 ns
1.8V domain 9.0 ns
SMC
16
NWR High to NLB/A0 Change
(3)
3.3V domain 6.0 ns
1.8V domain 9.0 ns
SMC
17
NWR High to A1 - A22 Change
(3)
3.3V domain 6.0 ns
1.8V domain 9.0 ns
SMC
18
NWR High to Chip Select Inactive
(3)
3.3V domain 5.5 ns
1.8V domain 9.0 ns
SMC
19
Data Out Valid before NWR High
(No Wait States)
(3)
3.3V domain 0.5 * t
CPMCK
- 3.5 ns
1.8V domain 0.5 * t
CPMCK
- 6.0 ns
SMC
20
Data Out Valid before NWR High
(Wait States)
(3)
3.3V domain n x t
CPMCK
- 3.5
(1)
ns
1.8V domain n x t
CPMCK
- 6.0
(1)
ns
SMC
21
Data Out Valid after NWR High
(No Wait States)
(3))
3.3V domain 0.5 * t
CPMCK
- 5.5 ns
1.8V domain 0.5 * t
CPMCK
- 12 ns
SMC
22
Data Out Valid after NWR High
(Wait States without Hold Cycles)
(3)
3.3V domain 0.5 * t
CPMCK
- 5.2 ns
1.8V domain 0.5 * t
CPMCK
- 8 ns
SMC
23
Data Out Valid after NWR High
(Wait States with Hold Cycles)
(3)
3.3V domain h x t
CPMCK
- 6.0
(2)
ns
1.8V domain h x t
CPMCK
- 12
(2)
ns
SMC
26
NWR Minimum Pulse Width
(No Wait States)
(3)
3.3V domain 0.5 * t
CPMCK
- 2.0 ns
1.8V domain 0.5 * t
CPMCK
- 6.5 ns
SMC
27
NWR Minimum Pulse Width
(Wait States)
(3)
3.3V domain n x t
CPMCK
- 2.5
(1)
ns
1.8V domain n x t
CPMCK
- 7.0
(1)
ns
634
6222HATARM25-Jan-12
SAM7SE512/256/32
Notes: 1. Early Read Protocol.
2. Standard Read Protocol.
3. n = Number of standard Wait States inserted.
4. h = Number of Hold Cycles inserted.
5. Not applicable when Address to Chip Select Setup Cycles are inserted.
Table 40-27. SAM7SE512/256 SMC Read Signals
Symbol Parameter Conditions Min Max Units
SMC
35
NRD High to NUB Change
3.3V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 1
(4)
ns
1.8V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 1
(4)
ns
SMC
36
NRD High to NLB/A0 Change
3.3V domain (h x t
CPMCK
) - 1.5
(4)
(h x t
CPMCK
)+ 1.5
(4)
ns
1.8V domain (h x t
CPMCK
) - 1.5
(4)
(h x t
CPMCK
)+ 1
(4)
ns
SMC
37
NRD High to A1-A22 Change
3.3V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 2
(4)
ns
1.8V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 3.5
(4)
ns
SMC
38
NRD High to Chip Select Inactive
3.3V domain (h x t
CPMCK
) - 3
(4)
(h x t
CPMCK
)+ 1
(4)
ns
1.8V domain (h x t
CPMCK
) - 3.5
(4)
(h x t
CPMCK
)+ 2
(4)
ns
SMC
40
Data Setup before NRD High
3.3V domain 22.2 ns
1.8V domain 35 ns
SMC
41
Data Hold after NRD High
3.3V domain 0 ns
1.8V domain 0 ns
SMC
42
Data Setup before NCS High
3.3V domain 23.2 ns
1.8V domain 37 ns
SMC
43
Data Hold after NCS High
3.3V domain 0 ns
1.8V domain 0 ns
SMC
44
NRD Minimum Pulse Width
(1) (5)
3.3V domain (n +1) x t
CPMCK
- 1
(3)
ns
1.8V domain (n +1) x t
CPMCK
- 1.5
(3)
ns
SMC
45
NRD Minimum Pulse Width
(2) (5)
3.3V domain
(2 x n +1) x 0.5 x t
CPMCK
-
1
(3)
ns
1.8V domain
(2 x n +1) x 0.5 x t
CPMCK
-
1
(3)
ns
Table 40-28. SAM7SE32 SMC Read Signals
Symbol Parameter Conditions Min Max Units
SMC
35
NRD High to NUB Change
3.3V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 1.5
(4)
ns
1.8V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 7
(4)
ns
SMC
36
NRD High to NLB/A0 Change
3.3V domain (h x t
CPMCK
) - 2
(4)
(h x t
CPMCK
)+ 1.5
(4)
ns
1.8V domain (h x t
CPMCK
) - 1.5
(4)
(h x t
CPMCK
)+ 6.5
(4)
ns
SMC
37
NRD High to A1-A22 Change
3.3V domain (h x t
CPMCK
) - 3
(4)
(h x t
CPMCK
)+ 3
(4)
ns
1.8V domain (h x t
CPMCK
) - 3
(4)
(h x t
CPMCK
)+ 8
(4)
ns
SMC
38
NRD High to Chip Select
Inactive
3.3V domain (h x t
CPMCK
) - 2.5
(4)
(h x t
CPMCK
)+ 2
(4)
ns
1.8V domain (h x t
CPMCK
) - 3
(4)
(h x t
CPMCK
)+ 2
(4)
ns
635
6222HATARM25-Jan-12
SAM7SE512/256/32
Notes: 1. Early Read Protocol.
2. Standard Read Protocol.
3. n = Number of standard Wait States inserted.
4. h = Number of Hold Cycles inserted.
5. Not applicable when Address to Chip Select Setup Cycles are inserted.
SMC
40
Data Setup before NRD High
3.3V domain 23.2 ns
1.8V domain 37 ns
SMC
41
Data Hold after NRD High
3.3V domain -0 ns
1.8V domain -0 ns
SMC
42
Data Setup before NCS High
3.3V domain 25.2 ns
1.8V domain 39 ns
SMC
43
Data Hold after NCS High
3.3V domain 0 ns
1.8V domain 0 ns
SMC
44
NRD Minimum Pulse Width
(1) (5)
3.3V domain (n +1) x t
CPMCK
- 2
(3)
ns
1.8V domain (n +1) x t
CPMCK
- 6
(3)
ns
SMC
45
NRD Minimum Pulse Width
(2) (5)
3.3V domain (2 x n +1) x 0.5 x t
CPMCK
- 2
(3)
ns
1.8V domain
(2 x n +1) x 0.5 x t
CPMCK
-
6.5
(3)
ns
Table 40-28. SAM7SE32 SMC Read Signals (Continued)
Symbol Parameter Conditions Min Max Units
636
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 40-8. SMC Signals in Memory Interface Mode
Notes: 1. Early Read Protocol
2. Standard Read Protocol with or without Setup and Hold Cycles.
N
R
D
(
1
)
N
R
D
(
2
)
N
C
S
N
W
A
I
T
A
1
-
A
2
2
D
0
-
D
1
5
R
e
a
d
N
W
R
D
0
-
D
1
5
t
o
W
r
i
t
e
N
U
B
/
N
L
B
/
A
0
S
M
C
4
0
S
M
C
4
1
S
M
C
4
4
S
M
C
4
5
S
M
C
1
9
S
M
C
2
1
S
M
C
1
8
S
M
C
1
7
S
M
C
1
5
S
M
C
1
6
S
M
C
2
6
S
M
C
3
8
S
M
C
3
7
S
M
C
3
5
S
M
C
3
6
S
M
C
8
S
M
C
3
5
S
M
C
3
6
S
M
C
3
7
S
M
C
3
8
S
M
C
4
0
S
M
C
4
1
S
M
C
4
1
S
M
C
4
4
S
M
C
4
5
S
M
C
2
7
S
M
C
2
2
S
M
C
2
0
S
M
C
3
5
S
M
C
3
6
S
M
C
3
7
S
M
C
3
8
S
M
C
4
0
S
M
C
4
5
S
M
C
2
0
S
M
C
2
3
S
M
C
2
7
637
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 40-9. SM Signals in LCD Interface Mode
Notes: 1. Standard Read Protocol only.
2. With Standard Wait States inserted only.
N
R
D
(
1
)
N
C
S
N
W
A
I
T
A
1
-
A
2
2
D
0
-
D
1
5
R
e
a
d
N
W
R
(
2
)
D
0
-
D
1
5
t
o
W
r
i
t
e
N
U
B
/
N
L
B
/
A
0
S
M
C
8
S
M
C
7
S
M
C
7
S
M
C
3
5
S
M
C
3
6
S
M
C
3
7
S
M
C
3
9
S
M
C
4
2
S
M
C
4
3
S
M
C
4
6
S
M
C
2
4
S
M
C
2
5
S
M
C
2
8
638
6222HATARM25-Jan-12
SAM7SE512/256/32
40.8.5 SDRAMC Signals
These timings are given for a maximum 30 pF load on SDCK and a maximum 50 pF load on the databus.
Table 40-29. SDRAMC Clock Signal
Symbol Parameter
Min Max
Units 1.8V Supply 3.3V Supply
1.8V
Supply 3.3V Supply
1/(t
CPSDCK
) SDRAM Controller Clock Frequency 24 48.2 MHz
t
CPSDCK
SDRAM Controller Clock Period 41.7 20.7 ns
Table 40-30. SAM7SE512/256 SDRAMC Signals
Symbol Parameter
Min Max
Units 1.8V Supply 3.3V Supply 1.8V Supply 3.3V Supply
SDRAMC
1
SDCKE High before SDCK Rising Edge 17.5 12 ns
SDRAMC
2
SDCKE Low after SDCK Rising Edge 22 9.5 ns
SDRAMC
3
SDCKE Low before SDCK Rising Edge 11 10 ns
SDRAMC
4
SDCKE High after SDCK Rising Edge 20.5 8 ns
SDRAMC
5
SDCS Low before SDCK Rising Edge 11 10.5 ns
SDRAMC
6
SDCS High after SDCK Rising Edge 20.5 7.5 ns
SDRAMC
7
RAS Low before SDCK Rising Edge 10.5 10 ns
SDRAMC
8
RAS High after SDCK Rising Edge 20.5 8 ns
SDRAMC
9
SDA10 Change before SDCK Rising Edge 10.5 10 ns
SDRAMC
10
SDA10 Change after SDCK Rising Edge 20.5 8 ns
SDRAMC
11
Address Change before SDCK Rising Edge 8.5 7.5 ns
SDRAMC
12
Address Change after SDCK Rising Edge 20 9 ns
SDRAMC
13
Bank Change before SDCK Rising Edge 9 8 ns
SDRAMC
14
Bank Change after SDCK Rising Edge 20.5 9 ns
SDRAMC
15
CAS Low before SDCK Rising Edge 10.5 10 ns
SDRAMC
16
CAS High after SDCK Rising Edge 20.5 8 ns
SDRAMC
17
DQM Change before SDCK Rising Edge 10 9.5 ns
SDRAMC
18
DQM Change after SDCK Rising Edge 20.5 9 ns
SDRAMC
19
D0-D15 in Setup before SDCK Rising Edge 16 12.5 ns
SDRAMC
20
D0-D15 in Hold after SDCK Rising Edge 3 2 ns
SDRAMC
21
D16-D31 in Setup before SDCK Rising Edge 16 12.5 ns
SDRAMC
22
D16-D31 in Hold after SDCK Rising Edge 3 2 ns
SDRAMC
23
SDWE Low before SDCK Rising Edge 10.5 10 ns
SDRAMC
24
SDWE High after SDCK Rising Edge 20.5 8 ns
SDRAMC
25
D0-D15 Out Valid before SDCK Rising Edge 6.5 5.5 ns
SDRAMC
26
D0-D15 Out Valid after SDCK Rising Edge 17 4.5 ns
SDRAMC
27
D16-D31 Out Valid before SDCK Rising Edge 6.5 5.5 ns
SDRAMC
28
D16-D31 Out Valid after SDCK Rising Edge 17 4.5 ns
639
6222HATARM25-Jan-12
SAM7SE512/256/32
Table 40-31. SAM7SE32 SDRAMC Signals
Symbol Parameter
Min Max
Units 1.8V Supply 3.3V Supply 1.8V Supply 3.3V Supply
SDRAMC
1
SDCKE High before SDCK Rising Edge 11.5 6.5 ns
SDRAMC
2
SDCKE Low after SDCK Rising Edge 23.5 11.5 ns
SDRAMC
3
SDCKE Low before SDCK Rising Edge 10.5 5.5 ns
SDRAMC
4
SDCKE High after SDCK Rising Edge 22.5 11 ns
SDRAMC
5
SDCS Low before SDCK Rising Edge 11.5 7.5 ns
SDRAMC
6
SDCS High after SDCK Rising Edge 22 10.5 ns
SDRAMC
7
RAS Low before SDCK Rising Edge 12.5 8 ns
SDRAMC
8
RAS High after SDCK Rising Edge 22 10 ns
SDRAMC
9
SDA10 Change before SDCK Rising Edge 12.5 8 ns
SDRAMC
10
SDA10 Change after SDCK Rising Edge 22 10 ns
SDRAMC
11
Address Change before SDCK Rising Edge 10 5 ns
SDRAMC
12
Address Change after SDCK Rising Edge 22 10.5 ns
SDRAMC
13
Bank Change before SDCK Rising Edge 9.5 4.5 ns
SDRAMC
14
Bank Change after SDCK Rising Edge 22.5 10.5 ns
SDRAMC
15
CAS Low before SDCK Rising Edge 12 7 ns
SDRAMC
16
CAS High after SDCK Rising Edge 22 10.5 ns
SDRAMC
17
DQM Change before SDCK Rising Edge 8.5 4.5 ns
SDRAMC
18
DQM Change after SDCK Rising Edge 22 10.5 ns
SDRAMC
19
D0-D15 in Setup before SDCK Rising Edge 8.5 8.5 ns
SDRAMC
20
D0-D15 in Hold after SDCK Rising Edge 2 1 ns
SDRAMC
21
D16-D31 in Setup before SDCK Rising
Edge
8.5 8.5 ns
SDRAMC
22
D16-D31 in Hold after SDCK Rising Edge 2 1 ns
SDRAMC
23
SDWE Low before SDCK Rising Edge 12 7.5 ns
SDRAMC
24
SDWE High after SDCK Rising Edge 22 10.5 ns
SDRAMC
25
D0-D15 Out Valid before SDCK Rising Edge 6.5 2 ns
SDRAMC
26
D0-D15 Out Valid after SDCK Rising Edge 20 9 ns
SDRAMC
27
D16-D31 Out Valid before SDCK Rising
Edge
6.5 2 ns
SDRAMC
28
D16-D31 Out Valid after SDCK Rising Edge 20 9 ns
640
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 40-10. SDRAMC Signals
RAS
A0 - A9,
A11 - A13
D0 - D15
Read
SDCK
SDA10
D0 - D15
to Write
SDRAMC
1
SDCKE
SDRAMC
2
SDRAMC
3
SDRAMC
4
SDCS
SDRAMC
5
SDRAMC
6
SDRAMC
5
SDRAMC
6
SDRAMC
5
SDRAMC
6
SDRAMC
7
SDRAMC
8
CAS
SDRAMC
15
SDRAMC
16
SDRAMC
15
SDRAMC
16
SDWE
SDRAMC
23
SDRAMC
24
SDRAMC
9
SDRAMC
10
SDRAMC
9
SDRAMC
10
SDRAMC
9
SDRAMC
10
SDRAMC
11
SDRAMC
12
SDRAMC
11
SDRAMC
12
SDRAMC
11
SDRAMC
12
BA0/BA1
SDRAMC
13
SDRAMC
14
SDRAMC
13
SDRAMC
14
SDRAMC
13
SDRAMC
14
SDRAMC
17
SDRAMC
18
SDRAMC
17
SDRAMC
18
DQM0 -
DQM3
SDRAMC
19
SDRAMC
20
D16 - D31
Read
SDRAMC
21
SDRAMC
22
SDRAMC
25
SDRAMC
26
D16 - D31
to Write
SDRAMC
27
SDRAMC
28
641
6222HATARM25-Jan-12
SAM7SE512/256/32
40.8.6 Embedded Flash Characteristics
The maximum operating frequency is given in Table 40-32 and Table 40-33 but is limited by the Embedded Flash access
time when the processor is fetching code out of it. Table 40-32 and Table 40-33 give the device maximum operating fre-
quency depending on the FWS field of the MC_FMR register. This field defines the number of wait states required to
access the Embedded Flash Memory.
Notes: 1. FWS = Flash Wait States
2. It is not necessary to use 3 wait states because the Flash can operate at maximum frequency with only 2 wait states.
Notes: 1. FWS = Flash Wait States
2. It is not necessary to use 2 or 3 wait states because the Flash can operate at maximum frequency with only 1 wait state.
Table 40-32. Embedded Flash Wait States (VDDCORE = 1.65V)
FWS
(1)
Read Operations Maximum Operating Frequency (MHz)
0 1 cycle 25
1 2 cycles 44
2 3 cycles 48.2
3
(2)
4 cycles 48.2
Table 40-33. Embedded Flash Wait States (VDDCORE = 1.8V)
FWS
(1)
Read Operations Maximum Operating Frequency (MHz)
0 1 cycle 30
1 2 cycles 55
2
(2)
3 cycles 55
3
(2)
4 cycles 55
Table 40-34. AC Flash Characteristics
Parameter Conditions Min Max Units
Program Cycle Time
per page including auto-erase 6 ms
per page without auto-erase 3 ms
Full Chip Erase 15 ms
642
6222HATARM25-Jan-12
SAM7SE512/256/32
40.8.7 JTAG/ICE Timings
40.8.7.1 ICE Interface Signals
Note: 1. V
VDDIO
from 3.0V to 3.6V, maximum external capacitor = 40pF.
Figure 40-11. ICE Interface Signals
Table 40-35. ICE Interface Timing Specification
Symbol Parameter Conditions Min Max Units
ICE
0
TCK Low Half-period
(1)
51 ns
ICE
1
TCK High Half-period
(1)
51 ns
ICE
2
TCK Period
(1)
102 ns
ICE
3
TDI, TMS, Setup before TCK High
(1)
0 ns
ICE
4
TDI, TMS, Hold after TCK High
(1)
3 ns
ICE
5
TDO Hold Time
(1)
13 ns
ICE
6
TCK Low to TDO Valid
(1)
20 ns
TCK
ICE
3
ICE
4
ICE
6
TMS/TDI
TDO
ICE
5
ICE
1
ICE
2
ICE
0
643
6222HATARM25-Jan-12
SAM7SE512/256/32
40.8.7.2 JTAG Interface Signals
Note: 1. V
VDDIO
from 3.0V to 3.6V, maximum external capacitor = 40pF.
Table 40-36. JTAG Interface Timing specification
Symbol Parameter Conditions Min Max Units
JTAG
0
TCK Low Half-period
(1)
6.5 ns
JTAG
1
TCK High Half-period
(1)
5.5 ns
JTAG
2
TCK Period
(1)
12 ns
JTAG
3
TDI, TMS Setup before TCK High
(1)
2 ns
JTAG
4
TDI, TMS Hold after TCK High
(1)
3 ns
JTAG
5
TDO Hold Time
(1)
4 ns
JTAG
6
TCK Low to TDO Valid
(1)
16 ns
JTAG
7
Device Inputs Setup Time
(1)
0 ns
JTAG
8
Device Inputs Hold Time
(1)
3 ns
JTAG
9
Device Outputs Hold Time
(1)
6 ns
JTAG
10
TCK to Device Outputs Valid
(1)
18 ns
644
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 40-12. JTAG Interface Signals
TCK
JTAG
9
TMS/TDI
TDO
Device
Outputs
JTAG
5
JTAG
4
JTAG
3
JTAG
0
JTAG
1
JTAG
2
JTAG
10
Device
Inputs
JTAG
8 JTAG
7
JTAG
6
645
6222HATARM25-Jan-12
SAM7SE512/256/32
41. SAM7SE512/256/32 Mechanical Characteristics
41.1 Package Drawings
Figure 41-1. LQFP128 Package Drawing
This package respects the recommendations of the NEMI User Group.
Table 41-1. Device and LQFP Package Maximum Weight
SAM7SE512/256/32 800 mg
Table 41-2. Package Reference
JEDEC Drawing Reference MS-026
JESD97 Classification e3
Table 41-3. LQFP Package Characteristics
Moisture Sensitivity Level 3
646
6222HATARM25-Jan-12
SAM7SE512/256/32
Figure 41-2. 144-ball LFBGA Package Drawing
This package respects the recommendations of the NEMI User Group.
All dimensions are in mm
Table 41-4. Device and LFBGA Package Maximum Weight
SAM7SE512/256/32 mg
Table 41-5. Package Reference
JEDEC Drawing Reference MS-026
JESD97 Classification e1
Table 41-6. LFBGA Package Characteristics
Moisture Sensitivity Level 3
647
6222HATARM25-Jan-12
SAM7SE512/256/32
41.2 Soldering Profile
Table 41-7 gives the recommended soldering profile from J-STD-020C.
Note: The package is certified to be backward compatible with Pb/Sn soldering profile.
A maximum of three reflow passes is allowed per component.
41.3 Marking
All devices are marked with the Atmel logo and the ordering code.
Additional marking has the following format:
where
YY: manufactory year
WW: manufactory week
V: revision
XXXXXXXXX: lot number
Table 41-7. Soldering Profile
Profile Feature Green Package
Average Ramp-up Rate (217C to Peak) 3 C/sec. max.
Preheat Temperature 175C 25C 180 sec. max.
Temperature Maintained Above 217C 60 sec. to 150 sec.
Time within 5 C of Actual Peak Temperature 20 sec. to 40 sec.
Peak Temperature Range 260 C
Ramp-down Rate 6 C/sec. max.
Time 25 C to Peak Temperature 8 min. max.
YYWW V
XXXXXXXXX
ARM
648
6222HATARM25-Jan-12
SAM7SE512/256/32
42. SAM7SE512/256/32 Ordering Information
Table 42-1. Ordering Information
Ordering Code MRL Package Package Type
Temperature
Operating Range
AT91SAM7SE512B-AU B LQFP128 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE256B-AU B LQFP128 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE32B-AU B LQFP128 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE512B-CU B LFBGA144 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE256B-CU B LFBGA144 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE32B-CU B LFBGA144 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE512-AU A LQFP128 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE256-AU A LQFP128 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE32-AU A LQFP128 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE512-CU A LFBGA144 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE256-CU A LFBGA144 Green
Industrial
(-40 C to 85 C)
AT91SAM7SE32-CU A LFBGA144 Green
Industrial
(-40 C to 85 C)
649
6222HATARM25-Jan-12
SAM7SE512/256/32
43. SAM7SE512/256/32 Errata
43.1 Errata Summary by Product and Revision or Manufacturing Number
Table 43-1. Errata Summary Table
Part
AT91SAM7SE
Product Revision
or Manufacturing Number
Errata
S
A
M
7
S
E
5
1
2
/
2
5
6
/
3
2
r
e
v
A
S
A
M
7
S
E
5
1
2
/
2
5
6
r
e
v
B
S
A
M
7
S
E
3
2
r
e
v
B
ADC DRDY Bit Cleared X X X
ADC DRDY not Cleared on Disable X
ADC DRDY Possibly Skipped due to CDR Read X
ADC Possible Skip on DRDY when Disabling a Channel X
ADC GOVRE Bit is not Updated X X X
ADC GOVRE Bit is Not Set when Reading CDR X
ADC GOVRE Bit is Not Set when Disabling a Channel X
ADC OVRE Flag Behavior X X X
ADC EOC Set although Channel Disabled X
ADC Spurious Clear of EOC Flag X
ADC Sleep Mode X X X
EFC Embedded Flash Access Time X
FLASH
Power consumption with data read access with multiple load of two
words
X X X
PWM Update when PWM_CCNTx = 0 or 1 X X X
PWM Update when PWM_CPRDx = 0 X X X
PWM Counter Start Value X X X
PWM Behavior of CHIDx Status Bits in the PWM_SR Register X
RTT Possible Event Loss when Reading RTT_SR X
SDRAMC PDC buffer in 16-bit SDRAM while the Core Accesses SDRAM X
SPI Software Reset Must be Written Twice X
SPI Baudrate Set to 1 X
SPI Bad Serial Clock Generation on 2nd Chip Select X X X
SSC Periodic Transmission Limitations in Master Mode X
SSC Transmitter Limitations in Slave Mode X X X
SSC Transmitter Limitations in Slave Mode X
SSC Last RK Clock Cycle when RK Outputs a Clock during Data Transfer X X X
650
6222HATARM25-Jan-12
SAM7SE512/256/32
SSC First RK Clock Cycle when RK Outputs a Clock during Data Transfer X X X
TWI Switching from Slave to Master Mode X
USART CTS in Hardware Handshaking X
USART Two Characters Sent with Hardware Handshaking X
USART RXBRK Flag Error in Asynchronous Mode X
USART DCD is Active High instead of Low X
Table 43-1. Errata Summary Table (Continued)
Part
AT91SAM7SE
Product Revision
or Manufacturing Number
Errata
S
A
M
7
S
E
5
1
2
/
2
5
6
/
3
2
r
e
v
A
S
A
M
7
S
E
5
1
2
/
2
5
6
r
e
v
B
S
A
M
7
S
E
3
2
r
e
v
B
651
6222HATARM25-Jan-12
SAM7SE512/256/32
43.2 SAM7SE512/256/32 Errata - Rev. A Parts
Refer to Section 41.3 Marking .
Notes: 1. AT91SAM7SE512 Revision A chip ID is 0x272A 0A40.
2. AT91SAM7SE256 Revision A chip ID is 0x272A 0940.
3. AT91SAM7SE32 Revision A chip ID is 0x2728 0340.
43.2.1 Analog-to-Digital Converter (ADC)
43.2.1.1 ADC: DRDY Bit Cleared
The DRDY Flag should be cleared only after a read of ADC_LCDR (Last Converted Data Regis-
ter). A read of any ADC_CDRx register (Channel Data Register) automatically clears the DRDY
flag.
Problem Fix/Workaround
None.
43.2.1.2 ADC: DRDY not Cleared on Disable
When reading LCDR at the same instant as an end of conversion, with DRDY already active,
DRDY is kept active regardless of the enable status of the current channel. This sets DRDY,
whereas new data is not stored.
Problem Fix/Workaround
None.
43.2.1.3 ADC: DRDY Possibly Skipped due to CDR Read
Reading CDR for channel "y" at the same instant as an end of conversion on channel "x" with
EOC[x] already active, leads to skipping to set the DRDY flag if channel "x" is enabled.
Problem Fix/Workaround
Use of DRDY functionality with access to CDR registers should be avoided.
43.2.1.4 ADC: Possible Skip on DRDY when Disabling a Channel
DRDY does not rise when disabling channel "y" at the same time as an end of "x" channel con-
version, although data is stored into CDRx and LCDR.
Problem Fix/Workaround
None.
43.2.1.5 ADC: GOVRE Bit is Not Updated
Read of the Status Register at the same instant as an end of conversion leads to skipping the
update of the GOVRE (general overrun) flag. GOVRE is neither reset nor set.
For example, if reading the status while an end of conversion is occurring and:
1. GOVRE is active but DRDY is inactive, does not correspond to a new general overrun
condition but the GOVRE flag is not reset.
2. GOVRE is inactive but DRDY is active, does correspond to a new general overrun con-
dition but the GOVRE flag is not set.
Problem Fix/Workaround
None.
652
6222HATARM25-Jan-12
SAM7SE512/256/32
43.2.1.6 ADC: GOVRE Bit is not Set when Reading CDR
When reading CDRy (Channel Data Register y) at the same instant as an end of conversion on
channel "x" with the following conditions:
EOC[x] already active,
DRDY already active,
GOVRE inactive,
previous data stored in LCDR being neither data from channel "y", nor data from channel "x".
GOVRE should be set but is not.
Problem Fix/Workaround
None.
43.2.1.7 ADC: GOVRE Bit is not Set when Disabling a Channel
When disabling channel "y" at the same instant as an end of conversion on channel "x", EOC[x]
and DRDY being already active, GOVRE does not rise.
Note: OVRE[x] rises as expected.
Problem Fix/Workaround
None.
43.2.1.8 ADC: OVRE Flag Behavior
When the OVRE flag (on channel i) has been set but the related EOC status (of channel i) has
been cleared (by a read of CDRi or LCDR), reading the Status register at the same instant as an
end of conversion (causing the set of EOC status on channel i), does not lead to a reset of the
OVRE flag (on channel i) as expected.
Problem Fix/Workaround
None.
43.2.1.9 ADC: EOC Set although Channel Disabled
If a channel is disabled while a conversion is running and if a read of CDR is performed at the
same time as an end of conversion of any channel, the EOC of the channel with the conversion
running may rise (whereas it has been disabled).
Problem Fix/Workaround
Do not take into account the EOC of a disabled channel
43.2.1.10 ADC: Spurious Clear of EOC Flag
If "x" and "y" are two successively converted channels and "z" is yet another enabled channel
("z" being neither "x" nor "y"), reading CDR on channel "z" at the same instant as an end of con-
version on channel "y" automatically clears EOC[x] instead of EOC[z].
Problem Fix/Workaround
None.
43.2.1.11 ADC: Sleep Mode
If Sleep mode is activated while there is no activity (no conversion is being performed), it will
take effect only after a conversion occurs.
653
6222HATARM25-Jan-12
SAM7SE512/256/32
Problem Fix/Workaround
To activate sleep mode as soon as possible, it is recommended to write successively, ADC
Mode Register (SLEEP) then ADC Control Register (START bit field); to start an analog-to-digi-
tal conversion, put ADC into sleep mode at the end of this conversion.
43.2.2 Flash Memory
43.2.2.1 Flash: Power Consumption with data read access with multiple load of two words
When no Wait State (FWS = 0) is programmed and when data read access is performed with a
multiple load of two words, the internal Flash may stay in read mode.
It implies a potential increase of power consumption on VDDCORE (around 2 mA). Note that it
does not concern the program execution; thus, no issue is present when the program is fetching
out of Flash.
Problem Fix/Workaround
2 workarounds are possible:
Add one Wait State when performing these data read accesses (FWS =1)
After the multiple load, perform a single read data access to an address different from the
previous address accesses.
654
6222HATARM25-Jan-12
SAM7SE512/256/32
43.2.3 Pulse Width Modulation Controller (PWM)
43.2.3.1 PWM: Update when PWM_CCNTx = 0 or 1
If the Channel Counter Register value is 0 or 1, the Channel Period Register or Channel Duty
Cycle Register is directly modified when writing the Channel Update Register.
Problem Fix/Workaround
Check the Channel Counter Register before writing the Channel Update Register.
43.2.3.2 PWM: Update when PWM_CPRDx = 0
When the Channel Period Register equals 0, the period update is not operational.
Problem Fix/Workaround
Do not write 0 in the Channel Period Register.
43.2.3.3 PWM: Counter Start Value
In left aligned mode, the first start value of the counter is 0. For the other periods, the counter
starts at 1.
Problem Fix/Workaround
None.
43.2.3.4 PWM: Behavior of CHIDx Status Bits in the PWM_SR Register
There is an erratic behavior of the CHIDx status bit in the PWM_SR Register. When a channel is
disabled by writing in the PWM_DIS Register just after enabling it (before completion of a Clock
Period of the clock selected for the channel), the PWM line is internally disabled but the CHIDx
status bit in the PWM_SR stays at 1.
Problem Fix/Workaround
Do not disable a channel before completion of one period of the selected clock.
43.2.4 Real-Time Timer (RTT)
43.2.4.1 RTT: Possible Event Loss when Reading RTT_SR
If an event (RTTINC or ALMS) occurs within the same slow clock cycle when RTT_SR is read,
the corresponding bit might be cleared. This might lead to the loss of this event.
Problem Fix/Workaround
The software must handle RTT event as interrupt and should not poll RTT_SR.
43.2.5 SDRAM Controller (SDRAMC)
43.2.5.1 SDRAMC: PDC Buffer in 16-bit SDRAM while the Core Accesses SDRAM
When the SAM7SE interfaces with 16-bit SDRAM memory and the processor accesses the
SDRAM, either for instruction fetch or data read/write, the data transferred by the PDC from
SDRAM buffers to the peripherals might be corrupted. Transfers from peripherals to SDRAM
buffers are not affected.
Problem Fix/Workaround
Map the transmit PDC buffers in internal SRAM or Flash.
655
6222HATARM25-Jan-12
SAM7SE512/256/32
43.2.6 Serial Peripheral Interface (SPI)
43.2.6.1 SPI: Baudrate Set to 1
When the Baudrate is set to 1 (so, the serial clock frequency equals the master clock), and when
the BITS field (number of bits to be transmitted) in SPI_CSRx equals an odd value (in this case
9, 11, 13 or 15), an additional pulse will be generated on SPCK.
It does not occur when the BITS field is equal to 8, 10, 12, 14 or 16 and the Baudrate is equal
to 1.
Problem Fix/Workaround
None.
43.2.6.2 SPI: Bad Serial Clock Generation on 2nd Chip Select
There is a bad Serial clock generation on the 2nd chip select when SCBR = 1, CPOL = 1 and
NCPHA = 0.
This occurs using SPI with the following conditions:
Master Mode
CPOL = 1 and NCPHA = 0
Multiple chip selects are used with one transfer with Baud rate (SCBR) equal to 1 (i.e., when
serial clock frequency equals the system clock frequency); the other transfers set with SCBR
are not equal to 1.
Transmitting with the slowest chip select and then with the fastest one, then an additional
pulse is generated on output SPCK during the second transfer.
Problem Fix/Workaround
Do not use a multiple Chip Select configuration where at least one SCRx register is configured
with SCBR = 1 and the others differ from 1 if NCPHA = 0 and CPOL = 1.
If all chip selects are configured with Baudrate = 1, the issue does not appear.
43.2.6.3 SPI: Software Reset Must Be Written Twice
If a software reset (SWRST in the SPI control register) is performed, the SPI may not work prop-
erly (the clock is enabled before the chip select).
Problem Fix/Workaround
The SPI Control Register field SWRST (Software Reset) needs to be written twice to be correctly
set.
43.2.7 Synchronous Serial Controller (SSC)
43.2.7.1 SSC: Periodic Transmission Limitations in Master Mode
If the Least Significant Bit is sent first (MSBF = 0), the first TAG during the frame synchro is not
sent.
Problem Fix/Workaround
None.
43.2.7.2 SSC: Transmitter Limitations in Slave Mode
If TK is programmed as an output and TF is programmed as an input, it is impossible to emit
data when the starting edge (rising or falling) of synchro has a Start Delay equal to zero.
656
6222HATARM25-Jan-12
SAM7SE512/256/32
Problem Fix/Workaround
None.
43.2.7.3 SSC: Transmitter Limitations in Slave Mode
If TK is programmed as an input and TF is programmed as an output and requested to be set to
low/high during data emission, the Frame Synchro signal is generated one bit clock period after
the data start and one data bit is lost. This problem does not exist when generating a periodic
synchro.
Problem Fix/Workaround
The data need to be delayed for one bit clock period with an external assembly. In the following
schematic, TD, TK and NRST are SAM7SE signals, TXD is the delayed data to connect to the
device.
43.2.7.4 SSC: Last RK Clock Cycle when RK Outputs a Clock During Data Transfer
When the SSC receiver is used with the following conditions:
the internal clock divider is used (CKS = 0 and DIV different from 0)
RK pin set as output and provides the clock during data transfer (CKO = 2)
data sampled on RK falling edge (CKI = 0),
At the end of the data, the RK pin is set in high impedance which might be seen as an unex-
pected clock cycle.
Problem Fix/Workaround
Enable the pull-up on RK pin.
43.2.7.5 SSC: First RK Clock Cycle when RK Outputs a Clock During Data Transfer
When the SSC receiver is used with the following conditions:
RX clock is divided clock (CKS = 0 and DIV different from 0)
RK pin set as output and provides the clock during data transfer (CKO = 2)
data sampled on RK falling edge (CKI = 0),
657
6222HATARM25-Jan-12
SAM7SE512/256/32
The first clock cycle time generated by the RK pin is equal to MCK/(2 x (value +1)).
Problem Fix/Workaround
None.
43.2.8 Two Wire Interface (TWI)
43.2.8.1 TWI: Switching from Slave to Master Mode
When the TWI is set in slave mode and if a master write access is performed, the start event is
correctly generated but the SCL line is stuck at 1, so no transfer is possible.
Problem Fix/Workaround
Two software workarounds are possible:
1. Perform a software reset before going to master mode (TWI must be reconfigured).
2. Perform a slave read access before switching to master mode.
43.2.9 Universal Synchronous Asynchronous Receiver Transmitter (USART)
43.2.9.1 USART: CTS in Hardware Handshaking
When Hardware Handshaking is used and if CTS goes high near the end of the starting bit, a
character can be lost.
CTS must not go high during a time slot occurring between 2 Master Clock periods before the
starting bit and 16 Master Clock periods after the rising edge of the starting bit.
Problem Fix/Workaround
None.
43.2.9.2 USART: Two Characters Sent with Hardware Handshaking
When Hardware Handshaking is used and if CTS goes high during the TX of a character and if
the holding register (US_THR) is not empty, the content of the US_THR will also be transmitted.
Problem Fix/Workaround
Do not use the PDC in transmit mode and do not fill US_THR before TXRDY is set to 1.
43.2.9.3 USART: DCD is Active High Instead of Low
DCD signal is active at High level in USART block (Modem Mode).
DCD should be active at Low level.
Problem Fix/Workaround
Add an inverter.
43.2.9.4 USART: RXBRK Flag Error in Asynchronous Mode
In Receiver mode, when 2 characters are consecutive (without a timeguard in between), the
RXBRK is not taken into account. As a result, the RXBRK flag is not enabled correctly, and the
frame error flag is set.
Problem Fix/Workaround
Constraints on the Transmitter device connected to the AT91 USART Receiver:
658
6222HATARM25-Jan-12
SAM7SE512/256/32
The Transmitter may use the timeguard feature, or send 2 STOP conditions. Only 1 STOP con-
dition is taken into account by the Receiver state machine; after this STOP condition, as there is
no valid data, the Receiver state machine will go in idle mode and will enable the RXBRK
condition.
659
6222HATARM25-Jan-12
SAM7SE512/256/32
43.3 SAM7SE512/256 Errata - Rev. B Parts
Refer to Section 41.3 Marking .
Notes: 1. AT91SAM7SE512 Revision B chip ID is 0x272A 0A41.
2. AT91SAM7SE256 Revision B chip ID is 0x272A 0941.
43.3.1 Analog-to-Digital Converter (ADC)
43.3.1.1 ADC: DRDY Bit Cleared
The DRDY Flag should be cleared only after a read of ADC_LCDR (Last Converted Data Regis-
ter). A read of any ADC_CDRx register (Channel Data Register) automatically clears the DRDY
flag.
Problem Fix/Workaround
None.
43.3.1.2 ADC: GOVRE Bit is Not Updated
Read of the Status Register at the same instant as an end of conversion leads to skipping the
update of the GOVRE (general overrun) flag. GOVRE is neither reset nor set.
For example, if reading the status while an end of conversion is occurring and:
1. GOVRE is active but DRDY is inactive, does not correspond to a new general overrun
condition but the GOVRE flag is not reset.
2. GOVRE is inactive but DRDY is active, does correspond to a new general overrun con-
dition but the GOVRE flag is not set.
Problem Fix/Workaround
None.
43.3.1.3 ADC: OVRE Flag Behavior
When the OVRE flag (on channel i) has been set but the related EOC status (of channel i) has
been cleared (by a read of CDRi or LCDR), reading the Status register at the same instant as an
end of conversion (causing the set of EOC status on channel i), does not lead to a reset of the
OVRE flag (on channel i) as expected.
Problem Fix/Workaround
None.
43.3.1.4 ADC: Sleep Mode
If Sleep mode is activated while there is no activity (no conversion is being performed), it will
take effect only after a conversion occurs.
Problem Fix/Workaround
To activate sleep mode as soon as possible, it is recommended to write successively, ADC
Mode Register (SLEEP) then ADC Control Register (START bit field); to start an analog-to-digi-
tal conversion, put ADC into sleep mode at the end of this conversion.
660
6222HATARM25-Jan-12
SAM7SE512/256/32
43.3.2 Flash Controller
43.3.2.1 EFC : Embedded Flash Access Time
The embedded Flash maximum access time is lower than expected. The tables below show the
frequencies:
Notes: 1. FWS = Flash Wait States
2. It is not necessary to use 3 wait states because the Flash can operate at maximum with only 2
wait states.
Notes: 1. FWS = Flash Wait States
2. It is not necessary to use 3 wait states because the Flash can operate at maximum with only 2
wait states.
Problem Fix/Workaround
Set the number of Wait states (FWS) according to the frequency requirements described in the
errata.
43.3.3 Flash Memory
43.3.3.1 Flash: Power Consumption with data read access with multiple load of two words
When no Wait State (FWS = 0) is programmed and when data read access is performed with a
multiple load of two words, the internal Flash may stay in read mode.
It implies a potential increase of power consumption on VDDCORE (around 2 mA). Note that it
does not concern the program execution; thus, no issue is present when the program is fetching
out of Flash.
Problem Fix/Workaround
2 workarounds are possible:
Add one Wait State when performing these data read accesses (FWS =1)
After the multiple load, perform a single read data access to an address different from the
previous address accesses.
Table 43-2. Embedded Flash Wait State VDDCORE set at 1.65V
FWS
(1)
Read Operations Maximum Operating Frequency (MHz)
0 1 cycle 20
1 2 cycles 40
2 3 cycles 48.2
3
(2)
4 cycles 48.2
Table 43-3. Embedded Flash Wait State VDDCORE set at 1.80V
FWS
(1)
Read Operations Maximum Operating Frequency (MHz)
0 1 cycle 21.5
1 2 cycles 43
2 3 cycles 55
3
(2)
4 cycles 55
661
6222HATARM25-Jan-12
SAM7SE512/256/32
43.3.4 Pulse Width Modulation Controller (PWM)
43.3.4.1 PWM: Update when PWM_CCNTx = 0 or 1
If the Channel Counter Register value is 0 or 1, the Channel Period Register or Channel Duty
Cycle Register is directly modified when writing the Channel Update Register.
Problem Fix/Workaround
Check the Channel Counter Register before writing the Channel Update Register.
43.3.4.2 PWM: Update when PWM_CPRDx = 0
When the Channel Period Register equals 0, the period update is not operational.
Problem Fix/Workaround
Do not write 0 in the Channel Period Register.
43.3.4.3 PWM: Counter Start Value
In left aligned mode, the first start value of the counter is 0. For the other periods, the counter
starts at 1.
Problem Fix/Workaround
None.
43.3.5 Serial Peripheral Interface (SPI)
43.3.5.1 SPI: Bad Serial Clock Generation on 2nd Chip Select
There is a bad Serial clock generation on the 2nd chip select when SCBR = 1, CPOL = 1 and
NCPHA = 0.
This occurs using SPI with the following conditions:
Master Mode
CPOL = 1 and NCPHA = 0
Multiple chip selects are used with one transfer with Baud rate (SCBR) equal to 1 (i.e., when
serial clock frequency equals the system clock frequency); the other transfers set with SCBR
are not equal to 1.
Transmitting with the slowest chip select and then with the fastest one, then an additional
pulse is generated on output SPCK during the second transfer.
Problem Fix/Workaround
Do not use a multiple Chip Select configuration where at least one SCRx register is configured
with SCBR = 1 and the others differ from 1 if NCPHA = 0 and CPOL = 1.
If all chip selects are configured with Baudrate = 1, the issue does not appear.
43.3.6 Synchronous Serial Controller (SSC)
43.3.6.1 SSC: Transmitter Limitations in Slave Mode
If TK is programmed as output and TF is programmed as input, it is impossible to emit data
when the starting edge (rising or falling) of synchro has a Start Delay equal to zero.
Problem Fix/Workaround
None.
662
6222HATARM25-Jan-12
SAM7SE512/256/32
43.3.6.2 SSC: Last RK Clock Cycle when RK Outputs a Clock During Data Transfer
When the SSC receiver is used with the following conditions:
the internal clock divider is used (CKS = 0 and DIV different from 0)
RK pin set as output and provides the clock during data transfer (CKO = 2)
data sampled on RK falling edge (CKI = 0),
At the end of the data, the RK pin is set in high impedance which might be seen as an unex-
pected clock cycle.
Problem Fix/Workaround
Enable the pull-up on RK pin.
43.3.6.3 SSC: First RK Clock Cycle when Rk Outputs a Clock During Data Transfer
When the SSC receiver is used with the following conditions:
RX clock is divided clock (CKS = 0 and DIV different from 0)
RK pin set as output and provides the clock during data transfer (CKO = 2)
data sampled on RK falling edge (CKI = 0)
The first clock cycle time generated by the RK pin is equal to MCK/(2 x (value +1)).
Problem Fix/Workaround
None.
663
6222HATARM25-Jan-12
SAM7SE512/256/32
43.4 SAM7SE32 Errata - Rev. B Parts
Refer to Section 41.3 Marking .
Notes: 1. AT91SAM7SE32 Revision B chip ID is 0x2728 0341.
43.4.1 Analog-to-Digital Converter (ADC)
43.4.1.1 ADC: DRDY Bit Cleared
The DRDY Flag should be cleared only after a read of ADC_LCDR (Last Converted Data Regis-
ter). A read of any ADC_CDRx register (Channel Data Register) automatically clears the DRDY
flag.
Problem Fix/Workaround
None.
43.4.1.2 ADC: GOVRE Bit is Not Updated
Read of the Status Register at the same instant as an end of conversion leads to skipping the
update of the GOVRE (general overrun) flag. GOVRE is neither reset nor set.
For example, if reading the status while an end of conversion is occurring and:
1. GOVRE is active but DRDY is inactive, does not correspond to a new general overrun
condition but the GOVRE flag is not reset.
2. GOVRE is inactive but DRDY is active, does correspond to a new general overrun con-
dition but the GOVRE flag is not set.
Problem Fix/Workaround
None.
43.4.1.3 ADC: OVRE Flag Behavior
When the OVRE flag (on channel i) has been set but the related EOC status (of channel i) has
been cleared (by a read of CDRi or LCDR), reading the Status register at the same instant as an
end of conversion (causing the set of EOC status on channel i), does not lead to a reset of the
OVRE flag (on channel i) as expected.
Problem Fix/Workaround
None.
43.4.1.4 ADC: Sleep Mode
If Sleep mode is activated while there is no activity (no conversion is being performed), it will
take effect only after a conversion occurs.
Problem Fix/Workaround
To activate sleep mode as soon as possible, it is recommended to write successively, ADC
Mode Register (SLEEP) then ADC Control Register (START bit field); to start an analog-to-digi-
tal conversion, put ADC into sleep mode at the end of this conversion.
43.4.2 Flash Memory
43.4.2.1 Flash: Power Consumption with data read access with multiple load of two words
When no Wait State (FWS = 0) is programmed and when data read access is performed with a
multiple load of two words, the internal Flash may stay in read mode.
664
6222HATARM25-Jan-12
SAM7SE512/256/32
It implies a potential increase of power consumption on VDDCORE (around 2 mA). Note that it
does not concern the program execution; thus, no issue is present when the program is fetching
out of Flash.
Problem Fix/Workaround
2 workarounds are possible:
Add one Wait State when performing these data read accesses (FWS =1)
After the multiple load, perform a single read data access to an address different from the
previous address accesses.
43.4.3 Pulse Width Modulation Controller (PWM)
43.4.3.1 PWM: Update when PWM_CCNTx = 0 or 1
If the Channel Counter Register value is 0 or 1, the Channel Period Register or Channel Duty
Cycle Register is directly modified when writing the Channel Update Register.
Problem Fix/Workaround
Check the Channel Counter Register before writing the Channel Update Register.
43.4.3.2 PWM: Update when PWM_CPRDx = 0
When the Channel Period Register equals 0, the period update is not operational.
Problem Fix/Workaround
Do not write 0 in the Channel Period Register.
43.4.3.3 PWM: Counter Start Value
In left aligned mode, the first start value of the counter is 0. For the other periods, the counter
starts at 1.
Problem Fix/Workaround
None.
43.4.4 Serial Peripheral Interface (SPI)
43.4.4.1 SPI: Bad Serial Clock Generation on 2nd Chip Select
There is a bad Serial clock generation on the 2nd chip select when SCBR = 1, CPOL = 1 and
NCPHA = 0.
This occurs using SPI with the following conditions:
Master Mode
CPOL = 1 and NCPHA = 0
Multiple chip selects are used with one transfer with Baud rate (SCBR) equal to 1 (i.e., when
serial clock frequency equals the system clock frequency); the other transfers set with SCBR
are not equal to 1.
Transmitting with the slowest chip select and then with the fastest one, then an additional
pulse is generated on output SPCK during the second transfer.
Problem Fix/Workaround
Do not use a multiple Chip Select configuration where at least one SCRx register is configured
with SCBR = 1 and the others differ from 1 if NCPHA = 0 and CPOL = 1.
If all chip selects are configured with Baudrate = 1, the issue does not appear.
665
6222HATARM25-Jan-12
SAM7SE512/256/32
43.4.5 Synchronous Serial Controller (SSC)
43.4.5.1 SSC: Transmitter Limitations in Slave Mode
If TK is programmed as output and TF is programmed as input, it is impossible to emit data
when the starting edge (rising or falling) of synchro has a Start Delay equal to zero.
Problem Fix/Workaround
None.
43.4.5.2 SSC: Last RK Clock Cycle when RK Outputs a Clock During Data Transfer
When the SSC receiver is used with the following conditions:
the internal clock divider is used (CKS = 0 and DIV different from 0)
RK pin set as output and provides the clock during data transfer (CKO = 2)
data sampled on RK falling edge (CKI = 0),
At the end of the data, the RK pin is set in high impedance which might be seen as an unex-
pected clock cycle.
Problem Fix/Workaround
Enable the pull-up on RK pin.
43.4.5.3 SSC: First RK Clock Cycle when Rk Outputs a Clock During Data Transfer
When the SSC receiver is used with the following conditions:
RX clock is divided clock (CKS = 0 and DIV different from 0)
RK pin set as output and provides the clock during data transfer (CKO = 2)
data sampled on RK falling edge (CKI = 0)
The first clock cycle time generated by the RK pin is equal to MCK/(2 x (value +1)).
Problem Fix/Workaround
None.
666
6222HATARM25-Jan-12
SAM7SE512/256/32
667
6222HATARM25-Jan-12
SAM7SE512/256/32
44. Revision History
In the tables that follow, the most recent version of the document appears first.
Note: rfo indicates changes requested during document review and approval loop.
Version
6222H Comments
Change
Request
Ref.
Electrical Characteristics:
Section 40.2 DC Characteristics: Table 40.2, DC Characteristics, changed values for R pull-up Resistor 8124
Errata:
Section 43.3 SAM7SE512/256 Errata - Rev. B Parts: Flash Controller: EFC : Embedded Flash Access
Time, added
Section 43.1 Errata Summary by Product and Revision or Manufacturing Number, added column named
SAM7SE32 Rev B
Section 43.4 SAM7SE32 Errata - Rev. B Parts, added
8124
8156
Version
6222G Comments
Change
Request
Ref.
Preliminary removed from 1st page, and from all headers and footers. rfo
ADC:
Section 39.6.2 ADC Mode Register, formula updated in SHTIM bitfield description.
7890
Errata:
Table 43-1, Errata Summary Table added.
Notes added on top of Section 43.2 SAM7SE512/256/32 Errata - Rev. A Parts.
Section 43.5 SAM7SE512/256/32 Errata - Rev. B Parts added
Typos fixed within Section 43.2 SAM7SE512/256/32 Errata - Rev. A Parts.
7749
rfo
SAM7SE512/256/32 Ordering Information:
MRL B Ordering Codes added to Table 42-1, Ordering Information
7749
Version
6222F Comments
Change
Request
Ref.
Boot ROM:
SAM7SE32 user area addresses updated in Section 25.5 Hardware and Software Constraints.
Variables - only used in this section - changed into text (Yy, Yy_prod, Yz, Yz_prod, DRXD_PIO, DTXD_PIO).
7312
rfo
SAM7SE512/256/32 Errata - Rev. A Parts:
Section 43.2.2 Flash Memory added.
7541
AT91SAM product prefix changed to SAM (except for Chip ID and ordering codes). rfo
668
6222HATARM25-Jan-12
SAM7SE512/256/32
Version
6222E Comments
Change
Request
Ref.
Features:
Mode for General Purpose Two-wire UART Serial Communication added to Debug Unit (DBGU).
Signal Description:
Table 3-1, Signal Description List, AD0-AD3 and AD4-AD7 comments reversed.
System Controller:
Figure 9-1 System Controller Block Diagram, periph_nreset changed into power_on_reset for RTT.
5846
5271
5222
AT91SAM7SE512/256/32 Electrical Characteristics:
Section 40.7 ADC Characteristics, Table 40-17 and Table 40-18 edited. 6774
AT91SAM7SE512/256/32 Errata - Rev. A Parts:
Section 43.2.9.4 USART: RXBRK Flag Error in Asynchronous Mode description edited.
Section 43.2.6.3 SPI: Software Reset Must Be Written Twice added.
USART: XOFF Character Bad Behavior removed from Section 43.2.9
6626
5785
5337
Embedded Flash Controller (EFC):
Section 19.2.4.4 General-purpose NVM Bits, bit values edited in last paragraph.
Text added below Figure 19-6 Example of Partial Page Programming:
6236
6774
External Bus Interface (EBI):
Note (8) added to row NWR0/NWE/CFWE in Table 21-3.
Note (1) added to Figure 21-6.
6774
Memory Controller (MC):
Section 18.5.2 MC Abort Status Register, MST0, MST1, SVMST0, SVMST1 edited.
5687
Reset Controller (RSTC):
Section 13.2.4.4 Software Reset, text added at the end of PERRST description. 5436
USB Transceiver Characteristics:
Latest Programmer Datasheet used (UDP_6083S instead of UDP_6083M). 6774
669
6222HATARM25-Jan-12
SAM7SE512/256/32
Version
6222D Comments
Change
Request
Ref.
Two Wire Interface (TWI) Erroneous text references to PDC functionality removed from the TWI section of
the datasheet: page 353, page 355.
(32.7.7 Using The Peripheral DMA Controller (PDC) removed from page 357), subsequent chapter
numbering effected.
(32.9.45 PDC removed from page 368), subsequent chapter numbering effected.
Table 32-4, Register Mapping, reserved offset for PDC removed
Section 32.10.6 TWI Status Register, TXBUFE, RXBUFF, ENDTX, ENDRX bit fields and descriptions
removed.
Section 32.10.7 TWI Interrupt Enable Register, TXBUFE, RXBUFF, ENDTX, ENDRX bit fields and
descriptions removed.
Section 32.10.8 TWI Interrupt Disable Register,TXBUFE, RXBUFF, ENDTX, ENDRX bit fields and
descriptions removed.
Section 32.10.9 TWI Interrupt Mask Register,TXBUFE, RXBUFF, ENDTX, ENDRX bit fields and
descriptions removed.
5187
Version
6222C Comments
Change
Request
Ref.
Overview:
Figure 8-1 SAM7SE Memory Mapping, Compact Flash not shown w/EBI Chip Select 5. Compact Flash is
shown with EBI Chip Select 2
Section 8.1.2.1 Flash Overview, updated AT91SAM7SE32 ...reads as 8192 32-bit words.
Section 6. I/O Lines Considerations, JTAG Port Pins,Test Pin,Reset Pin,ERASE Pin; descriptions
updated.
4804
4512
5062
PMC
Section 29.9.10 PMC Master Clock Register, MDIV removed from bit fields 9 and 8. 4766
TWI
Important changes to this datasheet include a clarification of Atmel TWI compatibility with I2C Standard. (See
Section 32.1 Overview and Table 32-1)
Section 32.7 Master Mode, rewritten. New Master Read-write flowcharts, new Read-write transfer waveforms,
bit field description modification etc.
Figure 32-2 Application Block Diagram, updated
Figure 32-5 Master Mode Typical Application Block Diagram, updated
New sections; Section 32.7.4 Master Transmitter Mode and Section 32.7.5 Master Receiver Mode replace
Transmitting Data. See also: Figure 32-6, Figure 32-7, Figure 32-8, Figure 32-9 and Figure 32-10
Section 32.7.6 Internal Address added and includes, Section 32.7.6.1 7-bit Slave Addressing and Section
32.7.6.2 10-bit Slave Addressing See also: Figure 32-11, Figure 32-12 and Figure 32-13
Section 32.9.6 Read Write Flowcharts, updated and new flowcharts added.
4373
Fixed typo in ARBLST bit fields; TWI Interrupt Enable Register, TWI Interrupt Disable Register and TWI
Interrupt Mask Register
Inserted EOSACC bit field description in TWI Interrupt Enable Register
4584
4586
670
6222HATARM25-Jan-12
SAM7SE512/256/32
Section 40. SAM7SE512/256/32 Electrical Characteristics
Table 40-12, XIN Clock Electrical Characteristics VXIN_IL, VXIN_IH updated
Table 40-2, DC Characteristics, junction temperature removed and
VDDIO DC supplies 3.3V and 1.8V defined
Table 40-7, Power Consumption for Different Modes: Footnote assigned to Flash In standby mode. Footnote
assigned to Ultra Low Power mode.
Table 40-5, DC Flash Characteristics SAM7SE32, Max standby current updated.
5007
rfo
4657
4598
rfo
Section 41. SAM7SE512/256/32 Mechanical Characteristics
LQFP-package, JESD97 Classification is e3.
Thermal Considerations removed.
4971/5007
4657
Section 43. SAM7SE512/256/32 Errata
Section 43.2.1 Analog-to-Digital Converter (ADC), added to errata.
Section 43.2.5 SDRAM Controller (SDRAMC), added to errata.
Section 43.2.6.1 SPI: Baudrate Set to 1, Problem Fix/Workaround = None.
Section 43.2.6.2 SPI: Bad Serial Clock Generation on 2nd Chip Select, added to errata.
Section 43.2.7.4 SSC: Last RK Clock Cycle when RK Outputs a Clock During Data Transfer, added to errata.
Section 43.2.7.5 SSC: First RK Clock Cycle when RK Outputs a Clock During Data Transfer, added to errata.
Section 43.2.9.3 USART: DCD is Active High Instead of Low, added to errata.
Section 43.2.9.4 USART: RXBRK Flag Error in Asynchronous Mode, added to errata.
5007/4751
/4642
Version
6222C Comments
Change
Request
Ref.
Version
6222B Comments
Change
Request
Ref.
Overview, Section 6.1 JTAG Port Pins, Section 6.3 Reset Pin, Section 6.5 SDCK Pin, removed statement:
not 5V tolerant. Section 7.6 SDRAM Controller Mobile SDRAM controller added to SDRAMC description
INL and DNL updated in Section 10.14 Analog-to-Digital Converter on page 42
3826
4005
Features on page 2, Fully Static Operation: added up to 55 MHz at 1.8V and 85C worst case conditions
Section 7.1 ARM7TDMI Processor, Runs at up to 55 MHz, providing 0.9 MIPS/MHz (core supplied with 1.8V)
Section 7.8 Peripheral DMA Controller PDC priority list added.
Section 7.5 Static Memory Controller Multiple device adaptability: compliant w/PSRAM in synchronous
operations
3924
3833
review
Clock Generator, Removed information on capacitor load value in Section 28.3.1 Main Oscillator
Connections Figure 28-2 Typical Crystal Connection on page 272, updated, CL1 and CL2 labels removed.
3282
3861
DBGU, Debug Unit Chip ID Register, SRAMSIZ: Internal SRAM Size on page 320 updated w/AT91SAM7L
internal RAM size and ARCH: Architecture Identifier on page 321 updated bin values for 0x60 and 0xF0, and
added descriptions for CAP7, AT91SAM7AQxx series and CAP11
3828
3369
3807
EBI, Table 21-3, EBI Pins and External Static Device Connections, on page 138, I/O[8:15] bits added in
NAND Flash column, added notes to table for SDRAM, NAND FLash and references to app notes.
Figure 21-1 Organization of the External Bus Interface SDCK is not multiplexed with PIO
Section 21.7.6.1 Hardware Configuration A25 removed from CFRNW in CompactFlash
Section 21.7.7.1 Hardware Configuration A25 removed from CFRNW in CompactFlash True IDE
3742/3743
/
3852
3924
4044/3836
671
6222HATARM25-Jan-12
SAM7SE512/256/32
Electrical Characteristics,
Section 40.4.3 Crystal Characteristics TCHXIN and TCHLXIN updated, TCLCH and TCHCL added to
Table 40-12, XIN Clock Electrical Characteristics and Figure 40-2 XIN Clock Timing has been added.
3966
Section 40.7 ADC Characteristics INL and DNL updated and Absolute accuracy added to Table 40-19,
Transfer Characteristics. Reference to Data Converter Terminology added below table.
INL and DNL updated in Section 10.14 Analog-to-Digital Converter on page 42
4005
Section 40.8.4 SMC Signals,A25 Address line changed to A22. Table 40-25 on page 632 thru Table 40-28 on
page 634 and in the following two figures.
Figure 40-8 SMC Signals in Memory Interface Mode and Figure 40-9 SM Signals in LCD Interface Mode
SMC timings updated to be concordant with signals listed in Table 40-25 thru Table 40-28.
4044/3836
Section 40.8.6 Embedded Flash Characteristics updated. Note added t oTable 40-32, Embedded Flash Wait
States (VDDCORE = 1.65V) and added Table 40-33, Embedded Flash Wait States (VDDCORE = 1.8V)
Table 40-20, Master Clock Waveform Parameters, updated w/V
DDCORE
= 1.8V, Max = 55 MHz
3924
Table 40-10, Main Oscillator Characteristics added schematic in footnote to C
L
and C
LEXT
symbols
Table 40-7, Power Consumption for Different Modes DDM and DDP pins must be left floating.
Table 40-32, Embedded Flash Wait States (VDDCORE = 1.65V) footnote
(2)
added.
3868
3829
review
ECCC, Section 24.3 Functional Description and Section 24.3.1 Write Access and Section 24.3.2 Read
Access on page 220 updated. Section 24.4.4 ECC Parity Register and Section 24.4.5 ECC NParity
Register on page 228 instruction updated.
3970
ERRATA, Section 43.2.9.1 USART: CTS in Hardware Handshaking, updated.....if CTS goes high near the
end of the starting bit, a character can be lost...........
3955
MC, Section 18.4.5 Memory Protection Unit, initialization guidelines updated at end of section. 4045
PIO, Section 34.4.5 Synchronous Data Output, PIO_OWSR typo corrected.
User Interface, Table 34-2, PIO Register Mapping, on page 446, footnotes updated on PIO_PSR,
PIO_ODSR, PIO_PDSR table cells.
3289
3974
SDRAMC, Section 23.1 Overview on page 199, Mobile SDRAM controller added to SDRAMC description
Figure 23-1 on page 199, SDCK signal in the Block Diagram updated.
3826
review
SMC, Figure 22-9, Figure 22-10, Figure 22-11, Figure 22-12, Figure 22-13 and Figure 22-25 replaced
32-bit bus removed from bit field description BAT: Byte Access Type on page 196
SMC Chip Select Registers on page 196, section restructured with table moved from the end of the section to
appear in the bit field description: NWS: Number of Wait States on page 196. Dont Care and Number of
Wait States column added to this table and NRD Pulse Length is defined in Standard Read and Early Read
Protocols.
Note 1 assigned to table describing bit fields RWSETUP: Read and Write Signal Setup Timeand RWHOLD:
Read and Write Signal Hold Time on page 197.
GLOBAL All references to A25 address line changed to be A22 (23-bit address bus)
Note specific to ECC Controller added to RWHOLD: Read and Write Signal Hold Timebit field description.
Overview on page 161, Address space is 64 Mbytes and the address bus is 23 bits.
External Memory Mapping on page 163, external address bus is 23 bits.
Figure 22-3 on page 164, maximum address space per device is 8 Mbytes.
Figure 22-32 on page 183,change in values on [D15:0] line.
Figure 22-45, Figure 22-46 and Figure 22-47 on page 198 replaced.
3846
3847
3848/4182
3863/3864
3886
review
Version
6222B Comments
Change
Request
Ref.
672
6222HATARM25-Jan-12
SAM7SE512/256/32
SSC, Section 35.6.6.1 Compare Functions on page 474, updated review
UDP, Table 38-2, USB Communication Flow, Supported end point size updated for transfer interrupt
Control endpoints are not effected by the EPEDS: Endpoint Enable Disablebit field in the USB_CSR register.
write 1 updated in RX_DATA_BK0: Receive Data Bank 0bit field in USB_CSR register.
write 0 updated in TXPKTRDY: Transmit Packet Readybit field in USB_CSR register.
3476
4063
4099
USART, In the US_MR register, typo fixed in bit field description CLKO: Clock Output Select on page 422
and DIV value given in bit field description USCLKS: Clock Selection on page 421
Section 33.5.1 I/O Lines on page 392, 3rd paragraph updated.
In the US_CSR register the bit field description TXEMPTY: TXEMPTY Interrupt Enable on page 424 has
been updated
3306
3763
3851
3895
Version
6222A Comments
Change
Request
Ref.
First issue: Preliminary
Version
6222B Comments
Change
Request
Ref.
1
6222HATARM25-Jan-12
SAM7SE512/256/32
Features .................................................................................................... 1
1 Description ............................................................................................... 3
1.1Configuration Summary of the SAM7SE512, SAM7SE256 and SAM7SE32 ............3
2 Block Diagram .......................................................................................... 4
3 Signal Description .................................................................................... 5
4 Package ..................................................................................................... 9
4.1128-lead LQFP Package Outline ...............................................................................9
4.2128-lead LQFP Pinout .............................................................................................10
4.3144-ball LFBGA Package Outline ............................................................................11
4.4144-ball LFBGA Pinout ............................................................................................12
5 Power Considerations ........................................................................... 13
5.1Power Supplies ........................................................................................................13
5.2Power Consumption ................................................................................................13
5.3Voltage Regulator ....................................................................................................13
5.4Typical Powering Schematics ..................................................................................14
6 I/O Lines Considerations ....................................................................... 15
6.1JTAG Port Pins ........................................................................................................15
6.2Test Pin ...................................................................................................................15
6.3Reset Pin .................................................................................................................15
6.4ERASE Pin ..............................................................................................................15
6.5SDCK Pin ................................................................................................................16
6.6PIO Controller lines .................................................................................................16
6.7I/O Lines Current Drawing .......................................................................................16
7 Processor and Architecture .................................................................. 17
7.1ARM7TDMI Processor .............................................................................................17
7.2Debug and Test Features ........................................................................................17
7.3Memory Controller ...................................................................................................17
7.4External Bus Interface .............................................................................................18
7.5Static Memory Controller .........................................................................................18
7.6SDRAM Controller ...................................................................................................19
7.7Error Corrected Code Controller ..............................................................................19
7.8Peripheral DMA Controller .......................................................................................20
8 Memories ................................................................................................ 21
2
6222HATARM25-Jan-12
SAM7SE512/256/32
8.1Embedded Memories ..............................................................................................23
8.2External Memories ...................................................................................................27
9 System Controller .................................................................................. 28
9.1Reset Controller .......................................................................................................30
9.2Clock Generator ......................................................................................................30
9.3Power Management Controller ................................................................................31
9.4Advanced Interrupt Controller ..................................................................................32
9.5Debug Unit ...............................................................................................................33
9.6Periodic Interval Timer .............................................................................................33
9.7Watchdog Timer ......................................................................................................33
9.8Real-time Timer .......................................................................................................33
9.9PIO Controllers ........................................................................................................33
9.10Voltage Regulator Controller .................................................................................34
10 Peripherals .............................................................................................. 35
10.1User Interface ........................................................................................................35
10.2Peripheral Identifiers ..............................................................................................35
10.3Peripheral Multiplexing on PIO Lines ....................................................................36
10.4PIO Controller A Multiplexing ................................................................................37
10.5PIO Controller B Multiplexing ................................................................................38
10.6PIO Controller C Multiplexing ................................................................................39
10.7Serial Peripheral Interface .....................................................................................39
10.8Two Wire Interface ................................................................................................40
10.9USART ..................................................................................................................40
10.10Serial Synchronous Controller .............................................................................40
10.11Timer Counter ......................................................................................................41
10.12PWM Controller ...................................................................................................41
10.13USB Device Port ..................................................................................................42
10.14Analog-to-Digital Converter .................................................................................42
11 ARM7TDMI Processor Overview ........................................................... 43
11.1Overview ................................................................................................................43
11.2ARM7TDMI Processor ...........................................................................................44
12 Debug and Test Features ...................................................................... 49
12.1Overview ................................................................................................................49
12.2Block Diagram .......................................................................................................49
12.3Application Examples ............................................................................................50
3
6222HATARM25-Jan-12
SAM7SE512/256/32
12.4Debug and Test Pin Description ............................................................................51
12.5Functional Description ...........................................................................................52
13 Reset Controller (RSTC) ........................................................................ 55
13.1Block Diagram .......................................................................................................55
13.2Functional Description ...........................................................................................56
13.3Reset Controller (RSTC) User Interface ................................................................63
14 Real-time Timer (RTT) ............................................................................ 67
14.1Overview ................................................................................................................67
14.2Block Diagram .......................................................................................................67
14.3Functional Description ...........................................................................................67
14.4Real-time Timer (RTT) User Interface ...................................................................69
15 Watchdog Timer (WDT) ......................................................................... 73
15.1Overview ................................................................................................................73
15.2Block Diagram .......................................................................................................73
15.3Functional Description ...........................................................................................74
15.4Watchdog Timer (WDT) User Interface .................................................................76
16 Periodic Interval Timer (PIT) ................................................................. 79
16.1Overview ................................................................................................................79
16.2Block Diagram .......................................................................................................79
16.3Functional Description ...........................................................................................80
16.4Periodic Interval Timer (PIT) User Interface ..........................................................82
17 Voltage Regulator Mode Controller (VREG) ........................................ 85
17.1Overview ................................................................................................................85
17.2Voltage Regulator Power Controller (VREG) User Interface .................................86
18 Memory Controller (MC) ........................................................................ 87
18.1Overview ................................................................................................................87
18.2Block Diagram .......................................................................................................87
18.3Functional Description ...........................................................................................88
18.4External Memory Areas .........................................................................................89
18.5Memory Controller (MC) User Interface ................................................................93
19 Embedded Flash Controller (EFC) ...................................................... 101
19.1Overview .............................................................................................................101
19.2Functional Description .........................................................................................101
19.3Embedded Flash Controller (EFC ) User Interface ..............................................110
4
6222HATARM25-Jan-12
SAM7SE512/256/32
20 Fast Flash Programming Interface (FFPI) .......................................... 117
20.1Overview ..............................................................................................................117
20.2Parallel Fast Flash Programming ........................................................................118
20.3Serial Fast Flash Programming ...........................................................................128
21 External Bus Interface (EBI) ................................................................ 135
21.1Overview ..............................................................................................................135
21.2Block Diagram .....................................................................................................136
21.3I/O Lines Description ...........................................................................................137
21.4Application Example ............................................................................................138
21.5Product Dependencies ........................................................................................141
21.6Functional Description .........................................................................................141
21.7Implementation Examples ...................................................................................148
21.8External Bus Interface (EBI) User Interface ........................................................157
22 Static Memory Controller (SMC) ......................................................... 161
22.1Overview ..............................................................................................................161
22.2Block Diagram .....................................................................................................161
22.3I/O Lines Description ...........................................................................................162
22.4Multiplexed Signals ..............................................................................................162
22.5Product Dependencies ........................................................................................163
22.6Functional Description .........................................................................................163
22.7Static Memory Controller (SMC) User Interface ..................................................195
23 SDRAM Controller (SDRAMC) ............................................................. 199
23.1Overview ..............................................................................................................199
23.2Block Diagram .....................................................................................................199
23.3I/O Lines Description ...........................................................................................200
23.4Application Example ............................................................................................200
23.5Product Dependencies ........................................................................................202
23.6Functional Description .........................................................................................204
23.7SDRAM Controller (SDRAMC) User Interface ....................................................210
24 Error Corrected Code Controller (ECC) ............................................. 219
24.1Overview ..............................................................................................................219
24.2Block Diagram .....................................................................................................219
24.3Functional Description .........................................................................................220
24.4ECC User Interface .............................................................................................224
5
6222HATARM25-Jan-12
SAM7SE512/256/32
25 AT91SAM Boot Program ..................................................................... 229
25.1Overview ..............................................................................................................229
25.2Flow Diagram ......................................................................................................229
25.3Device Initialization ..............................................................................................229
25.4SAM-BA Boot ......................................................................................................230
25.5Hardware and Software Constraints ....................................................................233
26 Peripheral DMA Controller (PDC) ....................................................... 235
26.1Overview ..............................................................................................................235
26.2Block Diagram .....................................................................................................235
26.3Functional Description .........................................................................................236
26.4Peripheral DMA Controller (PDC) User Interface ...............................................238
27 Advanced Interrupt Controller (AIC) .................................................. 245
27.1Overview ..............................................................................................................245
27.2Block Diagram .....................................................................................................245
27.3Application Block Diagram ...................................................................................246
27.4AIC Detailed Block Diagram ................................................................................246
27.5I/O Line Description .............................................................................................246
27.6Product Dependencies ........................................................................................247
27.7Functional Description .........................................................................................248
27.8Advanced Interrupt Controller (AIC) User Interface .............................................260
28 Clock Generator ................................................................................... 271
28.1Overview ..............................................................................................................271
28.2Slow Clock RC Oscillator .....................................................................................271
28.3Main Oscillator .....................................................................................................271
28.4Divider and PLL Block .........................................................................................273
29 Power Management Controller (PMC) ................................................ 275
29.1Overview ..............................................................................................................275
29.2Master Clock Controller .......................................................................................275
29.3Processor Clock Controller ..................................................................................276
29.4USB Clock Controller ...........................................................................................276
29.5Peripheral Clock Controller ..................................................................................276
29.6Programmable Clock Output Controller ...............................................................277
29.7Programming Sequence ......................................................................................277
29.8Clock Switching Details .......................................................................................281
29.9Power Management Controller (PMC) User Interface ........................................284
6
6222HATARM25-Jan-12
SAM7SE512/256/32
30 Debug Unit (DBGU) .............................................................................. 299
30.1Overview ..............................................................................................................299
30.2Block Diagram .....................................................................................................300
30.3Product Dependencies ........................................................................................301
30.4UART Operations ................................................................................................301
30.5Debug Unit User Interface ..................................................................................308
31 Serial Peripheral Interface (SPI) .......................................................... 323
31.1Overview ..............................................................................................................323
31.2Block Diagram .....................................................................................................324
31.3Application Block Diagram ...................................................................................324
31.4Signal Description ...............................................................................................325
31.5Product Dependencies ........................................................................................325
31.6Functional Description .........................................................................................326
31.7Serial Peripheral Interface (SPI) User Interface ..................................................335
32 Two Wire Interface (TWI) ..................................................................... 349
32.1Overview ..............................................................................................................349
32.2List of Abbreviations ............................................................................................349
32.3Block Diagram .....................................................................................................350
32.4Application Block Diagram ...................................................................................350
32.5Product Dependencies ........................................................................................351
32.6Functional Description .........................................................................................352
32.7Master Mode ........................................................................................................353
32.8Multi-master Mode ...............................................................................................364
32.9Slave Mode ..........................................................................................................367
32.10Two-wire Interface (TWI) User Interface ...........................................................375
33 Universal Synchronous Asynchronous Receiver Transceiver (USART) 389
33.1Overview ..............................................................................................................389
33.2Block Diagram .....................................................................................................390
33.3Application Block Diagram ...................................................................................391
33.4I/O Lines Description ..........................................................................................391
33.5Product Dependencies ........................................................................................392
33.6Functional Description .........................................................................................393
33.7USART User Interface ........................................................................................418
34 Parallel Input Output Controller (PIO) ................................................ 437
34.1Overview ..............................................................................................................437
7
6222HATARM25-Jan-12
SAM7SE512/256/32
34.2Block Diagram .....................................................................................................438
34.3Product Dependencies ........................................................................................439
34.4Functional Description .........................................................................................440
34.5I/O Lines Programming Example .........................................................................444
34.6PIO User Interface ...............................................................................................446
35 Synchronous Serial Controller (SSC) ................................................ 463
35.1Description ...........................................................................................................463
35.2Block Diagram .....................................................................................................464
35.3Application Block Diagram ...................................................................................464
35.4Pin Name List ......................................................................................................465
35.5Product Dependencies ........................................................................................465
35.6Functional Description .........................................................................................465
35.7SSC Application Examples ..................................................................................477
35.8Synchronous Serial Controller (SSC) User Interface ..........................................479
36 Timer/Counter (TC) .............................................................................. 501
36.1Overview ..............................................................................................................501
36.2Block Diagram .....................................................................................................502
36.3Pin Name List ......................................................................................................503
36.4Product Dependencies ........................................................................................503
36.5Functional Description .........................................................................................504
36.6Timer/Counter (TC) User Interface ......................................................................517
37 Pulse WIdth Modulation Controller (PWM) ........................................ 535
37.1Overview ..............................................................................................................535
37.2Block Diagram .....................................................................................................535
37.3I/O Lines Description ...........................................................................................536
37.4Product Dependencies ........................................................................................536
37.5Functional Description .........................................................................................537
37.6Pulse Width Modulation (PWM) Controller User Interface .................................545
38 USB Device Port (UDP) ........................................................................ 555
38.1Overview ..............................................................................................................555
38.2Block Diagram .....................................................................................................556
38.3Product Dependencies ........................................................................................557
38.4Typical Connection ..............................................................................................558
38.5Functional Description .........................................................................................559
38.6USB Device Port (UDP) User Interface ...............................................................573
8
6222HATARM25-Jan-12
SAM7SE512/256/32
39 Analog-to-Digital Converter (ADC) ..................................................... 597
39.1Overview ..............................................................................................................597
39.2Block Diagram .....................................................................................................597
39.3Signal Description ................................................................................................598
39.4Product Dependencies ........................................................................................598
39.5Functional Description .........................................................................................599
39.6Analog-to-digital Converter (ADC) User Interface ...............................................604
40 SAM7SE512/256/32 Electrical Characteristics .................................. 615
40.1Absolute Maximum Ratings .................................................................................615
40.2DC Characteristics ...............................................................................................616
40.3Power Consumption ............................................................................................619
40.4Crystal Oscillators Characteristics .......................................................................621
40.5PLL Characteristics .............................................................................................624
40.6USB Transceiver Characteristics .........................................................................625
40.7ADC Characteristics ...........................................................................................627
40.8AC Characteristics ...............................................................................................628
41 SAM7SE512/256/32 Mechanical Characteristics ............................... 645
41.1Package Drawings ...............................................................................................645
41.2Soldering Profile ..................................................................................................647
41.3Marking ................................................................................................................647
42 SAM7SE512/256/32 Ordering Information ......................................... 648
43 SAM7SE512/256/32 Errata ................................................................... 649
43.1Errata Summary by Product and Revision or Manufacturing Number .................649
43.2SAM7SE512/256/32 Errata - Rev. A Parts ..........................................................651
43.3SAM7SE512/256 Errata - Rev. B Parts ...............................................................659
43.4SAM7SE32 Errata - Rev. B Parts ........................................................................663
44 Revision History ................................................................................... 667
Headquarters International
Atmel Corporation
2325 Orchard Parkway
San Jose, CA 95131
USA
Tel: (+1) (408) 441-0311
Fax: (+1) (408) 487-2600
Atmel Asia Limited
Unit 01-5 & 16, 19F
BEA Tower, Millennium City 5
418 Kwun Tong Road
Kwun Tong, Kowloon
HONG KONG
Tel: (+852) 2245-6100
Fax: (+852) 2722-1369
Atmel Munich GmbH
Business Campus
Parkring 4
D-85748 Garching b. Munich
GERMANY
Tel: (+49) 89-31970-0
Fax: (+49) 89-3194621
Atmel Japan
9F, Tonetsu Shinkawa Bldg.
1-24-8 Shinkawa
Chuo-ku, Tokyo 104-0033
JAPAN
Tel: (81) 3-3523-3551
Fax: (81) 3-3523-7581
Product Contact
Web Site
www.atmel.com
www.atmel.com/AT91SAM
Technical Support
AT91SAM Support
Atmel technical support
Sales Contacts
www.atmel.com/contacts/
Literature Requests
www.atmel.com/literature
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any
intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMELS TERMS AND CONDI-
TIONS OF SALE LOCATED ON ATMELS WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY
WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN-
TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT
OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications
and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided
otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmels products are not intended, authorized, or warranted for use
as components in applications intended to support or sustain life.
2011 Atmel Corporation. All rights reserved. Atmel
, DataFlash
, ARMPowered
logo, Cortex
, Thumb
and others are registered trademarks or trademarks of Microsoft Corporation in the US and/or
other countries. Other terms and product names may be trademarks of others.
6222HATARM25-Jan-12
2
6222HATARM25-Jan-12
SAM7SE512/256/32