Atmel 11100 32 Bit Cortex M4 Microcontroller SAM4S Datasheet
Atmel 11100 32 Bit Cortex M4 Microcontroller SAM4S Datasheet
DATASHEET
Description
Atmel-11100K-ATARM-SAM4S-Datasheet_09-Jun-15
Features
Core
ARM Cortex-M4 with 2 Kbytes of cache running at up to 120 MHz
Memory Protection Unit (MPU)
DSP Instruction Set
Thumb-2 instruction set
Pin-to-pin compatible with SAM3N, SAM3S, SAM4N and SAM7S legacy products (64-pin version)
Memories
Up to 2048 Kbytes embedded Flash with optional dual-bank and cache memory, ECC, Security Bit and Lock
Bits
Up to 160 Kbytes embedded SRAM
16 Kbytes ROM with embedded boot loader routines (UART, USB) and IAP routines
8-bit Static Memory Controller (SMC): SRAM, PSRAM, NOR and NAND Flash support
System
Embedded voltage regulator for single supply operation
Power-on-Reset (POR), Brown-out Detector (BOD) and Watchdog for safe operation
Quartz or ceramic resonator oscillators: 3 to 20 MHz main power with failure detection and optional low-power
32.768 kHz for RTC or device clock
RTC with Gregorian and Persian calendar mode, waveform generation in low-power modes
RTC counter calibration circuitry compensates for 32.768 kHz crystal frequency inaccuracy
High-precision 8/12 MHz factory-trimmed internal RC oscillator with 4 MHz default frequency for device startup,
in-application trimming access for frequency adjustment
Slow clock internal RC oscillator as permanent low-power mode device clock
Two PLLs up to 240 MHz for device clock and for USB
Temperature sensor
Low-power tamper detection on two inputs, anti-tampering by immediate clear of general-purpose backup
registers (GPBR)
Up to 22 Peripheral DMA (PDC) channels
Low-power Modes
Sleep, Wait and Backup modes; consumption down to 1 A in Backup mode
Peripherals
USB 2.0 Device: 12 Mbps, 2668 byte FIFO, up to 8 bidirectional Endpoints, on-chip transceiver
Up to two USARTs with ISO7816, IrDA, RS-485, SPI, Manchester and Modem Mode
Two 2-wire UARTs
Up to two 2-Wire Interface modules (I2C-compatible), one SPI, one Serial Synchronous Controller (I2S), one
high-speed Multimedia Card Interface (SDIO/SD Card/MMC)
Two 3-channel 16-bit Timer Counters with capture, waveform, compare and PWM mode, Quadrature decoder
logic and 2-bit Gray up/down counter for stepper motor
4-channel 16-bit PWM with complementary output, fault input, 12-bit dead time generator counter for motor
control
32-bit Real-time Timer and RTC with calendar, alarm and 32 kHz trimming features
256-bit General Purpose Backup Registers (GPBR)
Up to 16-channel, 1Msps ADC with differential input mode and programmable gain stage and auto calibration
One 2-channel 12-bit 1Msps DAC
One Analog Comparator with flexible input selection, selectable input hysteresis
32-bit Cyclic Redundancy Check Calculation Unit (CRCCU) for data integrity check of off-/on-chip memories
Register Write Protection
Flash
Built-in ECC (hamming), single error correction
Security bit and lock bits
Flash 2 x 1024 Kbytes 2 x 1024 Kbytes 2 x 512 Kbytes 2 x 512 Kbytes 1024 Kbytes 1024 Kbytes 1024 Kbytes 1024 Kbytes
SRAM 160 Kbytes 160 Kbytes 160 Kbytes 160 Kbytes 160 Kbytes 160 Kbytes 128 Kbytes 128 Kbytes
Number of PIOs 79 47 79 47 79 47 79 47
12-bit ADC 16 ch.(1) 11 ch.(1) 16 ch.(1) 11 ch.(1) 16 ch.(1) 11 ch.(1) 16 ch.(1) 11 ch.(1)
12-bit DAC 2 ch. 2 ch. 2 ch. 2 ch. 2 ch. 2 ch. 2 ch. 2 ch.
Timer Counter
6 6(2) 6 6(2) 6 6(2) 6 6(2)
Channels
PDC Channels 22 22 22 22 22 22 22 22
(3) (3) (3) (3) (3) (3) (3)
USART/UART 2/2 2/2 2/2 2/2 2/2 2/2 2/2 2/2(3)
HSMCI 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits
Flash 512 Kbytes 512 Kbytes 256 Kbytes 256 Kbytes 256 Kbytes 128 Kbytes 128 Kbytes 128 Kbytes
SRAM 128 Kbytes 128 Kbytes 64 Kbytes 64 Kbytes 64 Kbytes 64 Kbytes 64 Kbytes 64 Kbytes
HCACHE
Number of PIOs 79 47 79 47 34 79 47 34
Timer Counter
6 6(2) 6 6(2) 6(2) 6 6(2) 6(2)
Channels
PDC Channels 22 22 22 22 22 22 22 22
(3) (3) (3) (3) (3) (3)
USART/UART 2/2 2/2 2/2 2/2 2/1 2/2 2/2 2/1
HSMCI 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits 1 port, 4 bits
Notes: 1. One channel is reserved for internal temperature sensor.
2. Three TC channels are reserved for internal use.
3. Full modem support on USART1.
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN
XOUT
320 MHz
Oscillator
fMAX 120 MHz
ERASE
Supply 24-bit SysTick
WKUP[15:0] DSP NVIC
Controller Counter
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc I D Unique
Signature
Identifier
32K typ. S CMCC
RC Osc (2 Kbyte Cache)
VDDIO 256-bit
Power-on
VDDCORE Reset Flash
VDDPLL
GPBR
M M S 2*1024/2*512/1024 Kbytes
RTCOUT0 Real-time Real-time
RTCOUT1 Clock Timer
4-layer AHB Bus Matrix SRAM
NRST Reset
fMAX 120 MHz S 160 Kbytes
Controller
Watchdog Supply
Timer Monitor S M S S ROM
16 Kbytes
PIOA/PIOB/PIOC
D[7:0]
External Bus A[23:0]
System Controller AHB/APB Interface A21/NANDALE
Bridge PDC
A22/NANDCLE
NAND Flash NANDOE
Logic
NANDWE
NWAIT
TWCK0 PDC Static Memory NCS[3:0]
TWD0
TWI0 Controller NRD
PDC NWE
TWCK1
TWI1
TWD1
Transceiver
URXD1 PDC
UTXD1
UART1
PDC High-speed MCCK
SCK0 MCCDA
PDC MCI
TXD0 MCDA[3:0]
RXD0 USART0 PDC MISO
RTS0
MOSI
CTS0 SPI SPCK
SCK1 NPCS[3:0]
PDC
TXD1
RXD1 PDC TD
RTS1 RD
CTS1 USART1 SSC TK
DTR1
RK
DSR1
TF
DCD1
RI1 RF
TIOA[5:3]
TC[3..5]
ADVREF TIOB[5:3]
PDC
DAC[1:0]
DAC
DATRG PDC
PWMH[3:0]
ADC PWML[3:0]
PWM PWMFI0
DAC Analog Comparator
Temp. Sensor
ADVREF
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN
XOUT
320 MHz fMAX 120 MHz
Oscillator
ERASE
24-bit SysTick
WKUP[15:0] Supply DSP NVIC
Counter
Controller
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc I D Unique
Signature
Identifier
32K typ. S CMCC
RC Osc (2 Kbyte Cache)
VDDIO
Power-on 256-bit
VDDCORE Flash
Reset GPBR
VDDPLL M M 2*1024/2*512/1024 Kbytes
S
RTCOUT0 Real-time Real-time
Clock Timer
RTCOUT1 4-layer AHB Bus Matrix SRAM
NRST Reset fMAX 120 MHz S 160 Kbytes
Controller
Watchdog Supply
Timer Monitor S M S S ROM
16 Kbytes
PIOA/PIOB/PIOC
AHB/APB
System Controller PDC
Bridge
Transceiver
TWCK0 PDC
TWD0
TWI0 2668
bytes USB 2.0 DDP
FIFO
Full-speed DDM
TWCK1 PDC
TWI1
TWD1
URXD0 PDC
UTXD0 UART0
PDC High-speed MCCK
MCCDA
URXD1 PDC MCI MCDA[3:0]
UTXD1
UART1
SCK0 PDC
PDC MISO
TXD0
MOSI
RXD0 USART0 SPI
RTS0 SPCK
CTS0 NPCS[3:0]
SCK1 PDC
TXD1 PDC TD
RXD1
RD
RTS1
SSC TK
CTS1 USART1 RK
DTR1
DSR1 TF
DCD1 RF
RI1
CRCCU
PIODC[7:0] PDC
PIODCCLK PIO Timer Counter 0
PIODCEN[2:1] TCLK[2:0]
TC[0..2] TIOA[2:0]
PDC TIOB[2:0]
AD[9:0]
ADC Timer Counter 1
Event System
ADTRG
TC[3..5]
Temp Sensor
ADVREF
PDC PDC
DAC[1:0] PWMH[3:0]
DAC PWML[3:0]
DATRG
PWM
PWMFI0
ADC
DAC Analog Comparator
Temp Sensor
ADVREF
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN
XOUT
320 MHz fMAX 120 MHz
Oscillator
ERASE
Supply 24-bit SysTick
WKUP[15:0] DSP NVIC
Counter
Controller
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc Unique
Signature
Identifier
32K typ.
S I/D
RC Osc
VDDIO
Power-on 256-bit
VDDCORE Reset Flash
VDDPLL GPBR
M M S 1024/512 Kbytes
Real-time Real-time
RTCOUT0 Timer
Clock
RTCOUT1 4-layer AHB Bus Matrix SRAM
Reset fMAX 120 MHz S 128 Kbytes
NRST Controller
Watchdog Supply
Timer Monitor S M S S ROM
16 Kbytes
PIOA/PIOB/PIOC
D[7:0]
External Bus A[23:0]
AHB/APB Interface A21/NANDALE
System Controller PDC
Bridge A22/NANDCLE
NAND Flash NANDOE
Logic
NANDWE
NWAIT
TWCK0 PDC Static Memory NCS[3:0]
TWD0
TWI0 Controller NRD
PDC NWE
TWCK1
TWI1
TWD1 Transceiver
URXD1 PDC
UTXD1
UART1
PDC High-speed MCCK
SCK0 MCCDA
PDC MCI
TXD0 MCDA[3:0]
RXD0 USART0 PDC MISO
RTS0
MOSI
CTS0 SPI SPCK
SCK1 NPCS[3:0]
PDC
TXD1
RXD1 PDC TD
RTS1 RD
CTS1 USART1 SSC TK
DTR1
RK
DSR1
TF
DCD1
RI1 RF
TIOA[5:3]
TC[3..5]
ADVREF TIOB[5:3]
PDC
DAC[1:0]
DAC
DATRG PDC
PWMH[3:0]
ADC PWML[3:0]
PWM PWMFI0
DAC Analog Comparator
Temp Sensor
ADVREF
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN 320 MHz
XOUT Oscillator
fMAX 120 MHz
ERASE
Supply 24-bit SysTick
WKUP[15:0] DSP NVIC
Counter
Controller
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc Unique
Signature
Identifier
32K typ.
RC Osc S I/D
VDDIO 256-bit
Power-on
VDDCORE Reset Flash
GPBR
VDDPLL M M 1024/512 Kbytes
Real-time
S
Real-time
RTCOUT0 Clock Timer
RTCOUT1 4-layer AHB Bus Matrix SRAM
Reset
fMAX 120 MHz S 128 Kbytes
NRST Controller
Watchdog Supply
Timer Monitor
S M S S ROM
16 Kbytes
PIOA/PIOB
Transceiver
TWCK0 PDC
TWD0
TWI0 2668
bytes USB 2.0 DDP
FIFO
Full-speed DDM
TWCK1 PDC
TWI1
TWD1
URXD0 PDC
UTXD0 UART0
PDC High-speed MCCK
MCCDA
URXD1 PDC MCI MCDA[3:0]
UTXD1
UART1
SCK0 PDC
PDC MISO
TXD0
MOSI
RXD0 USART0 SPI SPCK
RTS0
CTS0 NPCS[3:0]
SCK1 PDC
TXD1 PDC TD
RXD1
RD
RTS1
SSC TK
CTS1 USART1 RK
DTR1
DSR1 TF
DCD1 RF
RI1
CRCCU
PIODC[7:0] PDC
PIODCCLK PIO Timer Counter 0
PIODCEN[2:1] TCLK[2:0]
TC[0..2] TIOA[2:0]
PDC TIOB[2:0]
AD[9:0]
ADTRG ADC Timer Counter 1
Event System
TC[3..5]
Temp Sensor
ADVREF
PDC
PDC
DAC[1:0] PWMH[3:0]
DAC PWML[3:0]
DATRG
PWM
PWMFI0
ADC
DAC Analog Comparator
Temp Sensor
ADVREF
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN
XOUT
320 MHz fMAX 120 MHz
Oscillator
ERASE
Supply 24-bit SysTick
WKUP[15:0] DSP NVIC
Counter
Controller
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc Unique
Signature
Identifier
32K typ.
S I/D
RC Osc
VDDIO
Power-on 256-bit
VDDCORE Reset Flash
VDDPLL GPBR
M M S 256/128 Kbytes
Real-time Real-time
RTCOUT0 Timer
Clock
RTCOUT1 4-layer AHB Bus Matrix SRAM
Reset fMAX 120 MHz S 64 Kbytes
NRST Controller
Watchdog Supply
Timer Monitor S M S S ROM
16 Kbytes
PIOA/PIOB/PIOC
D[7:0]
External Bus A[23:0]
AHB/APB Interface A21/NANDALE
System Controller PDC
Bridge A22/NANDCLE
NAND Flash NANDOE
Logic
NANDWE
NWAIT
TWCK0 PDC Static Memory NCS[3:0]
TWD0
TWI0 Controller NRD
PDC NWE
TWCK1
TWI1
TWD1 Transceiver
URXD1 PDC
UTXD1
UART1
PDC High-speed MCCK
SCK0 MCCDA
PDC MCI
TXD0 MCDA[3:0]
RXD0 USART0 PDC MISO
RTS0
MOSI
CTS0 SPI SPCK
SCK1 NPCS[3:0]
PDC
TXD1
RXD1 PDC TD
RTS1 RD
CTS1 USART1 SSC TK
DTR1
RK
DSR1
TF
DCD1
RI1 RF
TIOA[5:3]
TC[3..5]
ADVREF TIOB[5:3]
PDC
DAC[1:0]
DAC
DATRG PDC
PWMH[3:0]
ADC PWML[3:0]
PWM PWMFI0
DAC Analog Comparator
Temp Sensor
ADVREF
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN
XOUT
320 MHz fMAX 120 MHz
Oscillator
ERASE
24-bit SysTick
WKUP[15:0] Supply DSP NVIC
Counter
Controller
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc Unique
Signature
Identifier
32K typ. I/D
RC Osc S
VDDIO
VDDCORE Power-on 256-bit
Reset GPBR Flash
VDDPLL M M 256/128 Kbytes
S
RTCOUT0 Real-time Real-time
Clock Timer
RTCOUT1 4-layer AHB Bus Matrix SRAM
Reset fMAX 120 MHz S 64 Kbytes
NRST Controller
Watchdog Supply
Timer Monitor S M S ROM
16 Kbytes
PIOA/PIOB
AHB/APB
System Controller PDC
Bridge
Transceiver
TWCK0 PDC
TWD0
TWI0 2668
USB 2.0 DDP
bytes
FIFO
Full-speed DDM
TWCK1 PDC
TWI1
TWD1
URXD0 PDC
UTXD0 UART0
PDC High-speed MCCK
MCCDA
URXD1 PDC MCI
UTXD1
UART1 MCDA[3:0]
SCK0 PDC
TXD0 PDC MISO
RXD0 MOSI
USART0 SPI
RTS0 SPCK
CTS0 NPCS[3:0]
SCK1 PDC
TXD1
PDC TD
RXD1
RTS1 RD
CTS1 USART1 SSC TK
DTR1 RK
DSR1 TF
DCD1 RF
RI1
CRCCU
PIODC[7:0] PDC
PIODCCLK PIO Timer Counter 0
PIODCEN[2:1] TCLK[2:0]
TC[0..2] TIOA[2:0]
PDC TIOB[2:0]
AD[9:0]
ADTRG ADC Timer Counter 1
ADVREF
PDC
DAC[1:0] PDC
PWMH[3:0]
DAC
DATRG PWML[3:0]
PWM
PWMFI0
ADC
DAC Analog Comparator
Temp Sensor
ADVREF
LK
SW IO
T
K/ D
C
U
TC /SW
IO
SE
O
D
D
AG
O
S
VD
VD
I
TM
TD
TD
JT
TST Voltage
PCK[2:0] Regulator
PLLA
Power JTAG and Serial Wire
Management
PLLB Controller
RC Osc
4/8/12 MHz In-Circuit Emulator
Cortex-M4 Processor
XIN
XOUT
320 MHz fMAX 120 MHz
Oscillator
ERASE
Supply 24-bit SysTick
WKUP[15:0] DSP NVIC
Counter
Controller
Backup Tamper Detection
MPU
XIN32 32K Cryst Flash
User
XOUT32 Osc Unique
Signature
Identifier
32K typ.
S I/D
RC Osc
VDDIO
Power-on 256-bit
VDDCORE Reset Flash
VDDPLL GPBR
M M S 256/128 Kbytes
Real-time Real-time
RTCOUT0 Timer
Clock
RTCOUT1 4-layer AHB Bus Matrix SRAM
Reset fMAX 120 MHz S 64 Kbytes
NRST Controller
Watchdog Supply
Timer Monitor S M S ROM
16 Kbytes
PIOA/PIOB
AHB/APB
System Controller PDC
Bridge
TWCK1 PDC
TWI1 PDC MISO
TWD1
MOSI
SPI SPCK
URXD0 PDC NPCS[3:0]
UTXD0
UART0
PDC TD
URXD1 PDC RD
UTXD1 UART1 SSC TK
RK
TF
SCK0 PDC RF
TXD0
RXD0 USART0 Timer Counter 0 TCLK[2:0]
RTS0 TIOA[2:0]
TC[0..2]
CTS0
TIOB[2:0]
AD[7:0]
ADTRG ADC TC[3..5]
ADVREF
Temp Sensor PDC
PWMH[3:0]
ADC PWML[3:0]
Analog Comparator
PWM PWMFI0
DAC
Temp Sensor
ADVREF
76 50
100 26
1 25
A B C D E F G H J K
BALL A1
48 33
49 32
64 17
1 16
64 49
1 48
16 33
17 32
TOP VIEW
Note: The bottom pad of the QFN package must be connected to ground.
Note: The bottom pad of the QFN package must be connected to ground.
VDDIO
VDDIO(min)
VDDCORE
VDDCORE(min)
VT+
Time (t)
tRST
SLCK
VDDIO USB
Transceivers
Main Supply
(1.623.6 V) ADC, DAC,
Analog Comp.
VDDIN
VDDOUT
Voltage
Regulator
VDDCORE
VDDPLL
Note: Restrictions:
For USB, VDDIO needs to be greater than 3.0V.
For ADC, DAC and Analog Comparator, VDDIN needs to be greater than 2.4V.
VDDOUT Voltage
Regulator
VDDCORE Supply VDDCORE
(1.081.32V)
VDDPLL
Note: Restrictions:
For USB, VDDIO needs to be greater than 3.0V.
For ADC, DAC and Analog Comparator, VDDIN needs to be greater than 2.4V.
VDDIO USB
Backup Transceivers
Battery +
ADC, DAC,
- Analog Comp.
VDDIN
VDDPLL
PIOx (Output)
WKUPx
External wakeup signal
Note: The two diodes provide a switchover circuit (for illustration purpose)
between the backup battery and the main supply when the system is put in
backup mode.
Note: Restrictions:
For USB, VDDIO needs to be greater than 3.0V.
For ADC, DAC and Analog Comparator, VDDIN needs to be greater than 2.4V.
(7) (7)
Sleep Mode ON ON WFI + from: Unchanged
(Not clocked) back saved
SAM4S Series [DATASHEET]
Z0 ~ ZO + RODT
ODT
36 Typ.
RODT
Receiver
SAM4 Driver with PCB Trace
ZO ~ 10 Z0 ~ 50
The SRAM is accessible over system Cortex-M4 bus at address 0x2000 0000.
The SRAM is in the bit band region. The bit band alias region is from 0x2200 0000 to 0x23FF FFFF.
64 Kbytes Sector 1
64 Kbytes Sector n
Refer to Figure 8-3, "Flash Size" for the organization of the Flash depending on its size.
3 * 64 Kbytes
7 * 64 Kbytes
15 * 64 Kbytes
The following erase commands can be used depending on the sector size:
8 Kbyte small sector
Erase and write page (EWP)
Erase and write page and lock (EWPL)
Erase sector (ES) with FARG set to a page number in the sector to erase
Erase pages (EPA) with FARG [1:0] = 0 to erase four pages or FARG [1:0] = 1 to erase eight pages.
FARG [1:0] = 2 and FARG [1:0] = 3 must not be used.
48 Kbyte and 64 Kbyte sectors
One block of 8 pages inside any sector, with the command Erase pages (EPA) with FARG[1:0] = 1
One block of 16 pages inside any sector, with the command Erase pages (EPA) and FARG[1:0] = 2
One block of 32 pages inside any sector, with the command Erase pages (EPA) and FARG[1:0] = 3
One sector with the command Erase sector (ES) and FARG set to a page number in the sector to
erase
Entire memory plane
The entire Flash, with the command Erase all (EA)
The Write commands of the Flash cannot be used under 330 kHz.
8.1.3.2 Enhanced Embedded Flash Controller
The Enhanced Embedded Flash Controller manages accesses performed by the masters of the system. It enables
reading the Flash and writing the write buffer. It also contains a User Interface, mapped on the APB.
The Enhanced Embedded Flash Controller ensures the interface of the Flash block.
It manages the programming, erasing, locking and unlocking sequences of the Flash using a full set of commands.
One of the commands returns the embedded Flash descriptor definition that informs the system about the Flash
organization, thus making the software generic.
8.1.3.3 Flash Speed
The user must set the number of wait states depending on the frequency used.
For more details, refer to Section 44.12 AC Characteristics.
If a locked region erase or program command occurs, the command is aborted and the EEFC triggers an interrupt.
The lock bits are software programmable through the EEFC User Interface. The command Set Lock Bit enables
the protection. The command Clear Lock Bit unlocks the lock region.
Asserting the ERASE pin clears the lock bits, thus unlocking the entire Flash.
8.1.3.6 Security Bit
The SAM4SD32/SD16/S16/SA16/S8/S4/S2 feature one security bit based on a specific General Purpose NVM bit
(GPNVM bit 0). When the security bit is enabled, any access to the Flash, SRAM, core registers and internal
peripherals through the ICE interface or through the Fast Flash Programming Interface, is forbidden. This ensures
the confidentiality of the code programmed in the Flash.
This security bit can only be enabled through the command Set General Purpose NVM Bit 0 of the EEFC User
Interface. Disabling the security bit can only be achieved by asserting the ERASE pin at 1, and after a full Flash
erase is performed. When the security bit is deactivated, all accesses to the Flash, SRAM, Core registers, Internal
Peripherals are permitted.
The ERASE pin integrates a permanent pull-down. Consequently, it can be left unconnected during normal
operation. However, it is recommended, in harsh environment, to connect it directly to GND if the erase operation
is not used in the application.
To avoid unexpected erase at power-up, a minimum ERASE pin assertion time is required. This time is defined in
Table 44-74 AC Flash Characteristics.
The erase operation is not performed when the system is in Wait mode with the Flash in deep-power-down mode.
To make sure that the erase operation is performed after power-up, the system must not reconfigure the ERASE
pin as GPIO or enter Wait mode with Flash in Deep-power-down mode before the ERASE pin assertion time has
elapsed.
The following sequence ensures the erase operation in all cases:
1. Assert the ERASE pin (High)
2. Assert the NRST pin (Low)
3. Power cycle the device
10.2.1 Power-on-Reset
The Power-on-Reset monitors VDDIO. It is always activated and monitors voltage at start up but also during power
down. If VDDIO goes below the threshold voltage, the entire chip is reset. For more information, refer to Section
44. Electrical Characteristics.
Notes: 1. Analog input has priority over RTCOUTx pin. See Section 16.5.8 Waveform Generation.
2. WKUPx can be used if PIO controller defines the I/O line as "input".
3. To select this extra function, refer to Section 42.5.3 Analog Inputs.
4. Refer to Section 6.2 System I/O Lines.
5. DAC0 is selected when DACC_CHER.CH0 is set. DAC1 is selected when DACC_CHER.CH1 is set. See Section 43.7.3
DACC Channel Enable Register.
Note: 1. To select this extra function, refer to Section 42.5.3 Analog Inputs.
12.1 Description
The Cortex-M4 processor is a high performance 32-bit processor designed for the microcontroller market. It offers
significant benefits to developers, including outstanding processing performance combined with fast interrupt
handling, enhanced system debug with extensive breakpoint and trace capabilities, efficient processor core,
system and memories, ultra-low power consumption with integrated sleep modes, and platform security
robustness, with integrated memory protection unit (MPU).
The Cortex-M4 processor is built on a high-performance processor core, with a 3-stage pipeline Harvard
architecture, making it ideal for demanding embedded applications. The processor delivers exceptional power
efficiency through an efficient instruction set and extensively optimized design, providing high-end processing
hardware including a range of single-cycle and SIMD multiplication and multiply-with-accumulate capabilities,
saturating arithmetic and dedicated hardware division.
To facilitate the design of cost-sensitive devices, the Cortex-M4 processor implements tightly-coupled system
components that reduce processor area while significantly improving interrupt handling and system debug
capabilities. The Cortex-M4 processor implements a version of the Thumb instruction set based on Thumb-2
technology, ensuring high code density and reduced program memory requirements. The Cortex-M4 instruction
set provides the exceptional performance expected of a modern 32-bit architecture, with the high code density of
8-bit and 16-bit microcontrollers.
The Cortex-M4 processor closely integrates a configurable NVIC, to deliver industry-leading interrupt
performance. The NVIC includes a non-maskable interrupt (NMI), and provides up to 256 interrupt priority levels.
The tight integration of the processor core and NVIC provides fast execution of interrupt service routines (ISRs),
dramatically reducing the interrupt latency. This is achieved through the hardware stacking of registers, and the
ability to suspend load-multiple and store-multiple operations. Interrupt handlers do not require wrapping in
assembler code, removing any code overhead from the ISRs. A tail-chain optimization also significantly reduces
the overhead when switching from one ISR to another.
To optimize low-power designs, the NVIC integrates with the sleep modes, that include a deep sleep function that
enables the entire device to be rapidly powered down while still retaining program state.
Cortex-M4
Processor
NVIC
Processor
Core
Debug Serial
Memory
Access Wire
Port Protection Unit
Viewer
Flash Data
Patch Watchpoints
Bus Matrix
Code SRAM and
Interface Peripheral Interface
Table 12-1. Summary of processor mode, execution privilege level, and stack use options
Processor Privilege Level for
Mode Used to Execute Software Execution Stack Used
(1)
Thread Applications Privileged or unprivileged Main stack or process stack(1)
Handler Exception handlers Always privileged Main stack
Note: 1. See Control Register .
R0
R1
R2
R3
Low registers
R4
R5
R6 General-purpose registers
R7
R8
R9
High registers R10
R11
R12
Stack Pointer SP (R13) PSP MSP
Banked version of SP
Link Register LR (R14)
Program Counter PC (R15)
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
ICI/IT ISR_NUMBER
7 6 5 4 3 2 1 0
ISR_NUMBER
See the instruction descriptions MRS and MSR for more information about how to access the program status registers.
23 22 21 20 19 18 17 16
GE[3:0]
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
The APSR contains the current state of the condition flags from previous instruction executions.
N: Negative Flag
0: Operation result was positive, zero, greater than, or equal
1: Operation result was negative or less than.
Z: Zero Flag
0: Operation result was not zero
1: Operation result was zero.
V: Overflow Flag
0: Operation did not result in an overflow
1: Operation resulted in an overflow.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
ISR_NUMBER
7 6 5 4 3 2 1 0
ISR_NUMBER
The IPSR contains the exception type number of the current Interrupt Service Routine (ISR).
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
ICI/IT
7 6 5 4 3 2 1 0
The EPSR contains the Thumb state bit, and the execution state bits for either the If-Then (IT) instruction, or the Interrupt-
ible-Continuable Instruction (ICI) field for an interrupted load multiple or store multiple instruction.
Attempts to read the EPSR directly through application software using the MSR instruction always return zero. Attempts to
write the EPSR using the MSR instruction in the application software are ignored. Fault handlers can examine the EPSR
value in the stacked PSR to indicate the operation that is at fault. See Exception Entry and Return .
T: Thumb State
The Cortex-M4 processor only supports the execution of instructions in Thumb state. The following can clear the T bit to 0:
Instructions BLX, BX and POP{PC}
Restoration from the stacked xPSR value on an exception return
Bit[0] of the vector value on an exception entry or reset.
Attempting to execute instructions when the T bit is 0 results in a fault or lockup. See Lockup for more information.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PRIMASK
The PRIMASK register prevents the activation of all exceptions with a configurable priority.
PRIMASK
0: No effect
1: Prevents the activation of all exceptions with a configurable priority.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FAULTMASK
The FAULTMASK register prevents the activation of all exceptions except for Non-Maskable Interrupt (NMI).
FAULTMASK
0: No effect.
1: Prevents the activation of all exceptions except for NMI.
The processor clears the FAULTMASK bit to 0 on exit from any exception handler except the NMI handler.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
BASEPRI
The BASEPRI register defines the minimum priority for exception processing. When BASEPRI is set to a nonzero value, it
prevents the activation of all exceptions with same or lower priority level as the BASEPRI value.
BASEPRI
Priority mask bits:
0x0000: No effect
Nonzero: Defines the base priority for exception processing
The processor does not process any exception with a priority value greater than or equal to BASEPRI.
This field is similar to the priority fields in the interrupt priority registers. The processor implements only bits[7:4] of this
field, bits[3:0] read as zero and ignore writes. See Interrupt Priority Registers for more information. Remember that
higher priority field values correspond to lower exception priorities.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SPSEL nPRIV
The Control Register controls the stack used and the privilege level for software execution when the processor is in Thread
mode.
Vendor-specific
511 MB
memory
0xE0100000
Private peripheral 0xE00FFFFF
1.0 MB
bus
0xE000 0000
0x DFFFFFFF
0xA0000000
0x9FFFFFFF
32 MB Bit-band alias
0x42000000 0x60000000
0x5FFFFFFF
Peripheral 0.5 GB
0x400FFFFF
1 MB Bit-band region
0x40000000 0x40000000
0x3FFFFFFF
0x23FFFFFF
SRAM 0.5 GB
32 MB Bit-band alias
0x20000000
0x22000000 0x1FFFFFFF
Code 0.5 GB
0x200FFFFF
1 MB Bit-band region
0x20000000 0x00000000
The regions for SRAM and peripherals include bit-band regions. Bit-banding provides atomic operations to bit
data, see Bit-banding .
The processor reserves regions of the Private peripheral bus (PPB) address range for core peripheral registers.
This memory mapping is generic to ARM Cortex-M4 products. To get the specific memory mapping of this product,
refer to the Memories section of the datasheet.
12.4.2.1 Memory Regions, Types and Attributes
The memory map and the programming of the MPU split the memory map into regions. Each region has a defined
memory type, and some regions have additional memory attributes. The memory type and attributes determine the
behavior of accesses to the region.
The Code, SRAM, and external RAM regions can hold programs. However, ARM recommends that programs
always use the Code region. This is because the processor has separate buses that enable instruction fetches and
data accesses to occur simultaneously.
The MPU can override the default memory access behavior described in this section. For more information, see
Memory Protection Unit (MPU) .
Additional Memory Access Constraints For Caches and Shared Memory
When a system includes caches or shared memory, some memory regions have additional access constraints,
and some regions are subdivided, as Table 12-5 shows.
Notes: 1. A word access to the SRAM or peripheral bit-band alias regions map to a single bit in the SRAM or peripheral bit-band
region.
2. Bit-band accesses can use byte, halfword, or word transfers. The bit-band transfer size matches the transfer size of the
instruction making the bit-band access.
The following formula shows how the alias region maps onto the bit-band region:
bit_word_offset = (byte_offset x 32) + (bit_number x 4)
bit_word_addr = bit_band_base + bit_word_offset
where:
Bit_word_offset is the position of the target bit in the bit-band memory region.
Bit_word_addr is the address of the word in the alias memory region that maps to the targeted bit.
Bit_band_base is the starting address of the alias region.
Byte_offset is the number of the byte in the bit-band region that contains the targeted bit.
Bit_number is the bit position, 07, of the targeted bit.
Figure 12-4 shows examples of bit-band mapping between the SRAM bit-band alias region and the SRAM bit-
band region:
The alias word at 0x23FFFFE0 maps to bit[0] of the bit-band byte at 0x200FFFFF: 0x23FFFFE0 =
0x22000000 + (0xFFFFF*32) + (0*4).
The alias word at 0x23FFFFFC maps to bit[7] of the bit-band byte at 0x200FFFFF: 0x23FFFFFC =
0x22000000 + (0xFFFFF*32) + (7*4).
The alias word at 0x22000000 maps to bit[0] of the bit-band byte at 0x20000000: 0x22000000 =
0x22000000 + (0*32) + (0*4).
The alias word at 0x2200001C maps to bit[7] of the bit-band byte at 0x20000000: 0x2200001C =
0x22000000+ (0*32) + (7*4).
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
Memory Register
7 0
31 24 23 16 15 8 7 0
Address A B0 lsbyte B3 B2 B1 B0
A+1 B1
A+2 B2
A+3 B3 msbyte
The actual exclusive access instruction generated depends on the data type of the pointer passed to the intrinsic
function. For example, the following C code generates the required LDREXB operation:
__ldrex((volatile char *) 0xFF);
For an asynchronous exception, other than reset, the processor can execute another instruction between when the
exception is triggered and when the processor enters the exception handler.
Privileged software can disable the exceptions that Table 12-9 shows as having configurable priority, see:
System Handler Control and State Register
Interrupt Clear-enable Registers .
On system reset, the vector table is fixed at address 0x00000000. Privileged software can write to the SCB_VTOR
to relocate the vector table start address to a different memory location, in the range 0x00000080 to 0x3FFFFF80,
see Vector Table Offset Register .
Note: Configurable priority values are in the range 015. This means that the Reset, Hard fault, and NMI exceptions, with
fixed negative priority values, always have higher priority than any other exception.
For example, assigning a higher priority value to IRQ[0] and a lower priority value to IRQ[1] means that IRQ[1] has
higher priority than IRQ[0]. If both IRQ[1] and IRQ[0] are asserted, IRQ[1] is processed before IRQ[0].
If multiple pending exceptions have the same priority, the pending exception with the lowest exception number
takes precedence. For example, if both IRQ[0] and IRQ[1] are pending and have the same priority, then IRQ[0] is
processed before IRQ[1].
When the processor is executing an exception handler, the exception handler is preempted if a higher priority
exception occurs. If an exception occurs with the same priority as the exception being handled, the handler is not
preempted, irrespective of the exception number. However, the status of the new interrupt changes to pending.
12.4.3.6 Interrupt Priority Grouping
To increase priority control in systems with interrupts, the NVIC supports priority grouping. This divides each
interrupt priority register entry into two fields:
An upper field that defines the group priority
A lower field that defines a subpriority within the group.
Only the group priority determines preemption of interrupt exceptions. When the processor is executing an
interrupt exception handler, another interrupt with the same group priority as the interrupt being handled does not
preempt the handler.
If multiple pending interrupts have the same group priority, the subpriority field determines the order in which they
are processed. If multiple pending interrupts have the same group priority and subpriority, the interrupt with the
lowest IRQ number is processed first.
For information about splitting the interrupt priority fields into group priority and subpriority, see Application
Interrupt and Reset Control Register .
12.4.3.7 Exception Entry and Return
Descriptions of exception handling use the following terms:
Preemption
When the processor is executing an exception handler, an exception can preempt the exception handler if its
priority is higher than the priority of the exception being handled. See Interrupt Priority Grouping for more
information about preemption by an interrupt.
When one exception preempts another, the exceptions are called nested exceptions. See Exception Entry more
information.
Return
This occurs when the exception handler is completed, and:
There is no pending exception with sufficient priority to be serviced
The completed exception handler was not handling a late-arriving exception.
The processor pops the stack and restores the processor state to the state it had before the interrupt occurred.
See Exception Return for more information.
FPSCR
S15
S14
S13
S12
S11
S10
S9
S8
S7
S6
S5
S4
S3
S2
S1 ...
Pre-IRQ top of stack
S0 {aligner}
xPSR Decreasing xPSR
PC memory PC
address
LR LR
R12 R12
R3 R3
R2 R2
R1 R1
R0 IRQ top of stack R0 IRQ top of stack
Immediately after stacking, the stack pointer indicates the lowest address in the stack frame. The alignment of the
stack frame is controlled via the STKALIGN bit of the Configuration Control Register (CCR).
The stack frame includes the return address. This is the address of the next instruction in the interrupted program.
This value is restored to the PC at exception return so that the interrupted program resumes.
In parallel to the stacking operation, the processor performs a vector fetch that reads the exception handler start
address from the vector table. When stacking is complete, the processor starts executing the exception handler. At
the same time, the processor writes an EXC_RETURN value to the LR. This indicates which stack pointer
corresponds to the stack frame and what operation mode the processor was in before the entry occurred.
If no higher priority exception occurs during the exception entry, the processor starts executing the exception
handler and automatically changes the status of the corresponding pending interrupt to active.
If another higher priority exception occurs during the exception entry, the processor starts executing the exception
handler for this exception and does not change the pending status of the earlier exception. This is the late arrival
case.
Exception Return
An Exception return occurs when the processor is in Handler mode and executes one of the following instructions
to load the EXC_RETURN value into the PC:
An LDM or POP instruction that loads the PC
An LDR instruction with the PC as the destination.
A BX instruction using any register.
Lockup
The processor enters a lockup state if a hard fault occurs when executing the NMI or hard fault handlers. When the
processor is in lockup state, it does not execute any instructions. The processor remains in lockup state until
either:
It is reset
An NMI occurs
It is halted by a debugger.
Note: If the lockup state occurs from the NMI handler, a subsequent NMI does not cause the processor to leave the lockup
state.
The CMSIS also provides a number of functions for accessing the special registers using MRS and MSR
instructions:
12.6.3.1 Operands
An instruction operand can be an ARM register, a constant, or another instruction-specific parameter. Instructions
act on the operands and often store the result in a destination register. When there is a destination register in the
instruction, it is usually specified before the operands.
Operands in some instructions are flexible, can either be a register or a constant. See Flexible Second Operand .
12.6.3.2 Restrictions when Using PC or SP
Many instructions have restrictions on whether the Program Counter (PC) or Stack Pointer (SP) for the operands
or destination register can be used. See instruction descriptions for more information.
Note: Bit[0] of any address written to the PC with a BX, BLX, LDM, LDR, or POP instruction must be 1 for correct execution,
because this bit indicates the required instruction set, and the Cortex-M4 processor only supports Thumb instructions.
If n is 32 or more, then all the bits in the result are set to the value of bit[31] of Rm.
If n is 32 or more and the carry flag is updated, it is updated to the value of bit[31] of Rm.
LSR
Logical shift right by n bits moves the left-hand 32-n bits of the register Rm, to the right by n places, into the right-
hand 32-n bits of the result. And it sets the left-hand n bits of the result to 0. See Figure 12-9.
&DUU\
)ODJ
LSL
Logical shift left by n bits moves the right-hand 32-n bits of the register Rm, to the left by n places, into the left-hand
32-n bits of the result; and it sets the right-hand n bits of the result to 0. See Figure 12-10.
The LSL #n operation can be used to multiply the value in the register Rm by 2n, if the value is regarded as an
unsigned integer or a twos complement signed integer. Overflow can occur without warning.
When the instruction is LSLS or when LSL #n, with non-zero n, is used in Operand2 with the instructions MOVS,
MVNS, ANDS, ORRS, ORNS, EORS, BICS, TEQ or TST, the carry flag is updated to the last bit shifted out, bit[32-
n], of the register Rm. These instructions do not affect the carry flag when used with LSL #0.
&DUU\
)ODJ
ROR
Rotate right by n bits moves the left-hand 32-n bits of the register Rm, to the right by n places, into the right-hand
32-n bits of the result; and it moves the right-hand n bits of the register into the left-hand n bits of the result. See
Figure 12-11.
When the instruction is RORS or when ROR #n is used in Operand2 with the instructions MOVS, MVNS, ANDS,
ORRS, ORNS, EORS, BICS, TEQ or TST, the carry flag is updated to the last bit rotation, bit[n-1], of the register
Rm.
If n is 32, then the value of the result is same as the value in Rm, and if the carry flag is updated, it is updated
to bit[31] of Rm.
ROR with shift length, n, more than 32 is the same as ROR with shift length n-32.
&DUU\
)ODJ
RRX
Rotate right with extend moves the bits of the register Rm to the right by one bit; and it copies the carry flag into
bit[31] of the result. See Figure 12-12.
When the instruction is RRXS or when RRX is used in Operand2 with the instructions MOVS, MVNS, ANDS,
ORRS, ORNS, EORS, BICS, TEQ or TST, the carry flag is updated to bit[0] of the register Rm.
For B, BL, CBNZ, and CBZ instructions, the value of the PC is the address of the current instruction plus 4
bytes.
Absolute Value
The example below shows the use of a conditional instruction to find the absolute value of a number. R0 =
ABS(R1).
MOVS R0, R1 ; R0 = R1, setting flags
IT MI ; IT instruction for the negative condition
RSBMI R0, R1, #0 ; If negative, R0 = -R1
Compare and Update Value
The example below shows the use of conditional instructions to update the value of R4 if the signed values R0 is
greater than R1 and R2 is greater than R3.
CMP R0, R1 ; Compare R0 and R1, setting flags
ITT GT ; IT instruction for the two GT conditions
CMPGT R2, R3 ; If 'greater than', compare R2 and R3, setting flags
MOVGT R4, R5 ; If still 'greater than', do R4 = R5
Restrictions
Rd must not be SP and must not be PC.
Condition Flags
This instruction does not change the flags.
Examples
ADR R1, TextMessage ; Write address value of a location labelled as
; TextMessage to R1
Restrictions
For load instructions:
Rt can be SP or PC for word loads only
Rt must be different from Rt2 for two-word loads
Rn must be different from Rt and Rt2 in the pre-indexed or post-indexed forms.
When Rt is PC in a word load instruction:
Bit[0] of the loaded value must be 1 for correct execution
A branch occurs to the address created by changing bit[0] of the loaded value to 0
If the instruction is conditional, it must be the last instruction in the IT block.
For store instructions:
Rt can be SP for word stores only
Rt must not be PC
Rn must not be PC
Rn must be different from Rt and Rt2 in the pre-indexed or post-indexed forms.
Condition Flags
These instructions do not change the flags.
The user might have to use the .W suffix to get the maximum offset range. See Instruction Width Selection .
Restrictions
In these instructions:
Rt can be SP or PC only for word loads
Rt2 must not be SP and must not be PC
Rt must be different from Rt2.
Restrictions
In these instructions:
Do not use PC
Do not use SP for Rd and Rt
For STREX, Rd must be different from both Rt and Rn
The value of offset must be a multiple of four in the range 01020.
Condition Flags
These instructions do not change the flags.
Examples
MOV R1, #0x1 ; Initialize the lock taken value try
LDREX R0, [LockAddr] ; Load the lock value
CMP R0, #0 ; Is the lock free?
12.6.4.9 CLREX
Clear Exclusive.
Syntax
CLREX{cond}
where:
cond is an optional condition code, see Conditional Execution .
Operation
Use CLREX to make the next STREX, STREXB, or STREXH instruction write a 1 to its destination register and fail
to perform the store. It is useful in exception handler code to force the failure of the store exclusive if the exception
occurs between a load exclusive instruction and the matching store exclusive instruction in a synchronization
operation.
See Synchronization Primitives for more information.
Condition Flags
These instructions do not change the flags.
Examples
CLREX
Restrictions
In these instructions:
Operand2 must not be SP and must not be PC
Rd can be SP only in ADD and SUB, and only with the additional restrictions:
Rn must also be SP
Any shift in Operand2 must be limited to a maximum of 3 bits using LSL
Rn can be SP only in ADD and SUB
Rd can be PC only in the ADD{cond} PC, PC, Rm instruction where:
The user must not specify the S suffix
Rm must not be PC and must not be SP
MOVS Rd, Rm is the preferred syntax for LSLS Rd, Rm, #0.
Operation
ASR, LSL, LSR, and ROR move the bits in the register Rm to the left or right by the number of places specified by
constant n or register Rs.
RRX moves the bits in register Rm to the right by 1.
In all these instructions, the result is written to Rd, but the value in register Rm remains unchanged. For details on
what result is generated by the different instructions, see Shift Operations .
Restrictions
Do not use SP and do not use PC.
Condition Flags
12.6.5.4 CLZ
Count Leading Zeros.
Syntax
CLZ{cond} Rd, Rm
where:
cond is an optional condition code, see Conditional Execution .
Rd is the destination register.
Rm is the operand register.
Operation
The CLZ instruction counts the number of leading zeros in the value in Rm and returns the result in Rd. The result
value is 32 if no bits are set and zero if bit[31] is set.
Restrictions
Do not use SP and do not use PC.
Condition Flags
This instruction does not change the flags.
Examples
CLZ R4,R9
CLZNE R2,R3
In these instructions:
Do not use PC
Operand2 must not be SP.
Condition Flags
These instructions update the N, Z, C and V flags according to the result.
Examples
CMP R2, R9
CMN R0, #6400
CMPGT SP, R7, LSL #2
Though it is possible to use MOV as a branch instruction, ARM strongly recommends the use of a BX or BLX
instruction to branch for software portability to the ARM instruction set.
Condition Flags
12.6.5.7 MOVT
Move Top.
Syntax
MOVT{cond} Rd, #imm16
where:
cond is an optional condition code, see Conditional Execution .
Rd is the destination register.
imm16 is a 16-bit immediate constant.
Operation
MOVT writes a 16-bit immediate value, imm16, to the top halfword, Rd[31:16], of its destination register. The write
does not affect Rd[15:0].
The MOV, MOVT instruction pair enables to generate any 32-bit constant.
Restrictions
Rd must not be SP and must not be PC.
Condition Flags
This instruction does not change the flags.
Examples
MOVT R3, #0xF123 ; Write 0xF123 to upper halfword of R3, lower halfword
; and APSR are unchanged.
Condition Flags
These instructions do not change the flags.
Examples
SHSUB16 R1, R0 ; Subtracts halfwords in R0 from corresponding halfword
; of R1 and writes to corresponding halfword of R1
SHSUB8 R4, R0, R5 ; Subtracts bytes of R0 from corresponding byte in R5,
; and writes to corresponding byte in R4.
Examples
SSUB16 R1, R0 ; Subtracts halfwords in R0 from corresponding halfword
; of R1 and writes to corresponding halfword of R1
SSUB8 R4, R0, R5 ; Subtracts bytes of R5 from corresponding byte in
; R0, and writes to corresponding byte of R4.
Examples
UHASX R7, R4, R2 ; Adds top halfword of R4 with bottom halfword of R2
; and writes halved result to top halfword of R7
; Subtracts top halfword of R2 from bottom halfword of
; R7 and writes halved result to bottom halfword of R7
UHSAX R0, R3, R5 ; Subtracts bottom halfword of R5 from top halfword of
; R3 and writes halved result to top halfword of R0
; Adds top halfword of R5 to bottom halfword of R3 and
; writes halved result to bottom halfword of R0.
12.6.5.21 SEL
Select Bytes. Selects each byte of its result from either its first operand or its second operand, according to the
values of the GE flags.
Syntax
SEL{<c>}{<q>} {<Rd>,} <Rn>, <Rm>
where:
c, q are standard assembler syntax fields.
12.6.6.8 SMMUL
Signed Most Significant Word Multiply
Syntax
op{R}{cond} Rd, Rn, Rm
where:
op is one of:
SMMUL Signed Most Significant Word Multiply.
R is a rounding error flag. If R is specified, the result is rounded instead of being
truncated. In this case the constant 0x80000000 is added to the product before
the high word is extracted.
cond is an optional condition code, see Conditional Execution .
Rd is the destination register.
Rn, Rm are registers holding the first and second operands.
Operation
The SMMUL instruction interprets the values from Rn and Rm as twos complement 32-bit signed integers. The
SMMUL instruction:
Multiplies the values from Rn and Rm.
Optionally rounds the result, otherwise truncates the result.
Writes the most significant signed 32 bits of the result in Rd.
Restrictions
In this instruction:
do not use SP and do not use PC.
Condition Flags
This instruction does not affect the condition code flags.
Examples
SMULL R0, R4, R5 ; Multiplies R4 and R5, truncates top 32 bits
; and writes to R0
SMULLR R6, R2 ; Multiplies R6 and R2, rounds the top 32 bits
; and writes to R6.
To read the state of the Q flag, the MRS instruction must be used; see MRS .
The table below shows the instructions that operate on packing and unpacking data.
Condition Flags
This instruction does not change the flags.
Restrictions
Do not use SP and do not use PC.
Condition Flags
These instructions do not affect the flags.
The .W suffix might be used to get the maximum branch range. See Instruction Width Selection .
Restrictions
The restrictions are:
Do not use PC in the BLX instruction
For BX and BLX, bit[0] of Rm must be 1 for correct execution but a branch occurs to the target address
created by changing bit[0] to 0
When any of these instructions is inside an IT block, it must be the last instruction of the IT block.
Bcond is the only conditional instruction that is not required to be inside an IT block. However, it has a longer
branch range when it is inside an IT block.
Your assembler might place extra restrictions on the use of IT blocks, such as prohibiting the use of assembler
directives within them.
Condition Flags
This instruction does not change the flags.
Example
ITTE NE ; Next 3 instructions are conditional
ANDNE R0, R0, R1 ; ANDNE does not update condition flags
ADDSNE R2, R2, #1 ; ADDSNE updates condition flags
MOVEQ R2, R3 ; Conditional move
TBH [PC, R1, LSL #1] ; R1 is the index, PC is used as base of the
; branch table
BranchTable_H
DCI ((CaseA - BranchTable_H)/2) ; CaseA offset calculation
DCI ((CaseB - BranchTable_H)/2) ; CaseB offset calculation
DCI ((CaseC - BranchTable_H)/2) ; CaseC offset calculation
CaseA
; an instruction sequence follows
CaseB
; an instruction sequence follows
CaseC
; an instruction sequence follows
Note: ARM does not recommend the use of the BKPT instruction with an immediate value set to 0xAB for any purpose other
than Semi-hosting.
12.6.11.2 CPS
Change Processor State.
Syntax
CPSeffect iflags
where:
effect is one of:
IE Clears the special purpose register.
ID Sets the special purpose register.
iflags is a sequence of one or more flags:
i Set or clear PRIMASK.
f Set or clear FAULTMASK.
Operation
CPS changes the PRIMASK and FAULTMASK special register values. See Exception Mask Registers for more
information about these registers.
Restrictions
The restrictions are:
Use CPS only from privileged software, it has no effect if used in unprivileged software
CPS cannot be conditional and so must not be used inside an IT block.
12.6.11.3 DMB
Data Memory Barrier.
Syntax
DMB{cond}
where:
cond is an optional condition code, see Conditional Execution .
Operation
DMB acts as a data memory barrier. It ensures that all explicit memory accesses that appear, in program order,
before the DMB instruction are completed before any explicit memory accesses that appear, in program order,
after the DMB instruction. DMB does not affect the ordering or execution of instructions that do not access
memory.
Condition Flags
This instruction does not change the flags.
Examples
DMB ; Data Memory Barrier
12.6.11.5 ISB
Instruction Synchronization Barrier.
Syntax
ISB{cond}
where:
cond is an optional condition code, see Conditional Execution .
Operation
ISB acts as an instruction synchronization barrier. It flushes the pipeline of the processor, so that all instructions
following the ISB are fetched from cache or memory again, after the ISB instruction has been completed.
Condition Flags
This instruction does not change the flags.
Examples
ISB ; Instruction Synchronisation Barrier
12.6.11.7 MSR
Move the contents of a general-purpose register into the specified special register.
Syntax
MSR{cond} spec_reg, Rn
where:
cond is an optional condition code, see Conditional Execution .
Rn is the source register.
spec_reg can be any of: APSR, IPSR, EPSR, IEPSR, IAPSR, EAPSR, PSR, MSP, PSP,
PRIMASK, BASEPRI, BASEPRI_MAX, FAULTMASK, or CONTROL.
12.6.11.8 NOP
No Operation.
Syntax
NOP{cond}
where:
cond is an optional condition code, see Conditional Execution .
Operation
NOP does nothing. NOP is not necessarily a time-consuming NOP. The processor might remove it from the
pipeline before it reaches the execution stage.
Use NOP for padding, for example to place the following instruction on a 64-bit boundary.
Condition Flags
This instruction does not change the flags.
Examples
NOP ; No operation
12.6.11.10 SVC
Supervisor Call.
Syntax
SVC{cond} #imm
where:
cond is an optional condition code, see Conditional Execution .
imm is an expression evaluating to an integer in the range 0-255 (8-bit value).
Operation
The SVC instruction causes the SVC exception.
imm is ignored by the processor. If required, it can be retrieved by the exception handler to determine what service
is being requested.
Condition Flags
This instruction does not change the flags.
Examples
SVC 0x32 ; Supervisor Call (SVC handler can extract the immediate value
; by locating it via the stacked PC)
12.6.11.12 WFI
Wait for Interrupt.
Syntax
WFI{cond}
where:
cond is an optional condition code, see Conditional Execution .
Operation
WFI is a hint instruction that suspends execution until one of the following events occurs:
An exception
A Debug Entry request, regardless of whether Debug is enabled.
Condition Flags
This instruction does not change the flags.
Examples
WFI ; Wait for interrupt
12.7.1 Peripherals
Nested Vectored Interrupt Controller (NVIC)
The Nested Vectored Interrupt Controller (NVIC) is an embedded interrupt controller that supports low
latency interrupt processing. See Section 12.8 Nested Vectored Interrupt Controller (NVIC).
System Control Block (SCB)
The System Control Block (SCB) is the programmers model interface to the processor. It provides system
implementation information and system control, including configuration, control, and reporting of system
exceptions. See Section 12.9 System Control Block (SCB).
System Timer (SysTick)
The System Timer, SysTick, is a 24-bit count-down timer. Use this as a Real Time Operating System
(RTOS) tick timer or as a simple counter. See Section 12.10 System Timer (SysTick).
Memory Protection Unit (MPU)
The Memory Protection Unit (MPU) improves system reliability by defining the memory attributes for different
memory regions. It provides up to eight different regions, and an optional predefined background region.
See Section 12.11 Memory Protection Unit (MPU).
In register descriptions:
The required privilege gives the privilege level required to access the register, as follows:
Privileged: Only privileged software can access the register.
Unprivileged: Both unprivileged and privileged software can access the register.
The input parameter IRQn is the IRQ number. For more information about these functions, see the CMSIS
documentation.
To improve software efficiency, the CMSIS simplifies the NVIC register presentation. In the CMSIS:
The Set-enable, Clear-enable, Set-pending, Clear-pending and Active Bit registers map to arrays of 32-bit
integers, so that:
The array ISER[0] to ISER[1] corresponds to the registers ISER0ISER1
The array ICER[0] to ICER[1] corresponds to the registers ICER0ICER1
The array ISPR[0] to ISPR[1] corresponds to the registers ISPR0ISPR1
The array ICPR[0] to ICPR[1] corresponds to the registers ICPR0ICPR1
The array IABR[0] to IABR[1] corresponds to the registers IABR0IABR1
The Interrupt Priority Registers (IPR0IPR8) provide an 8-bit priority field for each interrupt and each register
holds four priority fields.
The CMSIS provides thread-safe code that gives atomic access to the Interrupt Priority Registers. Table 12-30
shows how the interrupts, or IRQ numbers, map onto the interrupt registers and corresponding CMSIS variables
that have one bit per interrupt.
23 22 21 20 19 18 17 16
SETENA
15 14 13 12 11 10 9 8
SETENA
7 6 5 4 3 2 1 0
SETENA
These registers enable interrupts and show which interrupts are enabled.
23 22 21 20 19 18 17 16
CLRENA
15 14 13 12 11 10 9 8
CLRENA
7 6 5 4 3 2 1 0
CLRENA
These registers disable interrupts, and show which interrupts are enabled.
23 22 21 20 19 18 17 16
SETPEND
15 14 13 12 11 10 9 8
SETPEND
7 6 5 4 3 2 1 0
SETPEND
These registers force interrupts into the pending state, and show which interrupts are pending.
23 22 21 20 19 18 17 16
CLRPEND
15 14 13 12 11 10 9 8
CLRPEND
7 6 5 4 3 2 1 0
CLRPEND
These registers remove the pending state from interrupts, and show which interrupts are pending.
23 22 21 20 19 18 17 16
ACTIVE
15 14 13 12 11 10 9 8
ACTIVE
7 6 5 4 3 2 1 0
ACTIVE
23 22 21 20 19 18 17 16
PRI2
15 14 13 12 11 10 9 8
PRI1
7 6 5 4 3 2 1 0
PRI0
The NVIC_IPR0NVIC_IPR8 registers provide a 8-bit priority field for each interrupt. These registers are byte-accessible.
Each register holds four priority fields that map up to four elements in the CMSIS interrupt priority array IP[0] to IP[34].
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
INTID
7 6 5 4 3 2 1 0
INTID
INTID: Interrupt ID
Interrupt ID of the interrupt to trigger, in the range 0239. For example, a value of 0x03 specifies interrupt IRQ3.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
DISOOFP DISFPCA
7 6 5 4 3 2 1 0
DISFOLD DISDEFWBUF DISMCYCINT
The SCB_ACTLR provides disable bits for the following processor functions:
IT folding
Write buffer use for accesses to the default memory map
Interruption of multi-cycle instructions.
By default, this register is set to provide optimum performance from the Cortex-M4 processor, and does not normally
require modification.
23 22 21 20 19 18 17 16
Variant Constant
15 14 13 12 11 10 9 8
PartNo
7 6 5 4 3 2 1 0
PartNo Revision
The SCB_CPUID register contains the processor part number, version, and implementation information.
23 22 21 20 19 18 17 16
ISRPENDING VECTPENDING
15 14 13 12 11 10 9 8
VECTPENDING RETTOBASE VECTACTIVE
7 6 5 4 3 2 1 0
VECTACTIVE
The SCB_ICSR provides a set-pending bit for the Non-Maskable Interrupt (NMI) exception, and set-pending and clear-
pending bits for the PendSV and SysTick exceptions.
It indicates:
The exception number of the exception being processed, and whether there are preempted active exceptions,
The exception number of the highest priority pending exception, and whether any interrupts are pending.
23 22 21 20 19 18 17 16
TBLOFF
15 14 13 12 11 10 9 8
TBLOFF
7 6 5 4 3 2 1 0
TBLOFF
The SCB_VTOR indicates the offset of the vector table base address from memory address 0x00000000.
23 22 21 20 19 18 17 16
VECTKEYSTAT/VECTKEY
15 14 13 12 11 10 9 8
ENDIANNESS PRIGROUP
7 6 5 4 3 2 1 0
SYSRESETREQ VECTCLRACTIVE VECTRESET
The SCB_AIRCR provides priority grouping control for the exception model, endian status for data accesses, and reset
control of the system. To write to this register, write 0x5FA to the VECTKEY field, otherwise the processor ignores the
write.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SEVONPEND SLEEPDEEP SLEEPONEXIT
SLEEPONEXIT: Sleep-on-exit
Indicates sleep-on-exit when returning from the Handler mode to the Thread mode:
0: Do not sleep when returning to Thread mode.
1: Enter sleep, or deep sleep, on return from an ISR.
Setting this bit to 1 enables an interrupt-driven application to avoid returning to an empty main application.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
STKALIGN BFHFNMIGN
7 6 5 4 3 2 1 0
NONBASETHRDE
DIV_0_TRP UNALIGN_TRP USERSETMPEND
NA
The SCB_CCR controls the entry to the Thread mode and enables the handlers for NMI, hard fault and faults escalated by
FAULTMASK to ignore BusFaults. It also enables the division by zero and unaligned access trapping, and the access to
the NVIC_STIR by unprivileged software (see Software Trigger Interrupt Register ).
Each PRI_N field is 8 bits wide, but the processor implements only bits [7:4] of each field, and bits [3:0] read as zero and
ignore writes.
23 22 21 20 19 18 17 16
PRI_6
15 14 13 12 11 10 9 8
PRI_5
7 6 5 4 3 2 1 0
PRI_4
PRI_6: Priority
Priority of system handler 6, UsageFault.
PRI_5: Priority
Priority of system handler 5, BusFault.
PRI_4: Priority
Priority of system handler 4, MemManage.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PRI_11: Priority
Priority of system handler 11, SVCall.
23 22 21 20 19 18 17 16
PRI_14
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PRI_15: Priority
Priority of system handler 15, SysTick exception.
PRI_14: Priority
Priority of system handler 14, PendSV.
23 22 21 20 19 18 17 16
USGFAULTENA BUSFAULTENA MEMFAULTENA
15 14 13 12 11 10 9 8
BUSFAULTPEND MEMFAULTPEND USGFAULTPEND
SVCALLPENDED SYSTICKACT PENDSVACT MONITORACT
ED ED ED
7 6 5 4 3 2 1 0
SVCALLACT USGFAULTACT BUSFAULTACT MEMFAULTACT
The SHCSR enables the system handlers, and indicates the pending status of the bus fault, memory management fault,
and SVC exceptions; it also indicates the active status of the system handlers.
23 22 21 20 19 18 17 16
NOCP INVPC INVSTATE UNDEFINSTR
15 14 13 12 11 10 9 8
BFARVALID STKERR UNSTKERR IMPRECISERR PRECISERR IBUSERR
7 6 5 4 3 2 1 0
MMARVALID MSTKERR MUNSTKERR DACCVIOL IACCVIOL
23 22 21 20 19 18 17 16
UFSR
15 14 13 12 11 10 9 8
BFSR
7 6 5 4 3 2 1 0
MMFSR
The SCB_CFSR indicates the cause of a memory management fault, bus fault, or usage fault. It is byte accessible. The
user can access the SCB_CFSR or its subregisters as follows:
Access complete SCB_CFSR with a word access to 0xE000ED28
Access MMFSR with a byte access to 0xE000ED28
Access MMFSR and BFSR with a halfword access to 0xE000ED28
Access BFSR with a byte access to 0xE000ED29
Access UFSR with a halfword access to 0xE000ED2A.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
VECTTBL
The SCB_HFSR gives information about events that activate the hard fault handler. This register is read, write to clear.
This means that bits in the register read normally, but wrting a 1 to any bit clears that bit to 0.
Note: The HFSR bits are sticky. This means that, as one or more fault occurs, the associated bits are set to 1. A bit that is set to 1 is
cleared to 0 only by wrting a 1 to that bit, or by a reset.
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
The SCB_MMFAR contains the address of the location that generated a memory management fault.
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
The SCB_BFAR contains the address of the location that generated a bus fault.
23 22 21 20 19 18 17 16
COUNTFLAG
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CLKSOURCE TICKINT ENABLE
23 22 21 20 19 18 17 16
RELOAD
15 14 13 12 11 10 9 8
RELOAD
7 6 5 4 3 2 1 0
RELOAD
The SYST_RVR specifies the start value to load into the SYST_CVR.
23 22 21 20 19 18 17 16
CURRENT
15 14 13 12 11 10 9 8
CURRENT
7 6 5 4 3 2 1 0
CURRENT
The SysTick SYST_CVR contains the current value of the SysTick counter.
23 22 21 20 19 18 17 16
TENMS
15 14 13 12 11 10 9 8
TENMS
7 6 5 4 3 2 1 0
TENMS
Disable a region before writing new region settings to the MPU, if the region being changed was previously
enabled. For example:
; R1 = region number
; R2 = size/enable
; R3 = attributes
; R4 = address
LDR R0,=MPU_RNR ; 0xE000ED98, MPU region number register
STR R1, [R0, #0x0] ; Region Number
BIC R2, R2, #1 ; Disable
STRH R2, [R0, #0x8] ; Region Size and Enable
STR R4, [R0, #0x4] ; Region Base Address
STRH R3, [R0, #0xA] ; Region Attribute
ORR R2, #1 ; Enable
This can be done in two words for pre-packed information. This means that the MPU_RBAR contains the required
region number and had the VALID bit set to 1. See MPU Region Base Address Register . Use this when the data
is statically packed, for example in a boot loader:
; R1 = address and region number in one
; R2 = size and attributes in one
LDR R0, =MPU_RBAR ; 0xE000ED9C, MPU Region Base register
STR R1, [R0, #0x0] ; Region base address and
; region number combined with VALID (bit 4) set to 1
STR R2, [R0, #0x4] ; Region Attribute, Size and Enable
12.11.1.5 Subregions
Regions of 256 bytes or more are divided into eight equal-sized subregions. Set the corresponding bit in the SRD
field of the MPU_RASR field to disable a subregion. See MPU Region Attribute and Size Register . The least
significant bit of SRD controls the first subregion, and the most significant bit controls the last subregion. Disabling
a subregion means another region overlapping the disabled range matches instead. If no other enabled region
overlaps the disabled subregion, the MPU issues a fault.
Regions of 32, 64, and 128 bytes do not support subregions. With regions of these sizes, the SRD field must be
set to 0x00, otherwise the MPU behavior is unpredictable.
12.11.1.6 Example of SRD Use
Two regions with the same base address overlap. Region 1 is 128 KB, and region 2 is 512 KB. To ensure the
attributes from region 1 apply to the first 128 KB region, set the SRD field for region 2 to b00000011 to disable the
first two subregions, as in Figure 12-13 below:
23 22 21 20 19 18 17 16
IREGION
15 14 13 12 11 10 9 8
DREGION
7 6 5 4 3 2 1 0
SEPARATE
The MPU_TYPE register indicates whether the MPU is present, and if so, how many regions it supports.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PRIVDEFENA HFNMIENA ENABLE
The MPU CTRL register enables the MPU, enables the default memory map background region, and enables the use of
the MPU when in the hard fault, Non-maskable Interrupt (NMI), and FAULTMASK escalated handlers.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
REGION
The MPU_RNR selects which memory region is referenced by the MPU_RBAR and MPU_RASRs.
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 VALID REGION
The MPU_RBAR defines the base address of the MPU region selected by the MPU_RNR, and can update the value of the
MPU_RNR.
Write MPU_RBAR with the VALID bit set to 1 to change the current region number and update the MPU_RNR.
23 22 21 20 19 18 17 16
TEX S C B
15 14 13 12 11 10 9 8
SRD
7 6 5 4 3 2 1 0
SIZE ENABLE
The MPU_RASR defines the region size and memory attributes of the MPU region specified by the MPU_RNR, and
enables that region and any subregions.
MPU_RASR is accessible using word or halfword accesses:
The most significant halfword holds the region attributes.
The least significant halfword holds the region size, and the region and subregion enable bits.
S: Shareable
See Table 12-36.
Note: For information about access permission, see MPU Access Permission Attributes .
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 VALID REGION
The MPU_RBAR defines the base address of the MPU region selected by the MPU_RNR, and can update the value of the
MPU_RNR.
Write MPU_RBAR with the VALID bit set to 1 to change the current region number and update the MPU_RNR.
23 22 21 20 19 18 17 16
TEX S C B
15 14 13 12 11 10 9 8
SRD
7 6 5 4 3 2 1 0
SIZE ENABLE
The MPU_RASR defines the region size and memory attributes of the MPU region specified by the MPU_RNR, and
enables that region and any subregions.
MPU_RASR is accessible using word or halfword accesses:
The most significant halfword holds the region attributes.
The least significant halfword holds the region size, and the region and subregion enable bits.
S: Shareable
See Table 12-36.
Note: For information about access permission, see MPU Access Permission Attributes .
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 VALID REGION
The MPU_RBAR defines the base address of the MPU region selected by the MPU_RNR, and can update the value of the
MPU_RNR.
Write MPU_RBAR with the VALID bit set to 1 to change the current region number and update the MPU_RNR.
23 22 21 20 19 18 17 16
TEX S C B
15 14 13 12 11 10 9 8
SRD
7 6 5 4 3 2 1 0
SIZE ENABLE
The MPU_RASR defines the region size and memory attributes of the MPU region specified by the MPU_RNR, and
enables that region and any subregions.
MPU_RASR is accessible using word or halfword accesses:
The most significant halfword holds the region attributes.
The least significant halfword holds the region size, and the region and subregion enable bits.
S: Shareable
See Table 12-36.
Note: For information about access permission, see MPU Access Permission Attributes .
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 VALID REGION
The MPU_RBAR defines the base address of the MPU region selected by the MPU_RNR, and can update the value of the
MPU_RNR.
Write MPU_RBAR with the VALID bit set to 1 to change the current region number and update the MPU_RNR.
23 22 21 20 19 18 17 16
TEX S C B
15 14 13 12 11 10 9 8
SRD
7 6 5 4 3 2 1 0
SIZE ENABLE
The MPU_RASR defines the region size and memory attributes of the MPU region specified by the MPU_RNR, and
enables that region and any subregions.
MPU_RASR is accessible using word or halfword accesses:
The most significant halfword holds the region attributes.
The least significant halfword holds the region size, and the region and subregion enable bits.
S: Shareable
See Table 12-36.
Note: For information about access permission, see MPU Access Permission Attributes .
Abort A mechanism that indicates to a processor that the value associated with a memory access is invalid.
An abort can be caused by the external or internal memory system as a result of attempting to access
invalid instruction or data memory.
Aligned
A data item stored at an address that is divisible by the number of bytes that defines the data size is
said to be aligned. Aligned words and halfwords have addresses that are divisible by four and two
respectively. The terms word-aligned and halfword-aligned therefore stipulate addresses that are
divisible by four and two respectively.
Banked register A register that has multiple physical copies, where the state of the processor determines which copy is
used. The Stack Pointer, SP (R13) is a banked register.
Base register
In instruction descriptions, a register specified by a load or store instruction that is used to hold the
base value for the instructions address calculation. Depending on the instruction and its addressing
mode, an offset can be added to or subtracted from the base register value to form the address that is
sent to memory.
See also Index register .
Big-endian (BE) Byte ordering scheme in which bytes of decreasing significance in a data word are stored at
increasing addresses in memory.
See also Byte-invariant , Endianness , Little-endian (LE) .
Big-endian memory
Memory in which:
a byte or halfword at a word-aligned address is the most significant byte or halfword within the word at
that address,
a byte at a halfword-aligned address is the most significant byte within the halfword at that address.
See also Little-endian memory .
Breakpoint
A breakpoint is a mechanism provided by debuggers to identify an instruction at which program
execution is to be halted. Breakpoints are inserted by the programmer to enable inspection of register
contents, memory locations, variable values at fixed points in the program execution to test that the
program is operating correctly. Breakpoints are removed after the program is successfully tested.
Cache
A block of on-chip or off-chip fast access memory locations, situated between the processor and main
memory, used for storing and retrieving copies of often used instructions, data, or instructions and
data. This is done to greatly increase the average speed of memory accesses and so improve
processor performance.
Condition field
A four-bit field in an instruction that specifies a condition under which the instruction can execute.
Conditional execution If the condition code flags indicate that the corresponding condition is true when the instruction starts
executing, it executes normally. Otherwise, the instruction does nothing.
Context The environment that each process operates in for a multitasking operating system. In ARM
processors, this is limited to mean the physical address range that it can access in memory and the
associated memory access permissions.
Coprocessor
A processor that supplements the main processor. Cortex-M4 does not support any coprocessors.
Debugger A debugging system that includes a program, used to detect, locate, and correct software faults,
together with custom hardware that supports software debugging.
Direct Memory Access An operation that accesses main memory directly, without the processor performing any accesses to
(DMA) the data concerned.
Doubleword
A 64-bit data item. The contents are taken as being an unsigned integer unless otherwise stated.
Endianness Byte ordering. The scheme that determines the order that successive bytes of a data word are stored
in memory. An aspect of the systems memory mapping.
See also Little-endian (LE) and Big-endian (BE) .
Flat address mapping A system of organizing memory in which each physical address in the memory space is the same as
the corresponding virtual address.
Implementation-defined The behavior is not architecturally defined, but is defined and documented by individual
implementations.
Implementation-specific The behavior is not architecturally defined, and does not have to be documented by individual
implementations. Used when there are a number of implementation options available and the option
chosen does not affect software compatibility.
Index register
In some load and store instruction descriptions, the value of this register is used as an offset to be
added to or subtracted from the base register value to form the address that is sent to memory. Some
addressing modes optionally enable the index register value to be shifted prior to the addition or
subtraction.
See also Base register .
Instruction cycle count The number of cycles that an instruction occupies the Execute stage of the pipeline.
Interrupt handler A program that control of the processor is passed to when an interrupt occurs.
Interrupt vector One of a number of fixed addresses in low memory, or in high memory if high vectors are configured,
that contains the first instruction of the corresponding interrupt handler.
Little-endian memory
Memory in which:
a byte or halfword at a word-aligned address is the least significant byte or halfword within the word at
that address,
a byte at a halfword-aligned address is the least significant byte within the halfword at that address.
See also Big-endian memory .
Load/store architecture A processor architecture where data-processing operations only operate on register contents, not
directly on memory contents.
Memory Protection Unit Hardware that controls access permissions to blocks of memory. An MPU does not perform any
(MPU) address translation.
Prefetching In pipelined processors, the process of fetching instructions from memory to fill up the pipeline before
the preceding instructions have finished executing. Prefetching an instruction does not mean that the
instruction has to be executed.
Preserved Preserved by writing the same value back that has been previously read from the same field on the
same processor.
Read Reads are defined as memory operations that have the semantics of a load. Reads include the Thumb
instructions LDM, LDR, LDRSH, LDRH, LDRSB, LDRB, and POP.
Reserved
A field in a control register or instruction format is reserved if the field is to be defined by the
implementation, or produces Unpredictable results if the contents of the field are not zero. These fields
are reserved for use in future extensions of the architecture or are implementation-specific. All
reserved bits not used by the implementation must be written as 0 and read as 0.
Thread-safe
In a multi-tasking environment, thread-safe functions use safeguard mechanisms when accessing
shared resources, to ensure correct operation without the risk of shared access conflicts.
Thumb instruction One or two halfwords that specify an operation for a processor to perform. Thumb instructions must be
halfword-aligned.
Unpredictable One cannot rely on the behavior. Unpredictable behavior must not represent security holes.
Unpredictable behavior must not halt or hang the processor, or any parts of the system.
Warm reset
Also known as a core reset. Initializes the majority of the processor excluding the debug controller and
debug logic. This type of reset is useful if debugging features of a processor.
Write Writes are defined as operations that have the semantics of a store. Writes include the Thumb
instructions STM, STR, STRH, STRB, and PUSH.
In a write-allocate cache, a cache miss on storing data causes a cache line to be allocated into the
Write-allocate (WA)
cache.
Write-back (WB) In a write-back cache, data is only written to main memory when it is forced out of the cache on line
replacement following a cache miss. Otherwise, writes by the processor only update the cache. This is
also known as copyback.
Write buffer A block of high-speed memory, arranged as a FIFO buffer, between the data cache and main memory,
whose purpose is to optimize stores to main memory.
Write-through (WT)
In a write-through cache, data is written to main memory at the same time as the cache is updated.
13.1 Description
The SAM4 series microcontrollers feature a number of complementary debug and test capabilities. The Serial
Wire/JTAG Debug Port (SWJ-DP) combining a Serial Wire Debug Port (SW-DP) and JTAG Debug (JTAG-DP) port
is used for standard debugging functions, such as downloading code and single-stepping through programs. It also
embeds a serial wire trace.
TMS
TCK/SWCLK
TDI
POR
Reset
and
Test TST
Host Debugger
PC
SWJ-DP
Emulator/Probe
SWJ-DP
Connector
SAM4
Test Adaptor
Tester
JTAG
Probe
JTAG
Chip n Chip 2
Connector
SAM4 Chip 1
DWT
4 watchpoints
FPB
PC sampler SWJ-DP
6 breakpoints
ITM
data sampler
software trace SWO trace
32 channels
interrupt trace TPIU
time stamping
CPU statistics
SW-DP or JTAG-DP mode is selected when JTAGSEL is low. It is not possible to switch directly between SWJ-DP
and JTAG boundary scan operations. A chip reset must be performed after JTAGSEL is changed.
13.5.3.1 SW-DP and JTAG-DP Selection Mechanism
Debug port selection mechanism is done by sending specific SWDIOTMS sequence. The JTAG-DP is selected by
default after reset.
Switch from JTAG-DP to SW-DP. The sequence is:
Send more than 50 SWCLKTCK cycles with SWDIOTMS = 1
Send the 16-bit sequence on SWDIOTMS = 0111100111100111 (0x79E7 MSB first)
Send more than 50 SWCLKTCK cycles with SWDIOTMS = 1
Switch from SWD to JTAG. The sequence is:
Send more than 50 SWCLKTCK cycles with SWDIOTMS = 1
Send the 16-bit sequence on SWDIOTMS = 0011110011100111 (0x3CE7 MSB first)
Send more than 50 SWCLKTCK cycles with SWDIOTMS = 1
23 22 21 20 19 18 17 16
PART NUMBER
15 14 13 12 11 10 9 8
PART NUMBER MANUFACTURER IDENTITY
7 6 5 4 3 2 1 0
MANUFACTURER IDENTITY 1
MANUFACTURER IDENTITY[11:1]
Set to 0x01F.
14.1 Description
The Reset Controller (RSTC), based on power-on reset cells, handles all the resets of the system without any
external components. It reports which reset occurred last.
The Reset Controller also drives independently or simultaneously the external reset and the peripheral and
processor resets.
Reset Controller
core_backup_reset
rstc_irq
vddcore_nreset
Reset proc_nreset
user_reset State
NRST Manager
NRST periph_nreset
Manager
nrst_out
exter_nreset
WDRPROC
wd_fault
SLCK
RSTC_MR
URSTIEN
RSTC_SR
URSTS
rstc_irq
NRSTL RSTC_MR Other
interrupt
URSTEN
sources
user_reset
NRST RSTC_MR
ERSTL
nrst_out
External Reset Timer exter_nreset
SLCK
Any
MCK Freq.
vddio_nreset
Processor Startup
= 2 cycles
proc_nreset
periph_nreset
NRST
(nrst_out)
SLCK
Any
MCK Freq.
wd_fault
Processor Startup
= 2 cycles
proc_nreset
periph_nreset
Only if
WDRPROC = 0
NRST
(nrst_out)
SLCK
Any
MCK Freq.
Write RSTC_CR
proc_nreset
if PROCRST=1
periph_nreset
if PERRST=1
NRST
(nrst_out)
if EXTRST=1
EXTERNAL RESET LENGTH
8 cycles (ERSTL=2)
SRCMP in RSTC_SR
SLCK
Any
MCK Freq.
NRST
proc_nreset
periph_nreset
NRST
(nrst_out)
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
EXTRST PERRST PROCRST
23 22 21 20 19 18 17 16
SRCMP NRSTL
15 14 13 12 11 10 9 8
RSTTYP
7 6 5 4 3 2 1 0
URSTS
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
ERSTL
7 6 5 4 3 2 1 0
URSTIEN URSTEN
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_WPMR).
15.1 Description
The Real-time Timer (RTT) is built around a 32-bit counter used to count roll-over events of the programmable 16-
bit prescaler driven from the 32-kHz slow clock source. It generates a periodic interrupt and/or triggers an alarm on
a programmed value.
The RTT can also be configured to be driven by the 1Hz RTC signal, thus taking advantage of a calibrated 1Hz
clock.
The slow clock source can be fully disabled to reduce power consumption when only an elapsed seconds count is
required.
RTT_MR
reload RTTINCIEN
SLCK 16-bit
Prescaler
0 set
RTT_MR RTT_SR RTTINC
RTC 1Hz
RTTRST 1 0 reset
RTT_MR
1 0 rtt_int
RTC1HZ
32-bit
Counter read
RTT_MR
RTT_SR
ALMIEN
reset
RTT_VR CRTV
RTT_SR ALMS
set
rtt_alarm
=
RTT_AR ALMV
SLCK
RTPRES - 1
Prescaler
RTTINC (RTT_SR)
ALMS (RTT_SR)
APB Interface
23 22 21 20 19 18 17 16
RTTDIS RTTRST RTTINCIEN ALMIEN
15 14 13 12 11 10 9 8
RTPRES
7 6 5 4 3 2 1 0
RTPRES
23 22 21 20 19 18 17 16
ALMV
15 14 13 12 11 10 9 8
ALMV
7 6 5 4 3 2 1 0
ALMV
23 22 21 20 19 18 17 16
CRTV
15 14 13 12 11 10 9 8
CRTV
7 6 5 4 3 2 1 0
CRTV
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RTTINC ALMS
16.1 Description
The Real-time Clock (RTC) peripheral is designed for very low power consumption. For optimal functionality, the
RTC requires an accurate external 32.768 kHz clock, which can be provided by a crystal oscillator.
It combines a complete time-of-day clock with alarm and a Gregorian or Persian calendar, complemented by a
programmable periodic interrupt. The alarm and calendar registers are accessed by a 32-bit data bus.
The time and calendar values are coded in binary-coded decimal (BCD) format. The time format can be 24-hour
mode or 12-hour mode with an AM/PM indicator.
Updating time and calendar fields and configuring the alarm fields are performed by a parallel capture on the 32-bit
data bus. An entry control is performed to avoid loading registers with incompatible BCD format data or with an
incompatible date according to the current month/year/century.
A clock divider calibration circuitry can be used to compensate for crystal oscillator frequency inaccuracy.
An RTC output can be programmed to generate several waveforms, including a prescaled clock derived from
32.768 kHz.
Entry Interrupt
System Bus User Interface Alarm RTC Interrupt
Control Control
16.4.2 Interrupt
RTC interrupt line is connected on one of the internal sources of the interrupt controller. RTC interrupt requires the
interrupt controller to be programmed first.
16.5.3 Alarm
The RTC has five programmable fields: month, date, hours, minutes and seconds.
Each of these fields can be enabled or disabled to match the alarm condition:
If all the fields are enabled, an alarm flag is generated (the corresponding flag is asserted and an interrupt
generated if enabled) at a given month, date, hour/minute/second.
If only the seconds field is enabled, then an alarm is generated every minute.
Depending on the combination of fields enabled, a large number of possibilities are available to the user ranging
from minutes to 365/366 days.
Hour, minute and second matching alarm (SECEN, MINEN, HOUREN) can be enabled independently of SEC,
MIN, HOUR fields.
Note: To change one of the SEC, MIN, HOUR, DATE, MONTH fields, it is recommended to disable the field before changing
the value and then re-enable it after the change has been made. This requires up to three accesses to the
RTC_TIMALR or RTC_CALALR. The first access clears the enable corresponding to the field to change (SECEN,
MINEN, HOUREN, DATEEN, MTHEN). If the field is already cleared, this access is not required. The second access
performs the change of the value (SEC, MIN, HOUR, DATE, MONTH). The third access is required to re-enable the
field by writing 1 in SECEN, MINEN, HOUREn, DATEEN, MTHEN fields.
Read RTC_SR
Polling or
IRQ (if enabled)
No
ACKUPD
=1?
Yes
End
RTC
32.768 kHz
Integrator CORRECTION, HIGHPPM
Comparator NEGPPM
Other Logic
Monotonic 1Hz
Counter value 32.768 kHz +50ppm Nominal 32.768 kHz
Phase adjustment
(~4ms) 32.768 kHz -50ppm
-25ppm
Crystal clock
NEGATIVE CORRECTION
The inaccuracy of a crystal oscillator at typical room temperature (20 ppm at 2025 C) can be compensated if a
reference clock/signal is used to measure such inaccuracy. This kind of calibration operation can be set up during
0 0 0 0
1 Hz 1 1 Hz 1
32 Hz 2 32 Hz 2
64 Hz 3 64 Hz 3
RTCOUT0 RTCOUT1
512 Hz 4 512 Hz 4
toggle_alarm 5 toggle_alarm 5
flag_alarm 6 flag_alarm 6
pulse 7 pulse 7
RTC_MR(OUT0) RTC_MR(OUT1)
flag_alarm
RTC_SCCR(ALRCLR) RTC_SCCR(ALRCLR)
toggle_alarm
pulse
Thigh
Tperiod Tperiod
23 22 21 20 19 18 17 16
CALEVSEL
15 14 13 12 11 10 9 8
TIMEVSEL
7 6 5 4 3 2 1 0
UPDCAL UPDTIM
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_WPMR).
23 22 21 20 19 18 17 16
OUT1 OUT0
15 14 13 12 11 10 9 8
HIGHPPM CORRECTION
7 6 5 4 3 2 1 0
NEGPPM PERSIAN HRMOD
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_WPMR).
The value obtained must be rounded to the nearest integer prior to being programmed into CORRECTION field.
If HIGHPPM = 1, then the clock frequency correction range is from 30.5 ppm up to 1950 ppm. The RTC accuracy is
less than 1 ppm for a range correction from 30.5 ppm up to 90 ppm.
The correction field must be programmed according to the required correction in ppm; the formula is as follows:
3906
CORRECTION = ------------ 1
ppm
The value obtained must be rounded to the nearest integer prior to be programmed into CORRECTION field.
If NEGPPM is set to 1, the ppm correction is negative (used to correct crystals that are faster than the nominal 32.768
kHz).
23 22 21 20 19 18 17 16
AMPM HOUR
15 14 13 12 11 10 9 8
MIN
7 6 5 4 3 2 1 0
SEC
23 22 21 20 19 18 17 16
DAY MONTH
15 14 13 12 11 10 9 8
YEAR
7 6 5 4 3 2 1 0
CENT
23 22 21 20 19 18 17 16
HOUREN AMPM HOUR
15 14 13 12 11 10 9 8
MINEN MIN
7 6 5 4 3 2 1 0
SECEN SEC
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_WPMR).
Note: To change one of the SEC, MIN, HOUR fields, it is recommended to disable the field before changing the value and then re-
enable it after the change has been made. This requires up to three accesses to the RTC_TIMALR. The first access clears the
enable corresponding to the field to change (SECEN, MINEN, HOUREN). If the field is already cleared, this access is not
required. The second access performs the change of the value (SEC, MIN, HOUR). The third access is required to re-enable the
field by writing 1 in SECEN, MINEN, HOUREN fields.
23 22 21 20 19 18 17 16
MTHEN MONTH
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_WPMR).
Note: To change one of the DATE, MONTH fields, it is recommended to disable the field before changing the value and then re-enable
it after the change has been made. This requires up to three accesses to the RTC_CALALR. The first access clears the enable
corresponding to the field to change (DATEEN, MTHEN). If the field is already cleared, this access is not required. The second
access performs the change of the value (DATE, MONTH). The third access is required to re-enable the field by writing 1 in
DATEEN, MTHEN fields.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TDERR CALEV TIMEV SEC ALARM ACKUPD
Note: The time event is selected in the TIMEVSEL field in the Control Register (RTC_CR) and can be any one of the following events:
minute change, hour change, noon, midnight (day change).
Note: The calendar event is selected in the CALEVSEL field in the Control Register (RTC_CR) and can be any one of the following
events: week change, month change and year change.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TDERRCLR CALCLR TIMCLR SECCLR ALRCLR ACKCLR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TDERREN CALEN TIMEN SECEN ALREN ACKEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TDERRDIS CALDIS TIMDIS SECDIS ALRDIS ACKDIS
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TDERR CAL TIM SEC ALR ACK
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
NVCALALR NVTIMALR NVCAL NVTIM
17.1 Description
The Watchdog Timer (WDT) is used to prevent system lock-up if the software becomes trapped in a deadlock. It
features a 12-bit down counter that allows a watchdog period of up to 16 seconds (slow clock around 32 kHz). It
can generate a general reset or a processor reset only. In addition, it can be stopped while the processor is in
debug mode or idle mode.
write WDT_MR
WDT_MR
WDV
WDT_CR
WDRSTT reload
1 0
12-bit Down
Counter
WDT_MR
reload
WDD Current
1/128 SLCK
Value
<= WDD
WDT_MR
WDRSTEN
=0
wdt_fault
(to Reset Controller)
set
WDUNF wdt_int
set reset
WDERR
read WDT_SR reset WDFIEN
or
reset WDT_MR
if WDRSTEN is 1
FFF
Forbidden
Window
WDD
Permitted
Window
WDT_CR.WDRSTT=1
Watchdog
Fault
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
WDRSTT
KEY: Password
Value Name Description
0xA5 PASSWD Writing any other value in this field aborts the write operation.
23 22 21 20 19 18 17 16
WDD
15 14 13 12 11 10 9 8
WDDIS WDRPROC WDRSTEN WDFIEN WDV
7 6 5 4 3 2 1 0
WDV
Note: The first write access prevents any further modification of the value of this register. Read accesses remain possible.
Note: The WDD and WDV values must not be modified within three slow clock periods following a restart of the watchdog performed by
a write access in WDT_CR. Any modification will cause the watchdog to trigger an end of period earlier than expected.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
WDERR WDUNF
18.1 Description
The Supply Controller (SUPC) controls the supply voltages of the system and manages the Backup mode. In this
mode, current consumption is reduced to a few microamps for backup power retention. Exit from this mode is
possible on multiple wake-up sources. The SUPC also generates the slow clock by selecting either the low-power
RC oscillator or the low-power crystal oscillator.
Supply Controller
bod_out
Brown-Out
Detector SMRSTEN
VDDCORE SMIEN vddcore_nreset
Supply Reset
SMSMPL SMTH
Monitor Controller
Controller
Programmable
Supply Monitor
VDDIO sm_out
NRST
proc_nreset
Zero-Power periph_nreset
por_io_out
Power-On Reset ice_nreset
VDDIO
Backup Area
XTALSEL SLCK
OSCBYPASS
Slow SLCK
XIN32 Real-Time
XTAL OSC 32kHz Clock Timer
XOUT32 Controller
RC OSC 32kHz
sm_out rtt_alarm
SMEN RTTEN
WKUP0-WKUP15 Real-Time
LPDBC Wake-Up rtc_alarm Clock
LPDBCEN0 Controller
LPDBCEN1 RTCEN
RTCOUT0
LPDBCCLR
RTCOUT1
WKUPEN0..15
WKUPT0..15 clear
WKUPDBC General-Purpose
Backup Registers
ONREG VROFF
wake_up VDDIN
on/off
Voltage Regulator Core Voltage
Controller Regulator
VDDOUT
18.4.1 Overview
The device is divided into two power supply areas:
VDDIO power supply: includes the Supply Controller, part of the Reset Controller, the slow clock switch, the
general-purpose backup registers, the supply monitor and the clock which includes the Real-time Timer and
the Real-time Clock.
Core power supply: includes part of the Reset Controller, the Brownout Detector, the processor, the SRAM
memory, the Flash memory and the peripherals.
The Supply Controller (SUPC) controls the supply voltage of the core power supply. The SUPC intervenes when
the VDDIO power supply rises (when the system is starting) or when Backup mode is entered.
The SUPC also integrates the slow clock generator, which is based on a 32 kHz crystal oscillator, and an
embedded 32 kHz RC oscillator. The slow clock defaults to the RC oscillator, but the software can enable the
crystal oscillator and select it as the slow clock source.
The SUPC and the VDDIO power supply have a reset circuitry based on a zero-power power-on reset cell. The
zero-power power-on reset allows the SUPC to start correctly as soon as the VDDIO voltage becomes valid.
At start-up of the system, once the backup voltage VDDIO is valid and the embedded 32 kHz RC oscillator is
stabilized, the SUPC starts up the core by sequentially enabling the internal voltage regulator. The SUPC waits
until the core voltage VDDCORE is valid, then releases the reset signal of the core vddcore_nreset signal.
Once the system has started, the user can program a supply monitor and/or a brownout detector. If the supply
monitor detects a voltage level on VDDIO that is too low, the SUPC asserts the reset signal of the core
vddcore_nreset signal until VDDIO is valid. Likewise, if the brownout detector detects a core voltage level
VDDCORE that is too low, the SUPC asserts the reset signal vddcore_nreset until VDDCORE is valid.
When Backup mode is entered, the SUPC sequentially asserts the reset signal of the core power supply
vddcore_nreset and disables the voltage regulator, in order to supply only the VDDIO power supply. Current
consumption is reduced to a few microamps for the backup part retention. Exit from this mode is possible on
multiple wake-up sources including an event on WKUP pins, or a clock alarm. To exit this mode, the SUPC
operates in the same way as system start-up.
3.3 V
Threshold
0V
Read SUPC_SR
Zero-Power POR
Backup Power Supply
Zero-Power Power-On
Reset Cell output
22 - 42 kHz RC
Oscillator output
vr_on
Fast RC
Oscillator output
bodcore_in
vddcore_nreset
RSTC.ERSTL
default = 2
NRST
(no ext. drive assumed)
periph_nreset
proc_nreset
Note: After proc_nreset rising, the core starts fetching instructions from Flash at 4 MHz.
RTCEN
rtc_alarm
RTTEN
rtt_alarm
Low-power LPDBC
WKUPT1
Tamper Detection RTCOUT0
Logic LPDBCS1
LPDBCEN1
Falling/Rising
Edge Detect Debouncer
WKUPT0
WKUPEN0 WKUPIS0
Falling/Rising WKUPDBC
WKUP0
Edge Detect
SLCK WKUPS
WKUPT1 WKUPEN1 WKUPIS1
Debouncer
WKUPT15 LPDBCCLR
WKUPEN15 WKUPIS15
Falling/Rising
WKUP15 Edge Detect
Figure 18-5. Entering and Exiting Backup Mode with a WKUP Pin
WKUPDBC > 0
WKUPTx=0
WKUPx Edge detect + Edge detect +
debounce time debounce time
VROFF=1 VROFF=1
MCU
RTCOUTx
Pull-up
Resistor
WKUP0
Pull-up
Resistor
GND WKUP1
GND
GND
MCU
RTCOUTx
WKUP0
WKUP1
Pull-down
Resistors GND
GND GND
The debouncing period duration is configurable. The period is set for all debouncers (i.e., the duration cannot be
adjusted for each debouncer). The number of successive identical samples to wake up the system can be
configured from 2 up to 8 in the LPDBC field of SUPC_WUMR. The period of time between two samples can be
configured by programming the TPERIOD field in the RTC_MR. Power parameters can be adjusted by modifying
the period of time in the THIGH field in RTC_MR.
The wake-up polarity of the inputs can be independently configured by writing WKUPT0 and/ or WKUPT1 fields in
SUPC_WUMR.
In order to determine which wake-up/tamper pin triggers the system wake-up, a status flag is associated for each
low-power debouncer. These flags are read in SUPC_SR.
A debounce event (tamper detection) can perform an immediate clear (0 delay) on the first half the general-
purpose backup registers (GPBR). The LPDBCCLR bit must be set in SUPC_WUMR.
Note that it is not mandatory to use the RTCOUTx pin when using the WKUP0/WKUP1 pins as tampering inputs in
any mode. Using the RTCOUTx pin provides a sampling mode to further reduce the power consumption of the
MCU
Pull-up
Resistor
WKUP0
Pull-up
Resistor
GND WKUP1
GND
GND
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
XTALSEL VROFF
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_MR).
KEY: Password
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
SMIEN SMRSTEN SMSMPL
7 6 5 4 3 2 1 0
SMTH
23 22 21 20 19 18 17 16
OSCBYPASS
15 14 13 12 11 10 9 8
ONREG BODDIS BODRSTEN
7 6 5 4 3 2 1 0
This register can only be written if the WPEN bit is cleared in the System Controller Write Protection Mode Register
(SYSC_MR).
23 22 21 20 19 18 17 16
LPDBC
15 14 13 12 11 10 9 8
WKUPDBC
7 6 5 4 3 2 1 0
LPDBCCLR LPDBCEN1 LPDBCEN0 RTCEN RTTEN SMEN
23 22 21 20 19 18 17 16
WKUPT7 WKUPT6 WKUPT5 WKUPT4 WKUPT3 WKUPT2 WKUPT1 WKUPT0
15 14 13 12 11 10 9 8
WKUPEN15 WKUPEN14 WKUPEN13 WKUPEN12 WKUPEN11 WKUPEN10 WKUPEN9 WKUPEN8
7 6 5 4 3 2 1 0
WKUPEN7 WKUPEN6 WKUPEN5 WKUPEN4 WKUPEN3 WKUPEN2 WKUPEN1 WKUPEN0
23 22 21 20 19 18 17 16
WKUPIS7 WKUPIS6 WKUPIS5 WKUPIS4 WKUPIS3 WKUPIS2 WKUPIS1 WKUPIS0
15 14 13 12 11 10 9 8
LPDBCS1 LPDBCS0
7 6 5 4 3 2 1 0
OSCSEL SMOS SMS SMRSTS BODRSTS SMWS WKUPS
Note: Because of the asynchronism between the Slow Clock (SLCK) and the System Clock (MCK), the status register flag reset is taken
into account only 2 slow clock cycles after the read of the SUPC_SR.
This register is located in the VDDIO domain.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
19.1 Description
The System Controller embeds 256 bits of General Purpose Backup registers organized as Eight 32-bit registers.
It is possible to generate an immediate clear of the content of General Purpose Backup registers 0 to 3 (first half) if
a Low-power Debounce event is detected on one of the wakeup pins, WKUP0 or WKUP1. The content of the other
General Purpose Backup registers (second half) remains unchanged.
The Supply Controller module must be programmed accordingly. In the register SUPC_WUMR in the Supply
Controller module, LPDBCCLR, LPDBCEN0 and/or LPDBCEN1 bit must be configured to 1 and LPDBC must be
other than 0.
If a Tamper event has been detected, it is not possible to write to the General Purpose Backup registers while the
LPDBCS0 or LPDBCS1 flags are not cleared in the Supply Controller Status Register (SUPC_SR).
23 22 21 20 19 18 17 16
GPBR_VALUE
15 14 13 12 11 10 9 8
GPBR_VALUE
7 6 5 4 3 2 1 0
GPBR_VALUE
These registers are reset at first power-up and on each loss of VVDIO.
20.1 Description
The Enhanced Embedded Flash Controller (EEFC) provides the interface of the Flash block with the 32-bit internal
bus.
Its 128-bit or 64-bit wide memory interface increases performance. It also manages the programming, erasing,
locking and unlocking sequences of the Flash using a full set of commands. One of the commands returns the
embedded Flash descriptor definition that informs the system about the Flash organization, thus making the
software generic.
ea
Ar
e
od
C
@FBA+0x010
@FBA+0x000
Write Stop Unique Identifier
(Flash Command SPUI) Write Start Unique Identifier
(Flash Command STUI)
@FBA+0x3FF
a
re
rA
ie
tif
en
Id
e
qu
ni
@FBA+0x010
U
Page (m-1)
Master Clock
ARM Request
(32-bit)
@0 @+4 @ +8 @+12 @+16 @+20 @+24 @+28 @+32
anticipation of @16-31
Data to ARM XXX Bytes 03 Bytes 47 Bytes 811 Bytes 1215 Bytes 1619 Bytes 2023 Bytes 2427 Bytes 2831
Note: When FWS is equal to 0, all the accesses are performed in a single-cycle access.
ARM Request
(32-bit)
@0 @+4 @+8 @+12 @+16 @+20 @+24 @+28 @+32 @+36 @+40 @+44 @+48 @+52
wait 3 cycles before
128-bit data is stable anticipation of @16-31 anticipation of @32-47
@0/4/8/12 are ready
@16/20/24/28 are ready
Flash Access Bytes 015 Bytes 1631 Bytes 3247 Bytes 486
Data to ARM XXX 03 47 811 1215 1619 2023 2427 2831 3235 3639 4043 4447 4851
Note: When FWS is between 1 and 3, in case of sequential reads, the first access takes (FWS + 1) cycles. The following accesses take
only one cycle.
Flash Memory
128-bit words
B0 B1 B2 B3 B4 B5 B6 B7 P0 P1 P2 P3 P4 P5 P6 P7
Master Clock
ARM Request
(32-bit)
@Byte 0 @4 @8 @ 12 @ 16 @ 20 @ 24 @ 28 @ 32 @ 36
Data to ARM XXX Bytes 03 47 811 1215 1619 2023 2427 2831 3235
In order to execute one of these commands, select the required command using the FCMD field in the Flash
Command register (EEFC_FCR). As soon as EEFC_FCR is written, the FRDY flag and the FVALUE field in the
Flash Result register (EEFC_FRR) are automatically cleared. Once the current command has completed, the
FRDY flag is automatically set. If an interrupt has been enabled by setting the bit EEFC_FMR.FRDY, the
corresponding interrupt line of the interrupt controller is activated. (Note that this is true for all commands except
for the STUI command. The FRDY flag is not set when the STUI command has completed.)
All the commands are protected by the same keyword, which must be written in the eight highest bits of
EEFC_FCR.
Writing EEFC_FCR with data that does not contain the correct key and/or with an invalid command has no effect
on the whole memory plane, but the FCMDE flag is set in the Flash Status register (EEFC_FSR). This flag is
automatically cleared by a read access to EEFC_FSR.
When the current command writes or erases a page in a locked region, the command has no effect on the whole
memory plane, but the FLOCKE flag is set in EEFC_FSR. This flag is automatically cleared by a read access to
EEFC_FSR.
No
Check if FRDY flag Set
Yes
No
Check if FRDY flag Set
Yes
Yes
Check if FLOCKE flag Set Locking region violation
No
Yes
Check if FCMDE flag Set Bad keyword violation
No
Command Successful
CA FE CA FE FF FF FF FF
CA FE CA FE 0xX1C FF FF FF FF 0xX1C
CA FE CA FE 0xX18 FF FF FF FF 0xX18
address space
CA FE CA FE 0xX14 for FF FF FF FF 0xX14
CA FE CA FE 0xX10 Page N FF FF FF FF 0xX10
CA FE CA FE 0xX0C FF FF FF FF 0xX0C
CA FE CA FE 0xX08 FF FF FF FF 0xX08
CA FE CA FE 0xX04 FF FF FF FF 0xX04
CA FE CA FE 0xX00 FF FF FF FF 0xX00
Before programming: Unerased page in Flash array Step 1: Flash array after page erase
DE CA DE CA DE CA DE CA
DE CA DE CA 0xX1C DE CA DE CA 0xX1C
DE CA DE CA 0xX18 DE CA DE CA 0xX18
address space address space
DE CA DE CA 0xX14 for DE CA DE CA 0xX14 for
DE CA DE CA 0xX10 latch buffer DE CA DE CA 0xX10 Page N
DE CA DE CA 0xX0C DE CA DE CA 0xX0C
DE CA DE CA 0xX08 DE CA DE CA 0xX08
DE CA DE CA 0xX04 DE CA DE CA 0xX04
DE CA DE CA 0xX00 DE CA DE CA 0xX00
Step 2: Writing a page in the latch buffer Step 3: Page in Flash array after issuing
WP command and FRDY=1
FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 0xX1C
FF FF FF FF FF FF FF FF 0xX18
address space
FF FF FF FF for FF FF FF FF 0xX14
FF FF FF FF Page N FF FF FF FF 0xX10
FF FF FF FF CA FE CA FE 0xX0C
FF FF FF FF CA FE CA FE 0xX08
FF FF FF FF FF FF FF FF 0xX04
FF FF FF FF FF FF FF FF 0xX00
Step 1: Flash array after page erase Step 2: Flash array after programming
64-bit at address 0xX08 (write latch buffer + WP)
FF FF FF FF FF FF FF FF
FF FF FF FF 0xX1C CA FE CA FE 0xX1C
FF FF FF FF 0xX18 CA FE CA FE 0xX18
FF FF FF FF 0xX14 CA FE CA FE 0xX14
FF FF FF FF 0xX10 CA FE CA FE 0xX10
CA FE CA FE 0xX0C CA FE CA FE 0xX0C
CA FE CA FE 0xX08 CA FE CA FE 0xX08
CA FE CA FE 0xX04 CA FE CA FE 0xX04
CA FE CA FE 0xX00 CA FE CA FE 0xX00
Step 3: Flash array after programming Step 4: Flash array after programming
a second 64-bit data at address 0xX00 a 128-bit data word at address 0xX10
(write latch buffer + WP) (write latch buffer + WP)
FF FF FF FF FF FF FF FF
FF FF FF FF 0xX1C FF FF FF FF 0xX1C
4 x 32 bits = FF FF FF FF 0xX18 FF FF FF FF 0xX18
address space
1 Flash word FF FF FF FF 0xX14 for FF FF FF FF 0xX14
FF FF FF FF 0xX10 Page N FF FF FF FF 0xX10
FF FF FF FF 0xX0C xx xx xx xx 0xX0C
4 x 32 bits = FF FF FF FF 0xX08 xx xx xx 55 0xX08
1 Flash word 0xX04 0xX04
xx xx xx xx xx xx xx xx
xx xx xx AA 0xX00 xx xx xx AA 0xX00
Step 1: Flash array after programming first byte (0xAA) Step 2: Flash array after programming second byte (0x55)
64-bit used at address 0xX00 (write latch buffer + WP) 64-bit used at address 0xX08 (write latch buffer + WP)
Note: The byte location shown here is for example only, it can be any byte location within a 64-bit word.
If the processor is fetching code from the Flash memory while the EPA or ES command is being executed, the
processor accesses are stalled until the EPA command is completed. To avoid stalling the processor, the code can
be run out of internal SRAM.
2. When erasing is completed, the bit EEFC_FSR.FRDY rises. If an interrupt has been enabled by setting the
bit EEFC_FMR.FRDY, the interrupt line of the interrupt controller is activated.
Three errors can be detected in EEFC_FSR after an erasing sequence:
Command Error: A bad keyword has been written in EEFC_FCR.
Lock Error: At least one page to be erased belongs to a locked region. The erase command has been
refused, no page has been erased. A command must be run previously to unlock the corresponding region.
Flash Error: At the end of the erase period, the EraseVerify test of the Flash memory has failed.
20.4.3.4 Lock Bit Protection
Lock bits are associated with several pages in the embedded Flash memory plane. This defines lock regions in the
embedded Flash memory plane. They prevent writing/erasing protected pages.
The lock sequence is the following:
1. Execute the Set Lock Bit command by writing EEFC_FCR.FCMD with the SLB command and
EEFC_FCR.FARG with a page number to be protected.
2. When the locking completes, the bit EEFC_FSR.FRDY rises. If an interrupt has been enabled by setting the
bit EEFC_FMR.FRDY, the interrupt line of the interrupt controller is activated.
3. The result of the SLB command can be checked running a Get Lock Bit (GLB) command.
Note: The value of the FARG argument passed together with SLB command must not exceed the higher lock bit index
available in the product.
Two errors can be detected in EEFC_FSR after a programming sequence:
Command Error: A bad keyword has been written in EEFC_FCR.
Flash Error: At the end of the programming, the EraseVerify or WriteVerify test of the Flash memory has
failed.
It is possible to clear lock bits previously set. After the lock bits are cleared, the locked region can be erased or
programmed. The unlock sequence is the following:
1. Execute the Clear Lock Bit command by writing EEFC_FCR.FCMD with the CLB command and
EEFC_FCR.FARG with a page number to be unprotected.
2. When the unlock completes, the bit EEFC_FSR.FRDY rises. If an interrupt has been enabled by setting the
bit EEFC_FMR.FRDY, the interrupt line of the interrupt controller is activated.
Note: The value of the FARG argument passed together with CLB command must not exceed the higher lock bit index
available in the product.
Two errors can be detected in EEFC_FSR after a programming sequence:
Command Error: A bad keyword has been written in EEFC_FCR.
23 22 21 20 19 18 17 16
SCOD
15 14 13 12 11 10 9 8
FWS
7 6 5 4 3 2 1 0
FRDY
23 22 21 20 19 18 17 16
FARG
15 14 13 12 11 10 9 8
FARG
7 6 5 4 3 2 1 0
FCMD
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FLERR FLOCKE FCMDE FRDY
23 22 21 20 19 18 17 16
FVALUE
15 14 13 12 11 10 9 8
FVALUE
7 6 5 4 3 2 1 0
FVALUE
21.1 Description
The Fast Flash Programming Interface (FFPI) provides parallel high-volume programming using a standard gang
programmer. The parallel interface is fully handshaked and the device is considered to be a standard EEPROM.
Additionally, the parallel protocol offers an optimized access to all the embedded Flash functionalities.
Although the Fast Flash Programming mode is a dedicated mode for high volume programming, this mode is not
designed for in-situ programming.
VDDIO TST
VDDIO PGMEN0
VDDIO PGMEN1
VDDCORE
VDDIO
NCMD PGMNCMD
RDY PGMRDY VDDPLL
NOE PGMNOE GND
NVALID PGMNVALID
MODE[3:0] PGMM[3:0]
DATA[15:0] PGMD[15:0]
0 - 50MHz XIN
XIN This input can be tied to GND. In this Input 32 KHz to 50 MHz
case, the device is clocked by the internal
RC oscillator.
Test
TST Test Mode Select Input High Must be connected to VDDIO
PGMEN0 Test Mode Select Input High Must be connected to VDDIO
PGMEN1 Test Mode Select Input High Must be connected to VDDIO
PGMEN2 Test Mode Select Input Low Must be connected to GND
PIO
PGMNCMD Valid command available Input Low Pulled-up input at reset
When MODE is equal to CMDE, then a new command (strobed on DATA[15:0] signals) is stored in the command
register.
NCMD 2 4
3 5
RDY
NOE
NVALID
DATA[15:0]
1
MODE[3:0]
NCMD 2 12
3 13
RDY
NOE 5 9
NVALID 7 11
4 6 8 10
MODE[3:0] ADDR
The Flash command Write Page and Lock (WPL) is equivalent to the Flash Write Command. However, the lock
bit is automatically set at the end of the Flash write operation. As a lock region is composed of several pages, the
programmer writes to the first pages of the lock region using Flash write commands and writes to the last page of
the lock region using a Flash write and lock command.
The Flash command Erase Page and Write (EWP) is equivalent to the Flash Write Command. However, before
programming the load buffer, the page is erased.
The Flash command Erase Page and Write the Lock (EWPL) combines EWP and WPL commands.
21.3.5.3 Flash Full Erase Command
This command is used to erase the Flash memory planes.
All lock regions must be unlocked before the Full Erase command by using the CLB command. Otherwise, the
erase command is aborted and no page is erased.
Lock bits can be read using Get Lock Bit command (GLB). The nth lock bit is active when the bit n of the bit mask
is set.
General-purpose NVM bits can be read using the Get GPNVM Bit command (GGPB). The nth GP NVM bit is
active when bit n of the bit mask is set.
Once the security bit is set, it is not possible to access FFPI. The only way to erase the security bit is to erase the
Flash.
In order to erase the Flash, the user must perform the following:
1. Power-off the chip.
2. Power-on the chip with TST = 0.
3. Assert Erase during a period of more than 220 ms.
4. Power-off the chip.
Then it is possible to return to FFPI mode and check that Flash is erased.
21.3.5.7 Memory Write Command
This command is used to perform a write access to any memory location.
22.1 Description
The Cortex-M Cache Controller (CMCC) is a 4-Way set associative unified cache controller. It integrates a
controller, a tag directory, data memory, metadata memory and a configuration interface.
Cortex-M Interface
Memory Interface
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CLSIZE CSIZE
7 6 5 4 3 2 1 0
LCKDOWN WAYNUM RRP LRUP RANDP GCLK AP
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
GCLKDIS
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CSTS
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
INVALL
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
INDEX
7 6 5 4 3 2 1 0
INDEX
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
MODE
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
MENABLE
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
SWRST: Monitor
0: No effect.
1: Resets the event counter register.
23 22 21 20 19 18 17 16
EVENT_CNT
15 14 13 12 11 10 9 8
EVENT_CNT
7 6 5 4 3 2 1 0
EVENT_CNT
23.1 Description
The Cyclic Redundancy Check Calculation Unit (CRCCU) has its own DMA which functions as a Master with the
Bus Matrix. Three different polynomials are available: CCITT802.3, CASTAGNOLI and CCITT16.
The CRCCU is designed to perform data integrity checks of off-/on-chip memories as a background task without
CPU intervention.
Context FSM
TR_CRC
TR_ADDR
HRDATA
AHB Interface
HTRANS
HSIZE
AHB-Layer
External
Bus Interface Flash AHB SRAM
TR_ADDR defines the start address of memory area targeted for CRC calculation.
TR_CTRL defines the buffer transfer size, the transfer width (byte, halfword, word) and the transfer-completed
interrupt enable.
To start the CRCCU, set the CRC enable bit (ENABLE) and configure the mode of operation in the CRCCU Mode
Register (CRCCU_MR), then configure the Transfer Control Registers and finally, set the DMA enable bit
(DMAEN) in the CRCCU DMA Enable Register (CRCCU_DMA_EN).
When the CRCCU is enabled, the CRCCU reads the predefined amount of data (defined in TR_CTRL) located
from TR_ADDR start address and computes the checksum.
The CRCCU_SR contains the temporary CRC value.
The BTSIZE field located in the TR_CTRL register (located in memory), is automatically decremented if its value is
different from zero. Once the value of the BTSIZE field is equal to zero, the CRCCU is disabled by hardware. In
this case, the relevant CRCCU DMA Status Register bit DMASR is automatically cleared.
If the COMPARE field of the CRCCU_MR is set to true, the TR_CRC (Transfer Reference Register) is compared
with the last CRC computed. If a mismatch occurs, an error flag is set and an interrupt is raised (if unmasked).
The CRCCU accesses the memory by single access (TRWIDTH size) in order not to limit the bandwidth usage of
the system, but the DIVIDER field of the CRCCU Mode Register can be used to lower it by dividing the frequency
of the single accesses.
The CRCCU scrolls the defined memory area using ascending addresses.
In order to compute the CRC for a memory size larger than 256 Kbytes or for non-contiguous memory area, it is
possible to re-enable the CRCCU on the new memory area and the CRC will be updated accordingly. Use the
RESET field of the CRCCU_CR to reset the CRCCU Status Register to its default value (0xFFFFFFFF).
24.1 Description
The SAM-BA Boot Program integrates an array of programs permitting download and/or upload into the different
memories of the product.
No
Device USB Enumeration Character # received
Setup Successful ? from UART0?
Yes Yes
The SAM-BA Boot program seeks to detect a source clock either from the embedded main oscillator with external
crystal (main oscillator enabled) or from a supported frequency signal applied to the XIN pin (main oscillator in
Bypass mode).
If a clock is found from the two possible sources above, the boot program checks to verify that the frequency is one
of the supported external frequencies. If the frequency is one of the supported external frequencies, USB
activation is allowed, else (no clock or frequency other than one of the supported external frequencies), the internal
12 MHz RC oscillator is used as main clock and USB clock is not allowed due to frequency drift of the 12 MHz RC
oscillator.
Mode commands:
Normal mode configures SAM-BA Monitor to send/receive data in binary format,
Terminal mode configures SAM-BA Monitor to send/receive data in ascii format.
Write commands: Write a byte (O), a halfword (H) or a word (W) to the target.
Address: Address in hexadecimal.
Value: Byte, halfword or word to write in hexadecimal.
Output: >.
Read commands: Read a byte (o), a halfword (h) or a word (w) from the target.
Address: Address in hexadecimal
Output: The byte, halfword or word read in hexadecimal following by >
Send a file (S): Send a file to a specified address
Address: Address in hexadecimal
Output: >.
Note: There is a time-out on this command which is reached when the prompt > appears before the end of the command
execution.
Receive a file (R): Receive data into a file from a specified address
Address: Address in hexadecimal
NbOfBytes: Number of bytes in hexadecimal to receive
Output: >
Go (G): Jump to a specified address and execute the code
Address: Address to jump in hexadecimal
Output: >
Get Version (V): Return the SAM-BA boot version
Output: >
Host Device
ACK
ACK
ACK
EOT
ACK
The device also handles some class requests defined in the CDC class.
/* Initialize the function pointer (retrieve function address from NMI vector)
*/
25.1 Description
The Bus Matrix implements a multi-layer AHB that enables parallel access paths between multiple AHB masters
and slaves in a system, thus increasing overall bandwidth. The Bus Matrix interconnects AHB masters to AHB
slaves. The normal latency to connect a master to a slave is one cycle. The exception is the default master of the
accessed slave which is connected directly (zero cycle latency).
The Bus Matrix user interface also provides a System I/O Configuration user interface with registers that support
application-specific features.
Masters 0 1 2 3
Slaves Cortex-M4 I/D Bus Cortex-M4 S Bus PDC CRCCU
0 Internal SRAM X X X
1 Internal ROM X X X
2 Internal Flash X - X
3 External Bus Interface X X X
4 Peripheral Bridge X X
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
ULBT
23 22 21 20 19 18 17 16
FIXED_DEFMSTR DEFMSTR_TYPE
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SLOT_CYCLE
23 22 21 20 19 18 17 16
M4PR
15 14 13 12 11 10 9 8
M3PR M2PR
7 6 5 4 3 2 1 0
M1PR M0PR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
SYSIO12 SYSIO11 SYSIO10
7 6 5 4 3 2 1 0
SYSIO7 SYSIO6 SYSIO5 SYSIO4
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SMC_NFCS3 SMC_NFCS2 SMC_NFCS1 SMC_NFCS0
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
26.1 Description
The External Bus Interface (EBI) is designed to ensure the successful data transfer between several external
devices and the ARM-based microcontroller. The Static Memory Controller (SMC) is part of the EBI.
This SMC can handle several types of external memory and peripheral devices, such as SRAM, PSRAM, PROM,
EPROM, EEPROM, LCD Module, NOR Flash and NAND Flash.
The SMC generates the signals that control the access to the external memory devices or peripheral devices. It
has 4 Chip Selects, a 24-bit address bus, and an 8-bit data bus. Separate read and write control signals allow for
direct memory and peripheral interfacing. Read and write signal waveforms are fully adjustable.
The SMC can manage wait requests from external devices to extend the current access. The SMC is provided with
an automatic Slow clock mode. In Slow clock mode, it switches from user-programmed waveforms to slow-rate
specific waveforms on read and write signals. The SMC supports asynchronous burst read in Page mode access
for page sizes up to 32 bytes.
The External Data Bus can be scrambled/unscrambled by means of user keys.
NCS[0] - NCS[3]
NRD
SMC NWE
A[23:0]
D[7:0] NCS3
Memory Enable
NCS2
Memory Enable
NCS1
Memory Enable
NCS0
Memory Enable
Output Enable
Write Enable
24
A[23:0]
8
D[7:0]
D[7:0] D[7:0]
A[18:2] A[18:2]
A1 A1
SMC A0 A0
SMC
NANDWE
NANDWE
NWE
Note: When the NAND Flash logic is activated, (SMC_NFCSx=1), the NWE pin cannot be used in PIO mode but only in
Peripheral mode (NWE function). If the NWE function is not used for other external memories (SRAM, LCD), it must
be configured in one of the following modes:
PIO Input with pull-up enabled (default state after reset)
PIO Output set at level 1
The address latch enable and command latch enable signals on the NAND Flash device are driven by address bits
A22 and A21of the address bus. Any bit of the address bus can also be used for this purpose. The command,
address or data words on the data bus of the NAND Flash device use their own addresses within the NCSx
address space (configured by the register CCFG_SMCNFCS on the Bus Matrix User Interface). The chip enable
(CE) signal of the device and the ready/busy (R/B) signals are connected to PIO lines. The CE signal then remains
asserted even when NCS3 is not selected, preventing the device from returning to Standby mode. The NANDCS
output signal should be used in accordance with the external NAND Flash device type.
Two types of CE behavior exist depending on the NAND Flash device:
Standard NAND Flash devices require that the CE pin remains asserted Low continuously during the read
busy period to prevent the device from returning to Standby mode. Since the SMC asserts the NCSx signal
High, it is necessary to connect the CE pin of the NAND Flash device to a GPIO line, in order to hold it low
during the busy period preceding data read out.
This restriction has been removed for CE dont care NAND Flash devices. The NCSx signal can be directly
connected to the CE pin of the NAND Flash device.
Figure 26-4 illustrates both topologies: Standard and CE dont care NAND Flash.
D[7:0] D[7:0]
AD[7:0] AD[7:0]
A[22:21] A[22:21]
ALE ALE
CLE CLE
NCSx NCSx
Not Connected CE
SMC SMC
NANDOE NANDOE
NOE NOE
NANDWE NANDWE
NWE NWE
PIO CE
Hardware Configuration
D[0..7]
U1 K9F2G08U0M
CLE 16 29 D0
CLE I/O0 D1
ALE 17 ALE I/O1 30
NANDOE 8 31 D2
RE I/O2 D3
NANDWE 18 WE I/O3 32
(ANY PIO) 9 41 D4
CE I/O4 D5
I/O5 42
7 43 D6
(ANY PIO) R/B I/O6
R1 10K 44 D7
I/O7
3V3 19 WP
R2 10K N.C 48
N.C 47
1 N.C N.C 46
2 N.C N.C 45
3 N.C N.C 40
4 N.C N.C 39
5 N.C PRE 38
6 N.C N.C 35
10 N.C N.C 34
11 N.C N.C 33
14 N.C N.C 28
15 N.C N.C 27 3V3
20 N.C
21 N.C VCC 37
22 N.C VCC 12
23 C2
N.C
24 N.C
25 36 100NF
N.C VSS
26 N.C VSS 13
C1
100NF
2 Gb
TSOP48 PACKAGE
Software Configuration
Perform the following configuration:
1. Assign the SMC_NFCSx (for example SMC_NFCS3) field in the CCFG_SMCNFCS register on the Bus
Matrix User Interface.
2. Reserve A21 / A22 for ALE / CLE functions. Address and Command Latches are controlled by setting the
address bits A21 and A22, respectively, during accesses.
3. NANDOE and NANDWE signals are multiplexed with PIO lines. Thus, the dedicated PIOs must be
programmed in Peripheral mode in the PIO controller.
4. Configure a PIO line as an input to manage the Ready/Busy signal.
5. Configure SMC CS3 Setup, Pulse, Cycle and Mode according to NAND Flash timings, the data bus width
and the system bus frequency.
In this example, the NAND Flash is not addressed as a CE dont care. To address it as a CE dont care, connect
NCS3 (if SMC_NFCS3 is set) to the NAND Flash CE.
Hardware Configuration
D[0..7]
A[0..21]
U1
A0 D0
A0 DQ0 D1
A1
A1 DQ1 D2
A2
A2 DQ2 D3
A3
A3 DQ3 D4
A4
A4 DQ4 D5
A5
A5 DQ5 D6
A6
A6 DQ6 D7
A7
A7 DQ7
A8
A8
A9
A9
A10
A10
A11
A11
A12
A12
A13
A13
A14
A14
A15
A15
A16
A16
A17
A17
A18
A18
A19
A19
A20 3V3
A20
A21
A21
VCCQ
NRST RESET
NWE WE
WP VCC C2
3V3 VPP 100NF
NCS0 CE
NRD OE VSS
VSS C1
100NF
Software Configuration
Configure the SMC CS0 Setup, Pulse, Cycle and Mode depending on Flash timings and system bus frequency.
MCK
A[23:0]
NRD
NCS
D[7:0]
NRD_CYCLE
MCK
A[23:0]
NRD
NCS
D[7:0]
MCK
A[23:0]
NRD
NCS
tPACC
D[7:0]
Data Sampling
Figure 26-8. READ_MODE = 0: Data is sampled by SMC before the rising edge of NCS
MCK
A[23:0]
NRD
NCS
tPACC
D[7:0]
Data Sampling
MCK
A[23:0]
NWE
NCS
NWE_CYCLE
Figure 26-10. Null Setup and Hold Values of NCS and NWE in Write Cycle
MCK
A[23:0]
NWE
NCS
D[7:0]
MCK
A[23:0]
NWE
NCS
D[7:0]
MCK
A[23:0]
NWE
NCS
D[7:0]
MCK
A[23:0]
NRD
NWE
NCS0
NCS2
NRD_CYCLE NWE_CYCLE
D[7:0]
MCK
A[23:0]
NWE
NRD
no hold
no setup
D[7:0]
Figure 26-15. Early Read Wait State: NCS Controlled Write with No Hold Followed by a Read with No NCS Setup
MCK
A[23:0]
NCS
NRD
no hold no setup
D[7:0]
MCK
A[25:2]
D[7:0]
26.12.1 READ_MODE
Setting the READ_MODE to 1 indicates to the SMC that the NRD signal is responsible for turning off the tri-state
buffers of the external memory device. The Data Float Period then begins after the rising edge of the NRD signal
and lasts TDF_CYCLES MCK cycles.
When the read operation is controlled by the NCS signal (READ_MODE = 0), the TDF field gives the number of
MCK cycles during which the data bus remains busy after the rising edge of NCS.
Figure 26-17 illustrates the Data Float Period in NRD-controlled mode (READ_MODE =1), assuming a data float
period of 2 cycles (TDF_CYCLES = 2). Figure 26-18 shows the read operation when controlled by NCS
(READ_MODE = 0) and the TDF_CYCLES parameter equals 3.
MCK
A[23:0]
NRD
NCS
tpacc
D[7:0]
MCK
A[23:0]
NRD
NCS
tpacc
D[7:0]
MCK
NRD
NRD_HOLD= 4
NWE
NWE_SETUP= 3
NCS0
TDF_CYCLES = 6
D[7:0]
read access on NCS0 (NRD controlled) Read to Write write access on NCS0 (NWE controlled)
Wait State
MCK
A[23:0]
D[7:0]
Figure 26-21. TDF Mode = 0: TDF wait states between a read and a write access on different chip selects
MCK
A[23:0]
D[7:0]
MCK
A[23:0]
D[7:0]
26.13.1 Restriction
When one of the EXNW_MODE is enabled, it is mandatory to program at least one hold cycle for the
read/write controlling signal. For that reason, the NWAIT signal cannot be used in Page mode (Section
26.15 Asynchronous Page Mode), or in Slow clock mode (Section 26.14 Slow Clock Mode).
The NWAIT signal is assumed to be a response of the external device to the read/write request of the SMC. Then
NWAIT is examined by the SMC only in the pulse state of the read or write controlling signal. The assertion of the
NWAIT signal outside the expected period has no impact on SMC behavior.
Figure 26-23. Write Access with NWAIT Assertion in Frozen Mode (EXNW_MODE = 10)
MCK
A[23:0]
FROZEN STATE
4 3 2 1 1 1 1 0
NWE
6 5 4 3 2 2 2 2 1 0
NCS
D[7:0]
NWAIT
internally synchronized
NWAIT signal
Write cycle
EXNW_MODE = 10 (Frozen)
WRITE_MODE = 1 (NWE_controlled)
NWE_PULSE = 5
NCS_WR_PULSE = 7
MCK
A[23:0]
FROZEN STATE
NCS 2 2 2 1 0
4 3
2 1 0
1 0
NRD
5 5 5 4 3 2 1 0
NWAIT
internally synchronized
NWAIT signal
Read cycle
EXNW_MODE = 10 (Frozen)
READ_MODE = 0 (NCS_controlled)
Assertion is ignored
NRD_PULSE = 2, NRD_HOLD = 6
NCS_RD_PULSE =5, NCS_RD_HOLD =3
Figure 26-25. NWAIT Assertion in Write Access: Ready Mode (EXNW_MODE = 11)
MCK
A[23:0]
Wait STATE
4 3 2 1 0 0 0
NWE
6 5 4 3 2 1 1 1 0
NCS
D[7:0]
NWAIT
internally synchronized
NWAIT signal
Write cycle
NWE_PULSE = 5
NCS_WR_PULSE = 7
MCK
A[23:0]
Wait STATE
6 5 4 3 2 1 0 0
NCS
6 5 4 3 2 1 1 0
NRD
NWAIT
internally synchronized
NWAIT signal
Read cycle
MCK
A[23:0]
WAIT STATE
4 3 2 1 0 0 0
NRD
minimal pulse length
NWAIT
Read cycle
EXNW_MODE = 10 or 11
READ_MODE = 1 (NRD_controlled)
NRD_PULSE = 5
MCK MCK
A[23:0] A[23:0]
NRD
NWE 1 1 1
1 1
NCS
NCS
NRD_CYCLE = 2
NWE_CYCLE = 3
Table 26-6. Read and Write Timing Parameters in Slow Clock Mode
Read Parameters Duration (cycles) Write Parameters Duration (cycles)
NRD_SETUP 1 NWE_SETUP 1
NRD_PULSE 1 NWE_PULSE 1
NCS_RD_SETUP 0 NCS_WR_SETUP 0
NCS_RD_PULSE 2 NCS_WR_PULSE 3
NRD_CYCLE 2 NWE_CYCLE 3
Figure 26-29. Clock Rate Transition Occurs while the SMC is Performing a Write Operation
MCK
A[23:0]
NWE
1 1 1 1 1 1 2 3 2
NCS
NWE_CYCLE = 3 NWE_CYCLE = 7
SLOW CLOCK MODE WRITE SLOW CLOCK MODE WRITE NORMAL MODE WRITE
This write cycle finishes with the slow clock mode set Slow clock mode
of parameters after the clock rate transition transition is detected:
Reload Configuration Wait State
Figure 26-30. Recommended Procedure to Switch from Slow Clock Mode to Normal Mode or from Normal Mode to Slow Clock
Mode
Slow Clock Mode
internal signal from PMC
MCK
A[23:0]
NWE
1 1 1 2 3 2
NCS
Reload Configuration
Wait State
Figure 26-31. Page Mode Read Protocol (Address MSB and LSB are defined in Table 26-7)
MCK
A[MSB]
A[LSB]
NRD
D[7:0]
The NRD and NCS signals are held low during all read transfers, whatever the programmed values of the setup
and hold timings in the User Interface may be. Moreover, the NRD and NCS timings are identical. The pulse length
of the first access to the page is defined with the NCS_RD_PULSE field of the SMC_PULSE register. The pulse
length of subsequent accesses within the page are defined using the NRD_PULSE parameter.
The SMC does not check the coherency of timings. It will always apply the NCS_RD_PULSE timings as page
access timing (tpa) and the NRD_PULSE for accesses to the page (tsa), even if the programmed value for tpa is
shorter than the programmed value for tsa.
MCK
A[2], A1, A0 A1 A3 A7
NRD
NCS
D[7:0] D1 D3 D7
23 22 21 20 19 18 17 16
NRD_SETUP
15 14 13 12 11 10 9 8
NCS_WR_SETUP
7 6 5 4 3 2 1 0
NWE_SETUP
This register can only be written if the WPEN bit is cleared in the SMC Write Protection Mode Register .
23 22 21 20 19 18 17 16
NRD_PULSE
15 14 13 12 11 10 9 8
NCS_WR_PULSE
7 6 5 4 3 2 1 0
NWE_PULSE
This register can only be written if the WPEN bit is cleared in the SMC Write Protection Mode Register .
23 22 21 20 19 18 17 16
NRD_CYCLE
15 14 13 12 11 10 9 8
NWE_CYCLE
7 6 5 4 3 2 1 0
NWE_CYCLE
This register can only be written if the WPEN bit is cleared in the SMC Write Protection Mode Register .
23 22 21 20 19 18 17 16
TDF_MODE TDF_CYCLES
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
EXNW_MODE WRITE_MODE READ_MODE
This register can only be written if the WPEN bit is cleared in the SMC Write Protection Mode Register .
Disabled Mode: The NWAIT input signal is ignored on the corresponding Chip Select.
Frozen Mode: If asserted, the NWAIT signal freezes the current read or write cycle. After deassertion, the read/write
cycle is resumed from the point where it was stopped.
23 22 21 20 19 18 17 16
CS3SE CS2SE CS1SE CS0SE
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SMSE
23 22 21 20 19 18 17 16
KEY1
15 14 13 12 11 10 9 8
KEY1
7 6 5 4 3 2 1 0
KEY1
23 22 21 20 19 18 17 16
KEY2
15 14 13 12 11 10 9 8
KEY2
7 6 5 4 3 2 1 0
KEY2
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
27.1 Description
The Peripheral DMA Controller (PDC) transfers data between on-chip serial peripherals and the target memories.
The link between the PDC and a serial peripheral is operated by the AHB to APB bridge.
The user interface of each PDC channel is integrated into the user interface of the peripheral it serves. The user
interface of mono-directional channels (receive-only or transmit-only) contains two 32-bit memory pointers and two
16-bit counters, one set (pointer, counter) for the current transfer and one set (pointer, counter) for the next
transfer. The bidirectional channel user interface contains four 32-bit memory pointers and four 16-bit counters.
Each set (pointer, counter) is used by the current transmit, next transmit, current receive and next receive.
Using the PDC decreases processor overhead by reducing its intervention during the transfer. This lowers
significantly the number of clock cycles required for a data transfer, improving microcontroller performance.
To launch a transfer, the peripheral triggers its associated PDC channels by using transmit and receive signals.
When the programmed data is transferred, an end of transfer interrupt is generated by the peripheral itself.
TWI1 Transmit 20
TWI0 Transmit 19
UART1 Transmit 18
UART0 Transmit 17
USART1 Transmit 16
USART0 Transmit 15
DACC Transmit 14
SPI Transmit 13
SSC Transmit 12
HSMCI Transmit 11
PIOA Receive 10
TWI1 Receive 9
TWI0 Receive 8
UART1 Receive 7
UART0 Receive 6
USART1 Receive 5
USART0 Receive 4
ADC Receive 3
SPI Receive 2
SSC Receive 1
HSMCI Receive 0
HALF DUPLEX
PERIPHERAL Control
THR
PDC Channel C
RHR
RECEIVE or TRANSMIT
PERIPHERAL
27.5.1 Configuration
The PDC channel user interface enables the user to configure and control data transfers for each channel. The
user interface of each PDC channel is integrated into the associated peripheral user interface.
The user interface of a serial peripheral, whether it is full- or half-duplex, contains four 32-bit pointers (RPR,
RNPR, TPR, TNPR) and four 16-bit counter registers (RCR, RNCR, TCR, TNCR). However, the transmit and
receive parts of each type are programmed differently: the transmit and receive parts of a full-duplex peripheral
can be programmed at the same time, whereas only one part (transmit or receive) of a half-duplex peripheral can
be programmed at a time.
32-bit pointers define the access location in memory for the current and next transfer, whether it is for read
(transmit) or write (receive). 16-bit counters define the size of the current and next transfers. It is possible, at any
moment, to read the number of transfers remaining for each channel.
The PDC has dedicated status registers which indicate if the transfer is enabled or disabled for each channel. The
status for each channel is located in the associated peripheral status register. Transfers can be enabled and/or
disabled by setting TXTEN/TXTDIS and RXTEN/RXTDIS in the peripherals Transfer Control register.
At the end of a transfer, the PDC channel sends status flags to its associated peripheral. These flags are visible in
the peripheral Status register (ENDRX, ENDTX, RXBUFF, and TXBUFE). Refer to Section 27.5.3 and to the
associated peripheral user interface.
The peripheral where a PDC transfer is configured must have its peripheral clock enabled. The peripheral clock
must be also enabled to access the PDC register set associated to this peripheral.
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
23 22 21 20 19 18 17 16
TXPTR
15 14 13 12 11 10 9 8
TXPTR
7 6 5 4 3 2 1 0
TXPTR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXCTR
7 6 5 4 3 2 1 0
TXCTR
23 22 21 20 19 18 17 16
RXNPTR
15 14 13 12 11 10 9 8
RXNPTR
7 6 5 4 3 2 1 0
RXNPTR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXNCTR
7 6 5 4 3 2 1 0
RXNCTR
23 22 21 20 19 18 17 16
TXNPTR
15 14 13 12 11 10 9 8
TXNPTR
7 6 5 4 3 2 1 0
TXNPTR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXNCTR
7 6 5 4 3 2 1 0
TXNCTR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXTDIS TXTEN
7 6 5 4 3 2 1 0
RXTDIS RXTEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXTEN
7 6 5 4 3 2 1 0
RXTEN
28.1 Description
The Clock Generator user interface is embedded within the Power Management Controller and is described in
Section 29.17 Power Management Controller (PMC) User Interface. However, the Clock Generator registers are
named CKGR_.
Clock Generator
XTALSEL
(Supply Controller)
Embedded
32 kHz 0
RC Oscillator
Slow Clock
SLCK
XIN32 32768 Hz
Crystal 1
XOUT32 Oscillator
CKGR_MOR
MOSCSEL
Embedded
4/8/12 MHz
Fast 0
RC Oscillator
Main Clock
MAINCK
320 MHz
XIN Crystal
or 1
Ceramic
XOUT Resonator
Oscillator
PLLADIV2
PMC_MCKR
PLLBDIV2
PMC_MCKR
Status Control
Power
Management
Controller
The user can select the crystal oscillator to be the source of the slow clock, as it provides a more accurate
frequency. The command is made by writing a 1 to the SUPC_CR.XTALSEL bit. This results in a sequence which
first configures the PIO lines multiplexed with XIN32 and XOUT32 to be driven by the oscillator, then enables the
crystal oscillator and then disables the RC oscillator to save power. The switch of the slow clock source is glitch
free. The OSCSEL bit of the Supply Controller Status Register (SUPC_SR) or the OSCSEL bit of the PMC Status
Register (PMC_SR) tracks the oscillator frequency downstream. It must be read in order to be informed when the
switch sequence, initiated when a new value is written in the SUPC_CR.XTALSEL bit, is done.
Coming back on the RC oscillator is only possible by shutting down the VDDIO power supply. If the user does not
need the crystal oscillator, the XIN32 and XOUT32 pins can be left unconnected since by default the XIN32 and
XOUT32 system I/O pins are in PIO input mode with pull-up after reset.
The user can also set the crystal oscillator in Bypass mode instead of connecting a crystal. In this case, the user
has to provide the external clock signal on XIN32. The input characteristics of the XIN32 pin are given in the
product electrical characteristics section. In order to set the Bypass mode, the OSCBYPASS bit of the Supply
Controller Mode Register (SUPC_MR) needs to be set at 1 prior to writing a 1 in bit XTALSEL.
CKGR_MOR PMC_SR
Fast RC
Oscillator MOSCSEL MOSCSELS
CKGR_MOR
MAINCK
MOSCXTEN
Main Clock
320 MHz 1
XIN Crystal
or
XOUT Ceramic Resonator
Oscillator
CKGR_MOR
MOSCXTST
PMC_SR
320 MHz
SLCK MOSCXTS
Oscillator
Slow Clock Counter
CKGR_MOR
MOSCRCEN
CKGR_MOR CKGR_MCFR
MOSCXTEN RCMEAS
CKGR_MOR
MOSCSEL
CKGR_MCFR
MAINF
MAINCK Ref. Main Clock
Main Clock Frequency CKGR_MCFR
Counter MAINFRDY
28.5.6 Switching Main Clock between the Main RC Oscillator and Fast Crystal Oscillator
Both sources must be enabled during the switchover operation. Only after completion can the unused oscillator be
disabled. If switching to fast crystal oscillator, the clock presence must first be checked according to what is
described in Section 28.5.7 Software Sequence to Detect the Presence of Fast Crystal because the source may
not be reliable (crystal failure or bypass on a non-existent clock).
PLLBDIV2
PMC_MCKR
CKGR_PLLAR CKGR_PLLAR
DIVA MULA
PLLADIV2
PMC_MCKR
CKGR_PLLBR
PLLBCOUNT
PMC_SR
PLL B
LOCKB
Counter
CKGR_PLLAR
PLLACOUNT
PMC_SR
SLCK PLL A
LOCKA
Counter
29.1 Description
The Power Management Controller (PMC) optimizes power consumption by controlling all system and user
peripheral clocks. The PMC enables/disables the clock inputs to many of the peripherals and the Cortex-M4
processor.
The Supply Controller selects between the 32 kHz RC oscillator or the slow crystal oscillator. The unused oscillator
is disabled automatically so that power consumption is optimized.
By default, at startup, the chip runs out of the master clock using the fast RC oscillator running at 4 MHz.
The user can trim the 8 and 12 MHz RC oscillator frequencies by software.
Clock Generator
XTALSEL Processor Processor clock
Clock HCLK
(Supply Controller) Controller
int
Sleep Mode
Embedded
32 kHz RC 0
Oscillator
Slow Clock Divider
/8 SysTick
SLCK
XIN32 32768 Hz
Master Clock Controller
SLCK (PMC_MCKR) Free Running Clock
Crystal 1
FCLK
Oscillator
XOUT32 MAINCK
CKGR_MOR Prescaler
MOSCSEL PLLBCK /1, /2, /3, /4, /8, Master Clock
/16, /32, /64 MCK
Embedded PLLACK
4/8/12 MHz Peripherals
Fast 0 Clock Controller
RC Oscillator CSS PRES (PMC_PCERx)
Main Clock ON/OFF
320 MHz MAINCK periph_clk[..]
Crystal
XIN or
Ceramic 1
Resonator
XOUT
Oscillator Programmable Clock Controller
SLCK (PMC_PCKx)
MAINCK
Prescaler ON/OFF
PLLA and PLLBCK /1, /2, /4, /8, pck[..]
(PMC_SCER/SCDR)
Divider /2 PLLA Clock PLLACK /16, /32, /64
PLLACK MCK
PLLADIV2 CSS PRES
PMC_MCKR
Status Control
Power
Management
Controller
SLCK
MAINCK Master Clock
To the MCK Divider
PLLACK Prescaler
PLLBCK
To the Processor
Clock Controller (PCK)
PMC_USB PMC_SCER,
PMC_SDER
USBDIV
USB
Divider UDP Clock (UDPCK)
Source
/1,/2,/3,.../16
Clock
UDP
WKUP0
FSTP0 FSTT1
WKUP1
FSTP1
FSTT15
WKUP15 fast_restart
FSTP15 RTTAL
RTT Alarm
RTCAL
RTC Alarm
USBAL
USB Alarm
SLCK
CDFS
If the main oscillator is selected as the source clock of MAINCK (MOSCSEL in CKGR_MOR = 1), and if the master
clock source is PLLACK or PLLBCK (CSS = 2 or 3), a clock failure detection automatically forces MAINCK to be
the source clock for the master clock (MCK). Then, regardless of the PMC configuration, a clock failure detection
Table 29-2. Clock Switching Timings between Two PLLs (Worst Case)
From PLLA Clock PLLB Clock
To
2.5 x PLLA Clock + 3 x PLLA Clock +
PLLA Clock 4 x SLCK + 4 x SLCK +
PLLACOUNT x SLCK 1.5 x PLLA Clock
3 x PLLB Clock + 2.5 x PLLB Clock +
PLLB Clock 4 x SLCK + 4 x SLCK +
1.5 x PLLB Clock PLLBCOUNT x SLCK
Figure 29-6. Switch Master Clock from Slow Clock to PLLx Clock
Slow Clock
PLLx Clock
LOCK
MCKRDY
Master Clock
Write PMC_MCKR
Figure 29-7. Switch Master Clock from Main Clock to Slow Clock
Slow Clock
Main Clock
MCKRDY
Master Clock
Write PMC_MCKR
Slow Clock
PLLx Clock
LOCKx
MCKRDY
Master Clock
Slow Clock
Write CKGR_PLLxR
PLLx Clock
PCKRDY
PCKx Output
Write PMC_SCER
PCKx is enabled
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCK2 PCK1 PCK0
7 6 5 4 3 2 1 0
UDP
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCK2 PCK1 PCK0
7 6 5 4 3 2 1 0
UDP
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PCK2 PCK1 PCK0
7 6 5 4 3 2 1 0
UDP
23 22 21 20 19 18 17 16
PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16
15 14 13 12 11 10 9 8
PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8
7 6 5 4 3 2 1 0
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16
15 14 13 12 11 10 9 8
PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8
7 6 5 4 3 2 1 0
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16
15 14 13 12 11 10 9 8
PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8
7 6 5 4 3 2 1 0
23 22 21 20 19 18 17 16
KEY
15 14 13 12 11 10 9 8
MOSCXTST
7 6 5 4 3 2 1 0
MOSCRCF MOSCRCEN WAITMODE MOSCXTBY MOSCXTEN
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
RCMEAS MAINFRDY
15 14 13 12 11 10 9 8
MAINF
7 6 5 4 3 2 1 0
MAINF
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
MULA
15 14 13 12 11 10 9 8
PLLACOUNT
7 6 5 4 3 2 1 0
DIVA
Possible limitations on PLLA input frequencies and multiplier factors should be checked before using the PMC.
Warning: Bit 29 must always be set to 1 when programming the CKGR_PLLAR.
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
MULB
15 14 13 12 11 10 9 8
PLLBCOUNT
7 6 5 4 3 2 1 0
DIVB
Possible limitations on PLLB input frequencies and multiplier factors should be checked before using the PMC.
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PLLBDIV2 PLLADIV2
7 6 5 4 3 2 1 0
PRES CSS
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
USBDIV
7 6 5 4 3 2 1 0
USBS
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
USBS: USB Input Clock Selection
0: USB Clock Input is PLLA.
1: USB Clock Input is PLLB
USBDIV: Divider for USB Clock
USB Clock is Input clock divided by USBDIV + 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
PRES CSS
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
CFDEV MOSCRCS MOSCSELS
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY LOCKB LOCKA MOSCXTS
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
CFDEV MOSCRCS MOSCSELS
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY LOCKB LOCKA MOSCXTS
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
FOS CFDS CFDEV MOSCRCS MOSCSELS
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
OSCSELS MCKRDY LOCKB LOCKA MOSCXTS
23 22 21 20 19 18 17 16
CFDEV MOSCRCS MOSCSELS
15 14 13 12 11 10 9 8
PCKRDY2 PCKRDY1 PCKRDY0
7 6 5 4 3 2 1 0
MCKRDY LOCKB LOCKA MOSCXTS
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
FLPM LPM USBAL RTCAL RTTAL
15 14 13 12 11 10 9 8
FSTT15 FSTT14 FSTT13 FSTT12 FSTT11 FSTT10 FSTT9 FSTT8
7 6 5 4 3 2 1 0
FSTT7 FSTT6 FSTT5 FSTT4 FSTT3 FSTT2 FSTT1 FSTT0
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FSTP15 FSTP14 FSTP13 FSTP12 FSTP11 FSTP10 FSTP9 FSTP8
7 6 5 4 3 2 1 0
FSTP7 FSTP6 FSTP5 FSTP4 FSTP3 FSTP2 FSTP1 FSTP0
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FOCLR
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PID34 PID33 PID32
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PID34 PID33 PID32
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
PID34 PID33 PID32
23 22 21 20 19 18 17 16
SEL12 CAL12
15 14 13 12 11 10 9 8
SEL8 CAL8
7 6 5 4 3 2 1 0
SEL4 CAL4
This register can only be written if the WPEN bit is cleared in the PMC Write Protection Mode Register.
30.1 Description
Chip Identifier (CHIPID) registers permit recognition of the device and its revision. These registers provide the
sizes and types of the on-chip memories, as well as the set of embedded peripherals.
Two CHIPID registers are embedded: Chip ID Register (CHIPID_CIDR) and Chip ID Extension Register
(CHIPID_EXID). Both registers contain a hard-wired value that is read-only.
The CHIPID_CIDR contains the following fields:
VERSION: Identifies the revision of the silicon
EPROC: Indicates the embedded ARM processor
NVPTYP and NVPSIZ: Identify the type of embedded non-volatile memory and the size
SRAMSIZ: Indicates the size of the embedded SRAM
ARCH: Identifies the set of embedded peripherals
EXT: Shows the use of the extension identifier register
The CHIPID_EXID register is device-dependent and reads 0 if CHIPID_CIDR.EXT = 0.
23 22 21 20 19 18 17 16
ARCH SRAMSIZ
15 14 13 12 11 10 9 8
NVPSIZ2 NVPSIZ
7 6 5 4 3 2 1 0
EPROC VERSION
23 22 21 20 19 18 17 16
EXID
15 14 13 12 11 10 9 8
EXID
7 6 5 4 3 2 1 0
EXID
31.1 Description
The Parallel Input/Output Controller (PIO) manages up to 32 fully programmable input/output lines. Each I/O line
may be dedicated as a general-purpose I/O or be assigned to a function of an embedded peripheral. This ensures
effective optimization of the pins of the product.
Each I/O line is associated with a bit number in all of the 32-bit registers of the 32-bit wide user interface.
Each I/O line of the PIO Controller features:
An input change interrupt enabling level change detection on any I/O line.
Additional Interrupt modes enabling rising edge, falling edge, low-level or high-level detection on any I/O
line.
A glitch filter providing rejection of glitches lower than one-half of peripheral clock cycle.
A debouncing filter providing rejection of unwanted pulses from key or push button operations.
Multi-drive capability similar to an open drain I/O line.
Control of the pull-up and pull-down of the I/O line.
Input visibility and output control.
The PIO Controller also features a synchronous output providing up to 32 bits of data output in a single write
operation.
An 8-bit parallel capture mode is also available which can be used to interface a CMOS digital image sensor, an
ADC, a DSP synchronous port in synchronous mode, etc.
PIODCCLK
Data
PIODC[7:0]
Status Parallel Capture
PDC
Events Mode PIODCEN1
PIODCEN2
PIO Interrupt
Interrupt Controller
Data, Enable
Up to x
peripheral IOs
Embedded
Peripheral
PIN 0
Data, Enable
PIN 1
Up to x
Embedded peripheral IOs
Peripheral PIN x-1
APB
x is an integer representing the maximum number
of IOs managed by one PIO controller.
PIO_OER[0] VDD
PIO_OSR[0] PIO_PUER[0]
Integrated
PIO_ODR[0] PIO_PUSR[0] Pull-Up
PIO_PUDR[0] Resistor
1
Peripheral A Output Enable 00
Peripheral B Output Enable 01 0
Peripheral C Output Enable 10
0
Peripheral D Output Enable 11
PIO_PER[0]
PIO_ABCDSR1[0]
PIO_PSR[0] 1
PIO_ABCDSR2[0]
PIO_PDR[0] PIO_MDER[0]
Peripheral A Output 00
PIO_MDSR[0]
Peripheral B Output 01
0 PIO_MDDR[0]
Peripheral C Output 10
Peripheral D Output 11 PIO_SODR[0] 0
PIO_ODSR[0] 1 Pad
PIO_CODR[0] 1
PIO_PPDER[0] Integrated
PIO_PPDSR[0] Pull-Down
Resistor
PIO_PPDDR[0]
GND
Peripheral A Input
Peripheral B Input
Peripheral C Input
Peripheral D Input
PIO_PDSR[0]
PIO_ISR[0]
0 (Up to 32 possible inputs)
D Q D Q EVENT
Peripheral Clock Programmable DFF DFF DETECTOR
0 Glitch PIO Interrupt
or 1
Slow Clock Peripheral Clock
Debouncing
Clock div_slck Filter Resynchronization
1 PIO_IER[0]
Divider Stage
PIO_SCDR PIO_IMR[0]
PIO_IFER[0] PIO_IDR[0]
PIO_IFSR[0]
PIO_IFSCER[0] PIO_ISR[31]
PIO_IFDR[0]
PIO_IFSCSR[0]
PIO_IER[31]
PIO_IFSCDR[0]
PIO_IMR[31]
PIO_IDR[31]
Peripheral clock
PIO_ODSR
2 cycles 2 cycles
PIO_PDSR
31.5.8 Inputs
The level on each I/O line can be read through PIO_PDSR. This register indicates the level of the I/O lines
regardless of their configuration, whether uniquely as an input, or driven by the PIO Controller, or driven by a
peripheral.
Reading the I/O line levels requires the clock of the PIO Controller to be enabled, otherwise PIO_PDSR reads the
levels present on the I/O line at the time the clock was disabled.
Peripheral clcok
up to 1.5 cycles
Pin Level
1 cycle 1 cycle 1 cycle 1 cycle
PIO_PDSR
if PIO_IFSR = 0
2 cycles 1 cycle
Pin Level
Event Detector
Rising Edge
1
Detector
Falling Edge 0
Detector
0
PIO_REHLSR[0]
1
PIO_FRLHSR[0] Event detection on line 0
PIO_FELLSR[0] 1
0
Resynchronized input on line 0 High Level
1
Detector
Low Level 0
Detector
PIO_LSR[0]
PIO_ELSR[0] PIO_AIMER[0]
PIO_ESR[0] PIO_AIMMR[0]
PIO_AIMDR[0]
Edge
Detector
Edge or Level Detection The other lines are configured in edge detection by default, if they have not been previously
configured. Otherwise, lines 0, 1, 2, 6 and 7 must be configured in edge detection by writing
32h0000_00C7 in PIO_ESR.
Lines 0, 2, 4, 5 and 7 are configured in rising edge or high-level detection by writing
32h0000_00B5 in PIO_REHLSR.
Falling/Rising Edge or Low/High-Level
Detection The other lines are configured in falling edge or low-level detection by default if they have
not been previously configured. Otherwise, lines 1, 3 and 6 must be configured in falling
edge/low-level detection by writing 32h0000_004A in PIO_FELLSR.
Peripheral clock
Pin Level
PIO_ISR
31.5.13.1 Overview
The PIO Controller integrates an interface able to read data from a CMOS digital image sensor, a high-speed
parallel ADC, a DSP synchronous port in synchronous mode, etc. For better understanding and to ease reading,
the following description uses an example with a CMOS digital image sensor.
31.5.13.2 Functional Description
The CMOS digital image sensor provides a sensor clock, an 8-bit data synchronous with the sensor clock and two
data enables which are also synchronous with the sensor clock.
Figure 31-8. PIO Controller Connection with CMOS Digital Image Sensor
PIO Controller
Parallel Capture
Mode CMOS Digital
PIODCCLK PCLK Image Sensor
Data
PIODCEN2 HSYNC
MCK
PIODCLK
PIODC[7:0] 0x01 0x12 0x23 0x34 0x45 0x56 0x67 0x78 0x89
PIODCEN1
PIODCEN2
DRDY (PIO_PCISR)
Read of PIO_PCISR
MCK
PIODCLK
PIODC[7:0] 0x01 0x12 0x23 0x34 0x45 0x56 0x67 0x78 0x89
PIODCEN1
PIODCEN2
DRDY (PIO_PCISR)
Read of PIO_PCISR
Figure 31-11. Parallel Capture Mode Waveforms (DSIZE = 2, ALWYS = 0, HALFS = 1, FRSTS = 0)
MCK
PIODCLK
PIODC[7:0] 0x01 0x12 0x23 0x34 0x45 0x56 0x67 0x78 0x89
PIODCEN1
PIODCEN2
DRDY (PIO_PCISR)
Read of PIO_PCISR
MCK
PIODCLK
PIODC[7:0] 0x01 0x12 0x23 0x34 0x45 0x56 0x67 0x78 0x89
PIODCEN1
PIODCEN2
DRDY (PIO_PCISR)
Read of PIO_PCISR
31.5.13.3 Restrictions
Configuration fields DSIZE, ALWYS, HALFS and FRSTS in PIO_PCMR can be changed ONLY if the parallel
capture mode is disabled at this time (PCEN = 0 in PIO_PCMR).
The frequency of peripheral clock must be strictly superior to two times the frequency of the clock of the
device which generates the parallel data.
31.5.13.4 Programming Sequence
Without PDC
1. Write PIO_PCIDR and PIO_PCIER in order to configure the parallel capture mode
interrupt mask.
2. Write PIO_PCMR to set the fields DSIZE, ALWYS, HALFS and FRSTS in order to
configure the parallel capture mode WITHOUT enabling the parallel capture mode.
3. Write PIO_PCMR to set the PCEN bit to one in order to enable the parallel capture
mode WITHOUT changing the previous configuration.
4. Wait for a data ready by polling the DRDY flag in PIO_PCISR or by waiting for the
corresponding interrupt.
5. Check OVRE flag in PIO_PCISR.
6. Read the data in PIO_PCRHR.
7. If new data are expected, go to step 4.
8. Write PIO_PCMR to set the PCEN bit to zero in order to disable the parallel capture
mode WITHOUT changing the previous configuration.
With PDC
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
DIV
7 6 5 4 3 2 1 0
DIV
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
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 can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
P23 P22 P21 P20 P19 P18 P17 P16
15 14 13 12 11 10 9 8
P15 P14 P13 P12 P11 P10 P9 P8
7 6 5 4 3 2 1 0
P7 P6 P5 P4 P3 P2 P1 P0
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
15 14 13 12 11 10 9 8
SCHMITT15 SCHMITT14 SCHMITT13 SCHMITT12 SCHMITT11 SCHMITT10 SCHMITT9 SCHMITT8
7 6 5 4 3 2 1 0
SCHMITT7 SCHMITT6 SCHMITT5 SCHMITT4 SCHMITT3 SCHMITT2 SCHMITT1 SCHMITT0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FRSTS HALFS ALWYS
7 6 5 4 3 2 1 0
DSIZE PCEN
This register can only be written if the WPEN bit is cleared in the PIO Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRE DRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Enables the corresponding interrupt
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRE DRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Disables the corresponding interrupt
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRE DRDY
The following configuration values are valid for all listed bit names of this register:
0: Corresponding interrupt is not enabled.
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
RXBUFF ENDRX OVRE DRDY
23 22 21 20 19 18 17 16
RDATA
15 14 13 12 11 10 9 8
RDATA
7 6 5 4 3 2 1 0
RDATA
32.1 Description
The Synchronous Serial Controller (SSC) provides a synchronous communication link with external devices. It
supports many serial synchronous communication protocols generally used in audio and telecom applications
such as I2S, Short Frame Sync, Long Frame Sync, etc.
The SSC contains an independent receiver and transmitter and a common clock divider. The receiver and the
transmitter each interface with three signals: the TD/RD signal for data, the TK/RK signal for the clock and the
TF/RF signal for the Frame Sync. The transfers can be programmed to start automatically or on different events
detected on the Frame Sync signal.
The SSC high-level of programmability and its two dedicated PDC channels of up to 32 bits permit a continuous
high bit rate data transfer without processor intervention.
Featuring connection to two PDC channels, the SSC permits interfacing with low processor overhead to the
following:
Codecs in master or slave mode
DAC through dedicated serial interface, particularly I2S
Magnetic card reader
System
Bus
Peripheral Bridge
PDC
Bus Clock
Peripheral
Bus
TF
TK
TD
Peripheral Clock
PMC
SSC Interface PIO
RF
RK
Interrupt Control
RD
SSC Interrupt
SSC
Clock SCK
TK
Word Select WS
TF I2S
RECEIVER
Data SD
TD
SSC
RD Clock SCK
RF Word Select WS
RK
Data SD MSB LSB MSB
RF
Serial Data Clock (SCLK)
Serial Data In
SSC
Data In
RD
RF
RK
CODEC
Second
Time Slot
Serial Data in
32.7.3 Interrupt
The SSC interface has an interrupt line connected to the interrupt controller. Handling interrupts requires
programming the interrupt controller before configuring the SSC.
All SSC interrupts can be enabled/disabled configuring the SSC Interrupt Mask Register. Each pending and
unmasked SSC interrupt will assert the SSC interrupt line. The SSC interrupt service routine can get the interrupt
origin by reading the SSC Interrupt Status Register.
Transmitter
Clock Output
TK
Controller
Peripheral TK Input
Clock Clock Transmit Clock TX clock Frame Sync TF
Divider Controller Controller
RX clock
TXEN
TX Start Data
RX Start Start TD
Selector Controller
TF Transmit Shift Register
RK Input
Receive Clock RX Clock Frame Sync
Controller RF
Controller
TX Clock
RXEN
RX Start
TX Start Start Data
RF RD
Selector Receive Shift Register Controller
RC0R
To Interrupt Controller
Clock Divider
SSC_CMR
The peripheral clock divider is determined by the 12-bit field DIV counter and comparator (so its maximal value is
4095) in the Clock Mode Register (SSC_CMR), allowing a peripheral clock division by up to 8190. The Divided
Clock is provided to both the Receiver and Transmitter. When this field is programmed to 0, the Clock Divider is
not used and remains inactive.
When DIV is set to a value equal to or greater than 1, the Divided Clock has a frequency of peripheral clock divided
by 2 times DIV. Each level of the Divided Clock has a duration of the peripheral clock multiplied by DIV. This
ensures a 50% duty cycle for the Divided Clock regardless of whether the DIV value is even or odd.
Divided Clock
DIV = 1
Peripheral Clock
Divided Clock
DIV = 3
TK (pin)
Divider
Clock
CKO Data Transfer
CKS
INV Tri_state Transmitter
MUX Controller Clock
CKI CKG
RK (pin)
Divider
Clock
CKO Data Transfer
CKS
INV Tri_state Receiver
MUX Controller Clock
CKI CKG
SSC_CRTXEN
TXEN
SSC_SRTXEN
SSC_CRTXDIS
SSC_TCMR.STTDLY
SSC_TFMR.FSDEN
SSC_RCMR.START SSC_TCMR.START SSC_TFMR.DATNB
SSC_TFMR.DATDEF
RXEN SSC_TFMR.MSBF TX Controller
TXEN
TX Start RX Start Start TX Start
Start TD
RF Selector Selector
RC0R RF
SSC_TFMR.FSDEN
SSC_TCMR.STTDLY != 0 0 1 Transmitter Clock
SSC_CR.RXEN
SSC_SR.RXEN
SSC_CR.RXDIS
SSC_TCMR.START
SSC_RCMR.START SSC_RFMR.MSBF
TXEN SSC_RFMR.DATNB
RXEN
RX Start Start RX Start
Selector Start RX Controller
RF RF Selector
RC0R RD
SSC_RCMR.STTDLY != 0
load SSC_RSHR load SSC_RHR Receiver Clock
SSC_RFMR.FSLEN SSC_RFMR.DATLEN
RX Controller counter reached STTDLY
32.8.4 Start
The transmitter and receiver can both be programmed to start their operations when an event occurs, respectively
in the Transmit Start Selection (START) field of SSC_TCMR and in the Receive Start Selection (START) field of
SSC_RCMR.
Under the following conditions the start event is independently programmable:
Continuous. In this case, the transmission starts as soon as a word is written in SSC_THR and the reception
starts as soon as the Receiver is enabled.
Synchronously with the transmitter/receiver
On detection of a falling/rising edge on TF/RF
On detection of a low level/high level on TF/RF
On detection of a level change or an edge on TF/RF
A start can be programmed in the same manner on either side of the Transmit/Receive Clock Register
(SSC_RCMR/SSC_TCMR). Thus, the start could be on TF (Transmit) or RF (Receive).
Moreover, the Receiver can start when data is detected in the bit stream with the Compare Functions.
Detection on TF/RF input/output is done by the field FSOS of the Transmit/Receive Frame Mode Register
(SSC_TFMR/SSC_RFMR).
TF
(Input)
TD
Start = Low Level on TF X BO B1
(Output)
STTDLY
TD
Start = Level Change on TF X BO B1 BO B1
(Output)
STTDLY
TD
Start = Any Edge on TF (Output) X BO B1 BO B1
STTDLY
RF
(Input)
RD
Start = Low Level on RF X BO B1
(Input)
STTDLY
RD
Start = Rising Edge on RF X BO B1
(Input)
STTDLY
RD
Start = Any Edge on RF X BO B1 BO B1
(Input)
STTDLY
RK
Start Start
PERIOD
(1)
TF/RF
FSLEN
DATNB
In the example illustrated in Figure 32-17 Transmit Frame Format in Continuous Mode (STTDLY = 0), the
SSC_THR is loaded twice. The FSDEN value has no effect on the transmission. SyncData cannot be output in
continuous mode.
Start
DATLEN DATLEN
RD Data Data
To SSC_RHR To SSC_RHR
DATLEN DATLEN
32.8.9 Interrupt
Most bits in the SSC_SR have a corresponding bit in interrupt management registers.
The SSC can be programmed to generate an interrupt when it detects an event. The interrupt is controlled by
writing the Interrupt Enable Register (SSC_IER) and Interrupt Disable Register (SSC_IDR). These registers
enable and disable, respectively, the corresponding interrupt by setting and clearing the corresponding bit in the
Interrupt Mask Register (SSC_IMR), which controls the generation of interrupts by asserting the SSC interrupt line
connected to the interrupt controller.
SSC_IMR
SSC_IER SSC_IDR
PDC Set Clear
TXBUFE
ENDTX
Transmitter
TXRDY
TXEMPTY
TXSYNC
Interrupt SSC Interrupt
RXBUFF Control
ENDRX
Receiver
RXRDY
OVRUN
RXSYNC
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
SWRST TXDIS TXEN
7 6 5 4 3 2 1 0
RXDIS RXEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
DIV
7 6 5 4 3 2 1 0
DIV
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
STTDLY
15 14 13 12 11 10 9 8
STOP START
7 6 5 4 3 2 1 0
CKG CKI CKO CKS
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
FSOS FSLEN
15 14 13 12 11 10 9 8
DATNB
7 6 5 4 3 2 1 0
MSBF LOOP DATLEN
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
STTDLY
15 14 13 12 11 10 9 8
START
7 6 5 4 3 2 1 0
CKG CKI CKO CKS
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
FSDEN FSOS FSLEN
15 14 13 12 11 10 9 8
DATNB
7 6 5 4 3 2 1 0
MSBF DATDEF DATLEN
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
RDAT
15 14 13 12 11 10 9 8
RDAT
7 6 5 4 3 2 1 0
RDAT
23 22 21 20 19 18 17 16
TDAT
15 14 13 12 11 10 9 8
TDAT
7 6 5 4 3 2 1 0
TDAT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RSDAT
7 6 5 4 3 2 1 0
RSDAT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TSDAT
7 6 5 4 3 2 1 0
TSDAT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CP0
7 6 5 4 3 2 1 0
CP0
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CP1
7 6 5 4 3 2 1 0
CP1
This register can only be written if the WPEN bit is cleared in the SSC Write Protection Mode Register.
23 22 21 20 19 18 17 16
RXEN TXEN
15 14 13 12 11 10 9 8
RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
CP0: Compare 0
0: A compare 0 has not occurred since the last read of the Status Register.
1: A compare 0 has occurred since the last read of the Status Register.
CP1: Compare 1
0: A compare 1 has not occurred since the last read of the Status Register.
1: A compare 1 has occurred since the last read of the Status Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXSYN TXSYN CP1 CP0
7 6 5 4 3 2 1 0
RXBUFF ENDRX OVRUN RXRDY TXBUFE ENDTX TXEMPTY TXRDY
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
33.1 Description
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 enables communication between processors if an external
processor is connected to the system.
The Serial Peripheral Interface is essentially a Shift register that serially transmits data bits to other SPIs. During a
data transfer, one SPI system acts as the master' which controls the data flow, while the other devices act as
slaves'' which have data shifted into and out by the master. Different CPUs can take turn being masters (multiple
master protocol, contrary to single master protocol where one CPU is always the master while all of the others are
always slaves). One master can simultaneously shift data into multiple slaves. However, only one slave can 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 can transmit data at a variety of baud rates; there is one SPCK pulse for each bit that is transmitted.
Slave Select (NSS)This control line allows slaves to be turned on and off by hardware.
Bus clock
Peripheral bridge Trigger
events
Peripheral
clock SPI
PMC
SPCK SPCK
MISO MISO
Slave 0
MOSI MOSI
SPCK
NPCS1
MISO
NPCS2 NC Slave 1
NPCS3 MOSI
NSS
SPCK
MISO
Slave 2
MOSI
NSS
SPCK
(CPOL = 0)
SPCK
(CPOL = 1)
MOSI
MSB 6 5 4 3 2 1 LSB
(from master)
MISO
(from slave)
MSB 6 5 4 3 2 1 LSB *
NSS
(to slave)
* Not defined.
SPCK
(CPOL = 0)
SPCK
(CPOL = 1)
MISO
(from slave) * MSB 6 5 4 3 2 1 LSB
NSS
(to slave)
* Not defined.
The transfer of received data from the Shift register to the SPI_RDR is indicated by the Receive Data Register Full
(RDRF) bit in the SPI_SR. When the received data is read, the RDRF bit is cleared.
If the SPI_RDR has not been read before new data is received, the Overrun Error (OVRES) bit in the SPI_SR is
set. As long as this flag is set, data is loaded in the SPI_RDR. The user has to read the SPI_SR to clear the
OVRES bit.
Figure 33-6, shows a block diagram of the SPI when operating in Master mode. Figure 33-7 on page 695 shows a
flow chart describing how transfers are handled.
SPI
Clock
SPI_CSRx
BITS SPI_RDR RDRF
NCPHA RD OVRES
CPOL
SPI_TDR
TD TDRE
SPI_CSRx
SPI_RDR
CSAAT PCS
PS
NPCSx
SPI_MR PCSDEC
PCS Current
0 Peripheral
SPI_TDR
PCS NPCS0
1
MSTR
MODF
NPCS0
MODFDIS
SPI Enable
TDRE/TXEMPTY are set
0
TDRE ?
(SW check)
Fixed
1 PS ? 0 peripheral
CSAAT ?
(HW check) (HW check)
Variable
0 1 peripheral
Fixed
0 peripheral SPI_TDR(PCS) yes SPI_MR(PCS)
PS ?
(HW check) = NPCS ? = NPCS ?
(HW check) (HW check)
Variable
1 peripheral no no
NPCS <= SPI_TDR(PCS) NPCS <= SPI_MR(PCS) NPCS deasserted NPCS deasserted
Delay DLYBS
TDRE ? 0 (i.e. a new write to SPI_TDR occured while data transfer or delay DLYBCT)
(HW check)
TXEMPTY is set
1 CSAAT ?
(HW check)
NPCS deasserted
Delay DLYBCS
SPCK
NPCS0
MOSI
MSB 6 5 4 3 2 1 LSB
(from master)
TDRE
RDR read
Write in
SPI_TDR
RDRF
MISO
MSB 6 5 4 3 2 1 LSB
(from slave)
TXEMPTY
1 2 3
SPCK
NPCS0
MOSI
MSB 6 5 4 3 2 1 LSB MSB 6 5 4 3 2 1 LSB MSB 6 5 4 3 2 1 LSB
(from master)
MISO
MSB 6 5 4 3 2 1 LSB MSB 6 5 4 3 2 1 LSB MSB 6 5 4 3 2 1 LSB
(from slave)
TDRE
(not required PDC loads 2nd byte PDC loads last byte
if PDC is used) (double buffer effect)
PDC loads first byte
ENDTX
ENDRX
TXBUFE
RXBUFF
TXEMPTY
Chip Select 1
Chip Select 2
SPCK
DLYBCS DLYBS DLYBCT DLYBCT
[xxxxxxx(7-bit) + LASTXFER(1-bit)(1)+ xxxx(4-bit) + PCS (4-bit) + DATA (8 to 16-bit)] with PCS equals the
chip select to assert, as defined in Section 33.8.4 SPI Transmit Data Register and LASTXFER bit at 0 or 1
depending on the CSAAT bit.
Note: 1. Optional
CSAAT, LASTXFER and CSNAAT bits are discussed in Section 33.7.3.9 Peripheral Deselection with PDC.
If LASTXFER is used, the command must be issued after writing the last character. Instead of LASTXFER,
the user can use the SPIDIS command. After the end of the PDC transfer, it is necessary to wait for the
TXEMPTY flag and then write SPIDIS into the SPI Control Register (SPI_CR). This does not change the
configuration register values). The NPCS is disabled after the last character transfer. Then, another PDC
transfer can be started if the SPIEN has previously been written in the SPI_CR.
33.7.3.6 SPI Peripheral DMA Controller (PDC)
In both Fixed and Variable peripheral select modes, the Peripheral DMA Controller (PDC) can be used to reduce
processor overhead.
The fixed peripheral selection allows buffer transfers with a single peripheral. Using the PDC is an optimal means,
as the size of the data transfer between the memory and the SPI is either 8 bits or 16 bits. However, if the
peripheral selection is modified, the SPI_MR must be reprogrammed.
SPCK
MISO
MOSI
TDRE
DLYBCT DLYBCT
NPCS[0..n] A A A A A
DLYBCS DLYBCS
PCS = A PCS = A
Write SPI_TDR
TDRE
DLYBCT DLYBCT
NPCS[0..n] A A A A A
DLYBCS DLYBCS
PCS=A PCS = A
Write SPI_TDR
TDRE
DLYBCT DLYBCT
NPCS[0..n] A B A B
DLYBCS DLYBCS
PCS = B PCS = B
Write SPI_TDR
DLYBCT DLYBCT
TDRE
NPCS[0..n] A A A A
DLYBCS
PCS = A PCS = A
Write SPI_TDR
SPCK
NSS SPI
Clock
SPIEN
SPIENS
SPIDIS
SPI_CSR0
BITS SPI_RDR RDRF
NCPHA RD OVRES
CPOL
SPI_TDR
TD TDRE
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SWRST SPIDIS SPIEN
23 22 21 20 19 18 17 16
PCS
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
LLB WDRBT MODFDIS PCSDEC PS MSTR
This register can only be written if the WPEN bit is cleared in the SPI Write Protection Mode Register.
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
23 22 21 20 19 18 17 16
PCS
15 14 13 12 11 10 9 8
TD
7 6 5 4 3 2 1 0
TD
23 22 21 20 19 18 17 16
SPIENS
15 14 13 12 11 10 9 8
UNDES TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
UNDES TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
UNDES TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
UNDES TXEMPTY NSSR
7 6 5 4 3 2 1 0
TXBUFE RXBUFF ENDTX ENDRX OVRES MODF TDRE RDRF
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is not enabled.
1: The corresponding interrupt is enabled.
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
7 6 5 4 3 2 1 0
BITS CSAAT CSNAAT NCPHA CPOL
This register can only be written if the WPEN bit is cleared in the SPI Write Protection Mode Register.
Note: SPI_CSRx registers must be written even if the user wants to use the default reset values. The BITS field is not updated with the
translated value unless the register is written.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
34.1 Description
The Atmel Two-wire Interface (TWI) interconnects components on a unique two-wire bus, made up of one clock
line and one data line with speeds of up to 400 Kbits per second, based on a byte-oriented transfer format. It can
be used with any Atmel Two-wire Interface bus Serial EEPROM and IC compatible device such as a Real Time
Clock (RTC), Dot Matrix/Graphic LCD Controllers and temperature sensor. The TWI is programmable as a master
or a slave with sequential or single-byte access. Multiple master capability is supported.
A configurable baud rate generator permits the output data rate to be adapted to a wide range of core clock
frequencies.
Table 34-1 lists the compatibility level of the Atmel Two-wire Interface in Master mode and a full I2C compatible
device.
Bus clock
Peripheral Bridge
TWCK
PIO
TWD
Peripheral Two-wire Interface
clock
PMC
TWI
Interrupt Interrupt
Controller
TWD
TWCK
Start Stop
TWD
TWCK
34.7.3.1 Definition
The master is the device that starts a transfer, generates a clock and stops it.
34.7.3.2 Application Block Diagram
Rp* Rp*
Host with TWI
SDA
TWD
SCL
TWCK
IC
Atmel TWI IC LCD
IC RTC Temperature
Serial EEPROM Controller
Sensor
Slave 1 Slave 2 Slave 3 Slave 4
TXCOMP
TXRDY
TWCK
TXCOMP
TXRDY
TWCK
TXCOMP
TXRDY
TXCOMP
Read RHR
TXCOMP
Write START Bit
RXRDY
Figure 34-11. Master Read with One, Two or Three Bytes Internal Address and One Data Byte
Three bytes internal address
TWD S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A Sr DADR R A
DATA NA P
M LR A M A LA A
S S / C S C SC C
B BW K B K BK K
TXCOMP
TXRDY
BEGIN
No
TXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
Transfer finished
BEGIN
No
TXRDY = 1?
Yes
TXCOMP = 1?
No
Yes
Transfer finished
BEGIN
No
Internal address size = 0?
Yes
Data to send?
Yes
No
No
TXCOMP = 1?
Yes
END
BEGIN
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
BEGIN
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
BEGIN
No
Internal address size = 0?
No
RXRDY = 1?
Yes
Yes
No
RXRDY = 1?
Yes
No
TXCOMP = 1?
Yes
END
34.7.4.1 Definition
In Multi-master mode, more than one master may handle the bus at the same time without data corruption by using
arbitration.
Arbitration starts as soon as two or more masters place information on the bus at the same time, and stops
(arbitration is lost) for the master that intends to send a logical one while the other master sends a logical zero.
As soon as a master lose arbitration, it stops sending data and listens to the bus in order to detect a stop. When
the stop is detected, the master may put its data on the bus by performing arbitration.
Arbitration is illustrated in Figure 34-21.
34.7.4.2 Two Multi-master Modes
Two Multi-master modes may be distinguished:
1. TWI is considered as a master only and will never be addressed.
2. TWI may be either a master or a slave and may be addressed.
Note: Arbitration is supported in both Multi-master modes.
TWI as Master Only
In this mode, TWI is considered as a Master only (MSEN is always one) and must be driven like a Master with the
ARBLST (Arbitration Lost) flag in addition.
If arbitration is lost (ARBLST = 1), the user must reinitiate the data transfer.
If the user starts a transfer (ex.: DADR + START + W + Write in THR) and if the bus is busy, the TWI automatically
waits for a STOP condition on the bus to initiate the transfer (see Figure 34-20).
Note: The state of the bus (busy or free) is not shown in the user interface.
TWI as Master or Slave
The automatic reversal from Master to Slave is not supported in case of a lost arbitration.
Then, in the case where TWI may be either a Master or a Slave, the user must manage the pseudo Multi-master
mode described in the steps below.
1. Program TWI in Slave mode (SADR + MSDIS + SVEN) and perform a slave access (if TWI is addressed).
2. If the TWI has to be set in Master mode, wait until the TXCOMP flag is at 1.
3. Program the Master mode (DADR + SVDIS + MSEN) and start the transfer (ex: START + Write in THR).
4. As soon as the Master mode is enabled, the TWI scans the bus in order to detect if it is busy or free. When
the bus is considered free, TWI initiates the transfer.
5. As soon as the transfer is initiated and until a STOP condition is sent, the arbitration becomes relevant and
the user must monitor the ARBLST flag.
6. If the arbitration is lost (ARBLST is set to 1), the user must program the TWI in Slave mode in case the
Master that won the arbitration is required to access the TWI.
7. If the TWI has to be set in Slave mode, wait until TXCOMP flag is at 1 and then program the Slave mode.
Note: If the arbitration is lost and the TWI is addressed, the TWI will not acknowledge even if it is programmed in Slave mode
as soon as ARBLST is set to 1. Then the Master must repeat SADR.
TWCK
TWCK
TWD
TWCK
Arbitration is lost
Data from a Master S 1 0 0 1 1 P S 1 0 1
The master stops sending data
Arbitration is lost
Data from TWI S 1 0 1 S 1 0 0 1 1
TWI stops sending data
ARBLST
Bus is busy Bus is free
The flowchart shown in Figure 34-22 gives an example of read and write operations in Multi-master mode.
START
Yes No
SVACC = 1 ? GACC = 1 ?
No
No SVREAD = 1 ?
No No
EOSACC = 1 ? Yes TXRDY= 1 ?
Yes Yes
No Write in TWI_THR
TXCOMP = 1 ? No
RXRDY= 1 ?
Yes
Yes
Read TWI_RHR
No Need to perform
a master access ?
GENERAL CALL TREATMENT
Yes
Decoding of the
programming sequence
Prog seq No
OK ?
Change SADR
Yes No
ARBLST = 1 ?
Yes No
MREAD = 1 ?
Yes Yes
RXRDY= 0 ? TXRDY= 0 ?
No No
Yes Yes
Read TWI_RHR Data to read? Data to send ? Write in TWI_THR
No No
Stop transfer
Yes No
TXCOMP = 0 ?
34.7.5.1 Definition
Slave mode is defined as a mode where the device receives the clock and the address from another device called
the master.
VDD
Master
R R
Host with TWI
SDA
TWD
TWCK SCL
TXRDY
Write THR Read RHR
NACK
SVACC
SVREAD SVREAD has to be taken into account only while SVACC is active
EOSACC
RXRDY
SVACC
SVREAD SVREAD has to be taken into account only while SVACC is active
EOSACC
TXD S GENERAL CALL A Reset or write DADD A DATA1 A DATA2 A New SADR A P
New SADR
Programming sequence
GACC
Reset after read
SVACC
Note: This method allows the user to create a personal programming sequence by choosing the programming bytes and the
number of them. The programming sequence has to be provided to the master.
TWCK
CLOCK is tied low by the TWI
as long as THR is empty
Write THR
SCLWS
TXRDY
SVACC
SVREAD
As soon as a START is detected
TXCOMP
TWI_THR is transmitted to the shift register Ack or Nack from the master
Notes: 1. TXRDY is reset when data has been written in the TWI_THR to the internal shifter and set when this data has been
acknowledged or non acknowledged.
2. At the end of the read sequence, TXCOMP is set after a STOP or after a REPEATED_START + an address different from
SADR.
3. SCLWS is automatically set when the clock stretching mechanism is started.
TWCK
CLOCK is tied low by the TWI as long as RHR is full
SCLWS
TWCK is stretched on the last bit of DATA1
RXRDY
Rd DATA0 Rd DATA1 Rd DATA2
SVACC
SVREAD
As soon as a START is detected
TXCOMP
Notes: 1. At the end of the read sequence, TXCOMP is set after a STOP or after a REPEATED_START + an address different from
SADR.
2. SCLWS is automatically set when the clock synchronization mechanism is started and automatically reset when the
mechanism is finished.
TWI_THR
DATA0 DATA1
SVACC
SVREAD
TXRDY
RXRDY
EOSACC Cleared after read
TXCOMP As soon as a START is detected
Note: 1. TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
SVACC
SVREAD
TXRDY
RXRDY
Read TWI_RHR
EOSACC Cleared after read
Notes: 1. In this case, if TWI_THR has not been written at the end of the read command, the clock is automatically stretched before
the ACK.
2. TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
No
SVACC = 1 ? GACC = 1 ?
No SVREAD = 1 ?
No No
EOSACC = 1 ? No TXRDY= 1 ?
No Write in TWI_THR
TXCOMP = 1 ?
No
RXRDY= 1 ?
END
Read TWI_RHR
Decoding of the
programming sequence
Prog seq No
OK ?
Change SADR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SWRST QUICK SVDIS SVEN MSDIS MSEN STOP START
23 22 21 20 19 18 17 16
DADR
15 14 13 12 11 10 9 8
MREAD IADRSZ
7 6 5 4 3 2 1 0
23 22 21 20 19 18 17 16
SADR
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
23 22 21 20 19 18 17 16
IADR
15 14 13 12 11 10 9 8
IADR
7 6 5 4 3 2 1 0
IADR
23 22 21 20 19 18 17 16
CKDIV
15 14 13 12 11 10 9 8
CHDIV
7 6 5 4 3 2 1 0
CLDIV
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXBUFE RXBUFF ENDTX ENDRX EOSACC SCLWS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC SVREAD TXRDY RXRDY TXCOMP
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXBUFE RXBUFF ENDTX ENDRX EOSACC SCL_WS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC TXRDY RXRDY TXCOMP
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXBUFE RXBUFF ENDTX ENDRX EOSACC SCL_WS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC TXRDY RXRDY TXCOMP
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXBUFE RXBUFF ENDTX ENDRX EOSACC SCL_WS ARBLST NACK
7 6 5 4 3 2 1 0
OVRE GACC SVACC TXRDY RXRDY TXCOMP
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is disabled.
1: The 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
RXDATA
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TXDATA
35.1 Description
The Universal Asynchronous Receiver Transmitter (UART) features a two-pin UART that can be used for
communication and trace purposes and offers an ideal medium for in-situ programming solutions.
Moreover, the association with a peripheral DMA controller (PDC) permits packet handling for these tasks with
processor time reduced to a minimum.
UART
UTXD
Transmit
Peripheral DMA Controller Parallel
Baud Rate
Generator Input/
Output
Receive
bus clock Bridge URXD
APB
Interrupt
uart_irq
Control
PMC peripheral clock
CD
35.5.2 Receiver
RXRDY
OVRE
RSTSTA
URXD
URXD S D0 D1 D2 D3 D4 D5 D6 D7 P S D0 D1 D2 D3 D4 D5 D6 D7 P
RXRDY
Read UART_RHR
RXRDY
OVRE
RSTSTA
URXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY
PARE
URXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY
FRAME
35.5.3 Transmitter
Baud Rate
Clock
UTXD
TXRDY
TXEMPTY
Receiver RXD
Disabled
Transmitter TXD
Local Loopback
Disabled
Receiver RXD
VDD
Disabled
Transmitter TXD
Disabled
Transmitter TXD
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
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CHMODE PAR
7 6 5 4 3 2 1 0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE TXEMPTY
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX TXRDY RXRDY
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
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
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
36.1 Description
The Universal Synchronous Asynchronous Receiver Transceiver (USART) provides one full duplex universal
synchronous asynchronous serial link. Data frame format is widely programmable (data length, parity, number of
stop bits) to support a maximum of standards. The receiver implements parity error, framing error and overrun
error detection. The receiver time-out enables handling variable-length frames and the transmitter timeguard
facilitates communications with slow remote devices. Multidrop communications are also supported through
address bit handling in reception and transmission.
The USART features three test modes: Remote loopback, Local loopback and Automatic echo.
The USART supports specific operating modes providing interfaces on RS485, and SPI buses, with ISO7816 T =
0 or T = 1 smart card slots, infrared transceivers and connection to modem ports. The hardware handshaking
feature enables an out-of-band flow control by automatic management of the pins RTS and CTS.
The USART supports the connection to the Peripheral DMA Controller, which enables data transfers to the
transmitter and from the receiver. The PDC provides chained buffer management without any intervention of the
processor.
RXD
Receiver
Channel
RTS
(Peripheral)
DMA Controller
TXD
Channel Transmitter
CTS
DTR
Modem
Signals DSR
Bus clock Control
Bridge DCD
RI
APB User
Interface
SCK
Baud Rate
Peripheral clock Generator
PMC
Peripheral clock/DIV
CD SCK
Peripheral clock
0 (CLKO = 1)
Peripheral clock/DIV
1
Reserved 16-bit Counter
2 FIDI
>1 SYNC
SCK 3 OVER
1 0
(CLKO = 0)
0 0 Sampling 0
Divider
Baud Rate
1 Clock
1
SYNC
Sampling
USCLKS = 3 Clock
This gives a maximum baud rate of peripheral clock divided by 8, assuming that the peripheral clock is the highest
possible clock and that the OVER bit is set.
The baud rate error is calculated with the following formula. It is not recommended to work with an error higher
than 5%.
Error = 1 ---------------------------------------------------
ExpectedBaudRate
ActualBaudRate
FP
USCLKS Modulus
CD
Control
FP
MCK CD SCK
0 (CLKO = 1)
MCK/DIV
1
Reserved 16-bit Counter
2 Glitch-free FIDI
Logic >1 SYNC
3 OVER
1 0
SCK
(CLKO = 0) 0 0 Sampling 0
Divider
Baud Rate
1 Clock
1
SYNC Sampling
USCLKS = 3 Clock
In Synchronous mode, if the external clock is selected (USCLKS = 3), the clock is provided directly by the signal on
the USART SCK pin. No division is active. The value written in US_BRGR has no effect. The external clock
frequency must be at least 3 times lower than the system clock. In Synchronous mode master (USCLKS = 0 or 1,
CLKO set to 1), the receive part limits the SCK maximum frequency tofperipheral clock/3 in USART mode, or fperipheral
clock/6 in SPI mode.
When either the external clock SCK or the internal clock divided (peripheral clock/DIV) is selected, the value
programmed in CD must be even if the user has to ensure a 50:50 mark/space ratio on the SCK pin. When the
peripheral clock is selected, the baud rate generator ensures a 50:50 duty cycle on the SCK pin, even if the value
programmed in CD is odd.
where:
B is the bit rate
Di is the bit-rate adjustment factor
Fi is the clock frequency division factor
f is the ISO7816 clock frequency (Hz)
Di is a binary value encoded on a 4-bit field, named DI, as represented in Table 36-5.
Fi is a binary value encoded on a 4-bit field, named FI, as represented in Table 36-6.
Table 36-7 shows the resulting Fi/Di ratio, which is the ratio between the ISO7816 clock and the baud rate clock.
If the USART is configured in ISO7816 mode, the clock selected by the USCLKS field in US_MR is first divided by
the value programmed in the field CD in the US_BRGR. The resulting clock can be provided to the SCK pin to feed
the smart card clock inputs. This means that the CLKO bit can be set in US_MR.
This clock is then divided by the value programmed in the FI_DI_RATIO field in the FI_DI_Ratio register
(US_FIDI). This is performed by the Sampling Divider, which performs a division by up to 2047 in ISO7816 mode.
The non-integer values of the Fi/Di Ratio are not supported and the user must program the FI_DI_RATIO field to a
value as close as possible to the expected value.
The FI_DI_RATIO field resets to the value 0x174 (372 in decimal) and is the most common divider between the
ISO7816 clock and the bit rate (Fi = 372, Di = 1).
Figure 36-4 shows the relation between the Elementary Time Unit, corresponding to a bit time, and the ISO 7816
clock.
ISO7816 Clock
on SCK
1 ETU
Baud Rate
Clock
TXD
The characters are sent by writing in the Transmit Holding register (US_THR). The transmitter reports two status
bits in the Channel Status register (US_CSR): TXRDY (Transmitter Ready), which indicates that US_THR is empty
and TXEMPTY, which indicates that all the characters written in US_THR have been processed. When the current
character processing is completed, the last character written in US_THR is transferred into the Shift register of the
transmitter and US_THR becomes empty, thus TXRDY rises.
Both TXRDY and TXEMPTY bits are low when the transmitter is disabled. Writing a character in US_THR while
TXRDY is low has no effect and the written character is lost.
TXD
Start Parity Stop Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit Bit Bit Bit
Write
US_THR
TXRDY
TXEMPTY
The Manchester encoded character can also be encapsulated by adding both a configurable preamble and a start
frame delimiter pattern. Depending on the configuration, the preamble is a training sequence, composed of a
Manchester
encoded SFD DATA
data Txd
Manchester
encoded SFD DATA
data Txd
Manchester
encoded SFD
Txd DATA
data
Manchester
encoded SFD DATA
data Txd
A start frame delimiter is to be configured using the ONEBIT bit in the US_MR. It consists of a user-defined pattern
that indicates the beginning of a valid data. Figure 36-9 illustrates these patterns. If the start frame delimiter, also
known as the start bit, is one bit, (ONEBIT = 1), a logic zero is Manchester encoded and indicates that a new
character is being sent serially on the line. If the start frame delimiter is a synchronization pattern also referred to
as sync (ONE BIT to 0), a sequence of three bit times is sent serially on the line to indicate the start of a new
character. The sync waveform is in itself an invalid Manchester waveform as the transition occurs at the middle of
the second bit time. Two distinct sync patterns are used: the command sync and the data sync. The command
sync has a logic one level for one and a half bit times, then a transition to logic zero for the second one and a half
bit times. If the MODSYNC bit in the US_MR is set to 1, the next character is a command. If it is set to 0, the next
character is a data. When direct memory access is used, the MODSYNC field can be immediately updated with a
modified character located in memory. To enable this mode, VAR_SYNC bit in US_MR must be set to 1. In this
case, the MODSYNC bit in the US_MR is bypassed and the sync configuration is held in the TXSYNH in the
US_THR. The USART character format is modified and includes sync information.
Preamble Length
is set to 0
SFD
Manchester
encoded DATA
data Txd
Command Sync
start frame delimiter
SFD
Manchester
encoded DATA
data Txd
Data Sync
start frame delimiter
Drift Compensation
Drift compensation is available only in 16X oversampling mode. An hardware recovery system allows a larger
clock drift. To enable the hardware system, the bit in the USART_MAN register must be set. If the RXD edge is
one 16X clock cycle from the expected edge, this is considered as normal jitter and no corrective actions is taken.
If the RXD event is between 4 and 2 clock cycles before the expected edge, then the current period is shortened
by one clock cycle. If the RXD event is between 2 and 3 clock cycles after the expected edge, then the current
period is lengthened by one clock cycle. These intervals are considered to be drift and so corrective actions are
automatically taken.
Oversampling
16x Clock
RXD
Sampling
point
Expected edge
Synchro. Tolerance Sync Synchro.
Synchro. Jump Jump Error
Error
Sampling
Clock (x16)
RXD
Sampling
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
D0
Start Sampling
Detection
RXD
Sampling
1 2 3 4 5 6 7 0 1 2 3 4
Start
Rejection
Baud Rate
Clock
RXD
Start 16 16 16 16 16 16 16 16 16 16
Detection samples samples samples samples samples samples samples samples samples samples
D0 D1 D2 D3 D4 D5 D6 D7 Parity Stop
Bit Bit
The receiver is activated and starts preamble and frame delimiter detection, sampling the data at one quarter and
then three quarters. If a valid preamble pattern or start frame delimiter is detected, the receiver continues decoding
with the same synchronization. If the stream does not match a valid pattern or a valid start frame delimiter, the
receiver resynchronizes on the next valid edge.The minimum time threshold to estimate the bit value is three
quarters of a bit time.
If a valid preamble (if used) followed with a valid start frame delimiter is detected, the incoming stream is decoded
into NRZ data and passed to USART for processing. Figure 36-14 illustrates Manchester pattern mismatch. When
incoming data stream is passed to the USART, the receiver is also able to detect Manchester code violation. A
code violation is a lack of transition in the middle of a bit cell. In this case, MANE flag in the US_CSR is raised. It is
cleared by writing a 1 to the RSTSTA in the US_CR. See Figure 36-15 for an example of Manchester error
detection during data phase.
Manchester
encoded SFD DATA
data Txd
sampling points
ASK/FSK
Upstream Receiver
Upstream
LNA Serial
Emitter VCO Configuration
RF filter Interface
Demod
ASK/FSK
downstream transmitter
Manchester USART
Downstream encoder Emitter
Receiver PA
RF filter
Mod
VCO
control
Manchester
encoded
data Txd
default polarity
unipolar output
FSK Modulator
Output
Uptstream Frequencies
[F0, F0+offset]
Baud Rate
Clock
RXD
Sampling
Start D0 D1 D2 D3 D4 D5 D6 D7 Stop Bit
Parity Bit
Baud Rate
Clock
RXD
Start Parity Stop Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit Bit Bit Bit
RSTSTA = 1
Write
US_CR
Read
US_RHR
RXRDY
OVRE
36.6.3.8 Parity
The USART supports five Parity modes that are selected by writing to the PAR field in the US_MR. The PAR field
also enables the Multidrop mode, see Section 36.6.3.9 Multidrop Mode. Even and odd parity bit generation and
error detection are supported.
If even parity is selected, the parity generator of the transmitter drives the parity bit to 0 if a number of 1s in the
character data bit is even, and to 1 if the number of 1s is odd. Accordingly, the receiver parity checker counts the
number of received 1s and reports a parity error if the sampled parity bit does not correspond. If odd parity is
selected, the parity generator of the transmitter drives the parity bit to 1 if a number of 1s in the character data bit
is even, and to 0 if the number of 1s is odd. Accordingly, the receiver parity checker counts the number of received
1s and reports a parity error if the sampled parity bit does not correspond. If the mark parity is used, the parity
generator of the transmitter drives the parity bit to 1 for all characters. The receiver parity checker reports an error
if the parity bit is sampled to 0. If the space parity is used, the parity generator of the transmitter drives the parity bit
to 0 for all characters. The receiver parity checker reports an error if the parity bit is sampled to 1. If parity is
disabled, the transmitter does not generate any parity bit and the receiver does not report any parity error.
Table 36-8 shows an example of the parity bit for the character 0x41 (character ASCII A) depending on the
configuration of the USART. Because there are two bits set to 1 in the character value, the parity bit is set to 1
when the parity is odd, or configured to 0 when the parity is even.
When the receiver detects a parity error, it sets the PARE (Parity Error) bit in the US_CSR. The PARE bit can be
cleared by writing a 1 to the RSTSTA bit the US_CR. Figure 36-21 illustrates the parity bit status setting and
clearing.
Baud Rate
Clock
RXD
Start Bad Stop
D0 D1 D2 D3 D4 D5 D6 D7
Bit Parity Bit
Bit RSTSTA = 1
Write
US_CR
Parity Error
Detect
PARE Time Flags
Report
Time
RXRDY
TG = 4 TG = 4
Baud Rate
Clock
TXD
Start Parity Stop Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit Bit Bit Bit
Write
US_THR
TXRDY
TXEMPTY
Table 36-9 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the
function of the baud rate.
Baud Rate TO
Clock
16-bit
Value
1 D Q Clock 16-bit Time-out
Counter
STTTO = TIMEOUT
Load 0
Clear
Character
Received
RETTO
Table 36-10 gives the maximum time-out period for some standard baud rates.
Baud Rate
Clock
RXD
Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit
RSTSTA = 1
Write
US_CR
FRAME
RXRDY
Baud Rate
Clock
TXD
Start Parity Stop
Bit
D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit
Break Transmission End of Break
STTBRK = 1 STPBRK = 1
Write
US_CR
TXRDY
TXEMPTY
USART Remote
Device
TXD RXD
RXD TXD
CTS RTS
RTS CTS
Setting the USART to operate with hardware handshaking is performed by writing the USART_MODE field in
US_MR to the value 0x2.
The USART behavior when hardware handshaking is enabled is the same as the behavior in standard
Synchronous or Asynchronous mode, except that the receiver drives the RTS pin as described below and the level
on the CTS pin modifies the behavior of the transmitter as described below. Using this mode requires using the
PDC channel for reception. The transmitter can handle hardware handshaking in any case.
Figure 36-27 shows how the receiver operates if hardware handshaking is enabled. The RTS pin is driven high if
the receiver is disabled or if the status RXBUFF (Receive Buffer Full) coming from the PDC channel is high.
Normally, the remote device does not start transmitting while its CTS pin (driven by RTS) is high. As soon as the
receiver is enabled, the RTS falls, indicating to the remote device that it can start transmitting. Defining a new
buffer in the PDC clears the status bit RXBUFF and, as a result, asserts the pin RTS low.
RXD
RXEN = 1 RXDIS = 1
Write
US_CR
RTS
RXBUFF
Figure 36-28 shows how the transmitter operates if hardware handshaking is enabled. The CTS pin disables the
transmitter. If a character is being processed, the transmitter is disabled only after the completion of the current
character and transmission of the next character happens as soon as the pin CTS falls.
CTS
TXD
USART
CLK
SCK Smart
Card
I/O
TXD
When operating in ISO7816, either in T = 0 or T = 1 modes, the character format is fixed. The configuration is 8
data bits, even parity and 1 or 2 stop bits, regardless of the values programmed in the CHRL, MODE9, PAR and
CHMODE fields. MSBF can be used to transmit LSB or MSB first. Parity Bit (PAR) can be used to transmit in
normal or inverse mode. Refer to Section 36.7.3 USART Mode Register and PAR: Parity Type .
RXD
I/O Error
USART IrDA
Transceivers
Receiver Demodulator RXD RX
TX
Transmitter Modulator TXD
The receiver and the transmitter must be enabled or disabled depending on the direction of the transmission to be
managed.
To receive IrDA signals, the following needs to be done:
Disable TX and Enable RX
Configure the TXD pin as PIO and set it as an output to 0 (to avoid LED emission). Disable the internal pull-
up (better for power consumption).
TXD
RXD
Counter
Value 6 5 4 3 2 6 6 5 4 3 2 1 0
Pulse Pulse
Rejected Accepted
Receiver
Input
The programmed value in the US_IF register must always meet the following criteria:
tperipheral clock (IRDA_FILTER + 3) < 1.41 s
As the IrDA mode uses the same logic as the ISO7816, note that the FI_DI_RATIO field in US_FIDI must be set to
a value higher than 0 in order to make sure IrDA communications operate correctly.
USART
RXD
Differential
TXD Bus
RTS
The USART is set in RS485 mode by writing the value 0x1 to the USART_MODE field in US_MR.
The RTS pin is at a level inverse to the TXEMPTY bit. Significantly, the RTS pin remains high when a timeguard is
programmed so that the line can remain driven after the last character completion. Figure 36-36 gives an example
of the RTS waveform during a character transmission when the timeguard is enabled.
TXD
Start Parity Stop
D0 D1 D2 D3 D4 D5 D6 D7
Bit Bit Bit
RTS
Write
US_THR
TXRDY
TXEMPTY
The control of the DTR output pin is performed by writing a 1 to the DTRDIS and DTREN bits respectively in
US_CR. The disable command forces the corresponding pin to its inactive level, i.e., high. The enable command
forces the corresponding pin to its active level, i.e., low. The RTS output pin is automatically controlled in this
mode.
The level changes are detected on the RI, DSR, DCD and CTS pins. If an input change is detected, the RIIC,
DSRIC, DCDIC and CTSIC bits in US_CSR are set respectively and can trigger an interrupt. The status is
automatically cleared when US_CSR is read. Furthermore, the CTS automatically disables the transmitter when it
is detected at its inactive state. If a character is being transmitted when the CTS rises, the character transmission
is completed before the transmitter is actually disabled.
SCK
(CPOL = 0)
SCK
(CPOL = 1)
MOSI
SPI Master ->TXD MSB 6 5 4 3 2 1 LSB
SPI Slave -> RXD
MISO
SPI Master -> RXD MSB 6 5 4 3 2 1 LSB
SPI Slave -> TXD
NSS
SPI Master -> RTS
SPI Slave -> CTS
SCK
(CPOL = 0)
SCK
(CPOL = 1)
MOSI
SPI Master -> TXD MSB 6 5 4 3 2 1 LSB
SPI Slave -> RXD
MISO
SPI Master -> RXD MSB 6 5 4 3 2 1 LSB
SPI Slave -> TXD
NSS
SPI Master -> RTS
SPI Slave -> CTS
TXD
Transmitter
TXD
Transmitter
TXD
Transmitter 1
TXD
Transmitter
23 22 21 20 19 18 17 16
RTSDIS RTSEN DTRDIS DTREN
15 14 13 12 11 10 9 8
RETTO RSTNACK RSTIT SENDA STTTO STPBRK STTBRK RSTSTA
7 6 5 4 3 2 1 0
TXDIS TXEN RXDIS RXEN RSTTX RSTRX
For SPI control, see Section 36.7.2 USART Control Register (SPI_MODE).
STTTO: Clear TIMEOUT Flag and Start Time-out After Next Character Received
0: No effect.
1: Starts waiting for a character before enabling the time-out counter. Immediately disables a time-out period in progress.
Resets the status bit TIMEOUT in US_CSR.
23 22 21 20 19 18 17 16
RCS FCS
15 14 13 12 11 10 9 8
RSTSTA
7 6 5 4 3 2 1 0
TXDIS TXEN RXDIS RXEN RSTTX RSTRX
This configuration is relevant only if USART_MODE = 0xE or 0xF in the USART Mode Register.
23 22 21 20 19 18 17 16
INVDATA VAR_SYNC DSNACK INACK OVER CLKO MODE9 MSBF
15 14 13 12 11 10 9 8
CHMODE NBSTOP PAR SYNC
7 6 5 4 3 2 1 0
CHRL USCLKS USART_MODE
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
For SPI configuration, see Section 36.7.4 USART Mode Register (SPI_MODE).
23 22 21 20 19 18 17 16
WRDBT CLKO CPOL
15 14 13 12 11 10 9 8
CPHA
7 6 5 4 3 2 1 0
CHRL USCLKS USART_MODE
This configuration is relevant only if USART_MODE = 0xE or 0xF in the USART Mode Register.
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
23 22 21 20 19 18 17 16
CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITER TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
For SPI specific configuration, see Section 36.7.6 USART Interrupt Enable Register (SPI_MODE).
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Enables the corresponding interrupt.
ENDRX: End of Receive Buffer Interrupt Enable (available in all USART modes of operation)
ENDTX: End of Transmit Buffer Interrupt Enable (available in all USART modes of operation)
TXBUFE: Transmit Buffer Empty Interrupt Enable (available in all USART modes of operation)
RXBUFF: Receive Buffer Full Interrupt Enable (available in all USART modes of operation)
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE UNRE TXEMPTY
7 6 5 4 3 2 1 0
OVRE ENDTX ENDRX TXRDY RXRDY
This configuration is relevant only if USART_MODE = 0xE or 0xF in the USART Mode Register.
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITER TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
For SPI specific configuration, see Section 36.7.8 USART Interrupt Disable Register (SPI_MODE).
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Disables the corresponding interrupt.
ENDRX: End of Receive Buffer Transfer Interrupt Disable (available in all USART modes of operation)
ENDTX: End of Transmit Buffer Interrupt Disable (available in all USART modes of operation)
TXBUFE: Transmit Buffer Empty Interrupt Disable (available in all USART modes of operation)
RXBUFF: Receive Buffer Full Interrupt Disable (available in all USART modes of operation)
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE UNRE TXEMPTY
7 6 5 4 3 2 1 0
OVRE ENDTX ENDRX TXRDY RXRDY
This configuration is relevant only if USART_MODE = 0xE or 0xF in the USART Mode Register.
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITER TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
For SPI specific configuration, see Section 36.7.10 USART Interrupt Mask Register (SPI_MODE).
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is not enabled.
1: The corresponding interrupt is enabled.
ENDRX: End of Receive Buffer Interrupt Mask (available in all USART modes of operation)
ENDTX: End of Transmit Buffer Interrupt Mask (available in all USART modes of operation)
TXBUFE: Transmit Buffer Empty Interrupt Mask (available in all USART modes of operation)
RXBUFF: Receive Buffer Full Interrupt Mask (available in all USART modes of operation)
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE UNRE TXEMPTY
7 6 5 4 3 2 1 0
OVRE ENDTX ENDRX TXRDY RXRDY
This configuration is relevant only if USART_MODE = 0xE or 0xF in the USART Mode Register.
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is not enabled.
1: The corresponding interrupt is enabled.
23 22 21 20 19 18 17 16
CTS DCD DSR RI CTSIC DCDIC DSRIC RIIC
15 14 13 12 11 10 9 8
NACK RXBUFF TXBUFE ITER TXEMPTY TIMEOUT
7 6 5 4 3 2 1 0
PARE FRAME OVRE ENDTX ENDRX RXBRK TXRDY RXRDY
For SPI specific configuration, see Section 36.7.12 USART Channel Status Register (SPI_MODE).
ITER: Max Number of Repetitions Reached (cleared by writing a one to bit US_CR.RSTIT)
0: Maximum number of repetitions has not been reached since the last RSTIT.
1: Maximum number of repetitions has been reached since the last RSTIT.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXBUFF TXBUFE UNRE TXEMPTY
7 6 5 4 3 2 1 0
OVRE ENDTX ENDRX TXRDY RXRDY
This configuration is relevant only if USART_MODE = 0xE or 0xF in the USART Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
RXSYNH RXCHR
7 6 5 4 3 2 1 0
RXCHR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TXSYNH TXCHR
7 6 5 4 3 2 1 0
TXCHR
23 22 21 20 19 18 17 16
FP
15 14 13 12 11 10 9 8
CD
7 6 5 4 3 2 1 0
CD
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
TO
7 6 5 4 3 2 1 0
TO
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TG
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
TG: Timeguard Value
0: The transmitter timeguard is disabled.
1255: The transmitter timeguard is enabled and TG is Timeguard Delay / Bit Period.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FI_DI_RATIO
7 6 5 4 3 2 1 0
FI_DI_RATIO
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
NB_ERRORS
This register is relevant only if USART_MODE = 0x4 or 0x6 in the USART Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
IRDA_FILTER
This register is relevant only if USART_MODE = 0x8 in the USART Mode Register.
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
23 22 21 20 19 18 17 16
RX_PL
15 14 13 12 11 10 9 8
TX_MPOL TX_PP
7 6 5 4 3 2 1 0
TX_PL
This register can only be written if the WPEN bit is cleared in the USART Write Protection Mode Register.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
37.1 Description
A Timer Counter (TC) module includes three identical TC channels. The number of implemented TC modules is
device-specific.
Each TC channel can be independently programmed to perform a wide range of functions including frequency
measurement, event counting, interval measurement, pulse generation, delay timing and pulse width modulation.
Each channel has three external clock inputs, five internal clock inputs and two multi-purpose input/output signals
which can be configured by the user. Each channel drives an internal interrupt signal which can be programmed to
generate processor interrupts.
The TC embeds a quadrature decoder (QDEC) connected in front of the timers and driven by TIOA0, TIOB0 and
TIOB1 inputs. When enabled, the QDEC performs the input lines filtering, decoding of quadrature signals and
connects to the timers/counters in order to read the position and speed of the motor through the user interface.
The TC block has two global registers which act upon all TC channels:
Block Control Register (TC_BCR)allows channels to be started simultaneously with the same instruction
Block Mode Register (TC_BMR)defines the external clock inputs for each channel, allowing them to be
chained
Parallel I/O
TIMER_CLOCK1 Controller
TCLK0
TCLK0
TIMER_CLOCK2 TCLK1
TIOA1 TCLK2
TCLK0
TCLK2 SYNC
INT1
TC1XC1S
Timer Counter
PWM Interrupt
Controller
37.6.1 Description
All channels of the Timer Counter are independent and identical in operation except when the QDEC is enabled.
The registers for channel programming are listed in Table 37-6 Register Mapping.
Timer/Counter
TCLK0 Channel 0
TIOA1
XC0 TIOA0
TIOA2
XC1 = TCLK1
XC2 = TCLK2 TIOB0
SYNC
TC1XC1S
Timer/Counter
Channel 1
TCLK1 XC0 = TCLK0 TIOA1
TIOA0
XC1
TIOA2
XC2 = TCLK2 TIOB1
SYNC
Timer/Counter
TC2XC2S Channel 2
SYNC
TCCLKS
CLKI
TIMER_CLOCK1 Synchronous
TIMER_CLOCK2 Edge Detection
TIMER_CLOCK3
TIMER_CLOCK4 Selected
Clock
TIMER_CLOCK5
XC0
XC1
XC2
Peripheral Clock
BURST
Q S
R
Q S
R
Stop Disable
Counter Event Event
Clock
37.6.6 Trigger
A trigger resets the counter and starts the counter clock. Three types of triggers are common to both modes, and a
fourth external trigger is available to each mode.
Regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. This
means that the counter value can be read differently from zero just after a trigger, especially when a low frequency
signal is selected as the clock.
The following triggers are common to both modes:
Software Trigger: Each channel has a software trigger, available by setting SWTRG in TC_CCR.
SYNC: Each channel has a synchronization signal SYNC. When asserted, this signal 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.
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 the TC_CMR.
The 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 bit ENETRG in the TC_CMR.
If an external trigger is used, the duration of the pulses must be longer than the peripheral clock period in order to
be detected.
TCCLKS
CLKSTA CLKEN CLKDIS
Synchronous CLKI
TIMER_CLOCK1
Edge Detection
TIMER_CLOCK2
TIMER_CLOCK3
Q S
TIMER_CLOCK4
Capture Mode
TIMER_CLOCK5 R
Q S
XC0
R
XC1
XC2
LDBSTOP LDBDIS
Peripheral Clock
BURST
Register C
Capture Capture
1 Register A Register B Compare RC =
Counter
SWTRG
CLK
OVF
RESET
SYNC
Trig
ABETRG
ETRGEDG CPCTRG
MTIOB Edge
Detector
TIOB
LDRA LDRB
CPCS
LDRAS
LDRBS
LOVRS
ETRGS
COVFS
TC1_SR
Timer/Counter Channel
Atmel-11100K-ATARM-SAM4S-Datasheet_09-Jun-15
SAM4S Series [DATASHEET]
INT
859
37.6.10 Waveform Mode
Waveform mode is entered by setting the TC_CMRx.WAVE bit.
In Waveform mode, the TC channel generates one or two PWM signals with the same frequency and
independently programmable duty cycles, or generates different types of one-shot or repetitive pulses.
In this mode, TIOA is configured as an output and TIOB is defined as an output if it is not used as an external event
(EEVT parameter in TC_CMR).
Figure 37-6 shows the configuration of the TC channel when programmed in Waveform operating mode.
TCCLKS
CLKSTA CLKEN CLKDIS
TIMER_CLOCK1 ACPC
Synchronous CLKI
TIMER_CLOCK2 Edge Detection
TIMER_CLOCK3
Q S
TIMER_CLOCK4 CPCDIS MTIOA
TIMER_CLOCK5 R ACPA
Waveform Mode
Q S
XC0
R
XC1
XC2 CPCSTOP TIOA
AEEVT
Peripheral Clock
Output Controller
Counter
CLK
OVF
RESET
SWTRG
BCPC
SYNC
Trig
BCPB MTIOB
WAVSEL
EEVT
TIOB
BEEVT
EEVTEDG
ENETRG
Output Controller
CPAS
CPBS
CPCS
ETRGS
COVFS
Edge
TC1_SR
Detector BSWTRG
TIOB
TC1_IMR
Timer/Counter Channel
INT
Atmel-11100K-ATARM-SAM4S-Datasheet_09-Jun-15
SAM4S Series [DATASHEET]
861
37.6.11.1 WAVSEL = 00
When WAVSEL = 00, the value of TC_CV is incremented from 0 to 216-1. Once 216-1 has been reached, the value
of TC_CV is reset. Incrementation of TC_CV starts again and the cycle continues. See Figure 37-7.
An external event trigger or a software trigger can reset the value of TC_CV. It is important to note that the trigger
may occur at any time. See Figure 37-8.
RC Compare cannot be programmed to generate a trigger in this configuration. At the same time, RC Compare
can stop the counter clock (CPCSTOP = 1 in TC_CMR) and/or disable the counter clock (CPCDIS = 1 in
TC_CMR).
0xFFFF
RC
RB
RA
TIOB
TIOA
0xFFFF
RB
RA
Time
Waveform Examples
TIOB
TIOA
2n-1
(n = counter size) Counter cleared by compare match with RC
RC
RB
RA
TIOB
TIOA
2n-1
(n = counter size) Counter cleared by compare match with RC Counter cleared by trigger
RC
RB
RA
TIOB
TIOA
0xFFFF
RC
RB
RA
TIOB
TIOA
0xFFFF
Counter decremented
by trigger
RC
RB
Counter incremented
by trigger
RA
TIOB
TIOA
Counter Value
2n-1
(n = counter size)
Counter decremented by compare match with RC
RC
RB
RA
TIOB
TIOA
2n-1
(n = counter size)
Counter decremented by compare match with RC
RC
Counter decremented
by trigger
RB
Counter incremented
by trigger
RA
TIOB
TIOA
37.6.14.1 Description
The quadrature decoder (QDEC) is driven by TIOA0, TIOB0, TIOB1 input pins and drives the timer/counter of
channel 0 and 1. Channel 2 can be used as a time base in case of speed measurement requirements (refer to
Figure 37-15).
When writing a 0 to bit QDEN of the TC_BMR, the QDEC is bypassed and the IO pins are directly routed to the
timer counter function. See
TIOA0 and TIOB0 are to be driven by the two dedicated quadrature signals from a rotary sensor mounted on the
shaft of the off-chip motor.
A third signal from the rotary sensor can be processed through pin TIOB1 and is typically dedicated to be driven by
an index signal if it is provided by the sensor. This signal is not required to decode the quadrature signals PHA,
PHB.
Field TCCLKS of TC_CMRx must be configured to select XC0 input (i.e., 0x101). Field TC0XC0S has no effect as
soon as the QDEC is enabled.
Either speed or position/revolution can be measured. Position channel 0 accumulates the edges of PHA, PHB
input signals giving a high accuracy on motor position whereas channel 1 accumulates the index pulses of the
sensor, therefore the number of rotations. Concatenation of both values provides a high level of precision on
motion system position.
In Speed mode, position cannot be measured but revolution can be measured.
Inputs from the rotary sensor can be filtered prior to down-stream processing. Accommodation of input polarity,
phase definition and other factors are configurable.
Interruptions can be generated on different events.
A compare function (using TC_RC) is available on channel 0 (speed/position) or channel 1 (rotation) and can
generate an interrupt by means of the CPCS flag in the TC_SRx.
SPEEDEN
Quadrature
Decoder 1
1
(Filter + Edge
Detect + QD) TIOA Timer/Counter
Channel 0
TIOA0
PHEdges QDEN
1
TIOB
1 XC0
TIOB0
TIOA0 PHA XC0
Speed/Position
TIOB0 QDEN
PHB
TIOB1 Index
IDX 1
TIOB
1 Timer/Counter
XC0
Channel 1
TIOB1
XC0
Rotation
Direction
Timer/Counter
Channel 2
Input Pre-Processing
1
PHA
1 PHedge
Filter
TIOA0
Direction
INVA and
Edge
Detection
1 PHB
1 DIR
Filter
TIOB0
INVB
1 IDX
1 IDX
1 Filter
TIOB1
IDXPHB
INVIDX
Input filtering can efficiently remove spurious pulses that might be generated by the presence of particulate
contamination on the optical or magnetic disk of the rotary sensor.
Spurious pulses can also occur in environments with high levels of electro-magnetic interference. Or, simply if
vibration occurs even when rotation is fully stopped and the shaft of the motor is in such a position that the
beginning of one of the reflective or magnetic bars on the rotary sensor disk is aligned with the light or magnetic
(Hall) receiver cell of the rotary sensor. Any vibration can make the PHA, PHB signals toggle for a short duration.
particulate contamination
PHA,B
Filter Out
PHA
PHB
motor shaft stopped in such a position that
rotary sensor cell is aligned with an edge of the disk
rotation
stop
PHA
PHB
stop
Resulting PHA, PHB electrical waveforms
PHB
vibration
PHA, PHB electrical waveforms after filtering
PHA
PHB
Report Time
PHB
DIR
DIRCHG
missing pulse
PHA
same phase
PHB
DIR
The direction change detection is disabled when QDTRANS is set in the TC_BMR. In this case, the DIR flag report
must not be used.
A quadrature error is also reported by the QDEC via the QERR flag in the TC_QISR. This error is reported if the
time difference between two edges on PHA, PHB is lower than a predefined value. This predefined value is
MAXFILT = 2
Peripheral Clock
PHA
PHB
PHA
PHB
PHA
Even with an abnorrmaly formatted disk, there is no occurence of PHA, PHB switching at the same time.
PHB
QERR
MAXFILT must be tuned according to several factors such as the peripheral clock frequency, type of rotary sensor
and rotation speed to be achieved.
37.6.14.4 Position and Rotation Measurement
When the POSEN bit is set in the TC_BMR, the motor axis position is processed on channel 0 (by means of the
PHA, PHB edge detections) and the number of motor revolutions are recorded on channel 1 if the IDX signal is
provided on the TIOB1 input. The position measurement can be read in the TC_CV0 register and the rotation
measurement can be read in the TC_CV1 register.
Channel 0 and 1 must be configured in Capture mode (TC_CMR0.WAVE = 0). Rising edge must be selected as
the External Trigger Edge (TC_CMR.ETRGEDG = 0x01) and TIOA must be selected as the External Trigger
(TC_CMR.ABETRG = 0x1).
In parallel, the number of edges are accumulated on timer/counter channel 0 and can be read on the TC_CV0
register.
Therefore, the accurate position can be read on both TC_CV registers and concatenated to form a 32-bit word.
The timer/counter channel 0 is cleared for each increment of IDX count value.
WAVEx = GCENx =1
TIOAx
TC_RCx
TIOBx
DOWNx
TC_FMR / ENCF0 OR
TC_FMR / ENCF1
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SWTRG CLKDIS CLKEN
23 22 21 20 19 18 17 16
LDRB LDRA
15 14 13 12 11 10 9 8
WAVE CPCTRG ABETRG ETRGEDG
7 6 5 4 3 2 1 0
LDBDIS LDBSTOP BURST CLKI TCCLKS
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
23 22 21 20 19 18 17 16
ASWTRG AEEVT ACPC ACPA
15 14 13 12 11 10 9 8
WAVE WAVSEL ENETRG EEVT EEVTEDG
7 6 5 4 3 2 1 0
CPCDIS CPCSTOP BURST CLKI TCCLKS
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
DOWN GCEN
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
23 22 21 20 19 18 17 16
CV
15 14 13 12 11 10 9 8
CV
7 6 5 4 3 2 1 0
CV
23 22 21 20 19 18 17 16
RA
15 14 13 12 11 10 9 8
RA
7 6 5 4 3 2 1 0
RA
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
RA: Register A
RA contains the Register A value in real time.
IMPORTANT: For 16-bit channels, RA field size is limited to register bits 15:0.
23 22 21 20 19 18 17 16
RB
15 14 13 12 11 10 9 8
RB
7 6 5 4 3 2 1 0
RB
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
RB: Register B
RB contains the Register B value in real time.
IMPORTANT: For 16-bit channels, RB field size is limited to register bits 15:0.
23 22 21 20 19 18 17 16
RC
15 14 13 12 11 10 9 8
RC
7 6 5 4 3 2 1 0
RC
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
RC: Register C
RC contains the Register C value in real time.
IMPORTANT: For 16-bit channels, RC field size is limited to register bits 15:0.
23 22 21 20 19 18 17 16
MTIOB MTIOA CLKSTA
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
CPAS: RA Compare
0: No effect.
1: Enables the RA Compare Interrupt.
CPBS: RB Compare
0: No effect.
1: Enables the RB Compare Interrupt.
CPCS: RC Compare
0: No effect.
1: Enables the RC Compare Interrupt.
LDRAS: RA Loading
0: No effect.
1: Enables the RA Load Interrupt.
LDRBS: RB Loading
0: No effect.
1: Enables the RB Load Interrupt.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
CPAS: RA Compare
0: No effect.
1: Disables the RA Compare Interrupt (if TC_CMRx.WAVE = 1).
CPBS: RB Compare
0: No effect.
1: Disables the RB Compare Interrupt (if TC_CMRx.WAVE = 1).
CPCS: RC Compare
0: No effect.
1: Disables the RC Compare Interrupt.
LDRAS: RA Loading
0: No effect.
1: Disables the RA Load Interrupt (if TC_CMRx.WAVE = 0).
LDRBS: RB Loading
0: No effect.
1: Disables the RB Load Interrupt (if TC_CMRx.WAVE = 0).
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
ETRGS LDRBS LDRAS CPCS CPBS CPAS LOVRS COVFS
CPAS: RA Compare
0: The RA Compare Interrupt is disabled.
1: The RA Compare Interrupt is enabled.
CPBS: RB Compare
0: The RB Compare Interrupt is disabled.
1: The RB Compare Interrupt is enabled.
CPCS: RC Compare
0: The RC Compare Interrupt is disabled.
1: The RC Compare Interrupt is enabled.
LDRAS: RA Loading
0: The Load RA Interrupt is disabled.
1: The Load RA Interrupt is enabled.
LDRBS: RB Loading
0: The Load RB Interrupt is disabled.
1: The Load RB Interrupt is enabled.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SYNC
23 22 21 20 19 18 17 16
MAXFILT IDXPHB SWAP
15 14 13 12 11 10 9 8
INVIDX INVB INVA EDGPHA QDTRANS SPEEDEN POSEN QDEN
7 6 5 4 3 2 1 0
TC2XC2S TC1XC1S TC0XC0S
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
QERR DIRCHG IDX
IDX: Index
0: No effect.
1: Enables the interrupt when a rising edge occurs on IDX input.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
QERR DIRCHG IDX
IDX: Index
0: No effect.
1: Disables the interrupt when a rising edge occurs on IDX input.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
QERR DIRCHG IDX
IDX: Index
0: The interrupt on IDX input is disabled.
1: The interrupt on IDX input is enabled.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
DIR
7 6 5 4 3 2 1 0
QERR DIRCHG IDX
IDX: Index
0: No Index input change since the last read of TC_QISR.
1: The IDX input has changed since the last read of TC_QISR.
DIR: Direction
Returns an image of the actual rotation direction.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
ENCF1 ENCF0
This register can only be written if the WPEN bit is cleared in the TC Write Protection Mode Register.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
38.1 Description
The High Speed Multimedia Card Interface (HSMCI) supports the MultiMedia Card (MMC) Specification V4.3, the
SD Memory Card Specification V2.0, the SDIO V2.0 specification and CE-ATA V1.1.
The HSMCI includes a command register, response registers, data registers, timeout counters and error detection
logic that automatically handle the transmission of commands and, when required, the reception of the associated
responses and data with a limited processor overhead.
The HSMCI supports stream, block and multi block data read and write, and is compatible with the Peripheral DMA
Controller (PDC) Channels, minimizing processor intervention for large buffer transfers.
The HSMCI operates at a rate of up to Master Clock divided by 2 and supports the interfacing of 1 slot(s). Each
slot may be used to interface with a High Speed MultiMedia Card bus (up to 30 Cards) or with an SD Memory
Card. A bit field in the SD Card Register performs this selection.
The SD Memory Card communication is based on a 9-pin interface (clock, command, four data and three power
lines) and the High Speed MultiMedia Card on a 7-pin interface (clock, command, one data, three power lines and
one reserved for future use).
The SD Memory Card interface also supports High Speed MultiMedia Card operations. The main differences
between SD and High Speed MultiMedia Cards are the initialization process and the bus topology.
HSMCI fully supports CE-ATA Revision 1.1, built on the MMC System Specification v4.0. The module includes
dedicated hardware to issue the command completion signal and capture the host command completion signal
disable.
APB Bridge
PDC
APB
MCCK(1)
MCCDA(1)
MCDA2(1)
MCDA3(1)
Interrupt Control
HSMCI Interrupt
Note: 1. When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA,
MCDAy to HSMCIx_DAy.
Application Layer
ex: File System, Audio, Security, etc.
Physical Layer
HSMCI Interface
1 2 3 4 5 6 7
1 2 3 4 5 6 78
9
9 10 11 1213 8
MMC SDCard
1 2 3 4 5 6 7
9 10 11 1213 8
MMC
HSMCI
MCDA0
MCCDA
MCCK
1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7
Note: When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA
MCDAy to HSMCIx_DAy.
1 2 3 4 56 78
9
SD CARD
The SD Memory Card bus includes the signals listed in Table 38-5.
MCDA0 - MCDA3
MCCK SD CARD
MCCDA
9
Note: When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA
MCDAy to HSMCIx_DAy.
When the HSMCI is configured to operate with SD memory cards, the width of the data bus can be selected in the
HSMCI_SDCR. Clearing the SDCBUS bit in this register means that the width is one bit; setting it means that the
width is four bits. In the case of High Speed MultiMedia cards, only the data line 0 is used. The other data lines can
be used as independent PIOs.
High Impedance
Host Command NID Cycles Response State
CID
CMD S T Content CRC E Z ****** Z S T Z Z Z
Content
Read HSMCI_SR
RETURN ERROR(1)
RETURN OK
Read HSMCI_SR
0
NOTBUSY
RETURN OK
Note: If the command is SEND_OP_COND, the CRC error flag is always present (refer to R3 response in the High Speed
MultiMedia Card specification).
Send SELECT/DESELECT_CARD
command(1) to select the card
No Yes
Read with PDC
Yes
Number of words to read = 0 ?
Read status register HSMCI_SR
No
No
RETURN
Read data = HSMCI_RDR
RETURN
Note: 1. It is assumed that this command has been correctly sent (see Figure 38-7).
Send SELECT/DESELECT_CARD
command(1) to select the card
No Yes
Write using PDC
HSMCI_PTCR = TXTEN
Yes
Number of words to write = 0 ?
No
No
RETURN
Note: 1. It is assumed that this command has been correctly sent (see Figure 38-7).
The flowchart in Figure 38-10 shows how to manage a multiple write block transfer with the PDC. Polling or
interrupt method can be used to wait for the end of write according to the contents of the HSMCI_IMR.
Send SELECT/DESELECT_CARD
command(1) to select the card
Send WRITE_MULTIPLE_BLOCK
command(1)
HSMCI_PTCR = TXTEN
No
Send STOP_TRANSMISSION
command(1)
No
RETURN
Note: 1. It is assumed that this command has been correctly sent (see Figure 38-7).
38.12.1 Definition
The XFRDONE flag in the HSMCI_SR indicates exactly when the read or write sequence is finished.
The CMDRDY flag is released 8 tbit after the end of the card response.
CMDRDY flag
Data
XFRDONE flag
CMDRDY flag The CMDRDY flag is released 8 tbit after the end of the card response.
XFRDONE flag
Notes: 1. The Response Register can be read by N accesses at the same HSMCI_RSPR or at consecutive addresses (0x20 to
0x2C). N depends on the size of the response.
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 PWSDIS PWSEN MCIDIS MCIEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PDCMODE PADV FBYTE WRPROOF RDPROOF PWSDIV
7 6 5 4 3 2 1 0
CLKDIV
This register can only be written if the WPEN bit is cleared in the HSMCI Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
DTOMUL DTOCYC
This register can only be written if the WPEN bit is cleared in the HSMCI Write Protection Mode Register.
If the data time-out set by DTOCYC and DTOMUL has been exceeded, the Data Time-out Error flag (DTOE) in the HSMCI
Status Register (HSMCI_SR) rises.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SDCBUS SDCSEL
This register can only be written if the WPEN bit is cleared in the HSMCI Write Protection Mode Register.
23 22 21 20 19 18 17 16
ARG
15 14 13 12 11 10 9 8
ARG
7 6 5 4 3 2 1 0
ARG
23 22 21 20 19 18 17 16
TRTYP TRDIR TRCMD
15 14 13 12 11 10 9 8
MAXLAT OPDCMD SPCMD
7 6 5 4 3 2 1 0
RSPTYP CMDNB
This register is write-protected while CMDRDY is 0 in HSMCI_SR. If an Interrupt command is sent, this register is only writ-
able by an interrupt response (field SPCMD). This means that the current command execution cannot be interrupted or
modified.
23 22 21 20 19 18 17 16
BLKLEN
15 14 13 12 11 10 9 8
BCNT
7 6 5 4 3 2 1 0
BCNT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CSTOMUL CSTOCYC
This register can only be written if the WPEN bit is cleared in the HSMCI Write Protection Mode Register.
If the data time-out set by CSTOCYC and CSTOMUL has been exceeded, the Completion Signal Time-out Error flag
(CSTOE) in the HSMCI Status Register (HSMCI_SR) rises.
23 22 21 20 19 18 17 16
RSP
15 14 13 12 11 10 9 8
RSP
7 6 5 4 3 2 1 0
RSP
RSP: Response
Note: 1. The response register can be read by N accesses at the same HSMCI_RSPR or at consecutive addresses (0x20 to 0x2C).
N depends on the size of the response.
23 22 21 20 19 18 17 16
DATA
15 14 13 12 11 10 9 8
DATA
7 6 5 4 3 2 1 0
DATA
23 22 21 20 19 18 17 16
DATA
15 14 13 12 11 10 9 8
DATA
7 6 5 4 3 2 1 0
DATA
23 22 21 20 19 18 17 16
CSTOE DTOE DCRCE RTOE RENDE RCRCE RDIRE RINDE
15 14 13 12 11 10 9 8
TXBUFE RXBUFF CSRCV SDIOWAIT SDIOIRQA
7 6 5 4 3 2 1 0
ENDTX ENDRX NOTBUSY DTIP BLKE TXRDY RXRDY CMDRDY
UNRE: Underrun (if FERRCTRL = 1, cleared by writing in HSMCI_CMDR or cleared on read if FERRCTRL = 0)
0: No error.
1: At least one 8-bit data has been sent without valid information (not written).
If FERRCTRL = 1 in HSMCI_CFG, OVRE is cleared on read.
If FERRCTRL = 0 in HSMCI_CFG, OVRE is cleared by writing HSMCI_CMDR.
23 22 21 20 19 18 17 16
CSTOE DTOE DCRCE RTOE RENDE RCRCE RDIRE RINDE
15 14 13 12 11 10 9 8
TXBUFE RXBUFF CSRCV SDIOWAIT SDIOIRQA
7 6 5 4 3 2 1 0
ENDTX ENDRX NOTBUSY DTIP BLKE TXRDY RXRDY CMDRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
CSTOE DTOE DCRCE RTOE RENDE RCRCE RDIRE RINDE
15 14 13 12 11 10 9 8
TXBUFE RXBUFF CSRCV SDIOWAIT SDIOIRQA
7 6 5 4 3 2 1 0
ENDTX ENDRX NOTBUSY DTIP BLKE TXRDY RXRDY CMDRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
CSTOE DTOE DCRCE RTOE RENDE RCRCE RDIRE RINDE
15 14 13 12 11 10 9 8
TXBUFE RXBUFF CSRCV SDIOWAIT SDIOIRQA
7 6 5 4 3 2 1 0
ENDTX ENDRX NOTBUSY DTIP BLKE TXRDY RXRDY CMDRDY
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is not enabled.
1: The corresponding interrupt is enabled.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
LSYNC HSMODE
7 6 5 4 3 2 1 0
FERRCTRL FIFOMODE
This register can only be written if the WPEN bit is cleared in the HSMCI Write Protection Mode Register.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
23 22 21 20 19 18 17 16
DATA
15 14 13 12 11 10 9 8
DATA
7 6 5 4 3 2 1 0
DATA
39.1 Description
The Pulse Width Modulation Controller (PWM) generates output pulses on 4 channels independently according to
parameters defined per channel. Each channel controls two complementary square output waveforms.
Characteristics of the output waveforms such as period, duty-cycle, polarity and dead-times (also called dead-
bands or non-overlapping times) are configured through the user interface. Each channel selects and uses one of
the clocks provided by the clock generator. The clock generator provides several clocks resulting from the division
of the PWM peripheral clock.
All accesses to the PWM are made through registers mapped on the peripheral bus. All channels integrate a
double buffering system in order to prevent an unexpected output waveform while modifying the period, the duty-
cycle or the dead-times.
Channels can be linked together as synchronous channels to be able to update their duty-cycle or dead-times at
the same time.
The update of duty-cycles of synchronous channels can be performed by the Peripheral DMA Controller channel
which offers buffer transfer without processor Intervention.
The PWM provides 8 independent comparison units capable of comparing a programmed value to the counter of
the synchronous channels (counter of channel 0). These comparisons are intended to generate software
interrupts, to trigger pulses on the 2 independent event lines (in order to synchronize ADC conversions with a lot of
flexibility independently of the PWM outputs) and to trigger Peripheral DMA Controllertransfer requests.
PWM outputs can be overridden synchronously or asynchronously to their channel counter.
The PWM provides a fault protection mechanism with 8 fault inputs, capable to detect a fault condition and to
override the PWM outputs asynchronously (outputs forced to 0, 1).
For safety usage, some configuration registers are write-protected.
Channel x
Update
Period
DTOHx OOOHx PWMHx
PWMHx
Comparator OCx Dead-Time Output Fault
Generator DTOLx Override OOOLx Protection PWMLx PWMLx
Duty-Cycle
SYNCx
MUX
Clock Counter
Selector Channel x
PIO
Channel 0
Update
Period
DTOH0 OOOH0 PWMH0
OC0 Dead-Time Output Fault PWMH0
Comparator
Generator DTOL0 Override OOOL0 Protection PWML0
PWML0
Duty-Cycle
Clock Counter
Selector Channel 0
PWMFIx
PIO
PWMFI0 event line 0
event line 1
Comparison Events
Units Generator ADC
event line x
Peripheral Clock CLOCK
PMC
Generator APB
Interface
Interrupt
Interrupt Generator
Controller
APB
peripheral clock
peripheral clock/2
peripheral clock/4
peripheral clock/8
peripheral clock/16
peripheral clock/32
peripheral clock/64
peripheral clock/128
peripheral clock/256
peripheral clock/512
peripheral clock/1024
Divider A clkA
PREA DIVA
PWM_MR
Divider B clkB
PREB DIVB
PWM_MR
The PWM peripheral clock is divided in the clock generator module to provide different clocks available for all
channels. Each channel can independently select one of the divided clocks.
The clock generator is divided into different blocks:
a modulo n counter which provides 11 clocks: fperipheral clock, fperipheral clock/2, fperipheral clock/4, fperipheral
clock/8, fperipheral clock/16, fperipheral clock/32, fperipheral clock/64, fperipheral clock/128, fperipheral clock/256, fperipheral
clock/512, fperipheral clock/1024
two linear dividers (1, 1/2, 1/3, ... 1/255) that provide two separate clocks: clkA and clkB
Each linear divider can independently divide one of the clocks of the modulo n counter. The selection of the clock
to be divided is made according to the PREA (PREB) field of the PWM Clock register (PWM_CLK). The resulting
clock clkA (clkB) is the clock selected divided by DIVA (DIVB) field value.
CAUTION:
Before using the PWM controller, the programmer must first enable the peripheral clock in the Power Management
Controller (PMC).
Update Channel x
Period
DTOHx OOOHx PWMHx
Comparator Dead-Time Output Fault
MUX
OCx
x Generator DTOLx Override OOOLx Protection PWMLx
Duty-Cycle
SYNCx
MUX
from
Clock Counter
Clock
Selector Channel x
Generator
from APB
Peripheral Bus
Counter
Channel 0 Channel y (= x+1)
DTOHy OOOHy PWMHy
OCy Dead-Time Output Fault
MUX
By using the PWM peripheral clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
( X C RPD DIVA -)
--------------------------------------------------- or
f peripheral clock
( X C RPD DIVB -)
---------------------------------------------------
f peripheral clock
If the waveform is center-aligned then the output waveform period depends on the counter source clock and
can be calculated:
By using the PWM peripheral clock divided by an X given prescaler value
(with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will be:
(----------------------------------------
2 X CPRD )
f peripheral clock
By using the PWM peripheral clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
( 2 X C PRD DIVA )
------------------------------------------------------------- or
f peripheral clock
( 2 X C PRD DIVB )
-------------------------------------------------------------
f peripheral clock
the waveform duty-cycle. This channel parameter is defined in the CDTY field of the PWM_CDTYx
register.
If the waveform is left-aligned then:
the waveform polarity. At the beginning of the period, the signal can be at high or low level. This property is
defined in the CPOL bit of the PWM_CMRx. By default the signal starts by a low level. the waveform
OC0
OC1
Period
When center-aligned, the channel counter increases up to CPRD and decreases down to 0. This ends the period.
When left-aligned, the channel counter increases up to CPRD and is reset. This ends the period.
Thus, for the same CPRD value, the period for a center-aligned channel is twice the period for a left-aligned
channel.
Waveforms are fixed at 0 when:
CDTY = CPRD and CPOL = 0
CDTY = 0 and CPOL = 1
Waveforms are fixed at 1 (once the channel is enabled) when:
CDTY = 0 and CPOL = 0
CDTY = CPRD and CPOL = 1
The waveform polarity must be set before enabling the channel. This immediately affects the channel output level.
Modifying CPOL in PWM Channel Mode Register while the channel is enabled can lead to an unexpected
behavior of the device being driven by PWM.
In addition to generating the output signals OCx, the comparator generates interrupts depending on the counter
value. When the output waveform is left-aligned, the interrupt occurs at the end of the counter period. When the
output waveform is center-aligned, the bit CES of PWM_CMRx defines when the channel counter interrupt occurs.
If CES is set to 0, the interrupt occurs at the end of the counter period. If CES is set to 1, the interrupt occurs at
the end of the counter period and at half of the counter period.
Figure 39-5 illustrates the counter interrupts depending on the configuration.
Channel x
slected clock
CHIDx(PWM_SR)
CHIDx(PWM_ENA)
CHIDx(PWM_DIS)
Center Aligned
CALG(PWM_CMRx) = 1
PWM_CCNTx
CPRD(PWM_CPRDx)
CDTY(PWM_CDTYx)
Period
Counter Event
CHIDx(PWM_ISR)
CES(PWM_CMRx) = 0
Counter Event
CHIDx(PWM_ISR)
CES(PWM_CMRx) = 1
Left Aligned
CALG(PWM_CMRx) = 0
PWM_CCNTx
CPRD(PWM_CPRDx)
CDTY(PWM_CDTYx)
Period
Counter Event
CHIDx(PWM_ISR)
PWMH0
PWML0
PWMH1
PWML1
DOWNx
DTHx DTLx
DTHx DTLx
OSHx
DTOLx
0
OOOLx
OOVLx
1
OSLx
The fields OSHx and OSLx in the PWM Output Selection Register (PWM_OS) allow the outputs of the dead-time
generator DTOHx and DTOLx to be overridden by the value defined in the fields OOVHx and OOVLx in the PWM
Output Override Value Register (PWM_OOV).
The set registers PWM Output Selection Set Register (PWM_OSS) and PWM Output Selection Set Update
Register (PWM_OSSUPD) enable the override of the outputs of a channel regardless of other channels. In the
same way, the clear registers PWM Output Selection Clear Register (PWM_OSC) and PWM Output Selection
Clear Update Register (PWM_OSCUPD) disable the override of the outputs of a channel regardless of other
channels.
By using buffer registers PWM_OSSUPD and PWM_OSCUPD, the output selection of PWM outputs is done
synchronously to the channel counter, at the beginning of the next PWM period.
By using registers PWM_OSS and PWM_OSC, the output selection of PWM outputs is done asynchronously to
the channel counter, as soon as the register is written.
The value of the current output selection can be read in PWM_OS.
While overriding PWM outputs, the channel counters continue to run, only the PWM outputs are forced to user
defined values.
0 0 Fault 0 Status
FIV0
fault input 0 Glitch
1
= FMOD0 SET
FS0
from fault 0
Filter OUT 1
CLR FPEx[0]
0
FPE0[0]
Write FCLR0 at 1 1
FFIL0 FPOL0 FMOD0
From Output
Override
0 0 Fault 1 Status SYNCx OOHx 0
FIV1
fault input 1
Glitch
1
= SET
FS1
from fault 1 FPVHx 1
PWMHx
Filter FMOD1 OUT 1
FPEx[1]
CLR 0
Fault protection
FPE0[1]
1 on PWM
FFIL1 FPOL1 Write FCLR1 at 1 FMOD1 channel x
from fault y
SYNCx
fault input y
FPVLx 1
PWMLx
OOLx 0
From Output
Override
The polarity level of the fault inputs is configured by the FPOL field in the PWM Fault Mode Register (PWM_FMR).
For fault inputs coming from internal peripherals such as ADC or Timer Counter, the polarity level must be FPOL =
1. For fault inputs coming from external GPIO pins the polarity level depends on the user's implementation.
The configuration of the Fault Activation mode (FMOD field in PWMC_FMR) depends on the peripheral generating
the fault. If the corresponding peripheral does not have Fault Clear management, then the FMOD configuration to
use must be FMOD = 1, to avoid spurious fault detection. Refer to the corresponding peripheral documentation for
details on handling fault generation.
Fault inputs may or may not be glitch-filtered depending on the FFIL field in the PWM_FMR. When the filter is
activated, glitches on fault inputs with a width inferior to the PWM peripheral clock period are rejected.
A fault becomes active as soon as its corresponding fault input has a transition to the programmed polarity level. If
the corresponding bit FMOD is set to 0 in the PWM_FMR, the fault remains active as long as the fault input is at
this polarity level. If the corresponding FMOD field is set to 1, the fault remains active until the fault input is no
longer at this polarity level and until it is cleared by writing the corresponding bit FCLR in the PWM Fault Clear
Register (PWM_FCR). In the PWM Fault Status Register (PWM_FSR), the field FIV indicates the current level of
the fault inputs and the field FIS indicates whether a fault is currently active.
Each fault can be taken into account or not by the fault protection mechanism in each channel. To be taken into
account in the channel x, the fault y must be enabled by the bit FPEx[y] in the PWM Fault Protection Enable
registers (PWM_FPE1). However, synchronous channels (see Section 39.6.2.7 Synchronous Channels) do not
use their own fault enable bits, but those of the channel 0 (bits FPE0[y]).
The fault protection on a channel is triggered when this channel is enabled and when any one of the faults that are
enabled for this channel is active. It can be triggered even if the PWM peripheral clock is not running but only by a
fault input that is not glitch-filtered.
When the fault protection is triggered on a channel, the fault protection mechanism resets the counter of this
channel and forces the channel outputs to the values defined by the fields FPVHx and FPVLx in the PWM Fault
Protection Value Register (PWM_FPV) . The output forcing is made asynchronously to the channel counter.
CAUTION:
To prevent any unexpected activation of the status flag FSy in the PWM_FSR, the FMODy bit can be set to
1 only if the FPOLy bit has been previously configured to its final value.
Method 1: Manual write of duty-cycle values and manual trigger of the update
In this mode, the update of the period value, the duty-cycle values and the dead-time values must be done by
writing in their respective update registers with the processor (respectively PWM_CPRDUPDx, PWM_CDTYUPDx
and PWM_DTUPDx).
To trigger the update, the user must use the bit UPDULOCK in the PWM_SCUC register which allows to update
synchronously (at the same PWM period) the synchronous channels:
If the bit UPDULOCK is set to 1, the update is done at the next PWM period of the synchronous channels.
If the UPDULOCK bit is not set to 1, the update is locked and cannot be performed.
After writing the UPDULOCK bit to 1, it is held at this value until the update occurs, then it is read 0.
Sequence for Method 1:
1. Select the manual write of duty-cycle values and the manual update by setting the UPDM field to 0 in the
PWM_SCM register
2. Define the synchronous channels by the SYNCx bits in the PWM_SCM register.
3. Enable the synchronous channels by writing CHID0 in the PWM_ENA register.
4. If an update of the period value and/or the duty-cycle values and/or the dead-time values is required, write
registers that need to be updated (PWM_CPRDUPDx, PWM_CDTYUPDx and PWM_DTUPDx).
5. Set UPDULOCK to 1 in PWM_SCUC.
6. The update of the registers will occur at the beginning of the next PWM period. When the UPDULOCK bit is
reset, go to Step 4. for new values.
UPDULOCK
Method 2: Manual write of duty-cycle values and automatic trigger of the update
In this mode, the update of the period value, the duty-cycle values, the dead-time values and the update period
value must be done by writing in their respective update registers with the processor (respectively
PWM_CPRDUPDx, PWM_CDTYUPDx, PWM_DTUPDx and PWM_SCUPUPD).
To trigger the update of the period value and the dead-time values, the user must use the bit UPDULOCK in the
PWM_SCUC register, which updates synchronously (at the same PWM period) the synchronous channels:
If the bit UPDULOCK is set to 1, the update is done at the next PWM period of the synchronous channels.
If the UPDULOCK bit is not set to 1, the update is locked and cannot be performed.
After writing the UPDULOCK bit to 1, it is held at this value until the update occurs, then it is read 0.
The update of the duty-cycle values and the update period is triggered automatically after an update period.
To configure the automatic update, the user must define a value for the update period by the UPR field in the
PWM_SCUP register. The PWM controller waits UPR+1 period of synchronous channels before updating
automatically the duty values and the update period value.
The status of the duty-cycle value write is reported in the PWM Interrupt Status Register 2 (PWM_ISR2) by the
following flags:
WRDY: this flag is set to 1 when the PWM Controller is ready to receive new duty-cycle values and a new
update period value. It is reset to 0 when the PWM_ISR2 register is read.
Depending on the interrupt mask in the PWM Interrupt Mask Register 2 (PWM_IMR2), an interrupt can be
generated by these flags.
Sequence for Method 2:
1. Select the manual write of duty-cycle values and the automatic update by setting the field UPDM to 1 in
the PWM_SCM register
2. Define the synchronous channels by the bits SYNCx in the PWM_SCM register.
3. Define the update period by the field UPR in the PWM_SCUP register.
4. Enable the synchronous channels by writing CHID0 in the PWM_ENA register.
5. If an update of the period value and/or of the dead-time values is required, write registers that need to be
updated (PWM_CPRDUPDx, PWM_DTUPDx), else go to Step 8.
6. Set UPDULOCK to 1 in PWM_SCUC.
7. The update of these registers will occur at the beginning of the next PWM period. At this moment the bit
UPDULOCK is reset, go to Step 5. for new values.
8. If an update of the duty-cycle values and/or the update period is required, check first that write of new update
values is possible by polling the flag WRDY (or by waiting for the corresponding interrupt) in the PWM_ISR2.
9. Write registers that need to be updated (PWM_CDTYUPDx, PWM_SCUPUPD).
UPRCNT 0x0 0x1 0x0 0x1 0x0 0x1 0x0 0x1 0x2 0x3 0x0 0x1 0x2
WRDY
Method 3: Automatic write of duty-cycle values and automatic trigger of the update
In this mode, the update of the duty cycle values is made automatically by the Peripheral DMA Controller. The
update of the period value, the dead-time values and the update period value must be done by writing in their
respective update registers with the processor (respectively PWM_CPRDUPDx, PWM_DTUPDx and
PWM_SCUPUPD).
To trigger the update of the period value and the dead-time values, the user must use the bit UPDULOCK which
allows to update synchronously (at the same PWM period) the synchronous channels:
If the bit UPDULOCK is set to 1, the update is done at the next PWM period of the synchronous channels.
If the UPDULOCK bit is not set to 1, the update is locked and cannot be performed.
After writing the UPDULOCK bit to 1, it is held at this value until the update occurs, then it is read 0.
The update of the duty-cycle values and the update period value is triggered automatically after an update period.
To configure the automatic update, the user must define a value for the Update Period by the field UPR in the
PWM_SCUP register. The PWM controller waits UPR+1 periods of synchronous channels before updating
automatically the duty values and the update period value.
Using the Peripheral DMA Controller removes processor overhead by reducing its intervention during the transfer.
This significantly reduces the number of clock cycles required for a data transfer, which improves microcontroller
performance.
The Peripheral DMA Controller must write the duty-cycle values in the synchronous channels index order. For
example if the channels 0, 1 and 3 are synchronous channels, the Peripheral DMA Controller must write the duty-
cycle of the channel 0 first, then the duty-cycle of the channel 1, and finally the duty-cycle of the channel 3.
The status of the Peripheral DMA Controller transfer is reported in the PWM_ISR2 by the following flags:
WRDY: this flag is set to 1 when the PWM Controller is ready to receive new duty-cycle values and a new
update period value. It is reset to 0 when the PWM_ISR2 is read. The user can choose to synchronize the
WRDY flag and the Peripheral DMA Controller transfer request with a comparison match (see Section
39.6.3 PWM Comparison Units), by the fields PTRM and PTRCS in the PWM_SCM register.
ENDTX : this flag is set to 1 when a PDC transfer is completed
TXBUFE : this flag is set to 1 when the PDC buffer is empty (no pending PDC transfers)
UPRCNT 0x0 0x1 0x0 0x1 0x0 0x1 0x0 0x1 0x2 0x3 0x0 0x1 0x2
transfer request
WRDY
UPRCNT 0x0 0x1 0x0 0x1 0x0 0x1 0x0 0x1 0x2 0x3 0x0 0x1 0x2
CMP0 match
transfer request
WRDY
fault on channel 0
CV [PWM_CMPVx]
1 0
CNT [PWM_CCNT0] is decrementing
= 1
CVM [PWM_CMPVx]
CALG [PWM_CMR0]
CPRCNT [PWM_CMPMx]
CTR [PWM_CMPMx]
=
The comparison x matches when it is enabled by the bit CEN in the PWM Comparison x Mode Register
(PWM_CMPMx for the comparison x) and when the counter of the channel 0 reaches the comparison value
defined by the field CV in PWM Comparison x Value Register (PWM_CMPVx for the comparison x). If the counter
CVMVUPD
CVM
CUPRCNT 0x0 0x1 0x2 0x3 0x0 0x1 0x2 0x0 0x1 0x2 0x0 0x1
CPRCNT 0x0 0x1 0x0 0x1 0x0 0x1 0x2 0x3 0x0 0x1 0x2 0x3
Comparison Update
CMPU
Comparison Match
CMPM
CMPM1 (PWM_ISR2)
CSEL1 (PWM_ELMRx)
CMPM2 (PWM_ISR2)
CSEL2 (PWM_ELMRx)
PULSE Event Line x
GENERATOR
CMPM7 (PWM_ISR2)
CSEL7 (PWM_ELMRx)
CDTY(PWM_CDTY1)
CDTY(PWM_CDTY0)
CV (PWM_CMPV0)
Waveform OC0
Waveform OC1
Waveform OC2
Comparison
Unit 0 Output
PWM_CMPM0.CEN = 1
Comparison
Unit 1 Output
PWM_CMPM0.CEN = 1
Event Line 0
(trigger event for ADC)
PWM_ELMR0.CSEL0 = 1 configurable delay
PWM_ELMR0.CSEL1 = 1 PWM_CMPV0.CV configurable delay
PWM_CMPV1.CV
39.6.5.1 Initialization
Before enabling the channels, they must be configured by the software application as described below:
Unlock User Interface by writing the WPCMD field in the PWM_WPCR.
Configuration of the clock generator (DIVA, PREA, DIVB, PREB in the PWM_CLK register if required).
Selection of the clock for each channel (CPRE field in PWM_CMRx)
Configuration of the waveform alignment for each channel (CALG field in PWM_CMRx)
Selection of the counter event selection (if CALG = 1) for each channel (CES field in PWM_CMRx)
Configuration of the output waveform polarity for each channel (CPOL bit in PWM_CMRx)
Note: If the update registers PWM_CDTYUPDx, PWM_CPRDUPDx and PWM_DTUPDx are written several times between
two updates, only the last written value is taken into account.
- If Asynchronous Channel
-> End of PWM period
- If Synchronous Channel
-> End of PWM period and UPDULOCK = 1
- If Asynchronous Channel
-> End of PWM period
- If Synchronous Channel
- If UPDM = 0
-> End of PWM period and UPDULOCK = 1
- If UPDM = 1 or 2
-> End of PWM period and end of Update Period
User's Writing
PWM_SCUPUPD Value
PWM_SCUP
PWM_CMPVx PWM_CMPMx
39.6.5.6 Interrupts
Depending on the interrupt mask in the PWM_IMR1 and PWM_IMR2, an interrupt can be generated at the end of
the corresponding channel period (CHIDx in the PWM Interrupt Status Register 1 (PWM_ISR1)), after a fault event
(FCHIDx in the PWM_ISR1), after a comparison match (CMPMx in the PWM_ISR2), after a comparison update
(CMPUx in the PWM_ISR2) or according to the Transfer mode of the synchronous channels (WRDY, ENDTX,
TXBUFE and UNRE in the PWM_ISR2).
If the interrupt is generated by the flags CHIDx or FCHIDx, the interrupt remains active until a read operation in the
PWM_ISR1 occurs.
If the interrupt is generated by the flags WRDY or UNRE or CMPMx or CMPUx, the interrupt remains active until a
read operation in the PWM_ISR2 occurs.
A channel interrupt is enabled by setting the corresponding bit in PWM_IER1 and PWM_IER2. A channel interrupt
is disabled by setting the corresponding bit in PWM_IDR1 and PWM_IDR2.
23 22 21 20 19 18 17 16
DIVB
15 14 13 12 11 10 9 8
PREA
7 6 5 4 3 2 1 0
DIVA
This register can only be written if bits WPSWS0 and WPHWS0 are cleared in the PWM Write Protection Status Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
CHIDx: Channel ID
0: No effect.
1: Enable PWM output for channel x.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
This register can only be written if bits WPSWS1 and WPHWS1 are cleared in the PWM Write Protection Status Register.
CHIDx: Channel ID
0: No effect.
1: Disable PWM output for channel x.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
CHIDx: Channel ID
0: PWM output for channel x is disabled.
1: PWM output for channel x is enabled.
23 22 21 20 19 18 17 16
FCHID3 FCHID2 FCHID1 FCHID0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
23 22 21 20 19 18 17 16
FCHID3 FCHID2 FCHID1 FCHID0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
23 22 21 20 19 18 17 16
FCHID3 FCHID2 FCHID1 FCHID0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
23 22 21 20 19 18 17 16
FCHID3 FCHID2 FCHID1 FCHID0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CHID3 CHID2 CHID1 CHID0
23 22 21 20 19 18 17 16
PTRCS PTRM UPDM
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SYNC3 SYNC2 SYNC1 SYNC0
This register can only be written if bits WPSWS2 and WPHWS2 are cleared in the PWM Write Protection Status Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
UPDULOCK
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
UPRCNT UPR
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
UPRUPD
This register acts as a double buffer for the UPR value. This prevents an unexpected automatic trigger of the update of
synchronous channels.
23 22 21 20 19 18 17 16
CMPU7 CMPU6 CMPU5 CMPU4 CMPU3 CMPU2 CMPU1 CMPU0
15 14 13 12 11 10 9 8
CMPM7 CMPM6 CMPM5 CMPM4 CMPM3 CMPM2 CMPM1 CMPM0
7 6 5 4 3 2 1 0
UNRE TXBUFE ENDTX WRDY
23 22 21 20 19 18 17 16
CMPU7 CMPU6 CMPU5 CMPU4 CMPU3 CMPU2 CMPU1 CMPU0
15 14 13 12 11 10 9 8
CMPM7 CMPM6 CMPM5 CMPM4 CMPM3 CMPM2 CMPM1 CMPM0
7 6 5 4 3 2 1 0
UNRE TXBUFE ENDTX WRDY
23 22 21 20 19 18 17 16
CMPU7 CMPU6 CMPU5 CMPU4 CMPU3 CMPU2 CMPU1 CMPU0
15 14 13 12 11 10 9 8
CMPM7 CMPM6 CMPM5 CMPM4 CMPM3 CMPM2 CMPM1 CMPM0
7 6 5 4 3 2 1 0
UNRE TXBUFE ENDTX WRDY
23 22 21 20 19 18 17 16
CMPU7 CMPU6 CMPU5 CMPU4 CMPU3 CMPU2 CMPU1 CMPU0
15 14 13 12 11 10 9 8
CMPM7 CMPM6 CMPM5 CMPM4 CMPM3 CMPM2 CMPM1 CMPM0
7 6 5 4 3 2 1 0
UNRE TXBUFE ENDTX WRDY
Note: Reading PWM_ISR2 automatically clears flags WRDY, UNRE and CMPSx.
23 22 21 20 19 18 17 16
OOVL3 OOVL2 OOVL1 OOVL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
OOVH3 OOVH2 OOVH1 OOVH0
23 22 21 20 19 18 17 16
OSL3 OSL2 OSL1 OSL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
OSH3 OSH2 OSH1 OSH0
23 22 21 20 19 18 17 16
OSSL3 OSSL2 OSSL1 OSSL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
OSSH3 OSSH2 OSSH1 OSSH0
23 22 21 20 19 18 17 16
OSCL3 OSCL2 OSCL1 OSCL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
OSCH3 OSCH2 OSCH1 OSCH0
23 22 21 20 19 18 17 16
OSSUPL3 OSSUPL2 OSSUPL1 OSSUPL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
OSSUPH3 OSSUPH2 OSSUPH1 OSSUPH0
23 22 21 20 19 18 17 16
OSCUPL3 OSCUPL2 OSCUPL1 OSCUPL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
OSCUPH3 OSCUPH2 OSCUPH1 OSCUPH0
23 22 21 20 19 18 17 16
FFIL
15 14 13 12 11 10 9 8
FMOD
7 6 5 4 3 2 1 0
FPOL
This register can only be written if bits WPSWS5 and WPHWS5 are cleared in the PWM Write Protection Status Register.
CAUTION: To prevent an unexpected activation of the status flag FSy in the PWM Fault Status Register, the bit FMODy
can be set to 1 only if the FPOLy bit has been previously configured to its final value.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FS
7 6 5 4 3 2 1 0
FIV
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FCLR
23 22 21 20 19 18 17 16
FPVL3 FPVL2 FPVL1 FPVL0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FPVH3 FPVH2 FPVH1 FPVH0
This register can only be written if bits WPSWS5 and WPHWS5 are cleared in the PWM Write Protection Status Register.
23 22 21 20 19 18 17 16
FPE2
15 14 13 12 11 10 9 8
FPE1
7 6 5 4 3 2 1 0
FPE0
This register can only be written if bits WPSWS5 and WPHWS5 are cleared in the PWM Write Protection Status Register.
Only the first 8 bits (number of fault input pins) of fields FPE0, FPE1, FPE2 and FPE3 are significant.
CAUTION: To prevent an unexpected activation of the fault protection, the bit y of FPEx field can be set to 1 only if the
corresponding FPOL field has been previously configured to its final value in PWM Fault Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CSEL7 CSEL6 CSEL5 CSEL4 CSEL3 CSEL2 CSEL1 CSEL0
23 22 21 20 19 18 17 16
DOWN1 DOWN0
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
GCEN1 GCEN0
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPRG5 WPRG4 WPRG3 WPRG2 WPRG1 WPRG0 WPCMD
See Section 39.6.6 Register Write Protection for the list of registers that can be write-protected.
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPHWS5 WPHWS4 WPHWS3 WPHWS2 WPHWS1 WPHWS0
7 6 5 4 3 2 1 0
WPVS WPSWS5 WPSWS4 WPSWS3 WPSWS2 WPSWS1 WPSWS0
23 22 21 20 19 18 17 16
CV
15 14 13 12 11 10 9 8
CV
7 6 5 4 3 2 1 0
CV
Only the first 16 bits (channel counter size) of field CV are significant.
23 22 21 20 19 18 17 16
CVUPD
15 14 13 12 11 10 9 8
CVUPD
7 6 5 4 3 2 1 0
CVUPD
This register acts as a double buffer for the CV and CVM values. This prevents an unexpected comparison x match.
Only the first 16 bits (channel counter size) of field CVUPD are significant.
CAUTION: The write of the register PWM_CMPVUPDx must be followed by a write of the register PWM_CMPMUPDx.
23 22 21 20 19 18 17 16
CUPRCNT CUPR
15 14 13 12 11 10 9 8
CPRCNT CPR
7 6 5 4 3 2 1 0
CTR CEN
23 22 21 20 19 18 17 16
CUPRUPD
15 14 13 12 11 10 9 8
CPRUPD
7 6 5 4 3 2 1 0
CTRUPD CENUPD
This register acts as a double buffer for the CEN, CTR, CPR and CUPR values. This prevents an unexpected comparison
x match.
23 22 21 20 19 18 17 16
DTLI DTHI DTE
15 14 13 12 11 10 9 8
CES CPOL CALG
7 6 5 4 3 2 1 0
CPRE
This register can only be written if bits WPSWS2 and WPHWS2 are cleared in the PWM Write Protection Status Register.
23 22 21 20 19 18 17 16
CDTY
15 14 13 12 11 10 9 8
CDTY
7 6 5 4 3 2 1 0
CDTY
23 22 21 20 19 18 17 16
CDTYUPD
15 14 13 12 11 10 9 8
CDTYUPD
7 6 5 4 3 2 1 0
CDTYUPD
This register acts as a double buffer for the CDTY value. This prevents an unexpected waveform when modifying the
waveform duty-cycle.
Only the first 16 bits (channel counter size) are significant.
23 22 21 20 19 18 17 16
CPRD
15 14 13 12 11 10 9 8
CPRD
7 6 5 4 3 2 1 0
CPRD
This register can only be written if bits WPSWS3 and WPHWS3 are cleared in the PWM Write Protection Status Register.
Only the first 16 bits (channel counter size) are significant.
( X CPRD )-
-------------------------------
f peripheral clock
By using the PWM peripheral clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
(-----------------------------------------
CRPD DIVA )- ( CRPD DIVB )
or ------------------------------------------
f peripheral clock f peripheral clock
If the waveform is center-aligned, then the output waveform period depends on the channel counter source clock and can
be calculated:
By using the PWM peripheral clock divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64,
128, 256, 512, or 1024). The resulting period formula will be:
(----------------------------------------
2 X CPRD )
f peripheral clock
By using the PWM peripheral clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
(---------------------------------------------------
2 CPRD DIVA ) ( 2 CPRD DIVB )
or ---------------------------------------------------
f peripheral clock f peripheral clock
23 22 21 20 19 18 17 16
CPRDUPD
15 14 13 12 11 10 9 8
CPRDUPD
7 6 5 4 3 2 1 0
CPRDUPD
This register can only be written if bits WPSWS3 and WPHWS3 are cleared in the PWM Write Protection Status Register.
This register acts as a double buffer for the CPRD value. This prevents an unexpected waveform when modifying the
waveform period.
Only the first 16 bits (channel counter size) are significant.
(--------------------------------------------
X CPRDUPD )
f peripheral clock
By using the PWM peripheral clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
(-------------------------------------------------------
CRPDUPD DIVA )- ( CRPDUPD DIVB )
or --------------------------------------------------------
f peripheral clock f peripheral clock
If the waveform is center-aligned, then the output waveform period depends on the channel counter source clock and can
be calculated:
By using the PWM peripheral clock divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64,
128, 256, 512, or 1024). The resulting period formula will be:
( 2 X CPRDUPD -)
-----------------------------------------------------
f peripheral clock
By using the PWM peripheral clock divided by one of both DIVA or DIVB divider, the formula becomes,
respectively:
23 22 21 20 19 18 17 16
CNT
15 14 13 12 11 10 9 8
CNT
7 6 5 4 3 2 1 0
CNT
23 22 21 20 19 18 17 16
DTL
15 14 13 12 11 10 9 8
DTH
7 6 5 4 3 2 1 0
DTH
This register can only be written if bits WPSWS4 and WPHWS4 are cleared in the PWM Write Protection Status Register.
Only the first 12 bits (dead-time counter size) of fields DTH and DTL are significant.
23 22 21 20 19 18 17 16
DTLUPD
15 14 13 12 11 10 9 8
DTHUPD
7 6 5 4 3 2 1 0
DTHUPD
This register can only be written if bits WPSWS4 and WPHWS4 are cleared in the PWM Write Protection Status Register.
This register acts as a double buffer for the DTH and DTL values. This prevents an unexpected waveform when modifying
the dead-time values.
Only the first 12 bits (dead-time counter size) of fields DTHUPD and DTLUPD are significant.
40.1 Description
The USB Device Port (UDP) is compliant with the Universal Serial Bus (USB) 2.0 full-speed device specification.
Each endpoint can be configured in one of several USB transfer types. It can be associated with one or two banks
of a dual-port RAM used to store the current data payload. If two banks are used, one DPR bank is read or written
by the processor, while the other is read or written by the USB device peripheral. This feature is mandatory for
isochronous endpoints. Thus the device maintains the maximum bandwidth (1 Mbyte/s) by working with endpoints
with two banks of DPR.
Atmel Bridge
USB Device
APB
to
MCU txoen
Bus eopn
MCK
Dual Serial DDP
txd
Wrapper
UDPCK Wrapper Port Interface Embedded
RAM Engine USB
rxdm DDM
Transceiver
FIFO SIE rxd
User 12 MHz
Interface rxdp
udp_int
(interrupt line)
Suspend/Resume Logic
Access to the UDP is via the APB bus interface. Read and write to the data FIFO are done by reading and writing
8-bit values to APB registers.
The UDP peripheral requires two clocks: one peripheral clock used by the Master Clock domain (MCK) and a 48
MHz clock (UDPCK) used by the 12 MHz domain.
A USB 2.0 full-speed pad is embedded and controlled by the Serial Interface Engine (SIE).
The signal external_resume is optional. It allows the UDP peripheral to wake up once in system mode. The host is
then notified that the device asks for a resume. This optional feature must also be negotiated with the host during
the enumeration.
40.4.3 Interrupt
The USB device interface has an interrupt line connected to the Interrupt Controller.
Handling the USB device interrupt requires programming the Interrupt Controller before configuring the UDP.
47 K
REXT
2 1
DDM
DDP
3 Type B 4
REXT
Connector
The Control Transfer endpoint EP0 is always used when a USB device is first configured (USB 2.0 specifications).
40.6.1.1 USB 2.0 Full-speed Transfer Types
A communication flow is carried over one of four transfer types defined by the USB device.
A status transaction is a special type of host-to-device transaction used only in a control transfer. The control
transfer must be performed using endpoints with no ping-pong attributes. According to the control sequence (read
or write), the USB device sends or receives a status transaction.
No Data Control
Setup TX Status IN TX
Notes: 1. During the Status IN stage, the host waits for a zero length packet (Data IN transaction with no data) from the
device using DATA1 PID. Refer to Chapter 8 of the Universal Serial Bus Specification, Rev. 2.0, for more
information on the protocol layer.
USB Setup PID Data Setup ACK Data OUT Data OUT NAK Data OUT Data OUT ACK
Bus Packets PID PID PID PID PID
Prevous Data IN TX Microcontroller Load Data in FIFO Data is Sent on USB Bus
USB Bus Packets Data IN Data IN 1 ACK Data IN NAK Data IN Data IN 2 ACK
PID PID PID PID PID PID
TXPKTRDY Flag
(UDP_CSRx)
Set by the firmware Set by the firmware Cleared by HW
Cleared by HW
Interrupt Pending Payload in FIFO Interrupt
TXCOMP Flag Pending
(UDP_CSRx)
Cleared by Firmware Cleared by
DPR access by the hardware Firmware
DPR access by the firmware
FIFO (DPR)
Content Data IN 1 Load In Progress Data IN 2
Write Read
1st Data Payload
Bank 0
Endpoint 1 Simultaneous
Write and Read
Data IN Packet
Bank 0
Endpoint 1 3rd Data Payload
When using a ping-pong endpoint, the following procedures are required to perform Data IN transactions:
1. The microcontroller checks if it is possible to write in the FIFO by polling TXPKTRDY to be cleared in the
endpoints UDP_CSRx.
2. The microcontroller writes the first data payload to be sent in the FIFO (Bank 0), writing zero or more byte
values in the endpoints UDP_FDRx.
3. The microcontroller notifies the USB peripheral it has finished writing in Bank 0 of the FIFO by setting the
TXPKTRDY in the endpoints UDP_CSRx.
4. Without waiting for TXPKTRDY to be cleared, the microcontroller writes the second data payload to be sent
in the FIFO (Bank 1), writing zero or more byte values in the endpoints UDP_FDRx.
5. The microcontroller is notified that the first Bank has been released by the USB device when TXCOMP in the
endpoints UDP_CSRx is set. An interrupt is pending while TXCOMP is being set.
6. Once the microcontroller has received TXCOMP for the first Bank, it notifies the USB device that it has
prepared the second Bank to be sent, raising TXPKTRDY in the endpoints UDP_CSRx.
7. At this step, Bank 0 is available and the microcontroller can prepare a third data payload to be sent.
TXPKTRDY Flag
(UDP_MCSRx) Cleared by USB Device,
Data Payload Fully Transmitted Set by Firmware,
Set by Firmware, Data Payload Written in FIFO Bank 1
Data Payload Written in FIFO Bank 0
Interrupt Pending
Set by USB
TXCOMP Flag Device Set by USB Device
(UDP_CSRx)
Interrupt Cleared by Firmware
FIFO (DPR)
Written by MCU Read by USB Device Written by MCU
Bank 0
FIFO (DPR)
Written by MCU Read by USB Device
Bank 1
Warning: There is software critical path due to the fact that once the second bank is filled, the driver has to wait for
TX_COMP to set TX_PKTRDY. If the delay between receiving TX_COMP is set and TX_PKTRDY is set too long,
some Data IN packets may be NACKed, reducing the bandwidth.
Warning: TX_COMP must be cleared after TX_PKTRDY has been set.
40.6.2.3 Data OUT Transaction
Data OUT transactions are used in control, isochronous, bulk and interrupt transfers and conduct the transfer of
data from the host to the device. Data OUT transactions in isochronous transfers must be done using endpoints
with ping-pong attributes.
Data OUT Transaction Without Ping-pong Attributes
To perform a Data OUT transaction, using a non ping-pong endpoint:
1. The host generates a Data OUT packet.
2. This packet is received by the USB device endpoint. While the FIFO associated to this endpoint is being
used by the microcontroller, a NAK PID is returned to the host. Once the FIFO is available, data are written
to the FIFO by the USB device and an ACK is automatically carried out to the host.
3. The microcontroller is notified that the USB device has received a data payload polling RX_DATA_BK0 in the
endpoints UDP_CSRx. An interrupt is pending for this endpoint while RX_DATA_BK0 is set.
4. The number of bytes available in the FIFO is made available by reading RXBYTECNT in the endpoints
UDP_CSRx.
5. The microcontroller carries out data received from the endpoints memory to its memory. Data received is
available by reading the endpoints UDP_FDRx.
6. The microcontroller notifies the USB device that it has finished the transfer by clearing RX_DATA_BK0 in the
endpoints UDP_CSRx.
7. A new Data OUT packet can be accepted by the USB device.
USB Bus Data OUT ACK Data OUT2 Data OUT2 NAK Data OUT Data OUT2 ACK
PID Data OUT 1 PID PID PID PID PID
Packets
FIFO (DPR)
Data OUT 1 Data OUT 1 Data OUT 2
Content
Written by USB Device Microcontroller Read Written by USB Device
An interrupt is pending while the flag RX_DATA_BK0 is set. Memory transfer between the USB device, the FIFO
and microcontroller memory is not possible after RX_DATA_BK0 has been cleared. Otherwise, the USB device
would accept the next Data OUT transfer and overwrite the current Data OUT packet in the FIFO.
Using Endpoints With Ping-pong Attributes
During isochronous transfer, using an endpoint with ping-pong attributes is obligatory. To be able to guarantee a
constant bandwidth, the microcontroller must read the previous data payload sent by the host, while the current
data payload is received by the USB device. Thus two banks of memory are used. While one is available for the
microcontroller, the other one is locked by the USB device.
Figure 40-10. Bank Swapping in Data OUT Transfers for Ping-pong Endpoints
Microcontroller USB Device USB Bus
Write Read
When using a ping-pong endpoint, the following procedures are required to perform Data OUT transactions:
1. The host generates a Data OUT packet.
2. This packet is received by the USB device endpoint. It is written in the endpoints FIFO Bank 0.
3. The USB device sends an ACK PID packet to the host. The host can immediately send a second Data OUT
packet. It is accepted by the device and copied to FIFO Bank 1.
4. The microcontroller is notified that the USB device has received a data payload, polling RX_DATA_BK0 in
the endpoints UDP_CSRx. An interrupt is pending for this endpoint while RX_DATA_BK0 is set.
USB Bus Data OUT ACK Data OUT ACK Data OUT
Packets PID Data OUT 1 PID PID Data OUT 2 PID PID Data OUT 3
A
FIFO (DPR)
Bank 0 Data OUT1 Data OUT 1 Data OUT 3
Write by USB Device Read By Microcontroller Write In Progress
FIFO (DPR)
Bank 1 Data OUT 2 Data OUT 2
Warning: When RX_DATA_BK0 and RX_DATA_BK1 are both set, there is no way to determine which one to
clear first. Thus the software must keep an internal counter to be sure to clear alternatively RX_DATA_BK0 then
RX_DATA_BK1. This situation may occur when the software application is busy elsewhere and the two banks are
filled by the USB host. Once the application comes back to the USB driver, the two flags are set.
Cleared by Firmware
FORCESTALL Set by Firmware
Interrupt Pending
Cleared by Firmware
STALLSENT
Set by
USB Device
Interrupt Pending
Attached
Hub Reset
Hub
or
Configured
Deconfigured
Bus Inactive
Powered Suspended
Bus Activity
Power
Interruption Reset
Bus Inactive
Suspended
Default
Bus Activity
Reset
Address
Assigned
Bus Inactive
Address Suspended
Bus Activity
Device Device
Deconfigured Configured
Bus Inactive
Configured
Suspended
Bus Activity
Movement from one state to another depends on the USB bus state or on standard requests sent through control
transactions via the default endpoint (endpoint 0).
After a period of bus inactivity, the USB device enters Suspend Mode. Accepting Suspend/Resume requests from
the USB host is mandatory. Constraints in Suspend Mode are very strict for bus-powered applications; devices
must not consume more than 2.5 mA on the USB bus.
While in Suspend Mode, the host may wake up a device by sending a resume signal (bus activity) or a USB device
may send a wakeup request to the host, e.g., waking up a PC by moving a USB mouse.
The wakeup feature is not mandatory for all devices and must be negotiated with the host.
40.6.3.1 Not Powered State
Self powered devices can detect 5V VBUS using a PIO as described in the typical connection section. When the
device is not connected to a host, device power consumption can be reduced by disabling MCK for the UDP,
disabling UDPCK and disabling the transceiver. DDP and DDM lines are pulled down by 330 K resistors.
23 22 21 20 19 18 17 16
FRM_OK FRM_ERR
15 14 13 12 11 10 9 8
FRM_NUM
7 6 5 4 3 2 1 0
FRM_NUM
FRM_OK: Frame OK
This bit is set at SOF_EOP when the SOF packet is received without any error.
This bit is reset upon receipt of SOF_PID (Packet Identification).
In the Interrupt Status Register, the SOF interrupt is updated upon receiving SOF_PID. This bit is set without waiting for
EOP.
Note: In the 8-bit Register Interface, FRM_OK is bit 4 of FRM_NUM_H and FRM_ERR is bit 3 of FRM_NUM_L.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
RMWUPE RSMINPR ESR CONFG FADDEN
This register is used to get and set the device state as specified in Chapter 9 of the USB Serial Bus Specification, Rev.2.0.
CONFG: Configured
Read:
0: Device is not in configured state
1: Device is in configured state
Write:
0: Sets device in a non configured state
1: Sets device in configured state
The device is set in configured state when it is in address state and receives a successful Set Configuration request. Refer
to Chapter 9 of the Universal Serial Bus Specification, Rev. 2.0 for more details.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FEN
7 6 5 4 3 2 1 0
FADD
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WAKEUP SOFINT EXTRSM RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP7INT EP6INT EP5INT EP4INT EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WAKEUP SOFINT EXTRSM RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP7INT EP6INT EP5INT EP4INT EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WAKEUP BIT12 SOFINT EXTRSM RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP7INT EP6INT EP5INT EP4INT EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WAKEUP ENDBUSRES SOFINT EXTRSM RXRSM RXSUSP
7 6 5 4 3 2 1 0
EP7INT EP6INT EP5INT EP4INT EP3INT EP2INT EP1INT EP0INT
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WAKEUP ENDBUSRES SOFINT EXTRSM RXRSM RXSUSP
7 6 5 4 3 2 1 0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
EP7 EP6 EP5 EP4 EP3 EP2 EP1 EP0
23 22 21 20 19 18 17 16
RXBYTECNT
15 14 13 12 11 10 9 8
EPEDS DTGLE EPTYPE
7 6 5 4 3 2 1 0
RX_DATA_
DIR RX_DATA_BK1 FORCESTALL TXPKTRDY STALLSENT RXSETUP TXCOMP
BK0
WARNING: Due to synchronization between MCK and UDPCK, the software application must wait for the end of the write
operation before executing another write by polling the bits which must be set/cleared.
As an example, to perform a control operation on the endpoint without modifying the status flags while accessing the con-
trol bits and fields of this register, the status flag bits must first be defined with the No effect value 1. Once the overall
UDP_CSR value is defined, the register can be written and then the synchronization wait procedure must be executed.
RX_DATA_BK1: Receive Data Bank 1 (only used by endpoints with ping-pong attributes)
This flag generates an interrupt while it is set to one.
Write (cleared by the firmware):
0: Notifies USB device that data have been read in the FIFOs Bank 1.
1: To leave the read value unchanged.
Read (Set by the USB peripheral):
0: No data packet has been received in the FIFOs Bank 1.
1: A data packet has been received, it has been stored in FIFOs Bank 1.
When the device firmware has polled this bit or has been interrupted by this signal, it must transfer data from the FIFO to
microcontroller memory. The number of bytes received is available in RXBYTECNT field. Bank 1 FIFO values are read
through UDP_FDRx. Once a transfer is done, the device firmware must release Bank 1 to the USB device by clearing
RX_DATA_BK1.
After setting or clearing this bit, a wait time of 3 UDPCK clock cycles and 3 peripheral clock cycles is required before
accessing DPR.
23 22 21 20 19 18 17 16
RXBYTECNT
15 14 13 12 11 10 9 8
EPEDS DTGLE EPTYPE
7 6 5 4 3 2 1 0
RX_DATA_
DIR RX_DATA_BK1 FORCESTALL TXPKTRDY ISOERROR RXSETUP TXCOMP
BK0
RX_DATA_BK1: Receive Data Bank 1 (only used by endpoints with ping-pong attributes)
This flag generates an interrupt while it is set to one.
Write (cleared by the firmware):
0: Notifies USB device that data have been read in the FIFOs Bank 1.
1: To leave the read value unchanged.
Read (set by the USB peripheral):
0: No data packet has been received in the FIFOs Bank 1.
1: A data packet has been received, it has been stored in FIFOs Bank 1.
When the device firmware has polled this bit or has been interrupted by this signal, it must transfer data from the FIFO to
microcontroller memory. The number of bytes received is available in RXBYTECNT field. Bank 1 FIFO values are read
through UDP_FDRx. Once a transfer is done, the device firmware must release Bank 1 to the USB device by clearing
RX_DATA_BK1.
After setting or clearing this bit, a wait time of 3 UDPCK clock cycles and 3 peripheral clock cycles is required before
accessing DPR.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
FIFO_DATA
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
PUON TXVDIS
7 6 5 4 3 2 1 0
WARNING: The UDP peripheral clock in the Power Management Controller (PMC) must be enabled before any read/write
operations to the UDP registers including the UDP_TXVC register.
PUON: Pull-up On
0: The 1.5K integrated pull-up on DDP is disconnected.
1: The 1.5 K integrated pull-up on DDP is connected.
NOTE: If the USB pull-up is not connected on DDP, the user should not write in any UDP register other than the
UDP_TXVC register. This is because if DDP and DDM are floating at 0, or pulled down, then SE0 is received by the device
with the consequence of a USB Reset.
41.1 Description
The Analog Comparator Controller (ACC) configures the analog comparator and generates an interrupt depending
on user settings. The analog comparator embeds two 8-to-1 multiplexers that generate two internal inputs. These
inputs are compared, resulting in a compare output. The hysteresis level, edge detection and polarity are
configurable.
The ACC also generates a compare event which can be used by the Pulse Width Modulator (PWM).
DAC0
DAC1
on
Mux
Write Detect
External 1)
and Mask Timer
Analog
Data
on
Inputs
SELPLUS SELMINUS ACEN ISEL HYST SELFS INV Write EDGETYP SCO CE
ACC_CR
User Interface ACC_MR/ACR
Note: 1. Refer to Table 41-1 for the list of external analog data inputs.
The analog input pins (AD0AD7 and DAC01) are multiplexed with digital functions (PIO) on
the IO line. By writing the SELMINUS and SELPLUS fields in the ACC Mode Register
(ACC_MR), the associated IO lines are set to Analog mode.
41.5.3 Interrupt
The ACC has an interrupt line connected to the Interrupt Controller (IC). In order to handle interrupts, the Interrupt
Controller must be programmed before configuring the ACC.
41.6.1 Description
The Analog Comparator Controller (ACC) controls the analog comparator settings and performs post-processing
of the analog comparator output.
When the analog comparator settings are modified, the output of the analog cell may be invalid. The ACC masks
the output for the invalid period.
A comparison flag is triggered by an event on the output of the analog comparator and an interrupt is generated.
The event on the analog comparator output can be selected among falling edge, rising edge or any edge.
The ACC registers are listed in Table 41-4.
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
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
FE SELFS INV EDGETYP ACEN
7 6 5 4 3 2 1 0
SELPLUS SELMINUS
This register can only be written if the WPEN bit is cleared in the ACC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CE
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CE
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CE
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
SCO CE
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
HYST ISEL
This register can only be written if the WPEN bit is cleared in ACC Write Protection Mode Register.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
WPVS
42.1 Description
The ADC is based on a 12-bit Analog-to-Digital Converter (ADC) managed by an ADC Controller. Refer to Figure
42-1, Analog-to-Digital Converter Block Diagram. It also integrates a 16-to-1 analog multiplexer, making possible
the analog-to-digital conversions of 16 analog lines.The conversions extend from 0V to the voltage carried on pin
ADVREF.
Conversion results are reported in a common register for all channels, as well as in a channel-dedicated register.
The last channel is internally connected by a temperature sensor.
Software trigger, external trigger on rising edge of the ADTRG pin or internal triggers from Timer Counter output(s)
are configurable.
The comparison circuitry allows automatic detection of values below a threshold, higher than a threshold, in a
given range or outside the range, thresholds and ranges being fully configurable.
The ADC Controller internal fault output is directly connected to PWM fault input. This input can be asserted by
means of comparison circuitry in order to immediately put the PWM output in a safe state (pure combinational
path).
The ADC also integrates a Sleep mode and a conversion sequencer and connects with a PDC channel. These
features reduce both power consumption and processor intervention.
This ADC has a selectable single-ended or fully differential input and benefits from a 2-bit programmable gain.
A digital error correction circuit based on the multi-bit redundant signed digit (RSD) algorithm is employed in order
to reduce INL and DNL errors.
Finally, the user can configure ADC timings, such as startup time and tracking time.
Trigger
ADC 12-bit Controller
ADTRG Selection ADC Interrupt Interrupt
Control Controller
Logic AHB
AD0
Peripheral Bridge
PIO
Analog AD1
Inputs IN+
Cyclic Pipeline User
IN- OFFSET S/H PGA
Interface Bus Clock
ADn 12-bit Analog-to-Digital
Converter
APB
GND CHx
PMC
Peripheral Clock
ADCCLK
ADC_ON
Commands
from controller ADC_Start
to analog cell
DRDY
Figure 42-3. Sequence of ADC Conversions When Tracking Time < Conversion Time
Read the
ADC_LCDR
ADCCLK
ADC_ON
Commands
from controller ADC_Start
to analog cell
DRDY
Start Up Hold Time Conversion Hold Time Conversion Hold Time Conversion
Time of CH0 of CH1 of CH2
& & & &
Tracking Tracking Tracking Tracking
of CH0 of CH1 of CH2 of CH3
CHx
(ADC_CHSR)
EOCx
(ADC_ISR)
DRDY
(ADC_ISR)
If ADC_CDR is not read before further incoming data is converted, the corresponding OVREx flag is set in the
Overrun Status register (ADC_OVER).
New data converted when DRDY is high sets the GOVRE bit in ADC_ISR.
Trigger event
CH0
(ADC_CHSR)
CH1
(ADC_CHSR)
EOC0 Conversion A
Conversion C Read ADC_CDR0
(ADC_ISR)
GOVRE
Read ADC_ISR
(ADC_ISR)
DRDY
(ADC_ISR)
Read ADC_OVER
OVRE0
(ADC_OVER)
OVRE1
(ADC_OVER)
Warning: If the corresponding channel is disabled during a conversion or if it is disabled and then reenabled during a con-
version, its associated data and corresponding EOCx and GOVRE flags in ADC_ISR and OVREx flags in ADC_OVER are
unpredictable.
trigger
start
delay
If one of the TIOA outputs is selected, the corresponding Timer Counter channel must be programmed in
Waveform mode.
Only one start command is necessary to initiate a conversion sequence on all the channels. The ADC hardware
logic automatically performs the conversions on the active channels, then waits for a new request. The Channel
Enable (ADC_CHER) and Channel Disable (ADC_CHDR) registers permit the analog channels to be enabled or
disabled independently.
If the ADC is used with a PDC, only the transfers of converted data from enabled channels are performed and the
resulting data buffers should be interpreted accordingly.
To allow the full range, the analog offset of the ADC can be configured by the OFFx bit of the Channel Offset
register (ADC_COR). The offset is only available in Single-ended mode.
VIN+
VIN+
same as
gain=0.5 ) ) VADVREF
gain=1
(00)
VIN-
0
VADVREF
( ) VADVREF
VIN+ VIN+
gain=1 ) ) VADVREF
VIN-
(01) ( ) VADVREF
VADVREF
offset=1 offset=0
( ) VADVREF
(5 8) VADVREF
VIN+
gain=2 ) ) VADVREF
VIN-
VIN+
(3 8) VADVREF
(10) ( ) VADVREF
VIN+
VADVREF
trig.eventN trig.eventN
5 ADC_CDR5 BA + [(N-1) * 6] 0 ADC_CDR5
6 ADC_CDR6 BA + [(N-1) * 6]+ 0x02
0 ADC_CDR6
8 ADC_CDR8 BA + [(N-1) * 6]+ 0x04 0 ADC_CDR8
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
AUTOCAL START SWRST
23 22 21 20 19 18 17 16
ANACH SETTLING STARTUP
15 14 13 12 11 10 9 8
PRESCAL
7 6 5 4 3 2 1 0
FREERUN FWUP SLEEP TRGSEL TRGEN
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
USCH6 USCH5
15 14 13 12 11 10 9 8
USCH4 USCH3
7 6 5 4 3 2 1 0
USCH2 USCH1
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
USCH14 USCH13
15 14 13 12 11 10 9 8
USCH12 USCH11
7 6 5 4 3 2 1 0
USCH10 USCH9
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
7 6 5 4 3 2 1 0
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
7 6 5 4 3 2 1 0
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CH15 CH14 CH13 CH12 CH11 CH10 CH9 CH8
7 6 5 4 3 2 1 0
CH7 CH6 CH5 CH4 CH3 CH2 CH1 CH0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CHNB LDATA
7 6 5 4 3 2 1 0
LDATA
23 22 21 20 19 18 17 16
EOCAL
15 14 13 12 11 10 9 8
EOC15 EOC14 EOC13 EOC12 EOC11 EOC10 EOC9 EOC8
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Enables the corresponding interrupt.
23 22 21 20 19 18 17 16
EOCAL
15 14 13 12 11 10 9 8
EOC15 EOC14 EOC13 EOC12 EOC11 EOC10 EOC9 EOC8
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
The following configuration values are valid for all listed bit names of this register:
0: No effect.
1: Disables the corresponding interrupt.
23 22 21 20 19 18 17 16
EOCAL
15 14 13 12 11 10 9 8
EOC15 EOC14 EOC13 EOC12 EOC11 EOC10 EOC9 EOC8
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
The following configuration values are valid for all listed bit names of this register:
0: The corresponding interrupt is disabled.
1: The corresponding interrupt is enabled.
23 22 21 20 19 18 17 16
EOCAL
15 14 13 12 11 10 9 8
EOC15 EOC14 EOC13 EOC12 EOC11 EOC10 EOC9 EOC8
7 6 5 4 3 2 1 0
EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
OVRE15 OVRE14 OVRE13 OVRE12 OVRE11 OVRE10 OVRE9 OVRE8
7 6 5 4 3 2 1 0
OVRE7 OVRE6 OVRE5 OVRE4 OVRE3 OVRE2 OVRE1 OVRE0
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
CMPALL
7 6 5 4 3 2 1 0
CMPSEL CMPMODE
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
HIGHTHRES
15 14 13 12 11 10 9 8
LOWTHRES
7 6 5 4 3 2 1 0
LOWTHRES
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
GAIN11 GAIN10 GAIN9 GAIN8
15 14 13 12 11 10 9 8
GAIN7 GAIN6 GAIN5 GAIN4
7 6 5 4 3 2 1 0
GAIN3 GAIN2 GAIN1 GAIN0
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
The DIFFx bit in this table is described in Section 42.7.17 ADC Channel Offset Register.
23 22 21 20 19 18 17 16
DIFF7 DIFF6 DIFF5 DIFF4 DIFF3 DIFF2 DIFF1 DIFF0
15 14 13 12 11 10 9 8
OFF15 OFF14 OFF13 OFF12 OFF11 OFF10 OFF9 OFF8
7 6 5 4 3 2 1 0
OFF7 OFF6 OFF5 OFF4 OFF3 OFF2 OFF1 OFF0
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
DATA
7 6 5 4 3 2 1 0
DATA
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
IBCTL
7 6 5 4 3 2 1 0
TSON
This register can only be written if the WPEN bit is cleared in the ADC Write Protection Mode Register.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
WPVSRC
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
43.1 Description
The Digital-to-Analog Converter Controller (DACC) provides up to 2 analog outputs, making it possible for the
digital-to-analog conversion to drive up to 2 independent analog lines.
The DACC supports 12-bit resolution. Data to be converted are sent in a common register for all channels.
External triggers or free-running mode are configurable.
External triggers
Trigger
DATRG Selection
DAC Clock
Control Interrupt
Logic Controller
PDC
DAC Core
User
Interface Peripheral Bridge
Sample & Hold 0
PMC
peripheral clock
DAC0 DAC1
Peripheral clock
Write DACC_CDR
DAC Channel 0
Data 0 Data 1
Output
DAC Channel 1
Data 2
Output
EOC
Read DACC_ISR
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
23 22 21 20 19 18 17 16
MAXS TAG USER_SEL
15 14 13 12 11 10 9 8
ONE
7 6 5 4 3 2 1 0
WORD TRGSEL TRGEN
This register can only be written if the WPEN bit is cleared in the DACC Write Protection Mode Register.
Note: Refer to the DAC electrical characteristics section in the datasheet for start-up time value.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CH1 CH0
This register can only be written if the WPEN bit is cleared in the DACC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CH1 CH0
This register can only be written if the WPEN bit is cleared in the DACC Write Protection Mode Register.
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
CH1 CH0
23 22 21 20 19 18 17 16
DATA
15 14 13 12 11 10 9 8
DATA
7 6 5 4 3 2 1 0
DATA
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TXBUFE ENDTX EOC TXRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Enables the corresponding interrupt
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TXBUFE ENDTX EOC TXRDY
The following configuration values are valid for all listed bit names of this register:
0: No effect
1: Disables the corresponding interrupt
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
TXBUFE ENDTX EOC TXRDY
The following configuration values are valid for all listed bit names of this register:
0: Corresponding interrupt is not enabled
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
TXBUFE ENDTX EOC TXRDY
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
IBCTLDACCORE
7 6 5 4 3 2 1 0
IBCTLCH1 IBCTLCH0
This register can only be written if the WPEN bit is cleared in the DACC Write Protection Mode Register.
23 22 21 20 19 18 17 16
WPKEY
15 14 13 12 11 10 9 8
WPKEY
7 6 5 4 3 2 1 0
WPEN
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
WPVSRC
7 6 5 4 3 2 1 0
WPVS
VT+
VT-
t
BOD OUTPUT
td- td+
VT + Vhys
VT
Reset
VT+
VT-
Reset
3.3V VDDIO
VDDIN
Voltage
VDDOUT Regulator
VDDCORE
VDDPLL
Table 44-10. Typical Power Consumption for Backup Mode (SAM4SD32/SD16/SA16 rev A)
@ 25C @ 85C @ 105C
(AMP1) (AMP1) (AMP1) (AMP1)
Conditions Configuration A Configuration B Configuration A Configuration A Unit
VDDIO = 3.6V 2.1 2.0 13.9 22.5
VDDIO = 3.3V 1.8 1.8
VDDIO = 3.0V 1.7 1.6 A
VDDIO = 2.5V 1.3 1.3
VDDIO = 1.8V 0.9 0.9
Table 44-11. Typical Power Consumption for Backup Mode (SAM4S16/S8 rev A)
@ 25C @ 85C @ 105C
(AMP1) (AMP1) (AMP1) (AMP1)
Conditions Configuration A Configuration B Configuration A Configuration A Unit
VDDIO = 3.6V 2.7 2.5 12.1 20.1
VDDIO = 3.3V 2.0 1.8
VDDIO = 3.0V 1.8 1.7 A
VDDIO = 2.5V 1.5 1.4
VDDIO = 1.8V 1 0.9
3.3V VDDIO
VDDIN
Voltage
VDDOUT Regulator
AMP1
VDDCORE
VDDPLL
Figure 44-6. SAM4S4/2 Current Consumption in Sleep Mode (AMP1) vs Master Clock Ranges (refer to Table 44-12)
6.000
ID DCORE 4.000
2.000
0.000
0 10 20 30 40 50 60 70 80 90 100 110 120
MHz
Table 44-13. SAM4S4/2 Typical Sleep Mode Current Consumption vs Master Clock (MCK) Variation with Fast RC
Typical Value @ 25C
VDDCORE Consumption Total Consumption
Core Clock/MCK (MHz) (AMP1) (AMP2) Unit
12 0.6 0.8
8 0.4 0.7
4 0.2 0.5
mA
2 0.17 0.41
1 0.13 0.34
0.5 0.11 0.35
10.000
8.000
ID DCORE 6.000
4.000
2.000
0.000
0 10 20 30 40 50 60 70 80 90 100 110 120
MHz
Table 44-14. SAM4S16/S8 Typical Sleep Mode Current Consumption vs Master Clock (MCK) Variation with PLLA
Typical Value @ 25C
VDDCORE Consumption Total Consumption
Core Clock/MCK (MHz) (AMP1) (AMP2) Unit
120 8.1 9.6
100 7.1 8.1
84 6.0 6.8
64 4.7 5.2 mA
48 3.5 3.9
32 2.4 2.6
24 1.8 2.0
Figure 44-8. SAM4SD32/SD16/SA16 Typical Current Consumption in Sleep Mode (AMP1) vs Master Clock Ranges (refer to
Table 44-16)
8.00
7.00
6.00
5.00
IDDCORE
4.00
3.00
2.00
1.00
0.00
0 20 40 60 80 100 120 140
MHz
Table 44-17. SAM4SD32/SD16/SA16 Typical Sleep Mode Current Consumption vs Master Clock (MCK) Variation with Fast RC
Typical Value @ 25C
VDDCORE Consumption Total Consumption
Core Clock/MCK (MHz) (AMP1) (AMP2) Unit
12 1.1 1.8
8 0.8 1.2
4 0.4 0.7
mA
2 0.3 0.7
1 0.2 0.5
0.5 0.2 0.5
3.6V VDDIO
VDDIN
AMP1
Voltage
VDDOUT Regulator
VDDCORE
VDDPLL
3.3V VDDIO
VDDIN
Voltage
VDDOUT Regulator
AMP1
VDDCORE
VDDPLL
The following tables give Active mode current consumption in typical conditions.
VDDCORE at 1.2V
TA = 25C
Table 44-21. SAM4S4/2 Active Power Consumption with VDDCORE @ 1.2V Running from Flash Memory or SRAM
CoreMark
(1)
128-bit Flash access 64-bit Flash access(1) SRAM
Core Clock (MHz) AMP1 AMP2 AMP1 AMP2 AMP2 Unit
120 17.7 21.2 12.8 16.4 16.2
100 16.1 19.4 11.6 14.8 13.5
84 13.6 16.8 9.9 13.1 12.0
64 11.6 14.6 8.5 10.9 9.0
32 7.3 9.8 5.8 8.0 5.2
24 6.0 8.3 5.2 7.4 3.9
mA
12 3.6 5.2 2.7 4.1 2.2
8 2.4 4.6 2.2 3.5 1.5
4 1.5 2.3 1.2 2.8 1.0
2 0.7 1.8 0.6 1.9 0.8
1 0.4 1.1 0.3 1.2 0.7
0.5 0.2 0.9 0.2 0.9 0.6
Note: 1. Flash Wait State (FWS) in EEFC_FMR adjusted versus core frequency
Table 44-22. SAM4S16/S8 Active Power Consumption with VDDCORE @ 1.2V Running from Flash Memory or SRAM
CoreMark
128-bit Flash access(1) 64-bit Flash access(1) SRAM
Core Clock (MHz) AMP1 AMP2 AMP1 AMP2 AMP2 Unit
120 24.9 28.8 18 21.4 19.6
100 21.9 25.4 16.3 19.5 16.5
84 18.5 21.4 13.8 16.6 13.9
64 15.0 17.6 11.4 13.9 10.7
48 11.9 14.3 9.6 11.8 8
32 8.1 9.9 7.4 9.3 5.4
24 6.0 7.7 5.8 7.5 4.1 mA
12 3.4 6.1 3.2 6.0 2
8 2.3 4.5 2.2 4.5 1.2
4 1.2 2.6 1.2 2.9 1.2
2 0.7 1.9 0.7 2.0 0.7
1 0.4 1.3 0.4 1.6
0.5 0.3 1.1 0.3 1.3
Note: 1. Flash Wait State (FWS) in EEFC_FMR adjusted versus core frequency
30
25
20
0
0 50 100 150
Frequency MHz
Table 44-23. SAM4SD32/SA16/SD16 Active Power Consumption with VDDCORE @ 1.2V running from Flash Memory
(IDDCORE- AMP1) or SRAM
CoreMark
Cache Enable (CE) Cache Disable (CD)
128-bit Flash 64-bit Flash 128-bit Flash 64-bit Flash
Core Clock (MHz) access(1) access(1) access(1) access(1) SRAM Unit
120 20.7 20.7 24.8 18.1 19.9
100 17.5 17.4 21.6 16.5 16.8
84 14.7 14.7 18.3 13.9 14.2
64 11.3 11.3 14.4 11.5 10.9
48 8.5 8.5 11.3 9.4 8.3
32 5.7 5.7 8.0 7.1 5.6
24 4.3 4.3 6.3 5.9 4.2 mA
12 2.5 2.5 3.5 3.3 1.9
8 1.7 1.7 2.4 2.3 1.7
4 0.9 0.9 1.2 1.2 0.7
2 0.5 0.5 0.7 0.7 0.5
1 0.4 0.4 0.5 0.5 0.4
0.5 0.3 0.3 0.3 0.3 0.3
Note: 1. Flash Wait State (FWS) in EEFC_FMR adjusted versus core frequency
Figure 44-12. SAM4SD32/SD16/SA16 Current Consumption in Active Mode (AMP1) versus Master Clock Ranges
25.0
20.0
5.0
0.0
0 20 40 60 80 100 120
SAM4
XIN32 XOUT32
VXIN32_IH
VXIN32_IL
tCLXIN32
tCPXIN32
XIN XOUT
VXIN_IH
VXIN_IL
tCLXIN
tCPXIN
VCRS 90%
10% 10%
Differential tr tf
Data Lines
(a)
REXT = 27
fOSC = 6 MHz/750 kHz
CLOAD
Buffer
(b)
Notes: 1. If ADC_MR.TRACKTIM is programmed with a value < 15, then the min. value is applied by default.
2. Refer to Figure 44-21 Simplified Acquisition Path for the max. tracking time computation.
3. Sampling frequency fs=1/tCONV in FREERUN mode. Oherwise, fs is defined by the trigger timing.
If TRACKTIM >14: tCONV = tHOLD +(TRACKTIM+1) x tCP_ADC with hold time tHOLD=5 tCP_ADC.
Table 44-42 is a computation example for the above formula, where VADVREF = 3V.
Table 44-43 is a computation example for the above formula, where VADVREF = 3V.
FSe-
VI Differential
0
-ADVREF/2 0 ADVREF/2
where:
FSe = (FSe+) - (FSe-) is for full-scale error, unit is LSB code
Offset error EO is the offset error measured for VI = 0V
Gain error EG = 100 FSe / 4096, unit in %
The error values in Table 44-46 and Table 44-47 include the sample and hold error as well as the PGA gain error.
FSe-
VI Single-ended
0
0 ADVREF/2 ADVREF
where:
FSe = (FSe+) - (FSe-) is for full-scale error, unit is LSB code
Offset error EO is the offset error measured for VI = 0V
Gain error EG = 100 FSe / 4096, unit in %
The error values in Table 44-48 and Table 44-49 include the sample and hold error as well as the PGA gain error.
Zi
RON RON
Zi
Ci Ci
GND RON
where:
Zi is input impedance in single-ended or differential mode
Ci = 1 to 8 pF 20% depending on the gain value and mode (SE or DIFF); temperature dependency is
negligible
RON is typical 2 k and 8 k max (worst case process and high temperature)
RON is negligible regarding the value of Zi
The following formula is used to calculate input impedance:
1
Z i = ----------------
fS Ci
where:
fS is the sampling frequency of the ADC channel
Typ values are used to compute ADC input impedance Zi
Ci
In 12-bit mode, during the tracking phase, the ADC needs to track the input signal during the tracking time shown
below:
tTRACK = 0.054 ZSOURCE + 205
with tTRACK expressed in ns and ZSOURCE expressed in .
The ADC already includes a tracking time of 15 tCP_ADC.
Two cases must be considered:
If the calculated tracking time (tTRACK) is lower than 15 tCP_ADC, then ADC_MR.TRACKTIM can be set to 0.
If the calculated tracking time (tTRACK) is higher than 15 tCP_ADC, then ADC_MR.TRACKTIM must be set to
the correct value.
External voltage reference for DAC is VADVREF. See the ADC voltage reference characteristics in Table 44-40 on
page 1173.
IBCTLCHx = 01 5.3
IBCTLCHx = 10 8
IBCTLCHx = 11 10.7
No resistive load
IBCTLCHx = 00 0.23
Output Channel
IBCTLCHx = 01 0.45 mA
Current Consumption
IBCTLCHx = 10 0.67
IBCTLCHx = 11 0.89
tsa Settling Time RLOAD = 10 k, 0 pF < CLOAD< 50 pF 0.5 s
RLOAD Output load resistor 10 k
CLOAD Output load capacitor 30 50 pF
Figure 44-22. SPI Master Mode with (CPOL = NCPHA = 0) or (CPOL = NCPHA = 1)
SPCK
SPI0 SPI1
MISO
SPI2
MOSI
Figure 44-23. SPI Master Mode with (CPOL = 0 and NCPHA = 1) or (CPOL = 1 and NCPHA = 0)
SPCK
SPI3 SPI4
MISO
SPI5
MOSI
Figure 44-24. SPI Slave Mode with (CPOL = 0 and NCPHA = 1) or (CPOL = 1 and NCPHA = 0)
NPCSS
SPI12 SPI13
SPCK
SPI6
MISO
SPI7 SPI8
MOSI
NPCS0
SPI15
SPI14
SPCK
SPI9
MISO
SPI10 SPI11
MOSI
TK (CKI =0)
TK (CKI =1)
SSC0
TF/TD
TK (CKI =0)
TK (CKI =1)
SSC1
TF/TD
TK (CKI=0)
TK (CKI=1)
SSC2 SSC3
TF
SSC4
TD
TK (CKI=1)
TK (CKI=0)
SSC5 SSC6
TF
SSC7
TD
RK (CKI=0)
RK (CKI=1)
SSC8 SSC9
RF/RD
RK (CKI=1)
RK (CKI=0)
SSC8 SSC9
RD
SSC10
RF
RK (CKI=1)
RK (CKI=0)
SSC11 SSC12
RD
SSC13
RF
RK (CKI=0)
RK (CKI=1)
SSC11 SSC12
RF/RD
TK (CKI = 1)
TK (CKI = 0)
SSC0min
SSC0max
TF/TD
A0A23
SMC13 SMC13
NRD
DATA
SMC25 SMC27
NWE
A0A23
NCS
SMC7 SMC7
NRD
DATA
NRD Controlled READ NWE Controlled WRITE NRD Controlled READ NWE Controlled WRITE
with NO HOLD with NO HOLD with HOLD with HOLD
CPOL = 1
SPI0
SCK
CPOL = 0
SPI4
SPI4 SPI1 SPI2
MOSI
NSS
SPI12 SPI13
SCK
SPI6
MISO
SPI7 SPI8
MOSI
NSS
SPI14
SPI15
SCK
SPI9
MISO
SPI10 SPI11
MOSI
Bus Free Time between a STOP and fTWCK 100 kHz tLOW s
tBUF
START Condition fTWCK > 100 kHz tLOW s
Notes: 1. Required only for fTWCK > 100 kHz
2. Cb = capacitance of one bus line in pF. Per I2C Standard, Cb Max = 400 pF
3. The TWCK low period is defined as follows: tLOW = ((CLDIV 2CKDIV) + 4) tMCK
4. The TWCK high period is defined as follows: tHIGH = ((CHDIV 2CKDIV) + 4) tMCK
5. tCPMCK = MCK bus period.
tfo tHIGH tr
tLOW tLOW
TWCK
tsu(start) th(start) th(data) tsu(data)
tsu(stop)
TWD
tBUF
Note : 1. This drawing is for general information only. Refer to JEDEC Drawing MS-026 for additional information.
1.0
1.0
1.0
YYWW V
XXXXXXXXX ARM
where
YY: manufactory year
WW: manufactory week
V: revision
XXXXXXXXX: lot number
ATSAM4SD32CA-CFU A Industrial
2*1024 160 VFBGA100 Tray
ATSAM4SD32CB-CFU B (-40C to +85C)
ATSAM4SD32CA-AU A Industrial
2*1024 160 LQFP100 Tray
ATSAM4SD32CB-AU B (-40C to +85C)
ATSAM4SD32CA-AN A Industrial
2*1024 160 LQFP100 Tray
ATSAM4SD32CB-AN B (-40C to +105C)
ATSAM4SD32BA-MU A Industrial
2*1024 160 QFN64 Tray
ATSAM4SD32BB-MU B (-40C to +85C)
ATSAM4SD32BA-AU A Industrial
2*1024 160 LQFP64 Tray
ATSAM4SD32BB-AU B (-40C to +85C)
ATSAM4SD32BA-AN A Industrial
2*1024 160 LQFP64 Tray
ATSAM4SD32BB-AN B (-40C to +105C)
ATSAM4SD32BA-UUR A Industrial
2*1024 160 WLCSP64 Tape and reel
ATSAM4SD32BB-UUR B (-40C to +85C)
ATSAM4SD16CA-CU A Industrial
2*512 160 TFBGA100 Tray
ATSAM4SD16CB-CU B (-40C to +85C)
ATSAM4SD16CA-CFU A Industrial
2*512 160 VFBGA100 Tray
ATSAM4SD16CB-CFU B (-40C to +85C)
ATSAM4SD16CA-AU A Industrial
2*512 160 LQFP100 Tray
ATSAM4SD16CB-AU B (-40C to +85C)
ATSAM4SD16CA-AN A Industrial
2*512 160 LQFP100 Tray
ATSAM4SD16CB-AN B (-40C to +105C)
ATSAM4SD16BA-MU A Industrial
2*512 160 QFN64 Tray
ATSAM4SD16BB-MU B (-40C to +85C)
ATSAM4SD16BA-AU A Industrial
2*512 160 LQFP64 Tray
ATSAM4SD16BB-AU B (-40C to +85C)
ATSAM4SD16BA-AN A Industrial
2*512 160 LQFP64 Tray
ATSAM4SD16BB-AN B (-40C to +105C)
ATSAM4SA16CA-CU A Industrial
1024 160 TFBGA100 Tray
ATSAM4SA16CB-CU B (-40C to +85C)
ATSAM4SA16CA-CFU A Industrial
1024 160 VFBGA100 Tray
ATSAM4SA16CB-CFU B (-40C to +85C)
ATSAM4SA16CA-AU A Industrial
1024 160 LQFP100 Tray
ATSAM4SA16CB-AU B (-40C to +85C)
ATSAM4SA16CA-AN A Industrial
1024 160 LQFP100 Tray
ATSAM4SA16CB-AN B (-40C to +105C)
ATSAM4SA16BA-MU A Industrial
1024 160 QFN64 Tray
ATSAM4SA16BB-MU B (-40C to +85C)
ATSAM4SA16BA-AU A Industrial
1024 160 LQFP64 Tray
ATSAM4SA16BB-AU B (-40C to +85C)
ATSAM4SA16BA-AN A Industrial
1024 160 LQFP64 Tray
ATSAM4SA16BB-AN B (-40C to +105C)
ATSAM4S16CA-CU A Industrial
1024 128 TFBGA100 Tray
ATSAM4S16CB-CU B (-40C to +85C)
ATSAM4S16CA-CFU A Industrial
1024 128 VFBGA100 Tray
ATSAM4S16CB-CFU B (-40C to +85C)
ATSAM4S16CA-AU A Industrial
1024 128 LQFP100 Tray
ATSAM4S16CB-AU B (-40C to +85C)
ATSAM4S16CA-CFN A Industrial
1024 128 VFBGA100 Tray
ATSAM4S16CB-CFN B (-40C to +105C)
ATSAM4S16CA-AN A Industrial
1024 128 LQFP100 Tray
ATSAM4S16CB-AN B (-40C to +105C)
ATSAM4S16BA-MU A Industrial
1024 128 QFN64 Tray
ATSAM4S16BB-MU B (-40C to +85C)
ATSAM4S16BA-AU A Industrial
1024 128 LQFP64 Tray
ATSAM4S16BB-AU B (-40C to +85C)
ATSAM4S16BA-UUR A Industrial
1024 128 WLCSP64 Reel
ATSAM4S16BB-UUR B (-40C to +85C)
ATSAM4S16BA-AN A Industrial
1024 128 LQFP64 Tray
ATSAM4S16BB-AN B (-40C to +105C)
ATSAM4S8CA-CU A Industrial
512 128 TFBGA100 Tray
ATSAM4S8CB-CU B (-40C to +85C)
ATSAM4S8CA-AU A Industrial
512 128 LQFP100 Tray
ATSAM4S8CB-AU B (-40C to +85C)
ATSAM4S8CA-CFN A Industrial
512 128 VFBGA100 Tray
ATSAM4S8CB-CFN B (-40C to +105C)
ATSAM4S8CA-AN A Industrial
512 128 LQFP100 Tray
ATSAM4S8CB-AN B (-40C to +105C)
ATSAM4S8BA-MU A Industrial
512 128 QFN64 Tray
ATSAM4S8BB-MU B (-40C to +85C)
ATSAM4S8BA-AU A Industrial
512 128 LQFP64 Tray
ATSAM4S8BB-AU B (-40C to +85C)
ATSAM4S8BA-UUR A Industrial
512 128 WLCSP64 Reel
ATSAM4S8BB-UUR B (-40C to +85C)
ATSAM4S8BA-AN A Industrial
512 128 LQFP64 Tray
ATSAM4S8BB-AN B (-40C to +105C)
ATSAM4S4CA-CU A Industrial
256 64 TFBGA100 Tray
ATSAM4S4CB-CU B (-40C to +85C)
ATSAM4S4CA-CFU A Industrial
256 64 VFBGA100 Tray
ATSAM4S4CB-CFU B (-40C to +85C)
ATSAM4S4CA-AU A Industrial
256 64 LQFP100 Tray
ATSAM4S4CB-AU B (-40C to +85C)
ATSAM4S4CA-AN A Industrial
256 64 LQFP100 Tray
ATSAM4S4CB-AN B (-40C to +105C)
ATSAM4S4BA-MU A Industrial
256 64 QFN64 Tray
ATSAM4S4BB-MU B (-40C to +85C)
ATSAM4S4BA-AU A Industrial
256 64 LQFP64 Tray
ATSAM4S4BB-AU B (-40C to +85C)
ATSAM4S4BA-UUR A Industrial
256 64 WLCSP64 Reel
ATSAM4S4BB-UUR B (-40C to +85C)
ATSAM4S4BA-AN A Industrial
256 64 LQFP64 Tray
ATSAM4S4BB-AN B (-40C to +105C)
ATSAM4S4AA-MU A Industrial
256 64 QFN48 Tray
ATSAM4S4AB-MU B (-40C to +85C)
ATSAM4S4AA-AU A Industrial
256 64 LQFP48 Tray
ATSAM4S4AB-AU B (-40C to +85C)
ATSAM4S2CA-CU A Industrial
128 64 TFBGA100 Tray
ATSAM4S2CB-CU B (-40C to +85C)
ATSAM4S2CA-CFU A Industrial
128 64 VFBGA100 Tray
ATSAM4S2CB-CFU B (-40C to +85C)
ATSAM4S2CA-AU A Industrial
128 64 LQFP100 Tray
ATSAM4S2CB-AU B (-40C to +85C)
ATSAM4S2CA-AN A Industrial
128 64 LQFP100 Tray
ATSAM4S2CB-AN B (-40C to +105C)
ATSAM4S2BA-MU A Industrial
128 64 QFN64 Tray
ATSAM4S2BB-MU B (-40C to +85C)
ATSAM4S2BA-AU A Industrial
128 64 LQFP64 Tray
ATSAM4S2BB-AU B (-40C to +85C)
ATSAM4S2BA-UUR A Industrial
128 64 WLCSP64 Reel
ATSAM4S2BB-UUR B (-40C to +85C)
ATSAM4S2BA-AN A Industrial
128 64 LQFP64 Tray
ATSAM4S2BB-AN B (-40C to +105C)
ATSAM4S2AA-MU A Industrial
128 64 QFN48 Tray
ATSAM4S2AB-MU B (-40C to +85C)
ATSAM4S2AA-AU A Industrial
128 64 LQFP48 Tray
ATSAM4S2AB-AU B (-40C to +85C)
ATSAM4S2AA-AN A Industrial
128 64 LQFP48 Tray
ATSAM4S2AB-AN B (-40C to +105C)
Workaround: Do not do partial programming (Fill completely the Write Buffer). Note that this problem occurs
only if the software tries to write into a locked region.
Issue: Erase Sector Command Cannot Be Performed If a Subsector Is Locked (ONLY in Flash
Sector0)
If one of subsector (Small Sector 0, Small Sector1 and Larger Sector) is locked, the Erase Sector Command (ES)
is not possible on non-locked subsectors.
Workaround: All the lock bits of the sector0 must be cleared prior to issuing the ES command. After the ES
command has been issued, the first sector lock bits must be reverted to the state before clearing
them.
Issue: Incorrect Flash Read May Occur Depending on VDDIO Voltage and Flash Wait State
Flash read issues leading to wrong instruction fetch or incorrect data read may occur under the following operating
conditions:
VDDIO < 2.4V and Flash wait state(1) 1
If the core clock frequency does not require the use of the Flash wait state (2) (FWS = 0 in EEFC_FMR) or if only
data reads are performed on the Flash (e.g., if the code is running out of SRAM), there are no constraints on
VDDIO voltage. The usable voltage range for VDDIO is defined in Table 44-3 DC Characteristics.
Notes: 1. Defined by the FWS field in EEFC_FMR register.
2. See Section 44.12.9 Embedded Flash Characteristics for the maximum core clock frequency at zero (0) wait
state.
48.1.3 Watchdog
Workaround: When entering wait mode, the Wait For Event (WFE) instruction of the processor Cortex-M4 must
be used with the SLEEPDEEP of the System Control Register (SCB_SCR) of the Cortex-M = 0.
Issue: Unpredictable Behavior if BOD is Disabled, VDDCORE is Lost and VDDIO is Connected
In active mode or in wait mode, if the Brownout Detector is disabled (SUPC_MR.BODDIS = 1) and power is lost on
VDDCORE while VDDIO is powered, the device might not be properly reset and may behave unpredictably.
Workaround: When the Brownout Detector is disabled in active or in wait mode, VDDCORE always needs to be
powered.
48.1.6 PIO
Workaround: The voltage on PB4 with respect to ground must be in the range
-0.1V to + VDDIO + 0.4V instead of -0.3V to + VDDIO + 0.4V for all other input pins, as shown in
Table 44.1 Absolute Maximum Ratings.
The minimum VIL on PB4 must be 0V instead of -0.3V for all other input pins, as shown in Table
44.3 DC Characteristics.
Workaround: Do not do partial programming (Fill completely the Write Buffer). Note that this problem occurs
only if the software tries to write into a locked region.
Issue: Erase Sector Command Cannot Be Performed If a Subsector Is Locked (ONLY in Flash
Sector0)
If one of subsector (Small Sector 0, Small Sector1 and Larger Sector) is locked, the Erase Sector Command (ES)
is not possible on non-locked subsectors.
Workaround: All the lock bits of the sector0 must be cleared prior to issuing the ES command. After the ES
command has been issued, the first sector lock bits must be reverted to the state before clearing
them.
48.2.3 Watchdog
Workaround: When entering wait mode, the Wait For Event (WFE) instruction of the processor Cortex-M4 must
be used with the SLEEPDEEP of the System Control Register (SCB_SCR) of the Cortex-M = 0.
Issue: Unpredictable Behavior if BOD is Disabled, VDDCORE is Lost and VDDIO is Connected
In active mode or in wait mode, if the Brownout Detector is disabled (SUPC_MR.BODDIS = 1) and power is lost on
VDDCORE while VDDIO is powered, the device might not be properly reset and may behave unpredictably.
Workaround: When the Brownout Detector is disabled in active or in wait mode, VDDCORE always needs to be
powered.
Workaround: The voltage on PB4 with respect to ground must be in the range
-0.1V to + VDDIO + 0.4V instead of -0.3V to + VDDIO + 0.4V for all other input pins, as shown in
Table 44.1 Absolute Maximum Ratings.
The minimum VIL on PB4 must be 0V instead of -0.3V for all other input pins, as shown in Table
44.3 DC Characteristics.
Issue: Erase Sector (ES) Command Cannot Be Performed If a Subsector Is Locked (ONLY in Flash
sector 0)
If one of the subsectors
small sector 0
small sector 1
larger sector
is locked within the Flash sector 0, the erase sector (ES) command cannot be processed on non-locked
subsectors. Refer to the Flash overview in Section 8. Memories.
Workaround: All the lock bits of the sector 0 must be cleared prior to issuing the ES command. After the ES
command has been issued, the lock bits must be reverted to the state before clearing them.
48.3.2 Flash
Issue: Incorrect Flash Read May Occur Depending on VDDIO Voltage and Flash Wait State
Flash read issues leading to wrong instruction fetch or incorrect data read may occur under the following operating
conditions:
VDDIO < 2.4V and Flash wait state(1) 1
If the core clock frequency does not require the use of the Flash wait state(2) (FWS = 0 in EEFC_FMR) or if only
data reads are performed on the Flash (e.g., if the code is running out of SRAM), there are no constraints on
VDDIO voltage. The usable voltage range for VDDIO is defined in Table 44-3 DC Characteristics.
Notes: 1. Defined by the FWS field in EEFC_FMR.
2. See Section 44.12.9 Embedded Flash Characteristics for the maximum core clock frequency at zero (0) wait
state.
Issue: Unpredictable Behavior if BOD is Disabled, VDDCORE is Lost and VDDIO is Connected
In active mode or in wait mode, if the Brownout Detector is disabled (SUPC_MR.BODDIS = 1) and power is lost on
VDDCORE while VDDIO is powered, the device might not be properly reset and may behave unpredictably.
Workaround: When the Brownout Detector is disabled in active or in wait mode, VDDCORE always needs to be
powered.
48.3.5 PIO
Workaround: The voltage on PB4 with respect to ground must be in the range
-0.1V to + VDDIO + 0.4V instead of -0.3V to + VDDIO + 0.4V for all other input pins, as shown in
Table 44.1 Absolute Maximum Ratings.
The minimum VIL on PB4 must be 0V instead of -0.3V for all other input pins, as shown in Table
44.3 DC Characteristics.
Issue: Erase Sector (ES) Command Cannot Be Performed If a Subsector Is Locked (ONLY in Flash
sector 0)
If one of the subsectors
small sector 0
small sector 1
larger sector
is locked within the Flash sector 0, the erase sector (ES) command cannot be processed on non-locked
subsectors. Refer to the Flash overview in Section 8. Memories.
Workaround: All the lock bits of the sector 0 must be cleared prior to issuing the ES command. After the ES
command has been issued, the lock bits must be reverted to the state before clearing them.
Issue: Unpredictable Behavior if BOD is Disabled, VDDCORE is Lost and VDDIO is Connected
In active mode or in wait mode, if the Brownout Detector is disabled (SUPC_MR.BODDIS = 1) and power is lost on
VDDCORE while VDDIO is powered, the device might not be properly reset and may behave unpredictably.
Workaround: When the Brownout Detector is disabled in active or in wait mode, VDDCORE always needs to be
powered.
Workaround: The voltage on PB4 with respect to ground must be in the range
-0.1V to + VDDIO + 0.4V instead of -0.3V to + VDDIO + 0.4V for all other input pins, as shown in
Table 44.1 Absolute Maximum Ratings.
The minimum VIL on PB4 must be 0V instead of -0.3V for all other input pins, as shown in Table
44.3 DC Characteristics.
Added 2nd paragraph in Section 6.1 General Purpose I/O Lines. 8992
RTC
Added new bullet Safety/security features in Section 16.2 Embedded Characteristics. 8544
Last sentence added in Section 16.5.3 Alarm. 8900
Added note in Section 16.5.3 Alarm, Section 16.6.5 RTC Time Alarm Register and Section 16.6.6 RTC 9027
Calendar Alarm Register.
Replaced values for temperature range with a generic term in Section 16.5.7 RTC Accurate Clock Calibration. 9033
Block diagram centered for readability in Section 16.3 Block Diagram. rfo
PMC
Section 28.4.2 Slow Clock Crystal Oscillator, replaced ...in MOSCSEL bit of CKGR_MOR,... with ...in
9069
XTALSEL bit of SUPC_CR,... in the last phrase of the 3d paragraph.
Section 28.4.2 Slow Clock Crystal Oscillator, added references on the OSCSEL bit of PMC_SR in the 3d rfo
paragraph.
Register names in Clock Generator: Replaced PLL_MCKR with PMC_MCKR and PLL_SR with PMC_SR 8970
in Section 28.5.6 Software Sequence to Detect the Presence of Fast Crystal
In Section 28.6.1 Divider and Phase Lock Loop Programming, 3rd bullet, replaced PMC_IER with PMC_SR. 8963
Deleted previous 4th bullet (was useless sentence Disable and then enable the PLL...).
In Figure 28-3 and Section 28.5.3 3 to 20 MHz Crystal or Ceramic Resonator-based Oscillator paragraph 5,
replaced MOSCXTCNT with MOSCXTST.
Added code example in step 1. of Section 29.14 Programming Sequence.
8447
Corrected reset value of CKGR_MOR register in Table 29-3, Register Mapping.
8564
Corrected value of PLLA(B)COUNT field description in Section 29.17.9 PMC Clock Generator PLLA Register
and Section 29.17.10 PMC Clock Generator PLLB Register.
8853
Added a note in Section 29.17.8 PMC Clock Generator Main Clock Frequency Register and reworked a
paragraph in Section 28.5.2 Fast RC Oscillator Clock Frequency Adjustment
Electrical Characteristics
Changed 85C temperatures with 105C in the whole chapter. Added read/write characteristics temperature rfo
information on Flash in Note (3), Table 44-3, DC Characteristics and Note (1), Table 44-73, AC Flash
Characteristics. Modified Section 44.4.1 Backup Mode Current Consumption and Table 44-9 to Table 44-23
with up-to-date current consumption values.
Updated Section 44.4.2.1 Sleep Mode. rfo
In Section 44.4.4 Peripheral Power Consumption in Active Mode, updated Table 44-24, Typical Power rfo
Consumption on VDDCORE (VDDIO = 3.3V, TA = 25C)
Mechanical Characteristics
Added Figure 45-6 and associated package dimensions and soldering tables for WLCSP64 package. 8620
Soldering tables updated in Section 45. Mechanical Characteristics. rfo
Ordering Information
New ordering codes (105 C, reel conditioning, WLCSP package) added in Table 47-1, Ordering Codes for 8620, rfo
SAM4S Devices.
Errata
Added Section Issue: Watchdog Not Stopped in Wait Mode and Section Issue: Unpredictable Behavior if
9075
BOD is Disabled, VDDCORE is Lost and VDDIO is Connected.
Backpage
ARMConnected logo and corresponding text deleted. rfo
Errata
Deleted former Chapter 45 SAM4S Series Errata (was only a cross-reference to Engineering Samples 8645
Erratas), added a new detailed Section 48. Errata.
Backpage
ARMPowered logo replaced with ARMConnected logo, corresponding text updated. rfo
Introduction
In Section 2. Block Diagram, USB linked to Peripheral Bridge instead of AHB Bus Matrix in Figure 2-3, Figure 8386
2-4, Figure 3. and Figure 2-2.
Reference to the LPM bit removed in the whole datasheet. 8392
Flash rails mentioned in Section 5.1 Power Supplies. 8406
Section 9. Real Time Event Management created. 8439
WKUP[15:0] pins added on each block diagram in Section 2. Block Diagram and in Table 3-1, Signal 8459
Description List.
All diagrams updated with Real Time Events in Section 2. Block Diagram. 8484
JTAG and PA7 pins details added in Section 6.2.1 Serial Wire JTAG Debug Port (SWJ-DP) Pins. 8547
CORTEX
Section 12.8.3 Nested Vectored Interrupt Controller (NVIC) User Interface, offset information for NVIC register 8211
mapping updated in Table 12-31 Nested Vectored Interrupt Controller (NVIC) Register Mapping.
Section 12.9.1 System Control Block (SCB) User Interface, deleted lines with MMFSR, BFSR, UFSR and
updated the note in Table 12-32, System Control Block (SCB) Register Mapping.
Table 12-34 System Timer (SYST) Register Mapping: table name updated (SysTick changed to SYST).
Harmonized instructions code fonts in Section 12.6 Cortex-M4 Instruction Set. Fixed various typos. 8343
RTT
RTC 1Hz calibrated clock feature added in Section 15.1 Description, Section 15.4 Functional Description
and in RTT_MR register, see Section 15.5.1 Real-time Timer Mode Register.
RTC
New bullet Safety/security features added in Section 16.2 Embedded Characteristics. 8544
WDT
Note added in Section 17.5.3 Watchdog Timer Status Register. 8128
SUPC
Offsets updated and SYSC_WPMR in Table 18-1 System Controller Registers. Section 18.4.9 System 8253
Controller Write Protection Mode Register added.
Force Wake Up Pin removed from Section 18.1 Embedded Characteristics. 8263
In Section 18.3.3 Core Voltage Regulator Control/Backup Low-power Mode, removed informations related to 8363, 8407
WFE and WFI, deleted reference to 1.8V for voltage regulator.
Figure 18-1 Block Diagram updated. 8515
EEFC
In Section 20.5.2 EEFC Flash Command Register, table added in FCMD bitfield, details added in table in 8352
FARG bitfield.
Note concerning bit number limitation added in Section 20.4.3.5 GPNVM Bit. 8390
CMCC
8373
Updated access condition from Write-only to Read-only in Section 22.5.4 Cache Controller Status Register
and Section 22.5.10 Cache Controller Monitor Status Register. Index bitfield size increased from 4 to 5 bits in
Section 22.5.6 Cache Controller Maintenance Register 1, bitfield description completed.
0xXX - 0xFC offset replaced with 0x38 - 0xFC in the last row in Table 22-1 Register Mapping. In Figure 22- rfo
1, replaced Cortex MPPB with APB Interface in Block Diagram.
CRCCU
TRWIDTH bitfield description table completed in Section 23.6.2 Transfer Control Register. 8303
Updated Section 23.1 Description and Section 23.5.2 CRC Calculation Unit Operation. rfo
PDC
Offset data for Register Mapping updated in Table 27-1 Register Mapping. 7976
ABP bridge changed to APB bridge in Section 27.1 Description. rfo
PMC
Section 28.5.6 Software Sequence to Detect the Presence of Fast Crystal added. 8371
Updated CKGR_MOR register reset value to 0x0000_0008 in Section 29.17 Power Management Controller 8448
(PMC) User Interface.
CHIPID
Section 30.3.1 Chip ID Register, in ARCH bitfield description table, rows sharing SAM3/SAM4 names 7730
reconfigured with standalone rows for each name. 7977,
Section 30.3.1 Chip ID Register, in ARCH bitfield description table, various devices added or removed. 8034, 8383
Section 30.3.1 Chip ID Register, in SRAMSIZ bitfield description table, replaced 1K/1Kbyte with 8036
192K/192Kbyte for value1.
In Section 30.2 Embedded Characteristics, updated Table 30-1 SAM4S Chip ID Registers. rfo
PIO
DSIZE bit description updated in Section 31.7.49 PIO Parallel Capture Mode Register. 7705
Section 31.4.2 External Interrupt Lines added. Section 31.4.4 Interrupt Generation updated. rfo
SSC
Removed Table 30-4 in Section 32.7.1.1 Clock Divider. 7303
Last line (PDC register) updated in Table 32-5 Register Mapping. 7971
Reworked tables and bitfield descriptions in Section 32.9.3 SSC Receive Clock Mode Register, Section 8466
32.9.4 SSC Receive Frame Mode Register, Section 32.9.5 SSC Transmit Clock Mode Register, Section
32.9.6 SSC Transmit Frame Mode Register.
SPI
In Section 33.2 Embedded Characteristics, added the 2 first bullets, deleted the previous last bullet. 8544
TWI
7844
NVIC and AIC changed to Interrupt Controller. Section 33.10.4.5 PDC removed. This bit is only used in
Master mode removed from bitfields ENDRX, ENDTX, RXBUFF, and TXBUFE in Section 34.11.6 TWI Status
Register.
Figure 34-23 updated: SVREAD = 1 and first occurrence of RXRDY = 1. 7884
Removed 20 at the end of the 1st paragraph in Section 34.1 Description. 7921
Table 34-7 Register Mapping, replaced 0x100 - 0x124 with 0x100 - 0x128 and Reserved for the PDC with 7973
Reserved for PDC registers in the PDC line.
Section 34.10.6 Using the Peripheral DMA Controller (PDC) in Slave Mode reworked.
rfo
UART
Table 35-3 Register Mapping, PDC registers info for register mapping updated. 7967
USART
Section 36.7.1 Baud Rate Generator, replaced or 6 with or 6 times lower in the last phrase. rfo
HSMCI
Phrase not only for Write operations now removed from NOTBUSY bitfield descriptionI in Section 38.14.12 8394
HSMCI Status Register.
replaced BCNT bitfield table with the corresponding description and updated Warning note in BCNT bitfield 8431
description in Section 38.14.7 HSMCI Block Register.
In Section 38.6.3 Interrupt, replaced references to NVIC/AIC with interrupt controller. rfo
PWM
Typo corrected in line Timer0 in Table 39-4 Fault Inputs. 8438
Replaced Main OSC with Main OSC (PMC) in Table 39-4 Fault Inputs. rfo
UDP
Pull-up and pull-down spelling harmonized in the whole chapter. 7867
Added UDP_CSRx (ISOENDPT) alternate register in Section 40.7.11 UDP Endpoint Control and Status 8414
Register (ISOCHRONOUS).
ADC
Removed ...and EOC bit corresponding to the last converted channel from the last phrase of the third 8357
paragraph in Section 42.6.4 Conversion Results.
TRANSFER value set to 2 in TRANSFER bitfield description in Section 42.7.2 ADC Mode Register. 8462
Text amended in Section 42.1 Description. rfo
SLEEP and FWUP bitfield description texts in tables updated in Section 42.7.2 ADC Mode Register.
Electrical Characteristics
Whole chapter reworked to add SAM4SD32/SD16/SA16 data, various values added or updated. rfo, 8435
Clext values changed in Table 44-30. 8391
Configurations A and B updated in Section 44.4.1 Backup Mode Current Consumption. 8422
Mechanical Characteristics
QFN64 package drawing and table updated in Figure 45-5. 8529
Introduction
48 pins packages (SAM4S16A and SAM4S8A devices) removed. 8100
Note related to EWP and EWPL commands added in Section 8.1.3.1 Flash Overview on page 38. 8225
Dual bank and cache memory mentioned in Description on page 1 and Configuration Summary on page 4. rfo
Flash and SRAM memory sizes updated in Description on page 1 and Configuration Summary on page 4.
1 A instead of 3 in Description on page 1, Section 5.3 on page 27 and Section 5.6.1 on page 30.
Table titles and sub-section titles updated with new devices.
New block diagram added in Figure 2-2 on page 6.
VFBGA100 package added: Figure 4-3 on page 17 and Table 4-3 on page 20 added.
Reference to CortexM3 deleted and VDDIO value added in Section 5.6.1 Backup Mode on page 30.
Entering Wait Mode process updated and current changed from 15 to 32 A in Section 5.6.2 on page 30.
Added paragraph detailing mode selection with FLPM value in Section 5.6.3 on page 31.
Values added and notes updated in Table 5-1 on page 32.
Third paragraph frequency values updated in Section 6.1 on page 34.
SRAM upper address changed to 0x20400000, and EFC1 added in Figure 7-1 on page 37.
Note added in Section 8.1.3.1 Flash Overview on page 38.
New devices features added in Section 8.1.1 Internal SRAM on page 38, Section 8.1.3.1 Flash Overview on
page 38, Section 8.1.3.4 Lock Regions on page 42, Section 8.1.3.5 Security Bit on page 42, Section
8.1.3.11 GPNVM Bits on page 43.
EEFC replaced by EEFC0 and EEFC1 in Table 11-1 on page 48.
Cortex M-4 changed for Cortex-M4 in block diagrams: Figure 2-3 on page 7 and Figure 2-4 on page 8. rfo
Section 5.6.4 Low-power Mode Summary Table, updated the list of potential wake up sources for Sleep Mode rfo
in Table 5-1 on page 32.
Added references to S16 in the flash size description in Section 8.1.3.1 Flash Overview. rfo
Section 2. Block Diagram, replaced Time Counter B by Time Counter A in Figure 2-3 on page 7. rfo
Fixed the section structure for Section 5.6.3 Sleep Mode. rfo
CORTEX
FPU related instructions deleted in Table 12-13 on page 87. 8252
Fonts style corrected for instructions code in the whole chapter. rfo
Updated Figure 12-9 on page 97. rfo
RSTC
Updated for dual core. 8306
EXTRST field description updated in Section 14.5.1 Reset Controller Control Register on page 283. 8340
RTC
In Section 16.6.2 RTC Mode Register on page 303, formulas associated with conditions HIGHPPM = 1 and 7950
HIGHPPM = 0 have been swapped, text has been clarified.
In Section 16.5.7 RTC Accurate Clock Calibration on page 299, paragraph describing RTC clock calibration 7952
circuitry correction updated with mention of crystal drift.
SUPC
References to WFE instructions deleted in Section 18.3.3 Core Voltage Regulator Control/Backup Low-power rfo
Mode on page 328.
Supply monitor threshold values modified in Section 18.3.4 Supply Monitor on page 328.
SMTH bit table replaced by a cross-reference to Electrical characteristics in Section 18.4.4 Supply Controller
Supply Monitor Mode Register on page 338.
Typo in Section 18.4.8 Supply Controller Status Register on page 343 is now fixed.
8024
half replaced with first half in Section 18.4.6 Supply Controller Wake-up Mode Register on page 340 and in
Section 18.4.7.2 Low Power Debouncer Inputs on page 295. 8067
square waveform .. changed to duty cycle .. in Section 18.4.7.2 Low Power Debouncer Inputs on page 8082
295. 8226
Switching time of slow crystal oscillator updated in Section 18.3.2 Slow Clock Generator on page 328. 8266
EEFC
Added GPNVM command line in Section FARG: Flash Command Argument on page 368. 8076
Unique identifier address changed in Section 20.4.3.8 Unique Identifier on page 363. 8274
User Signature address changed in Section 20.4.3.9 User Signature on page 363.
Changed the System Controller base address from 0x400E0800 to 0x400E0A00 in Section 20.5 Enhanced rfo
Embedded Flash Controller (EEFC) User Interface on page 365.
FFPI
All references, tables, figures related to 48-bit devices cleared in this whole chapter. rfo
CMCC
New chapter.
CRCCU
Typos: CCIT802 corrected to CCITT802, CCIT16 corrected to CCITT16 in Section 23.5.1 CRC Calculation 7803
Unit on page 399 and Section 23.7.10 CRCCU Mode Register on page 414. TRC_RC corrected to TR_CRC
in Section 23.7.10 CRCCU Mode Register on page 414.
SMC
turned out changed to switched to output mode in Section 26.8.4 Write Mode on page 450. 7925
Removed DBW which is not required for 8-bit only in Section 26.15.4 SMC MODE Register on page 476. 8307
PMC
Added a note in Section 29.17.7 PMC Clock Generator Main Oscillator Register on page 528. 7848
Max MULA/MULB value changed from 2047 to 62 in Section 29.17.9 PMC Clock Generator PLLA Register on 8064
page 531 and Section 29.17.10 PMC Clock Generator PLLB Register on page 532.
Step 5 in Section 28.2.13 Programming Sequence on page 463: Master Clock option added in CSS field. 8170
Third paragraph added in Section 28.2.12 Main Crystal Clock Failure Detector on page 462. WAITMODE bit 8208
added in Section 29.17.7 PMC Clock Generator Main Oscillator Register on page 528.
CHIPID
Table 30-1 on page 552 modified. rfo
TC
Changed TIOA1 in TIOB1 in Section 37.6.14.1 Description on page 860 and Section 37.6.14.4 Position and 8101
Rotation Measurement on page 865.
PWM
Font size enlarged in Figure 39-14 on page 964. 7910
CMPS replaced with CMPM in whole document. 8021
ADC
EOCAL pin and description added in Section 42.7.12 ADC Interrupt Status Register on page 1106. rfo
PDC register row added in Section 42.7 Analog-to-Digital Converter (ADC) User Interface on page 1092. 7969
Added comment in Section 42.7.15 ADC Compare Window Register on page 1109. 8045
Features added in Section 42.2 Embedded Characteristics on page 1077. 8088
Comments added, and removed offset in Section 42.6.11 Automatic Calibration on page 1090. 8133
Electrical Characteristics
Whole chapter updated. In tables, values updated, and missing values added. 8085, 8245
Comment for flash erasing added in Section 44.12.9 Embedded Flash Characteristics on page 1199. 8223
Updated conditions for VLINE-TR and VLOAD-TR in Table 44-4 on page 1143. rfo
Removed the ADVREF Current row from Table 43-30 on page 1059. rfo
Updated the Offset Error parameter description in Table 43-32 on page 1061.
Updated the TACCURACY parameter description in Table 44-6 on page 1144. rfo
Updated the temperature sensor description in Section 44.11 Temperature Sensor on page 1180 and the
slope accuracy parameter data in Table 44-60 on page 1180.
Mechanical Characteristics
48 pins packages (SAM4S16A and SAM4S8A devices) removed. 8100
100-ball VFBGA package drawing added in Figure 45-3 on page 1203. rfo
Ordering Information
Table 47-1 on page 1216 completed with new devices and reordered. rfo
Errata rfo
Removed the Flash Memory section.
Removed the Errata section and added references for two separate errata documents in Section 47. Ordering rfo
Information on page 1216.
Specified the preliminary status of the datasheet. rfo
Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Safety Features Highlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1. Configuration Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4. Package and Pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1 100-lead Packages and Pinouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 64-lead Packages and Pinouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3 48-lead Packages and Pinouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5. Power Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.1 Power Supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.2 Power-up Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.3 Voltage Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.4 Typical Powering Schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.5 Active Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.6 Low-power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.7 Wake-up Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.8 Fast Start-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6. Input/Output Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.1 General Purpose I/O Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.2 System I/O Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
6.3 Test Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.4 NRST Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.5 ERASE Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.6 Anti-tamper Pins/Low-power Tamper Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7. Product Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8. Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.1 Embedded Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.2 External Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
11. Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
11.1 Peripheral Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
11.2 Peripheral Signal Multiplexing on I/O Lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
XXXXXX
Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 | www.atmel.com
Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and
other countries. ARM, ARM Connected logo, and others are the registered trademarks or trademarks of ARM Ltd. Windows is a registered trademark of
Microsoft Corporation in U.S. and/or other countries. Other terms and product names may be trademarks of others.
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 THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE
ATMEL WEBSITE, 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 INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES
FOR LOSS AND 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 products 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 products are not intended,
authorized, or warranted for use as components in applications intended to support or sustain life.
SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where
the failure of such products would reasonably be expected to result in significant personal injury or death (Safety-Critical Applications) without an Atmel officer's specific written
consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation of nuclear facilities and weapons systems.
Atmel products are not designed nor intended for use in military or aerospace applications or environments unless specifically designated by Atmel as military-grade. Atmel products are
not designed nor intended for use in automotive applications unless specifically designated by Atmel as automotive-grade.