At91 Arm Thumb Microcontrollers AT91C140: Features
At91 Arm Thumb Microcontrollers AT91C140: Features
At91 Arm Thumb Microcontrollers AT91C140: Features
1. Description
The AT91C140 is a member of the Atmel AT91 16- and 32-bit microcontroller family
based on the ARM7TDMI processor core. This processor has a high performance
32-bit RISC architecture with a high density 16-bit instruction set and very low power
consumption.
In addition, the AT91C140 integrates a double Ethernet 10/100 base-T MAC capable
of operating as an Ethernet bridge, thus making it ideally suited for networking appli-
cations. It supports a wide range of memory devices such as SDRAM, SRAM and
Flash and embeds an extensive array of peripherals.
The device is manufactured using Atmel’s high-density CMOS technology. By com-
bining the ARM7TDMI processor core with an expansive assortment of peripheral
functions and low-power oscillators and PLL on a monolithic chip, the Atmel
AT91C140 is a powerful microcontroller that provides a highly flexible and cost effec-
tive solution to many networking applications.
6069C–ATARM–15-Sep-05
2. Block Diagram
Figure 2-1. AT91C140 Block Diagram
JTAG Debug
Interface ICE
ARM7TDMI Processor
Boot ROM
External Bus
Interface
Peripheral Data
Controller
Peripheral Bridge
OSC
System Serial Peripherals
Controller SPI Boot DataFlash
PLL
2 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
3. Pinout
Table 3-1. Pinout for 208-lead PQFP Package
Pin Pin Pin Pin
Number Signal Name Number Signal Name Number Signal Name Number Signal Name
1 GND 37 MB_TXD0 73 A15 109 RAS
3
6069C–ATARM–15-Sep-05
Table 3-1. Pinout for 208-lead PQFP Package (Continued)
Pin Pin Pin Pin
Number Signal Name Number Signal Name Number Signal Name Number Signal Name
145 SPCK 161 TMS 177 PA5 193 GND
157 104
208
53
1 52
4 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
4. Peripheral Multiplexing on PIO Lines
The AT91C140 features two PIO Controllers, PIOA and PIOB, multiplexing I/O lines of the
peripheral set.
The PIO Controller A manages 15 I/O lines, PA0 to PA12, PA19 and PA22.
The PIO Controller B manages only 10 I/O lines, PB0 to PB9.
Each I/O line of a PIO Controller can be multiplexed with a peripheral I/O. Multiplexing of the
PIO Controller A is given in Table 4-1 on page 6. Multiplexing of the PIO Controller B is given
in Table 4-2 on page 6.
5
6069C–ATARM–15-Sep-05
4.1 PIO Controller A Multiplexing
Table 4-1. Multiplexing on PIO Controller A
I/O Line Peripheral
Name Signal Name Description Type
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PA8 TCLK0 Timer Counter Clock Input 0 Input
PA9 TIOA0 Timer Counter I/O LIne A 0 I/O
PA10 TIOB0 Timer Counter I/O LIne B 0 I/O
PA11 SCKA UART A Serial Clock I/O
PA12 NPCS1 Serial Peripehral Chip Select 1 Output
PA19 ACLKO ARM System Clock Output
PA22 NPCS0 Serial Peripheral Chip Select 0 I/O
6 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
5. Signal Description
Table 5-1. Signal Description
Block Signal Name Function Type
VDDIO I/O Lines Power Supply
VDDCORE Device Core Power Supply
Power Supplies
VDDOSC PLL and Oscillator Power Supply
GND Ground
A0-A23 Address Bus Output
External Bus Interface
D0-D15 Data Bus Input/Output
SDCK SDRAM Clock Output
DQM0-DQM1 SDRAM Byte Masks Output
SDCS SDRAM Chip Select Output
7
6069C–ATARM–15-Sep-05
Table 5-1. Signal Description (Continued)
Block Signal Name Function Type
RXDA-RXDB Receive Data Input
TXDA-TXDB Transmit Data Output
NRTSA-NRSTB Ready to Send Output
NCTSA-NCTSB Clear to Send Input
UART A and UART B NDTRA-NDTRB Data Terminal Ready Output
NDSRA-NDSRB Data Set Ready Input
NDCDA-NDCDB Data Carrier Detect Input
NRIA-NRIB Ring Indicator Input
SCKA UART Serial Clock I/O
MA_COL MAC A Collision Detect Input
MA_CRS MAC A Carrier Sense Input
MA_TXER MAC A Transmit Error Output
MA_TXD0-MA_TXD3 MAC A Transmit Data Bus Output
MA_TXEN MAC A Transmit Enable Output
MA_TXCLK MAC A Transmit Clock Input
MAC A Interface MA_RXD0-MA_RXD3 MAC A Receive Data Bus Input
MA_RXER MAC A Receive Error Input
MA_RXCLK MAC A Receive Clock Input
MA_RXDV MAC A Receive Data Valid Output
MA_MDC MAC A Management Data Clock Output
MA_MDIO MAC A Management Data Bus Input/Output
MA_LINK MAC A Link Interrupt Input
MB_COL MAC B Collision Detect Input
MB_CRS MAC B Carrier Sense Input
MB_TXER MAC B Transmit Error Output
MB_TXD0-MB_TXD3 MAC B Transmit Data Bus Output
MB_TXEN MAC B Transmit Enable Output
MB_TXCLK MAC B Transmit Clock Input
MAC B Interface MB_RXD0-MB_RXD3 MAC B Receive Data Bus Input
MB_RXER MAC B Receive Error Input
MB_RXCLK MAC B Receive Clock Input
MB_RXDV MAC B Receive Data Valid Output
MB_MDC MAC B Management Data Clock Output
MB_MDIO MAC B Management Data Bus Input/Output
MB_LINK MAC B Link Interrupt Input
8 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Table 5-1. Signal Description (Continued)
Block Signal Name Function Type
NTRST Test Reset Input
TCK Test Clock Input
In-Circuit Emulator TMS Test Mode Select Input
TDI Test Data Input Input
TDO Test Data Output Output
NRST Reset Input
FIQ Fast Interrupt Input
IRQ0-IRQ1 Interrupt Lines Input
PLLRC PLL RC Filter Analog
Miscellaneous
XTALIN Crystal Input Analog
XTALOUT External Crystal Analog
TST Test Mode Input
ACLKO ARM Clock Output Output
9
6069C–ATARM–15-Sep-05
6. ARM7TDMI Core
The ARM7TDMI is a three-stage pipeline, 32-bit RISC processor. The processor architecture
is Von Neumann load/store architecture, characterized by a single data and address bus for
instructions and data. The CPU has two instruction sets: the ARM and the Thumb instruction
set. The ARM instruction set has 32-bit wide instructions and provides maximum performance.
Thumb instructions are 16-bit wide and give maximum code density.
Instructions operate on 8-bit, 16-bit and 32-bit data types.
The CPU has seven operating modes. Each operating mode has dedicated banked registers
for fast exception handling. The processor has a total of 37 32-bit registers, including six sta-
tus registers.
7. Power Supplies
The AT91C140 has three types of power supply pins:
• VDDCORE pins power the core, including the ARM7TDMI processor, the memories and
the peripherals; voltage is between 1.65V and 1.95V, 1.8V nominal.
• VDDIO pins power the I/O lines, including those of the External Bus Interface and those of
the peripherals; voltage is between 3V and 3.6V, 3.3V nominal.
• VDDOSC pins power the PLL and oscillator cells; voltage is between 1.65V and 1.95V,
1.8V nominal.
Ground pins are common to all power supplies.
10 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
8. System Controller
The AT91C140 features a System Controller that takes care of and controls:
• the Test Mode
• the Reset
• the System Clocks
• the Chip Identifier
The System Controller manages the reset of all the system and integrates a clock generator,
made up of an oscillator and a PLL.
8.1 Test
The AT91C140 features a test pin (TST). This pin must be tied low for normal operations.
Using the AT91C140 with the TST pin at a high level might lead to unpredictable results.
11
6069C–ATARM–15-Sep-05
Figure 8-1. Clock Generator
LP
LPCS
Counter and Control Logic RDY
DIV
SA 1
XTALIN
ACLK
DIV7 1
16 MHz 16MHz
Crystal 0
Oscillator ACLKO
0
LP DIV6
XTALOUT
After the reset, the ACLK clock is running at 31.25 kHz. The user can program the LPCS field
to speed the boot sequence.
The ACLKST (ARM Clock Status) bit reflects the clock being used for the ARM. When read at
0, ACLK is 40 MHz if SA is 0 and 34.3 MHz if SA is 1. When read at 1, ACLK is at a frequency
according to the value programmed in the LPCS field in the System Mode Register
(SYS_MR).
8.4 Chip ID
The System Controller features a Chip ID Register that reads a value of 0x00010221
12 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
8.5 System Controller User Interface
Base Address: 0xFF00 0000.
13
6069C–ATARM–15-Sep-05
8.5.1 System Mode Register
Register Name: SYS_MD
Access: 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
– 0 – 0 – – LPCS
7 6 5 4 3 2 1 0
SA LP – – 0 – 0 RM
• RM: Remap
0 =The ROM is mapped only at its normal address.
1 =The ROM is mapped at its address and at address 0x0.
• LP: Low Power Mode
0 =The PLL is enabled and ACLK is the output of the PLL divided by 6 or 7.
1 =The PLL is disabled and ACLK is defined by LPCS.
• SA: Slow ARM
0 =The ARM divider is 6.
1 =The ARM divider is 7.
• LPCS: Low Power Clock Select
14 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
8.5.2 System ID Register
Register Name: SYS_ID
Access: Read-only
31 30 29 28 27 26 25 24
0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 1
15 14 13 12 11 10 9 8
0 0 0 0 0 0 1 0
7 6 5 4 3 2 1 0
0 0 1 0 0 0 0 1
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – – – ACLKST
15
6069C–ATARM–15-Sep-05
9. Memory Controller (MC)
9.1 Architecture
The AT91C140 architecture is made up of two Advanced System Buses, the ARM ASB and
the MAC ASB. Both handle a single memory space.
The ARM ASB handles the access requests of the ARM7TDMI and the PDC. It also handles
the access requests coming from the MAC ASB. It connects with the External Bus Interface,
the Peripheral Bridge and the Internal Memories. It also connects with the MAC ASB.
The MAC ASB handles the access requests of the DMAs of both Ethernet MACs. It also han-
dles the access requests coming from the the ARM ASB. It connects essentially with the
Frame Buffer, but also connects with the ARM ASB.
The major advantage of this double-ASB architecture is that the Ethernet traffic does not
occupy the main ASB bandwidth, ensuring that the ARM7TDMI can perform at its maximum
speed while the Ethernet traffic goes through the Frame Buffer.
The AT91C140 architecture is shown in Figure 9-1.
ARM ASB
ARM7TDMI
Processor
Internal
ROM
Main
Bus
Peripheral Arbiter
Data
Controller External
Bus
Interface
From Master ASB-ASB
to Slave Bridge
Peripheral APB
MACA Bridge
DMA
Secondary
Bus
Arbiter
Frame
MACB Buffer
DMA
MAC ASB
16 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
9.2 Memory Map
The AT91C140 memory map is divided into regions of 256 megabytes. The top memory
region (0xF000_0000) is reserved and subdivided for the internal memories and shared mem-
ory and the embedded peripherals.
The device can define up to five other active external memory regions by means of the static
memory controller and SDRAM memory controller.
The memory map is divided between both ASBs, as shown in Figure 9-1. All regions except
the 16 megabytes between 0xFC00 0000 and 0xFCFF FFFF are located on the Main ASB.
Accesses to locations between 0xFC00 0000 and 0xFCFF FFFF are routed to the MAC ASB.
The memory map assumes default values on reset. External memory regions can be repro-
grammed to other base addresses in the Static Memory Controller or in the SDRAM
Controller. Note that the internal memory regions have fixed locations that cannot be
reprogrammed.
There are no hardware locks to prevent incorrect programming of the regions. Programming
two or more regions to have the same base address or overlapping two memory regions
results in undefined behavior.
The ARM processor reset vector at address 0x00000000 is mapped into the internal ROM or
external memory connected on NCE0. This selection depends on the PA0 signal pin. After
booting, the ROM region can be disabled and any external memory can be mapped to the bot-
tom of the memory map by programming SMC_CSRx or SDRAMC_ADDR.
0xEFFF FFFF
0xF000 0000 Internal Memories
256M bytes
0xFFFF FFFF and Peripherals
17
6069C–ATARM–15-Sep-05
Figure 9-3 below shows the mapping of the internal memories and the address space
reserved for the Peripheral Bridge.
18 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• The local bus arbiter arbitrates the master’s request for the local ASB bus if it does not
already have access to the bus.
• When the local bus arbiter grants the local bus to the master, the master initiates a cycle
with an address corresponding to a slave on the remote bus.
• The bridge is selected as the slave on the local bus and responds by inserting wait cycles.
The bridge also requests the remote bus from the remote bus arbiter.
• When the bridge is granted the remote bus, the two ASB buses are coupled and the transfer
completes.
The ASB performs pipelined arbitration. The ASB-ASB Bridge can only request the bus when
the address of the slave is available. For this reason, the ASB-ASB Bridge inserts a wait cycle
during the arbitration cycle on the remote bus because it cannot request the bus early.
0x0FFF FFFF
19
6069C–ATARM–15-Sep-05
9.7 Endianness
The AT91C140 Memory Controller operates in little-endian mode only. The user has to make
sure that the data structures used by the ARM7TDMI, the Ethernet DMAs and the PDC are
compliant with this mode of byte arrangement.
20 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
10. Peripherals
The Peripheral Bridge allows access to the embedded peripheral user interfaces. It is opti-
mized for low power consumption, as it is built without usage of any clock. However, any
access on the peripheral is performed in two cycles.
The AT91C140 peripherals are designed to be programmed with a minimum number of
instructions. Each peripheral has 16K bytes of address space allocated in the upper part of the
address space.
21
6069C–ATARM–15-Sep-05
10.2 Peripheral Memory Map
Figure 10-1 below gives the mapping of the peripherals integrated in the AT91C140.
0xFF00 0000
SYSC System Controller 16K bytes
0xFF00 3FFF
0xFF00 4000
SMC Static Memory Controller 16K bytes
0xFF00 7FFF
0xFF00 8000
SDRAMC SDRAM Controller 16K bytes
0xFF00 BFFF
0xFF00 C000
PIOA Parallel I/O Controller A 16K bytes
0xFF00 FFFF
0xFF01 0000
PIOB Parallel I/O Controller B 16K bytes
0xFF01 3FFF
0xFF01 4000
TC0, TC1, TC2 Timer Counter Channel 0, 1 and 2 16K bytes
0xFF01 7FFF
0xFF01 8000
UART A Universal Asynchronous 16K bytes
Receiver Transmitter A
0xFF01 BFFF
0xFF01 C000
UART B Universal Asynchronous 16K bytes
0xFF01 FFFF Receiver Transmitter B
0xFF02 0000
SPI Serial Peripheral Interface 16K bytes
0xFF02 3FFF
0xFF02 4000
Reserved
0xFF02 FFFF
0xFF03 0000
AIC Advanced Interrupt Controller 16K bytes
0xFF03 3FFF
0xFF03 4000
MACA Ethernet MAC A 16K bytes
0xFF03 7FFF
AIC is
0xFF03 8000 mapped
MACB Ethernet MAC B 16K bytes
at both
0xFF03 BFFF addresses
0xFF03 C000 Reserved
0xFFFF EFFF
0xFFFF F000
AIC Advanced Interrupt Controller 16K bytes
0xFFFF FFFF
22 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
11. Peripheral Data Controller (PDC)
23
6069C–ATARM–15-Sep-05
12. Boot Program
The AT91C140 can boot in several ways as explained below. When the ARM7TDMI proces-
sor is released from reset it basically attempts a fetch from address 0x00000000. Depending
on an hardware configuration, the memory mapping can be altered and thus modify how the
system boots.
AT91C140 DataFlash
NPCS0/PA22 CS
MOSI SI
MISO SO
SPCK CK
24 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• The on-chip SPI interface is setup to prepare for communications with DataFlash.
• A bunch of data is downloaded from the DataFlash. This data is expected to contain a
formatted header describing the contents of the DataFlash.
• This header is analyzed to verify whether a DataFlash is actually present and contains valid
executable code.
• If the DataFlash is there and contains valid executable code, this code is downloaded into a
location specified by the header, and an absolute branch to this code is performed.
• If the DataFlash is missing, or if the header is not valid, an absolute branch to address
0x00000000 is performed. A suitable memory device should be mapped at this address
and contain the expected code.
Note: 1. The field address is respective to the DataFlash space. 0x00 corresponds to the first loca-
tion of the DataFlash.
The MAGIC field contains a predefined magic number which allows identification of the suit-
ability of the DataFlash. The value of this field must be 0x0075C221 to allow the boot routine
to proceed. If another value is read, the boot code gives up the download and branches to
0x0000 0000 where the real application code is expected.
The DSRC field contains the address where the code to be downloaded resides in DataFlash.
This address is respective to the DataFlash address space (not the ARM Processor address
space) and follows the non-linear addressing scheme defined in the documentation of the
DataFlash. Note that all bits are not necessarily significant, depending on the specific
DataFlash device.
The DDST field contains the destination address where the downloaded code will be copied.
This address is respective to the ARM Processor address space. Typically, this address
should point into some internal RAM.
The DSIZE field contains the number of bytes to be downloaded. This value is exclusive of the
header. It must be even.
The ENTRY field contains the address where the boot routine must branch when the down-
load is complete. It is the entry point of the newly downloaded software. Although this is not
required, the ENTRY field equals the DDST field in most cases.
25
6069C–ATARM–15-Sep-05
12.5 Reserved Resources
The internal boot code needs some resources to operate correctly, especially as it programs
some on-chip peripherals. These must not be assumed to be in their reset state when the con-
trol is given to the application code. The concerned peripherals are:
• the clock management system
• the SPI interface
• the PIO pin PA22
• the RM bit
The internal boot code also uses some internal RAM locations to store temporary data. These
reside in the first 64 bytes of RAM, i.e. from 0xFD00 FFC0 to 0xFD00 FFFF. The DDST,
DSIZE fields of the DataFlash header must not define a memory area overlapping the loca-
tions used by the internal boot routine. The ENTRY field must not point into this area.
26 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
13. External Bus Interface (EBI)
The External Bus Interface (EBI) generates the signals that control access to external memo-
ries or peripheral devices. It contains two controllers, the SDRAM Controller and the Static
Memory Controller and manages the sharing of data and address busses between both of
these controllers.
27
6069C–ATARM–15-Sep-05
14. SDRAM Controller (SDRAMC)
14.1 Description
The SDRAM Controller (SDRAMC) extends the memory capabilities of a chip by providing the
interface to an external 16-bit SDRAM device. The page size supports ranges from 2048 to
8192 and the number of columns from 256 to 2048. It supports byte (8-bit), half-word (16-bit)
and word (32-bit) accesses. The maximum addressable SDRAM size is 256M bytes.
The SDRAM Controller supports a read or write burst length of one location. It keeps track of
the active row in each bank, thus maximizing SDRAM performance, e.g., the application may
be placed in one bank and data in the other banks. So as to optimize performance, it is advis-
able to avoid accessing different rows in the same bank.
SDRAMC
SDCK
SDRAMC
Memory
Chip Select
Controller SDCS
BA[1:0]
RAS
CAS
System ACLK
Controller WE
DQM[1:0]
A[12:11, 9:0]
SDA10
D[15:0]
User Interface
APB
28 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.3 I/O Lines Description
Table 14-1. I/O Line Description
Name Description Type Active Level
SDCK SDRAM Clock Output
SDCS SDRAM Controller Chip Select Output Low
BA[1:0] Bank Select Signals Output High
RAS Row Signal Output Low
CAS Column Signal Output Low
WE SDRAM Write Enable Output Low
DQM[1:0] Data Mask Enable Signals Output Low
A [12:11]
SDA10 Address Bus Output
A[9:0]
D[15:0] Data Bus I/O
Figure 14-2. SDRAM Controller Connections to SDRAM Devices: 16-bit Data Bus Width
D0-D31
RAS 2M x 8 2M x 8
CAS
SDCK D0-D7 SDRAM D8-D15 SDRAM
WE D0-D7 D0-D7
DQM0
DQM1 CS CS
VDD CKE VDD CKE
A0-A11 A0- A11
CLK A0--A11 CLK A0-A11
SDWE SDWE
WE BA0 BA0 WE BA0 BA0
RAS BA1 RAS BA1 BA1
BA1
CAS CAS
DQM DQM
DQM0 DQM1
A0-A11
A0-A9, SDA10, A11
A19/BA0
A20/BA1
SDRAM SDCS
Controller
29
6069C–ATARM–15-Sep-05
16-bit Memory Data Bus Width
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
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
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
30 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.5 SDRAM Device Initialization
The initialization sequence is generated by software. The SDRAM devices are initialized by
the following sequence:
1. A minimum pause of 200 µs is provided to precede any signal toggle.
2. An All Banks Precharge command is issued to the SDRAM devices.
3. Eight auto-refresh (CBR) cycles are provided.
4. A mode register set (MRS) cycle is issued to program the parameters of the SDRAM
devices, in particular CAS latency and burst length.
5. A Normal Mode command is provided, 3 clocks after tMRD is met.
6. Perform a dummy access in the SDRAM Memory Space to initialize the state
machine.
7. Write refresh rate into the count field in the SDRAMC Refresh Timer register.
(Refresh rate = delay between refresh cycles).
After these six steps, the SDRAM devices are fully functional.
The commands (NOP, MRS, CBR, normal mode) are generated by programming the com-
mand field in the SDRAMC Mode register.
SDCK
A[9:0]
SDA10
A[12:11]
SDCS
RAS
CAS
WE
NBS
Inputs Stable for Precharge All Banks 1st Auto-refresh 8th Auto-refresh MRS Command Valid Command
200 µsec
31
6069C–ATARM–15-Sep-05
14.6 SDRAM Controller Write Cycle
The SDRAM Controller allows burst access or single access. To initiate a burst access, the
SDRAM Controller uses the transfer type signal provided by the master requesting the access.
If the next access is a sequential write access, writing to the SDRAM device is carried out. If
the next access is a write-sequential access, but the current access is to a boundary page, or
if the next access is in another row, then the SDRAM Controller generates a precharge com-
mand, activates the new row and initiates a write command. To comply with SDRAM timing
parameters, additional clock cycles are inserted between precharge/active (tRP) commands
and active/write (tRCD) commands. For a definition of these timing parameters, refer to the
”SDRAMC Configuration Register” on page 39. This is described in Figure 14-4 below.
SDCS
SDCK
A[12:0] Row n col a col b col c col d col e col f col g col h col i col j col k col l
RAS
CAS
WE
D[15:0] Dna Dnb Dnc Dnd Dne Dnf Dng Dnh Dni Dnj Dnk Dnl
32 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.7 SDRAM Controller Read Cycle
The SDRAM Controller allows burst access or single access. To initiate a burst access, the
SDRAM Controller uses the transfer type signal provided by the master requesting the access.
If the next access is a sequential read access, reading to the SDRAM device is carried out. If
the next access is a sequential read access, but the current access is to a boundary page, or if
the next access is in another row, then the SDRAM Controller generates a precharge com-
mand, activates the new row and initiates a read command. To comply with SDRAM timing
parameters, an additional clock cycle is inserted between the precharge/active (tRP) command
and the active/read (tRCD) command, After a read command, additional wait states are gener-
ated to comply with cas latency. The SDRAM Controller supports a cas latency of two. For
definition of these timing parameters, refer to ”SDRAMC Configuration Register” on page 39.
This is described in Figure 14-5 below.
tRCD = 3 CAS = 2
SDCS
SDCK
RAS
CAS
WE
33
6069C–ATARM–15-Sep-05
14.8 Border Management
When the memory row boundary has been reached, an automatic page break is inserted. In
this case, the SDRAM controller generates a precharge command, activates the new row and
initiates a read or write command. To comply with SDRAM timing parameters, an additional
clock cycle is inserted between the precharge/active (tRP) command and the active/read (tRCD)
command. This is described in Figure 14-6 below.
SDCS
SDCK
Row n
A[12:0] col a col b col c col d Row m col a col b col c col d col e
RAS
CAS
WE
D[15:0] Dna Dnb Dnc Dnd Dma Dmb Dmc Dmd Dme
34 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.9 SDRAM Controller Refresh Cycles
An auto-refresh command is used to refresh the SDRAM device. Refresh addresses are gen-
erated internally by the SDRAM device and incremented after each auto-refresh automatically.
The SDRAM Controller generates these auto-refresh commands periodically. A timer is
loaded with the value in the register SDRAMC_TR that indicates the number of clock cycles
between refresh cycles.
When the SDRAM Controller initiates a refresh of the SDRAM device, internal memory
accesses are not delayed. However, if the ARM tries to access the SDRAM, it is held until the
refresh cycle has completed. See Figure 14-7 below.
SDCS
SDCK
Row n
A[12:0] col c col d Row m col a
RAS
CAS
WE
35
6069C–ATARM–15-Sep-05
14.10 SDRAM User Interface
Base Address: 0xFF00 8000
36 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.10.1 SDRAMC Mode Register
Register Name: SDRAMC_MR
Access Type: Read/Write
Reset Value: 0x00000010
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – MODE
7 6 5 4 3 2 1 0
MODE – – – – – –
MODE Description
0 0 0 Normal mode. Any access to the SDRAM is decoded normally.
0 0 1 The SDRAM Controller issues a NOP command when the SDRAM device is accessed regardless of the cycle.
The SDRAM Controller issues an “All Banks Precharge” command when the SDRAM device is accessed
0 1 0
regardless of the cycle.
The SDRAM Controller issues a “Load Mode Register” command when the SDRAM device is accessed
regardless of the cycle. The address offset with respect to the SDRAM device base address is used to program
0 1 1
the Mode Register. For instance, when this mode is activated, an access to the “SDRAM_Base + offset” address
generates a “Load Mode Register” command with the value “offset” written to the SDRAM device Mode Register.
The SDRAM Controller issues a “Refresh” Command when the SDRAM device is accessed regardless of the
1 0 0
cycle. Prior to this, an “All Banks Precharge” command must be issued.
Others Reserved
37
6069C–ATARM–15-Sep-05
14.10.2 SDRAMC Refresh Timer Register
Register Name: SDRAMC_TR
Access Type: Read/Write
Reset Value: 0x00000800
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – COUNT
7 6 5 4 3 2 1 0
COUNT
38 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.10.3 SDRAMC Configuration Register
Register Name: SDRAMC_CR
Access Type: Read/Write
Reset Value: 0x0299C140
31 30 29 28 27 26 25 24
– – – – – TRAS
23 22 21 20 19 18 17 16
TRAS TRCD TRP
15 14 13 12 11 10 9 8
TRP TRC TWR
7 6 5 4 3 2 1 0
TWR 1 0 NB NR NC
NC Column Bits
0 0 8
0 1 9
1 0 10
1 1 11
NR Row Bits
0 0 11
0 1 12
1 0 13
1 1 Reserved
NB Number of Banks
0 2
1 4
39
6069C–ATARM–15-Sep-05
• TRC: Row Cycle Delay
Reset value is eight cycles.
This field defines the delay between a Refresh and an Activate Command in number of cycles. Number of cycles is
between 2 and 15.
If TRC is less than or equal to 2, two clock periods are inserted by default.
• TRP: Row Precharge Delay
Reset value is three cycles.
This field defines the delay between a Precharge Command and another Command in number of cycles. Number of cycles
is between 2 and 15.
If TRP is less than or equal to 2, two clock periods are inserted by default.
• TRCD: Row to Column Delay
Reset value is three cycles.
This field defines the delay between an Activate Command and a Read/Write Command in number of cycles. Number of
cycles is between 2 and 15.
If TRCD is less than or equal to 2, two clock periods are inserted by default.
• TRAS: Active to Precharge Delay
Reset value is five cycles.
This field defines the delay between an Activate Command and a Precharge Command in number of cycles. Number of
cycles is between 2 and 15.
If TRAS is less than or equal to 2, two clock periods are inserted by default.
40 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
14.10.4 SDRAMC Address Register
Register Name: SDRAMC_ADDR
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
SDCS_ADDR
• SDCS_ADDR
This field defines the eight most significant bits of the base address of the SDRAMC.
41
6069C–ATARM–15-Sep-05
15. Static Memory Controller (SMC)
The AT91C140 features a Static Memory Controller (SMC), that enables interfacing with a
wide range of external static memory on peripheral devices, including Flash, ROM, static
RAM, and parallel peripherals.
The SMC provides a glueless memory interface to external memory using common address,
data bus and dedicated control signals. The SMC is highly programmable and has up to 24
bits of address bus, a 16-bit data bus and up to four chip select lines. The SMC supports differ-
ent access protocols allowing single clock-cycle accesses. The SMC is programmed as an
internal peripheral that has a standard APB bus interface and a set of memory-mapped regis-
ters. It shares the external address and data buses with the SDRAMC and any external bus
master.
42 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
This option is controlled by the BAT bit in the Chip Select Register (SMC_CSR0 to
SMC_CSR3).
The Byte Write Mode is used to connect two 8-bit devices on a 16-bit bus.
• The NWE0 signal is used as the write enable signal for byte 0.
• The NWE1 signal is used as the write enable signal for byte 1.
• The NSOE signal enables memory reads to all memory blocks.
The Byte Select Mode is used to connect one 16-bit device on a 16-bit data bus.
• The NWE0 signal is used to select byte 0 for read and write operations.
• The NWE1 signal is used to select byte 1 for read and write operations.
• The NWR signal is used as the write enable signal for the memory block.
• The NSOE signal enables memory reads to the memory block.
43
6069C–ATARM–15-Sep-05
15.5 Write Protocol
During a write cycle, the data becomes valid after the falling edge of the write strobe signal
and remains valid after the rising edge of the write strobe. The external write strobe waveform
on the appropriate write strobe pin is used to control the output data timing to guarantee this
operation.
Thus, it is necessary to avoid excessive loading of the write strobe pins, which could delay the
write signal too long and cause a contention with a subsequent read cycle in standard proto-
col. In early read protocol, the data can remain valid longer than in standard read protocol due
to the additional wait cycle that follows a write access.
44 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
15.7 SMC User Interface
The memory control register (SMC_MCR) is used to program the number of active chip
selects and data read protocol. Four chip select registers (SMC_CSR0 to SMC_CSR3) are
used to program the parameters for the individual external memories. Each SMC_CSR must
be programmed with a different base address, even for unused chip selects.
During the boot sequence, the Chip Select Registers must be programmed as required
depending on the devices connected on the external bus. The chip select addresses that are
programmed take effect immediately. Wait states also take effect immediately when they are
programmed to optimize boot program execution.
45
6069C–ATARM–15-Sep-05
15.7.1 SMC Chip Select Register
Register Name: SMC_CSR0..SMC_CSR3
Access: Read/Write
31 30 29 28 27 26 25 24
BA
23 22 21 20 19 18 17 16
BA – – – –
15 14 13 12 11 10 9 8
– – CSEN BAT TDF PAGES
7 6 5 4 3 2 1 0
PAGES MWS WSE NWS DBW
46 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• PAGES: Page Size
47
6069C–ATARM–15-Sep-05
15.7.2 SMC Memory Control Register
Register Name: SMC_MCR
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
– – – DRP – – – –
48 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16. Ethernet MAC (EMAC)
The AT91C140 features two identical Ethernet MACs, both of which feature the following:
• Compatible with IEEE Standard 802.3
• 10 and 100 Mbits per Second Data Throughput Capability
• Full- and Half-duplex Operation
• Media Independent Interface to the Physical Layer
• Register Interface to Address, Status and Control Registers
• DMA Interface
• Interrupt Generation to Signal Receive and Transmit Completion
• 28-byte Transmit and 28-byte Receive FIFOs
• Automatic Pad and CRC Generation on Transmitted Frames
• Address Checking Logic to Recognize Four 48-bit Addresses
• Supports Promiscuous Mode Where All Valid Frames are Copied to Memory
• Supports Physical Layer Management through MDIO Interface
The Ethernet MAC is the hardware implementation of the MAC sub-layer OSI reference model
between the physical layer (PHY) and the logical link layer (LLC). It controls the data
exchange between a host and a PHY layer according to Ethernet IEEE 802.3 data frame for-
mat. The Ethernet MAC contains the required logic and transmit and receive FIFOs for DMA
management. In addition, it is interfaced through MDIO/MDC pins for PHY layer management.
The Ethernet MAC transfers data in media-independent interface (MII).
MAC
ASB
DMA Mx_TXCLK, Mx_RXCLK
Mx_TXEN, Mx_TXER
APB Bridge
Mx_CRS, Mx_COL
Mx_RXER, Mx_RXDV
APB
Ethernet MAC
Mx_RXD[3:0]
Mx_TXD[3:0]
Mx_MDC
ACLK
Mx_MDIO
Interrupt Control
EMAC IRQ
49
6069C–ATARM–15-Sep-05
16.2 Media Independent Interface
Table 16-1. Pin Configuration
MII Signal Signal Name Pin Name EMAC A Pin Name EMAC B
Transmit Clock ETXCK MA_TXCLK MB_TXCLK
Carrier Sense ECRS MA_CRS MB_CRS
Collision Detect ECOL MA_COL MB_COL
Receive Data Valid ERXDV MA_RXDV MB_RXDV
4-bit Receive Data ERX0-ERX3 MA_RXD[0:3] MB_RXD[0:3]
Receive Error ERXER MA_RXER MB_RXER
Receive Clock ERXCK MA_RXCLK MB_RXCLK
Transmit Enable ETXEN MA_TXEN MB_TXEN
4-bit Transmit Data ETX0-ETX3 MA_TXD[0:3] MB_TXD[0:3]
Transmit Error ETXER MA_TXER MB_TXER
50 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
value indexes a 64-bit array that filters the value. If the address consists of all ones, it is a
broadcast address, indicating that the packet is intended for all nodes.
16.3.4 Length/Type
If the value of this field is less than or equal to 1500, then the Length/Type field indicates the
number of bytes in the subsequent LLC Data field. If the value of this field is greater than or
equal to 1536, then the Length/Type field indicates the nature of the MAC client protocol (pro-
tocol type).
51
6069C–ATARM–15-Sep-05
• The following one bit is a Canonical Format Indicator (CFI) used in Ethernet frames to
indicate the presence of a Routing Information Field (RIF).
• The last twelve bits are the VLAN Identifier (VID) that uniquely identifies the VLAN to which
the Ethernet frame belongs.
With the addition of VLAN tagging, the 802.3ac standard permits the maximum length of an
Ethernet frame to be extended from 1518 bytes to 1522 bytes. Table 16-3 on page 52 illus-
trates the format of an Ethernet frame that has been “tagged” with a VLAN identifier according
to the IEEE 802.3ac standard.
52 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Reading the transmit control register returns the total number of bytes to be transmitted. The
BNQ bit in the Transmit Status Register indicates whether another buffer can be safely
queued. An interrupt is generated whenever this bit is set.
Frame assembly starts by adding preamble and the start frame delimiter. Data is taken from
the transmit FIFO word-by-word. If necessary, padding is added to make the frame length 60
bytes. The CRC is calculated as a 32-bit polynomial. This is inverted and appended to the end
of the frame, making the frame length a minimum of 64 bytes. The CRC is not appended if the
NCRC bit is set in the transmit control register.
In full-duplex mode, frames are transmitted immediately. Back-to-back frames are transmitted
at least 96 bit times apart to guarantee the inter-frame gap.
In half-duplex mode, the transmitter checks carrier sense. If asserted, it waits for it to de-assert
and then starts transmission after the inter-frame gap of 96 bit-times.
If the collision signal is asserted during transmission, the transmitter transmits a jam sequence
of 32 bits taken from the data register and then retries transmission after the backoff time has
elapsed. An error is indicated and any further attempts aborted if 16 attempts cause collisions.
If transmit DMA underruns, bad CRC is automatically appended using the same mechanism
as jam insertion. Underrun also causes TXER to be asserted.
53
6069C–ATARM–15-Sep-05
entry. The received buffer queue pointer register must be written with zero in its lower-order bit
positions to enable the wrap function to work correctly.
If bit zero is set when the receive buffer manager reads the location of the receive buffer, then
the buffer has already been used and cannot be used again until software has processed the
frame and cleared bit zero. In this case, the DMA block sets the buffer unavailable bit in the
received status register and triggers an interrupt. The frame is discarded and the queue entry
is reread on reception of the next frame to see if the buffer is now available. Each discarded
frame increments a statistics register that is cleared on being read. When there is network
congestion, it is possible for the MAC to be programmed to apply back pressure.
This is when half-duplex mode collisions are forced on all received frames by transmitting 64
bits of data (a default pattern).
Reading the received buffer queue register returns the location of the queue entry currently
being accessed. The queue wraps around to the start after either 1024 entries (i.e., 2048
words) or when the wrap bit is found to be set in bit 1 of the first word of an entry.
54 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.5 Address Checking
Whether or not a frame is stored depends on what is enabled in the network configuration reg-
ister, the contents of the specific address and hash registers and the frame destination
address. In this implementation of the MAC the frame source address is not checked.
A frame is not copied to memory if the MAC is transmitting in half-duplex mode at the time a
destination address is received.
The hash register is 64 bits long and takes up two locations in the memory map.
There are four 48-bit specific address registers, each taking up two memory locations. The
first location contains the first four bytes of the address; the second location contains the last
two bytes of the address stored in its least significant byte positions. The addresses stored
can be specific, group, local or universal.
Ethernet frames are transmitted a byte at a time, LSB first. The first bit (i.e., the LSB of the first
byte) of the destination address is the group/individual bit and is set one for multicast
addresses and zero for unicast. This bit corresponds to bit 24 of the first word of the specific
address register. The MSB of the first byte of the destination address corresponds to bit 31 of
the specific address register.
The specific address registers are compared to the destination address of received frames
once they have been activated. Addresses are deactivated at reset or when the first byte
[47:40] is written and activated or when the last byte [7:0] is written. If a receive frame address
matches an active address, the local match signal is set and the store frame pulse signal is
sent to the DMA block via the ACLK synchronization block.
A frame can also be copied if a unicast or multicast hash match occurs, it has the broadcast
address of all ones, or the copy all frames bit in the network configuration register is set.
The broadcast address of 0xFFFFFFFF is recognized if the no broadcast bit in the network
configuration register is zero. This sets the broadcast match signal and triggers the store
frame signal.
The unicast hash enable and the multicast hash enable bits in the network configuration regis-
ter enable the reception of hash matched frames. So all multicast frames can be received by
setting all bits in the hash register.
The CRC algorithm reduces the destination address to a 6-bit index into a 64-bit hash regis-
ter.If the equivalent bit in the register is set, the frame is matched depending on whether the
frame is multicast or unicast and the appropriate match signals are sent to the DMA block. If
the copy all frames bit is set in the network configuration register, the store frame pulse is
always sent to the DMA block as soon as any destination address is received.
55
6069C–ATARM–15-Sep-05
16.6 EMAC User Interface
MACA Memory Address: 0xFF034000
MACB Memory Address: 0xFF038000
56 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Table 16-5. Ethernet MAC Register Mapping (Continued)
Offset Register Name Register Description Read/Write Reset
0x90 ETH_HSH Hash Address High [63:32] Read/Write 0x0
0x94 ETH_HSL Hash Address Low [31:0] Read/Write 0x0
0x98 ETH_SA1L Specific Address 1 Low, First 4 Bytes Read/Write 0x0
0x9C ETH_SA1H Specific Address 1 High, Last 2 Bytes Read/Write 0x0
0xA0 ETH_SA2L Specific Address 2 Low, First 4 Bytes Read/Write 0x0
0xA4 ETH_SA2H Specific Address 2 High, Last 2 Bytes Read/Write 0x0
0xA8 ETH_SA3L Specific Address 3 Low, First 4 Bytes Read/Write 0x0
0xAC ETH_SA3H Specific Address 3 High, Last 2 Bytes Read/Write 0x0
0xB0 ETH_SA4L Specific Address 4 Low, First 4 Bytes Read/Write 0x0
0xB4 ETH_SA4H Specific Address 4 High, Last 2 Bytes Read/Write 0x0
Note: 1. For further details on the statistics registers, see Table 16-6, “Statistics Register Block,” on page 71.
57
6069C–ATARM–15-Sep-05
16.6.1 EMAC Control Register
Register Name: ETH_CTL
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
– – – – – – – BP
7 6 5 4 3 2 1 0
WES ISR CSR MPE TE RE LBL LB
• LB: Loopback
. When set, loopback signal is at high level.
• LBL: Loopback Local
When set, connects ETX[3:0] to ERX[3:0], ETXEN to ERXDV, forces full duplex and drives ERXCK and ETXCK_REFCK
with ACK divided by 4.
• RE: Receive Enable
When set, enables the Ethernet MAC to receive data.
• TE: Transmit Enable
When set, enables the Ethernet transmitter to send data.
• MPE: Management Port Enable
Set to one to enable the management port. When zero, forces MDIO to high impedance state.
• CSR: Clear Statistics Registers
This bit is write-only. Writing a one clears the statistics registers.
• ISR: Increment Statistics Registers
This bit is write-only. Writing a one increments all the statistics registers by one for test purposes.
• WES: Write Enable for Statistics Registers
Setting this bit to one makes the statistics registers writable for functional test purposes.
• BP: Back Pressure
If this field is set, then in half-duplex mode collisions are forced on all received frames by transmitting 64 bits of data
(default pattern).
58 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.6.2 EMAC Mode Register
Name: ETH_CFG
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
– – – RTY CLK EAE BIG
7 6 5 4 3 2 1 0
UNI MTI NBC CAF – BR FD SPD
• SPD: Speed
Set to 1 to indicate 100 Mbit/sec, 0 for 10 Mbit/sec. Has no other functional effect.
• FD: Full Duplex
If set to 1, the transmit block ignores the state of collision and carrier sense and allows receive while transmitting.
• BR: Bit Rate
• CAF: Copy All Frames
When set to 1, all valid frames are received.
• NBC: No Broadcast
When set to 1, frames addressed to the broadcast address of all ones are not received.
• MTI: Multicast Hash Enable
When set multicast frames are received when six bits of the CRC of the destination address point to a bit that is set in the
hash register.
• UNI: Unicast Hash Enable
When set, unicast frames are received when six bits of the CRC of the destination address point to a bit that is set in the
hash register.
• BIG: Receive 1522 Bytes
When set, the MAC receives up to 1522 bytes. Normally the MAC receives frames up to 1518 bytes in length.
This bit allows to receive extended Ethernet frame with “VLAN tag” (IEEE 802.3ac)
• EAE: External Address Match Enable
• CLK
The ARM clock is divided down to generate MDC (the clock for the MDIO). To conform with IEEE standard 802.3 MDC
must not exceed 2.5 MHz. At reset this field is set to 10 so that ACK is divided by 32.
CLK MDC
00 ACK divided by 8
01 ACK divided by 16
10 ACK divided by 32
11 ACK divided by 64
59
6069C–ATARM–15-Sep-05
16.6.3 EMAC Status Register
Name: ETH_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
– – – – – IDLE MDIO LINK
• LINK
0 = LINK is at 0.
1 = LINK is at 1.
• MDIO
0 = MDIO pin not set.
1 = MDIO pin set.
• IDLE
0 = PHY logic is idle.
1 = PHY logic is running.
60 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.6.4 EMAC Transmit Address Register
Name: ETH_TAR
Access Type: Read/Write
31 30 29 28 27 26 25 24
ADDRESS
23 22 21 20 19 18 17 16
ADDRESS
15 14 13 12 11 10 9 8
ADDRESS
7 6 5 4 3 2 1 0
ADDRESS
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
NCRC – – – – LEN
7 6 5 4 3 2 1 0
LEN
61
6069C–ATARM–15-Sep-05
16.6.6 EMAC Transmit Status Register
Name: ETH_TSR
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
– UND COMP BNQ IDLE RLE COL OVR
62 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.6.7 EMAC Receive Buffer Queue Pointer Register
Name: ETH_RBQP
Access Type: Read/Write
31 30 29 28 27 26 25 24
ADDRESS
23 22 21 20 19 18 17 16
ADDRESS
15 14 13 12 11 10 9 8
ADDRESS
7 6 5 4 3 2 1 0
ADDRESS
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – – – – OVR REC BNA
63
6069C–ATARM–15-Sep-05
16.6.9 EMAC Interrupt Status Register
Name: ETH_ISR
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
– – – – ABT ROVR LINK TIDLE
7 6 5 4 3 2 1 0
TCOM TBRE RTRY TUND TOVR RBNA RCOM DONE
64 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.6.10 EMAC Interrupt Enable Register
Name: ETH_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
– – – – ABT ROVR LINK TIDLE
7 6 5 4 3 2 1 0
TCOM TBRE RTRY TUND TOVR RBNA RCOM DONE
65
6069C–ATARM–15-Sep-05
16.6.11 EMAC Interrupt Disable Register
Name: ETH_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
– – – – ABT ROVR LINK TIDLE
7 6 5 4 3 2 1 0
TCOM TBRE RTRY TUND TOVR RBNA RCOM DONE
66 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.6.12 EMAC Interrupt Mask Register
Name: ETH_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
– – – – ABT ROVR LINK TIDLE
7 6 5 4 3 2 1 0
TCOM TBRE RTRY TUND TOVR RBNA RCOM DONE
Important Note: The interrupt is disabled when the corresponding bit is set. This is non-standard with other peripherals of
the product, as generally a mask bit set enables the interrupt.
67
6069C–ATARM–15-Sep-05
16.6.13 EMAC PHY Maintenance Register
Name: ETH_MAN
Access Type: Read/Write
31 30 29 28 27 26 25 24
LOW HIGH RW PHYA
23 22 21 20 19 18 17 16
PHYA REGA CODE
15 14 13 12 11 10 9 8
DATA
7 6 5 4 3 2 1 0
DATA
Writing to this register starts the shift register that controls the serial connection to the PHY. On each shift cycle the MDIO
pin becomes equal to the MSB of the shift register and LSB of the shift register becomes equal to the value of the MDIO
pin. When the shifting is complete an interrupt is generated and the IDLE field is set in the Network Status register.
When read, gives current shifted value.
• DATA
For a write operation this is written with the data to be written to the PHY. After a read operation this contains the data read
from the PHY.
• CODE
Must be written to 10 in accordance with IEEE standard 802.3. Reads as written.
• REGA
Register address. Specifies the register in the PHY to access.
• PHYA
PHY address. Normally is 0.
• RW
Read/Write Operation. 10 is read. 01 is write. Any other value is an invalid PHY management frame.
• HIGH
Must be written with 1 to make a valid PHY management frame. Conforms with IEEE standard 802.3.
• LOW
Must be written with 0 to make a valid PHY management frame. Conforms with IEEE standard 802.3.
68 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.6.14 EMAC Hash Address High Register
Register Name: ETH_HSH
Access Type: Read/Write
31 30 29 28 27 26 25 24
ADDR
23 22 21 20 19 18 17 16
ADDR
15 14 13 12 11 10 9 8
ADDR
7 6 5 4 3 2 1 0
ADDR
• ADDR
Hash address bits 63 to 32.
23 22 21 20 19 18 17 16
ADDR
15 14 13 12 11 10 9 8
ADDR
7 6 5 4 3 2 1 0
ADDR
• ADDR
Hash address bits 31 to 0.
69
6069C–ATARM–15-Sep-05
16.6.16 EMAC Specific Address (1, 2, 3 and 4) High Register
Register Name: ETH_SA1H,...ETH_SA4H
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
ADDR
7 6 5 4 3 2 1 0
ADDR
• ADDR
Unicast addresses (1, 2, 3 and 4), Bits 47:32.
23 22 21 20 19 18 17 16
ADDR
15 14 13 12 11 10 9 8
ADDR
7 6 5 4 3 2 1 0
ADDR
• ADDR
Unicast addresses (1, 2, 3 and 4), Bits 31:0.
70 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
16.7 EMAC Statistics Register Block Registers
These registers reset to zero on a read and remain at all ones when they count to their maxi-
mum value. They should be read frequently enough to prevent loss of data.
The statistics register block contains the registers found in Table 16-5, “Ethernet MAC Regis-
ter Mapping,” on page 56.
71
6069C–ATARM–15-Sep-05
Table 16-6. Statistics Register Block (Continued)
Register Register Description
Name
An 8-bit register counting the number of frames received that are less than 64
Undersize Frame Register ETH_USF bytes in length but that do not have either a CRC error, an alignment error or a
code error.
An 8-bit register counting the number of frames where pin ECOL was not
SQE Test Error Register ETH_SQEE
asserted within a slot time of pin ETXEN being deasserted.
This 16-bit counter is incremented every time an address-recognized frame is
Discarded RX Frame Register ETH_DRFC
received but cannot be copied to memory because the receive buffer is available.
72 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17. Advanced Interrupt Controller (AIC)
The AT91C140 integrates the Atmel advanced interrupt controller (AIC).
The interrupt controller is connected to the fast interrupt request (nFIQ) and the standard inter-
rupt request (NIRQ) inputs of the ARM7TDMI processor. The processor’s nFIQ line can only
be asserted by the external fast interrupt request input (FIQ). The nIRQ line can be asserted
by the interrupts generated by the on-chip peripherals and the two external interrupt request
lines, IRQ0 to IRQ1.
An 8-level priority encoder allows the user to define the priority between the different interrupt
sources. Internal sources are programmed to be level-sensitive or edge-triggered. External
sources can be programmed to be positive- or negative-edge triggered or high- or low-level
sensitive.
NFIQ NFIQ
FIQ Source Memorization Manager
73
6069C–ATARM–15-Sep-05
Table 17-1. Interrupt Sources (Continued)
Interrupt Source Interrupt Name Interrupt Description
11 IRQ1 External Interrupt
12 Reserved
13 MACB MAC B Interrupt
14 UARTB UART B Interrupt
15 PIOB PIO B Interrupt
16 - 31 Reserved
74 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17.2.2 Interrupt Clearing and Setting
All interrupt sources which are programmed to be edge-triggered (including FIQ) can be indi-
vidually set or cleared by respectively writing to the registers AIC_ISCR and AIC_ICCR. This
function of the interrupt controller is available for auto-test or software debug purposes.
75
6069C–ATARM–15-Sep-05
10. The SPSR (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 the
step previously executed, of loading the CPSR with the stored SPSR and of masking
or unmasking the interrupts depending on the state saved in the SPSR (the previous
state of the ARM core).
Note: The I bit in the SPSR is significant. If it is set, it indicates that the ARM core was just about to
mask IRQ interrupts when the mask instruction was interrupted. Hence, when the SPSR is
restored, the mask instruction is completed (IRQ is masked).
76 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
rupt to the step previously executed, of loading the CPSR with the SPSR and of
masking or unmasking the fast interrupt depending on the state saved in the SPSR.
Note: The F bit in the 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).
77
6069C–ATARM–15-Sep-05
17.7 AIC User Interface
Base Address: 0xFF030000 with double mapping at address 0xFFFF F000
Note: 1. The reset value of this register depends on the level of the external IRQ lines. All other sources are cleared at reset.
78 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17.7.1 AIC Source Mode Register
Register Name: AIC_SMR0...AIC_SMR31
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
– SRCTYPE – – PRIOR
79
6069C–ATARM–15-Sep-05
17.7.2 AIC Source Vector Registers
Register Name: AIC_SVR0...AIC_SVR31
Access Type: Read/Write
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
• Vector
In these registers, the user may store the addresses of the corresponding handler for each interrupt source.
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
• IRQV
The IRQ Vector Register contains the vector programmed by the user in the Source Vector Register corresponding to the
current interrupt. The SVR Register (1 to 31) is indexed by the current interrupt number when the IVR register is read.
When there is no interrupt, the IRQ register reads 0.
80 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17.7.4 AIC FIQ Vector Register
Register Name: AIC_FVR
Access Type: Read-only
Reset Value: 0
31 30 29 28 27 26 25 24
FIQV
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
• FIQ
The vector register contains the vector programmed by the user in SVR Register 0 which corresponds to FIQ.
81
6069C–ATARM–15-Sep-05
17.7.5 AIC Interrupt Status Register
Register Name: AIC_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
– – – IRQID
• IRQID
The interrupt status register returns the current interrupt source register.
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
PIOB UARTB MACB 0 IRQ1 IRQ0 SPI MACA
7 6 5 4 3 2 1 0
PIOA TC2 TC1 TC0 UARTA SWI 0 FIQ
• Interrupt Pending
0 = Corresponding interrupt is not pending.
1 = Corresponding interrupt is pending.
82 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17.7.7 AIC Interrupt Mask Register
Register Name: AIC_IMR
Access Type: Read-only
31 30 29 28 27 26 25 24
0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
PIOB UARTB MACB 0 IRQ1(1) IRQ0 SPI MACA
7 6 5 4 3 2 1 0
PIOA TC2 TC1 TC0 UARTA SWI 0 FIQ
• Interrupt Mask
0 = Corresponding interrupt is disabled.
1 = Corresponding interrupt is enabled.
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 nFIQ
83
6069C–ATARM–15-Sep-05
17.7.9 AIC Interrupt Enable Command Register
Register Name: AIC_IECR
Access Type: Write-only
31 30 29 28 27 26 25 24
0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
PIOB UARTB MACB 0 IRQ1 IRQ0 SPI MACA
7 6 5 4 3 2 1 0
PIOA TC2 TC1 TC0 UARTA SWI 0 FIQ
• Interrupt Enable
0 = No effect.
1 = Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
PIOB UARTB MACB 0 IRQ1 IRQ0 SPI MACA
7 6 5 4 3 2 1 0
PIOA TC2 TC1 TC0 UARTA SWI 0 FIQ
• Interrupt Disable
0 = No effect.
1 = Disables the corresponding interrupt.
84 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17.7.11 AIC Interrupt Clear Command Register
Register Name: AIC_ICCR
Access Type: Write-only
31 30 29 28 27 26 25 24
0 0 0 0 0 0 0 0
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
PIOB UARTB MACB 0 IRQ1 IRQ0 SPI MACA
7 6 5 4 3 2 1 0
PIOA TC2 TC1 TC0 UARTA SWI 0 FIQ
• Interrupt Clear
0 = No effect.
1 = Clears the corresponding interrupt.
23 22 21 20 19 18 17 16
0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
PIOB UARTB MACB 0 IRQ1 IRQ0 SPI MACA
7 6 5 4 3 2 1 0
PIOA TC2 TC1 TC0 UARTA SWI 0 FIQ
• Interrupt Set
0 = No effect.
1 = Sets the corresponding interrupt.
85
6069C–ATARM–15-Sep-05
17.7.13 AIC End of Interrupt Command Register
Register Name: AIC_EOICR
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
– – – – – – – –
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 as it is only necessary to make a write to this register location to signal the end of interrupt
treatment.
23 22 21 20 19 18 17 16
SIQV
15 14 13 12 11 10 9 8
SIQV
7 6 5 4 3 2 1 0
SIQV
• SIQV
This register contains the 32-bit address of an interrupt routine which is used to treat cases of spurious interrupts.
The programmed address is read in the AIC_IVR if it is read when the nIRQ line is not asserted.
The programmed address is read in the AIC_FVR if it is read when the nFIQ line is not asserted.
86 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
18. Parallel I/O Controller (PIO)
The AT91C140 integrates two PIO controllers, PIOA and PIOB. PIOA controls 15 I/O lines and
PIOB controls 10 I/O lines. Each I/O line can be programmed as an input or an output and can
generate an interrupt on level change.
These pins are used for several functions:
• External I/O for Internal Peripherals
• Keypad Controller Function
• General Purpose I/O
18.3 Interrupts
Each parallel I/O can be programmed to generate an interrupt when a level change occurs.
This is controlled by the PIO_IER and PIO_IDR registers which enable/disable the I/O inter-
rupt by setting/clearing the corresponding bit in PIO_IMR. When a change in level occurs, the
corresponding bit in PIO_ISR is set depending on whether the pin is used as a PIO or a
peripheral, and whether it is defined as input or output. If the corresponding interrupt in
PIO_IMR is enabled, the PIO interrupt is asserted.
When PIO_ISR is read, the register is automatically cleared.
87
6069C–ATARM–15-Sep-05
18.4 I/O Line Control
PIO_OSR
1
Pad Output Enable
Peripheral
0 Output
Enable
PIO_PSR
PIO_ODSR
1
Pad Output
0 Peripheral
Output
Pad
Pad Input
0
Peripheral
Input
1
PIO_PSR
PIO_PDSR
Event
Detection
PIO_ISR
PIO_IMR
PIOIRQ
88 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
18.5 Parallel I/O Controller (PIO) User Interface
Each individual I/O is associated with a bit position in the parallel I/O user interface registers. Each of these registers is 32
bits wide. If a parallel I/O line is not defined, writing to the corresponding bits has no effect. Undefined bits read as zero.
Notes: 1. The reset value of this register depends on the level of the external pins at reset.
2. This register is cleared at reset. However, the first read of the register can give a value not equal to zero if any changes have
occurred on any pins between the reset and the read.
89
6069C–ATARM–15-Sep-05
18.5.1 PIO Enable Register
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
This register is used to enable individual pins to be controlled by the PIO controller instead of the associated peripheral.
When the PIO is enabled, the associated peripheral (if any) is held at logic zero.
1 = Enables the PIO to control the corresponding pin (disables peripheral control of the pin).
0 = No effect.
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
This register is used to disable PIO control of individual pins. When the PIO control is disabled, the normal peripheral func-
tion is enabled on the corresponding pin.
1 = Disables PIO control (enables peripheral control) on the corresponding pin.
0 = No effect.
90 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
18.5.3 PIO Status Register
Register Name: PIO_PSR
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
This register indicates which pins are enabled for PIO control. This register is updated when PIO lines are enabled or
disabled.
1 = PIO is active on the corresponding line (peripheral is inactive).
0 = PIO is inactive on the corresponding line (peripheral is active).
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
This register is used to enable PIO output drivers. If the pin is driven by a peripheral, there is no effect on the pin but the
information is stored. The register is programmed as follows:
1 = Enables the PIO output on the corresponding pin.
0 = No effect.
91
6069C–ATARM–15-Sep-05
18.5.5 PIO Output Disable Register
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
This register is used to disable PIO output drivers. If the pin is driven by the peripheral, there is no effect on the pin, but the
information is stored. The register is programmed as follows:
1 = Disables the PIO output on the corresponding pin.
0 = No effect.
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
This register shows the PIO pin control (output enable) status which is programmed in PIO_OER and PIO ODR. The
defined value is effective only if the pin is controlled by the PIO. The register reads as follows:
1 = The corresponding PIO is output on this line.
0 = The corresponding PIO is input on this line.
92 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
18.5.7 PIO Set Output Data Register
Register Name: PIO_SODR
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
This register is used to set PIO output data. It affects the pin only if the corresponding PIO output line is enabled and if the
pin is controlled by the PIO. Otherwise, the information is stored.
1 = PIO output data on the corresponding pin is set.
0 = No effect.
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
This register is used to clear PIO output data. It affects the pin only if the corresponding PIO output line is enabled and if the
pin is controlled by the PIO. Otherwise, the information is stored.
1 = PIO output data on the corresponding pin is cleared.
0 = No effect.
93
6069C–ATARM–15-Sep-05
18.5.9 PIO Output Data Status Register
Register Name: PIO_ODSR
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
This register shows the output data status which is programmed in PIO_SODR or PIO_CODR. The defined value is effec-
tive only if the pin is controlled by the PIO Controller and only if the pin is defined as an output.
1 = The output data for the corresponding line is programmed to 1.
0 = The output data for the corresponding line is programmed to 0.
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
This register shows the state of the physical pin of the chip. The pin values are always valid, regardless of whether the pins
are enabled as PIO, peripheral, input or output. The register reads as follows:
1 = The corresponding pin is at logic 1.
0 = The corresponding pin is at logic 0.
94 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
18.5.11 PIO Interrupt Enable Register
Register Name: PIO_IER
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
This register is used to enable PIO interrupts on the corresponding pin. It has an effect whether PIO is enabled or not.
1 = Enables an interrupt when a change of logic level is detected on the corresponding pin.
0 = No effect.
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
This register is used to disable PIO interrupts on the corresponding pin. It has an effect whether the PIO is enabled or not.
1 = Disables the interrupt on the corresponding pin. Logic level changes are still detected.
0 = No effect.
95
6069C–ATARM–15-Sep-05
18.5.13 PIO Interrupt Mask Register
Register Name: PIO_IMR
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
This register shows which pins have interrupts enabled. It is updated when interrupts are enabled or disabled by writing to
PIO_IER or PIO_IDR.
1 = Interrupt is enabled on the corresponding pin.
0 = Interrupt is not enabled on the corresponding pin.
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
This register indicates for each pin when a logic value change has been detected (rising or falling edge). This is valid
whether the PIO is selected for the pin or not and whether the pin is an input or an output.
The register is reset to zero following a read and at reset.
1 = At least one input change has been detected on the corresponding pin since the register was last read.
0 = No input change has been detected on the corresponding pin since the register was last read.
96 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19. Universal Asynchronous Receiver Transmitter (UART)
The AT91C140 provides two identical full-duplex Universal Asynchronous Receiver Transmit-
ters, UART A and UART B. These peripherals sit on the APB bus but are also connected to
the ASB bus (and hence external memory) via a dedicated PDC.
The main features are:
• Programmable Baud Rate Generator
• Parity, Framing and Overrun Error Detection
• Line Break Generation and Detection
• Automatic Echo, Local Loopback and Remote Loopback Channel Modes
• Interrupt Generation
• Two Dedicated Peripheral Data Controller Channels
• 6-, 7- and 8-bit Character Length
• Modem Control Signals
ARM
ASB
Receive Transmit
Channel Channel
UART
APB PIO
Control Logic
Receiver RXD
NRTS
NRI
NDTR
NDSR
NDCD
97
6069C–ATARM–15-Sep-05
19.2 Pin Description
Each UART channel has external signals as defined in Table 19-1.
98 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Figure 19-2. Baud Rate Generator
USCLKS [0] CD
CD
ACLK 0 CLK
16-bit Counter
OUT
ACLK/8 1 >1
1 Divide Baud Rate
by 16 Clock
0 0
16 x Baud
Rate Clock
RXD
Sampling
True Start D0
Detection
0.5-bit 1-bit
periods period
RXD
99
6069C–ATARM–15-Sep-05
19.4.1 Receiver Ready
When a complete character is received, it is transferred to the US_RHR and the RXRDY sta-
tus bit in US_CSR is set. If US_RHR has not been read since the last transfer, the OVRE
status bit in US_CSR is set.
19.4.4 Time-out
This function allows an idle condition on the RXD line to be detected. The maximum delay for
which the UART should wait for a new character to arrive while the RXD line is inactive (high
level) is programmed in US_RTOR. When this register is set to 0, no time-out is detected. Oth-
erwise, the receiver waits for a first character and then initializes a counter which is
decremented at each bit period and reloaded at each byte reception. When the counter
reaches 0, the TIMEOUT bit in US_CSR is set. The user can restart the wait for a first charac-
ter with the STTTO (Start Time-out) bit in US_CR.
Calculation of time-out duration:
Duration = Value × 4 × Bit Period
19.5 Transmitter
Start bit, data bits, parity bit and stop bits are serially shifted, lowest significant bit first, on the
falling edge of the serial clock.
The number of data bits is selected in the CHRL field in US_MR.
The parity bit is set according to the PAR field in US_MR.
The number of stop bits is selected in the NBSTOP field in US_MR.
When a character is written to US_THR, it is transferred to the Shift Register as soon as it is
empty. When the transfer occurs, the TXRDY bit in US_CSR is set until a new character is
written to US_THR. If the Transmit Shift Register and US_THR are both empty, the TXEMPTY
bit in US_CSR is set.
Baud Rate
Clock
TXD
100 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.5.1 Time-guard
The time-guard function allows the transmitter to insert an idle state on the TXD line between
two characters. The duration of the idle state is programmed in US_TTGR. When this register
is set to zero, no time-guard is generated. Otherwise, the transmitter holds a high level on TXD
after each transmitted byte during the number of bit periods programmed in US_TTGR.
Idle state duration = Time-guard x Bit
between two characters value period
Receiver RXD
Disabled
Transmitter TXD
Local Loopback
Disabled
Receiver RXD
VDD
Disabled
Transmitter TXD
Disabled
Transmitter TXD
101
6069C–ATARM–15-Sep-05
19.7 Peripheral Data Controller
Each UART channel is closely connected to a corresponding peripheral data controller chan-
nel. One is dedicated to the receiver, the other is dedicated to the transmitter.
The PDC channel is programmed using US_TPR and US_TCR for the transmitter and
US_RPR and US_RCR for the receiver. The status of the PDC is given in US_CSR by the
ENDTX bit for the transmitter and by the ENDRX bit for the receiver.
The pointer registers US_TPR and US_RPR are used to store the address of the transmit or
receive buffers. The counter registers US_TCR and US_RCR are used to store the size of
these buffers.
The receiver data transfer is triggered by the RXRDY bit and the transmitter data transfer is
triggered by TXRDY. When a transfer is performed, the counter is decremented and the
pointer is incremented. When the counter reaches 0, the status bit is set (ENDRX for the
receiver, ENDTX for the transmitter in US_CSR) and can be programmed to generate an inter-
rupt. Transfers are then disabled until a new non-zero counter value is programmed.
102 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
(TERI) of the Modem Status Register indicates whether the NRI input signal has changed from
a low to a high state since the previous read of the Modem Status Register.
103
6069C–ATARM–15-Sep-05
19.9 Universal Asynchronous Receiver/Transmitter (UART) User Interface
Table 19-3. UART Memory Map
Offset Register Name Description Access Reset Value
0x00 US_CR Control Register Write-only –
0x04 US_MR Mode Register Read/Write 0
0x08 US_IER Interrupt Enable Register Write-only –
0x0C US_IDR Interrupt Disable Register Write-only –
0x10 US_IMR Interrupt Mask Register Read-only 0
0x14 US_CSR Channel Status Register Read-only 0x18
0x18 US_RHR Receiver Holding Register Read-only 0
0x1C US_THR Transmitter Holding Register Write-only –
0x20 US_BRGR Baud Rate Generator Register Read/Write 0
0x24 US_RTOR Receiver Time-out Register Read/Write 0
0x28 US_TTGR Transmitter Time-guard Register Read/Write 0
0x2C – Reserved – –
0x30 US_RPR Receive Pointer Register Read/Write 0
0x34 US_RCR Receive Counter Register Read/Write 0
0x38 US_TPR Transmit Pointer Register Read/Write 0
0x3C US_TCR Transmit Counter Register Read/Write 0
0x40 US_MC Modem Control Register Write-only –
0x44 US_MS Modem Status Register Read-only
104 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.9.1 UART 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
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – RSTSTA
7 6 5 4 3 2 1 0
TXDIS TXEN RXDIS RXEN RSTTX RSTRX – –
• RSTRX: Reset Receiver
0 = No effect.
1 = The receiver logic is reset.
• RSTTX: Reset Transmitter
0 = No effect.
1 = The transmitter logic is reset.
• RXEN: Receiver Enable
0 = No effect.
1 = The receiver is enabled if RXDIS is 0.
• RXDIS: Receiver Disable
0 = No effect.
1 = The receiver is disabled.
• TXEN: Transmitter Enable
0 = No effect.
1 = The transmitter is enabled if TXDIS is 0.
• TXDIS: Transmitter Disable
0 = No effect.
1 = The transmitter is disabled.
• RSTSTA: Reset Status Bits
0 = No effect.
1 = Resets the status bits PARE, FRAME, OVRE and RXBRK in the US_CSR.
105
6069C–ATARM–15-Sep-05
19.9.2 UART Mode Register
Name: US_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 NBSTOP PAR –
7 6 5 4 3 2 1 0
CHRL USCLKS – – – –
NBSTOP
0 0 1 stop bit
0 1 1.5 stop bits
1 0 2 stop bits
1 1 Reserved
106 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• CHMODE: Channel Mode
107
6069C–ATARM–15-Sep-05
19.9.3 UART Interrupt Enable Register
Name: US_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
– – – – – DMSI TXEMPTY –
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX – TXRDY RXRDY
• RXRDY: Enable RXRDY Interrupt
• TXRDY: Enable TXRDY Interrupt
• ENDRX: Enable End of Receive Transfer Interrupt
• ENDTX: Enable End of Transmit Transfer Interrupt
• OVRE: Enable Overrun Error Interrupt
• FRAME: Enable Framing Error Interrupt
• PARE: Enable Parity Error Interrupt
• TXEMPTY: Enable TXEMPTY Interrupt
• DMSI: Delta Modem Interrupt
0 = No effect.
1 = Enables the corresponding interrupt.
108 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.10 UART 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
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – DMSI TXEMPTY –
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX – TXRDY RXRDY
109
6069C–ATARM–15-Sep-05
19.11 UART Interrupt Mask Register
Name: US_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
– – – – – DMSI TXEMPTY –
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK – RXRDY
110 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.11.1 UART 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
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – DMSI TXEMPTY –
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX – TXRDY RXRDY
111
6069C–ATARM–15-Sep-05
19.11.2 UART Receiver Holding Register
Name: US_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
112 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.11.4 UART 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
– – – – – – – –
15 14 13 12 11 10 9 8
CD
7 6 5 4 3 2 1 0
CD
CD Effect
0 Disables clock
1 Clock divisor bypass
2 to 65535 Baud rate = Selected clock/(16 x CD)
113
6069C–ATARM–15-Sep-05
19.11.5 UART Receive Pointer Register
Name: US_RPR
Access Type: Read/Write
31 30 29 28 27 26 25 24
RXPTR
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
114 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.11.7 UART Transmit Pointer Register
Name: US_TPR
Access Type: Read/Write
Reset Value: 0x0
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
115
6069C–ATARM–15-Sep-05
19.11.9 Modem Control Register
Register Name: US_MC
Access Type: Write-only
Reset Value: Undefined
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
– – – – – – RTS DTR
This register controls the interface with the modem or data set (or a peripheral device emulating a modem). The contents of
the Control Register are indicated below.
• DTR: Data Terminal Ready
This bit controls the NDTR output. When bit 0 is set to a logic 1, the NDTR output is forced to a logic 0.
When bit 0 is reset to a logic 0, the NDTR output is forced to a logic 1.
The NDTR output of the UART can be applied to an EIA inverting line driver to obtain proper polarity input at the succeed-
ing modem or data set.
• RTS: Request to Send
This bit controls the NRTS output. Bit 1 affects the NRTS output in a manner identical to that described above for bit 0.
116 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
19.11.10 Modem Status Register
Register Name: US_MS
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
DCD RI DSR CTS DDCD TERI DDSR DCTS
This register provides the current state of the control lines from the modem (or peripheral device) to the CPU. In addition to
this current-state information, four bits of the Modem Status Register provide change information. These bits are set to a
logic 1 whenever a control input from the modem changes state. They are reset to logic 0 whenever the CPU reads the
Modem Status Register.
• DCTS: Delta Clear to Send
Bit 0 indicates that the NCTS input to the chip has changed state since the last time it was read by the CPU.
• DDSR: Delta Data Set Ready
Bit 1 indicates that the NDSR input to the chip has changed state since the last time it was read by the CPU.
• TERI: Trailing Edge Ring Indicator
Bit 2 indicates that the NRI input to the chip has changed from a low to a high state.
• DDCD: Delta Data Carrier Detect
Bit 3 indicates that the NDCD input has changed state.
Note that whenever bit 0, 1, 2, or 3 is set to logic 1, a modem status interrupt is generated. This is reflected in the modem
status register.
• CTS: Clear to Send
This bit is the complement of the Clear to Send (NCTS) input.
• DSR: Data Set Ready
This bit is the complement of the Data Set Ready (NDSR) input.
• RI: Ring Indicator
This bit is the complement of the Ring Indicator (NRI) input.
• DCD: Data Carrier Detect
This bit is the complement of the Data Carrier Detect (NDCD) input.
117
6069C–ATARM–15-Sep-05
20. Timer/Counter (TC)
The AT91C140 features a timer/counter block that includes three identical 16-bit timer/counter
channels. Each channel can be independently programmed to perform a wide range of func-
tions including frequency measurement, event counting, interval measurement, pulse
generation, delay timing and pulse-width modulation.
Each timer/counter channel has three external clock inputs, five internal clock inputs, and two
multi-purpose input/output signals that can be configured by the user. Each channel drives an
internal interrupt signal that can be programmed to generate processor interrupts via the AIC.
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 timer/counter
channel, allowing them to be chained.
Parallel I/O
Controller
ACLK/2 TCLK0
TCLK0
TCLK1
ACLK/8 TIOA1 TCLK2
TIOA2 XC0 Timer/Counter
ACLK/32 TIOA
TCLK1 XC1 Channel 0 TIOA0 TIOA0
TIOB TIOB0
ACLK/128 TCLK2 XC2 TIOB0
TC0XC0S SYNC
ACLK/1024 INT
TCLK0
TCLK2 SYNC
INT
TC1XC1S
Timer/Counter Block
Advanced
Interrupt
Controller
118 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
20.2 Signal Name Description
20.3 Description
The three timer/counter channels are independent and identical in operation.
20.3.1 Counter
Each timer/counter channel is organized around a 16-bit counter. The value of the counter is
incremented at each positive edge of the selected clock. When the counter has reached the
value 0xFFFF and passes to 0x0000, an overflow occurs and the COVFS bit in TC_SR (Sta-
tus Register) is set.
The current value of the counter is accessible in real time by reading TC_CV. The counter can
be reset by a trigger. In this case, the counter value passes to 0x0000 on the next valid edge
of the selected clock.
119
6069C–ATARM–15-Sep-05
The selected clock can be inverted with the CLKI bit in TC_CMR (Channel Mode). This allows
counting on the opposite edges of the clock.
The burst function allows the clock to be validated when an external signal is high. The
BURST parameter in the Mode Register defines this signal (none, XC0, XC1, XC2).
Note: In all cases, if an external clock is used, the duration of each of its levels must be longer than the
system clock (ACLK) period. The external clock frequency must be at least 2.5 times lower than
the system clock (ACLK).
CLKS
CLKI
ACLK/2
ACLK/8
ACLK/32
ACLK/128
Selected
ACLK/1024
Clock
XC0
XC1
XC2
BURST
120 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
The timer/counter operating mode is programmed with the WAVE bit in the TC Mode Register.
In capture mode, TIOA and TIOB are configured as inputs. In waveform mode, TIOA is always
configured to be an output and TIOB is an output if it is not selected to be the external trigger.
Q S
R
Q S
R
Stop Disable
Counter Event Event
Clock
20.3.5 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:
1. Software trigger: Each channel has a software trigger, available by setting SWTRG in
TC_CCR.
2. SYNC: Each channel has a synchronization signal, SYNC. When asserted, this sig-
nal has the same effect as a software trigger. The SYNC signals of all channels are
asserted simultaneously by writing TC_BCR (Block Control) with SYNC set.
3. Compare RC trigger: RC is implemented in each channel and can provide a trigger
when the counter value matches the RC value if CPCTRG is set in TC_CMR.
The timer/counter channel can also be configured to have an external trigger. In capture
mode, the external trigger signal can be selected between TIOA and TIOB. In waveform
mode, an external event can be programmed on one of the following signals: TIOB, XC0, XC1
or XC2. This external event can then be programmed to perform a trigger by setting ENETRG
in TC_CMR.
If an external trigger is used, the duration of the pulses must be longer than the system clock
(ACLK) period in order to be detected.
Whatever the trigger used, it will be taken into account at the following active edge of the
selected clock. This means that the counter value may not read zero just after a trigger, espe-
cially when a low-frequency signal is selected as the clock.
121
6069C–ATARM–15-Sep-05
20.4 Capture Operating Mode
This mode is entered by clearing the WAVE parameter in TC_CMR (Channel Mode Register).
Capture mode allows the TC Channel to perform measurements such as pulse timing, fre-
quency, period, duty cycle and phase on TIOA and TIOB signals which are inputs.
Figure 20-4 shows the configuration of the TC Channel when programmed in capture mode.
122 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Figure 20-4. Capture Mode
TCCLKS
CLKSTA CLKEN CLKDIS
CLKI
ACLK/2
ACLK/8
ACLK/32
Q S
ACLK/128
ACLK/1024
R
Q S
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
ETRGEDG CPCTRG
MTIOB Edge
Detector
ETRGS
COVFS
LOVRS
LDRAS
LDRBS
TC_SR
CPCS
MTIOA Edge Edge
Detector Detector
If RA is not loaded
or RB is loaded If RA is loaded
TC_IMR
TIOA
Timer/Counter Channel
INT
123
6069C–ATARM–15-Sep-05
RC Compare can also stop the counter clock (CPCSTOP = 1 in TC_CMR) and/or disable the
counter clock (CPCDIS = 1 in TC_CMR).
As in capture mode, RC Compare can also generate a trigger if CPCTRG = 1. A trigger resets
the counter so RC can control the period of PWM waveforms.
124 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
If two or more events occur at the same time, the priority level is defined as follows:
1. Software trigger
2. External event
3. RC compare
4. RA or RB compare
20.5.4 Status
The following bits in the status register are significant in waveform mode:
• CPAS: RA Compare Status
There has been a RA Compare match at least once since the last read of the status
• CPBS: RB Compare Status
There has been a RB Compare match at least once since the last read of the status
• CPCS: RC Compare Status
There has been a RC Compare match at least once since the last read of the status
• COVFS: Counter Overflow
Counter has attempted to count past $FFFF since the last read of the status
• ETRGS: External Trigger
External trigger has been detected since the last read of the status
125
6069C–ATARM–15-Sep-05
126
TCCLKS
CLKSTA CLKEN CLKDIS
ACPC
ACLK/2
CLKI
ACLK/8
ACLK/32
Q S
AT91C140
ACLK/128 CPCDIS MTIOA
ACPA
Figure 20-5. Waveform Mode
ACLK/1024
R
Q S
XC0
R
XC1
TIOA
XC2 CPCSTOP
AEEVT
Output Controller
BURST
Register A Register B Register C
ASWTRG
1 Compare RA = Compare RB = Compare RC =
16-bit Counter
CLK
OVF
RESET
SWTRG
BCPC
SYNC Trig
BCPB MTIOB
CPCTRG
EEVT TIOB
BEEVT
EEVTEDG
ENETRG
Output Controller
CPAS
CPBS
CPCS
TC_SR
ETRGS
COVFS
Edge
Detector BSWTRG
TIOB
TC_IMR
Timer/Counter Channel
INT
6069C–ATARM–15-Sep-05
AT91C140
20.6 Timer/Counter (TC) User Interface
Table 20-4. TC Global Memory Map
Offset Register Name Channel/Register Access Reset Value
0x00 TC Channel 0 See Table 20-5
0x40 TC Channel 1 See Table 20-5
0x80 TC Channel 2 See Table 20-5
0xC0 TC_BCR TC Block Control Register Write-only –
0xC4 TC_BMR TC Block Mode Register Read/Write 0
TC_BCR (Block Control Register) and TC_BMR (Block Mode Register) control the whole TC block. TC channels are con-
trolled by the registers listed in Table 20-5. The offset of each of the channel registers in Table 20-5 is in relation to the
offset of the corresponding channel as specified in Table 20-4.
127
6069C–ATARM–15-Sep-05
20.6.1 TC Block Control Register
Register Name: TC_BCR
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
– – – – – – – SYNC
128 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
20.6.2 TC Block Mode Register
Register Name: TC_BMR
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
– – TC2XC2S TC1XC1S TC0XC0S
129
6069C–ATARM–15-Sep-05
20.6.3 TC Channel Control Register
Register Name: TC_CCR
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
– – – – – SWTRG CLKDIS CLKEN
130 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
20.6.4 TC Channel Mode Register: Capture Mode
Register Name: TC_CMR
Access Type: Read/Write
31 30 29 28 27 26 25 24
– – – – – – – –
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.
131
6069C–ATARM–15-Sep-05
• ETRGEDG: External Trigger Edge Selection
ETRGEDG Edge
0 0 None
0 1 Rising edge
1 0 Falling edge
1 1 Each edge
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
132 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
20.6.5 TC Channel Mode Register: Waveform Mode
Register Name: TC_CMR
Access Type: Read/Write
31 30 29 28 27 26 25 24
BSWTRG BEEVT BCPC BCPB
23 22 21 20 19 18 17 16
ASWTRG AEEVT ACPC ACPA
15 14 13 12 11 10 9 8
WAVE CPCTRG – 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.
133
6069C–ATARM–15-Sep-05
• EEVTEDG: External Event Edge Selection
EEVTEDG Edge
0 0 None
0 1 Rising edge
1 0 Falling edge
1 1 Each edge
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
134 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• AEEVT: External Event Effect on TIOA
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
135
6069C–ATARM–15-Sep-05
• BSWTRG: Software Trigger Effect on TIOB
BSWTRG Effect
0 0 None
0 1 Set
1 0 Clear
1 1 Toggle
136 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
20.6.6 TC Counter Value Register
Register Name: TC_CVR
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
CV
7 6 5 4 3 2 1 0
CV
20.6.7 TC Register A
Register Name: TC_RA
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.
20.6.8 TC Register B
Register Name: TC_RB
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
RB
7 6 5 4 3 2 1 0
RB
• RB: Register B
RB contains the Register B value in real-time.
137
6069C–ATARM–15-Sep-05
20.6.9 TC Register C
Register Name: TC_RC
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
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
138 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• LDRBS: RB Loading Status
0 = RB load has not occurred since the last read of the Status Register or WAVE = 1.
1 = RB load has occurred since the last read of the Status Register if WAVE = 0.
• ETRGS: External Trigger Status
0 = External trigger has not occurred since the last read of the Status Register.
1 = External trigger has occurred since the last read of the Status Register.
• CLKSTA: Clock Enabling Status
0 = Clock is disabled.
1 = Clock is enabled.
• MTIOA: TIOA Mirror
0 = TIOA is low. If WAVE = 0, then TIOA pin is low. If WAVE = 1, then TIOA is driven low.
1 = TIOA is high. If WAVE = 0, then TIOA pin is high. If WAVE = 1, then TIOA is driven high.
• MTIOB: TIOB Mirror
0 = TIOB is low. If WAVE = 0, then TIOB pin is low. If WAVE = 1, then TIOB is driven low.
1 = TIOB is high. If WAVE = 0, then TIOB pin is high. If WAVE = 1, then TIOB is driven high.
139
6069C–ATARM–15-Sep-05
20.6.11 TC Interrupt Enable Register
Register Name: TC_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
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
140 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
20.6.13 TC Interrupt Mask Register
Register Name: TC_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
– – – – – – – –
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
141
6069C–ATARM–15-Sep-05
21. Serial Peripheral Interface (SPI)
The AT91C140 embeds a Serial Peripheral Interface featuring:
• Four Chip Selects with External Decoder Support Allowing 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
• Connection to PDC Channel Capabilities Optimizes Data Transfers
• One Channel for the Receiver, One Channel for the Transmitter
21.1 Overview
The Serial Peripheral Interface (SPI) circuit is a synchronous serial data link that provides
communication with external devices in Master or Slave Mode. It also allows communication
between processors if an external processor is connected to the system.
The Serial Peripheral Interface is a shift register that serially transmits data bits to other SPIs.
During a data transfer, one SPI system acts as the “master”' that controls the data flow, while
the other system acts as the “slave'' that has data shifted into and out of it by the master. Dif-
ferent CPUs can take turn being masters (Multiple Master Protocol versus 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.
142 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.2 Block Diagram
ASB
APB Bridge
PDC
APB
SPCK
MISO
MOSI
ACK
ACK/32 SPI Interface PIO NPCS0/NSS
NPCS1
NPCS2
Interrupt Control
NPCS3
SPI Interrupt
143
6069C–ATARM–15-Sep-05
21.3 Connections
SPCK SPCK
MISO MISO
Slave 0
MOSI MOSI
NPCS1 SPCK
MISO
NPCS2 NC Slave 1
NPCS3 MOSI
NSS
SPCK
MISO
Slave 2
MOSI
NSS
144 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
continues to transfer data. If the SPI_RDR (Receive Data Register) has not been read before
new data is received, the Overrun Error (OVRES) flag is set.
Note: As long as this flag is set, no data is loaded in the SPI_RDR. The user has to read the status
register to clear it.
The delay between the activation of the chip select and the start of the data transfer (DLYBS),
as well as the delay between each data transfer (DLYBCT), can be programmed for each of
the four external chip selects. All data transfer characteristics, including the two timing values,
are programmed in registers SPI_CSR0 to SPI_CSR3 (Chip Select Registers).
In Master Mode, the peripheral selection can be defined in two different ways:
• Fixed Peripheral Select: SPI exchanges data with only one peripheral
• Variable Peripheral Select: Data can be exchanged with more than one peripheral
Figure 21-6 and Figure 21-7 show the operation of the SPI in Master Mode. For details con-
cerning the flag and control bits in these diagrams, see ”SPI Chip Select Register” on page
161.
145
6069C–ATARM–15-Sep-05
21.5.4 Mode Fault Detection
A mode fault is detected when the SPI is programmed in Master Mode and a low level is
driven by an external master on the NPCS[0]/NSS signal.
When a mode fault is detected, the MODF bit in the SPI_SR is set until the SPI_SR is read
and the SPI is disabled until re-enabled by bit SPIEN in the SPI_CR (Control Register).
By default, Mode Fault Detection is enabled. It is disabled by setting the MODFDIS bit in the
SPI Mode Register.
146 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.5.5 Master Mode Flow Diagram
1
TDRE
0 Fixed peripheral
PS
1 Variable peripheral
Delay DLYBS
Serializer = SPI_TDR(TD)
TDRE = 1
Data Transfer
SPI_RDR(RD) = Serializer
RDRF = 1
Delay DLYBCT
0
TDRE
1 0 Fixed peripheral
PS
NPCS = 0xF
1 Variable peripheral
Delay DLYBCS
Same peripheral
SPI_TDR(PCS)
New peripheral
NPCS = 0xF
Delay DLYBCS
NPCS = SPI_TDR(PCS)
147
6069C–ATARM–15-Sep-05
21.5.6 Master Mode Block Diagram
SPIDIS SPIEN
Q
R
SPI_RDR
PCS RD
LSB MSB
MISO Serializer MOSI
SPI_TDR
PCS TD
NPCS3
NPCS2
NPCS1
SPI_MR(PS)
NPCS0
SPI_MR(PCS) 0
SPI_MR(MSTR)
SPI_SR S
M T R O P
O D D V I
D R R R E
F E F E N
S
SPI_IER
SPI_IDR
SPI_IMR
SPI Interrupt
148 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.6 SPI Slave Mode
In Slave Mode, the SPI waits for NSS to go active low before receiving the serial clock from an
external master.
In Slave Mode, CPOL, NCPHA and BITS fields of SPI_CSR0 are used to define the transfer
characteristics. The other Chip Select Registers are not used in Slave Mode.
SPCK
NSS
SPIDIS SPIEN
Q
R
SPI_RDR
RD
LSB MSB
MOSI Serializer MISO
SPI_TDR
TD
SPI_SR S
P T R O
I D D V
E R R R
N E F E
S
SPI_IER
SPI_IDR
SPI_IMR
SPI Interrupt
149
6069C–ATARM–15-Sep-05
the clock signal on which the data are driven and sampled. Each of the two parameters has
two possible states, resulting in four possible combinations that are incompatible with one
another. Thus a master/slave pair must use the same parameter pair values to communicate.
If multiple slaves are used and fixed in different configurations, the master must reconfigure
itself each time it needs to communicate with a different slave.
Table 21-2 shows the four modes and corresponding parameter settings.
SPCK
(CPOL=0)
SPCK
(CPOL=1)
MOSI
(from master)
MSB 6 5 4 3 2 1 LSB
MISO
(from slave) MSB 6 5 4 3 2 1 LSB *
150 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Figure 21-7. SPI Transfer Format (NCPHA = 0, 8 bits per transfer)
SPCK
(CPOL=0)
SPCK
(CPOL=1)
MOSI
(from master)
MSB 6 5 4 3 2 1 LSB
MISO
(from slave) * MSB 6 5 4 3 2 1 LSB
151
6069C–ATARM–15-Sep-05
21.9 Serial Peripheral Interface (SPI) User Interface
Table 21-3. SPI Memory Map
Offset Register Register Name Access Reset
0x00 Control Register SPI_CR Write-only ---
0x04 Mode Register SPI_MR Read/Write 0x0
0x08 Receive Data Register SPI_RDR Read-only 0x0
0x0C Transmit Data Register SPI_TDR Write-only ---
0x10 Status Register SPI_SR Read-only 0x000000F0
0x14 Interrupt Enable Register SPI_IER Write-only ---
0x18 Interrupt Disable Register SPI_IDR Write-only ---
0x1C Interrupt Mask Register SPI_IMR Read-only 0x0
0x20 Receive Pointer Register SPI_RPR Read/Write 0x0
0x24 Receive Counter Register SPI_RCR Read/Write 0x0
0x28 Transmit Pointer Register SPI_TPR Read/Write 0x0
0x2C Transmit Counter Register SPI_TCR Read/Write 0x0
0x30 Chip Select Register 0 SPI_CSR0 Read/Write 0x0
0x34 Chip Select Register 1 SPI_CSR1 Read/Write 0x0
0x38 Chip Select Register 2 SPI_CSR2 Read/Write 0x0
0x3C Chip Select Register 3 SPI_CSR3 Read/Write 0x0
152 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.9.1 SPI Control Register
Name: SPI_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 – – – – – SPIDIS SPIEN
153
6069C–ATARM–15-Sep-05
21.9.2 SPI Mode Register
Name: SPI_MR
Access Type: Read/Write
31 30 29 28 27 26 25 24
DLYBCS
23 22 21 20 19 18 17 16
– – – – PCS
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
LLB – – MODFDIS DIV32 PCSDEC PS MSTR
154 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
• 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
This field defines the delay from NPCS inactive to the activation of another NPCS. The DLYBCS time guarantees non-over-
lapping chip selects and solves bus contentions in case of peripherals having long data float times.
If DLYBCS is less than or equal to six, six SPI Master Clock periods will be inserted by default.
Otherwise, the following equation determines the delay:
NPCS_to_SCK_Delay = DLYBCS * SPI_Master_Clock_period
155
6069C–ATARM–15-Sep-05
21.9.3 SPI Receive Data Register
Name: SPI_RDR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – PCS
15 14 13 12 11 10 9 8
RD
7 6 5 4 3 2 1 0
RD
156 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.9.4 SPI Transmit Data Register
Name: SPI_TDR
Access Type: Write-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – PCS
15 14 13 12 11 10 9 8
TD
7 6 5 4 3 2 1 0
TD
157
6069C–ATARM–15-Sep-05
21.9.5 SPI Status Register
Name: SPI_SR
Access Type: Read-only
31 30 29 28 27 26 25 24
– – – – – – – –
23 22 21 20 19 18 17 16
– – – – – – – SPIENS
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – ENDTX ENDRX OVRES MODF TDRE RDRF
158 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.9.6 SPI Interrupt Enable Register
Name: SPI_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
– – ENDTX ENDRX OVRES MODF TDRE RDRF
23 22 21 20 19 18 17 16
– – – – – – – –
15 14 13 12 11 10 9 8
– – – – – – – –
7 6 5 4 3 2 1 0
– – ENDTX ENDRX OVRES MODF TDRE RDRF
159
6069C–ATARM–15-Sep-05
21.9.8 SPI Interrupt Mask Register
Name: SPI_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
– – – – – – – –
7 6 5 4 3 2 1 0
– – ENDTX ENDRX OVRES MODF TDRE RDRF
160 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.9.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 – – NCPHA CPOL
161
6069C–ATARM–15-Sep-05
• SCBR: Serial Clock Baud Rate
In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the SPI Master Clock
(selected between CLOCK and FDIV). The Baud rate is selected by writing a value from 2 to 255 in the field SCBR. The fol-
lowing equation determines the SPCK baud rate:
SPCK Baudrate = SPI_Master_Clock / (2 * SCBR)
Giving SCBR a value of zero or one disables the baud rate generator. SPCK is disabled and assumes its inactive state
value. No serial transfers may occur. At reset, baud rate is disabled.
• DLYBS: Delay Before SCK
This field defines the delay from NPCS valid to the first valid SCK transition.
When DLYBS equals zero, the NPCS valid to SCK transition is 1/2 the SCK clock period.
Otherwise, the following equation determines the delay:
NPCS_to_SCK_Delay = DLYBS * SPI_Master_Clock_period
• DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select.
The delay is always inserted after each transfer and before removing the chip select if needed.
When DLYBCT equals zero, a delay of four SPI Master Clock periods are inserted.
Otherwise, the following equation determines the delay:
Delay_After_Transfer = 32 * DLYBCT * SPI_Master_Clock_period.
162 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
21.9.10 SPI Receive Pointer Register
Register Name: SPI_RPR
Access Type: Read/Write
31 30 29 28 27 26 25 24
RXPTR
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
163
6069C–ATARM–15-Sep-05
21.9.12 SPI Transmit Pointer Register
Register Name: SP_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
164 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
22. Mechanical Characteristics and Packaging
165
6069C–ATARM–15-Sep-05
22.2 PQFP Package Data
Table 22-1. Package Dimensions for 208-lead PQFP Package (in mm)
Symbol Min Nom Max
A 4.10
A1 0.25
A2 3.20 3.32 3.60
D 31.20 BASIC
D1 28.00 BASIC
E 31.20 BASIC
E1 28.00 BASIC
R2 0.13 0.30
R1 0.13
Q 0° 7°
Q1 0°
Q2 8° Ref
Q3 8° Ref
c 0.11 0.15 0.23
L 0.73 0.88 1.03
L1 1.60 REF
S 0.20
b 0.17 0.20 0.27
e 0.50 BSC
D2 25.50
E2 25.50
Tolerances of form and position
aaa 0.25 0.010
bbb 0.20 0.008
ccc 0.08 0.003
166 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
23. Ordering Information
167
6069C–ATARM–15-Sep-05
168 AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Table of Contents
Features1
1 Description ............................................................................................. 1
3 Pinout .................................................................................................... 3
3.1Mechanical Overview of the 208-lead PQFP Package ..........................................4
10 Peripherals ........................................................................................... 21
10.1Peripheral Registers ...........................................................................................21
10.2Peripheral Memory Map .....................................................................................22
i
6069C–ATARM–15-Sep-05
12 Boot Program ...................................................................................... 24
12.1Boot Mode ..........................................................................................................24
12.2Hardware Connection of the DataFlash .............................................................24
12.3Internal Boot Software ........................................................................................24
12.4DataFlash Header Details ..................................................................................25
12.5Reserved Resources ..........................................................................................26
ii AT91C140
6069C–ATARM–15-Sep-05
AT91C140
17 Advanced Interrupt Controller (AIC) .................................................. 73
17.1Priority Controller ...............................................................................................74
17.2Interrupt Handling ...............................................................................................74
17.3Standard Interrupt Sequence .............................................................................75
17.4Fast Interrupt ......................................................................................................76
17.5Software Interrupt ...............................................................................................77
17.6Spurious Interrupt ...............................................................................................77
17.7AIC User Interface ..............................................................................................78
iii
6069C–ATARM–15-Sep-05
21.2Block Diagram ..................................................................................................143
21.3Connections .....................................................................................................144
21.4Pin Name List ..................................................................................................144
21.5Master Mode Operations ..................................................................................144
21.6SPI Slave Mode ...............................................................................................149
21.7Data Transfers .................................................................................................149
21.8Clock Generation .............................................................................................151
21.9Serial Peripheral Interface (SPI) User Interface ...............................................152
Table of Contentsi
Revision Historyv
iv AT91C140
6069C–ATARM–15-Sep-05
AT91C140
Revision History
Global, External Bus Interface references to 32-bit changed to 16-bit or CSR 05-403
removed.
Table 3-1, “Pinout for 208-lead PQFP Package,” DBW32 and BO256
changed to GND
Table 5-1, “Signal Description,” DBW32 removed
Global all instances of the following changed
DQM0-DQM3 changed to DQM0-DQM1
NWE0-NWE3 changed to NWE0-NWE1
6069C 01-Sep-05
Signal Waveforms section removed
Data Bus Width section removed
Table 3-1, “Pinout for 208-lead PQFP Package,” Replaced SCLKA, CSR 05-409
FSA, STXA, SRXA by GND or NC
v
6069C–ATARM–15-Sep-05
Atmel Corporation Atmel Operations
2325 Orchard Parkway Memory RF/Automotive
San Jose, CA 95131, USA 2325 Orchard Parkway Theresienstrasse 2
Tel: 1(408) 441-0311 San Jose, CA 95131, USA Postfach 3535
Fax: 1(408) 487-2600 Tel: 1(408) 441-0311 74025 Heilbronn, Germany
Fax: 1(408) 436-4314 Tel: (49) 71-31-67-0
Fax: (49) 71-31-67-2340
Regional Headquarters Microcontrollers
Europe 2325 Orchard Parkway 1150 East Cheyenne Mtn. Blvd.
Atmel Sarl San Jose, CA 95131, USA Colorado Springs, CO 80906, USA
Route des Arsenaux 41 Tel: 1(408) 441-0311 Tel: 1(719) 576-3300
Case Postale 80 Fax: 1(408) 436-4314 Fax: 1(719) 540-1759
CH-1705 Fribourg
Switzerland La Chantrerie Biometrics/Imaging/Hi-Rel MPU/
Tel: (41) 26-426-5555 BP 70602 High Speed Converters/RF Datacom
Fax: (41) 26-426-5500 44306 Nantes Cedex 3, France Avenue de Rochepleine
Tel: (33) 2-40-18-18-18 BP 123
Asia Fax: (33) 2-40-18-19-60 38521 Saint-Egreve Cedex, France
Room 1219 Tel: (33) 4-76-58-30-00
Chinachem Golden Plaza ASIC/ASSP/Smart Cards Fax: (33) 4-76-58-34-80
77 Mody Road Tsimshatsui Zone Industrielle
East Kowloon 13106 Rousset Cedex, France
Hong Kong Tel: (33) 4-42-53-60-00
Tel: (852) 2721-9778 Fax: (33) 4-42-53-60-01
Fax: (852) 2722-1369
1150 East Cheyenne Mtn. Blvd.
Japan Colorado Springs, CO 80906, USA
9F, Tonetsu Shinkawa Bldg. Tel: 1(719) 576-3300
1-24-8 Shinkawa Fax: 1(719) 540-1759
Chuo-ku, Tokyo 104-0033
Japan Scottish Enterprise Technology Park
Tel: (81) 3-3523-3551 Maxwell Building
Fax: (81) 3-3523-7581 East Kilbride G75 0QR, Scotland
Tel: (44) 1355-803-000
Fax: (44) 1355-242-743
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 specifications
and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided
otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’s products are not intended, authorized, or warranted for use
as components in applications intended to support or sustain life.
© Atmel Corporation 2005. All rights reserved. Atmel®, logo and combinations thereof, Everywhere You Are® and others, are registered trade-
marks or trademarks of Atmel Corporation or its subsidiaries. ARM®, the ARM Powered logo and others, are registered trademarks or trade-
marks of ARM Limited. Other terms and product names may be trademarks of others.
Printed on recycled paper.
6069C–ATARM–15-Sep-05