AT91SAM7S Datasheet
AT91SAM7S Datasheet
AT91SAM7S Datasheet
1. Description
Atmel’s AT91SAM7S is a series of low pincount Flash microcontrollers based on the 32-bit ARM
RISC processor. It features a high-speed Flash and an SRAM, a large set of peripherals, includ-
ing a USB 2.0 device (except for the AT91SAM7S32 and AT91SAM7S16), and a complete set
of system functions minimizing the number of external components. The device is an ideal
migration path for 8-bit microcontroller users looking for additional performance and extended
memory.
The embedded Flash memory can be programmed in-system via the JTAG-ICE interface or via
a parallel interface on a production programmer prior to mounting. Built-in lock bits and a secu-
rity bit protect the firmware from accidental overwrite and preserves its confidentiality.
The AT91SAM7S Series system controller includes a reset controller capable of managing the
power-on sequence of the microcontroller and the complete system. Correct device operation
can be monitored by a built-in brownout detector and a watchdog running off an integrated RC
oscillator.
The AT91SAM7S Series are general-purpose microcontrollers. Their integrated USB Device
port makes them ideal devices for peripheral applications requiring connectivity to a PC or cellu-
lar phone. Their aggressive price point and high level of integration pushes their scope of use far
into the cost-sensitive, high-volume consumer market.
3
6175H–ATARM–03-Dec-07
2. Block Diagram
Figure 2-1. AT91SAM7S512/256/128/64/321/161 Block Diagram
TDI
TDO ICE
TMS JTAG ARM7TDMI
TCK SCAN Processor
JTAGSEL
1.8 V VDDIN
Voltage GND
System Controller Regulator VDDOUT
TST
FIQ
VDDCORE
AIC
IRQ0-IRQ1 Memory Controller VDDIO
PIO
SRAM
Embedded Address 64/32/16/8/4 Kbytes
PCK0-PCK2 Flash Decoder
Controller
PLLRC PLL
PMC Abort Misalignment
XIN
XOUT OSC Status Detection VDDFLASH
Flash ERASE
RCOSC 512/256/
128/64/32/16 Kbytes
RTT SAM-BA
DRXD PDC
PIO
PWM0
RXD0 PDC PWMC PWM1
TXD0 PWM2
SCK0 USART0 PWM3
RTS0 PDC TF
CTS0 PDC TK
RXD1 PDC SSC TD
TXD1 RD
SCK1 RK
PIO
RI1 TIOB0
NPCS0 PDC TIOA1
NPCS1 TC1 TIOB1
NPCS2
SPI TIOA2
NPCS3 TC2 TIOB2
MISO
MOSI TWD
PDC
TWI TWCK
SPCK
ADTRG PDC
AD0
AD1
AD2
AD3 ADC
AD4
AD5
AD6
AD7
ADVREF
TDI
TDO ICE
TMS JTAG ARM7TDMI
TCK SCAN Processor
JTAGSEL
1.8 V VDDIN
Voltage GND
System Controller Regulator
TST VDDOUT
FIQ
VDDCORE
AIC
IRQ0
Memory Controller VDDIO
PIO
SRAM
Embedded Address
Flash
8/4 Kbytes
PCK0-PCK2 Decoder
Controller
PLLRC PLL
PMC Abort Misalignment
XIN
XOUT
OSC Status Detection VDDFLASH
Flash ERASE
RCOSC 32/16 Kbytes
VDDCORE BOD
Peripheral Bridge
Reset
VDDCORE POR Controller
Peripheral DMA
NRST Controller ROM
PGMRDY
9 Channels
PGMNVALID
PIT Fast Flash PGMNOE
PGMCK
Programming
APB Interface PGMM0-PGMM3
WDT PGMD0-PGMD7
PGMNCMD
PGMEN0-PGMEN2
RTT
DTXD DBGU
PDC
PIOA
PWM0
PWMC PWM1
PWM2
RXD0 PDC PWM3
TXD0
PDC TF
SCK0 USART0
TK
RTS0
PDC SSC TD
PIO
CTS0
RD
NPCS0 PDC RK
NPCS1 PDC
PIO
RF
NPCS2
TCLK0
NPCS3 SPI
MISO Timer Counter
MOSI
TIOA0
SPCK PDC TC0 TIOB0
ADTRG PDC
TIOA1
AD0 TC1 TIOB1
AD1
AD2
AD3
TC2
ADC
AD4 TWD
AD5
TWI TWCK
AD6
AD7
ADVREF
5
6175H–ATARM–03-Dec-07
3. Signal Description
Table 3-1. Signal Description List
Active
Signal Name Function Type Level Comments
Power
Voltage and ADC Regulator Power Supply
VDDIN Power 3.0 to 3.6V
Input
VDDOUT Voltage Regulator Output Power 1.85V nominal
VDDFLASH Flash Power Supply Power 3.0V to 3.6V
VDDIO I/O Lines Power Supply Power 3.0V to 3.6V or 1.65V to 1.95V
VDDCORE Core Power Supply Power 1.65V to 1.95V
VDDPLL PLL Power 1.65V to 1.95V
GND Ground Ground
Clocks, Oscillators and PLLs
XIN Main Oscillator Input Input
XOUT Main Oscillator Output Output
PLLRC PLL Filter Input
PCK0 - PCK2 Programmable Clock Output Output
ICE and JTAG
TCK Test Clock Input No pull-up resistor
TDI Test Data In Input No pull-up resistor
TDO Test Data Out Output
TMS Test Mode Select Input No pull-up resistor
JTAGSEL JTAG Selection Input Pull-down resistor(1)
Flash Memory
Flash and NVM Configuration Bits Erase
ERASE Input High Pull-down resistor(1)
Command
Reset/Test
NRST Microcontroller Reset I/O Low Open-drain with pull-Up resistor
TST Test Mode Select Input High Pull-down resistor(1)
Debug Unit
DRXD Debug Receive Data Input
DTXD Debug Transmit Data Output
AIC
IRQ0 - IRQ1 External Interrupt Inputs Input IRQ1 not present on AT91SAM7S32/16
FIQ Fast Interrupt Input Input
PIO
Pulled-up input at reset
PA0 - PA31 Parallel IO Controller A I/O
PA0 - PA20 only on AT91SAM7S32/16
7
6175H–ATARM–03-Dec-07
Table 3-1. Signal Description List (Continued)
Active
Signal Name Function Type Level Comments
Two-Wire Interface
TWD Two-wire Serial Data I/O
TWCK Two-wire Serial Clock I/O
Analog-to-Digital Converter
AD0-AD3 Analog Inputs Analog Digital pulled-up inputs at reset
AD4-AD7 Analog Inputs Analog Analog Inputs
ADTRG ADC Trigger Input
ADVREF ADC Reference Analog
Fast Flash Programming Interface
PGMEN0-PGMEN2 Programming Enabling Input
PGMM0-PGMM3 Programming Mode Input
PGMD0-PGMD7 only on
PGMD0-PGMD15 Programming Data I/O
AT91SAM7S32/16
PGMRDY Programming Ready Output High
PGMNVALID Data Direction Output Low
PGMNOE Programming Read Input Low
PGMCK Programming Clock Input
PGMNCMD Programming Command Input Low
49 32
64
17
1 16
49 32
64 17
1 16
9
6175H–ATARM–03-Dec-07
4.2 64-lead LQFP and 64-pad QFN Pinout
48
13
1 12
37 24
48 13
1 12
11
6175H–ATARM–03-Dec-07
5. Power Considerations
Adequate input supply decoupling is mandatory for VDDIN in order to improve startup stability
and reduce source voltage drop. The input decoupling capacitor should be placed close to the
chip. For example, two capacitors can be used in parallel: 100 nF NPO and 4.7 µF X7R.
VDDCORE
VDDPLL
13
6175H–ATARM–03-Dec-07
6. I/O Lines Considerations
tor from the I/O line to VDDIO. Care should be taken, in particular at reset, as all the I/O lines
default to input with the pull-up resistor enabled at reset.
15
6175H–ATARM–03-Dec-07
7. Processor and Architecture
– Prefetch buffer, buffering and anticipating the 16-bit requests, reducing the required
wait states
– Key-protected program, erase and lock/unlock sequencer
– Single command for erasing, programming and locking operations
– Interrupt generation in case of forbidden operation
17
6175H–ATARM–03-Dec-07
8. Memories
8.1 AT91SAM7S512
• 512 Kbytes of Flash Memory, dual plane
– 2 contiguous banks of 1024 pages of 256 bytes
– Fast access time, 30 MHz single-cycle access in Worst Case conditions
– Page programming time: 6 ms, including page auto-erase
– Page programming without auto-erase: 3 ms
– Full chip erase time: 15 ms
– 10,000 write cycles, 10-year data retention capability
– 32 lock bits, protecting 32 sectors of 64 pages
– Protection Mode to secure contents of the Flash
• 64 Kbytes of Fast SRAM
– Single-cycle access at full speed
8.2 AT91SAM7S256
• 256 Kbytes of Flash Memory, single plane
– 1024 pages of 256 bytes
– Fast access time, 30 MHz single-cycle access in Worst Case conditions
– Page programming time: 6 ms, including page auto-erase
– Page programming without auto-erase: 3 ms
– Full chip erase time: 15 ms
– 10,000 write cycles, 10-year data retention capability
– 16 lock bits, protecting 16 sectors of 64 pages
– Protection Mode to secure contents of the Flash
• 64 Kbytes of Fast SRAM
– Single-cycle access at full speed
8.3 AT91SAM7S128
• 128 Kbytes of Flash Memory, single plane
– 512 pages of 256 bytes
– Fast access time, 30 MHz single-cycle access in Worst Case conditions
– Page programming time: 6 ms, including page auto-erase
– Page programming without auto-erase: 3 ms
– Full chip erase time: 15 ms
– 10,000 write cycles, 10-year data retention capability
– 8 lock bits, protecting 8 sectors of 64 pages
– Protection Mode to secure contents of the Flash
• 32 Kbytes of Fast SRAM
– Single-cycle access at full speed
8.4 AT91SAM7S64
• 64 Kbytes of Flash Memory, single plane
– 512 pages of 128 bytes
– Fast access time, 30 MHz single-cycle access in Worst Case conditions
– Page programming time: 6 ms, including page auto-erase
– Page programming without auto-erase: 3 ms
– Full chip erase time: 15 ms
– 10,000 write cycles, 10-year data retention capability
– 16 lock bits, protecting 16 sectors of 32 pages
– Protection Mode to secure contents of the Flash
• 16 Kbytes of Fast SRAM
– Single-cycle access at full speed
8.5 AT91SAM7S321/32
• 32 Kbytes of Flash Memory, single plane
– 256 pages of 128 bytes
– Fast access time, 30 MHz single-cycle access in Worst Case conditions
– Page programming time: 6 ms, including page auto-erase
– Page programming without auto-erase: 3 ms
– Full chip erase time: 15 ms
– 10,000 write cycles, 10-year data retention capability
– 8 lock bits, protecting 8 sectors of 32 pages
– Protection Mode to secure contents of the Flash
• 8 Kbytes of Fast SRAM
– Single-cycle access at full speed
8.6 AT91SAM7S161/16
• 16 Kbytes of Flash Memory, single plane
– 256 pages of 64 bytes
– Fast access time, 30 MHz single-cycle access in Worst Case conditions
– Page programming time: 6 ms, including page auto-erase
– Page programming without auto-erase: 3 ms
– Full chip erase time: 15 ms
– 10,000 write cycles, 10-year data retention capability
– 8 lock bits, protecting 8 sectors of 32 pages
– Protection Mode to secure contents of the Flash
• 4 Kbytes of Fast SRAM
– Single-cycle access at full speed
19
6175H–ATARM–03-Dec-07
Figure 8-1. AT91SAM7S512/256/128/64/321/32/161/16 Memory Mapping
Internal Memory Mapping Note:
(1) Can be Flash or SRAM
0x0000 0000 depending on REMAP.
(1)
Flash before Remap 1 MBytes
SRAM after Remap
0x000F FFF
0x0010 0000
Internal Flash 1 MBytes
0x001F FFF
0x0020 0000
Internal SRAM 1 MBytes
0x002F FFF
0x0030 0000
Address Memory Space
0x0000 0000
0x0FFF FFFF
0x0FFF FFFF
0x1000 0000
0xFFFF F000
512 Bytes/
Peripheral Mapping AIC
128 registers
0xF000 0000
0xFFFF F1FF
Undefined 14 x 256 MBytes Reserved
0xFFFF F200
(Abort) 3,584 MBytes 0xFFF9 FFFF
0xFFFA 0000 512 Bytes/
TC0, TC1, TC2 16 Kbytes DBGU
0xFFFA 3FFF 128 registers
0xFFFA 4000
Reserved 0xFFFF F3FF
0xFFFA FFFF 0xFFFF F400
0xFFFB 0000 16 Kbytes
UDP (Reserved on
0xFFFB 3FFF PIOA 512 Bytes/
AT91SAM7S32/16)
0xFFFB 4000 128 registers
Reserved
0xFFFF F5FF
0xFFFB 7FFF
0xFFFB 8000 0xFFFF F600
TWI 16 Kbytes
0xEFFF FFFF 0xFFFB BFFF Reserved
0xF000 0000 0xFFFB C000 0xFFFF FBFF
Reserved
0xFFFB FFFF 0xFFFF FC00
0xFFFC 0000 256 Bytes/
USART0 16 Kbytes PMC
0xFFFC 3FFF 64 registers
Internal Peripherals 256M Bytes 0xFFFC 4000 16 Kbytes 0xFFFF FCFF
USART1 (Reserved on 0xFFFF FD00 16 Bytes/
0xFFFC 7FFF AT91SAM7S32/16) RSTC
0xFFFF FD0F 4 registers
0xFFFC 8000 Reserved
0xFFFC BFFF Reserved
0xFFFF FFFF
0xFFFC C000 PWMC 16 Kbytes 0xFFFF FD20
RTT 16 Bytes/
0xFFFC FFFF 0xFFFF FC2F 4 registers
0xFFFD 0000 0xFFFF FD30
Reserved 16 Bytes/
PIT
0xFFFD 3FFF 0xFFFF FC3F 4 registers
0xFFFD 4000 0xFFFF FD40
SSC 16 Kbytes WDT 16 Bytes/
0xFFFD 7FFF 0xFFFF FD4F 4 registers
0xFFFD 8000
ADC 16 Kbytes Reserved
0xFFFD BFFF
0xFFFD C000 0xFFFF FD60
Reserved VREG 4 Bytes/
0xFFFD FFFF 0xFFFF FC6F 1 register
0xFFFE 0000 0xFFFF FD70
SPI 16 Kbytes Reserved
0xFFFE 3FFF 0xFFFF FEFF
0xFFFE 4000 0xFFFF FF00
Reserved
256 Bytes/
0xFFFF EFFF MC 64 registers
0xFFFF F000
SYSC
0xFFFF FFFF 0xFFFF FFFF
0x0000 0000
Flash Before Remap 1 MBytes
0x000F FFFF SRAM After Remap
0x0010 0000
Internal Flash 1 MBytes
0x001F FFFF
0x0020 0000
256 MBytes Internal SRAM 1 MBytes
0x002F FFFF
0x0030 0000
Undefined Areas
(Abort) 253 MBytes
0x0FFF FFFF
21
6175H–ATARM–03-Dec-07
8.8 Embedded Flash
8.8.3.1 AT91SAM7S512
Two Embedded Flash Controllers each manage 16 lock bits to protect 16 regions of the flash
against inadvertent flash erasing or programming commands. The AT91SAM7S512 contains 32
lock regions and each lock region contains 64 pages of 256 bytes. Each lock region has a size of
16 Kbytes.
If a locked-region’s erase or program command occurs, the command is aborted and the
LOCKE bit in the MC_FSR register rises and the interrupt line rises if the LOCKE bit has been
written at 1 in the MC_FMR register.
The 16 NVM bits (or 32 NVM bits) are software programmable through the corresponding EFC
User Interface. The command “Set Lock Bit” enables the protection. The command “Clear Lock
Bit” unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
8.8.3.2 AT91SAM7S256
The Embedded Flash Controller manages 16 lock bits to protect 16 regions of the flash against
inadvertent flash erasing or programming commands. The AT91SAM7S256 contains 16 lock
regions and each lock region contains 64 pages of 256 bytes. Each lock region has a size of 16
Kbytes.
If a locked-region’s erase or program command occurs, the command is aborted and the
LOCKE bit in the MC_FSR register rises and the interrupt line rises if the LOCKE bit has been
written at 1 in the MC_FMR register.
The 16 NVM bits are software programmable through the EFC User Interface. The command
“Set Lock Bit” enables the protection. The command “Clear Lock Bit” unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
8.8.3.3 AT91SAM7S128
The Embedded Flash Controller manages 8 lock bits to protect 8 regions of the flash against
inadvertent flash erasing or programming commands. The AT91SAM7S128 contains 8 lock
regions and each lock region contains 64 pages of 256 bytes. Each lock region has a size of 16
Kbytes.
If a locked-region’s erase or program command occurs, the command is aborted and the
LOCKE bit in the MC_FSR register rises and the interrupt line rises if the LOCKE bit has been
written at 1 in the MC_FMR register.
The 8 NVM bits are software programmable through the EFC User Interface. The command “Set
Lock Bit” enables the protection. The command “Clear Lock Bit” unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
8.8.3.4 AT91SAM7S64
The Embedded Flash Controller manages 16 lock bits to protect 16 regions of the flash against
inadvertent flash erasing or programming commands. The AT91SAM7S64 contains 16 lock
regions and each lock region contains 32 pages of 128 bytes. Each lock region has a size of 4
Kbytes.
23
6175H–ATARM–03-Dec-07
If a locked-region’s erase or program command occurs, the command is aborted and the
LOCKE bit in the MC_FSR register rises and the interrupt line rises if the LOCKE bit has been
written at 1 in the MC_FMR register.
The 16 NVM bits are software programmable through the EFC User Interface. The command
“Set Lock Bit” enables the protection. The command “Clear Lock Bit” unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
8.8.3.5 AT91SAM7S321/32
The Embedded Flash Controller manages 8 lock bits to protect 8 regions of the flash against
inadvertent flash erasing or programming commands. The AT91SAM7S321/32 contains 8 lock
regions and each lock region contains 32 pages of 128 bytes. Each lock region has a size of 4
Kbytes.
If a locked-region’s erase or program command occurs, the command is aborted and the
LOCKE bit in the MC_FSR register rises and the interrupt line rises if the LOCKE bit has been
written at 1 in the MC_FMR register.
The 8 NVM bits are software programmable through the EFC User Interface. The command “Set
Lock Bit” enables the protection. The command “Clear Lock Bit” unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
8.8.3.6 AT91SAM7S161/16
The Embedded Flash Controller manages 8 lock bits to protect 8 regions of the flash against
inadvertent flash erasing or programming commands. The AT91SAM7S161/16 contains 8 lock
regions and each lock region contains 32 pages of 64 bytes. Each lock region has a size of 2
Kbytes.
If a locked-region’s erase or program command occurs, the command is aborted and the
LOCKE bit in the MC_FSR register rises and the interrupt line rises if the LOCKE bit has been
written at 1 in the MC_FMR register.
The 8 NVM bits are software programmable through the EFC User Interface. The command “Set
Lock Bit” enables the protection. The command “Clear Lock Bit” unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
Table summarizes the configuration of the eight devices.
25
6175H–ATARM–03-Dec-07
The SAM-BA Boot Assistant is a default Boot Program that provides an easy way to program in
situ the on-chip Flash memory.
The SAM-BA Boot Assistant supports serial communication through the DBGU or through the
USB Device Port. (The AT91SAM7S32/16 have no USB Device Port.)
• Communication through the DBGU supports a wide range of crystals from 3 to 20 MHz via
software auto-detection.
• Communication through 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).
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 27 and Figure 9-2 on page 28 show the product specific System Controller
Block Diagrams.
Figure 8-1 on page 20 shows the mapping of the of the User Interface of the System Controller
peripherals. Note that the memory controller configuration user interface is also mapped within
this address space.
nirq
irq0-irq1
fiq
Advanced nfiq
Interrupt
Controller proc_nreset ARM7TDMI
periph_irq[2..14]
int PCK
pit_irq debug
rtt_irq
wdt_irq
dbgu_irq
pmc_irq power_on_reset
rstc_irq
force_ntrst
MCK dbgu_irq
periph_nreset
Debug
Unit force_ntrst
dbgu_rxd dbgu_txd
security_bit
MCK Periodic
debug Interval pit_irq
periph_nreset Timer
SLCK flash_poe
Real-Time rtt_irq
Embedded
periph_nreset Timer flash_wrdis Flash
SLCK cal
debug Watchdog wdt_irq gpnvm[0..1]
idle Timer
proc_nreset
cal wdt_fault
gpnvm[0] gpnvm[1]
WDRPROC
MCK
en bod_rst_en Memory
flash_wrdis
BOD proc_nreset Controller
power_on_reset
Reset periph_nreset
jtag_nreset proc_nreset Voltage
Controller
POR
flash_poe Regulator standby
Mode Voltage
rstc_irq Controller Regulator
NRST
cal
SLCK
SLCK
RCOSC periph_clk[2..14] UDPCK
pck[0-2] periph_clk[11]
USB Device
XIN Power
OSC MAINCK periph_nreset
Port
Management PCK
XOUT Controller UDPCK
periph_irq[11]
MCK
usb_suspend
PLLRC PLL PLLCK
pmc_irq
int
periph_nreset idle
usb_suspend periph_clk[4..14]
periph_nreset
Embedded
Peripherals
periph_nreset periph_irq{2]
periph_clk[2] irq0-irq1
periph_irq[4..14]
dbgu_rxd PIO fiq
Controller dbgu_txd
in
PA0-PA31
out
enable
27
6175H–ATARM–03-Dec-07
Figure 9-2. System Controller Block Diagram (AT91SAM7S32/16)
nirq
irq0
fiq
Advanced nfiq
Interrupt
Controller proc_nreset ARM7TDMI
periph_irq[2..14]
int PCK
pit_irq debug
rtt_irq
wdt_irq
dbgu_irq
pmc_irq power_on_reset
rstc_irq
force_ntrst
MCK dbgu_irq
periph_nreset Debug force_ntrst
Unit
dbgu_rxd dbgu_txd
security_bit
MCK Periodic
debug Interval pit_irq
periph_nreset Timer
SLCK flash_poe
Real-Time rtt_irq
Embedded
periph_nreset Timer flash_wrdis Flash
SLCK cal
debug Watchdog wdt_irq gpnvm[0..1]
idle Timer
proc_nreset
cal wdt_fault
gpnvm[0] gpnvm[1]
WDRPROC
MCK
en bod_rst_en Memory
BOD flash_wrdis proc_nreset Controller
power_on_reset periph_nreset
Reset
jtag_nreset Controller proc_nreset Voltage
POR
flash_poe Regulator standby
Mode Voltage
rstc_irq Controller Regulator
NRST
cal
SLCK
SLCK
RCOSC periph_clk[2..14]
pck[0-2]
XIN Power
OSC MAINCK
Management PCK
XOUT Controller
MCK
periph_nreset
Embedded
Peripherals
periph_nreset periph_irq{2]
periph_clk[2] irq0
periph_irq[4..14]
dbgu_rxd PIO fiq
Controller dbgu_txd
in
PA0-PA20
out
enable
29
6175H–ATARM–03-Dec-07
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
• 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.
Clock Generator
XIN
Main Main Clock
Oscillator MAINCK
XOUT
Status Control
Power
Management
Controller
Processor PCK
Clock
Controller
int
Master Clock Controller
Idle Mode
SLCK
MAINCK Prescaler
/1,/2,/4,...,/64 MCK
PLLCK
Peripherals periph_clk[2..14]
Clock Controller
ON/OFF
SLCK
MAINCK Prescaler
pck[0..2]
PLLCK /1,/2,/4,...,/64
Divider
PLLCK UDPCK
/1,/2,/4
31
6175H–ATARM–03-Dec-07
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
– Implemented features are compatible with the USART
– 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 0x270B0A40 for AT91SAM7S512 (VERSION 0)
– Chip ID is 0x270B0940 for AT91SAM7S256 (VERSION 0)
– Chip ID is 0x270C0941 for AT91SAM7S256 Rev B (VERSION 0)
– Chip ID is 0x270A0740 for AT91SAM7S128 (VERSION 0)
– Chip ID is 0x270C0741 for AT91SAM7S128 Rev B (VERSION 0)
– Chip ID is 0x27090540 for AT91SAM7S64 (VERSION 0)
– Chip ID is 0x27080342 for AT91SAM7S321 (VERSION 0)
– Chip ID is 0x27080340 for AT91SAM7S32 (VERSION 0)
– Chip ID is 0x27050241 for AT9SAM7S161 (VERSION 0)
– Chip ID is 0x27050240 for AT91SAM7S16 (VERSION 0)
33
6175H–ATARM–03-Dec-07
10. Peripherals
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.
35
6175H–ATARM–03-Dec-07
10.4 PIO Controller A Multiplexing
Table 10-3. Multiplexing on PIO Controller A (AT91SAM7S512/256/128/64/321/161)
PIO Controller A Application Usage
I/O Line Peripheral A Peripheral B Comments Function Comments
PA0 PWM0 TIOA0 High-Drive
PA1 PWM1 TIOB0 High-Drive
PA2 PWM2 SCK0 High-Drive
PA3 TWD NPCS3 High-Drive
PA4 TWCK TCLK0
PA5 RXD0 NPCS3
PA6 TXD0 PCK0
PA7 RTS0 PWM3
PA8 CTS0 ADTRG
PA9 DRXD NPCS1
PA10 DTXD NPCS2
PA11 NPCS0 PWM0
PA12 MISO PWM1
PA13 MOSI PWM2
PA14 SPCK PWM3
PA15 TF TIOA1
PA16 TK TIOB1
PA17 TD PCK1 AD0
PA18 RD PCK2 AD1
PA19 RK FIQ AD2
PA20 RF IRQ0 AD3
PA21 RXD1 PCK1
PA22 TXD1 NPCS3
PA23 SCK1 PWM0
PA24 RTS1 PWM1
PA25 CTS1 PWM2
PA26 DCD1 TIOA2
PA27 DTR1 TIOB2
PA28 DSR1 TCLK1
PA29 RI1 TCLK2
PA30 IRQ1 NPCS2
PA31 NPCS1 PCK2
37
6175H–ATARM–03-Dec-07
10.5 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® and 3-wire EEPROMs
– Serial peripherals, such as ADCs, DACs, LCD Controllers, CAN Controllers and
Sensors
– External co-processors
• Master or slave serial peripheral bus interface
– 8- to 16-bit programmable data length per chip select
– Programmable phase and polarity per chip select
– Programmable transfer delays between consecutive transfers and between clock
and data per chip select
– Programmable delay between consecutive transfers
– Selectable mode fault detection
– Maximum frequency at up to Master Clock
10.7 USART
• Programmable Baud Rate Generator
• 5- to 9-bit full-duplex synchronous or asynchronous serial communications
– 1, 1.5 or 2 stop bits in Asynchronous Mode
– 1 or 2 stop bits in Synchronous Mode
– Parity generation and error detection
– Framing error detection, overrun error detection
– MSB or LSB first
– Optional break generation and detection
– By 8 or by 16 over-sampling receiver frequency
– Hardware handshaking RTS - CTS
– Modem Signals Management DTR-DSR-DCD-RI on USART1 (not present on
AT91SAM7S32/16)
– Receiver time-out and transmitter timeguard
– Multi-drop Mode with address generation and detection
• RS485 with driver control signal
39
6175H–ATARM–03-Dec-07
10.10 PWM Controller
• Four channels, one 16-bit counter per channel
• Common clock generator, providing thirteen different clocks
– One Modulo n counter providing eleven clocks
– Two independent linear dividers working on modulo n counter outputs
• Independent channel programming
– Independent enable/disable commands
– Independent clock selection
– Independent period and duty cycle, with double buffering
– Programmable selection of the output waveform polarity
– Programmable center or left aligned output waveform
11.1 Overview
The ARM7TDMI core executes both the 32-bit ARM® and 16-bit Thumb® instruction sets, allow-
ing the user to trade off between high performance and high code density.The ARM7TDMI
processor implements Von Neuman architecture, using a three-stage pipeline consisting of
Fetch, Decode, and Execute stages.
The main features of the ARM7TDMI processor are:
• ARM7TDMI Based on ARMv4T Architecture
• Two Instruction Sets
– ARM® High-performance 32-bit Instruction Set
– Thumb® High Code Density 16-bit Instruction Set
• Three-Stage Pipeline Architecture
– Instruction Fetch (F)
– Instruction Decode (D)
– Execute (E)
41
6175H–ATARM–03-Dec-07
11.2 ARM7TDMI Processor
For further details on ARM7TDMI, refer to the following ARM documents:
ARM Architecture Reference Manual (DDI 0100E)
ARM7TDMI Technical Reference Manual (DDI 0210B)
R1 R1 R1 R1 R1 R1
R2 R2 R2 R2 R2 R2
R3 R3 R3 R3 R3 R3
R4 R4 R4 R4 R4 R4
R5 R5 R5 R5 R5 R5
R6 R6 R6 R6 R6 R6
R7 R7 R7 R7 R7 R7
R8 R8 R8 R8 R8 R8_FIQ
R9 R9 R9 R9 R9 R9_FIQ
PC PC PC PC PC PC
Registers R0 to R7 are unbanked registers. This means that each of them refers to the same 32-
bit physical register in all processor modes. They are general-purpose registers, with no special
uses managed by the architecture, and can be used wherever an instruction allows a general-
purpose register to be specified.
Registers R8 to R14 are banked registers. This means that each of them depends on the current
mode of the processor.
43
6175H–ATARM–03-Dec-07
A seventh processing mode, System Mode, does not have any banked registers. It uses the
User Mode registers. System Mode runs tasks that require a privileged processor mode and
allows them to invoke all classes of exceptions.
LDRBT Load Register Byte with Translation STRT Store Register with Translation
45
6175H–ATARM–03-Dec-07
Stack Pointer (ARM Register 13). Further instructions allow limited access to the ARM registers
8 to 15.
Table 11-3 gives the Thumb instruction mnemonic list.
MUL Multiply
12.1 Description
The AT91SAM7S Series Microcontrollers feature a number of complementary debug and test
capabilities. A common JTAG/ICE (EmbeddedICE) port is used for standard debugging func-
tions, such as downloading code and single-stepping through programs. The Debug Unit
provides a two-pin UART that can be used to upload an application into internal SRAM. It man-
ages the interrupt handling of the internal COMMTX and COMMRX signals that trace the activity
of the Debug Communication Channel.
A set of dedicated debug and test input/output pins gives direct access to these capabilities from
a PC-based test environment.
TMS
TCK
TDI
ICE/JTAG JTAGSEL
Boundary TAP
TAP
TDO
POR
Reset
ICE and
Test TST
ARM7TDMI
PIO
DTXD
PDC DBGU
DRXD
47
6175H–ATARM–03-Dec-07
12.3 Application Examples
Host Debugger
ICE/JTAG
Interface
ICE/JTAG
Connector
AT91SAMS RS232
Terminal
Connector
Test Adaptor
Tester
JTAG
Interface
ICE/JTAG
Connector Chip n Chip 2
AT91SAM7S Chip 1
49
6175H–ATARM–03-Dec-07
12.4 Debug and Test Pin Description
51
6175H–ATARM–03-Dec-07
Table 12-2. AT91SAM7S Series Debug Unit Chip ID (Continued)
AT91SAM7S256 0x270B0940
AT91SAM7S256 Rev B 0x270D0941
AT91SAM7S512 0x270B0A40
For further details on the Debug Unit, see the Debug Unit section.
53
6175H–ATARM–03-Dec-07
Table 12-3. AT91SAM7Sxx JTAG Boundary Scan Register (Continued)
Associated BSR
Bit Number Pin Name Pin Type Cells
51 INPUT
50 PA9/PGMM1 IN/OUT OUTPUT
49 CONTROL
48 INPUT
47 PA8/PGMM0 IN/OUT OUTPUT
46 CONTROL
45 INPUT
44 PA7/PGMNVALID IN/OUT OUTPUT
43 CONTROL
42 INPUT
41 PA6/PGMNOE IN/OUT OUTPUT
40 CONTROL
39 INPUT
38 PA5/PGMRDY IN/OUT OUTPUT
37 CONTROL
36 INPUT
35 PA4/PGMNCMD IN/OUT OUTPUT
34 CONTROL
33 INPUT(1)
32 PA25/PGMD13 IN/OUT OUTPUT(1)
31 CONTROL(1)
30 INPUT(1)
29 PA26/PGMD14 IN/OUT OUTPUT(1)
28 CONTROL(1)
27 INPUT(1)
26 PA27/PGMD15 IN/OUT OUTPUT(1)
25 CONTROL(1)
24 INPUT(1)
23 PA28 IN/OUT OUTPUT(1)
22 CONTROL(1)
21 INPUT
20 PA3 IN/OUT OUTPUT
19 CONTROL
55
6175H–ATARM–03-Dec-07
12.5.5 ID Code Register
Access: Read-only
31 30 29 28 27 26 25 24
VERSION PART NUMBER
23 22 21 20 19 18 17 16
PART NUMBER
15 14 13 12 11 10 9 8
PART NUMBER MANUFACTURER IDENTITY
7 6 5 4 3 2 1 0
MANUFACTURER IDENTITY 1
• MANUFACTURER IDENTITY[11:1]
Set to 0x01F.
13.1 Overview
The Reset Controller (RSTC), based on power-on reset cells, handles all the resets of the sys-
tem without any external components. It reports which reset occurred last.
The Reset Controller also drives independently or simultaneously the external reset and the
peripheral and processor resets.
A brownout detection is also available to prevent the processor from falling into an unpredictable
state.
Reset Controller
proc_nreset
user_reset
NRST
NRST periph_nreset
Manager
nrst_out
exter_nreset
WDRPROC
wd_fault
SLCK
57
6175H–ATARM–03-Dec-07
13.3 Functional Description
URSTS
rstc_irq
NRSTL RSTC_MR Other
interrupt
URSTEN
sources
user_reset
NRST RSTC_MR
ERSTL
nrst_out
External Reset Timer exter_nreset
RSTC_MR
BODIEN
RSTC_SR
brown_out BODSTS rstc_irq
Other
interrupt
sources
59
6175H–ATARM–03-Dec-07
13.3.4 Reset States
The Reset State Manager handles the different reset sources and generates the internal reset
signals. It reports the reset status in the field RSTTYP of the Status Register (RSTC_SR). The
update of the field RSTTYP is performed when the processor reset is released.
SLCK
Any
MCK Freq.
Main Supply
POR output
Startup Time
Processor Startup
= 3 cycles
proc_nreset
periph_nreset
NRST
(nrst_out)
SLCK
Any
MCK Freq.
NRST
proc_nreset
periph_nreset
NRST
(nrst_out)
61
6175H–ATARM–03-Dec-07
13.3.4.3 Brownout Reset
When the brown_out/bod_reset signal is asserted, the Reset State Manager immediately enters
the Brownout Reset. In this state, the processor, the peripheral and the external reset lines are
asserted.
The Brownout Reset is left Y Slow Clock cycles after the rising edge of brown_out/bod_reset
after a two-cycle resynchronization. An external reset is also triggered.
When the processor reset is released, the field RSTTYP in RSTC_SR is loaded with the value
0x5, thus indicating that the last reset is a Brownout Reset.
SLCK
MCK Any
Freq.
brown_out
or bod_reset
proc_nreset
periph_nreset
NRST
(nrst_out)
SLCK
Any
MCK Freq.
Write RSTC_CR
Resynch. Processor Startup
1 cycle = 3 cycles
proc_nreset
if PROCRST=1
periph_nreset
if PERRST=1
NRST
(nrst_out)
if EXTRST=1
EXTERNAL RESET LENGTH
8 cycles (ERSTL=2)
SRCMP in RSTC_SR
63
6175H–ATARM–03-Dec-07
13.3.4.5 Watchdog Reset
The Watchdog Reset is entered when a watchdog fault occurs. This state lasts Y Slow Clock
cycles.
When in Watchdog Reset, assertion of the reset signals depends on the WDRPROC bit in
WDT_MR:
• If WDRPROC is 0, the Processor Reset and the Peripheral Reset are asserted. The NRST
line is also asserted, depending on the programming of the field ERSTL. However, the
resulting low level on NRST does not result in a User Reset state.
• If WDRPROC = 1, only the processor reset is asserted.
The Watchdog Timer is reset by the proc_nreset signal. As the watchdog fault always causes a
processor reset if WDRSTEN is set, the Watchdog Timer is always reset after a Watchdog
Reset, and the Watchdog is enabled by default and with a period set to a maximum.
When the WDRSTEN in WDT_MR bit is reset, the watchdog fault has no impact on the reset
controller.
SLCK
Any
MCK Freq.
wd_fault
Processor Startup
= 3 cycles
proc_nreset
periph_nreset
Only if
WDRPROC = 0
NRST
(nrst_out)
65
6175H–ATARM–03-Dec-07
Figure 13-9. Reset Controller Status and Interrupt
MCK
read
Peripheral Access RSTC_SR
2 cycle 2 cycle
resynchronization resynchronization
NRST
NRSTL
URSTS
rstc_irq
if (URSTEN = 0) and
(URSTIEN = 1)
67
6175H–ATARM–03-Dec-07
13.4.1 Reset Controller Control Register
Register Name: RSTC_CR
Access Type: Write-only
31 30 29 28 27 26 25 24
KEY
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – EXTRST PERRST – PROCRST
• KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
23 22 21 20 19 18 17 16
– – – – – – SRCMP NRSTL
15 14 13 12 11 10 9 8
– – – – – RSTTYP
7 6 5 4 3 2 1 0
– – – – – – BODSTS URSTS
69
6175H–ATARM–03-Dec-07
13.4.3 Reset Controller Mode Register
Register Name: RSTC_MR
Access Type: Read/Write
31 30 29 28 27 26 25 24
KEY
23 22 21 20 19 18 17 16
– – – – – – – BODIEN
15 14 13 12 11 10 9 8
– – – – ERSTL
7 6 5 4 3 2 1 0
– – – URSTIEN – – – URSTEN
• KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
14.1 Overview
The Real-time Timer is built around a 32-bit counter and used to count elapsed seconds. It gen-
erates a periodic interrupt or/and triggers an alarm on a programmed value.
RTT_MR
reload RTTINCIEN
SLCK 16-bit
Divider
0 set
RTT_MR RTT_SR RTTINC
RTTRST 1 0 reset
rtt_int
32-bit
Counter read
RTT_MR
RTT_SR
ALMIEN
reset
RTT_VR CRTV
RTT_SR ALMS
set
rtt_alarm
=
RTT_AR ALMV
71
6175H–ATARM–03-Dec-07
The Real-time Timer value (CRTV) can be read at any time in the register RTT_VR (Real-time
Value Register). As this value can be updated asynchronously from the Master Clock, it is advis-
able to read this register twice at the same value to improve accuracy of the returned value.
The current value of the counter is compared with the value written in the alarm register
RTT_AR (Real-time Alarm Register). If the counter value matches the alarm, the bit ALMS in
RTT_SR is set. The alarm register is set to its maximum value, corresponding to 0xFFFF_FFFF,
after a reset.
The bit RTTINC in RTT_SR is set each time the Real-time Timer counter is incremented. This bit
can be used to start a periodic interrupt, the period being one second when the RTPRES is pro-
grammed with 0x8000 and Slow Clock equal to 32.768 Hz.
Reading the RTT_SR status register resets the RTTINC and ALMS fields.
Writing the bit RTTRST in RTT_MR immediately reloads and restarts the clock divider with the
new programmed value. This also resets the 32-bit counter.
Note: Because of the asynchronism between the Slow Clock (SCLK) and the System Clock (MCK):
1) The restart of the counter and the reset of the RTT_VR current value register is effective only 2
slow clock cycles after the write of the RTTRST bit in the RTT_MR register.
2) The status register flags reset is taken into account only 2 slow clock cycles after the read of the
RTT_SR (Status Register).
MCK
RTPRES - 1
Prescaler
RTTINC (RTT_SR)
ALMS (RTT_SR)
APB Interface
read RTT_SR
73
6175H–ATARM–03-Dec-07
14.4.1 Real-time Timer Mode Register
Register Name: RTT_MR
Access Type: Read-write
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – RTTRST RTTINCIEN ALMIEN
15 14 13 12 11 10 9 8
RTPRES
7 6 5 4 3 2 1 0
RTPRES
23 22 21 20 19 18 17 16
ALMV
15 14 13 12 11 10 9 8
ALMV
7 6 5 4 3 2 1 0
ALMV
23 22 21 20 19 18 17 16
CRTV
15 14 13 12 11 10 9 8
CRTV
7 6 5 4 3 2 1 0
CRTV
75
6175H–ATARM–03-Dec-07
14.4.4 Real-time Timer Status Register
Register Name: RTT_SR
Access Type: Read-only
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
– – – – – – RTTINC ALMS
15.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 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.
77
6175H–ATARM–03-Dec-07
15.2 Block Diagram
PIO Controller
PIO Interrupt
AIC
PIO Clock
PMC
Data, Enable
Up to 32
peripheral IOs
Embedded
Peripheral
PIN 0
Data, Enable
PIN 1
Up to 32 pins
Up to 32
Embedded peripheral IOs
Peripheral PIN 31
APB
PIO Controller
79
6175H–ATARM–03-Dec-07
15.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 15-3. In this description each signal shown
represents but one of up to 32 possible indexes.
PIO_OER[0]
PIO_OSR[0]
PIO_ODR[0] PIO_PUER[0]
PIO_PUSR[0]
1 PIO_PUDR[0]
Peripheral A
Output Enable 0
0
Peripheral B
0
Output Enable 1
PIO_ASR[0] PIO_PER[0]
PIO_ABSR[0] PIO_PSR[0] 1
Peripheral B 1 0
PIO_SODR[0]
Output
PIO_ODSR[0] 1 Pad
PIO_CODR[0] 1
Peripheral A
Input
Peripheral B
PIO_PDSR[0] PIO_ISR[0] Input
0
(Up to 32 possible inputs)
Edge
Detector
Glitch 1 PIO Interrupt
Filter
PIO_IFER[0]
PIO_IFSR[0] PIO_IER[0]
PIO_IFDR[0] PIO_IMR[0]
PIO_IDR[0]
PIO_ISR[31]
PIO_IER[31]
PIO_IMR[31]
PIO_IDR[31]
81
6175H–ATARM–03-Dec-07
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.
MCK
PIO_ODSR
2 cycles 2 cycles
PIO_PDSR
15.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.
83
6175H–ATARM–03-Dec-07
Figure 15-5. Input Glitch Filter Timing
MCK
up to 1.5 cycles
Pin Level
1 cycle 1 cycle 1 cycle 1 cycle
PIO_PDSR
if PIO_IFSR = 0
2 cycles 1 cycle
MCK
Pin Level
PIO_ISR
• 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
85
6175H–ATARM–03-Dec-07
15.6 Parallel Input/Output Controller (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.
87
6175H–ATARM–03-Dec-07
15.6.1 PIO Controller PIO Enable Register
Name: PIO_PER
Access Type: Write-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
89
6175H–ATARM–03-Dec-07
15.6.5 PIO Controller Output Disable Register
Name: PIO_ODR
Access Type: Write-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
91
6175H–ATARM–03-Dec-07
15.6.9 PIO Controller Input Filter Status Register
Name: PIO_IFSR
Access Type: Read-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
93
6175H–ATARM–03-Dec-07
15.6.13 PIO Controller Pin Data Status Register
Name: PIO_PDSR
Access Type: Read-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
95
6175H–ATARM–03-Dec-07
15.6.17 PIO Controller Interrupt Status Register
Name: PIO_ISR
Access Type: Read-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
97
6175H–ATARM–03-Dec-07
15.6.21 PIO Pull Up Disable Register
Name: PIO_PUDR
Access Type: Write-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
99
6175H–ATARM–03-Dec-07
15.6.25 PIO Peripheral B Select Register
Name: PIO_BSR
Access Type: Write-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
101
6175H–ATARM–03-Dec-07
15.6.29 PIO Output Write Status Register
Name: PIO_OWSR
Access Type: Read-only
31 30 29 28 27 26 25 24
P31 P30 P29 P28 P27 P26 P25 P24
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
16.1 Overview
The Periodic Interval Timer (PIT) provides the operating system’s scheduler interrupt. It is
designed to offer maximum accuracy and efficient management, even for systems with long
response time.
PIV
=? PIT_MR
PITIEN
set
0 pit_irq
PIT_SR PITS
reset
0 0 1
12-bit
0 1
Adder
read PIT_PIVR
MCK 20-bit
Counter
MCK/16
Prescaler CPIV PIT_PIVR PICNT
103
6175H–ATARM–03-Dec-07
16.3 Functional Description
The Periodic Interval Timer aims at providing periodic interrupts for use by operating systems.
The PIT provides a programmable overflow counter and a reset-on-read feature. It is built
around two counters: a 20-bit CPIV counter and a 12-bit PICNT counter. Both counters work at
Master Clock /16.
The first 20-bit CPIV counter increments from 0 up to a programmable overflow value set in the
field PIV of the Mode Register (PIT_MR). When the counter CPIV reaches this value, it resets to
0 and increments the Periodic Interval Counter, PICNT. The status bit PITS in the Status Regis-
ter (PIT_SR) rises and triggers an interrupt, provided the interrupt is enabled (PITIEN in
PIT_MR).
Writing a new PIV value in PIT_MR does not reset/restart the counters.
When CPIV and PICNT values are obtained by reading the Periodic Interval Value Register
(PIT_PIVR), the overflow counter (PICNT) is reset and the PITS is cleared, thus acknowledging
the interrupt. The value of PICNT gives the number of periodic intervals elapsed since the last
read of PIT_PIVR.
When CPIV and PICNT values are obtained by reading the Periodic Interval Image Register
(PIT_PIIR), there is no effect on the counters CPIV and PICNT, nor on the bit PITS. For exam-
ple, a profiler can read PIT_PIIR without clearing any pending interrupt, whereas a timer
interrupt clears the interrupt by reading PIT_PIVR.
The PIT may be enabled/disabled using the PITEN bit in the PIT_MR register (disabled on
reset). The PITEN bit only becomes effective when the CPIV value is 0. Figure 16-2 illustrates
the PIT counting. After the PIT Enable bit is reset (PITEN= 0), the CPIV goes on counting until
the PIV value is reached, and is then reset. PIT restarts counting, only if the PITEN is set again.
The PIT is stopped when the core enters debug state.
MCK
15
MCK Prescaler 0
PITEN
PICNT 0 1 0
PITS (PIT_SR)
APB Interface
read PIT_PIVR
105
6175H–ATARM–03-Dec-07
16.4 Periodic Interval Timer (PIT) User Interface
Table 16-1. Register Mapping
Offset Register Name Access Reset
0x00 Mode Register PIT_MR Read-write 0x000F_FFFF
0x04 Status Register PIT_SR Read-only 0x0000_0000
0x08 Periodic Interval Value Register PIT_PIVR Read-only 0x0000_0000
0x0C Periodic Interval Image Register PIT_PIIR Read-only 0x0000_0000
23 22 21 20 19 18 17 16
– – – – PIV
15 14 13 12 11 10 9 8
PIV
7 6 5 4 3 2 1 0
PIV
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – – PITS
107
6175H–ATARM–03-Dec-07
16.4.3 Periodic Interval Timer Value Register
Register Name: PIT_PIVR
Access Type: Read-only
31 30 29 28 27 26 25 24
PICNT
23 22 21 20 19 18 17 16
PICNT CPIV
15 14 13 12 11 10 9 8
CPIV
7 6 5 4 3 2 1 0
CPIV
23 22 21 20 19 18 17 16
PICNT CPIV
15 14 13 12 11 10 9 8
CPIV
7 6 5 4 3 2 1 0
CPIV
17.1 Overview
The Watchdog Timer can be used to prevent system lock-up if the software becomes trapped in
a deadlock. It features a 12-bit down counter that allows a watchdog period of up to 16 seconds
(slow clock at 32.768 kHz). It can generate a general reset or a processor reset only. In addition,
it can be stopped while the processor is in debug mode or idle mode.
write WDT_MR
WDT_MR
WDV
WDT_CR
WDRSTT reload
1 0
12-bit Down
Counter
WDT_MR
reload
WDD Current
1/128 SLCK
Value
<= WDD
WDT_MR
WDRSTEN
= 0
wdt_fault
(to Reset Controller)
set
WDUNF wdt_int
set reset
WDERR
read WDT_SR reset WDFIEN
or
reset WDT_MR
109
6175H–ATARM–03-Dec-07
17.3 Functional Description
The Watchdog Timer can be used to prevent system lock-up if the software becomes trapped in
a deadlock. It is supplied with VDDCORE. It restarts with initial values on processor reset.
The Watchdog is built around a 12-bit down counter, which is loaded with the value defined in
the field WDV of the Mode Register (WDT_MR). The Watchdog Timer uses the Slow Clock
divided by 128 to establish the maximum Watchdog period to be 16 seconds (with a typical Slow
Clock of 32.768 kHz).
After a Processor Reset, the value of WDV is 0xFFF, corresponding to the maximum value of
the counter with the external reset generation enabled (field WDRSTEN at 1 after a Backup
Reset). This means that a default Watchdog is running at reset, i.e., at power-up. The user must
either disable it (by setting the WDDIS bit in WDT_MR) if he does not expect to use it or must
reprogram it to meet the maximum Watchdog period the application requires.
The Watchdog Mode Register (WDT_MR) can be written only once. Only a processor reset
resets it. Writing the WDT_MR register reloads the timer with the newly programmed mode
parameters.
In normal operation, the user reloads the Watchdog at regular intervals before the timer under-
flow occurs, by writing the Control Register (WDT_CR) with the bit WDRSTT to 1. The
Watchdog counter is then immediately reloaded from WDT_MR and restarted, and the Slow
Clock 128 divider is reset and restarted. The WDT_CR register is write-protected. As a result,
writing WDT_CR without the correct hard-coded key has no effect. If an underflow does occur,
the “wdt_fault” signal to the Reset Controller is asserted if the bit WDRSTEN is set in the Mode
Register (WDT_MR). Moreover, the bit WDUNF is set in the Watchdog Status Register
(WDT_SR).
To prevent a software deadlock that continuously triggers the Watchdog, the reload of the
Watchdog must occur while the Watchdog counter is within a window between 0 and WDD,
WDD is defined in the WatchDog Mode Register WDT_MR.
Any attempt to restart the Watchdog while the Watchdog counter is between WDV and WDD
results in a Watchdog error, even if the Watchdog is disabled. The bit WDERR is updated in the
WDT_SR and the “wdt_fault” signal to the Reset Controller is asserted.
Note that this feature can be disabled by programming a WDD value greater than or equal to the
WDV value. In such a configuration, restarting the Watchdog Timer is permitted in the whole
range [0; WDV] and does not generate an error. This is the default configuration on reset (the
WDD and WDV values are equal).
The status bits WDUNF (Watchdog Underflow) and WDERR (Watchdog Error) trigger an inter-
rupt, provided the bit WDFIEN is set in the mode register. The signal “wdt_fault” to the reset
controller causes a Watchdog reset if the WDRSTEN bit is set as already explained in the reset
controller programmer Datasheet. In that case, the processor and the Watchdog Timer are
reset, and the WDERR and WDUNF flags are reset.
If a reset is generated or if WDT_SR is read, the status bits are reset, the interrupt is cleared,
and the “wdt_fault” signal to the reset controller is deasserted.
Writing the WDT_MR reloads and restarts the down counter.
While the processor is in debug state or in idle mode, the counter may be stopped depending on
the value programmed for the bits WDIDLEHLT and WDDBGHLT in the WDT_MR.
if WDRSTEN is 1
FFF
Forbidden
Window
WDD
Permitted
Window
WDT_CR = WDRSTT
Watchdog
Fault
111
6175H–ATARM–03-Dec-07
17.4 Watchdog Timer (WDT) User Interface
Table 17-1. Register Mapping
Offset Register Name Access Reset
0x00 Control Register WDT_CR Write-only -
0x04 Mode Register WDT_MR Read-write Once 0x3FFF_2FFF
0x08 Status Register WDT_SR Read-only 0x0000_0000
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – – WDRSTT
• KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
23 22 21 20 19 18 17 16
WDD
15 14 13 12 11 10 9 8
WDDIS WDRPROC WDRSTEN WDFIEN WDV
7 6 5 4 3 2 1 0
WDV
113
6175H–ATARM–03-Dec-07
• WDDIS: Watchdog Disable
0: Enables the Watchdog Timer.
1: Disables the Watchdog Timer.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – WDERR WDUNF
18.1 Overview
The Voltage Regulator Mode Controller contains one Read/Write register, the Voltage Regulator
Mode Register. Its offset is 0x60 with respect to the System Controller offset.
This register controls the Voltage Regulator Mode. Setting PSTDBY (bit 0) puts the Voltage
Regulator in Standby Mode or Low-power Mode. On reset, the PSTDBY is reset, so as to wake
up the Voltage Regulator in Normal Mode.
115
6175H–ATARM–03-Dec-07
18.2 Voltage Regulator Power Controller (VREG) User Interface
Table 18-1. Register Mapping
Offset Register Name Access Reset
0x60 Voltage Regulator Mode Register VREG_MR Read-write 0x0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – – PSTDBY
19.1 Overview
The Memory Controller (MC) manages the ASB bus and controls accesses requested by the
masters, typically the ARM7TDMI processor and the Peripheral DMA Controller. It features a
simple bus arbiter, an address decoder, an abort status, a misalignment detector and an
Embedded Flash Controller.
Memory Controller
ASB
Embedded Internal
ARM7TDMI Flash
Processor Flash
Abort Controller
Abort
Status
Internal
RAM
Misalignment Address
Bus Detector Decoder
Arbiter
User
Interface
Peripheral
DMA APB
Controller Bridge
Peripheral 0
Peripheral 1 APB
From Master
to Slave
Peripheral N
117
6175H–ATARM–03-Dec-07
19.3 Functional Description
The Memory Controller handles the internal ASB bus and arbitrates the accesses of both
masters.
It is made up of:
• A bus arbiter
• An address decoder
• An abort status
• A misalignment detector
• An Embedded Flash Controller
The MC handles only little-endian mode accesses. The masters work in little-endian mode only.
14 x 256MBytes Undefined
3,584 Mbytes (Abort)
0xEFFF FFFF
0xF000 0000
256M Bytes Peripherals
0xFFFF FFFF
0x0FFF FFFF
119
6175H–ATARM–03-Dec-07
19.3.4 Abort Status
There are three reasons for an abort to occur:
• access to an undefined address
• an access to a misaligned address.
When an abort occurs, a signal is sent back to all the masters, regardless of which one has gen-
erated the access. However, only the ARM7TDMI can take an abort signal into account, and
only under the condition that it was generating an access. The Peripheral DMA Controller does
not handle the abort input signal. Note that the connection is not represented in Figure 19-1.
To facilitate debug or for fault analysis by an operating system, the Memory Controller integrates
an Abort Status register set.
The full 32-bit wide abort address is saved in MC_AASR. Parameters of the access are saved in
MC_ASR and include:
• the size of the request (field ABTSZ)
• the type of the access, whether it is a data read or write, or a code fetch (field ABTTYP)
• whether the access is due to accessing an undefined address (bit UNDADD) or a misaligned
address (bit MISADD)
• the source of the access leading to the last abort (bits MST0 and MST1)
• whether or not an abort occurred for each master since the last read of the register (bit
SVMST0 and SVMST1) unless this information is loaded in MST bits
In the case of a Data Abort from the processor, the address of the data access is stored. This is
useful, as searching for which address generated the abort would require disassembling the
instructions and full knowledge of the processor context.
In the case of a Prefetch Abort, the address may have changed, as the prefetch abort is pipe-
lined in the ARM processor. The ARM processor takes the prefetch abort into account only if the
read instruction is executed and it is probable that several aborts have occurred during this time.
Thus, in this case, it is preferable to use the content of the Abort Link register of the ARM
processor.
As the requested address is saved in the Abort Status Register and the address of the instruc-
tion generating the misalignment is saved in the Abort Link Register of the processor, detection
and fix of this kind of software bug is simplified.
121
6175H–ATARM–03-Dec-07
19.4.1 MC Remap Control Register
Register Name: MC_RCR
Access Type: Write-only
Offset: 0x00
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
– – – – – – – RCB
23 22 21 20 19 18 17 16
– – – – – – MST1 MST0
15 14 13 12 11 10 9 8
– – – – ABTTYP ABTSZ
7 6 5 4 3 2 1 0
– – – – – – MISADD UNDADD
123
6175H–ATARM–03-Dec-07
• MST1: ARM7TDMI Abort Source
0: The last aborted access was not due to the ARM7TDMI.
1: The last aborted access was due to the ARM7TDMI.
23 22 21 20 19 18 17 16
ABTADD
15 14 13 12 11 10 9 8
ABTADD
7 6 5 4 3 2 1 0
ABTADD
20.1 Overview
The Embedded Flash Controller (EFC ) is a part of the Memory Controller and ensures the inter-
face of the Flash block with the 32-bit internal bus. It increases performance in Thumb Mode for
Code Fetch with its system of 32-bit buffers. It also manages the programming, erasing, locking
and unlocking sequences using a full set of commands.
The AT91SAM7S512 is equipped with two EFCs, EFC0 and EFC1. EFC1 does not feature the
Security bit and GPNVM bit. The Security and GPNVM bits embedded only on EFC0 apply to
the two blocks in the AT91SAM7S512.
125
6175H–ATARM–03-Dec-07
Figure 20-1. Embedded Flash Memory Mapping
Page 0
Flash Memory
Start Address
Lock Region 0 Lock Bit 0 Page (m-1)
32-bit wide
Page (n*m-1)
Master Clock
Flash Access Bytes 0-3 Bytes 4-7 Bytes 8-11 Bytes 12-15 Bytes 16-19
Buffer (32 bits) Bytes 0-3 Bytes 4-7 Bytes 8-11 Bytes 12-15
Data To ARM Bytes 0-1 Bytes 2-3 Bytes 4-5 Bytes 6-7 Bytes 8-9 Bytes 10-11 Bytes 12-13 Bytes 14-15
Note: When FWS is equal to 0, all accesses are performed in a single-cycle access.
Master Clock
Flash Access Bytes 0-3 Bytes 4-7 Bytes 8-11 Bytes 12-15
Data To ARM Bytes 0-1 Bytes 2-3 Bytes 4-5 Bytes 6-7 Bytes 8-9 Bytes 10-11 Bytes 12-13
127
6175H–ATARM–03-Dec-07
Note: When FWS is equal to 1, in case of sequential reads, all the accesses are performed in a single-cycle access (except for the
first one).
Master Clock
Note: When FWS is equal to 2 or 3, in case of sequential reads, the first access takes FWS cycles, the second access one cycle, the
third access FWS cycles, the fourth access one cycle, etc.
To run one of these commands, the field FCMD of the MC_FCR register has to be written with
the command number. As soon as the MC_FCR register is written, the FRDY flag is automati-
cally cleared. Once the current command is achieved, then the FRDY flag is automatically set. If
an interrupt has been enabled by setting the bit FRDY in MC_FMR, the interrupt line of the Mem-
ory Controller is activated.
All the commands are protected by the same keyword, which has to be written in the eight high-
est bits of the MC_FCR register.
Writing MC_FCR with data that does not contain the correct key and/or with an invalid command
has no effect on the memory plane; however, the PROGE flag is set in the MC_FSR register.
This flag is automatically cleared by a read access to the MC_FSR register.
When the current command writes or erases a page in a locked region, the command has no
effect on the whole memory plane; however, the LOCKE flag is set in the MC_FSR register. This
flag is automatically cleared by a read access to the MC_FSR register.
129
6175H–ATARM–03-Dec-07
Figure 20-5. Command State Chart
No
Check if FRDY flag set
Yes
No
Check if FRDY flag set
Yes
Yes
Check if LOCKE flag set Locking region violation
No
Yes
Check if PROGE flag set Bad keyword violation and/or Invalid command
No
Command Successful
In order to guarantee valid operations on the Flash memory, the field Flash Microsecond Cycle
Number (FMCN) in the Flash Mode Register MC_FMR must be correctly programmed (see “MC
Flash Mode Register” on page 136).
FF FF FF FF FF FF FF FF FF FF FF FF
... ... ...
16 words FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF CA FE CA FE CA FE CA FE
... ... ...
16 words FF FF FF FF CA FE CA FE CA FE CA FE
FF FF FF FF CA FE CA FE CA FE CA FE
FF FF FF FF FF FF FF FF DE CA DE CA
... ... ...
16 words FF FF FF FF FF FF FF FF DE CA DE CA
FF FF FF FF FF FF FF FF DE CA DE CA
FF FF FF FF FF FF FF FF FF FF FF FF
... ... ...
16 words FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
After programming, the page (the whole lock region) can be locked to prevent miscellaneous
write or erase sequences. The lock bit can be automatically set after page programming using
WPL.
Data to be written are stored in an internal latch buffer. The size of the latch buffer corresponds
to the page size. The latch buffer wraps around within the internal memory area address space
and appears to be repeated by the number of pages in it.
Note: Writing of 8-bit and 16-bit data is not allowed and may lead to unpredictable data corruption.
Data are written to the latch buffer before the programming command is written to the Flash
Command Register MC_FCR. The sequence is as follows:
• Write the full page, at any page address, within the internal memory area address space
using only 32-bit access.
• Programming starts as soon as the page number and the programming command are written
to the Flash Command Register. The FRDY bit in the Flash Programming Status Register
(MC_FSR) is automatically cleared.
• When programming is completed, the bit FRDY in the Flash Programming Status Register
(MC_FSR) rises. If an interrupt was enabled by setting the bit FRDY in MC_FMR, the
interrupt line of the Memory Controller is activated.
Two errors can be detected in the MC_FSR register after a programming sequence:
• Programming Error: A bad keyword and/or an invalid command have been written in the
MC_FCR register.
• Lock Error: The page to be programmed belongs to a locked region. A command must be
previously run to unlock the corresponding region.
131
6175H–ATARM–03-Dec-07
Erase All operation is allowed only if there are no lock bits set. Thus, if at least one lock region is
locked, the bit LOCKE in MC_FSR rises and the command is cancelled. If the bit LOCKE has
been written at 1 in MC_FMR, the interrupt line rises.
When programming is complete, the bit FRDY bit in the Flash Programming Status Register
(MC_FSR) rises. If an interrupt has been enabled by setting the bit FRDY in MC_FMR, the inter-
rupt line of the Memory Controller is activated.
Two errors can be detected in the MC_FSR register after a programming sequence:
• Programming Error: A bad keyword and/or an invalid command have been written in the
MC_FCR register.
• Lock Error: At least one lock region to be erased is protected. The erase command has been
refused and no page has been erased. A Clear Lock Bit command must be executed
previously to unlock the corresponding lock regions.
133
6175H–ATARM–03-Dec-07
• When the locking completes, the bit FRDY in the Flash Programming Status Register
(MC_FSR) rises. If an interrupt has been enabled by setting the bit FRDY in MC_FMR, the
interrupt line of the Memory Controller is activated.
When the security bit is active, the SECURITY bit in the MC_FSR is set.
135
6175H–ATARM–03-Dec-07
20.3.1 MC Flash Mode Register
Register Name: MC_FMR
Access Type: Read-write
Offset: (EFC0) 0x60
Offset: (EFC1) 0x70
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
FMCN
15 14 13 12 11 10 9 8
– – – – – – FWS
7 6 5 4 3 2 1 0
NEBP – – – PROGE LOCKE – FRDY
137
6175H–ATARM–03-Dec-07
20.3.2 MC Flash Command Register
Register Name: MC_FCR
Access Type: Write-only
Offset: (EFC0) 0x64
Offset: (EFC1) 0x74
31 30 29 28 27 26 25 24
KEY
23 22 21 20 19 18 17 16
– – – – – – PAGEN
15 14 13 12 11 10 9 8
PAGEN
7 6 5 4 3 2 1 0
– – – – FCMD
FCMD Operations
No command.
0000
Does not raise the Programming Error Status flag in the Flash Status Register MC_FSR.
Write Page Command (WP):
0001
Starts the programming of the page specified in the PAGEN field.
Set Lock Bit Command (SLB):
0010
Starts a set lock bit sequence of the lock region specified in the PAGEN field.
Write Page and Lock Command (WPL):
0011 The lock sequence of the lock region associated with the page specified in the field PAGEN
occurs automatically after completion of the programming sequence.
Clear Lock Bit Command (CLB):
0100
Starts a clear lock bit sequence of the lock region specified in the PAGEN field.
Erase All Command (EA):
1000 Starts the erase of the entire Flash.
If at least one page is locked, the command is cancelled.
Set General-purpose NVM Bit (SGPB):
1011 Activates the general-purpose NVM bit corresponding to the number specified in the PAGEN
field.
Clear General Purpose NVM Bit (CGPB):
1101 Deactivates the general-purpose NVM bit corresponding to the number specified in the
PAGEN field.
Set Security Bit Command (SSB):
1111
Sets security bit.
Reserved.
Others
Raises the Programming Error Status flag in the Flash Status Register MC_FSR.
139
6175H–ATARM–03-Dec-07
20.3.3 MC Flash Status Register
Register Name: MC_FSR
Access Type: Read-only
Offset: (EFC0) 0x68
Offset: (EFC1) 0x78
31 30 29 28 27 26 25 24
LOCKS15 LOCKS14 LOCKS13 LOCKS12 LOCKS11 LOCKS10 LOCKS9 LOCKS8
23 22 21 20 19 18 17 16
LOCKS7 LOCKS6 LOCKS5 LOCKS4 LOCKS3 LOCKS2 LOCKS1 LOCKS0
15 14 13 12 11 10 9 8
– – – – – – GPNVM1 GPNVM0
7 6 5 4 3 2 1 0
– – – SECURITY PROGE LOCKE – FRDY
• SECURITY: Security Bit Status (Does not apply to EFC1 on the AT91SAM7S512.)
0: The security bit is inactive.
1: The security bit is active.
• GPNVMx: General-purpose NVM Bit Status (Does not apply to EFC1 on the AT91SAM7S512.)
0: The corresponding general-purpose NVM bit is inactive.
1: The corresponding general-purpose NVM bit is active.
141
6175H–ATARM–03-Dec-07
142 AT91SAM7S Series Preliminary
6175H–ATARM–03-Dec-07
AT91SAM7S Series Preliminary
21.1 Overview
The Fast Flash Programming Interface provides two solutions - parallel or serial - for high-vol-
ume programming using a standard gang programmer. The parallel interface is fully
handshaked and the device is considered to be a standard EEPROM. Additionally, the parallel
protocol offers an optimized access to all the embedded Flash functionalities. The serial inter-
face uses the standard IEEE 1149.1 JTAG protocol. It offers an optimized access to all the
embedded Flash functionalities.
Although the Fast Flash Programming Mode is a dedicated mode for high volume programming,
this mode is not designed for in-situ programming.
143
6175H–ATARM–03-Dec-07
21.2 Parallel Fast Flash Programming
VDDIO TST
VDDIO PGMEN0
VDDIO PGMEN1
GND PGMEN2 VDDCORE
VDDIO
NCMD PGMNCMD
RDY PGMRDY VDDPLL
NOE PGMNOE VDDFLASH
MODE[3:0] PGMM[3:0]
DATA[15:0] PGMD[15:0]
0 - 50MHz XIN
VDDIO TST
VDDIO PGMEN0
VDDIO PGMEN1
GND PGMEN2 VDDCORE
VDDIO
NCMD PGMNCMD
RDY PGMRDY VDDPLL
NOE PGMNOE VDDFLASH
MODE[3:0] PGMM[3:0]
DATA[7:0] PGMD[7:0]
0 - 50MHz XIN
145
6175H–ATARM–03-Dec-07
21.2.2 Signal Names
Depending on the MODE settings, DATA is latched in different internal registers.
When MODE is equal to CMDE, then a new command (strobed on DATA[15:0] or DATA[7:0]
signals) is stored in the command register.
Note: DATA[7:0] pertains to the AT91SAM7S32/16.
NCMD 2 4
3 5
RDY
NOE
NVALID
DATA[15:0]
1
MODE[3:0]
147
6175H–ATARM–03-Dec-07
Figure 21-4. AT91SAM7S32/16 Parallel Programming Timing, Write Sequence
NCMD 2 4
3 5
RDY
NOE
NVALID
DATA[7:0]
1
MODE[3:0]
NCMD 2 12
3 13
RDY
NOE 5 9
NVALID 7 11
4 6 8 10
MODE[3:0] ADDR
NCMD 2 12
3 13
RDY
NOE 5 9
NVALID 7 11
4 6 8 10
MODE[3:0] ADDR
149
6175H–ATARM–03-Dec-07
21.2.5 Device Operations
Several commands on the Flash memory are available. These commands are summarized in
Table 21-3 on page 146. Each command is driven by the programmer through the parallel inter-
face running several read/write handshaking sequences.
When a new command is executed, the previous one is automatically achieved. Thus, chaining
a read command after a write automatically flushes the load buffer in the Flash.
In the following tables, 21-6 through 21-18
• DATA[15:0] pertains to AT91SAM7S512/256/128/64/321/161
• DATA[7:0] pertains to AT91SAM7S32/16
151
6175H–ATARM–03-Dec-07
Table 21-9. Write Command (Continued)
Step Handshake Sequence MODE[3:0] DATA[7:0]
5 Write handshaking ADDR3 Memory Address
6 Write handshaking DATA *Memory Address++
7 Write handshaking DATA *Memory Address++
... ... ... ...
n Write handshaking ADDR0 Memory Address LSB
n+1 Write handshaking ADDR1 Memory Address
n+2 Write handshaking ADDR2 Memory Address
n+3 Write handshaking ADDR3 Memory Address
n+4 Write handshaking DATA *Memory Address++
n+5 Write handshaking DATA *Memory Address++
... ... ... ...
The Flash command Write Page and Lock (WPL) is equivalent to the Flash Write Command.
However, the lock bit is automatically set at the end of the Flash write operation. As a lock region
is composed of several pages, the programmer writes to the first pages of the lock region using
Flash write commands and writes to the last page of the lock region using a Flash write and lock
command.
The Flash command Erase Page and Write (EWP) is equivalent to the Flash Write Command.
However, before programming the load buffer, the page is erased.
The Flash command Erase Page and Write the Lock (EWPL) combines EWP and WPL
commands.
In the same way, the Clear Lock command (CLB) is used to clear lock bits. All the lock bits are
also cleared by the EA command.
Lock bits can be read using Get Lock Bit command (GLB). The nth lock bit is active when the bit
n of the bit mask is set..
General-purpose NVM bits can be read using the Get GPNVM Bit command (GGPB). The nth
GP NVM bit is active when bit n of the bit mask is set..
153
6175H–ATARM–03-Dec-07
The AT91SAM7S512 security bit is controlled by the EFC0. To use the Set Security Bit com-
mand, the EFC0 must be selected using the Select EFC command
Once the security bit is set, it is not possible to access FFPI. The only way to erase the security
bit is to erase the Flash.
In order to erase the Flash, the user must perform the following:
• Power-off the chip
• Power-on the chip with TST = 0
• Assert Erase during a period of more than 220 ms
• Power-off the chip
Then it is possible o return to FFPI mode and check that Flash is erased.
155
6175H–ATARM–03-Dec-07
21.3 Serial Fast Flash Programming
The Serial Fast Flash programming interface is based on IEEE Std. 1149.1 “Standard Test
Access Port and Boundary-Scan Architecture”. Refer to this standard for an explanation of terms
used in this chapter and for a description of the TAP controller states.
In this mode, data read/written from/to the embedded Flash of the device are transmitted
through the JTAG interface of the device.
VDDIO TST
VDDIO PGMEN0
VDDIO PGMEN1
GND PGMEN2 VDDCORE
VDDIO
TDI
TDO VDDPLL
TMS VDDFLASH
TCK GND
0-50MHz XIN
157
6175H–ATARM–03-Dec-07
21.3.3 Read/Write Handshake
The read/write handshake is done by carrying out read/write operations on two registers of the
device that are accessible through the JTAG:
• Debug Comms Control Register: DCCR
• Debug Comms Data Register: DCDR
Access to these registers is done through the TAP 38-bit DR register comprising a 32-bit data
field, a 5-bit address field and a read/write bit. The data to be written is scanned into the 32-bit
data field with the address of the register to the 5-bit address field and 1 to the read/write bit. A
register is read by scanning its address into the address field and 0 into the read/write bit, going
through the UPDATE-DR TAP state, then scanning out the data.
Refer to the ARM7TDMI reference manuel for more information on Comm channel operations.
5 32
A read or write takes place when the TAP controller enters UPDATE-DR state. Refer to the IEEE
1149.1 for more details on JTAG operations.
• The address of the Debug Comms Control Register is 0x04.
• The address of the Debug Comms Data Register is 0x05.
The Debug Comms Control Register is read-only and allows synchronized handshaking
between the processor and the debugger.
– Bit 1 (W): Denotes whether the programmer can read a data through the Debug
Comms Data Register. If the device is busy W = 0, then the programmer must poll
until W = 1.
– Bit 0 (R): Denotes whether the programmer can send data from the Debug Comms
Data Register. If R = 1, data previously placed there through the scan chain has not
been collected by the device and so the programmer must wait.
The write handshake is done by polling the Debug Comms Control Register until the R bit is
cleared. Once cleared, data can be written to the Debug Comms Data Register.
The read handshake is done by polling the Debug Comms Control Register until the W bit is set.
Once set, data can be read in the Debug Comms Data Register.
Flash Write Page and Lock command (WPL) is equivalent to the Flash Write Command. How-
ever, the lock bit is automatically set at the end of the Flash write operation. As a lock region is
composed of several pages, the programmer writes to the first pages of the lock region using
Flash write commands and writes to the last page of the lock region using a Flash write and lock
command.
Flash Erase Page and Write command (EWP) is equivalent to the Flash Write Command. How-
ever, before programming the load buffer, the page is erased.
Flash Erase Page and Write the Lock command (EWPL) combines EWP and WPL
commands.
159
6175H–ATARM–03-Dec-07
21.3.4.3 Flash Full Erase Command
This command is used to erase the Flash memory planes.
All lock bits must be deactivated before using the Full Erase command. This can be done by
using the CLB command.
Lock bits can be read using Get Lock Bit command (GLB). When a bit set in the Bit Mask is
returned, then the corresponding lock bit is active.
GP NVM bits can be read using Get GPNVM Bit command (GGPB). When a bit set in the Bit
Mask is returned, then the corresponding GPNVM bit is set.
Once the security bit is set, it is not possible to access FFPI. The only way to erase the security
bit is to erase the Flash.
In order to erase the Flash, the user must perform the following:
• Power-off the chip
• Power-on the chip with TST = 0
• Assert Erase during a period of more than 220 ms
• Power-off the chip
Then it is possible to return to FFPI mode and check that Flash is erased.
161
6175H–ATARM–03-Dec-07
21.3.4.8 Memory Write Command
This command is used to perform a write access to any memory location.
The Memory Write command (WRAM) is optimized for consecutive writes. An internal address
buffer is automatically increased.
22.1 Description
The Boot Program integrates different programs permitting download and/or upload into the
different memories of the product.
First, it initializes the Debug Unit serial port (DBGU) and the USB Device Port.
SAM-BA™ Boot is then executed. It waits for transactions either on the USB device or on the
DBGU serial port.
No AutoBaudrate
Device USB Enumeration Sequence Successful ?
Setup Successful ?
Yes Yes
163
6175H–ATARM–03-Dec-07
22.3 Device Initialization with USB
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 165)
Device
Setup
Character '0x80' No
1st measurement
received ?
Yes
Yes
Yes
165
6175H–ATARM–03-Dec-07
– Once the communication interface is identified, the application runs in an infinite
loop waiting for different commands as shown in Table 22-1.
• 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: ‘>’
Host Device
ACK
ACK
ACK
EOT
ACK
167
6175H–ATARM–03-Dec-07
22.5.3 USB Device Port
A 48 MHz USB clock is necessary to use the USB Device port. It has been programmed ear-
lier 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®, from Windows98SE to WindowsXP. The CDC document, available at
www.usb.org, describes a way to implement devices such as ISDN modems and virtual COM
ports.
The Vendor ID is Atmel’s vendor ID 0x03EB. The product ID is 0x6124. These references are
used by the host operating system to mount the correct driver. On Windows systems, the INF
files contain the correspondence between vendor ID and product ID.
The device also handles some class requests defined in the CDC class.
169
6175H–ATARM–03-Dec-07
22.6 Hardware and Software Constraints
• SAM-BA boot copies itself in the SRAM and uses a block of internal SRAM for variables
and stacks. The remaining available sizes for the user codes are as follows: 57344 bytes for
AT91SAM7S512, 57344 bytes for AT91SAM7S256, 24576 bytes for AT91SAM7S128,
8192 bytes for AT91SAM7S64, 2048 bytes for AT91SAM7S321 and AT91SAM7S32, 3840
bytes for AT91SAM7S161 and AT91SAM7S16.
• USB requirements: (Does not pertain to AT91SAM7S32/16)
– 18.432 MHz Quartz
– PIOA16 dedicated to the USB Pull-up
23.1 Overview
The Peripheral DMA Controller (PDC) transfers data between on-chip serial peripherals such as
the UART, USART, SSC, SPI, MCI and the on- and off-chip memories. Using the Peripheral
DMA Controller avoids processor intervention and removes the processor interrupt-handling
overhead. This significantly reduces the number of clock cycles required for a data transfer and,
as a result, improves the performance of the microcontroller and makes it more power efficient.
The PDC channels are implemented in pairs, each pair being dedicated to a particular periph-
eral. One channel in the pair is dedicated to the receiving channel and one to the transmitting
channel of each UART, USART, SSC and SPI.
The user interface of a PDC channel is integrated in the memory space of each peripheral. It
contains:
• two 32-bit memory pointer registers (send and receive)
• two 16-bit transfer count registers (send and receive)
• two 32-bit registers for next memory pointer (send and receive)
• two 16-bit registesr for next transfer count (send and receive)
The peripheral triggers PDC transfers using transmit and receive signals. When the pro-
grammed data is transferred, an end of transfer interrupt is generated by the corresponding
peripheral.
Memory
RHR PDC Channel 1 Control
Controller
171
6175H–ATARM–03-Dec-07
23.3 Functional Description
23.3.1 Configuration
The PDC channels user interface enables the user to configure and control the data transfers for
each channel. The user interface of a PDC channel is integrated into the user interface of the
peripheral (offset 0x100), which it is related to.
Per peripheral, it contains four 32-bit Pointer Registers (RPR, RNPR, TPR, and TNPR) and four
16-bit Counter Registers (RCR, RNCR, TCR, and TNCR).
The size of the buffer (number of transfers) is configured in an internal 16-bit transfer counter
register, and it is possible, at any moment, to read the number of transfers left for each channel.
The memory base address is configured in a 32-bit memory pointer by defining the location of
the first address to access in the memory. It is possible, at any moment, to read the location in
memory of the next transfer and the number of remaining transfers. The PDC has dedicated sta-
tus registers which indicate if the transfer is enabled or disabled for each channel. The status for
each channel is located in the peripheral status register. Transfers can be enabled and/or dis-
abled by setting TXTEN/TXTDIS and RXTEN/RXTDIS in PDC Transfer Control Register. These
control bits enable reading the pointer and counter registers safely without any risk of their
changing between both reads.
The PDC sends status flags to the peripheral visible in its status-register (ENDRX, ENDTX,
RXBUFF, and TXBUFE).
ENDRX flag is set when the PERIPH_RCR register reaches zero.
RXBUFF flag is set when both PERIPH_RCR and PERIPH_RNCR reach zero.
ENDTX flag is set when the PERIPH_TCR register reaches zero.
TXBUFE flag is set when both PERIPH_TCR and PERIPH_TNCR reach zero.
These status flags are described in the peripheral status register.
Programming the Next Counter/Pointer registers chains the buffers. The counters are decre-
mented after each data transfer as stated above, but when the transfer counter reaches zero,
the values of the Next Counter/Pointer are loaded into the Counter/Pointer registers in order to
re-enable the triggers.
For each channel, two status bits indicate the end of the current buffer (ENDRX, ENDTX) and
the end of both current and next buffer (RXBUFF, TXBUFE). These bits are directly mapped to
the peripheral status register and can trigger an interrupt request to the AIC.
The peripheral end flag is automatically cleared when one of the counter-registers (Counter or
Next Counter Register) is written.
Note: When the Next Counter Register is loaded into the Counter Register, it is set to zero.
173
6175H–ATARM–03-Dec-07
23.4 Peripheral DMA Controller (PDC) User Interface
Table 23-1. Register Mapping
Offset Register Register Name Access Reset
(1)
0x100 Receive Pointer Register PERIPH _RPR Read-write 0x0
0x104 Receive Counter Register PERIPH_RCR Read-write 0x0
0x108 Transmit Pointer Register PERIPH_TPR Read-write 0x0
0x10C Transmit Counter Register PERIPH_TCR Read-write 0x0
0x110 Receive Next Pointer Register PERIPH_RNPR Read-write 0x0
0x114 Receive Next Counter Register PERIPH_RNCR Read-write 0x0
0x118 Transmit Next Pointer Register PERIPH_TNPR Read-write 0x0
0x11C Transmit Next Counter Register PERIPH_TNCR Read-write 0x0
0x120 PDC Transfer Control Register PERIPH_PTCR Write-only -
0x124 PDC Transfer Status Register PERIPH_PTSR Read-only 0x0
Note: 1. PERIPH: Ten registers are mapped in the peripheral memory space at the same offset. These can be defined by the user
according to the function and the peripheral desired (DBGU, USART, SSC, SPI, MCI etc).
23 22 21 20 19 18 17 16
RXPTR
15 14 13 12 11 10 9 8
RXPTR
7 6 5 4 3 2 1 0
RXPTR
23 22 21 20 19 18 17 16
--
15 14 13 12 11 10 9 8
RXCTR
7 6 5 4 3 2 1 0
RXCTR
175
6175H–ATARM–03-Dec-07
23.4.3 PDC Transmit Pointer Register
Register Name: PERIPH_TPR
Access Type: Read-write
31 30 29 28 27 26 25 24
TXPTR
23 22 21 20 19 18 17 16
TXPTR
15 14 13 12 11 10 9 8
TXPTR
7 6 5 4 3 2 1 0
TXPTR
23 22 21 20 19 18 17 16
--
15 14 13 12 11 10 9 8
TXCTR
7 6 5 4 3 2 1 0
TXCTR
23 22 21 20 19 18 17 16
RXNPTR
15 14 13 12 11 10 9 8
RXNPTR
7 6 5 4 3 2 1 0
RXNPTR
23 22 21 20 19 18 17 16
--
15 14 13 12 11 10 9 8
RXNCR
7 6 5 4 3 2 1 0
RXNCR
177
6175H–ATARM–03-Dec-07
23.4.7 PDC Transmit Next Pointer Register
Register Name: PERIPH_TNPR
Access Type: Read-write
31 30 29 28 27 26 25 24
TXNPTR
23 22 21 20 19 18 17 16
TXNPTR
15 14 13 12 11 10 9 8
TXNPTR
7 6 5 4 3 2 1 0
TXNPTR
23 22 21 20 19 18 17 16
--
15 14 13 12 11 10 9 8
TXNCR
7 6 5 4 3 2 1 0
TXNCR
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – TXTDIS TXTEN
7 6 5 4 3 2 1 0
– – – – – – RXTDIS RXTEN
179
6175H–ATARM–03-Dec-07
23.4.10 PDC Transfer Status Register
Register Name: PERIPH_PTSR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – TXTEN
7 6 5 4 3 2 1 0
– – – – – – – RXTEN
24.1 Overview
The Advanced Interrupt Controller (AIC) is an 8-level priority, individually maskable, vectored
interrupt controller, providing handling of up to thirty-two interrupt sources. It is designed to sub-
stantially reduce the software and real-time overhead in handling internal and external
interrupts.
The AIC drives the nFIQ (fast interrupt request) and the nIRQ (standard interrupt request) inputs
of an ARM processor. Inputs of the AIC are either internal peripheral interrupts or external inter-
rupts coming from the product's pins.
The 8-level Priority Controller allows the user to define the priority for each interrupt source, thus
permitting higher priority interrupts to be serviced even if a lower priority interrupt is being
treated.
Internal interrupt sources can be programmed to be level sensitive or edge triggered. External
interrupt sources can be programmed to be positive-edge or negative-edge triggered or high-
level or low-level sensitive.
The fast forcing feature redirects any internal or external interrupt source to provide a fast inter-
rupt rather than a normal interrupt.
FIQ AIC
ARM
IRQ0-IRQn Processor
Up to
Thirty-two nFIQ
Embedded Sources
PeripheralEE
Embedded nIRQ
Peripheral
Embedded
Peripheral
APB
181
6175H–ATARM–03-Dec-07
24.3 Application Block Diagram
OS-based Applications
Standalone
Applications OS Drivers RTOS Drivers
Hard Real Time Tasks
General OS Interrupt Handler
External Peripherals
Embedded Peripherals
(External Interrupts)
APB
183
6175H–ATARM–03-Dec-07
24.7 Functional Description
AIC_ICCR
AIC_IDCR
Level/ AIC_IPR
Edge
AIC_IMR
Source i
Fast Interrupt Controller
or
Priority Controller
Pos./Neg. AIC_IECR
Edge
Detector FF
Set Clear
AIC_ISCR AIC_IDCR
AIC_ICCR
185
6175H–ATARM–03-Dec-07
24.7.2 Interrupt Latencies
Global interrupt latencies depend on several parameters, including:
• The time the software masks the interrupts.
• Occurrence, either at the processor level or at the AIC level.
• The execution time of the instruction in progress when the interrupt occurs.
• The treatment of higher priority interrupts and the resynchronization of the hardware signals.
This section addresses only the hardware resynchronizations. It gives details of the latency
times between the event on an external interrupt leading in a valid interrupt (edge or level) or the
assertion of an internal interrupt source and the assertion of the nIRQ or nFIQ line on the pro-
cessor. The resynchronization time depends on the programming of the interrupt source and on
its type (internal or external). For the standard interrupt, resynchronization times are given
assuming there is no higher priority in progress.
The PIO Controller multiplexing has no effect on the interrupt latencies of the external interrupt
sources.
MCK
IRQ or FIQ
(Positive Edge)
IRQ or FIQ
(Negative Edge)
nIRQ
Maximum IRQ Latency = 4 Cycles
nFIQ
Maximum FIQ Latency = 4 Cycles
MCK
IRQ or FIQ
(High Level)
IRQ or FIQ
(Low Level)
nIRQ
Maximum IRQ
Latency = 3 Cycles
nFIQ
Maximum FIQ
Latency = 3 cycles
MCK
nIRQ
Peripheral Interrupt
Becomes Active
MCK
nIRQ
Peripheral Interrupt
Becomes Active
187
6175H–ATARM–03-Dec-07
24.7.3 Normal Interrupt
When the processor executes this instruction, it loads the read value in AIC_IVR in its program
counter, thus branching the execution on the correct interrupt handler.
This feature is often not used when the application is based on an operating system (either real
time or not). Operating systems often have a single entry point for all the interrupts and the first
task performed is to discern the source of the interrupt.
However, it is strongly recommended to port the operating system on AT91 products by support-
ing the interrupt vectoring. This can be performed by defining all the AIC_SVR of the interrupt
source to be handled by the operating system at the address of its interrupt handler. When doing
so, the interrupt vectoring permits a critical interrupt to transfer the execution on a specific very
fast handler and not onto the operating system’s general interrupt handler. This facilitates the
support of hard real-time tasks (input/outputs of voice/audio buffers and software peripheral han-
dling) to be handled efficiently and independently of the application running under an operating
system.
189
6175H–ATARM–03-Dec-07
5. Further interrupts can then be unmasked by clearing the “I” bit in CPSR, allowing re-
assertion of the nIRQ to be taken into account by the core. This can happen if an inter-
rupt with a higher priority than the current interrupt occurs.
6. The interrupt handler can then proceed as required, saving the registers that will be
used and restoring them at the end. During this phase, an interrupt of higher priority
than the current level will restart the sequence from step 1.
Note: If the interrupt is programmed to be level sensitive, the source of the interrupt must be cleared dur-
ing this phase.
7. The “I” bit in CPSR must be set in order to mask interrupts before exiting to ensure that
the interrupt is completed in an orderly manner.
8. The End of Interrupt Command Register (AIC_EOICR) must be written in order to indi-
cate to the AIC that the current interrupt is finished. This causes the current level to be
popped from the stack, restoring the previous current level if one exists on the stack. If
another interrupt is pending, with lower or equal priority than the old current level but
with higher priority than the new current level, the nIRQ line is re-asserted, but the inter-
rupt sequence does not immediately start because the “I” bit is set in the core.
SPSR_irq is restored. Finally, the saved value of the link register is restored directly into
the PC. This has the effect of returning from the interrupt to whatever was being exe-
cuted before, and of loading the CPSR with the stored SPSR, masking or unmasking
the interrupts depending on the state saved in SPSR_irq.
Note: The “I” bit in SPSR is significant. If it is set, it indicates that the ARM core was on the verge of
masking an interrupt when the mask instruction was interrupted. Hence, when SPSR is restored,
the mask instruction is completed (interrupt is masked).
191
6175H–ATARM–03-Dec-07
cally clearing the fast interrupt, if it has been programmed to be edge triggered. In this
case only, it de-asserts the nFIQ line on the processor.
4. The previous step enables branching to the corresponding interrupt service routine. It is
not necessary to save the link register R14_fiq and SPSR_fiq if nested fast interrupts
are not needed.
5. The Interrupt Handler can then proceed as required. It is not necessary to save regis-
ters R8 to R13 because FIQ mode has its own dedicated registers and the user R8 to
R13 are banked. The other registers, R0 to R7, must be saved before being used, and
restored at the end (before the next step). Note that if the fast interrupt is programmed
to be level sensitive, the source of the interrupt must be cleared during this phase in
order to de-assert the interrupt source 0.
6. Finally, the Link Register R14_fiq is restored into the PC after decrementing it by four
(with instruction SUB PC, LR, #4 for example). This has the effect of returning from
the interrupt to whatever was being executed before, loading the CPSR with the SPSR
and masking or unmasking the fast interrupt depending on the state saved in the
SPSR.
Note: The “F” bit in SPSR is significant. If it is set, it indicates that the ARM core was just about to mask
FIQ interrupts when the mask instruction was interrupted. Hence when the SPSR is restored, the
interrupted instruction is completed (FIQ is masked).
Another way to handle the fast interrupt is to map the interrupt service routine at the address of
the ARM vector 0x1C. This method does not use the vectoring, so that reading AIC_FVR must
be performed at the very beginning of the handler operation. However, this method saves the
execution of a branch instruction.
All enabled and pending interrupt sources that have the fast forcing feature enabled and that are
programmed in edge-triggered mode must be cleared by writing to the Interrupt Clear Command
Register. In doing so, they are cleared independently and thus lost interrupts are prevented.
The read of AIC_IVR does not clear the source that has the fast forcing feature enabled.
The source 0, reserved to the fast interrupt, continues operating normally and becomes one of
the Fast Interrupt sources.
AIC_FFSR
Source n AIC_IPR
Input Stage
Priority
Manager
Automatic Clear AIC_IMR nIRQ
193
6175H–ATARM–03-Dec-07
24.7.5 Protect Mode
The Protect Mode permits reading the Interrupt Vector Register without performing the associ-
ated automatic operations. This is necessary when working with a debug system. When a
debugger, working either with a Debug Monitor or the ARM processor's ICE, stops the applica-
tions and updates the opened windows, it might read the AIC User Interface and thus the IVR.
This has undesirable consequences:
• If an enabled interrupt with a higher priority than the current one is pending, it is stacked.
• If there is no enabled pending interrupt, the spurious vector is returned.
In either case, an End of Interrupt command is necessary to acknowledge and to restore the
context of the AIC. This operation is generally not performed by the debug system as the debug
system would become strongly intrusive and cause the application to enter an undesired state.
This is avoided by using the Protect Mode. Writing DBGM in AIC_DCR (Debug Control Register)
at 0x1 enables the Protect Mode.
When the Protect Mode is enabled, the AIC performs interrupt stacking only when a write access
is performed on the AIC_IVR. Therefore, the Interrupt Service Routines must write (arbitrary
data) to the AIC_IVR just after reading it. The new context of the AIC, including the value of the
Interrupt Status Register (AIC_ISR), is updated with the current interrupt only when AIC_IVR is
written.
An AIC_IVR read on its own (e.g., by a debugger), modifies neither the AIC context nor the
AIC_ISR. Extra AIC_IVR reads perform the same operations. However, it is recommended to
not stop the processor between the read and the write of AIC_IVR of the interrupt service routine
to make sure the debugger does not modify the AIC context.
To summarize, in normal operating mode, the read of AIC_IVR performs the following opera-
tions within the AIC:
1. Calculates active interrupt (higher than current or spurious).
2. Determines and returns the vector of the active interrupt.
3. Memorizes the interrupt.
4. Pushes the current priority level onto the internal stack.
5. Acknowledges the interrupt.
However, while the Protect Mode is activated, only operations 1 to 3 are performed when
AIC_IVR is read. Operations 4 and 5 are only performed by the AIC when AIC_IVR is written.
Software that has been written and debugged using the Protect Mode runs correctly in Normal
Mode without modification. However, in Normal Mode the AIC_IVR write has no effect and can
be removed to optimize the code.
• An internal interrupt source is programmed in level sensitive and the output signal of the
corresponding embedded peripheral is activated for a short time. (As in the case for the
Watchdog.)
• An interrupt occurs just a few cycles before the software begins to mask it, thus resulting in a
pulse on the interrupt source.
The AIC detects a spurious interrupt at the time the AIC_IVR is read while no enabled interrupt
source is pending. When this happens, the AIC returns the value stored by the programmer in
AIC_SPU (Spurious Vector Register). The programmer must store the address of a spurious
interrupt handler in AIC_SPU as part of the application, to enable an as fast as possible return to
the normal execution flow. This handler writes in AIC_EOICR and performs a return from
interrupt.
195
6175H–ATARM–03-Dec-07
24.8 Advanced Interrupt Controller (AIC) User Interface
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– SRCTYPE – – PRIOR
197
6175H–ATARM–03-Dec-07
24.8.3 AIC Source Vector Register
Register Name: AIC_SVR0..AIC_SVR31
Access Type: Read/Write
Reset Value: 0x0
31 30 29 28 27 26 25 24
VECTOR
23 22 21 20 19 18 17 16
VECTOR
15 14 13 12 11 10 9 8
VECTOR
7 6 5 4 3 2 1 0
VECTOR
23 22 21 20 19 18 17 16
IRQV
15 14 13 12 11 10 9 8
IRQV
7 6 5 4 3 2 1 0
IRQV
23 22 21 20 19 18 17 16
FIQV
15 14 13 12 11 10 9 8
FIQV
7 6 5 4 3 2 1 0
FIQV
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – IRQID
199
6175H–ATARM–03-Dec-07
24.8.7 AIC Interrupt Pending Register
Register Name: AIC_IPR
Access Type: Read-only
Reset Value: 0x0
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 SYS FIQ
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 SYS FIQ
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – NIRQ NIFQ
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 SYS FIQ
201
6175H–ATARM–03-Dec-07
24.8.11 AIC Interrupt Disable Command Register
Register Name: AIC_IDCR
Access Type: Write-only
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 SYS FIQ
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 SYS FIQ
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 SYS FIQ
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – – –
The End of Interrupt Command Register is used by the interrupt routine to indicate that the interrupt treatment is complete.
Any value can be written because it is only necessary to make a write to this register location to signal the end of interrupt
treatment.
203
6175H–ATARM–03-Dec-07
24.8.15 AIC Spurious Interrupt Vector Register
Register Name: AIC_SPU
Access Type: Read/Write
Reset Value: 0x0
31 30 29 28 27 26 25 24
SIVR
23 22 21 20 19 18 17 16
SIVR
15 14 13 12 11 10 9 8
SIVR
7 6 5 4 3 2 1 0
SIVR
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – GMSK PROT
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 SYS –
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 SYS –
205
6175H–ATARM–03-Dec-07
24.8.19 AIC Fast Forcing Status Register
Register Name: AIC_FFSR
Access Type: Read-only
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 SYS –
25.1 Overview
The Clock Generator is made up of 1 PLL, a Main Oscillator, as well as an RC Oscillator .
It provides the following clocks:
• SLCK, the Slow Clock, which is the only permanent clock within the system
• MAINCK is the output of the Main Oscillator
• PLLCK is the output of the Divider and PLL block
The Clock Generator User Interface is embedded within the Power Management Controller one
and is described in Section 26.9. However, the Clock Generator registers are named CKGR_.
MOSCEN
OSCOUNT
Main
SLCK Oscillator MOSCS
Slow Clock
Counter
207
6175H–ATARM–03-Dec-07
Figure 25-2. Typical Crystal Connection
AT91SAM7S Microcontroller
1K
Slow Clock, so that the frequency of the crystal connected on the Main Oscillator can be
determined.
PLLRC
PLLCOUNT
PLL
SLCK LOCK
Counter
C2
C1
GND
209
6175H–ATARM–03-Dec-07
25.4.2 Divider and Phase Lock Loop Programming
The divider can be set between 1 and 255 in steps of 1. When a divider field (DIV) is set to 0, the
output of the corresponding divider and the PLL output is a continuous signal at level 0. On
reset, each DIV field is set to 0, thus the corresponding PLL input clock is set to 0.
The PLL allows multiplication of the divider’s outputs. The PLL clock signal has a frequency that
depends on the respective source signal frequency and on the parameters DIV and MUL. The
factor applied to the source signal frequency is (MUL + 1)/DIV. When MUL is written to 0, the
corresponding PLL is disabled and its power consumption is saved. Re-enabling the PLL can be
performed by writing a value higher than 0 in the MUL field.
Whenever the PLL is re-enabled or one of its parameters is changed, the LOCK bit in PMC_SR
is automatically cleared. The values written in the PLLCOUNT field in CKGR_PLLR are loaded
in the PLL counter. The PLL counter then decrements at the speed of the Slow Clock until it
reaches 0. At this time, the LOCK bit is set in PMC_SR and can trigger an interrupt to the pro-
cessor. The user has to load the number of Slow Clock cycles required to cover the PLL
transient time into the PLLCOUNT field. The transient time depends on the PLL filter. The initial
state of the PLL and its target frequency can be calculated using a specific tool provided by
Atmel.
26.1 Description
The Power Management Controller (PMC) optimizes power consumption by controlling all sys-
tem and user peripheral clocks. The PMC enables/disables the clock inputs to many of the
peripherals and the ARM Processor.
The Power Management Controller provides the following clocks:
• MCK, the Master Clock, programmable from a few hundred Hz to the maximum operating
frequency of the device. It is available to the modules running permanently, such as the AIC
and the Memory Controller.
• Processor Clock (PCK), switched off when entering processor in idle mode.
• Peripheral Clocks, typically MCK, provided to the embedded peripherals (USART, SSC, SPI,
TWI, TC, MCI, etc.) and independently controllable. In order to reduce the number of clock
names in a product, the Peripheral Clocks are named MCK in the product datasheet.
• UDP Clock (UDPCK), required by USB Device Port operations.(Does not pertain to
AT91SAM7S32/16.)
• Programmable Clock Outputs can be selected from the clocks provided by the clock
generator and driven on the PCKx pins.
SLCK
Master Clock
MAINCK MCK
Prescaler
PLLCK
To the Processor
Clock Controller (PCK)
211
6175H–ATARM–03-Dec-07
26.3 Processor Clock Controller
The PMC features a Processor Clock Controller (PCK) that implements the Processor Idle
Mode. The Processor Clock can be disabled by writing the System Clock Disable Register
(PMC_SCDR). The status of this clock (at least for debug purpose) can be read in the System
Clock Status Register (PMC_SCSR).
The Processor Clock PCK is enabled after a reset and is automatically re-enabled by any
enabled interrupt. The Processor Idle Mode is achieved by disabling the Processor Clock, which
is automatically re-enabled by any enabled fast or normal interrupt, or by the reset of the
product.
When the Processor Clock is disabled, the current instruction is finished before the clock is
stopped, but this does not prevent data transfers from other masters of the system bus.
• The USB device clock can be enabled by setting the UDP bit in PMC_SCER. To save power
on this peripheral when it is not used, the user can set the UDP bit in PMC_SCDR. The UDP
bit in PMC_SCSR gives the activity of this clock. The USB device port require both the 48
MHz signal and the Master Clock. The Master Clock may be controlled via the Master Clock
Controller.
USBDIV
USB
Divider UDP Clock (UDPCK)
Source
/1,/2,/4
Clock UDP
In order to stop a peripheral, it is recommended that the system software wait until the peripheral
has executed its last programmed operation before disabling the clock. This is to avoid data cor-
ruption or erroneous behavior of the system.
The bit number within the Peripheral Clock Control registers (PMC_PCER, PMC_PCDR, and
PMC_PCSR) is the Peripheral Identifier defined at the product level. Generally, the bit number
corresponds to the interrupt source number assigned to the peripheral.
Code Example:
write_register(CKGR_MOR,0x00000701)
Start Up Time = 8 * OSCOUNT / SLCK = 56 Slow Clock Cycles.
So, the main oscillator will be enabled (MOSCS bit set) after 56 Slow Clock Cycles.
213
6175H–ATARM–03-Dec-07
3. Setting PLL and divider:
All parameters needed to configure PLL and the divider are located in the CKGR_PLLR
register.
The DIV field is used to control divider itself. A value between 0 and 255 can be pro-
grammed. Divider output is divider input divided by DIV parameter. By default DIV
parameter is set to 0 which means that divider is turned off.
The OUT field is used to select the PLL B output frequency range.
The MUL field is the PLL multiplier factor. This parameter can be programmed between 0
and 2047. If MUL is set to 0, PLL will be turned off, otherwise the PLL output frequency is
PLL input frequency multiplied by (MUL + 1).
The PLLCOUNT field specifies the number of slow clock cycles before LOCK bit is set in the
PMC_SR register after CKGR_PLLR register has been written.
Once the PMC_PLL register has been written, the user must wait for the LOCK bit to be set
in the PMC_SR register. This can be done either by polling the status register or by waiting
the interrupt line to be raised if the associated interrupt to LOCK has been enabled in the
PMC_IER register. All parameters in CKGR_PLLR can be programmed in a single write
operation. If at some stage one of the following parameters, MUL, DIV is modified, LOCK bit
will go low to indicate that PLL is not ready yet. When PLL is locked, LOCK will be set again.
The user is constrained to wait for LOCK bit to be set before using the PLL output clock.
The USBDIV field is used to control the additional divider by 1, 2 or 4, which generates the
USB clock(s) (Does not pertain to AT91SAM7S32/16.)
Code Example:
write_register(CKGR_PLLR,0x00040805)
If PLL and divider are enabled, the PLL input clock is the main clock. PLL output clock is PLL
input clock multiplied by 5. Once CKGR_PLLR has been written, LOCK bit will be set after-
eight slow clock cycles.
4. Selection of Master Clock and Processor Clock
The Master Clock and the Processor Clock are configurable via the PMC_MCKR register.
The CSS field is used to select the Master Clock divider source. By default, the selected
clock source is slow clock.
The PRES field is used to control the Master Clock prescaler. The user can choose between
different values (1, 2, 4, 8, 16, 32, 64). Master Clock output is prescaler input divided by
PRES parameter. By default, PRES parameter is set to 1 which means that master clock is
equal to slow clock.
Once the PMC_MCKR register has been written, the user must wait for the MCKRDY bit to
be set in the PMC_SR register. This can be done either by polling the status register or by
waiting for the interrupt line to be raised if the associated interrupt to MCKRDY has been
enabled in the PMC_IER register.
The PMC_MCKR register must not be programmed in a single write operation. The pre-
ferred programming sequence for the PMC_MCKR register is as follows:
Code Example:
write_register(PMC_MCKR,0x00000001)
wait (MCKRDY=1)
write_register(PMC_MCKR,0x00000011)
wait (MCKRDY=1)
215
6175H–ATARM–03-Dec-07
input divided by PRES parameter. By default, the PRES parameter is set to 1 which means
that master clock is equal to slow clock.
Once the PMC_PCKx register has been programmed, The corresponding Programmable
clock must be enabled and the user is constrained to wait for the PCKRDYx bit to be set in
the PMC_SR register. This can be done either by polling the status register or by waiting the
interrupt line to be raised if the associated interrupt to PCKRDYx has been enabled in the
PMC_IER register. All parameters in PMC_PCKx can be programmed in a single write
operation.
If the CSS and PRES parameters are to be modified, the corresponding Programmable
clock must be disabled first. The parameters can then be modified. Once this has been
done, the user must re-enable the Programmable clock and wait for the PCKRDYx bit to be
set.
Code Example:
write_register(PMC_PCK0,0x00000015)
Code Examples:
write_register(PMC_PCER,0x00000110)
write_register(PMC_PCDR,0x00000010)
Figure 26-3. Switch Master Clock from Slow Clock to PLL Clock
Slow Clock
PLL Clock
LOCK
MCKRDY
Master Clock
Write PMC_MCKR
217
6175H–ATARM–03-Dec-07
Figure 26-4. Switch Master Clock from Main Clock to Slow Clock
Slow Clock
Main Clock
MCKRDY
Master Clock
Write PMC_MCKR
Main Clock
PLL Clock
LOCK
MCKRDY
Master Clock
Main Clock
Write CKGR_PLLR
PLL Clock
PCKRDY
PCKx Output
Write PMC_SCER
PCKx is enabled
219
6175H–ATARM–03-Dec-07
26.9 Power Management Controller (PMC) User Interface
Table 26-2. Register Mapping
Offset Register Name Access Reset
(1)
0x0000 System Clock Enable Register PMC_SCER Write-only –
(1)
0x0004 System Clock Disable Register PMC_SCDR Write-only –
(1)
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(2) 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 – – –
Notes: 1. UDP bit of this register doe not pertain to AT91SAM7S32/16.
2. USBDIV bit of this register does not pertain to AT91SAM7S32/16
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
221
6175H–ATARM–03-Dec-07
26.9.2 PMC System Clock Disable Register
Register Name: PMC_SCDR
Access Type: Write-only
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
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
223
6175H–ATARM–03-Dec-07
26.9.4 PMC Peripheral Clock Enable Register
Register Name: PMC_PCER
Access Type: Write-only
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 - -
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 - -
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 – –
225
6175H–ATARM–03-Dec-07
26.9.7 PMC Clock Generator Main Oscillator Register
Register Name: CKGR_MOR
Access Type: Read-write
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
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
227
6175H–ATARM–03-Dec-07
26.9.9 PMC Clock Generator PLL Register
Register Name: CKGR_PLLR
Access Type: Read-write
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
Possible limitations on PLL input frequencies and multiplier factors should be checked before using the PMC.
• DIV: Divider
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – MDIV
7 6 5 4 3 2 1 0
– – – PRES CSS
229
6175H–ATARM–03-Dec-07
26.9.11 PMC Programmable Clock Register
Register Name: PMC_PCKx
Access Type: Read-write
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
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
– LOCKU UOSCS – MCKRDY LOCK – MOSCS
231
6175H–ATARM–03-Dec-07
26.9.13 PMC Interrupt Disable Register
Register Name: PMC_IDR
Access Type: Write-only
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
– LOCKU UOSCS – MCKRDY LOCK – MOSCS
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
– LOCKU UOSCS – MCKRDY LOCK – MOSCS
233
6175H–ATARM–03-Dec-07
26.9.15 PMC Interrupt Mask Register
Register Name: PMC_IMR
Access Type: Read-only
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
– LOCKU UOSCS – MCKRDY LOCK – MOSCS
27.1 Overview
The Debug Unit provides a single entry point from the processor for access to all the debug
capabilities of Atmel’s 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. 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.
235
6175H–ATARM–03-Dec-07
27.2 Block Diagram
Peripheral
Bridge
COMMRX
DCC
R Chip ID
ARM COMMTX Handler
Processor
nTRST
ICE
Interrupt
Access dbgu_irq
Control
Handler
Power-on
Reset
force_ntrst
Debug Unit
RS232 Drivers
MCK
Baud Rate = ---------------------
16 × CD
237
6175H–ATARM–03-Dec-07
Figure 27-2. Baud Rate Generator
CD
CD
27.4.2 Receiver
DRXD
True Start D0
Detection
Baud Rate
Clock
DRXD
DRXD S D0 D1 D2 D3 D4 D5 D6 D7 P S D0 D1 D2 D3 D4 D5 D6 D7 P
RXRDY
Read DBGU_RHR
RXRDY
OVRE
RSTSTA
239
6175H–ATARM–03-Dec-07
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.
RXRDY
PARE
RXRDY
FRAME
27.4.3 Transmitter
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.
Baud Rate
Clock
DTXD
TXRDY
TXEMPTY
241
6175H–ATARM–03-Dec-07
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.
Receiver RXD
Disabled
Transmitter TXD
Local Loopback
Disabled
Receiver RXD
VDD
Disabled
Transmitter TXD
Disabled
Transmitter TXD
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
243
6175H–ATARM–03-Dec-07
27.5 Debug Unit (DBGU) User Interface
Table 27-2. Memory Mapping
Offset Register Name Access Reset
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 – – –
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 – –
245
6175H–ATARM–03-Dec-07
27.5.2 Debug Unit Mode Register
Name: DBGU_MR
Access Type: Read-write
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
– – – – – – – –
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
247
6175H–ATARM–03-Dec-07
27.5.4 Debug Unit Interrupt Disable Register
Name: DBGU_IDR
Access Type: Write-only
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
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
249
6175H–ATARM–03-Dec-07
27.5.6 Debug Unit Status Register
Name: DBGU_SR
Access Type: Read-only
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
251
6175H–ATARM–03-Dec-07
27.5.7 Debug Unit Receiver Holding Register
Name: DBGU_RHR
Access Type: Read-only
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
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
253
6175H–ATARM–03-Dec-07
27.5.9 Debug Unit Baud Rate Generator Register
Name: DBGU_BRGR
Access Type: Read-write
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
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
255
6175H–ATARM–03-Dec-07
• NVPSIZ2 Second Nonvolatile Program Memory 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
ARCH
Hex Bin Architecture
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 AT91SAM7Lxx 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
ROM and Embedded Flash Memory
0 1 1 NVPSIZ is ROM size
NVPSIZ2 is Flash size
257
6175H–ATARM–03-Dec-07
27.5.11 Debug Unit Chip ID Extension Register
Name: DBGU_EXID
Access Type: Read-only
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
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
28.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.
259
6175H–ATARM–03-Dec-07
28.2 Block Diagram
PDC
APB
SPCK
MISO
MCK MOSI
PMC
SPI Interface PIO NPCS0/NSS
NPCS1
NPCS2
Interrupt Control
NPCS3
SPI Interrupt
SPCK SPCK
MISO MISO
Slave 0
MOSI MOSI
SPCK
NPCS1
MISO
NPCS2 NC Slave 1
NPCS3 MOSI
NSS
SPCK
MISO
Slave 2
MOSI
NSS
28.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.
261
6175H–ATARM–03-Dec-07
28.6 Functional Description
SPCK
(CPOL = 0)
SPCK
(CPOL = 1)
MOSI
MSB 6 5 4 3 2 1 LSB
(from master)
MISO
(from slave)
MSB 6 5 4 3 2 1 LSB *
NSS
(to slave)
SPCK
(CPOL = 0)
SPCK
(CPOL = 1)
MISO
(from slave) * MSB 6 5 4 3 2 1 LSB
NSS
(to slave)
263
6175H–ATARM–03-Dec-07
28.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 28-5 on page 265 shows a block diagram of the SPI when operating in Master Mode. Fig-
ure 28-6 on page 266 shows a flow chart describing how transfers are handled.
SPI
Clock
SPI_CSR0..3
BITS SPI_RDR RDRF
NCPHA RD OVRES
CPOL
SPI_TDR
TD TDRE
SPI_CSR0..3
CSAAT SPI_RDR
PCS
PS
NPCS3
SPI_MR PCSDEC
PCS Current NPCS2
0 Peripheral
NPCS1
SPI_TDR
PCS NPCS0
1
MSTR
MODF
NPCS0
MODFDIS
265
6175H–ATARM–03-Dec-07
28.6.3.2 Master Mode Flow Diagram
Fixed
1 0 peripheral
CSAAT ? PS ?
Variable
0 1 peripheral
Fixed
0 peripheral yes
PS ? SPI_TDR(PCS) SPI_MR(PCS)
= NPCS ? = NPCS ?
Variable
1 peripheral no no
NPCS = SPI_TDR(PCS) NPCS = SPI_MR(PCS) NPCS = 0xF NPCS = 0xF
Delay DLYBS
Serializer = SPI_TDR(TD)
TDRE = 1
Data Transfer
SPI_RDR(RD) = Serializer
RDRF = 1
Delay DLYBCT
0
TDRE ?
1
CSAAT ?
NPCS = 0xF
Delay DLYBCS
Chip Select 1
Chip Select 2
SPCK
DLYBCS DLYBS DLYBCT DLYBCT
267
6175H–ATARM–03-Dec-07
• 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.
Figure 28-8 shows different peripheral deselection cases and the effect of the CSAAT bit.
TDRE
DLYBCT DLYBCT
NPCS[0..3] A A A A A
DLYBCS DLYBCS
PCS = A PCS = A
Write SPI_TDR
TDRE
DLYBCT DLYBCT
NPCS[0..3] A A A A A
DLYBCS DLYBCS
PCS=A PCS = A
Write SPI_TDR
TDRE
DLYBCT DLYBCT
NPCS[0..3] A B A B
DLYBCS DLYBCS
PCS = B PCS = B
Write SPI_TDR
269
6175H–ATARM–03-Dec-07
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 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.
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 28-9 shows a block diagram of the SPI when operating in Slave Mode.
NSS SPI
Clock
SPIEN
SPIENS
SPIDIS
SPI_CSR0
BITS SPI_RDR RDRF
NCPHA RD OVRES
CPOL
SPI_TDR
TD TDRE
271
6175H–ATARM–03-Dec-07
28.7.1 SPI Control Register
Name: SPI_CR
Access Type: Write-only
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
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
273
6175H–ATARM–03-Dec-07
• 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 = don’t care)
If PCSDEC = 1:
NPCS[3:0] output signals = PCS.
DLYBCS
Delay Between Chip Selects = -----------------------
MCK
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
275
6175H–ATARM–03-Dec-07
28.7.4 SPI Transmit Data Register
Name: SPI_TDR
Access Type: Write-only
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
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
277
6175H–ATARM–03-Dec-07
• 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.
Note: 1. SPI_RCR, SPI_RNCR, SPI_TCR, SPI_TNCR are physically located in the PDC.
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
279
6175H–ATARM–03-Dec-07
28.7.7 SPI Interrupt Disable Register
Name: SPI_IDR
Access Type: Write-only
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
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
281
6175H–ATARM–03-Dec-07
28.7.9 SPI Chip Select Register
Name: SPI_CSR0... SPI_CSR3
Access Type: Read-write
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
MCK
SPCK Baudrate = ---------------
SCBR
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 = -------------------
MCK
32 × DLYBCT
Delay Between Consecutive Transfers = ------------------------------------
MCK
283
6175H–ATARM–03-Dec-07
284 AT91SAM7S Series Preliminary
6175H–ATARM–03-Dec-07
AT91SAM7S Series Preliminary
29.1 Overview
The 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-ori-
ented transfer format. It can be used with any Atmel Two-wire Interface bus Serial EEPROM and
I²C 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 master transmitter or
master receiver with sequential or single-byte access. A configurable baud rate generator per-
mits the output data rate to be adapted to a wide range of core clock frequencies. Below, Table
29-1 lists the compatibility level of the Atmel Two-wire Interface and a full I2C compatible device.
285
6175H–ATARM–03-Dec-07
29.3 Block Diagram
APB Bridge
TWCK
PIO
Two-wire TWD
Interface
MCK
PMC
TWI
Interrupt
AIC
Rp Rp
TWD
Host with
TWI
Interface TWCK
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.
29.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.
TWD
TWCK
Start Stop
TWD
TWCK
287
6175H–ATARM–03-Dec-07
29.6.2 Modes of Operation
The TWI has two modes of operation:
• Master transmitter mode
• Master receiver mode
The TWI Control Register (TWI_CR) allows configuration of the interface in Master Mode. In this
mode, it generates the clock according to the value programmed in the Clock Waveform Gener-
ator Register (TWI_CWGR). This register defines the TWCK signal completely, enabling the
interface to be adapted to a wide range of clocks.
TXCOMP
TXRDY
TXCOMP
TXRDY
Write THR (Data n) Write THR (Data n+1) Write THR (Data n+x) STOP sent automaticaly
Last data sent (ACK received and TXRDY = 1)
Figure 29-7. Master Write with One Byte Internal Address and Multiple Data Bytes
TXCOMP
TXRDY
Write THR (Data n) Write THR (Data n+1) Write THR (Data n+x) STOP sent automaticaly
Last data sent (ACK received and TXRDY = 1)
289
6175H–ATARM–03-Dec-07
Figure 29-8. Master Read with One Data Byte
TXCOMP
Read RHR
TXCOMP
Write START Bit
RXRDY
•S Start
•P Stop
•W Write
•R Read
•A Acknowledge
•N Not Acknowledge
• DADR Device Address
• IADR Internal Address
Figure 29-10. Master Write with One, Two or Three Bytes Internal Address and One Data Byte
Three bytes internal address
TWD S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A DATA A P
Figure 29-11. Master Read with One, Two or Three Bytes Internal Address and One Data Byte
Three bytes internal address
TWD S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A S DADR R A
DATA N P
Two bytes internal address
TWD S DADR W A IADR(15:8) A IADR(7:0) A S DADR R A DATA N P
291
6175H–ATARM–03-Dec-07
29.6.5.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)
Figure 29-12 below shows a byte write to an Atmel AT24LC512 EEPROM. This demonstrates
the use of internal addresses to access the device.
M L R A M A L A A
S S / C S C SC C
B BW K B K BK K
Figure 29-13. TWI Write Operation with Single Data Byte without Internal Address
BEGIN
No
TXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
Transfer finished
293
6175H–ATARM–03-Dec-07
Figure 29-14. TWI Write Operation with Single Data Byte and Internal Address
BEGIN
No
TXRDY = 1?
Yes
TXCOMP = 1?
No
Yes
Transfer finished
Figure 29-15. TWI Write Operation with Multiple Data Bytes with or without Internal Address
BEGIN
No
Internal address size = 0?
Yes
Data to send?
Yes
Yes
No
TXCOMP = 1?
END
295
6175H–ATARM–03-Dec-07
Figure 29-16. TWI Read Operation with Single Data Byte without Internal Address
BEGIN
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
Figure 29-17. TWI Read Operation with Single Data Byte and Internal Address
BEGIN
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
297
6175H–ATARM–03-Dec-07
Figure 29-18. TWI Read Operation with Multiple Data Bytes with or without Internal Address
BEGIN
No
RXRDY = 1?
Yes
Yes
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
299
6175H–ATARM–03-Dec-07
29.7.1 TWI Control Register
Register Name: TWI_CR
Access Type: Write-only
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 – – – MSDIS MSEN STOP START
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
– – – – – – – –
Table 29-5.
IADRSZ[9:8]
0 0 No internal device address (Byte command protocol)
0 1 One-byte internal device address
1 0 Two-byte internal device address
1 1 Three-byte internal device address
301
6175H–ATARM–03-Dec-07
29.7.3 TWI Internal Address Register
Register Name: TWI_IADR
Access Type: Read-write
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
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
CKDIV
T low = ( ( CLDIV × 2 ) + 3 ) × T MCK
CKDIV
T high = ( ( CHDIV × 2 ) + 3 ) × T MCK
303
6175H–ATARM–03-Dec-07
29.7.5 TWI Status Register
Register Name: TWI_SR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – NACK
7 6 5 4 3 2 1 0
– – – – – TXRDY RXRDY TXCOMP
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – NACK
7 6 5 4 3 2 1 0
– – – – – TXRDY RXRDY TXCOMP
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – NACK
7 6 5 4 3 2 1 0
– – – – – TXRDY RXRDY TXCOMP
305
6175H–ATARM–03-Dec-07
29.7.8 TWI Interrupt Mask Register
Register Name: TWI_IMR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – NACK
7 6 5 4 3 2 1 0
– – – – – TXRDY RXRDY TXCOMP
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
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
307
6175H–ATARM–03-Dec-07
308 AT91SAM7S Series Preliminary
6175H–ATARM–03-Dec-07
AT91SAM7S Series Preliminary
30.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 I²C 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 30-1 lists the compatibility level of the Atmel Two-wire Interface in Master Mode and
a full I2C compatible device.
309
6175H–ATARM–03-Dec-07
Table 30-2. Abbreviations
Abbreviation Description
ADR Any address except SADR
R Read
W Write
APB Bridge
TWCK
PIO
Two-wire TWD
Interface
MCK
PMC
TWI
Interrupt
AIC
Rp Rp
TWD
Host with
TWI
Interface TWCK
30.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.
TWD
TWCK
Start Stop
TWD
TWCK
30.7.1 Definition
The Master is the device which starts a transfer, generates a clock and stops it.
Rp Rp
TWD
Host with
TWI
Interface TWCK
TXCOMP
TXRDY
TXCOMP
TXRDY
Write THR (Data n) Write THR (Data n+1) Write THR (Data n+x) STOP sent automaticaly
Last data sent (ACK received and TXRDY = 1)
Figure 30-8. Master Write with One Byte Internal Address and Multiple Data Bytes
TXCOMP
TXRDY
Write THR (Data n) Write THR (Data n+1) Write THR (Data n+x) STOP sent automaticaly
Last data sent (ACK received and TXRDY = 1)
TXCOMP
Read RHR
TXCOMP
Write START Bit
RXRDY
•S Start
• Sr Repeated Start
•P Stop
•W Write
•R Read
•A Acknowledge
•N Not Acknowledge
• DADR Device Address
• IADR Internal Address
Figure 30-11. Master Write with One, Two or Three Bytes Internal Address and One Data Byte
Three bytes internal address
TWD S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A DATA A P
Figure 30-12. Master Read with One, Two or Three Bytes Internal Address and One Data Byte
Three bytes internal address
TWD S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A Sr DADR R A
DATA N P
M LR A M A LA A
S S / C S C SC C
B BW K B K BK K
Figure 30-14. TWI Write Operation with Single Data Byte without Internal Address
BEGIN
No
TXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
Transfer finished
BEGIN
No
TXRDY = 1?
Yes
TXCOMP = 1?
No
Yes
Transfer finished
BEGIN
No
Internal address size = 0?
Yes
Data to send?
Yes
Yes
No
TXCOMP = 1?
END
BEGIN
No
RXRDY = 1?
Yes
BEGIN
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
No
RXRDY = 1?
Yes
Yes
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
30.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 30-21 on page 325.
TWCK
TWCK
TWD
TWCK
Arbitration is lost
Data from a Master S 1 0 0 1 1 P S 1 0 1
The master stops sending data
Arbitration is lost
Data from TWI S 1 0 1 S 1 0 0 1 1
TWI stops sending data
ARBLST
Bus is busy Bus is free
The flowchart shown in Figure 30-22 on page 326 gives an example of read and write operations
in Multi-master mode.
START
Yes
SVACC = 1 ? GACC = 1 ?
SVREAD = 0 ?
Yes Yes
Write in TWI_THR
TXCOMP = 1 ?
RXRDY= 0 ?
Yes
Yes
Prog seq
OK ?
Change SADR
Yes
ARBLST = 1 ?
Yes
MREAD = 1 ?
Yes Yes
RXRDY= 0 ? TXRDY= 0 ?
Yes Yes
Read TWI_RHR Data to read? Data to send ? Write in TWI_THR
Stop transfer
Yes
TXCOMP = 0 ?
30.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).
VDD
R R
Master
TWD
Host with
TWI
Interface TWCK
TXRDY
Write THR Read RHR
NACK
SVACC
SVREAD SVREAD has to be taken into account only while SVACC is active
EOSVACC
RXRDY
SVACC
SVREAD SVREAD has to be taken into account only while SVACC is active
EOSVACC
TXD S GENERAL CALL A Reset or write DADD A DATA1 A DATA2 A New SADR A P
New SADR
Programming sequence
GCACC
Reset after read
SVACC
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.
TWCK
CLOCK is tied low by the TWI
as long as THR is empty
Write THR
SCLWS
TXRDY
SVACC
SVREAD
As soon as a START is detected
TXCOMP
TWI_THR is transmitted to the shift register Ack or Nack from the master
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.
TWCK
CLOCK is tied low by the TWI as long as RHR is full
SCLWS
SCL is stretched on the last bit of DATA1
RXRDY
Rd DATA0 Rd DATA1 Rd DATA2
SVACC
SVREAD
As soon as a START is detected
TXCOMP
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.
TWI_THR
DATA0 DATA1
SVACC
SVREAD
TXRDY
RXRDY
EOSACC Cleared after read
TXCOMP As soon as a START is detected
1. TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
SVACC
SVREAD
TXRDY
RXRDY
Read TWI_RHR
EOSACC Cleared after read
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.
SVACC = 1 ? GACC = 1 ?
SVREAD = 0 ?
EOSACC = 1 ? TXRDY= 1 ?
Write in TWI_THR
TXCOMP = 1 ?
RXRDY= 0 ?
END
Read TWI_RHR
Decoding of the
programming sequence
Prog seq
OK ?
Change SADR
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
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
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
– – – – – – – –
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
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
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
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
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
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
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
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
31.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, and infrared transceivers and connection to modem
ports. The hardware handshaking feature enables an out-of-band flow control by automatic
management 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.
349
6175H–ATARM–03-Dec-07
31.2 Block Diagram
Peripheral DMA
Controller
Channel Channel
PIO
USART Controller
RXD
Receiver
RTS
DTR
PMC Modem
MCK Signals DSR
Control
MCK/DIV DCD
DIV
RI
SLCK SCK
Baud Rate
Generator
User Interface
APB
Peripheral DMA
Controller
Channel Channel
PIO
USART Controller
RXD
Receiver
RTS
PMC
MCK SCK
Baud Rate
Generator
MCK/DIV
DIV
User Interface
SLCK
APB
PPP IrLAP
Field Bus EMV
Modem Serial Driver Driver IrDA
Driver Driver Driver
USART
351
6175H–ATARM–03-Dec-07
Figure 31-4. AT91SAM7S32/16 Application Block Diagram
PPP IrLAP
Field Bus EMV
Serial Driver Driver IrDA
Driver Driver
USART
Serial Differential
Port Bus
31.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.
353
6175H–ATARM–03-Dec-07
31.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 (AT91SAM7S512/256/128/64/321/161)
– 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 (AT91SAM7S512/256/128/64/321/161)
– 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
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.
USCLKS CD
MCK CD
0 SCK
MCK/DIV
1
Reserved 16-bit Counter
SCK 2 FIDI
>1 SYNC
3 OVER
1 0
0 0 Sampling 0
Divider
Baud Rate
1 Clock
1
SYNC
Sampling
USCLKS = 3 Clock
SelectedClock
Baudrate = --------------------------------------------
( 8 ( 2 – Over )CD )
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.
355
6175H–ATARM–03-Dec-07
Table 31-2. Baud Rate Example (OVER = 0) (Continued)
Expected Baud
Source Clock Rate Calculation Result CD Actual Baud Rate Error
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%
Error = 1 – ⎛ ---------------------------------------------------⎞
ExpectedBaudRate
⎝ ActualBaudRate ⎠
SelectedClock
Baudrate = ----------------------------------------------------------------
-
⎛ 8 ( 2 – Over ) ⎛ CD + FP -------⎞ ⎞
⎝ ⎝ 8 ⎠⎠
USCLKS Modulus
CD
Control
FP
MCK CD
0 SCK
MCK/DIV
1
Reserved 16-bit Counter
SCK 2 glitch-free FIDI
logic >1 SYNC
3 OVER
1 0
0 0 Sampling 0
Divider
Baud Rate
1 Clock
1
SYNC Sampling
USCLKS = 3 Clock
BaudRate = SelectedClock
--------------------------------------
CD
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.
357
6175H–ATARM–03-Dec-07
Di is a binary value encoded on a 4-bit field, named DI, as represented in Table 31-3.
Fi is a binary value encoded on a 4-bit field, named FI, as represented in Table 31-4.
Table 31-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 31-7 shows the relation between the Elementary Time Unit, corresponding to a bit time,
and the ISO 7816 clock.
ISO7816 Clock
on SCK
1 ETU
359
6175H–ATARM–03-Dec-07
Figure 31-8. Character Transmit
Example: 8-bit, Parity Enabled One Stop
Baud Rate
Clock
TXD
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 when the transmitter is disabled. Writing a character in
US_THR while TXRDY is low has no effect and the written character is lost.
TXD
Start Parity Stop Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit Bit Bit Bit
Write
US_THR
TXRDY
TXEMPTY
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 31-10 and Figure 31-11 illustrate start detection and character reception when USART
operates in asynchronous mode.
Sampling
Clock (x16)
RXD
Sampling
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
D0
Start Sampling
Detection
RXD
Sampling
1 2 3 4 5 6 7 0 1 2 3 4
Start
Rejection
Baud Rate
Clock
RXD
Start 16 16 16 16 16 16 16 16 16 16
Detection samples samples samples samples samples samples samples samples samples samples
D0 D1 D2 D3 D4 D5 D6 D7 Parity Stop
Bit Bit
361
6175H–ATARM–03-Dec-07
Figure 31-12. Synchronous Mode Character Reception
Example: 8-bit, Parity Enabled 1 Stop
Baud Rate
Clock
RXD
Sampling
Start D0 D1 D2 D3 D4 D5 D6 D7 Stop Bit
Parity Bit
Rate
Clock
RXD
Start Parity Stop Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit Bit Bit Bit
RSTSTA = 1
Write
S_CR
Read
_RHR
XRDY
OVRE
31.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 364. 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 31-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 31-14 illustrates the parity bit status setting and clearing.
363
6175H–ATARM–03-Dec-07
Figure 31-14. Parity Error
Baud Rate
Clock
RXD
Start Bad Stop
D0 D1 D2 D3 D4 D5 D6 D7
Bit Parity Bit
Bit RSTSTA = 1
Write
US_CR
PARE
RXRDY
TXD
Start Parity Stop Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit Bit Bit Bit
Write
US_THR
TXRDY
TXEMPTY
Table 31-7 indicates the maximum length of a timeguard period that the transmitter can handle
in relation to the function of the Baud Rate.
365
6175H–ATARM–03-Dec-07
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 31-16 shows the block diagram of the Receiver Time-out feature.
Baud Rate TO
Clock
16-bit
Value
1 D Q Clock 16-bit Time-out
Counter
STTTO = TIMEOUT
Load 0
Clear
Character
Received
RETTO
Table 31-8 gives the maximum time-out period for some standard baud rates.
Baud Rate
Clock
RXD
Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit
RSTSTA = 1
Write
US_CR
FRAME
RXRDY
367
6175H–ATARM–03-Dec-07
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 31-18 illustrates the effect of both the Start Break (STTBRK) and Stop Break (STPBRK)
commands on the TXD line.
Baud Rate
Clock
TXD
Start Parity Stop
Bit
D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit
Break Transmission End of Break
STTBRK = 1 STPBRK = 1
Write
US_CR
TXRDY
TXEMPTY
USART Remote
Device
TXD RXD
RXD TXD
CTS RTS
RTS CTS
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 31-20 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.
RXD
RXEN = 1 RXDIS = 1
Write
US_CR
RTS
RXBUFF
Figure 31-21 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.
CTS
TXD
369
6175H–ATARM–03-Dec-07
31.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.
USART
CLK
SCK Smart
Card
I/O
TXD
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 382 and “PAR: Parity Type” on page 383.
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).
31.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 31-23.
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 31-24. 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.
RXD
I/O Error
371
6175H–ATARM–03-Dec-07
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.
31.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).
USART IrDA
Transceivers
Receiver Demodulator RXD RX
TX
Transmitter Modulator TXD
The receiver and the transmitter must be enabled or disabled according to the direction of the
transmission to be managed.
To receive IrDA signals, the following needs to be done:
• Disable TX and Enable RX
• Configure the TXD pin as PIO and set it as an output at 0 (to avoid LED emission). Disable
the internal pull-up (better for power consumption).
• Receive data
TXD
Bit Period 3
16 Bit Period
373
6175H–ATARM–03-Dec-07
Table 31-10. IrDA Baud Rate Error (Continued)
Peripheral Clock Baud Rate CD Baud Rate Error Pulse Time
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
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
RXD
Counter
Value 6 5 4 3 2 6 6 5 4 3 2 1 0
Pulse Pulse
Rejected Accepted
Receiver
Input
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.
USART
RXD
Differential
TXD Bus
RTS
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 31-29 gives an example of the RTS waveform during a character transmission
when the timeguard is enabled.
TXD
Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit
Write
US_THR
TXRDY
TXEMPTY
RTS
375
6175H–ATARM–03-Dec-07
31.6.7 AT91SAM7S512/256/128/64/321/161 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 31-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.
TXD
Transmitter
TXD
Transmitter
TXD
Transmitter 1
377
6175H–ATARM–03-Dec-07
Figure 31-33. Remote Loopback Mode Configuration
RXD
Receiver 1
TXD
Transmitter
379
6175H–ATARM–03-Dec-07
31.7.1 USART Control Register
Name: US_CR
Access Type: Write-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – RTSDIS RTSEN DTRDIS(1) DTREN(1)
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 – –
0: No effect.
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.
381
6175H–ATARM–03-Dec-07
31.7.2 USART Mode Register
Name: US_MR
Access Type: Read-write
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
383
6175H–ATARM–03-Dec-07
• OVER: Oversampling Mode
0: 16x Oversampling.
1: 8x Oversampling.
• MAX_ITERATION
Defines the maximum number of iterations in mode ISO7816, protocol T= 0.
23 22 21 20 19 18 17 16
– – – – CTSIC DCDIC (1) DSRIC (1) RIIC (1)
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
385
6175H–ATARM–03-Dec-07
31.7.4 USART Interrupt Disable Register
Name: US_IDR
Access Type: Write-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – CTSIC DCDIC (1) DSRIC (1) RIIC (1)
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
23 22 21 20 19 18 17 16
– – – – CTSIC DCDIC (1) DSRIC(1) RIIC (1)
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
387
6175H–ATARM–03-Dec-07
31.7.6 USART Channel Status Register
Name: US_CSR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
CTS DCD DSR RI CTSIC DCDIC (1) DSRIC (1) RIIC (1)
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
389
6175H–ATARM–03-Dec-07
• RI: Image of RI Input
0: RI is at 0.
1: RI is at 1.
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
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
391
6175H–ATARM–03-Dec-07
31.7.9 USART Baud Rate Generator Register
Name: US_BRGR
Access Type: Read-write
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
USART_MODE ≠ ISO7816
USART_MODE =
CD SYNC = 0 SYNC = 1
ISO7816
OVER = 0 OVER = 1
0 Baud Rate Clock Disabled
Baud Rate = Baud Rate = Baud Rate = Baud Rate = Selected
1 to 65535
Selected Clock/16/CD Selected Clock/8/CD Selected Clock /CD Clock/CD/FI_DI_RATIO
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
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
393
6175H–ATARM–03-Dec-07
31.7.12 USART FI DI RATIO Register
Name: US_FIDI
Access Type: Read-write
Reset Value : 0x174
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
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
395
6175H–ATARM–03-Dec-07
31.7.14 USART IrDA FILTER Register
Name: US_IF
Access Type: Read-write
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
32.1 Description
The Atmel Synchronous Serial Controller (SSC) provides a synchronous communication link
with external devices. It supports many serial synchronous communication protocols generally
used in audio and telecom applications such as I2S, Short Frame Sync, Long Frame Sync, etc.
The SSC contains an independent receiver and transmitter and a common clock divider. The
receiver and the transmitter each interface with three signals: the TD/RD signal for data, the
TK/RK signal for the clock and the TF/RF signal for the Frame Sync. The transfers can be pro-
grammed to start automatically or on different events detected on the Frame Sync signal.
The SSC’s high-level of programmability and its two dedicated PDC channels of up to 32 bits
permit a continuous high bit rate data transfer without processor intervention.
Featuring connection to two PDC channels, the SSC permits interfacing with low processor
overhead to the following:
• CODEC’s in master or slave mode
• DAC through dedicated serial interface, particularly I2S
• Magnetic card reader
397
6175H–ATARM–03-Dec-07
32.2 Block Diagram
System
Bus
APB Bridge
PDC
Peripheral
Bus
TF
TK
TD
MCK
PMC
SSC Interface PIO
RF
RK
Interrupt Control
RD
SSC Interrupt
SSC
32.5.3 Interrupt
The SSC interface has an interrupt line connected to the Advanced Interrupt Controller (AIC).
Handling interrupts requires programming the AIC before configuring the SSC.
All SSC interrupts can be enabled/disabled configuring the SSC Interrupt mask register. Each
pending and unmasked SSC interrupt will assert the SSC interrupt line. The SSC interrupt ser-
vice routine can get the interrupt origin by reading the SSC interrupt status register.
399
6175H–ATARM–03-Dec-07
Figure 32-3. SSC Functional Block Diagram
Transmitter
Clock Output
TK
Controller
TK Input
MCK Clock Transmit Clock TX clock Frame Sync TF
Divider Controller Controller
RX clock
TF
Start
RF Transmit Shift Register TD
Selector
TX PDC Transmit Holding Transmit Sync
Register Holding Register
APB
Load Shift
User
Interface
RK Input
Receive Clock RX Clock Frame Sync
Controller RF
Controller
TX Clock
RF
Start
TF Receive Shift Register RD
Selector
AIC
SSC_CMR
The Master Clock divider is determined by the 12-bit field DIV counter and comparator (so its
maximal value is 4095) in the Clock Mode Register SSC_CMR, allowing a Master Clock division
by up to 8190. The Divided Clock is provided to both the Receiver and Transmitter. When this
field is programmed to 0, the Clock Divider is not used and remains inactive.
When DIV is set to a value equal to or greater than 1, the Divided Clock has a frequency of Mas-
ter Clock divided by 2 times DIV. Each level of the Divided Clock has a duration of the Master
Clock multiplied by DIV. This ensures a 50% duty cycle for the Divided Clock regardless of
whether the DIV value is even or odd.
Divided Clock
DIV = 1
Master Clock
Divided Clock
DIV = 3
Table 32-2.
Maximum Minimum
MCK / 2 MCK / 8190
401
6175H–ATARM–03-Dec-07
The transmitter can also drive the TK I/O pad continuously or be limited to the actual data trans-
fer. The clock output is configured by the SSC_TCMR register. The Transmit Clock Inversion
(CKI) bits have no effect on the clock outputs. Programming the TCMR register to select TK pin
(CKS field) and at the same time Continuous Transmit Clock (CKO field) might lead to unpredict-
able results.
Divider
Clock
CKI CKG
Divider
Clock
CKI CKG
403
6175H–ATARM–03-Dec-07
Figure 32-8. Transmitter Block Diagram
SSC_CR.TXEN
SSC_SR.TXEN
SSC_CR.TXDIS
SSC_TFMR.DATDEF SSC_TCMR.STTDLY
SSC_TFMR.FSDEN
SSC_TFMR.DATNB
1
SSC_TFMR.MSBF 0 TD
RF TF
Transmitter Clock
Start
Transmit Shift Register
Selector
SSC_TFMR.FSDEN 0 1
SSC_TCMR.STTDLY
SSC_CR.RXEN
SSC_SR.RXEN
SSC_CR.RXDIS
SSC_RFMR.MSBF SSC_RFMR.DATNB
RF TF
Receiver Clock
Start
Receive Shift Register RD
Selector
SSC_RSHR SSC_RHR
SSC_RCMR.STTDLY
SSC_RFMR.FSLEN SSC_RFMR.DATLEN
32.6.4 Start
The transmitter and receiver can both be programmed to start their operations when an event
occurs, respectively in the Transmit Start Selection (START) field of SSC_TCMR and in the
Receive Start Selection (START) field of SSC_RCMR.
Under the following conditions the start event is independently programmable:
• Continuous. In this case, the transmission starts as soon as a word is written in SSC_THR
and the reception starts as soon as the Receiver is enabled.
• Synchronously with the transmitter/receiver
• On detection of a falling/rising edge on TF/RF
• On detection of a low level/high level on TF/RF
• On detection of a level change or an edge on TF/RF
A start can be programmed in the same manner on either side of the Transmit/Receive Clock
Register (RCMR/TCMR). Thus, the start could be on TF (Transmit) or RF (Receive).
Moreover, the Receiver can start when data is detected in the bit stream with the Compare
Functions.
Detection on TF/RF input/output is done by the field FSOS of the Transmit/Receive Frame Mode
Register (TFMR/RFMR).
405
6175H–ATARM–03-Dec-07
Figure 32-10. Transmit Start Mode
TK
TF
(Input)
TD
Start = Low Level on TF X BO B1
(Output)
STTDLY
TD
Start = Level Change on TF X BO B1 BO B1
(Output)
STTDLY
TD
Start = Any Edge on TF (Output) X BO B1 BO B1
STTDLY
RF
(Input)
RD
Start = Low Level on RF X BO B1
(Input)
STTDLY
RD
Start = Level Change on RF X BO B1 BO B1
(Input)
STTDLY
RD
Start = Any Edge on RF (Input) X BO B1 BO B1
STTDLY
RK
407
6175H–ATARM–03-Dec-07
32.6.6.1 Compare Functions
Length of the comparison patterns (Compare 0, Compare 1) and thus the number of bits they
are compared to is defined by FSLEN, but with a maximum value of 16 bits. Comparison is
always done by comparing the last bits received with the comparison pattern. Compare 0 can be
one start event of the Receiver. In this case, the receiver compares at each new sample the last
bits received at the Compare 0 pattern contained in the Compare 0 Register (SSC_RC0R).
When this start event is selected, the user can program the Receiver to start a new data transfer
either by writing a new Compare 0, or by receiving continuously until Compare 1 occurs. This
selection is done with the bit (STOP) in SSC_RCMR.
Figure 32-13. Transmit and Receive Frame Format in Edge/Pulse Start Modes
Start Start
PERIOD
(1)
TF/RF
FSLEN
DATNB
Start
DATLEN DATLEN
409
6175H–ATARM–03-Dec-07
Note: 1. STTDLY is set to 0. In this example, SSC_THR is loaded twice. FSDEN value has no effect on
the transmission. SyncData cannot be output in continuous mode.
RD Data Data
To SSC_RHR To SSC_RHR
DATLEN DATLEN
32.6.9 Interrupt
Most bits in SSC_SR have a corresponding bit in interrupt management registers.
The SSC can be programmed to generate an interrupt when it detects an event. The interrupt is
controlled by writing SSC_IER (Interrupt Enable Register) and SSC_IDR (Interrupt Disable Reg-
ister) These registers enable and disable, respectively, the corresponding interrupt by setting
and clearing the corresponding bit in SSC_IMR (Interrupt Mask Register), which controls the
generation of interrupts by asserting the SSC interrupt line connected to the AIC.
SSC_IMR
SSC_IER SSC_IDR
PDC Set Clear
TXBUFE
ENDTX
Transmitter
TXRDY
TXEMPTY
TXSYNC
Interrupt SSC Interrupt
RXBUFF Control
ENDRX
Receiver
RXRDY
OVRUN
RXSYNC
Clock SCK
TK
Word Select WS
TF I2S
RECEIVER
Data SD
TD
SSC
RD Clock SCK
RF Word Select WS
RK
Data SD MSB LSB MSB
RF
Serial Data Clock (SCLK)
Serial Data In
411
6175H–ATARM–03-Dec-07
Figure 32-19. Time Slot Application Block Diagram
SCLK
TK
FSYNC
TF CODEC
First
Data Out
TD Time Slot
SSC
Data in
RD
RF
RK
CODEC
Second
Time Slot
Serial Data in
413
6175H–ATARM–03-Dec-07
32.8.1 SSC Control Register
Name: SSC_CR
Access Type: Write-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
SWRST – – – – – TXDIS TXEN
7 6 5 4 3 2 1 0
– – – – – – RXDIS RXEN
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – DIV
7 6 5 4 3 2 1 0
DIV
415
6175H–ATARM–03-Dec-07
32.8.3 SSC Receive Clock Mode Register
Name: SSC_RCMR
Access Type: Read-write
31 30 29 28 27 26 25 24
PERIOD
23 22 21 20 19 18 17 16
STTDLY
15 14 13 12 11 10 9 8
– – – STOP START
7 6 5 4 3 2 1 0
CKG CKI CKO CKS
417
6175H–ATARM–03-Dec-07
32.8.4 SSC Receive Frame Mode Register
Name: SSC_RFMR
Access Type: Read-write
31 30 29 28 27 26 25 24
– – – – – – – FSEDGE
23 22 21 20 19 18 17 16
– FSOS FSLEN
15 14 13 12 11 10 9 8
– – – – DATNB
7 6 5 4 3 2 1 0
MSBF – LOOP DATLEN
419
6175H–ATARM–03-Dec-07
32.8.5 SSC Transmit Clock Mode Register
Name: SSC_TCMR
Access Type: Read-write
31 30 29 28 27 26 25 24
PERIOD
23 22 21 20 19 18 17 16
STTDLY
15 14 13 12 11 10 9 8
– – – – START
7 6 5 4 3 2 1 0
CKG CKI CKO CKS
421
6175H–ATARM–03-Dec-07
32.8.6 SSC Transmit Frame Mode Register
Name: SSC_TFMR
Access Type: Read-write
31 30 29 28 27 26 25 24
– – – – – – – FSEDGE
23 22 21 20 19 18 17 16
FSDEN FSOS FSLEN
15 14 13 12 11 10 9 8
– – – – DATNB
7 6 5 4 3 2 1 0
MSBF – DATDEF DATLEN
423
6175H–ATARM–03-Dec-07
32.8.7 SSC Receive Holding Register
Name: SSC_RHR
Access Type: Read-only
31 30 29 28 27 26 25 24
RDAT
23 22 21 20 19 18 17 16
RDAT
15 14 13 12 11 10 9 8
RDAT
7 6 5 4 3 2 1 0
RDAT
23 22 21 20 19 18 17 16
TDAT
15 14 13 12 11 10 9 8
TDAT
7 6 5 4 3 2 1 0
TDAT
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
RSDAT
7 6 5 4 3 2 1 0
RSDAT
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
TSDAT
7 6 5 4 3 2 1 0
TSDAT
425
6175H–ATARM–03-Dec-07
32.8.11 SSC Receive Compare 0 Register
Name: SSC_RC0R
Access Type: Read-write
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
CP0
7 6 5 4 3 2 1 0
CP0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
CP1
7 6 5 4 3 2 1 0
CP1
23 22 21 20 19 18 17 16
– – – – – – RXEN TXEN
15 14 13 12 11 10 9 8
– – – – RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
427
6175H–ATARM–03-Dec-07
• RXBUFF: Receive Buffer Full
0 = SSC_RCR or SSC_RNCR have a value other than 0.
1 = Both SSC_RCR and SSC_RNCR have a value of 0.
• CP0: Compare 0
0 = A compare 0 has not occurred since the last read of the Status Register.
1 = A compare 0 has occurred since the last read of the Status Register.
• CP1: Compare 1
0 = A compare 1 has not occurred since the last read of the Status Register.
1 = A compare 1 has occurred since the last read of the Status Register.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
429
6175H–ATARM–03-Dec-07
• RXBUFF: Receive Buffer Full Interrupt Enable
0 = No effect.
1 = Enables the Receive Buffer Full Interrupt.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
431
6175H–ATARM–03-Dec-07
• RXBUFF: Receive Buffer Full Interrupt Disable
0 = No effect.
1 = Disables the Receive Buffer Full Interrupt.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
433
6175H–ATARM–03-Dec-07
• RXBUFF: Receive Buffer Full Interrupt Mask
0 = The Receive Buffer Full Interrupt is disabled.
1 = The Receive Buffer Full Interrupt is enabled.
33.1 Overview
The Timer Counter (TC) includes three identical 16-bit Timer Counter channels.
Each channel can be independently programmed to perform a wide range of functions including
frequency measurement, event counting, interval measurement, pulse generation, delay timing
and pulse width modulation.
Each channel has three external clock inputs, five internal clock inputs and two multi-purpose
input/output signals which can be configured by the user. Each channel drives an internal inter-
rupt signal which can be programmed to generate processor interrupts.
The Timer Counter block has two global registers which act upon all three TC channels.
The Block Control Register allows the three channels to be started simultaneously with the same
instruction.
The Block Mode Register defines the external clock inputs for each channel, allowing them to be
chained.
Table 33-1 gives the assignment of the device Timer Counter clock inputs common to Timer
Counter 0 to 2
435
6175H–ATARM–03-Dec-07
33.2 Block Diagram
Parallel I/O
TIMER_CLOCK1 Controller
TCLK0
TCLK0
TIMER_CLOCK2 TCLK1
TIOA1 TCLK2
TCLK0
TCLK2 SYNC
INT1
TC1XC1S
Timer Counter
Advanced
Interrupt
Controller
33.4.3 Interrupt
The TC has an interrupt line connected to the Advanced Interrupt Controller (AIC). Handling the
TC interrupt requires programming the AIC before configuring the TC.
33.5.1 TC Description
The three channels of the Timer Counter are independent and identical in operation. The regis-
ters for channel programming are listed in Table 33-4 on page 451.
Timer/Counter
TCLK0 Channel 0
TIOA1
XC0 TIOA0
TIOA2
XC1 = TCLK1
XC2 = TCLK2 TIOB0
SYNC
TC1XC1S
Timer/Counter
Channel 1
TCLK1 XC0 = TCLK2 TIOA1
TIOA0
XC1
TIOA2
XC2 = TCLK2 TIOB1
SYNC
Timer/Counter
TC2XC2S Channel 2
XC0 = TCLK0 TIOA2
TCLK2 XC1 = TCLK1
TIOA0
XC2 TIOB2
TIOA1
SYNC
TCCLKS
TIMER_CLOCK1
TIMER_CLOCK2 CLKI
TIMER_CLOCK3
TIMER_CLOCK4
TIMER_CLOCK5
Selected
XC0 Clock
XC1
XC2
BURST
Q S
R
Q S
R
Stop Disable
Counter Event Event
Clock
33.5.6 Trigger
A trigger resets the counter and starts the counter clock. Three types of triggers are common to
both modes, and a fourth external trigger is available to each mode.
The following triggers are common to both modes:
XC0
R
XC1
XC2
LDBSTOP LDBDIS
BURST
Register C
Capture Capture
1 Register A Register B Compare RC =
16-bit Counter
SWTRG
CLK
OVF
RESET
SYNC
Trig
ABETRG
MTIOB Edge
Detector
TIOB
LDRA LDRB
CPCS
LDRAS
LDRBS
LOVRS
ETRGS
COVFS
TC1_SR
Timer/Counter Channel
INT
6175H–ATARM–03-Dec-07
33.5.10 Waveform Operating Mode
Waveform operating mode is entered by setting the WAVE parameter in TC_CMR (Channel
Mode Register).
In Waveform Operating Mode the TC channel generates 1 or 2 PWM signals with the same fre-
quency and independently programmable duty cycles, or generates different types of one-shot
or repetitive pulses.
In this mode, TIOA is configured as an output and TIOB is defined as an output if it is not used
as an external event (EEVT parameter in TC_CMR).
Figure 33-6 shows the configuration of the TC channel when programmed in Waveform Operat-
ing Mode.
Output Controller
16-bit Counter
CLK
BCPC
SYNC
Trig
BCPB MTIOB
WAVSEL
EEVT
TIOB
BEEVT
EEVTEDG
ENETRG
Output Controller
CPAS
CPBS
CPCS
ETRGS
COVFS
Edge
TC1_SR
Detector BSWTRG
TIOB
TC1_IMR
Timer/Counter Channel
INT
6175H–ATARM–03-Dec-07
33.5.11.1 WAVSEL = 00
When WAVSEL = 00, the value of TC_CV is incremented from 0 to 0xFFFF. Once 0xFFFF has
been reached, the value of TC_CV is reset. Incrementation of TC_CV starts again and the cycle
continues. See Figure 33-7.
An external event trigger or a software trigger can reset the value of TC_CV. It is important to
note that the trigger may occur at any time. See Figure 33-8.
RC Compare cannot be programmed to generate a trigger in this configuration. At the same
time, RC Compare can stop the counter clock (CPCSTOP = 1 in TC_CMR) and/or disable the
counter clock (CPCDIS = 1 in TC_CMR).
0xFFFF
RC
RB
RA
TIOB
TIOA
0xFFFF
RB
RA
Time
Waveform Examples
TIOB
TIOA
33.5.11.2 WAVSEL = 10
When WAVSEL = 10, the value of TC_CV is incremented from 0 to the value of RC, then auto-
matically reset on a RC Compare. Once the value of TC_CV has been reset, it is then
incremented and so on. See Figure 33-9.
It is important to note that TC_CV can be reset at any time by an external event or a software
trigger if both are programmed correctly. See Figure 33-10.
In addition, RC Compare can stop the counter clock (CPCSTOP = 1 in TC_CMR) and/or disable
the counter clock (CPCDIS = 1 in TC_CMR).
0xFFFF
Counter cleared by compare match with RC
RC
RB
RA
TIOB
TIOA
0xFFFF
Counter cleared by compare match with RC Counter cleared by trigger
RC
RB
RA
TIOB
TIOA
33.5.11.3 WAVSEL = 01
When WAVSEL = 01, the value of TC_CV is incremented from 0 to 0xFFFF. Once 0xFFFF is
reached, the value of TC_CV is decremented to 0, then re-incremented to 0xFFFF and so on.
See Figure 33-11.
A trigger such as an external event or a software trigger can modify TC_CV at any time. If a trig-
ger occurs while TC_CV is incrementing, TC_CV then decrements. If a trigger is received while
TC_CV is decrementing, TC_CV then increments. See Figure 33-12.
RC Compare cannot be programmed to generate a trigger in this configuration.
At the same time, RC Compare can stop the counter clock (CPCSTOP = 1) and/or disable the
counter clock (CPCDIS = 1).
0xFFFF
RC
RB
RA
TIOB
TIOA
Counter Value
0xFFFF
Counter cleared by compare match with RC Counter cleared by trigger
RC
RB
RA
TIOB
TIOA
33.5.11.4 WAVSEL = 11
When WAVSEL = 11, the value of TC_CV is incremented from 0 to RC. Once RC is reached, the
value of TC_CV is decremented to 0, then re-incremented to RC and so on. See Figure 33-13.
A trigger such as an external event or a software trigger can modify TC_CV at any time. If a trig-
ger occurs while TC_CV is incrementing, TC_CV then decrements. If a trigger is received while
TC_CV is decrementing, TC_CV then increments. See Figure 33-14.
RC Compare can stop the counter clock (CPCSTOP = 1) and/or disable the counter clock (CPC-
DIS = 1).
0xFFFF
Counter decremented by compare match with RC
RC
RB
RA
TIOB
TIOA
0xFFFF
Counter decremented by compare match with RC
RC
Counter decremented
by trigger
RB
Counter incremented
by trigger
RA
TIOB
TIOA
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – – SYNC
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – TC2XC2S TC1XC1S TC0XC0S
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – SWTRG CLKDIS CLKEN
23 22 21 20 19 18 17 16
– – – – LDRB LDRA
15 14 13 12 11 10 9 8
WAVE CPCTRG – – – ABETRG ETRGEDG
7 6 5 4 3 2 1 0
LDBDIS LDBSTOP BURST CLKI TCCLKS
BURST
0 0 The clock is not gated by an external signal.
0 1 XC0 is ANDed with the selected clock.
1 0 XC1 is ANDed with the selected clock.
1 1 XC2 is ANDed with the selected clock.
ETRGEDG Edge
0 0 none
0 1 rising edge
1 0 falling edge
1 1 each edge
• WAVE
0 = Capture Mode is enabled.
1 = Capture Mode is disabled (Waveform Mode is enabled).
LDRA Edge
0 0 none
0 1 rising edge of TIOA
1 0 falling edge of TIOA
1 1 each edge of TIOA
LDRB Edge
0 0 none
0 1 rising edge of TIOA
1 0 falling edge of TIOA
1 1 each edge of TIOA
23 22 21 20 19 18 17 16
ASWTRG AEEVT ACPC ACPA
15 14 13 12 11 10 9 8
WAVE WAVSEL ENETRG EEVT EEVTEDG
7 6 5 4 3 2 1 0
CPCDIS CPCSTOP BURST CLKI TCCLKS
BURST
0 0 The clock is not gated by an external signal.
0 1 XC0 is ANDed with the selected clock.
1 0 XC1 is ANDed with the selected clock.
1 1 XC2 is ANDed with the selected clock.
EEVTEDG Edge
0 0 none
0 1 rising edge
1 0 falling edge
1 1 each edge
WAVSEL Effect
0 0 UP mode without automatic trigger on RC Compare
1 0 UP mode with automatic trigger on RC Compare
0 1 UPDOWN mode without automatic trigger on RC Compare
1 1 UPDOWN mode with automatic trigger on RC Compare
• WAVE
0 = Waveform Mode is disabled (Capture Mode is enabled).
1 = Waveform Mode is enabled.
ACPA Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
ACPC Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
AEEVT Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
ASWTRG Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
BCPB Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
BCPC Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
BEEVT Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
BSWTRG Effect
0 0 none
0 1 set
1 0 clear
1 1 toggle
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
CV
7 6 5 4 3 2 1 0
CV
33.6.7 TC Register A
Register Name: TC_RAx [x=0..2]
Access Type: Read-only if WAVE = 0, Read-write if WAVE = 1
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
RA
7 6 5 4 3 2 1 0
RA
• RA: Register A
RA contains the Register A value in real time.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
RB
7 6 5 4 3 2 1 0
RB
• RB: Register B
RB contains the Register B value in real time.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
RC
7 6 5 4 3 2 1 0
RC
• RC: Register C
RC contains the Register C value in real time.
23 22 21 20 19 18 17 16
– – – – – MTIOB MTIOA CLKSTA
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
• CPAS: RA Compare
0 = No effect.
1 = Enables the RA Compare Interrupt.
• CPBS: RB Compare
0 = No effect.
1 = Enables the RB Compare Interrupt.
• CPCS: RC Compare
0 = No effect.
1 = Enables the RC Compare Interrupt.
• LDRAS: RA Loading
0 = No effect.
1 = Enables the RA Load Interrupt.
• LDRBS: RB Loading
0 = No effect.
1 = Enables the RB Load Interrupt.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
• CPAS: RA Compare
0 = No effect.
1 = Disables the RA Compare Interrupt (if WAVE = 1).
• CPBS: RB Compare
0 = No effect.
1 = Disables the RB Compare Interrupt (if WAVE = 1).
• CPCS: RC Compare
0 = No effect.
1 = Disables the RC Compare Interrupt.
• LDRAS: RA Loading
0 = No effect.
1 = Disables the RA Load Interrupt (if WAVE = 0).
• LDRBS: RB Loading
0 = No effect.
1 = Disables the RB Load Interrupt (if WAVE = 0).
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
• CPAS: RA Compare
0 = The RA Compare Interrupt is disabled.
1 = The RA Compare Interrupt is enabled.
• CPBS: RB Compare
0 = The RB Compare Interrupt is disabled.
1 = The RB Compare Interrupt is enabled.
• CPCS: RC Compare
0 = The RC Compare Interrupt is disabled.
1 = The RC Compare Interrupt is enabled.
• LDRAS: RA Loading
0 = The Load RA Interrupt is disabled.
1 = The Load RA Interrupt is enabled.
• LDRBS: RB Loading
0 = The Load RB Interrupt is disabled.
1 = The Load RB Interrupt is enabled.
34.1 overview
The PWM macrocell controls several channels independently. Each channel controls one
square output waveform. Characteristics of the output waveform such as period, duty-cycle and
polarity are configurable through the user interface. Each channel selects and uses one of the
clocks provided by the clock generator. The clock generator provides several clocks resulting
from the division of the PWM macrocell master clock.
All PWM macrocell accesses are made through APB mapped registers.
Channels can be synchronized, to generate non overlapped waveforms. All channels integrate a
double buffering system in order to prevent an unexpected output waveform while modifying the
period or the duty-cycle.
PWM
Controller
PWMx
Channel Period
Update PWMx
Comparator
Duty Cycle PWMx
Clock
Selector Counter
PIO
PWM0 Period
Channel
Update PWM0
Comparator
Duty Cycle PWM0
Clock
Selector Counter
MCK
PMC Clock Generator APB Interface Interrupt Generator AIC
APB
469
6175H–ATARM–03-Dec-07
34.3 I/O Lines Description
Each channel outputs one waveform on one external I/O line.
modulo n counter
MCK
MCK
MCK/2
MCK/4
MCK/8
MCK/16
MCK/32
MCK/64
MCK/128
MCK/256
MCK/512
MCK/1024
Divider A clkA
PREA DIVA
PWM_MR
Divider B clkB
PREB DIVB
PWM_MR
Caution: Before using the PWM macrocell, the programmer must first enable the PWM clock in
the Power Management Controller (PMC).
The PWM macrocell master clock, MCK, is divided in the clock generator module to provide dif-
ferent clocks available for all channels. Each channel can independently select one of the
divided clocks.
471
6175H–ATARM–03-Dec-07
After a reset of the PWM controller, DIVA (DIVB) and PREA (PREB) in the PWM Mode register
are set to 0. This implies that after reset clkA (clkB) are turned off.
At reset, all clocks provided by the modulo n counter are turned off except clock “clk”. This situa-
tion is also true when the PWM master clock is turned off through the Power Management
Controller.
inputs from
APB bus
( X × CPRD )
-------------------------------
MCK
By using a Master Clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
If the waveform is center aligned then the output waveform period depends on the counter
source clock and can be calculated:
By using the Master Clock (MCK) divided by an X given prescaler value
(with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will
be:
(----------------------------------------
2 × X × CPRD )-
MCK
By using a Master Clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
(---------------------------------------------------
2 × CPRD × DIVA )- ( 2 × CPRD × DIVB )
or ----------------------------------------------------
MCK MCK
• the waveform duty cycle. This channel parameter is defined in the CDTY field of the
PWM_CDTYx register.
If the waveform is left aligned then:
• the waveform polarity. At the beginning of the period, the signal can be at high or low level.
This property is defined in the CPOL field of the PWM_CMRx register. By default the signal
starts by a low level.
• the waveform alignment. The output waveform can be left or center aligned. Center aligned
waveforms can be used to generate non overlapped waveforms. This property is defined in
the CALG field of the PWM_CMRx register. The default mode is left aligned.
PWM0
PWM1
Period
Note: See Figure 34-5 on page 475 for a detailed description of center aligned waveforms.
473
6175H–ATARM–03-Dec-07
When center aligned, the internal channel counter increases up to CPRD and.decreases down
to 0. This ends the period.
When left aligned, the internal channel counter increases up to CPRD and is reset. This ends
the period.
Thus, for the same CPRD value, the period for a center aligned channel is twice the period for a
left aligned channel.
Waveforms are fixed at 0 when:
• CDTY = CPRD and CPOL = 0
• CDTY = 0 and CPOL = 1
Waveforms are fixed at 1 (once the channel is enabled) when:
• CDTY = 0 and CPOL = 0
• CDTY = CPRD and CPOL = 1
The waveform polarity must be set before enabling the channel. This immediately affects the
channel output level. Changes on channel polarity are not taken into account while the channel
is enabled.
CHIDx(PWM_SR)
CHIDx(PWM_ENA)
CHIDx(PWM_DIS)
Center Aligned
CALG(PWM_CMRx) = 1
PWM_CCNTx
CPRD(PWM_CPRDx)
CDTY(PWM_CDTYx)
Period
CHIDx(PWM_ISR)
Left Aligned
CALG(PWM_CMRx) = 0
PWM_CCNTx
CPRD(PWM_CPRDx)
CDTY(PWM_CDTYx)
Period
CHIDx(PWM_ISR)
475
6175H–ATARM–03-Dec-07
34.5.3 PWM Controller Operations
34.5.3.1 Initialization
Before enabling the output channel, this channel must have been configured by the software
application:
• Configuration of the clock generator if DIVA and DIVB are required
• Selection of the clock for each channel (CPRE field in the PWM_CMRx register)
• Configuration of the waveform alignment for each channel (CALG field in the PWM_CMRx
register)
• Configuration of the period for each channel (CPRD in the PWM_CPRDx register). Writing in
PWM_CPRDx Register is possible while the channel is disabled. After validation of the
channel, the user must use PWM_CUPDx Register to update PWM_CPRDx as explained
below.
• Configuration of the duty cycle for each channel (CDTY in the PWM_CDTYx register).
Writing in PWM_CDTYx Register is possible while the channel is disabled. After validation of
the channel, the user must use PWM_CUPDx Register to update PWM_CDTYx as explained
below.
• Configuration of the output waveform polarity for each channel (CPOL in the PWM_CMRx
register)
• Enable Interrupts (Writing CHIDx in the PWM_IER register)
• Enable the PWM channel (Writing CHIDx in the PWM_ENA register)
It is possible to synchronize different channels by enabling them at the same time by means of
writing simultaneously several CHIDx bits in the PWM_ENA register.
• In such a situation, all channels may have the same clock selector configuration and the
same period specified.
User's Writing
PWM_CUPDx Value
1 0
PWM_CMRx. CPD
PWM_CPRDx PWM_CDTYx
End of Cycle
To prevent overwriting the PWM_CUPDx by software, the user can use status events in order to
synchronize his software. Two methods are possible. In both, the user must enable the dedi-
cated interrupt in PWM_IER at PWM Controller level.
The first method (polling method) consists of reading the relevant status bit in PWM_ISR Regis-
ter according to the enabled channel(s). See Figure 34-7.
The second method uses an Interrupt Service Routine associated with the PWM channel.
Note: Reading the PWM_ISR register automatically clears CHIDx flags.
PWM_ISR Read
Acknowledgement and clear previous register state
CHIDx = 1
YES
Writing in PWM_CUPDx
The last write has been taken into account
Note: Polarity and alignment can be modified only when the channel is disabled.
477
6175H–ATARM–03-Dec-07
34.5.3.4 Interrupts
Depending on the interrupt mask in the PWM_IMR register, an interrupt is generated at the end
of the corresponding channel period. The interrupt remains active until a read operation in the
PWM_ISR register occurs.
A channel interrupt is enabled by setting the corresponding bit in the PWM_IER register. A chan-
nel interrupt is disabled by setting the corresponding bit in the PWM_IDR register.
23 22 21 20 19 18 17 16
DIVB
15 14 13 12 11 10 9 8
– – – – PREA
7 6 5 4 3 2 1 0
DIVA
• PREA, PREB
479
6175H–ATARM–03-Dec-07
34.6.2 PWM Enable Register
Register Name: PWM_ENA
Access Type: Write-only
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
– – – – CHID3 CHID2 CHID1 CHID0
• CHIDx: Channel ID
0 = No effect.
1 = Enable PWM output for channel x.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – CHID3 CHID2 CHID1 CHID0
• CHIDx: Channel ID
0 = No effect.
1 = Disable PWM output for channel x.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – CHID3 CHID2 CHID1 CHID0
• CHIDx: Channel ID
0 = PWM output for channel x is disabled.
1 = PWM output for channel x is enabled.
481
6175H–ATARM–03-Dec-07
34.6.5 PWM Interrupt Enable Register
Register Name: PWM_IER
Access Type: Write-only
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
– – – – CHID3 CHID2 CHID1 CHID0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – CHID3 CHID2 CHID1 CHID0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – CHID3 CHID2 CHID1 CHID0
483
6175H–ATARM–03-Dec-07
34.6.8 PWM Interrupt Status Register
Register Name: PWM_ISR
Access Type: Read-only
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
– – – – CHID3 CHID2 CHID1 CHID0
• CHIDx: Channel ID
0 = No new channel period has been achieved since the last read of the PWM_ISR register.
1 = At least one new channel period has been achieved since the last read of the PWM_ISR register.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – CPD CPOL CALG
7 6 5 4 3 2 1 0
– – – – CPRE
485
6175H–ATARM–03-Dec-07
34.6.10 PWM Channel Duty Cycle Register
Register Name: PWM_CDTY[0..X-1]
Access Type: Read/Write
31 30 29 28 27 26 25 24
CDTY
23 22 21 20 19 18 17 16
CDTY
15 14 13 12 11 10 9 8
CDTY
7 6 5 4 3 2 1 0
CDTY
Only the first 16 bits (internal channel counter size) are significant.
23 22 21 20 19 18 17 16
CPRD
15 14 13 12 11 10 9 8
CPRD
7 6 5 4 3 2 1 0
CPRD
Only the first 16 bits (internal channel counter size) are significant.
(------------------------------
X × CPRD )-
MCK
– By using a Master Clock divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
(-----------------------------------------
CRPD × DIVA )- ( CRPD × DIVAB )
or ----------------------------------------------
MCK MCK
If the waveform is center-aligned, then the output waveform period depends on the counter source clock and can be
calculated:
– By using the Master Clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128,
256, 512, or 1024). The resulting period formula will be:
(----------------------------------------
2 × X × CPRD )-
MCK
– By using a Master Clock divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
(---------------------------------------------------
2 × CPRD × DIVA )- ( 2 × CPRD × DIVB )
or ----------------------------------------------------
MCK MCK
487
6175H–ATARM–03-Dec-07
34.6.12 PWM Channel Counter Register
Register Name: PWM_CCNT[0..X-1]
Access Type: Read-only
31 30 29 28 27 26 25 24
CNT
23 22 21 20 19 18 17 16
CNT
15 14 13 12 11 10 9 8
CNT
7 6 5 4 3 2 1 0
CNT
23 22 21 20 19 18 17 16
CUPD
15 14 13 12 11 10 9 8
CUPD
7 6 5 4 3 2 1 0
CUPD
This register acts as a double buffer for the period or the duty cycle. This prevents an unexpected waveform when modify-
ing the waveform period or duty-cycle.
Only the first 16 bits (internal channel counter size) are significant.
35.1 Overview
The USB Device Port (UDP) is compliant with the Universal Serial Bus (USB) V2.0 full-speed
device specification.
Each endpoint can be configured in one of several USB transfer types. It can be associated with
one or two banks of a dual-port RAM used to store the current data payload. If two banks are
used, one DPR bank is read or written by the processor, while the other is read or written by the
USB device peripheral. This feature is mandatory for isochronous endpoints. Thus the device
maintains the maximum bandwidth (1M bytes/s) by working with endpoints with two banks of
DPR.
489
6175H–ATARM–03-Dec-07
35.2 Block Diagram
Atmel Bridge
USB Device
APB
to
MCU txoen
Bus eopn
MCK U W W
s r Dual r Serial DP
txd
UDPCK e a Port a Interface Embedded
r p RAM p Engine USB
p p rxdm DM
Transceiver
I e e rxd
n FIFO 12 MHz SIE
r r
t rxdp
e
r
f
udp_int a
c
e Suspend/Resume Logic
Access to the UDP is via the APB bus interface. Read and write to the data FIFO are done by
reading and writing 8-bit values to APB registers.
The UDP peripheral requires two clocks: one peripheral clock used by the Master Clock domain
(MCK) and a 48 MHz clock (UDPCK) used by the 12 MHz domain.
A USB 2.0 full-speed pad is embedded and controlled by the Serial Interface Engine (SIE).
The signal external_resume is optional. It allows the UDP peripheral to wake up once in system
mode. The host is then notified that the device asks for a resume. This optional feature must be
also negotiated with the host during the enumeration.
35.3.3 Interrupt
The USB device interface has an interrupt line connected to the Advanced Interrupt Controller
(AIC).
Handling the USB device interrupt requires programming the AIC before configuring the UDP.
47 K
3V3
1.5K
REXT
2 1
DDM
DDP
3 Type B 4
REXT
Connector
330 K 330 K
Software Client
The Control Transfer endpoint EP0 is always used when a USB device is first configured (USB v. 2.0 specifications).
No Data
Control Setup TX Status IN TX
Notes: 1. During the Status IN stage, the host waits for a zero length packet (Data IN transaction with no
data) from the device using DATA1 PID. Refer to Chapter 8 of the Universal Serial Bus Specifi-
cation, Rev. 2.0, for more information on the protocol layer.
2. During the Status OUT stage, the host emits a zero length packet to the device (Data OUT
transaction with no data).
USB Setup Data Setup ACK Data OUT Data OUT NAK Data OUT Data OUT ACK
Bus Packets PID PID PID PID PID PID
USB Bus Packets Data IN Data IN 1 ACK Data IN NAK Data IN Data IN 2 ACK
PID PID PID PID PID PID
TXPKTRDY Flag
(UDP_CSRx)
Set by the firmware Set by the firmware Cleared by Hw
Cleared by Hw
Interrupt Pending Interrupt
TXCOMP Flag Pending
(UDP_CSRx) Payload in FIFO
Cleared by Firmware Cleared by
DPR access by the hardware Firmware
DPR access by the firmware
FIFO (DPR)
Content Data IN 1 Load In Progress Data IN 2
Write Read
1st Data Payload
Bank 0
Endpoint 1
Read and Write at the Same Time
Data IN Packet
Bank 0
Endpoint 1 3rd Data Payload
When using a ping-pong endpoint, the following procedures are required to perform Data IN
transactions:
TXPKTRDY Flag
(UDP_MCSRx) Cleared by USB Device,
Data Payload Fully Transmitted Set by Firmware,
Set by Firmware, Data Payload Written in FIFO Bank 1
Data Payload Written in FIFO Bank 0
Interrupt Pending
Set by USB
TXCOMP Flag Device Set by USB Device
(UDP_CSRx)
Interrupt Cleared by Firmware
Warning: There is software critical path due to the fact that once the second bank is filled, the
driver has to wait for TX_COMP to set TX_PKTRDY. If the delay between receiving TX_COMP
is set and TX_PKTRDY is set too long, some Data IN packets may be NACKed, reducing the
bandwidth.
Warning: TX_COMP must be cleared after TX_PKTRDY has been set.
USB Bus Data OUT ACK Data OUT2 Data OUT2 NAK Data OUT Data OUT2 ACK
PID Data OUT 1 PID PID PID PID PID
Packets
FIFO (DPR)
Data OUT 1 Data OUT 1 Data OUT 2
Content
Written by USB Device Microcontroller Read Written by USB Device
An interrupt is pending while the flag RX_DATA_BK0 is set. Memory transfer between the USB
device, the FIFO and microcontroller memory can not be done after RX_DATA_BK0 has been
cleared. Otherwise, the USB device would accept the next Data OUT transfer and overwrite the
current Data OUT packet in the FIFO.
Figure 35-10. Bank Swapping in Data OUT Transfers for Ping-pong Endpoints
Write Read
When using a ping-pong endpoint, the following procedures are required to perform Data OUT
transactions:
1. The host generates a Data OUT packet.
2. This packet is received by the USB device endpoint. It is written in the endpoint’s FIFO
Bank 0.
3. The USB device sends an ACK PID packet to the host. The host can immediately send
a second Data OUT packet. It is accepted by the device and copied to FIFO Bank 1.
4. The microcontroller is notified that the USB device has received a data payload, polling
RX_DATA_BK0 in the endpoint’s UDP_ CSRx register. An interrupt is pending for this
endpoint while RX_DATA_BK0 is set.
5. The number of bytes available in the FIFO is made available by reading RXBYTECNT
in the endpoint’s UDP_ CSRx register.
6. The microcontroller transfers out data received from the endpoint’s memory to the
microcontroller’s memory. Data received is made available by reading the endpoint’s
UDP_ FDRx register.
7. The microcontroller notifies the USB peripheral device that it has finished the transfer
by clearing RX_DATA_BK0 in the endpoint’s UDP_ CSRx register.
8. A third Data OUT packet can be accepted by the USB peripheral device and copied in
the FIFO Bank 0.
9. If a second Data OUT packet has been received, the microcontroller is notified by the
flag RX_DATA_BK1 set in the endpoint’s UDP_ CSRx register. An interrupt is pending
for this endpoint while RX_DATA_BK1 is set.
10. The microcontroller transfers out data received from the endpoint’s memory to the
microcontroller’s memory. Data received is available by reading the endpoint’s UDP_
FDRx register.
USB Bus Data OUT ACK Data OUT ACK Data OUT
Packets PID Data OUT 1 PID PID Data OUT 2 PID PID Data OUT 3
A
P
FIFO (DPR)
Bank 0 Data OUT1 Data OUT 1 Data OUT 3
Write by USB Device Read By Microcontroller Write In Progress
FIFO (DPR)
Bank 1 Data OUT 2 Data OUT 2
Warning: When RX_DATA_BK0 and RX_DATA_BK1 are both set, there is no way to determine
which one to clear first. Thus the software must keep an internal counter to be sure to clear alter-
natively RX_DATA_BK0 then RX_DATA_BK1. This situation may occur when the software
application is busy elsewhere and the two banks are filled by the USB host. Once the application
comes back to the USB driver, the two flags are set.
Cleared by Firmware
FORCESTALL Set by Firmware
Interrupt Pending
Cleared by Firmware
STALLSENT
Set by
USB Device
Interrupt Pending
Attached
Hub Reset
Hub
or
Configured
Deconfigured
Bus Inactive
Powered Suspended
Bus Activity
Power
Interruption Reset
Bus Inactive
Suspended
Default
Bus Activity
Reset
Address
Assigned
Bus Inactive
Address Suspended
Bus Activity
Device Device
Deconfigured Configured
Bus Inactive
Configured
Suspended
Bus Activity
Movement from one state to another depends on the USB bus state or on standard requests
sent through control transactions via the default endpoint (endpoint 0).
After a period of bus inactivity, the USB device enters Suspend Mode. Accepting Sus-
pend/Resume requests from the USB host is mandatory. Constraints in Suspend Mode are very
strict for bus-powered applications; devices may not consume more than 500 µA on the USB
bus.
While in Suspend Mode, the host may wake up a device by sending a resume signal (bus activ-
ity) or a USB device may send a wake up request to the host, e.g., waking up a PC by moving a
USB mouse.
The wake up feature is not mandatory for all devices and must be negotiated with the host.
PIO
0: Force Wake UP (K State)
1: Normal Mode
1.5 K
DM
23 22 21 20 19 18 17 16
– – – – – – FRM_OK FRM_ERR
15 14 13 12 11 10 9 8
– – – – – FRM_NUM
7 6 5 4 3 2 1 0
FRM_NUM
• FRM_OK: Frame OK
This bit is set at SOF_EOP when the SOF packet is received without any error.
This bit is reset upon receipt of SOF_PID (Packet Identification).
In the Interrupt Status Register, the SOF interrupt is updated upon receiving SOF_PID. This bit is set without waiting for
EOP.
Note: In the 8-bit Register Interface, FRM_OK is bit 4 of FRM_NUM_H and FRM_ERR is bit 3 of FRM_NUM_L.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – CONFG FADDEN
This register is used to get and set the device state as specified in Chapter 9 of the USB Serial Bus Specification, Rev.2.0.
• CONFG: Configured
Read:
0 = Device is not in configured state.
1 = Device is in configured state.
Write:
0 = Sets device in a non configured state
1 = Sets device in configured state.
The device is set in configured state when it is in address state and receives a successful Set Configuration request. Refer
to Chapter 9 of the Universal Serial Bus Specification, Rev. 2.0 for more details.
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – FEN
7 6 5 4 3 2 1 0
– FADD
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – WAKEUP – SOFINT – RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – WAKEUP – SOFINT – RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – WAKEUP BIT12 SOFINT – RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – WAKEUP ENDBUSRES SOFINT – RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – WAKEUP ENDBUSRES SOFINT – RXRSM RXSUSP
7 6 5 4 3 2 1 0
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
EP3 EP2 EP1 EP0
23 22 21 20 19 18 17 16
RXBYTECNT
15 14 13 12 11 10 9 8
EPEDS – – – DTGLE EPTYPE
7 6 5 4 3 2 1 0
RX_DATA_ FORCE STALLSENT RX_DATA_
DIR TXPKTRDY RXSETUP TXCOMP
BK1 STALL ISOERROR BK0
WARNING: Due to synchronization between MCK and UDPCK, the software application must wait for the end of the write
operation before executing another write by polling the bits which must be set/cleared.
//! Clear flags of UDP UDP_CSR register and waits for synchronization
#define Udp_ep_clr_flag(pInterface, endpoint, flags) { \
pInterface->UDP_CSR[endpoint] &= ~(flags); \
while ( (pInterface->UDP_CSR[endpoint] & (flags)) == (flags) ); \
}
//! Set flags of UDP UDP_CSR register and waits for synchronization
#define Udp_ep_set_flag(pInterface, endpoint, flags) { \
pInterface->UDP_CSR[endpoint] |= (flags); \
while ( (pInterface->UDP_CSR[endpoint] & (flags)) != (flags) ); \
}
Note: In a preemptive environment, set or clear the flag and wait for a time of 1 UDPCK clock cycle and 1peripheral clock cycle. How-
ever, RX_DATA_BLK0, TXPKTRDY, RX_DATA_BK1 require wait times of 3 UDPCK clock cycles and 3 peripheral clock cycles
before accessin DPR.
• RX_DATA_BK1: Receive Data Bank 1 (only used by endpoints with ping-pong attributes)
This flag generates an interrupt while it is set to one.
Write (Cleared by the firmware):
0 = Notifies USB device that data have been read in the FIFO’s Bank 1.
1 = To leave the read value unchanged.
Read (Set by the USB peripheral):
0 = No data packet has been received in the FIFO's Bank 1.
1 = A data packet has been received, it has been stored in FIFO's Bank 1.
When the device firmware has polled this bit or has been interrupted by this signal, it must transfer data from the FIFO to
microcontroller memory. The number of bytes received is available in RXBYTECNT field. Bank 1 FIFO values are read
through UDP_ FDRx register. Once a transfer is done, the device firmware must release Bank 1 to the USB device by
clearing RX_DATA_BK1.
After setting or clearing this bit, a wait time of 3 UDPCK clock cycles and 3 peripheral clock cycles is required before
accessing DPR.
Read-write
000 Control
001 Isochronous OUT
101 Isochronous IN
010 Bulk OUT
110 Bulk IN
011 Interrupt OUT
111 Interrupt IN
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
FIFO_DATA
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – TXVDIS
7 6 5 4 3 2 1 0
– – – – – – – –
WARNING: The UDP peripheral clock in the Power Management Controller (PMC) must be enabled before any read/write
operations to the UDP registers including the UDP_TXCV register.
NOTE: If the USB pullup is not connected on DP, the user should not write in any UDP register other than the UDP_ TXVC
register. This is because if DP and DM are floating at 0, or pulled down, then SE0 is received by the device with the conse-
quence of a USB Reset.
36.1 Overview
The ADC is based on a Successive Approximation Register (SAR) 10-bit Analog-to-Digital Con-
verter (ADC). It also integrates an 8-to-1 analog multiplexer, making possible the analog-to-
digital conversions of 8 analog lines. The conversions extend from 0V to ADVREF.
The ADC supports an 8-bit or 10-bit resolution mode, and conversion results are reported in a
common register for all channels, as well as in a channel-dedicated register. Software trigger,
external trigger on rising edge of the ADTRG pin or internal triggers from Timer Counter out-
put(s) are configurable.
The ADC also integrates a Sleep Mode and a conversion sequencer and connects with a PDC
channel. These features reduce both power consumption and processor intervention.
Finally, the user can configure ADC timings, such as Startup Time and Sample & Hold Time.
ADC
Trigger
ADTRG Selection ADC Interrupt
Control AIC
Logic
VDDANA
ADVREF
ASB
AD- PDC
Dedicated
AD-
Analog
Inputs User
Interface Peripheral Bridge
AD- Successive
Approximation
Register
Analog-to-Digital
AD-
Analog Inputs PIO Converter
APB
Multiplexed AD-
with I/O lines
AD-
GND
527
6175H–ATARM–03-Dec-07
36.3 Signal Description
Table 36-1. ADC Pin Description
Pin Name Description
VDDANA Analog power supply
ADVREF Reference voltage
AD0 - AD7 Analog input channels
ADTRG External trigger
529
6175H–ATARM–03-Dec-07
36.5.4 Conversion Results
When a conversion is completed, the resulting 10-bit digital value is stored in the Channel Data
Register (ADC_CDR) of the current channel and in the ADC Last Converted Data Register
(ADC_LCDR).
The channel EOC bit in the Status Register (ADC_SR) is set and the DRDY is set. In the case of
a connected PDC channel, DRDY rising triggers a data transfer request. In any case, either
EOC and DRDY can trigger an interrupt.
Reading one of the ADC_CDR registers clears the corresponding EOC bit. Reading ADC_LCDR
clears the DRDY bit and the EOC bit corresponding to the last converted channel.
CHx
(ADC_CHSR)
EOCx
(ADC_SR)
DRDY
(ADC_SR)
If the ADC_CDR is not read before further incoming data is converted, the corresponding Over-
run Error (OVRE) flag is set in the Status Register (ADC_SR).
In the same way, new data converted when DRDY is high sets the bit GOVRE (General Overrun
Error) in ADC_SR.
The OVRE and GOVRE flags are automatically cleared when ADC_SR is read.
Read ADC_SR
ADTRG
CH0
(ADC_CHSR)
CH1
(ADC_CHSR)
EOC0 Conversion
(ADC_SR) Conversion Read ADC_CDR0
GOVRE
(ADC_SR)
DRDY
(ADC_SR)
OVRE0
(ADC_SR)
531
6175H–ATARM–03-Dec-07
36.5.5 Conversion Triggers
Conversions of the active analog channels are started with a software or a hardware trigger. The
software trigger is provided by writing the Control Register (ADC_CR) with the bit START at 1.
The hardware trigger can be one of the TIOA outputs of the Timer Counter channels, or the
external trigger input of the ADC (ADTRG). The hardware trigger is selected with the field TRG-
SEL in the Mode Register (ADC_MR). The selected hardware trigger is enabled with the bit
TRGEN in the Mode Register (ADC_MR).
If a hardware trigger is selected, the start of a conversion is detected at each rising edge of the
selected signal. If one of the TIOA outputs is selected, the corresponding Timer Counter channel
must be programmed in Waveform Mode.
Only one start command is necessary to initiate a conversion sequence on all the channels. The
ADC hardware logic automatically performs the conversions on the active channels, then waits
for a new request. The Channel Enable (ADC_CHER) and Channel Disable (ADC_CHDR) Reg-
isters enable the analog channels to be enabled or disabled independently.
If the ADC is used with a PDC, only the transfers of converted data from enabled channels are
performed and the resulting data buffers should be interpreted accordingly.
Warning: Enabling hardware triggers does not disable the software trigger functionality. Thus, if
a hardware trigger is selected, the start of a conversion can be initiated either by the hardware or
the software trigger.
533
6175H–ATARM–03-Dec-07
36.6 Analog-to-Digital Converter (ADC) User Interface
Table 36-2. Register Mapping
Offset Register Name Access Reset
0x00 Control Register ADC_CR Write-only –
0x04 Mode Register ADC_MR Read-write 0x00000000
0x08 Reserved – – –
0x0C Reserved – – –
0x10 Channel Enable Register ADC_CHER Write-only –
0x14 Channel Disable Register ADC_CHDR Write-only –
0x18 Channel Status Register ADC_CHSR Read-only 0x00000000
0x1C Status Register ADC_SR Read-only 0x000C0000
0x20 Last Converted Data Register ADC_LCDR Read-only 0x00000000
0x24 Interrupt Enable Register ADC_IER Write-only –
0x28 Interrupt Disable Register ADC_IDR Write-only –
0x2C Interrupt Mask Register ADC_IMR Read-only 0x00000000
0x30 Channel Data Register 0 ADC_CDR0 Read-only 0x00000000
0x34 Channel Data Register 1 ADC_CDR1 Read-only 0x00000000
... ... ... ... ...
0x4C Channel Data Register 7 ADC_CDR7 Read-only 0x00000000
0x50 - 0xFC Reserved – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – START SWRST
535
6175H–ATARM–03-Dec-07
36.6.2 ADC Mode Register
Register Name: ADC_MR
Access Type: Read-write
31 30 29 28 27 26 25 24
– – – – SHTIM
23 22 21 20 19 18 17 16
– STARTUP
15 14 13 12 11 10 9 8
PRESCAL
7 6 5 4 3 2 1 0
– – SLEEP LOWRES TRGSEL TRGEN
• LOWRES: Resolution
537
6175H–ATARM–03-Dec-07
36.6.3 ADC Channel Enable Register
Register Name: ADC_CHER
Access Type: Write-only
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
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
539
6175H–ATARM–03-Dec-07
36.6.6 ADC Status Register
Register Name: ADC_SR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – RXBUFF ENDRX GOVRE DRDY
15 14 13 12 11 10 9 8
OVRE7 OVRE6 OVRE5 OVRE4 OVRE3 OVRE2 OVRE1 OVRE0
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – LDATA
7 6 5 4 3 2 1 0
LDATA
23 22 21 20 19 18 17 16
– – – – RXBUFF ENDRX GOVRE DRDY
15 14 13 12 11 10 9 8
OVRE7 OVRE6 OVRE5 OVRE4 OVRE3 OVRE2 OVRE1 OVRE0
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
541
6175H–ATARM–03-Dec-07
36.6.9 ADC Interrupt Disable Register
Register Name: ADC_IDR
Access Type: Write-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – RXBUFF ENDRX GOVRE DRDY
15 14 13 12 11 10 9 8
OVRE7 OVRE6 OVRE5 OVRE4 OVRE3 OVRE2 OVRE1 OVRE0
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
23 22 21 20 19 18 17 16
– – – – RXBUFF ENDRX GOVRE DRDY
15 14 13 12 11 10 9 8
OVRE7 OVRE6 OVRE5 OVRE4 OVRE3 OVRE2 OVRE1 OVRE0
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
543
6175H–ATARM–03-Dec-07
36.6.11 ADC Channel Data Register
Register Name: ADC_CDRx
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – DATA
7 6 5 4 3 2 1 0
DATA
545
6175H–ATARM–03-Dec-07
37.2 DC Characteristics
The following characteristics are applicable to the operating temperature range: TA = -40°C to 85°C unless otherwise
specified.
Note that even during startup, VVDDFLASH must always be superior or equal to VVDDCORE.
547
6175H–ATARM–03-Dec-07
Table 37-5. DC Flash Characteristics AT91SAM7S64/321/32
Symbol Parameter Conditions Min Max Units
TPU Power-up delay 45 µS
@25°C
onto VDDCORE = 1.8V 4
µA
onto VDDFLASH = 3.3V 7
ISB Standby current
@85°C
onto VDDCORE = 1.8V 10
µA
onto VDDFLASH = 3.3V 30
Random Read @ 30MHz
onto VDDCORE = 1.8V 3.0
mA
onto VDDFLASH = 3.3V 0.4
ICC Active current
Write
onto VDDCORE = 1.8V 400 µA
onto VDDFLASH = 3.3V 2.2 mA
VDDIO
VDDIN
3.3V
Voltage
AMP1 Regulator
VDDOUT
1.8V
AMP2
VDDCORE
VDDPLL
549
6175H–ATARM–03-Dec-07
These figures represent the power consumption typically measured on the power supplies..
551
6175H–ATARM–03-Dec-07
Table 37-7. Power Consumption for Different Modes
Mode Conditions Consumption Unit
Voltage regulator is on.
Brown Out Detector is activated.
Flash is read.
PLL is activated.
Active, running out of Flash, 50 MHz ARM Core clock is 50 MHz.
(AT91SAM7S64/321/32/161/16) Analog-to-Digital Converter activated.
All peripheral clocks activated.
USB transceiver enabled.
onto AMP1 28.3
mA
onto AMP2 28.1
Voltage regulator is on.
Brown Out Detector is activated.
Flash is read.
PLL is activated.
Active, running out of Flash, 50 MHz ARM Core clock is 50 MHz.
(AT91SAM7S512/256/128) Analog-to-Digital Converter activated.
All peripheral clocks activated.
USB transceiver enabled.
onto AMP1 30.8
mA
onto AMP2 30.6
Voltage regulator is on.
Brown Out Detector is activated.
Flash is read.
PLL is activated.
Active, running out of Flash, 55 MHz ARM Core clock is 55 MHz.
(AT91SAM7S64/321/32/161/16) Analog-to-Digital Converter activated.
All peripheral clocks activated.
USB transceiver enabled.
onto AMP1 31.7 mA
onto AMP2 31.5
Voltage regulator is on.
Brown Out Detector is activated.
Flash is read.
PLL is activated.
Active, running out of Flash, 55 MHz ARM Core clock is 55 MHz.
(AT91SAM7S512/256/128) Analog-to-Digital Converter activated.
All peripheral clocks activated.
USB transceiver enabled.
onto AMP1 33.3
mA
onto AMP2 33.1
553
6175H–ATARM–03-Dec-07
37.3.2 Peripheral Power Consumption in Active Mode
555
6175H–ATARM–03-Dec-07
37.4.2 Main Oscillator Characteristics
XIN XOUT
CLEXT CLEXT
VXIN_IH
VXIN_IL
tCPXIN
tCPXIN
557
6175H–ATARM–03-Dec-07
37.5 PLL Characteristics
Table 37-13. Phase Lock Loop Characteristics
Symbol Parameter Conditions Min Typ Max Unit
559
6175H–ATARM–03-Dec-07
37.8 USB Transceiver Characteristics
VCRS 90%
10% 10%
Differential tR tF
Data Lines
(a)
REXT=27 ohms
Fosc = 6MHz/750kHz
Cload
Buffer
(b)
561
6175H–ATARM–03-Dec-07
37.9 ADC Characteristics
Table 37-18. Channel Conversion Time and ADC Clock
Parameter Conditions Min Typ Max Units
ADC Clock Frequency 10-bit resolution mode 5 MHz
ADC Clock Frequency 8-bit resolution mode 8 MHz
Startup Time Return from Idle Mode 20 µs
Track and Hold Acquisition Time 600 ns
Conversion Time ADC Clock = 5 MHz 2 µs
Conversion Time ADC Clock = 8 MHz 1.25 µs
(1)
Throughput Rate ADC Clock = 5 MHz 384 kSPS
Throughput Rate ADC Clock = 8 MHz 533(2) kSPS
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.
563
6175H–ATARM–03-Dec-07
37.10 AC Characteristics
Figure 37-4. SPI Master mode with (CPOL = NCPHA = 0) or (CPOL= NCPHA= 1)
SPCK
SPI0 SPI1
MISO
SPI2
MOSI
Figure 37-5. SPI Master mode with (CPOL=0 and NCPHA=1) or (CPOL=1 and NCPHA=0)
SPCK
SPI3 SPI4
MISO
SPI5
MOSI
Figure 37-6. SPI Slave mode with (CPOL=0 and NCPHA=1) or (CPOL=1 and NCPHA=0)
SPCK
SPI6
MISO
SPI7 SPI8
MOSI
Figure 37-7. SPI Slave mode with (CPOL = NCPHA = 0) or (CPOL= NCPHA= 1)
SPCK
SPI9
MISO
SPI10 SPI11
MOSI
Notes: 1. 3.3V domain: VVDDIO from 3.0V to 3.6V, maximum external capacitor = 40 pF.
2. 1.8V domain: VVDDIO from 1.65V to 1.95V, maximum external capacitor = 20 pF.
3. tCPMCK: Master Clock period in ns.
Note that in SPI master mode the ATSAM7S512/256/128/64/321/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 37-4 and Figure 37-5.
565
6175H–ATARM–03-Dec-07
37.10.2 Embedded Flash Characteristics
The maximum operating frequency is given in Table 37-23 but is limited by the Embedded Flash access time when the pro-
cessor is fetching code out of it. Table 37-23 gives the device maximum operating frequency 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.
ICE2
TCK
ICE0 ICE1
TMS/TDI
ICE3 ICE4
TDO
ICE5
ICE6
567
6175H–ATARM–03-Dec-07
37.10.3.2 JTAG Interface Signals
.
JTAG JTAG1
0
TMS/TDI
JTAG3 JTAG4
TDO
JTAG5
JTAG6
Device
Inputs
JTAG7 JTAG8
Device
Outputs
JTAG9
JTAG10
569
6175H–ATARM–03-Dec-07
Table 38-1. 48-lead LQFP Package Dimensions (in mm)
Millimeter Inch
Symbol
Min Nom Max Min Nom Max
A – – 1.60 – – 0.063
A1 0.05 – 0.15 0.002 – 0.006
A2 1.35 1.40 1.45 0.053 0.055 0.057
D 9.00 BSC 0.354 BSC
D1 7.00 BSC 0.276 BSC
E 9.00 BSC 0.354 BSC
E1 7.00 BSC 0.276 BSC
R2 0.08 – 0.20 0.003 – 0.008
R1 0.08 – – 0.003 – –
q 0° 3.5° 7° 0° 3.5° 7°
θ1 0° – – 0° – –
θ2 11° 12° 13° 11° 12° 13°
θ3 11° 12° 13° 11° 12° 13°
c 0.09 – 0.20 0.004 – 0.008
L 0.45 0.60 0.75 0.018 0.024 0.030
L1 1.00 REF 0.039 REF
S 0.20 – – 0.008 – –
b 0.17 0.20 0.27 0.007 0.008 0.011
e 0.50 BSC. 0.020 BSC.
D2 5.50 0.217
E2 5.50 0.217
Tolerances of Form and Position
aaa 0.20 0.008
bbb 0.20 0.008
ccc 0.08 0.003
ddd 0.08 0.003
571
6175H–ATARM–03-Dec-07
38.3 QFN Packages
573
6175H–ATARM–03-Dec-07
Figure 38-3. 64-pad QFN Package Drawing
ll dimensions are in mm
ference : JEDEC Drawing MO-220
575
6175H–ATARM–03-Dec-07
38.4 Soldering Profile
Table 38-11 gives the recommended soldering profile from J-STD-020C.
Note: The package is certified to be backward compatible with Pb/Sn soldering profile.
Industrial
AT91SAM7S161-AU LQFP 64 Green
(-40°C to 85°C)
AT91SAM7S32-AU-001 LQFP 48 Industrial
Green
AT91SAM7S32-MU QFN 48 (-40°C to 85°C)
577
6175H–ATARM–03-Dec-07
578 AT91SAM7S Series Preliminary
6175H–ATARM–03-Dec-07
AT91SAM7S Series Preliminary
40. Errata
40.1 Marking
All devices are marked with the Atmel logo and the ordering code.
Additional marking may be in one of the following formats:
YYWW V
XXXXXXXXX ARM
where
• “YY”: manufactory year
• “WW”: manufactory week
• “V”: revision
• “XXXXXXXXX”: lot number
ZZZZZZ YYWW
XXXXXXXXX ARM
where
• “ZZZZZZ”: manufacturing number
• “YY”: manufactory year
• “WW”: manufactory week
• “XXXXXXXXX”: lot number
579
6175H–ATARM–03-Dec-07
40.2 Errata Organisation by Product and Revision
“AT91SAM7S512 Errata - Revision A Parts” on page 581
“AT91SAM7S256 Errata - Manufacturing Number 58818C” on page 589
“AT91SAM7S256 Errata - Revision A Parts” on page 600
“AT91SAM7S256 Errata - Revision B Parts” on page 610
“AT91SAM7S128 Errata - Manufacturing Number 58818C” on page 619
“AT91SAM7S128 Errata - Revision A Parts” on page 630
“AT91SAM7S128 Errata - Revision B Parts” on page 640
“AT91SAM7S64 Errata - Manufacturing Number 58814G” on page 649
“AT91SAM7S64 Errata - Revision A Parts” on page 659
“AT91SAM7S321 Errata - Revision A Parts” on page 668
“AT91SAM7S32 Errata - Manufacturing Number 58814G” on page 676
“AT91SAM7S32 Errata - Revision A Parts” on page 686
“AT91SAM7S32 Errata - Revision B Parts” on page 695
“AT91SAM7S161 Errata - Revision A Parts” on page 704
“AT91SAM7S16 Errata - Revision A Parts” on page 709
581
6175H–ATARM–03-Dec-07
• 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
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
583
6175H–ATARM–03-Dec-07
40.3.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.
Use the CS in PIO mode when PDC mode is required and CS has to be maintained between
transfers.
585
6175H–ATARM–03-Dec-07
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.
587
6175H–ATARM–03-Dec-07
None.
40.4.1 Chip ID
589
6175H–ATARM–03-Dec-07
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
None.
591
6175H–ATARM–03-Dec-07
40.4.5 Parallel Input/Output Controller (PIO)
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
40.4.6.1 PMC: Slow Clock Selected in PMC and a Transition Occurs on PA1
Under certain rare circumstances, when CSS = 00 in PMC_MCKR, and PA1 is set as an input
and a transition occurs on PA1, device malfunction might occur.
Problem Fix/Workaround
Do not transition PA1 as an input when CSS = 00 in PMC_MCKR.
1. Switching from:
– PLL Clock to Slow Clock or
– PLL Clock to Main Clock or
– Main Clock to PLL Clock or
– Main Clock to Slow Clock
And
2. Program code is being executed out of flash, or a transition is occurring on PA1, either
as an input or output.
Note: This issue does not occur when transitioning from slow clock to main clock or from slow clock to
PLL clock.
Problem Fix/Workaround
When changing CSS in the PMC_MCKR to switch from
– PLL Clock to Slow Clock or
– PLL Clock to Main Clock or
– Main Clock to PLL Clock or
– Main Clock to Slow Clock
Ensure that the processor is executing out of SRAM and ensure no transition occurs on PA1,
either as an input or output, starting from writing to the PMC_MCKR register until MCKRDY = 1.
593
6175H–ATARM–03-Dec-07
40.4.7.5 PWM: Behavior of CHIDx Status Bits in the PWM_SR Register
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.
595
6175H–ATARM–03-Dec-07
40.4.10 Synchronous Serial Controller (SSC)
None.
597
6175H–ATARM–03-Dec-07
40.4.12.3 USART: XOFF Character Bad Behavior
The XOFF character is sent only when the receive buffer is detected full. While the XOFF is
being sent, the remote transmitter is still transmitting. As only one Holding register is available in
the receiver, characters will be lost in reception. This makes the software handshaking function-
ality ineffective.
Problem Fix/Workaround
None.
40.4.14.1 WDT: The Watchdog Timer May Lock the Device in a Reset State
Under certain rare circumstances, if the Watchdog Timer is used with the Watchdog Reset
enabled (WDRSTEN set at 1), the Watchdog Timer may lock the device in a reset state when
the user restarts the watchdog (WDDRSTT). The only way to recover from this state is a power-
on reset. The issue depends on the values of WDD and WDV in the WDT_MR register.
Problem Fix/Workaround
Two workarounds are possible.
1. Either do not use the Watchdog Timer with the Watchdog Reset enabled (WDRSTEN
set at 1),
2. or set WDD to 0xFFF and in addition use only one of the following values for WDV:
0xFFF, 0xDFF, 0xBFF, 0x9FF, 0x7FF, 0x77F, 0x6FF, 0x67F, 0x5FF, 0x57F, 0x4FF,
0x47F, 0x3FF, 0x37F, 0x2FF, 0x27F, 0x1FF, 0x1BF, 0x17F, 0x13F, 0x0FF, 0x0DF, 0x0BF,
0x09F, 0x07F, 0x06F, 0x05F, 0x04F, 0x03F, 0x037, 0x02f, 0x027, 0x01F, 0x01B, 0x017,
0x013 and 0x00F.
599
6175H–ATARM–03-Dec-07
40.5 AT91SAM7S256 Errata - Revision A Parts
Refer to Section 40.1 “Marking” on page 579.
Important: Section 40.5.13.1 ”WDT: The Watchdog Timer May Lock the Device in a Reset State”
40.5.1 Chip ID
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
601
6175H–ATARM–03-Dec-07
None.
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
40.5.5.1 PMC: Slow Clock Selected in PMC and a Transition Occurs on PA1
Under certain rare circumstances, when CSS = 00 in PMC_MCKR, and PA1 is set as an input
and a transition occurs on PA1, device malfunction might occur.
Problem Fix/Workaround
Do not transition PA1 as an input when CSS = 00 in PMC_MCKR.
603
6175H–ATARM–03-Dec-07
40.5.6.2 PWM: Update when PWM_CPRDx = 0
When Channel Period Register equals 0, the period update is not operational.
Problem Fix/Workaround
Do not write 0 in the period register.
Problem Fix/Workaround
Do not use the combination CSAAT = 1 and SCBR = 1.
605
6175H–ATARM–03-Dec-07
40.5.8.7 SPI: Bad Serial Clock Generation on 2nd Chip Select
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) and 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.
607
6175H–ATARM–03-Dec-07
TXCOMP and NACK fields are set simultaneously and the NACK field is reset after the read of
the TWI_SR.
40.5.13.1 WDT: The Watchdog Timer May Lock the Device in a Reset State
Under certain rare circumstances, if the Watchdog Timer is used with the Watchdog Reset
enabled (WDRSTEN set at 1), the Watchdog Timer may lock the device in a reset state when
the user restarts the watchdog (WDDRSTT). The only way to recover from this state is a power-
on reset. The issue depends on the values of WDD and WDV in the WDT_MR register.
Problem Fix/Workaround
Two workarounds are possible.
1. Either do not use the Watchdog Timer with the Watchdog Reset enabled (WDRSTEN
set at 1),
2. or set WDD to 0xFFF and in addition use only one of the following values for WDV:
0xFFF, 0xDFF, 0xBFF, 0x9FF, 0x7FF, 0x77F, 0x6FF, 0x67F, 0x5FF, 0x57F, 0x4FF,
0x47F, 0x3FF, 0x37F, 0x2FF, 0x27F, 0x1FF, 0x1BF, 0x17F, 0x13F, 0x0FF, 0x0DF, 0x0BF,
0x09F, 0x07F, 0x06F, 0x05F, 0x04F, 0x03F, 0x037, 0x02f, 0x027, 0x01F, 0x01B, 0x017,
0x013 and 0x00F.
609
6175H–ATARM–03-Dec-07
40.6 AT91SAM7S256 Errata - Revision B Parts
Refer to Section 40.1 “Marking” on page 579.
Note: AT91SAM7S256 Revision B chip ID is 0x270D 0941.
611
6175H–ATARM–03-Dec-07
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, in order put ADC into sleep mode at the end of this conversion.
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
Problem Fix/Workaround
Check the Channel Counter Register before writing the update register.
613
6175H–ATARM–03-Dec-07
40.6.6.2 SPI: LASTXFER (Last Transfer) Behavior
In FIXED Mode, with CSAAT bit set, and in “PDC mode” the Chip Select can rise depending on
the data written in the SPI_TDR when the TX_EMPTY flag is set. If for example, the PDC writes
a “1” in the bit 24 (LASTXFER bit) of the SPI_TDR, the chip select will rise as soon as the
TXEMPTY flag is set.
Problem Fix/Workaround
Use the CS in PIO mode when PDC mode is required and CS has to be maintained between
transfers.
• 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) and 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.
615
6175H–ATARM–03-Dec-07
40.6.8 Two-wire Interface (TWI)
TXCOMP and NACK fields are set simultaneously and the NACK field is reset after the read of
the TWI_SR.
617
6175H–ATARM–03-Dec-07
40.6.10 Voltage Regulator
40.7.1 Chip ID
619
6175H–ATARM–03-Dec-07
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
None.
621
6175H–ATARM–03-Dec-07
40.7.5 Parallel Input/Output Controller (PIO)
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
40.7.6.1 PMC: Slow Clock Selected in PMC and a Transition Occurs on PA1
Under certain rare circumstances, when CSS = 00 in PMC_MCKR, and PA1 is set as an input
and a transition occurs on PA1, device malfunction might occur.
Problem Fix/Workaround
Do not transition PA1 as an input when CSS = 00 in PMC_MCKR.
1. Switching from:
– PLL Clock to Slow Clock or
– PLL Clock to Main Clock or
– Main Clock to PLL Clock or
– Main Clock to Slow Clock
And
2. Program code is being executed out of flash, or a transition is occurring on PA1, either
as an input or output.
Note: This issue does not occur when transitioning from slow clock to main clock or from slow clock to
PLL clock.
Problem Fix/Workaround
When changing CSS in the PMC_MCKR to switch from
– PLL Clock to Slow Clock or
– PLL Clock to Main Clock or
– Main Clock to PLL Clock or
– Main Clock to Slow Clock
Ensure that the processor is executing out of SRAM and ensure no transition occurs on PA1,
either as an input or output, starting from writing to the PMC_MCKR register until MCKRDY = 1.
623
6175H–ATARM–03-Dec-07
40.7.7.5 PWM: Behavior of CHIDx Status Bits in the PWM_SR Register
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.
625
6175H–ATARM–03-Dec-07
40.7.10 Synchronous Serial Controller (SSC)
Problem Fix/Workaround
None.
627
6175H–ATARM–03-Dec-07
Don't use the PDC in transmit mode and do not fill US_THR before TXEMPTY is set at 1.
40.7.14.1 WDT: The Watchdog Timer May Lock the Device in a Reset State
Under certain rare circumstances, if the Watchdog Timer is used with the Watchdog Reset
enabled (WDRSTEN set at 1), the Watchdog Timer may lock the device in a reset state when
the user restarts the watchdog (WDDRSTT). The only way to recover from this state is a power-
on reset. The issue depends on the values of WDD and WDV in the WDT_MR register.
Problem Fix/Workaround
629
6175H–ATARM–03-Dec-07
40.8 AT91SAM7S128 Errata - Revision A Parts
Refer to Section 40.1 “Marking” on page 579.
Important: Section 40.8.13.1 ”WDT: The Watchdog Timer May Lock the Device in a Reset State”
40.8.1 Chip ID
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
631
6175H–ATARM–03-Dec-07
None.
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
40.8.5.1 PMC: Slow Clock Selected in PMC and a Transition Occurs on PA1
Under certain rare circumstances, when CSS = 00 in PMC_MCKR, and PA1 is set as an input
and a transition occurs on PA1, device malfunction might occur.
Problem Fix/Workaround
Do not transition PA1 as an input when CSS = 00 in PMC_MCKR.
633
6175H–ATARM–03-Dec-07
40.8.6.2 PWM: Update when PWM_CPRDx = 0
When Channel Period Register equals 0, the period update is not operational.
Problem Fix/Workaround
Do not write 0 in the period register.
Note: idle = delay in loading the SPI_THR register by the oore or by the PDC.
Problem Fix/Workaround
Do not use the combination CSAAT = 1 and SCBR = 1.
635
6175H–ATARM–03-Dec-07
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) and 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.
637
6175H–ATARM–03-Dec-07
TXCOMP and NACK fields are set simultaneously and the NACK field is reset after the read of
the TWI_SR.
40.8.13.1 WDT: The Watchdog Timer May Lock the Device in a Reset State
Under certain rare circumstances, if the Watchdog Timer is used with the Watchdog Reset
enabled (WDRSTEN set at 1), the Watchdog Timer may lock the device in a reset state when
the user restarts the watchdog (WDDRSTT). The only way to recover from this state is a power-
on reset. The issue depends on the values of WDD and WDV in the WDT_MR register.
Problem Fix/Workaround
Two workarounds are possible.
1. Either do not use the Watchdog Timer with the Watchdog Reset enabled (WDRSTEN
set at 1),
2. or set WDD to 0xFFF and in addition use only one of the following values for WDV:
0xFFF, 0xDFF, 0xBFF, 0x9FF, 0x7FF, 0x77F, 0x6FF, 0x67F, 0x5FF, 0x57F, 0x4FF,
0x47F, 0x3FF, 0x37F, 0x2FF, 0x27F, 0x1FF, 0x1BF, 0x17F, 0x13F, 0x0FF, 0x0DF, 0x0BF,
0x09F, 0x07F, 0x06F, 0x05F, 0x04F, 0x03F, 0x037, 0x02f, 0x027, 0x01F, 0x01B, 0x017,
0x013 and 0x00F.
639
6175H–ATARM–03-Dec-07
40.9 AT91SAM7S128 Errata - Revision B Parts
Refer to Section 40.1 “Marking” on page 579.
Note: AT91SAM7S128 Revision B chip ID is: 0x270C 0741.
641
6175H–ATARM–03-Dec-07
40.9.2 Non Volatile Memory Bits (NVM Bits)
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
643
6175H–ATARM–03-Dec-07
40.9.6.2 SPI: LASTXFER (Last Transfer) behavior
In FIXED Mode, with CSAAT bit set, and in “PDC mode” the Chip Select can rise depending on
the data written in the SPI_TDR when the TX_EMPTY flag is set. If for example, the PDC writes
a “1” in the bit 24 (LASTXFER bit) of the SPI_TDR, the chip select will rise as soon as the
TXEMPTY flag is set.
Problem Fix/Workaround
Use the CS in PIO mode when PDC mode is required and CS has to be maintained between
transfers.
• 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) and 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.
645
6175H–ATARM–03-Dec-07
40.9.8 Two-wire Interface (TWI)
TXCOMP and NACK fields are set simultaneously and the NACK field is reset after the read of
the TWI_SR.
647
6175H–ATARM–03-Dec-07
40.9.10 Voltage Regulator
649
6175H–ATARM–03-Dec-07
• 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
40.10.2 JTAG
651
6175H–ATARM–03-Dec-07
None.
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
Problem Fix/Workaround
Do not write 0 in the period register.
653
6175H–ATARM–03-Dec-07
40.10.8.2 SPI: Bad Behavior when CSAAT = 1 and SCBR = 1
If the SPI is programmed (with or without using the PDC) with CSAAT = 1, SCBR(baudrate) = 1
and two transfers are performed consecutively on the same slave with an idle state between
them, the second data can be sent twice.
Note: idle = delay in loading the SPI_THR register by the oore or by the PDC.
Problem Fix/Workaround
Do not use the combination CSAAT = 1 and SCBR = 1.
Read first the received data, then perform the software reset.
655
6175H–ATARM–03-Dec-07
40.10.9.2 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 start of edge (rising or falling) of synchro has a Start Delay equal to zero.
Problem Fix/Workaround
None.
None.
657
6175H–ATARM–03-Dec-07
40.10.11.4 USART: XOFF Character Bad Behavior
The XOFF character is sent only when the receive buffer is detected full. While the XOFF is
being sent, the remote transmitter is still transmitting. As only one Holding register is available in
the receiver, characters will be lost in reception. This makes the software handshaking function-
ality ineffective.
Problem Fix/Workaround
None.
659
6175H–ATARM–03-Dec-07
• 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
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
661
6175H–ATARM–03-Dec-07
40.11.4 Pulse Width Modulation Controller (PWM)
663
6175H–ATARM–03-Dec-07
40.11.6.6 SPI: Baudrate Set to 1
When Baudrate is set at 1 (i.e. when serial clock frequency equals the system clock frequency)
and when the BITS field of the SPI_CSR register (number of bits to be transmitted) equals an
ODD value (in this case 9,11,13 or 15), an additional pulse will be generated on output SPCK.
Everything is OK if the BITS field equals 8,10,12,14 or 16 and Baudrate = 1.
Problem Fix/Workaround
None.
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
6175H–ATARM–03-Dec-07
40.11.8 Two-wire Interface (TWI)
667
6175H–ATARM–03-Dec-07
40.12 AT91SAM7S321 Errata - Revision A Parts
Refer to Section 40.1 “Marking” on page 579.
Note: AT91SAM7S321 Revision A chip ID is: 0x2708 0342.
669
6175H–ATARM–03-Dec-07
40.12.2 Parallel Input/Output Controller (PIO)
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
671
6175H–ATARM–03-Dec-07
a “1” in the bit 24 (LASTXFER bit) of the SPI_TDR, the chip select will rise as soon as the
TXEMPTY flag is set.
Problem Fix/Workaround
Use the CS in PIO mode when PDC mode is required and CS has to be maintained between
transfers.
• 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.
673
6175H–ATARM–03-Dec-07
40.12.7 Two-wire Interface (TWI)
TXCOMP and NACK fields are set simultaneously and the NACK field is reset after the read of
the TWI_SR.
675
6175H–ATARM–03-Dec-07
40.13 AT91SAM7S32 Errata - Manufacturing Number 58814G
Refer to Section 40.1 “Marking” on page 579.
677
6175H–ATARM–03-Dec-07
40.13.2 JTAG
None.
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
679
6175H–ATARM–03-Dec-07
Problem Fix/Workaround
Do not write 0 in the period register.
681
6175H–ATARM–03-Dec-07
40.13.7.9 SPI: Software Reset and SPIEN Bit
The SPI Command “software reset” does not reset the SPIEN config bit. Therefore rewriting an
SPI enable command does not set TX_READY, TX_EMPTY flags.
Problem Fix/Workaround
Send SPI disable command after a software reset.
683
6175H–ATARM–03-Dec-07
The user must wait for the end of transfer before disabling the TWI. In addition, the interrupts
must be disabled before disabling the TWI.
685
6175H–ATARM–03-Dec-07
40.14 AT91SAM7S32 Errata - Revision A Parts
Refer to Section 40.1 “Marking” on page 579.
687
6175H–ATARM–03-Dec-07
40.14.2 Non Volatile Memory Bits (NVM Bits)
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
689
6175H–ATARM–03-Dec-07
40.14.6 Serial Peripheral Interface (SPI)
691
6175H–ATARM–03-Dec-07
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.
693
6175H–ATARM–03-Dec-07
40.14.9.2 USART: CTS in Hardware Handshaking
When Hardware Handshaking is used and if CTS goes low near the end of the starting bit, a
character can be lost.
Problem Fix/Workaround
CTS must not go low 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.
695
6175H–ATARM–03-Dec-07
• 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
Vpull-up
VPull-up Min VPull-up Max
VDDIO - 0.65 V VDDIO - 0.45 V
This condition causes a leakage through VDDIO. This leakage is 45 µA per pad in worst case at
3.3 V and 25 µA at 1.8V.
I Leakage
Parameter Typ Max
I Leakage at 3,3V 2.5 µA 45 µA
I Leakage at 1.8V 1 µA 25 µA
Problem Fix/Workaround
It is recommended to use an external pull-up if needed.
697
6175H–ATARM–03-Dec-07
40.15.4.2 PWM: Update when PWM_CPRDx = 0
When Channel Period Register equals 0, the period update is not operational.
Problem Fix/Workaround
Do not write 0 in the period register.
699
6175H–ATARM–03-Dec-07
Read first the received data, then perform the software reset.
701
6175H–ATARM–03-Dec-07
40.15.8.3 TWI: Disabling Does not Operate Correctly
Any transfer in progress is immediately frozen if the Control Register (TWI_CR) is written with
the bit MSDIS at 1. Furthermore, the status bits TXCOMP and TXRDY in the Status Register
(TWI_SR) are not reset.
Problem Fix/Workaround
The user must wait for the end of transfer before disabling the TWI. In addition, the interrupts
must be disabled before disabling the TWI.
703
6175H–ATARM–03-Dec-07
40.16 AT91SAM7S161 Errata - Revision A Parts
Refer to Section 40.1 “Marking” on page 579.
705
6175H–ATARM–03-Dec-07
40.16.2 Pulse Width Modulation Controller (PWM)
707
6175H–ATARM–03-Dec-07
40.16.6 Universal Synchronous Asynchronous Receiver Transmitter (USART)
709
6175H–ATARM–03-Dec-07
• 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
711
6175H–ATARM–03-Dec-07
40.17.4 Serial Peripheral Interface (SPI)
713
6175H–ATARM–03-Dec-07
714 AT91SAM7S Series Preliminary
6175H–ATARM–03-Dec-07
AT91SAM7S Series Preliminary
Revision History
Change
Version Request
6175H Comments Ref.
Overview:
“Features” on page 1 (and all of datasheet) Added AT91SAM7S16/161 to product family.
rfo
See: Table 1-1, “Configuration Summary,” on page 3
Section 8.6 “AT91SAM7S161/16” on page 19.
Section 9.5 ”Debug Unit” Chip ID updated. 4325
Section 6. ”I/O Lines Considerations”, JTAG Port Pin, Test Pin, Erase Pin, updated. 5063
ADC: Section 36.6.2 ”ADC Mode Register”, STARTUP and PRESCAL bitfields updated (width expanded).
AIC: Section 24.8.15 ”AIC Spurious Interrupt Vector Register”, bitfield typo corrected 4749
Debug and Test:
Table 12-2, “AT91SAM7S Series Debug Unit Chip ID,” on page 51, updated. 4325/rfo
Table 12.5.5, “ID Code Register,” on page 56, updated.
EFC: Section 20.3.3 ”MC Flash Status Register” GPNVM2 removed from bit field 10. 4464
FFPI:
Table 21-6, Table 21-7 plus Table 21-8, Table plus Table 21-17, Table 21-18 and Table 21-20 updated 4410
Global update to terms listed below: 3933
Fuse → GPNVM
SFB →SGPB
CFB →CGPB
GFB → GGPB
Section 21.2.5.6 on page 153 &Section 21.3.4.6 on page 161, security bit restraint on access to FFPI explained 4744
PIO:
Section 15.4.5 ”Synchronous Data Output”, typo fixed on PIO_OWSR 3289
PIO User Interface, Table 15-2, “Register Mapping” updates to footnotes, PIO_PSR, PIO_ODSR, PIO_PDSR 3974
PMC: Figure 25-2 ”Typical Crystal Connection” updated 3861
SPI: Section 28.6.4 ”SPI Slave Mode”, Corrected information on OVRES (SPI_SR) and data read in SPI_RDR. 3943
SSC: “SSC Receive Clock Mode Register” on page 416, typo corrected in STTDLY bit field. 4478
TC: Section 33.6 ”Timer Counter (TC) User Interface”, register mapping consolidated in Table 33-4 on page
451 and register offsets indexed. Section 33.6.3 on page 454 to Section 33.6.13 on page 468, register names
4583
updated with indexed offset.
Section 33.6.4 ”TC Channel Mode Register: Capture Mode”, bit field 15 and WAVE bit field description updated.
TWI:
Section 29. ”Two-wire Interface (TWI) AT91SAM7S512/256/128/64/321/32”, section has been updated.
4247
Important changes to this datasheet include a clarification of Atmel TWI compatibility with I2C Standard.
Section 30. ”Two Wire Interface (TWI) AT91SAM7S161/16”, section added specific to the TWI implementation
rfo
on the AT91SAM7S16/161 devices.
PWM:
Section 34.6 ”Pulse Width Modulation Controller (PWM) User Interface”, in the Offset column in Table 34-2, 4486
“Register Mapping”, the PWM channel-dependent registers are indexed. See alos, PWM Channel registers
from: Section 34.6.10 on page 486 to Section 34.6.13 on page 488.
715
6175H–ATARM–03-Dec-07
Change
Version Request
6175H Comments Ref.
UDP:
Table 35-2, “USB Communication Flow”, Supported Enpoint column updated 3476
In the USB_CSR register, the control endpoints are not effected by the fit field, “EPEDS: Endpoint Enable 4063
Disable” on page 523,
Updated: write1 =....in “RX_DATA_BK0: Receive Data Bank 0” bit field of USB_CSR register.
4099
Updated: write1 =....in “TXPKTRDY: Transmit Packet Ready” bit field of USB_CSR register.
Section 35.6.10 ”UDP Endpoint Control and Status Register” update to code and added instructions regarding
4462
USB clock and system clock cycle, and updated “note” appearing under the code. “wait 3 USB clock cycles and
3 system clock cycles before accessing DPR from RX_DATAx and TXPKTRDY bit 4487
fields, ditto for RX_DATAx and TXPKTRDY bit field descriptions.”
Section 35.2 ”Block Diagram”, in the text below the block diagram, MCK specified as clock used by Master 4508
Clock domain, UDPCK specified as 48 MHz clock used by 12 MHz domain, in peripheral clock requirements.
Section 35.6 ”USB Device Port (UDP) User Interface”, The register mapping table has been updated. 4802
Section 35.6.6 ”UDP Interrupt Mask Register”, bit field 12 has been defined as BIT12 and cannot be masked.
USART:
“USCLKS: Clock Selection” on page 382, bit field in US_MR register, DIV=8 in “Selected Clock” column 3763
Section 31.5.1 ”I/O Lines” 2nd and 3rd paragraphs updated. 3895
“TXEMPTY: TXEMPTY Interrupt Enable” on page 385, no characters when at 1, updated bit field in US_CSR 3851/4285
Section 31.6.2 ”Receiver and Transmitter Control”, In 4th paragraph, “ replaced 2nd sentence: The software 4367
resets clear the...”
Section 31.6.5 ”IrDA Mode”, updated with instruction to receive IrDA signals. 4912
Section 31.2 ”Block Diagram”, signal directions from pads to PIO updated in the block diagrams. 4905
Section 31.6.3.1 ”Transmitter Operations”, last (4th) paragraph updated. rfo
Electrical/Mechanical Characteristics,
Table 37-10, “Main Oscillator Characteristics”, added schematic in footnote to CL and CLEXT symbols. 3867
Table 37-12, “XIN Clock Electrical Characteristics”, updated 3965
Figure 37-2 ”XIN Clock Timing” added below table 36-12
Section 37.2 ”DC Characteristics”and Section 38. ”Mechanical Characteristics”, removed reference to TJ. 4656
ADC Characteristics: Table 37-21, “Transfer Characteristics” INL and DN updated, linked reference to Data 4006
Converter Terminology added below table.
Table 38-5, “LQFP and QFN Package Characteristics” JESD97 Classification updated to be e3. 4969
Table 37-7, “Power Consumption for Different Modes”, updated and expanded ARM core clock information.
Section 37.6 ”Master Clock Characteristics”, moved from former location. rfo
Section 37.7 ”I/O Characteristics”, moved from former location.
Section 40. ”Errata”, added the following:
Section 40.2 ”Errata Organisation by Product and Revision” provides list of errata with links. rfo
Section 40.6 ”AT91SAM7S256 Errata - Revision B Parts” 4325
Section 40.9 ”AT91SAM7S128 Errata - Revision B Parts”
Section 40.11 ”AT91SAM7S64 Errata - Revision A Parts” 4772
Section 40.14 ”AT91SAM7S32 Errata - Revision A Parts”
Section 40.15 ”AT91SAM7S32 Errata - Revision B Parts”
AT91SAM7S16/161:
Section 40.16 ”AT91SAM7S161 Errata - Revision A Parts” rfo
Section 40.17 ”AT91SAM7S16 Errata - Revision A Parts”
Change
Version Request
6175H Comments Ref.
All AT91SAM7S:
“Analog-to-Digital Converter (ADC)”, errata applies to all AT91SAM7S products. 4752
“USART: DCD is active High instead of Low”, errata applies to all AT91SAM7S products.
“SPI: Bad Serial Clock Generation on 2nd Chip Select”, errata applies to all AT91SAM7S products.
“SPI: Bad Behavior when CSAAT = 1 and SCBR = 1”, errata applies to all AT91SAM7S products. rfo
AT91SAM7S256 Mfg # 58818C, AT91SAM7S256 Parts.A, AT91SAM7S128 Mfg # 58818C,
AT91SAM7S128 Parts A,
added the following:
Section 40.4.14.2 ”WDT: The Watchdog Timer Status Register and Interrupt” 3811
Section 40.5.13.2 ”WDT: The Watchdog Timer Status Register and Interrupt”
Section 40.7.14.2 ”WDT: The Watchdog Timer Status Register and Interrupt”
Section 40.8.13.2 ”WDT: The Watchdog Timer Status Register and Interrupt”
AT91SAM7S512 Section 40.3.8.1 ”USART: CTS in Hardware Handshaking” updated 3954
AT91SAM7S512/256/128, added the following: (and in newly added “B Parts”)
Section 40.3.8.4 ”USART: RXBRK Flag Error in Asynchronous Mode”
Section 40.4.12.4 ”USART: RXBRK Flag Error in Asynchronous Mode” 4646
Section 40.7.12.4 ”USART: RXBRK Flag Error in Asynchronous Mode”
Section 40.8.11.4 ”USART: RXBRK Flag Error in Asynchronous Mode”
Change
Version Request
6175G Comments Ref.
Added note to “Description” on page 3 3442
TC: added Figure 32-2 ”Clock Chaining Selection” page 393 3342
SAM-BA Boot: Section 22.5.3 ”USB Device Port”reference to INF example and lit°6123 removed. (Doc
3647
no longer available on web.)
UDP: Table 35-2, “USB Communication Flow”, Isochronous supported endpoint size is 64. 3475
Errata: items added to the Errata Sections listed below.
Section 40.4 ”AT91SAM7S256 Errata - Manufacturing Number 58818C”
Section 40.5 ”AT91SAM7S256 Errata - Revision A Parts”
Section 40.7 ”AT91SAM7S128 Errata - Manufacturing Number 58818C”
Section 40.8 ”AT91SAM7S128 Errata - Revision A Parts” 3652
Watchdog Timer: ”The Watchdog Timer May Lock the Device in a Reset State”
Real-time Timer: “RTT_VR May be Corrupted”
Powe Management Controller: “Slow Clock Selected in PMC and a Transition Occurs on PA1” and
“Programming CSS in PMC_MCKR Register”
717
6175H–ATARM–03-Dec-07
Change
Version Request
6175F Comments Ref.
“Features” on page 1 (global) QFN packages changed to 64- and 48-pad QFN
Manchester Encoder/Decoder removed from USART.
“Features” on page 1, Table 1-1, “Configuration Summary,” on page 3, Section 4. ”Package and
Pinout”Section 39. ”AT91SAM7S Ordering Information”and global, AT91SAM7S512 added to product
family. #2748
Section 4.1 ”64-lead LQFP and 64-pad QFN Package Outlines” and Section 4.3 ”48-lead LQFP and 48-
pad QFN Package Outlines”added (replace Mechanical Overview).
Figure 8-1 on page 20 Peripheral and System Controller Memory Mapping has been condensed.
Section 20. ”Embedded Flash Controller (EFC)” EFC0 and EFC1 on AT91SAM7S512 explained.
Section 10.1 ”User Interface”User Peripherals are mapped between 0xF000 0000 and 0xFFFF EFFF.
rfo review
Table 10-1 and Table 10-2 SYSIRQ changed to SYSC in “Peripheral Identifiers”
ADC Block diagram Figure 35-1 on page 479 - dedicated and I/O analog inputs differentiated #3052
”ADC Timings” page 485 WARNING ”...See the section ADC Characteristics....” typo fixed. #2830
Section 21. ”Fast Flash Programming Interface (FFPI)”, AT91SAM7S512 instructions added to Section #2284
21.2.5.6, and Section 21.2.5.7 on page 155, Section 21.3.4.6 and Section 21.3.4.7 on page 162.
Table 21-1 on page 147 PMD and PGMNVALID bus size for AT91SAM7S32 is [7:0]. #2748
AIC, Section 24.7.3.1 ”Priority Controller” SRCTYPTE field is in AIC_SMR register, not AIC_SVR #2512
“Advanced Interrupt Controller (AIC) User Interface” , Table 24-2 on page 198 note 2 ref to PID bit fields #2548
AT91SAM7 Boot Program Section 22.5 ”SAM-BA Boot” SAM-BA boot principle changed Section 22.2
#3050
”Flow Diagram”replaced Figure 22-1 and Figure 22-2 on page 165
DBGU: ”ARCH: Architecture Identifier” page 259: updated
Functional Block Diagram in Figure 27-1 on page 238 and Section 27.5.12 ”Debug Unit Force NTRST #2832
Register”ice_nreset signal replaced with pad name, Power-on Reset (power_on_reset.)
“Peripheral DMA Controller (PDC)” User interface description updated page 173. Correct typo to
05-460
“ENDTX” bit field name in Section 23.3.3 ”Transfer Counters”
PIO, Section 15.4.4 ”Output Control” typo corrected 05-346
Section 15.4.1 ”Pull-up Resistor Control”, ref to resistor value removed. 05-497
Figure 15-3 ”I/O Line Control Logic” page 82, 0 and 1 inverted in the MUX controlled by PIO_MDSR. #3053
”PMC Master Clock Register” on page 231 Corrected name of bitfield “PRES” #1603
Note defining PIDx added to “PMC Peripheral Clock Enable Register” , ”PMC Peripheral Clock Disable #2468
Register” page 226 and
Table 26-2 on page 222: footnotes reassigned. #2748
PWM, updated waveform generation Section 33.5.3.3 ”Changing the Duty Cycle or the Period” page 430. #1677
RSTC; added info on startup counter on crystal oscillator Section 13.3.1 ”Reset Controller Overview” #3005
RTT, added note to ”Functional Description” page 73 #2522
Change
Version Request
6175F Comments Ref.
SPI, Figure 28-9 ”Slave Mode Functional Block Diagram” page 272, FLOAD removed #1542
Section 28.6.3 ”Master Mode Operations” change to SPI_RDR information #1543
Section 28.7.1 ”SPI Control Register” added information to bit description ”SWRST: SPI Software Reset”
page 14.
Section 28.7.9 ”SPI Chip Select Register” corrected equation in ”DLYBCT: Delay Between Consecutive
Transfers” page 25.
Section 28.6.3.8 ”Mode Fault Detection” updated #1676
SSC, Section 31.6.6.1 ”Compare Functions” updated IP update
TC, Table 32-1, “Timer Counter Clock Assignment,” on page 389 has been added. #2470
Section 32.5.4 ”External Event/Trigger Conditions” TIOB defined as external event signal..... updated #2704
”EEVT: External Event Selection” page 412, TIOB chosen as external event signal..... updated in footnote
TWI, ”Two-wire Interface (TWI) User Interface” page 294, UNRE and OVRE bit fields removed from TWI
#2470
Status and Interrupt register tables.
UDP, Figure 34-2 on page 446 updated,
Section 34.4.1 ”USB Device Transceiver” and Section 34.4.2 ”VBUS Monitoring” page 446 added.
Section 34.5.1.2 ”USB Bus Transactions” updated
Section 34.5.1.3 ”USB Transfer Event Definitions” updated with endpoint information.
Section 34.5.2.2 ”Data IN Transaction” Endpoint use updated.
Section 34.5.2 ”Handling Transactions with USB V2.0 Device Peripheral” page 450, Section reworked, source file
warnings added. update
Section 34.5.3 ”Controlling Device States” page 458, Section reworked and Section 34.5.3.1 ”Not
Powered State” and Section 34.5.3.2 ”Entering Attached State” page 459 added.
Section 34.6 ”USB Device Port (UDP) User Interface”
Section 34.6.2 ”UDP Global State Register” page 464,updated.
Section 34.6.10 ”UDP Endpoint Control and Status Register” page 473, updated
Corrections, improvements, additions and deletions throughout section, new source document.
Section Section 34.5.3.8 ”Sending a Device Remote Wakeup” replaces title: “Sending an External 3288
Resume”.
WAKEUP bit shown in interruput registers:Section 34.6.4 on page 466 thru Section 34.6.8 on page 471.
RMWUPE, RSMINPR, ESR bits removed from Section 34.6.2 ”UDP Global State Register”.
NOTE: pertinent to USB pullup effect on USB Reset added to Section 34.6.12 ”UDP Transceiver Control
Register”.
719
6175H–ATARM–03-Dec-07
Change
Version Request
6175F Comments Ref.
USART, Section 30.6.7 ”AT91SAM7S512/256/128/64/321 Modem Mode”change to: The control of DTR #1770
output.... RTS output pin.....
Section 30.6.4.1 ”ISO7816 Mode Overview”PAR bit usage #1552
Section 30.6.3 ”Synchronous and Asynchronous Modes” Manchester Encoder/Decoder feature removed #2748
Section 30.5.1 ”I/O Lines”TXD line information added #2794 &
Section 30.6.1.3 ”AT91SAM7S512/256/128 Fractional Baud Rate in Asynchronous Mode”USART rfo review
“functional mode” changed to “normal mode”
Table 30-3 and Table 30-4 on page 312 Di and Fi references corrected in titles.
Figure 30-27 ”IrDA Demodulator Operations” page 328, Figure modified.
Table 30-2, “Baud Rate Example (OVER = 0)last two lines of table removed. #2942
Section 30.6.3.2 ”Asynchronous Receiver” change to second sentence in fourth paragraph, “For the #3023
synchronization mechanism.....”
Section 30.6.3.8 ”Receiver Time-out” list of user options rewritten.
Section 30.7.1 ”USART Control Register” STTTO bit function related to TIMEOUT in US_CSR register.
Section 30.7.6 ”USART Channel Status Register” TIMEOUT bit function related to STTTO in US_CR
register.
WDT, WV changed to WDV in Section 17.2 ”Block Diagram” and in Section 17.3 ”Functional Description”
#3002
and 6th and 7th paragraph rewritten on page 112 beginning with “To prevent a software deadlock....”
Section 37. ”AT91SAM7S Electrical Characteristics” AT91SAM7S512 specific info added and changes to
the following tables.
Table 37-2, “DC Characteristics”
Table 37-5, “DC Flash Characteristics AT91SAM7S64/321/32”
Table 37-6, “DC Flash Characteristics AT91SAM7S512/256/128”
Table 37-7, “Power Consumption for Different Modes”
Review
Table 37-8, “Power Consumption on VDDCORE(1)”
Table 37-10, “Main Oscillator Characteristics”
Table 37-11, “Crystal Characteristics” has been added.
Table 37-12, “XIN Clock Electrical Characteristics”
Table 37-13, “Phase Lock Loop Characteristics”
Table 37-22, “SPI Timings”
Section 37. ”AT91SAM7S Electrical Characteristics”
“Absolute Maximum Ratings” on page 545, change to Maximum Operating Voltages. #3058
Table 37-7, “Power Consumption for Different Modes”, note added to table #3061
Section 38. ”Mechanical Characteristics” SAM7S512 added to Device and Package weights
Change
Version Request
6175F Comments Ref.
Section 40. ”Errata” Added Section 40.1 ”Marking”
TWI: Behavior of OVRE bit: eliminated.
change or added to all:
PIO: Leakage on PA17 - PA20...” the leakage can be 9 µA in worst case...”
RTT: Possible Event Loss when Reading RTT_SR
SPI: Chip Select and Fixed Mode
SPI: Baudrate Set to 1
SPI: Disable in Slave Mode
TWI: Software Reset
USART: Hardware Handshaking – Two Characters are Sent
USART: XOFF Character Bad Behavior
added to AT91SAM7S64/32 only:
SPI: Disable Issue
SPI: Software Reset and SPIEN Bit
SPI: CSAAT = 1 and Delay
Change to AT91SAM7S321 only:
Voltage Regulator errata removed.
PWM: Constraints on Duty Cycle Value, updated all 3173
Change
Version Request
6175E Comments Ref
“Features” on page 1, Table 1-1, “Configuration Summary,” on page 3, Section 4. ”Package and
Pinout”“Absolute Maximum Ratings” on page 545, Table 37-1, “Thermal Resistance Data,” on #2403
page 537and
Section 39. ”AT91SAM7S Ordering Information”QFN package information added.
Section 40. ”Errata” QFN package errata added,
#2453
Section 40. ”Errata” SPI: SPCK Behavior in Master Mode added.
#2607
Section 40. ”Errata” PIO: Leakage in worst case changed to 9 µA.
721
6175H–ATARM–03-Dec-07
Change
Version Request
6175D Comments Ref
Section 40.12 ”AT91SAM7S321 Errata - Revision A Parts” added
Section 40. ”Errata” added the following:
Section 40.4.11.3 ”TWI: Disabling Does not Operate Correctly” AT91SAM7S256
Section 40.4.11.4 ”TWI: NACK Status Bit Lost”
Section 40.4.11.5 ”TWI: Possible Receive Holding Register Corruption”
Section 40.4.12.1 ”USART: CTS in Hardware Handshaking”
Change
Version Request
6175C Comments Ref
AT91SAM7S321 addresses redefined:Table 22-4, “User Area Addresses,” on page 171
#1217
Values given in PIO Line column: Table 22-5, “Pins Driven during Boot Program Execution,” on page 171
Section 40. ”Errata” added lines and note to the following:
Section 40.4.3.1 ”MCK: Limited Master Clock Frequency Ranges” AT91SAM7S256
Section 40.7.3.1 ”MCK: Limited Master Clock Frequency Ranges” AT91SAM7S128
Section 40.10.3.1 ”MCK: Limited Master Clock Frequency Ranges” AT91SAM7S64
Section 40.13.3.1 ”MCK: Limited Master Clock Frequency Ranges” AT91SAM7S32 #1547 and
and review
Section 40.4.4.1 ”NVM Bits: Write/Erase Cycles Number” AT91SAM7S256
Section 40.7.4.1 ”NVM Bits: Write/Erase Cycles Number” AT91SAM7S128
Section 40.10.4.1 ”NVM Bits: Write/Erase Cycles Number” AT91SAM7S64
Section 40.13.4.1 ”NVM Bits: Write/Erase Cycles Number” AT91SAM7S32
note (2) added to Table 37-23, “Embedded Flash Wait States,” on page 566 review
”Voltage Regulator Mode Register” page 118, bit field name corrected ”PSTDBY: Power Standby Mode” #1585
AT91SAM7S321 addresses redefined:Table 22-4, “User Area Addresses,” on page 171
#1217
Values given in PIO Line column: Table 22-5, “Pins Driven during Boot Program Execution,” on page 171
723
6175H–ATARM–03-Dec-07
Change
Version Request
6175B Comments Ref
Added to datasheet: Section 40. “Errata” on page 579
Section 40.4 “AT91SAM7S256 Errata - Manufacturing Number 58818C” on page 589,Section 40.7
“AT91SAM7S128 Errata - Manufacturing Number 58818C” on page 619, Section 40.10 “AT91SAM7S64
Errata - Manufacturing Number 58814G” on page 649 Section 40.13 “AT91SAM7S32 Errata -
Manufacturing Number 58814G” on page 676 05-501
Changes/updates to the following:
“ADC Characteristics” on page 562, Figure 37-5 and Figure 37-6 on page 564, Table 37-6, “DC Flash
Characteristics AT91SAM7S512/256/128,” on page 548 and Table 37-13, “Phase Lock Loop
Characteristics,” on page 558
update to “Internal Memory Mapping” on page 119 05-507
update to SVMST0: Saved PDC Abort Source and SVMST1: Saved ARM7TDMI Abort Source register
05-509
field definitions in “MC Abort Status Register” on page 123.
Section 8. “Memories” on page 18 updated: 2 ms => 3 ms, 10 ms => 15 ms, 4 ms => 6 ms 05-529
Evolution in IP blocks:
EFC: FMCN: Flash Microsecond Cycle Number register field in ”MC Flash Mode Register” page 138
PMC: Section 26.7 ”Programming Sequence” page 215
DBGU: ”ARCH: Architecture Identifier” page 259 register field in “Debug Unit Chip ID Register”
SPI: Section 28. ”Serial Peripheral Interface (SPI)” page 1
UDP: Section 34.3.2 ”Power Management” page 445, Section 34.6 ”USB Device Port (UDP) User
Interface” page 462, ”UDP Transceiver Control Register” page 478
In Features and global: ”EmbeddedICE™ In-circuit Emulation, Debug Communication Channel Support”
EmbeddedICE to replace usage of “embedded in-ciruit emulator”
Change
Version Request
6175A Comments Ref
First issue
Table of Contents
Features ..................................................................................................... 1
1 Description ............................................................................................... 3
1.1Configuration Summary of the AT91SAM7S512, AT91SAM7S256, AT91SAM7S128,
AT91SAM7S64, AT91SAM7S321, AT91SAM7S32, AT91SAM7S161 and
AT91SAM7S16 ..................................................................................................3
8 Memories ................................................................................................ 18
8.1AT91SAM7S512 ......................................................................................................18
8.2AT91SAM7S256 ......................................................................................................18
i
6175H–ATARM–03-Dec-07
8.3AT91SAM7S128 ......................................................................................................18
8.4AT91SAM7S64 ........................................................................................................19
8.5AT91SAM7S321/32 .................................................................................................19
8.6AT91SAM7S161/16 .................................................................................................19
8.7Memory Mapping .....................................................................................................21
8.8Embedded Flash .....................................................................................................22
8.9Fast Flash Programming Interface ..........................................................................25
8.10SAM-BA Boot Assistant .........................................................................................25
10 Peripherals ............................................................................................. 34
10.1User Interface ........................................................................................................34
10.2Peripheral Identifiers .............................................................................................34
10.3Peripheral Multiplexing on PIO Lines ....................................................................35
10.4PIO Controller A Multiplexing ................................................................................36
10.5Serial Peripheral Interface .....................................................................................38
10.6Two-wire Interface .................................................................................................38
10.7USART ..................................................................................................................38
10.8Serial Synchronous Controller ...............................................................................39
10.9Timer Counter .......................................................................................................39
10.10PWM Controller ...................................................................................................40
10.11USB Device Port (Does not pertain to AT91SAM7S32/16) .................................40
10.12Analog-to-digital Converter ..................................................................................40
iii
6175H–ATARM–03-Dec-07
18.1Overview .............................................................................................................115
18.2Voltage Regulator Power Controller (VREG) User Interface ...............................116
v
6175H–ATARM–03-Dec-07
29.3Block Diagram .....................................................................................................286
29.4Application Block Diagram ..................................................................................286
29.5Product Dependencies ........................................................................................286
29.6Functional Description .........................................................................................287
29.7Two-wire Interface (TWI) User Interface .............................................................299
vii
6175H–ATARM–03-Dec-07
37.7I/O Characteristics ...............................................................................................558
37.8USB Transceiver Characteristics .........................................................................560
37.9ADC Characteristics ...........................................................................................562
37.10AC Characteristics .............................................................................................564
Table of Contents....................................................................................... i
Product Contact
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 ATMEL’S TERMS AND CONDI-
TIONS OF SALE LOCATED ON ATMEL’S 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 specifica-
tions and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically pro-
vided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’s products are not intended, authorized, or warranted
for use as components in applications intended to support or sustain life.
© 2007 Atmel Corporation. All rights reserved. Atmel®, logo and combinations thereof, DataFlash® and others, are registered trademarks, SAM-BA™
and others are trademarks of Atmel Corporation or its subsidiaries. Windows® and others are registered trademarks or trademarks of Microsoft Corpora-
tion in the US and/or in other countries. ARM®, the ARM Powered® logo, ARM7TDMI® , Thumb®, are registered trademarks of ARM Limited. Other terms
and product names may be the trademarks of others.
6175H–ATARM–03-Dec-07