Atmel 11121 32 Bit Cortex A5 Microcontroller SAMA5D3 Datasheet
Atmel 11121 32 Bit Cortex A5 Microcontroller SAMA5D3 Datasheet
Atmel 11121 32 Bit Cortex A5 Microcontroller SAMA5D3 Datasheet
SAMA5D3 Series
DATASHEET
Description
The Atmel SAMA5D3 series is a high-performance, power-efficient embedded MPU based on the ARM Cortex -A5 processor, achieving 536 MHz with power consumption levels below 0.5 mW in low-power mode. The device features a floating point unit for high-precision computing and accelerated data processing, and a high data bandwidth architecture. It integrates advanced user interface and connectivity peripherals and security features. The SAMA5D3 series features an internal multi-layer bus architecture associated with 39 DMA channels to sustain the high bandwidth required by the processor and the high-speed peripherals. The device offers support for DDR2/LPDDR/LPDDR2 and MLC NAND Flash memory with 24-bit ECC. The comprehensive peripheral set includes an LCD controller with overlays for hardware-accelerated image composition, a touchscreen interface and a CMOS sensor interface. Connectivity peripherals include Gigabit EMAC with IEEE1588, 10/100 EMAC, multiple CAN, UART, SPI and I2C. With its secure boot mechanism, hardware accelerated engines for encryption (AES, TDES) and hash function (SHA), the SAMA5D3 ensures anti-cloning, code protection and secure external data transfers. The SAMA5D3 series is optimized for control panel/HMI applications and applications that require high levels of connectivity in the industrial and consumer markets. Its lowpower consumption levels make the SAMA5D3 particularly suited for battery-powered devices. There are four SAMA5D3 devices in this series. Table 1-1 SAMA5D3 Devices shows the differences in the embedded features. All other features are available on all derivatives; this includes the three USB ports as well as the encryption engine and secure boot features.
11121BATARM08-Mar-13
1.
Features
z
Core
z
z z
32 Kbyte Data Cache, 32 Kbyte Instruction Cache, Virtual Memory System Architecture (VMSA) Fully Integrated MMU and Floating Point Unit (VFPv4) One 160 Kbyte Internal ROM Single-cycle Access at System Speed, Embedded Boot Loader: Boot on NAND Flash, SDCard, eMMC, serial DataFlash, selectable Order One 128 Kbyte Internal SRAM, Single-cycle Access at System Speed High Bandwidth 32-bit Multi-port Dynamic Ram Controller supporting 512 Mbyte 8 bank DDR2/LPDDR/LPDDR2 Independent Static Memory Controller with SLC/MLC NAND Support with up to 24-bit Error Correcting Code (PMECC) Power-on Reset Cells, Reset Controller, Shut Down Controller, Periodic Interval Timer, Watchdog Timer and Real-time Clock Boot Mode Select Option, Remap Command Internal Low-power 32 kHz RC Oscillator and Fast 12 MHz RC Oscillators Selectable 32768 Hz Low-power Oscillator and 12 MHz Oscillator One 400 to 1000 MHz PLL for the System and one PLL at 480 MHz optimized for USB High Speed 39 DMA Channels including two 8-channel 64-bit Central DMA Controllers 64-bit Advanced Interrupt Controller Three Programmable External Clock Signals Programmable Fuse Box with 256 fuse bits, 192 of them available for Customer Shut Down Controller Battery Backup Registers Clock Generator and Power Management Controller Very Slow Clock Operating Mode, Software Programmable Power Optimization Capabilities LCD TFT Controller with Overlay, Alpha-blending, Rotation, Scaling and Color Space Conversion ITU-R BT. 601/656 Image Sensor Interface Three HS/FS/LS USB Ports with On-Chip Transceivers
z z
Memories
z z z z
Peripherals
z z z
One Device Controller One Host Controller with Integrated Root Hub (3 Downstream Ports)
z z z z z z z z z z
One 10/100/1000 Mbps Gigabit Ethernet Mac Controller (GMAC) with IEEE1588 support One 10/100 Mbps Ethernet Mac Controller (EMAC) Two CAN Controllers with 8 Mailboxes, fully Compliant with CAN 2.0 Part A and 2.0 Part B Softmodem Interface Three High Speed Memory Card Hosts (eMMC 4.3 and SD 2.0) Two Master/Slave Serial Peripheral Interface Two Synchronous Serial Controllers Three Two-wire Interface up to 400 Kbits supporting I2C Protocol and SMBUS Four USARTs, two UARTs, one DBGU Two Three-channel 32-bit Timer/Counters
z z z
One Four-channel 16-bit PWM Controller One 12-channel 12-bit Analog-to-Digital Converter with Resistive Touch-Screen function Write Protected Registers TRNG: True Random Number Generator Encryption Engine
z z z
Security
z z
AES: 256-bit, 192-bit, 128-bit Key Algorithm, Compliant with FIPS PUB 197 Specifications TDES: Two-key or Three-key Algorithms, Compliant with FIPS PUB 46-3 Specifications SHA: Supports Secure Hash Algorithm (SHA1, SHA224, SHA256, SHA384, SHA512)
Atmel Secure Boot Solution Five 32-bit Parallel Input/Output Controllers 160 I/Os Input Change Interrupt Capability on Each I/O Line, Selectable Schmitt Trigger Input Individually Programmable Open-drain, Pull-up and Pull-down Resistor, Synchronous Output, Filtering Slew Rate Control on High Speed I/Os Impedance Control on DDR I/Os 324-ball LFBGA, pitch 0.8 mm
I/O
z z z z z z
Package
z
Table 1-1.
2.
Block Diagram
TST
BMS
HH S HH DPC SD H H MC HH SDP SD B MB VB G
SysC
FIQ IRQ
PIO
JTAG / SWD
AIC
In-Circuit Emulator
HS Trans
HS Trans
HS Trans
PIO
DBGU
PC PB
Cortex-A5
PLLA PLLUTMI
ICache 32 KB MMU BIU
VFP DCache 32 KB
XIN XOUT
Osc12 MHz
PMC
DMA
DMA
DMA
DMA
I/D
PIT
4 GPBR EBI
DDR_DQSN[3..0] DDR_CS DDR_CLK,DDR_CLKN DDR_CKE DDR_RAS, DDR_CAS DDR_WE DDR_BA[2..0] D0-D15 A21/NANDALE A22/NANDCLE NRD/NANDOE NWE/NWR0/NANDWE NCS3/NANDCS NANDRDY A0/NBS0 A1-A20 A23-A25 NWR1/NBS1 NCS0,NCS1,NCS2 NWAIT
Multi-Layer Matrix
RTC RSTC
TRNG SHA AES TDES DMA
PIOB PIOD
ROM 160 KB
SRAM0 64 KB
SRAM1 64 KB
8-CH DMA0
8-CH DMA1
Peripheral Bridge
PIO
DMA
DMA MCI0/MCI1/MCI2 SD/SDIO eMMC TC0, TC1 TC2, TC3 TC4, TC5
UART0 UART1
Real-time Events
PIO
P
N CA RX NT 0-C X0 A -C NR A X TW NT 1 TW D0 X1 CK -TW 0TW D2 CK CT 2 S RT 03 SCS03 RDK0X 3 TX 0-3 UR D0 D -3 UT X0NP UR X CS D0 D X 1, NP -UT 1 XD CS 1 2, NP C NP S3 CS SP 0 C M K O M SI TK ISO 0 TF -TK TD 0-T 1 F 0 RD -T 1 0 D RF -RD1 0 1 RK -RF 0 1 M -RK CI 1 M 0_C CI D M 1_ A CI C D 2 M _C A C D M I0_ A CI C M MC 1_CK CI I K M 0_D 2_C CI A K M 1_D [7..0 CI A ] 2 [ TI _D 3..0 O A ] TI A0 [3.. O -T 0] B TC 0 IO -T A PW LK0 IOB5 M -TC 5 LK PW H0 5 PW ML PW M 0-P MH FI W 3 0- M PW L3 M TS FI AD 3 TR AD IG 0U AD L 1 AD UR 2 AD LL GP 3 AD A LR 5- D4 G P TS PAD I AD 11 VR EF
DIB
SPI0_, SPI1_
CA
DI
BN
3.
Signal Description
Table 3-1 gives details on the signal names classified by peripheral.
Signal Description List Function Type Active Level Frequency (MHz) Comments
Table 3-1.
Signal Name Clocks, Oscillators and PLLs XIN XOUT XIN32 XOUT32 VBG PCK0 - PCK2 Main Oscillator Input Main Oscillator Output Slow Clock Oscillator Input Slow Clock Oscillator Output Bias Voltage Reference for USB Programmable Clock Output Input Output Input Output Analog Output
Shutdown, Wake-up Logic SHDN WKUP Shut-Down Control Wake-Up Input ICE and JTAG TCK/SWCLK TDI TDO TMS/SWDIO JTAGSEL Test Clock/Serial Wire Clock Test Data In Test Data Out Test Mode Select/Serial Wire Input/Output JTAG Selection Reset/Test NRST TST NTRST BMS Microcontroller Reset Test Mode Select Test Reset Signal Boot Mode Select I/O Input Input Input Debug Unit - DBGU DRXD DTXD Debug Receive Data Debug Transmit Data Input Output Advanced Interrupt Controller - AIC IRQ FIQ External Interrupt Input Fast Interrupt Input Input Input Low Input Input Output I/O Input Output Input
PIO Controller - PIOA - PIOB - PIOC - PIOD - PIOE PA0 - PAxx PB0 - PBxx PC0 - PCxx PD0 - PDxx PE0 - PExx Parallel IO Controller A Parallel IO Controller B Parallel IO Controller C Parallel IO Controller D Parallel IO Controller E I/O I/O I/O I/O I/O
Table 3-1.
Signal Description List (Continued) Function Type Active Level Frequency (MHz) Comments
Signal Name External Bus Interface - EBI D0 - D15 A0 - A25 NWAIT Data Bus Address Bus External Wait Signal I/O Output Input Static Memory Controller - HSMC NCS0 - NCS3 NWR0 - NWR1 NRD NWE NBS0 - NBS1 NANDOE NANDWE Chip Select Lines Write Signal Read Signal Write Enable Byte Mask Signal NAND Flash Output Enable NAND Flash Write Enable Output Output Output Output Output Output Output DDR2/LPDDR Controller DDR_VREF DDR_CALP DDR_CALN DDR_CK, DDR_CKN DDR_CKE DDR_CS DDR_BA[2..0] DDR_WE DDR_RAS, DDR_CAS DDR_A[13..0] DDR_D[31..0] DQS[3..0] DQSN[3..0] DQM[3..0] Reference Voltage Positive Calibration Reference Negative Calibration Reference DDR2 differential clock DDR2 Clock Enable DDR2 Controller Chip Select Bank Select DDR2 Write Enable Row and Column Signal DDR2 Address Bus DDR2 Data Bus Differential Data Strobe DQSN must be connected to DDR_VREF for DDR2 memories Write Data Mask Input Input Input Output Output Output Output Output Output Output I/O/-PD I/O- PD I/O- PD Output
Low
High Speed Multimedia Card Interface - HSMCI0-2 MCI0_CK, MCI1_CK, MCI2_CK MCI0_CDA,MCI1_C DA, MCI2_CDA MCI0_DA[7..0] MCI1_DA[3..0] MCI2_DA[3..0) Multimedia Card Clock Multimedia Card Command Multimedia Card 0 Data Multimedia Card 1 Data Multimedia Card 2 Data I/O I/O I/O I/O I/O
Table 3-1.
Signal Description List (Continued) Function Type Active Level Frequency (MHz) Comments
Signal Name
Universal Synchronous Asynchronous Receiver Transmitter- USART0-3 SCKx TXDx RXDx RTSx CTSx USARTx Serial Clock USARTx Transmit Data USARTx Receive Data USARTx Request To Send USARTx Clear To Send I/O Output Input Output Input
Universal Asynchronous Receiver Transmitter - UARTx [1..0] UTXDx URXDx UARTx Transmit Data UARTx Receive Data Output Input
Synchronous Serial Controller - SSCx [1..0] TDx RDx TKx RKx TFx RFx SSC Transmit Data SSC Receive Data SSC Transmit Clock SSC Receive Clock SSC Transmit Frame Sync SSC Receive Frame Sync Timer/Counter - TCx [5..0] TCLKx TIOAx TIOBx TC Channel x External Clock Input TC Channel x I/O Line A TC Channel x I/O Line B Input I/O I/O Output Input I/O I/O I/O I/O
Serial Peripheral Interface - SPIx [1..0] SPIx_MISO SPIx_MOSI SPIx_SPCK SPIx_NPCS0 SPIx_NPCS[3..1] Master In Slave Out Master Out Slave In SPI Serial Clock SPI Peripheral Chip Select 0 SPI Peripheral Chip Select I/O I/O I/O I/O Output Low Low
Two-Wire Interface -TWIx [2..0] TWDx TWCKx Two-wire Serial Data Two-wire Serial Clock I/O I/O CAN controller - CANx CANRXx CANTXx CAN input CAN output Input Output Soft Modem - SMD DIBN DIBP Soft Modem Signal Soft Modem Signal I/O I/O
Table 3-1.
Signal Description List (Continued) Function Type Active Level Frequency (MHz) Comments
Signal Name
Pulse Width Modulation Controller- PWMC PWMH[3..0] PWML[3..0] PWMFIx PWM Waveform Output High PWM Waveform Output LOW PWM Fault Input Output Output Input USB Host High Speed Port - UHPHS HHSDPA HHSDMA HHSDPB HHSDMB HHSDPC HHSDMC USB Host Port A High Speed Data + USB Host Port A High Speed Data USB Host Port B High Speed Data + USB Host Port B High Speed Data USB Host Port C High Speed Data + USB Host Port C High Speed Data Analog Analog Analog Analog Analog Analog
USB Device High Speed Port - UDPHS DHSDP DHSDM USB Device High Speed Data + USB Device High Speed Data Analog Analog
GIgabit Ethernet 10/100/1000 - GMAC GTXCK G125CK G125CKO GTXEN GTX[7..0] GTXER GRXCK GRXDV GRX[7..0] GRXER GCRS GCOL GMDC GMDIO Transmit Clock or Reference Clock 125 MHz input Clock 125 MHz output Clock Transmit Enable Transmit Data Transmit Coding Error Receive Clock Receive Data Valid Receive Data Receive Error Carrier Sense and Data Valid Collision Detect Management Data Clock Management Data Input/Output Input Input Output Output Output Output Input Input Input Input Input Input Output I/O
RMII Ethernet 10/100 - EMAC EREFCK ETXEN ETX[1..0] ECRSDV ERX[1..0] ERXER Transmit Clock or Reference Clock Transmit Enable Transmit Data Carrier Sense/Data Valid Receive Data Receive Error Input Output Output Input Input Input
Table 3-1.
Signal Description List (Continued) Function Type Output I/O Active Level Frequency (MHz) Comments
Signal Name EMDC EMDIO Management Data Clock Management Data Input/Output
LCD Controller - LCDC LCDDAT[23..0] LCDVSYNC LCDHSYNC LCDPCK LCDDEN LCDPWM LCDDISP LCD Data Bus LCD Vertical Synchronization LCD Horizontal Synchronization LCD pixel Clock LCD Data Enable LCDPWM for Contrast Control LCD Display ON/OFF Output Output Output Output Output Output Output Image Sensor Interface - ISI ISI_D[11..0] ISI_HSYNC ISI_VSYNC ISI_PCK Image Sensor Data Image Sensor Horizontal Synchro Image Sensor Vertical Synchro Image Sensor Data clock Input input input input
Touch Screen Analog-to-Digital Converter - ADC AD0UL AD1UR AD2LL AD3LR AD4PI AD5-AD11 ADTRG ADVREF Upper Left Touch Panel Upper Right Touch Panel Lower Left Touch Panel Lower Right Touch Panel Panel Input 7 Analog Inputs ADC Trigger ADC Reference Analog Analog Analog Analog Analog Analog Input Analog
4.
4.1
1 2
3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18
10
4.2
Table 4-1.
Pin
E3 F5 D2 F4 D1 J10 G4 J9 F3 J8 E2 K8 F2 G6 E1 H5 H3 H6 H4 H7 H2 J6 G2 J5 F1 J4 G3 J3 G1 K4 H1 K3 T2 N7 T3 N6 P5 T4 R4 U1
Power Rail
VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1
I/O Type
GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO_CLK2 GPIO GPIO GPIO GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC
Signal
PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 PA8 PA9 PA10 PA11 PA12 PA13 PA14 PA15 PA16 PA17 PA18 PA19 PA20 PA21 PA22 PA23 PA24 PA25 PA26 PA27 PA28 PA29 PA30 PA31 PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7
Dir
I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O
Signal
Dir
Signal
LCDDAT0 LCDDAT1 LCDDAT2 LCDDAT3 LCDDAT4 LCDDAT5 LCDDAT6 LCDDAT7 LCDDAT8 LCDDAT9 LCDDAT10 LCDDAT11 LCDDAT12 LCDDAT13 LCDDAT14 LCDDAT15 LCDDAT16 LCDDAT17 LCDDAT18 LCDDAT19 LCDDAT20 LCDDAT21 LCDDAT22 LCDDAT23 LCDPWM LCDDISP LCDVSYNC LCDHSYNC LCDPCK LCDDEN TWD0 TWCK0 GTX0 GTX1 GTX2 GTX3 GRX0 GRX1 GRX2 GRX3
Dir
O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O I/O O O O O O I I I I
Signal
Dir
Signal
Dir
11
Table 4-1.
Pin
R5 P3 R6 V3 P6 V1 R7 U3 P7 V2 V5 T6 N8 U4 M7 U5 M8 T5 N9 V4 M9 P8 M10 R9 D8 A4 E8 A3 A2 F8 B3 G8 B4 F7 A1 D7 C6 E7 B2 F6 B1 E6 C3
Power Rail
VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0
I/O Type
GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GMAC GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO MCI_CLK GPIO GPIO GPIO
Signal
PB8 PB9 PB10 PB11 PB12 PB13 PB14 PB15 PB16 PB17 PB18 PB19 PB20 PB21 PB22 PB23 PB24 PB25 PB26 PB27 PB28 PB29 PB30 PB31 PC0 PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17 PC18
Dir
I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O
Signal
Dir
Signal
GTXCK GTXEN GTXER GRXCK GRXDV GRXER GCRS GCOL GMDC GMDIO G125CK MCI1_CDA MCI1_DA0 MCI1_DA1 MCI1_DA2 MCI1_DA3 MCI1_CK SCK1 CTS1 RTS1 RXD1 TXD1 DRXD DTXD ETX0 ETX1 ERX0 ERX1 ETXEN ECRSDV ERXER EREFCK EMDC EMDIO MCI2_CDA MCI2_DA0 MCI2_DA1 MCI2_DA2 MCI2_DA3 MCI2_CK TK0 TF0 TD0
Dir
I O O I I I I I O I/O I I/O I/O I/O I/O I/O I/O I/O I O I O I O O O I I O I I I O I/O I/O I/O I/O I/O I/O I/O I/O I/O O
Signal
PWMH2 PWML2 RF1 RD1 PWMH3 PWML3 CANRX1 CANTX1
Dir
O O I/O I O O I O
Signal
Dir
12
Table 4-1.
Pin
D6 C4 D5 C2 G9 C1 H10 H9 D4 H8 G5 D3 E4 K5 P1 K6 R1 L7 P2 L8 R2 K7 U2 K9 M5 K10 N4 L9 N3 L10 N5 M6 T1 N2 M3 M2 L3 M1 N1 L1 L2 K1 K2
Power Rail
VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDIOP1 VDDANA VDDANA VDDANA VDDANA VDDANA VDDANA VDDANA VDDANA VDDANA VDDANA
I/O Type
GPIO GPIO GPIO GPIO GPIO GPIO_CLK GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO MCI_CLK GPIO GPIO GPIO_CLK GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA GPIO_ANA
Signal
PC19 PC20 PC21 PC22 PC23 PC24 PC25 PC26 PC27 PC28 PC29 PC30 PC31 PD0 PD1 PD2 PD3 PD4 PD5 PD6 PD7 PD8 PD9 PD10 PD11 PD12 PD13 PD14 PD15 PD16 PD17 PD18 PD19 PD20 PD21 PD22 PD23 PD24 PD25 PD26 PD27 PD28 PD29
Dir
I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O
Signal
Dir
Signal
RK0 RF0 RD0 SPI1_MISO SPI1_MOSI SPI1_SPCK SPI1_NPCS0 SPI1_NPCS1 SPI1_NPCS2 SPI1_NPCS3 URXD0 UTXD0 FIQ MCI0_CDA MCI0_DA0 MCI0_DA1 MCI0_DA2 MCI0_DA3 MCI0_DA4 MCI0_DA5 MCI0_DA6 MCI0_DA7 MCI0_CK SPI0_MISO SPI0_MOSI SPI0_SPCK SPI0_NPCS0 SCK0 CTS0 RTS0 RXD0 TXD0 ADTRG AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 AD8 AD9
Dir
I/O I/O I I/O I/O I/O I/O O O O I O I I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I O I O I I I I I I I I I I I
Signal
Dir
Signal
Dir
13
Table 4-1.
Pin
J1 J2 P13 R14 R13 V18 P14 U18 T18 R15 P17 P15 P18 R16 N16 R17 N17 R18 N18 P16 M18 N15 M15 N14 M17 M13 M16 N12 M14 M12 L13 L15 L14 L16 U15 U9 U8 V8 U16 V16 T12 T10 V9
Power Rail
VDDANA VDDANA VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDBU VDDIOP0 VDDIOP0 VDDIOP0 VDDBU VDDBU VDDBU VDDBU VDDIOP0
I/O Type
GPIO_ANA GPIO_ANA EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI SYSC SYSC CLOCK CLOCK CLOCK CLOCK SYSC SYSC RSTJTAG
Signal
PD30 PD31 PE0 PE1 PE2 PE3 PE4 PE5 PE6 PE7 PE8 PE9 PE10 PE11 PE12 PE13 PE14 PE15 PE16 PE17 PE18 PE19 PE20 PE21 PE22 PE23 PE24 PE25 PE26 PE27 PE28 PE29 PE30 PE31 TST BMS XIN XOUT XIN32 XOUT32 SHDN WKUP NRST
Dir
I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I I I O I O O I I/O
Signal
Dir
Signal
AD10 AD11 A0/NBS0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21/NANDALE A22/NANDCLE A23 A24 A25 NCS0 NCS1 NCS2 NWR1/NBS1 NWAIT IRQ
Dir
I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O I I
Signal
PCK0 PCK1
Dir
O O
Signal
Dir
14
Table 4-1.
Pin
P11 R8 M11 N10 P9 T9 V6 U6 K12 K15 K14 K16 K13 K17 J12 K18 J14 J16 J13 J17 J15 J18 H16 H18 L12 L18 L17 K11 C13 B10 C11 A9 D11 B9 E10 D10 A8 C10 B8 F11 A7 D9 A6
Power Rail
VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDIOP0 VDDBU VDDIOP0 VDDIOP0 VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIOM VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR
I/O Type
RSTJTAG RSTJTAG RSTJTAG RSTJTAG RSTJTAG SYSC DIB DIB EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI EBI
Signal
NTRST TDI TDO TMS TCK JTAGSEL DIBP DIBN D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 NCS3/NANDCS NANDRDY NRD/NANDOE NWE/NANDWE DDR_VREF
Dir
I I O I I I O O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O O I O O I O O O O O O O O O O O O O O
Signal
Dir
Signal
Dir
Signal
Dir
Signal
Dir
DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO
DDR_A0 DDR_A1 DDR_A2 DDR_A3 DDR_A4 DDR_A5 DDR_A6 DDR_A7 DDR_A8 DDR_A9 DDR_A10 DDR_A11 DDR_A12 DDR_A13
15
Table 4-1.
Pin
H12 H17 H13 G17 G16 H15 F17 G15 F16 E17 G14 E16 D17 C18 D16 C17 B16 B18 C15 A18 C16 C14 D15 B14 A15 A14 E12 A11 B11 F12 A10 E11 G12 E15 B15 D12 E18 G18 B17 B13 D18 F18 A17
Power Rail
VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR
I/O Type
DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO
Signal
DDR_D0 DDR_D1 DDR_D2 DDR_D3 DDR_D4 DDR_D5 DDR_D6 DDR_D7 DDR_D8 DDR_D9 DDR_D10 DDR_D11 DDR_D12 DDR_D13 DDR_D14 DDR_D15 DDR_D16 DDR_D17 DDR_D18 DDR_D19 DDR_D20 DDR_D21 DDR_D22 DDR_D23 DDR_D24 DDR_D25 DDR_D26 DDR_D27 DDR_D28 DDR_D29 DDR_D30 DDR_D31 DDR_DQM0 DDR_DQM1 DDR_DQM2 DDR_DQM3 DDR_DQS0 DDR_DQS1 DDR_DQS2 DDR_DQS3 DDR_DQSN0 DDR_DQSN1 DDR_DQSN2
Dir
I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O O O O O I/O I/O I/O I/O I/O I/O I/O
Signal
Dir
Signal
Dir
Signal
Dir
Signal
Dir
16
Table 4-1.
Pin
A13 C8 B12 A12 B7 C12 E13 G11 A5 B5 E9 B6 F9 R11 U14 V14 U12 V12 U10 V10 V15 T13 C5, C7, D14, T15, T7, U17, V7 A16, C9, N13, T14, T8, V17 D13, F14, G10, G13, H11 E14, F10, F13, F15, H14 P12, T16 J11, T17 G7, V11 L11, M4
Power Rail
VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VDDIODDR VBG VDDUTMII VDDUTMII VDDUTMII VDDUTMII VDDUTMII VDDUTMII VDDBU GNDBU
I/O Type
DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO DDR_IO VBG USBHS USBHS USBHS USBHS USBHS USBHS power supply ground
Signal
DDR_DQSN3 DDR_CS DDR_CLK DDR_CLKN DDR_CKE DDR_CALN DDR_CALP DDR_RAS DDR_CAS DDR_WE DDR_BA0 DDR_BA1 DDR_BA2 VBG HHSDPC HHSDMC HHSDPB HHSDMB HHSDPA HHSDMA VDDBU GNDBU
Dir
I/O O O O O I I O O O O O O I I/O I/O I/O I/O I/O I/O I I
Signal
Dir
Signal
Dir
Signal
Dir
Signal
Dir
VDDCORE
power supply
VDDCORE
GNDCORE
ground
GNDCORE
VDDIODDR
power supply
VDDIODDR
GNDIODDR
ground
GNDIODDR
VDDIOM
power supply
VDDIOM
GNDIOM
ground
GNDIOM
VDDIOP0
power supply
VDDIOP0
VDDIOP1
power supply
VDDIOP1
17
Table 4-1.
Pin
E5, J7, N11, U7 V13 U13 R12 R10 P10 U11 T11 L6 L4 L5 R3 P4
Power Rail
GNDIOP
I/O Type
Ground
Signal
GNDIOP
Dir
I
Signal
Dir
Signal
Dir
Signal
Dir
Signal
Dir
VDDUTMIC VDDUTMII GNDUTMI VDDPLLA GNDPLL VDDOSC GNDOSC VDDANA GNDANA VDDANA VDDFUSE GNDFUSE
Power supply Power supply Ground Power supply Ground Power supply Ground Power supply Ground Power supply Power supply Ground
VDDUTMIC VDDUTMII GNDUTMI VDDPLLA GNDPLL VDDOSC GNDOSC VDDANA GNDANA ADVREF VDDFUSE GNDFUSE
I I I I I I I I I I I I
I I I I I I I I I I I I
18
4.3
Input/Output Description
SAMA5 I/O Types Description
Voltage Range 1.65-3.6V 1.65-3.6V 1.65-3.6V 3.0-3.6V 1.65-1.95V, 3.0-3.6V 3.0-3.6V 1.65-3.6V 3.0-3.6V 1.65-3.6V 3.0-3.6V I/O I/O I/O I Pull-up Analog Pull-up Switchable Switchable Switchable Switchable Switchable Reset State Typ Value (Ohm) 100K 100K 100K 100K 100K 100K Switchable Reset State Reset State 100K 100K 15K Reset State Reset State Pull-down Switchable Switchable Switchable Pull-down Typ Value (Ohm) 100K 100K 100K Schmitt Trigger Switchable Switchable Switchable Switchable
Table 4-2.
I/O Type GPIO GPIO_CLK GPIO_CLK2 GPIO_ANA EBI RSTJTAG SYSC USBHS CLOCK DIB
When Reset State is indicated, the configuration is defined by the Reset State column of the Pin Description table (see Table 4-1 on page 11).
Table 4-3.
I/O Type GPIO MCI_CLK GPIO_CLK GPIO_CLK2 GPIO_ANA
50 20 10 10 10 10 20 50 15
All EBI signals All DDR signals NRST, NTRST, BMS TCK, TDI, TMS, TDO WKUP, SHDN, JTAGSEL, TST, SHDN VBG HHSDPC, HHSDPB, HHSDPA/DHSDP, HHSDMC, HHSDMB, HHSDMA/DHSDM XIN, XOUT, XIN32, XOUT32 Gigabit Ethernet I/Os
19
5.
5.1
Power Considerations
Power Supplies
Table 5-1 defines the power supply rails and the estimated power consumption at typical voltage.
Table 5-1. Name SAMA5D3 Power supplies Voltage Range, Nominal 1.1-1.32V, 1.2V 1.7-1.9V, 1.8V 1.14-1.30, 1.2V 1.65-1.95V, 1.8V 3.0-3.6V, 3.3V 1.65-3.6V 1.65-3.6V 1.65-3.6V 1.1-1.32V, 1.2V 3.0-3.6V, 3.3V 1.1-1.32V, 1.2V 1.65-3.6V 3.0-3.6V, 3.3V 2.25-2.75V, 2.5V Associated Ground Powers The core, including the processor, the embedded memories and the peripherals LPDDR/DDR2 Interface I/O lines LPDDR2 Interface I/O lines NAND and HSMC Interface I/O lines Peripheral I/O lines Peripheral I/O lines The Slow Clock oscillator, the internal 32 kHz RC Oscillator and a part of the System Controller The USB device and host UTMI+ core The UTMI PLL The USB device and host UTMI+ interface The PLLA cell Main Oscillator cell and VBG if 3.0V<VDDOSC<= 3.6V The Analog to Digital Converter Fuse box for programming. VDDFUSE GNDFUSE It can be tied to ground with a 100 resistor for fuse reading only.
VDDCORE VDDIODDR
GNDCORE GNDIODDR
5.2
Power-up Consideration
The user must first activate VDDIOP and VDDIOM, then VDDPLL and VDDCORE with the constraint that VDDPLL is established no later than 1 ms after VDDCORE. The VDDCORE and VDDBU power supplies rising time must be defined according to the Core and Backup Power-OnReset characteristics to ensure VDDCORE or VDDBU has reached VIH after the POR reset time. Please refer to the Core Power Supply POR Characteristics and Backup Power Supply POR Characteristics sections of the product datasheet for power-up constraints.
5.3
Power-down Consideration
The user must remove VDDPLL first, then VDDCORE, and at last VDDIOP and VDDIOM, to ensure a reliable operation of the device.
20
6.
Memories
0x0000 0000
Boot Memory
0x0010 0000
(1)
ROM
0x0020 0000
Internal Memories
0x0FFF FFFF 0x1000 0000
256 MBytes
NFC SRAM
0x0030 0000
Peripheral Mapping
256 MBytes
0xF000 0000
HSMCI0
0xF000 4000 0xF000 8000
DDRCS
0xF000 C000
512 MBytes
0xF001 0000
0x0070 0000
UHP EHCI
0x0080 0000 0x0090 0000
0x00A0 0000
256 MBytes
0xF001 C000
TWI1
0x0FFF FFFF
Undefined (Abort)
256 MBytes
0xF002 4000
USART1 UART0
0xF002 8000
256 MBytes
GMAC
0xF002 C000
0xF003 0000
HSMC
256 MBytes
LCDC
0xF003 4000
0xFFFF D000
ISI
0xF003 8000
Reserved
0xFFFF E400
SFR
0xF003 C000
Reserved
0xF800 0000
FUSE
0xFFFF E600
DMAC0 HSMCI1
0xFFFF E800
0xF800 4000
DMAC1 HSMCI2
0xFFFF EA00
0xF800 8000
SPI1
0xF800 C000
MPDDRC
0xFFFF EC00
SSC1
0xF801 0000
MATRIX
0xFFFF EE00
CAN1
0xF801 4000
DBGU
0xFFFF F000
AIC
0xFFFF F200
TSADC
0xF801 C000
PIOA
0xFFFF F400
TWI2
0xF802 0000
PIOB
0xFFFF F600
PIOC USART2
0xFFFF F800
0xF802 4000
USART3
0xF802 8000 0xFFFF FA00
PIOD PIOE
0xFFFF FC00
UART1
0xF802 C000
EMAC
0xF803 0000
PMC
0xFFFF FE00
RSTC UDPHS
0xFFFF FE10
SHDC SHA
0xFFFF FE20 0xFFFF FE30
0xF803 8000
Internal Peripherals
0xFFFF FFFF
256 MBytes
0xF803 C000
AES TDES
0xF804 0000
SCKCR BSC
TRNG
0xF804 4000 0xFFFF FE60
Reserved
0xFFFF C000
SYSC
0xFFFF FFFF
Reserved
21
6.1
6.1.1
Embedded Memories
Internal SRAM
The SAMA5D3 product embeds a total of 128 Kbytes high-speed SRAM0 and SRAM1. After Remap the SRAM is accessible at address 0 but also at address 0x00300000. Only the ARM core has access to the SRAM at address 0. The others masters (DMA, peripherals, etc.) always access the SRAM at address 0x00300000. SRAM0 and SRAM1 can be accessed in parallel to improve the overall bandwidth of the system.
6.1.2
Internal ROM
The SAMA5D3 product embeds one 160-Kbyte internal ROM containing a standard and a secure bootloader. The secure bootloader is described in a separate document, under NDA. The standard bootloader supports booting from:
z z z z z
8-bit NAND Flash with ECC management SPI Serial Flash SDCARD EMMC TWI EEPROM
The boot sequence can be selected using the boot order facility (Boot Select Control Register). The internal ROM embeds Galois field tables that are used to compute NandFlash ECC. Please refer to Figure 12-9 Galois Field Table Mapping in the Boot Strategies section of this datasheet.
6.1.3
Boot Strategies
For standard boot strategies, please refer to the Boot Strategies section of this datasheet. For secure boot strategies, please refer to the Application Note Secure Boot on SAMA5D3 Series (NDA required).
6.2
External Memory
The SAMA5D3 features interfaces to offer connexion to a wide range of external memories or to parallel peripherals.
6.2.1
DDR2/LPDDR/LPDDR2 Interface
z z z z z z z
32-bit external interface 512 Mbytes address space on CS1 Supports DDR2, LPDDR and LPDDR2 memories Drive level control I/O impedance control embedded Supports 4-banks and 8-banks and up to 512 Mbytes Multi-port
6.2.2
Asynchronous SRAM-like memories and parallel peripherals NAND Flash (8-Bit MLC and SLC)
The HSMC embeds a NAND Flash Controller (NFC). The NFC can handle automatic transfers, sending the commands and address cycles to the NAND Flash and transferring the contents of the page (for read and write) to the NFC SRAM. It minimizes the CPU overhead.
22
In order to improve overall system performance the DATA phase of the transfer can be DMA assisted. The static memory embeds a NAND Flash Error Correcting Code controller with the features as follows:
z z z
Algorithm based on BCH codes. Supports also SLC 1-bit (BCH 2-bit), SLC 4-bit (BCH 4-bit) Programmable Error Correcting Capability:
z z
2-bit, 4-bit, 8-bit and 16-bit errors for 512 Bytes/sector (4 Kbyte page) 24-bit error for 1024 Bytes/sector (8 Kbyte page)
z z z z z z z z z
Programmable sector size: 512 bytes or 1024 bytes Programmable number of sector per page: 1, 2, 4 or 8 blocks of data per page Programmable spare area size Supports spare area ECC protection Supports 8 Kbyte page size using 1024 Bytes/sector and 4 Kbyte page size using 512 Bytes/sector Error detection is interrupt driven Provides hardware acceleration for error location Finds roots of error-locator polynomial Programmable number of roots
23
7.
7.1
Embedded Characteristics
z
Peripherals generate event triggers which are directly routed to event managers such as ADC, for example, to start measurement/conversion without processor intervention.
7.2
Table 7-1.
24
8.
System Controller
The System Controller is a set of peripherals that allows handling of key elements of the system, such as power, resets, clocks, time, interrupts, watchdog, etc. The System Controller User Interface also embeds the registers that configure the Matrix and a set of registers for the chip configuration. The chip configuration registers configure the EBI chip select assignment and voltage range for external memories. The System Controllers peripherals are all mapped within the highest 16 KB of address space, between addresses 0xFFFF D000 and 0xFFFF FFFF. However, all the registers of System Controller are mapped on the top of the address space. All the registers of the System Controller can be addressed from a single pointer by using the standard ARM instruction set, as the Load/Store instruction have an indexing mode of 4 KB. Figure 8-1 on page 26 shows the System Controller block diagram.
25
wdt_irq
Reset Controller
VDDBU
VDDBU POR
SLCK backup_nreset SLCK SHDN WKUP backup_nreset rtc_alarm 32 kHz RC OSC SCKCR SLCK int MAINCK 12 MHz MAIN OSC UPLL PLLA periph_nreset SMDCK UPLLCK PLLACK
Shut-Down Controller
XIN32 XOUT32
periph_clk[2..49] pck[0-1] UHP48M UHP12M PCK MCK DDR sysclk LCD Pixel clock pmc_irq idle SMDCK = periph_clk[11]
periph_clk[2..49] periph_nreset
PIO Controllers
Fuse Box
26
8.1
Chip Identification
z z
Device EXT ID
z z z
Boundary JTAG ID: 0x05B3103F Cortex A5 JTAG IDCODE: 0x4ba00477 Cortex A5 Serial Wire IDCODE: 0x2ba01477
8.2
Backup Section
The SAMA5D3 features a Backup Section that embeds:
z z z z z z z z
RC Oscillator Slow Clock Oscillator SCKR register Real-time Clock (RTC) Shutdown Controller 4 Backup registers Part of the Reset Controller (RSTC) Boot Select Control Register
27
9.
9.1
Peripherals
Peripheral Mapping
As shown in Section 6. Memories the Peripherals are mapped in the upper 256 Mbytes of the address space between the addresses 0xFFF7 8000 and 0xFFFC FFFF. Each User Peripheral is allocated 16 Kbytes of address space.
9.2
Peripheral Identifiers
Peripheral Identifiers Instance Name AIC SYS DBGU PIT WDT HSMC PIOA PIOB PIOC PIOD PIOE SMD USART0 USART1 USART2 USART3 UART0 UART1 TWI0 TWI1 TWI2 HSMCI0 HSMCI1 HSMCI2 SPI0 SPI1 Instance Description Advanced Interrupt Controller System Controller Interrupt Debug Unit Interrupt Periodic Interval Timer Interrupt Watchdog timer Interrupt Multi-bit ECC Interrupt Parallel I/O Controller A Parallel I/O Controller B Parallel I/O Controller C Parallel I/O Controller D Parallel I/O Controller E SMD Soft Modem USART 0 USART 1 USART 2 USART 3 UART 0 UART 1 Two-Wire Interface 0 Two-Wire Interface 1 Two-Wire Interface 2 High Speed Multimedia Card Interface 0 High Speed Multimedia Card Interface 1 High Speed Multimedia Card Interface 2 Serial Peripheral Interface 0 Serial Peripheral Interface 1 External Interrupt FIQ PMC, RSTC, RTC Wired-OR Interrupt Clock Type SYS_CLK SYS_CLK PCLOCK SYS_CLK SYS_CLK HCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK HCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK
28
Peripheral Identifiers (Continued) Instance Name TC0 TC1 PWM ADC DMAC0 DMAC1 UHPHS UDPHS GMAC EMAC LCDC ISI SSC0 SSC1 CAN0 CAN1 SHA AES TDES TRNG ARM AIC FUSE MPDDRC Reserved Instance Description Timer Counter 0 (ch. 0, 1, 2) Timer Counter 1 (ch. 3, 4, 5) Pulse Width Modulation Controller Touch Screen ADC Controller DMA Controller 0 DMA Controller 1 USB Host High Speed USB Device High Speed Gigabit Ethernet MAC Ethernet MAC LCD Controller Image Sensor Interface Synchronous Serial Controller 0 Synchronous Serial Controller 1 CAN controller 0 CAN controller 1 Secure Hash Algorithm Advanced Encryption Standard Triple Data Encryption Standard True Random Number Generator Performance Monitor Unit Advanced Interrupt Controller Fuse Controller MPDDR controller IRQ External Interrupt Wired-OR Interrupt Clock Type PCLOCK PCLOCK PCLOCK PCLOCK HCLOCK HCLOCK HCLOCK HCLOCK HCLOCK + PCLOCK HCLOCK + PCLOCK HCLOCK HCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PCLOCK PROC_CLOCK SYS_CLK PCLOCK HCLOCK -
29
9.3
9.4
HCLOCK: AHB Clock, managed with the PMC_SCER, PMC_SCDR and PMC_SCSR registers of PMC System Clock PCLOCK: APB Clock, managed with the PMC_PCER, PMC_PCDR, PMC_PCSR and PMC_PCR registers of Peripheral Clock HCLOCK+PCLOCK: Both clock types coexist. The clock is managed with the PMC_PCER, PMC_PCDR, PMC_PCSR and PMC_PCR registers of Peripheral Clock SYS_CLOCK: This clock cannot be disabled. PROC_CLOCK: The clock related to Processor Clock (PCK) and managed with the PMC_SCDR and PMC_SCSR registers of PMC System Clock
30
10.
10.1
Cortex-A5 ARM
Description
The ARM Cortex-A5 processor is a high-performance, low-power, ARM macrocell with an L1 cache subsystem that provides full virtual memory capabilities. The Cortex-A5 processor implements the ARMv7 architecture and runs 32-bit ARM instructions, 16-bit and 32-bit Thumb instructions, and 8-bit Java byte codes in Jazelle state. The Floating-Point Unit (FPU) supports the ARMv7 VFPv4-D16 architecture without Advanced SIMD extensions (NEON). It is tightly integrated to the Cortex-A5 processor pipeline. It provides trapless execution and is optimized for scalar operation. It can generate an Undefined instruction exception on vector instructions that enables the programmer to emulate vector capability in software. The design can include the FPU only, in which case the Media Processing Engine (MPE) is not included. See the Cortex-A5 Floating-Point Unit Technical Reference Manual.
The arrival of an interrupt, either masked or unmasked The arrival of an event, if standby mode was initiated by a Wait for Event (WFE) instruction A debug request, when either debug is enabled or disabled A reset
10.2
Embedded Characteristics
z z z z z z z z z
In-order pipeline with dynamic branch prediction ARM, Thumb, and ThumbEE instruction set support Harvard level 1 memory system with a Memory Management Unit (MMU) 32 Kbytes Data Cache 32 Kbytes Instruction Cache 64-bit AXI master interface ARM v7 debug architecture VFPv4-D16 FPU with trapless execution Jazelle hardware acceleration.
31
10.3
Block Diagram
Figure 10-1. Cortex-A5 Processor Top-level Diagram
Embedded trace macrocell (ETM) interface Cortex-A5 processor APB interface
Debug
AXI interface
32
10.4
Programmer Model
User mode (USR) is the usual ARM program execution state. It is used for executing most application programs Fast Interrupt (FIQ) mode is used for handling fast interrupts. It is suitable for high-speed data transfer or channel process Interrupt (IRQ) mode is used for general-purpose interrupt handling Supervisor mode (SVC) is a protected mode for the operating system Abort mode (ABT) is entered after a data or instruction prefetch abort System mode (SYS) is a privileged user mode for the operating system Undefined mode (UND) is entered when an undefined instruction exception occurs
Mode changes may be made under software control, or may be brought about by external interrupts or exception processing. Most application programs execute in User Mode. The non-user modes, known as privileged modes, are entered in order to service interrupts or exceptions or to access protected resources.
ARM state: The processor executes 32-bit, word-aligned ARM instructions. Thumb state: The processor executes 16-bit and 32-bit, halfword-aligned Thumb instructions. ThumbEE state: The processor executes a variant of the Thumb instruction set designed as a target for dynamically generated code. This is code compiled on the device either shortly before or during execution from a portable bytecode or other intermediate or native representation.
Jazelle state: The processor executes variable length, byte-aligned Java bytecodes.
The J bit and the T bit determine the instruction set used by the processor. Table 3-1 shows the encoding of these bits.
Table 10-1. CPSR J and T Bit Encoding J 0 0 1 1 T 0 1 0 1 Instruction Set State ARM Thumb Jazelle ThumbEE
Changing between ARM and Thumb states does not affect the processor mode or the register contents. See the ARM Architecture Reference Manual for information on entering and exiting ThumbEE state. 10.4.2.1 Switching State It is possible to change the instruction set state of the processor between:
z z z z
ARM state and Thumb state using the BX and BLX instructions. Thumb state and ThumbEE state using the ENTERX and LEAVEX instructions. ARM and Jazelle state using the BXJ instruction. Thumb and Jazelle state using the BXJ instruction.
See the ARM Architecture Reference Manual for more information about changing instruction set state.
33
CPSR
CPSR SPSR_MON
CPSR SPSR_SVC
CPSR SPSR_ABT
CPSR SPSR_UND
CPSR SPSR_IRQ
CPSR SPSR_FIQ
The core contains one CPSR, and six SPSRs for exception handlers to use. The program status registers:
z z z
Hold information about the most recently performed ALU operation Control the enabling and disabling of interrupts Set the processor operation mode
N Z C V Q
IT J Reserved [1:0]
GE[3:0]
IT[7:2]
E A I F T
Mode
34
z z z z z z
N: Negative, Z: Zero, C: Carry, and V: Overflow are the four ALU flags Q: cumulative saturation flag IT: If-Then execution state bits for the Thumb IT (If-Then) instruction J: Jazelle bit, see the description of the T bit GE: Greater than or Equal flags, for SIMD instructions E: Endianness execution state bit. Controls the load and store endianness for data accesses. This bit is ignored by instruction fetches.
z z
z z z z z
A: Asynchronous abort disable bit. Used to mask asynchronous aborts. I: Interrupt disable bit. Used to mask IRQ interrupts. F: Fast interrupt disable bit. Used to mask FIQ interrupts. T: Thumb execution state bit. This bit and the J execution state bit, bit [24], determine the instruction set state of the processor, ARM, Thumb, Jazelle, or ThumbEE. Mode: Five bits to encode the current processor mode. The effect of setting M[4:0] to a reserved value is UNPREDICTABLE.
Table 10-3. Processor Mode vs. Mode Field Mode USR FIQ IRQ SVC M[4:0] 10000 10001 10010 10011
10.4.3.1 CP15 Coprocessor Coprocessor 15, or System Control Coprocessor CP15, is used to configure and control all the items in the list below:
z z z z z
Cortex A5 Caches (ICache, DCache and write buffer) MMU Security Other system options
To control these features, CP15 provides 16 additional registers. See Table 10-4 below.
Table 10-4. CP15 Registers Register 0 0 1 1 Name ID Code
(1)
Security
35
Table 10-4. CP15 Registers Register 2 3 4 5 5 6 7 8 9 10 11 Name Translation Table Base Domain Access Control Reserved Data fault Status
(1)
Instruction fault status Fault Address Cache and MMU Operations TLB operations cache lockdown(1) TLB lockdown Reserved
13 13 14 15
Note:
1.
This register provides access to more than one register. The register accessed depends on the value of the CRm field or Opcode_2 field.
36
MCR (Move to Coprocessor from ARM Register) instruction is used to write an ARM register to CP15. MRC (Move to ARM Register from Coprocessor) instruction is used to read the value of CP15 to an ARM register.
Other instructions such as CDP, LDC, STC can cause an undefined instruction exception. The assembler code for these instructions is: MCR/MRC{cond} p15, opcode_1, Rd, CRn, CRm, opcode_2. The MCR/MRC instructions bit pattern is shown below:
31
30 cond
29
28
27 1 19
26 1 18 CRn
25 1 17
24 0 16
23
22 opcode_1 14 Rd
21
20 L 12
15
13
11 1 3
10 1 2 CRm
9 1 1
8 1 0
6 opcode_2
4 1
opcode_2[7:5]
Determines specific coprocessor operation code. By default, set to 0.
L: Instruction Bit
0 = MCR instruction 1 = MRC instruction
37
3. 4.
38
10.5
16-Mbyte supersections. The processor supports supersections that consist of 16-Mbyte blocks of memory. 1-Mbyte sections 64-Kbyte large pages 4-Kbyte small pages
z z z
16 access domains Global and application-specific identifiers to remove the requirement for context switch TLB flushes. Extended permissions checking capability.
TLB maintenance and configuration operations are controlled through a dedicated coprocessor, CP15, integrated with the core. This coprocessor provides a standard mechanism for configuring the L1 memory system. See the ARM Architecture Reference Manual for a full architectural description of the ARMv7 VMSA.
Write-through caches are not supported. Any memory marked as write-through is treated as Non-cacheable. The outer shareable attribute is not supported. Anything marked as outer shareable is treated in the same way as inner shareable. Write-back no write-allocate is not supported. It is treated as write-back write-allocate.
39
Table 10-5 shows the treatment of each different memory type in the Cortex-A5 processor in addition to the architectural requirements.
Table 10-5. Treatment of Memory Attributes Memory Type Attribute Strongly Ordered Device Other attributes Shareability Non-shareable Shareable Non-cacheable Write-through cacheable Non-shareable Write-back cacheable, write allocate Write-back cacheable, no write allocate Non-cacheable Write-through cacheable Normal Inner shareable Write-back cacheable, write allocate Write-back cacheable, no write allocate Non-cacheable Write-through cacheable Outer shareable Write-back cacheable, write allocate Write-back cacheable, no write allocate Treated as inner shareable non-cacheable. Treated as inner shareable non-cacheable unless the SMP bit in the Auxiliary Control Register is set (ACTLR[6] = b1). If this bit is set the area is treated as Write-back cacheable write allocate. Does not access L1 caches. Treated as non-cacheable. Can dynamically switch to no write allocate, if more than three full cache lines are written in succession. Treated as non-shareable write-back cacheable, write allocate Treated as inner shareable non-cacheable. Treated as inner shareable non-cacheable unless the SMP bit in the Auxiliary Control Register is set (ACTLR[6] = b1). If this bit is set the area is treated as Write-back cacheable write allocate. Notes
10.5.3.1 Micro TLB The first level of caching for the page table information is a micro TLB of 10 entries that is implemented on each of the instruction and data sides. These blocks provide a lookup of the virtual addresses in a single cycle. The micro TLB returns the physical address to the cache for the address comparison, and also checks the access permissions to signal either a Prefetch Abort or a Data Abort. All main TLB related maintenance operations affect both the instruction and data micro TLBs, causing them to be flushed. In the same way, any change of the following registers causes the micro TLBs to be flushed:
z z z z z
Context ID Register (CONTEXTIDR) Domain Access Control Register (DACR) Primary Region Remap Register (PRRR) Normal Memory Remap Register (NMRR) Translation Table Base Registers (TTBR0 and TTBR1).
40
10.5.3.2 Main TLB Misses from the instruction and data micro TLBs are handled by a unified main TLB. Accesses to the main TLB take a variable number of cycles, according to competing requests from each of the micro TLBs and other implementationdependent factors. The main TLB is 128-entry two-way set-associative. TLB match process Each TLB entry contains a virtual address, a page size, a physical address, and a set of memory properties. Each is marked as being associated with a particular application space (ASID), or as global for all application spaces. The CONTEXTIDR determines the currently selected application space. A TLB entry matches when these conditions are true:
z z z
Its virtual address matches that of the requested address Its Non-secure TLB ID (NSTID) matches the Secure or Non-secure state of the MMU request Its ASID matches the current ASID in the CONTEXTIDR or is global.
The operating system must ensure that, at most, one TLB entry matches at any time. The TLB can store entries based on the following block sizes:
Supersections Sections Large pages Small pages Describe 16-Mbyte blocks of memory. Describe 1-Mbyte blocks of memory. Describe 64-Kbyte blocks of memory. Describe 4-Kbyte blocks of memory
Supersections, sections and large pages are supported to permit mapping of a large region of memory while using only a single entry in the TLB. If no mapping for an address is found within the TLB, then the translation table is automatically read by hardware and a mapping is placed in the TLB.
The MMU can be configured to perform hardware translation table walks in cacheable regions by setting the IRGN bits in Translation Table Base Register 0 and Translation Table Base Register 1. If the encoding of the IRGN bits is write-back, an L1 data cache lookup is performed and data is read from the data cache. If the encoding of the IRGN bits is writethrough or non-cacheable, an access to external memory is performed. For more information refer to: Cortex-A5 Technical Reference Manual. The MMU might not find a global mapping, or a mapping for the currently selected ASID, with a matching Non-secure TLB ID (NSTID) for the virtual address in the TLB. In this case, the hardware does a translation table walk if the translation table walk is enabled by the PD0 or PD1 bit in the Translation Table Base Control Register. If translation table walks are disabled, the processor returns a Section Translation fault. For more information refer to: Cortex-A5 Technical Reference Manual. If the TLB finds a matching entry, it uses the information in the entry as follows: 1. The access permission bits and the domain determine if the access is enabled. If the matching entry does not pass the permission checks, the MMU signals a memory abort. See the ARM Architecture Reference Manual for a description of access permission bits, abort types and priorities, and for a description of the Instruction Fault Status Register (IFSR) and Data Fault Status Register (DFSR).
41
2.
z z z
The memory region attributes specified in both the TLB entry and the CP15 c10 remap registers determine if the access is: Secure or Non-secure Shared or not Normal memory, Device, or Strongly-ordered. The TLB translates the virtual address to a physical address for the memory access.
For more information refer to: Cortex-A5 Technical Reference Manual, Memory region remap. 3.
42
11.
11.1
11.2
Embedded Characteristics
z
Two real-time Watchpoint Units Two Independent Registers: Debug Control Register and Debug Status Register Test Access Port Accessible through JTAG Protocol Debug Communications Channel Serial Wire Debug Two-pin UART Debug Communication Channel Interrupt Handling Chip ID Register
Debug Unit
z z z
43
11.3
Block Diagram
Figure 11-1. Debug and Test Block Diagram
TMS / SWDIO TCK / SWCLK TDI
RTCK
Cortex-A5
44
11.4
Application Examples
ICE/JTAG Connector
SAM device
RS232 Connector
Terminal
45
Tester
JTAG Interface
ICE/JTAG
Chip n
Chip 2
SAM device
Chip 1
46
11.5
47
11.6
Functional Description
11.6.2 EmbeddedICE
The Cortex-A5 EmbeddedICE-RT is supported via the ICE/JTAG port. It is connected to a host computer via an ICE interface.The internal state of the Cortex-A5 is examined through an ICE/JTAG port which allows instructions to be serially inserted into the pipeline of the core without using the external data bus. Therefore, when in debug state, a storemultiple (STM) can be inserted into the instruction pipeline. This exports the contents of the Cortex-A5 registers. This data can be serially shifted out without affecting the rest of the system. There are two scan chains inside the Cortex-A5 processor which support testing, debugging, and programming of the EmbeddedICE-RT. The scan chains are controlled by the ICE/JTAG port. EmbeddedICE mode is selected when JTAGSEL is low. It is not possible to switch directly between ICE and JTAG operations. A chip reset must be performed after JTAGSEL is changed. For further details on the EmbeddedICE-RT, see the ARM document: ARM IHI 0031A_ARM_debug_interface_v5.pdf
48
Connect your computer to the board with JTAG and USB (J20 USB-A) Power on the chip Open a terminal console (TeraTerm or HyperTerminal, etc.) on your computer and connect to the USB CDC Serial COM port related to the J20 connector on the board Send the '#' character. You will see then the prompt '>' character sent by the device (indicating that the Standard SAM-BA Monitor is running) Use the Standard SAM-BA Monitor to connect to the chip with JTAG
Note that you don't need to follow this sequence in order to connect the Standard SAM-BA Monitor with USB.
49
11.7
Access:
VERSION
23 22 21 20 19
PART NUMBER
18 17 16
PART NUMBER
15 14 13 12 11 10 9 8
PART NUMBER
7 6 5 4 3
MANUFACTURER IDENTITY
2 1 0
MANUFACTURER IDENTITY
MANUFACTURER IDENTITY[11:1]
Set to 0x01F. Bit[0] required by IEEE Std. 1149.1. Set to 0x1. JTAG ID Code value is 0x05B3_103F.
50
11.8
Read-only
30 29 28 27 26 25 24
VERSION
23 22 21 20 19
PART NUMBER
18 17 16
PART NUMBER
15 14 13 12 11 10 9 8
PART NUMBER
7 6 5 4 3 2
DESIGNER
1 0
DESIGNER
DESIGNER[11:1]
Set to 0x23B. Bit[0] required by IEEE Std. 1149.1. Set to 0x1. Cortex-A5 JTAG-DP IDCODE value is 0x0BA0_0477
51
Read-only
30 29 28 27 26 25 24
VERSION
23 22 21 20 19
PART NUMBER
18 17 16
PART NUMBER
15 14 13 12 11 10 9 8
PART NUMBER
7 6 5 4 3 2
DESIGNER
1 0
DESIGNER
DESIGNER[11:1]
Set to 0x23B. Bit[0] required by IEEE Std. 1149.1. Set to 0x1. Cortex-A5 SW-DP IDCODE is 0x0BA0_1477
52
12.
The user can choose to boot from an external NOR Flash memory with the help of the BMS pin. The sampling of the BMS pin is done by hardware at reset, and the result is available in the BMS_EBI bit of the SFR_EBICFG register. The first steps of the ROM Code program is to check the state of this pin by reading this register. If BMS signal is tied to 0, BMS_BIT is read at 1 The ROM Code allows execution of the code contained into the memory connected to Chip Select 0 of the External Bus Interface. To achieve that, the following sequence is preformed by the ROM Code:
z z z z
The main clock is the on-chip 12 MHz RC oscillator, The Static Memory Controller is configured with timing allowing code execution inCS0 external memory at 12 MHz AXI matrix is configured to remap EBI CS0 address at 0x0 0x0 is loaded in the Program Counter register
The user software in the external memory must perform the next operation in order to complete the clocks and SMC timings configuration to run at a higher clock frequency:
z z z z z
Enable the 32768 Hz oscillator if best accuracy is needed Reprogram the SMC setup, cycle, hold, mode timing registers for EBI CS0, to adapt them to the new clock Program the PMC (Main Oscillator Enable or Bypass mode) Program and Start the PLL Switch the system clock to the new value
If BMS signal is tied to 1, BMS_BIT is read at 0 The ROM Code standard sequence is executed as follows:
z z z
Basic chip initialization: XTal or external clock frequency detection Attempt to retrieve a valid code from external non-volatile memories (NVM) Execution of a monitor called SAM-BA Monitor, in case no valid application has been found on any NVM
53
12.1
Flow Diagram
The ROM Code implements the algorithm shown in Figure 12-1.
Figure 12-1. ROM Code Algorithm Flow Diagram
Chip Setup
Yes
No
SAM-BA Monitor
12.2
Chip Setup
At boot start-up, the processor clock (PCK) and the master clock (MCK) source is the 12 MHz Fast RC Oscillator. Initialization follows the steps described below: 1. 2. Stack Setup for ARM supervisor mode Main Oscillator Detection: The Main Clock is switched to the 32 kHz RC oscillator to allow external clock frequency to be measured. Then the Main Oscillator is enabled and set in the bypass mode. If the MOSCSELS bit rises, an external clock is connected, and the next step is Main Clock Selection (3). If not, the bypass mode is cleared to attempt external quartz detection. This detection is successful when the MOSCXTS and MOSCSELS bits rise, else the 12 MHz Fast RC internal oscillator is used as the Main Clock. Main Clock Selection: The Master Clock source is switched from the Slow Clock to the Main Oscillator without prescaler. The PMC Status Register is polled to wait for MCK Ready. PCK and MCK are now the Main Clock. C Variable Initialization: Non zero-initialized data is initialized in the RAM (copy from ROM to RAM). Zero-initialized data is set to 0 in the RAM. PLLA Initialization: PLLA is configured to get a PCK at 96 MHz and an MCK at 48 MHz. If an external clock or crystal frequency running at 12 MHz is found, then the PLLA is configured to allow communication on the USB link for the SAM-BA Monitor; else the Main Clock is switched to the internal 12 MHz Fast RC, but USB will not be activated.
3. 4. 5.
54
12.3
NVM Boot
SPI0 NPCS1 Y Y Y Y Y -
TWI EEPROM Y Y Y Y Y -
55
Yes
Run
No
SD Card Boot
Yes
Run
SD Card Bootloader
No
Yes
Run
No
Yes
Run
No
Yes
Run
No
SAM-BA Monitor
56
Initialize NVM
Initialization OK ?
No
Restore the reset values for the peripherals and Jump to next boot solution
No
Yes Copy the valid code from external NVM to internal SRAM.
Restore the reset values for the peripherals. Perform the REMAP and set the PC to 0 to jump to the downloaded application
End
57
The NVM bootloader program first initializes the PIOs related to the NVM device. Then it configures the right peripheral depending on the NVM and tries to access this memory. If the initialization fails, it restores the reset values for the PIO and the peripheral, and then tries to fulfill the same operations on the next NVM of the sequence. If the initialization is successful, the NVM bootloader program reads the beginning of the NVM and determines if the NVM contains a valid code. If the NVM does not contain a valid code, the NVM bootloader program restores the reset value for the peripherals and then tries to fulfill the same operations on the next NVM of the sequence. If a valid code is found, this code is loaded from the NVM into the internal SRAM and executed by branching at address 0x0000_0000 after remap. This code may be the application code or a second-level bootloader. All the calls to functions are PC relative and do not use absolute addresses.
Figure 12-4. Remap Action after Download Completion
0x0000_0000 Internal ROM 0x0010_0000 Internal ROM 0x0030_0000 Internal SRAM Internal SRAM Internal ROM 0x0030_0000 REMAP Internal SRAM 0x0010_0000 0x0000_0000
58
Unconditional instruction: 0xE for bits 31 to 28. Load PC with the PC relative addressing instruction:
z z z z z
Rn = Rd = PC = 0xF I==0 (12-bit immediate value) P==1 (pre-indexed) U offset added (U==1) or subtracted (U==0) W==1
The sixth vector, at the offset 0x14, contains the size of the image to download. The user must replace this vector with the users own vector. This procedure is described below.
Figure 12-7. Structure of the ARM Vector 6
31 Size of the code to download in bytes 0
Example
An example of valid vectors: 00 04 08 0c 10 14 18 12.3.3.2 boot.bin File Check This method is the one used on FAT formatted SD Card and eMMC. The boot program must be a file named boot.bin written in the root directory of the file system. Its size must not exceed the maximum size allowed: 64 Kbytes (0x10000). ea000006 eafffffe ea00002f eafffffe eafffffe 00001234 eafffffe B0x20 B0x04 B_main B0x0c B0x10 B0x14<- Code size = 4660 bytes B0x18
The detection of a specific header written at the beginning of the first page of the NAND Flash, Through the ONFI parameters for the ONFI compliant memories
or
z
59
No
Yes
Yes
Restore the reset values for the peripherals. Perform the REMAP and set the PC to 0 to jump to the downloaded application
End
Restore the reset values for the peripherals and Jump to next bootable memory
60
key
23 22 21 20
19 18
eccOffset
17 16
eccOffset
15 14 13 12 11 10 9
sectorSize
8
eccBitReq
7 6 5 4 3
spareSize
2 1 0
spareSize
nbSectorPerPage
usePmecc
nbSectorPerPage: Number of Sectors per Page spareSize: Size of the Spare Zone in Bytes eccBitReq: Number of ECC Bits Required
0 = 2-bit ECC 1 = 4-bit ECC 2 = 8-bit ECC 3 = 12-bit ECC 4 = 24-bit ECC
key: Value 0xC Must be Written here to Validate the Content of the Whole Word.
If the header is valid, the Boot Program continues with the detection of a valid code.
61
Number of bytes per page (byte 80) Number of bytes in spare zone (byte 84) Number of ECC bit correction required (byte 112) ECC sector size: by default, set to 512 bytes; or to 1024 bytes if the ECC bit capability above is 0xFF
By default, the ONFI NAND Flash detection will turn ON the usePmecc parameter, and the ECC correction algorithm is automatically activated. Once the Boot Program retrieves the parameter, using one of the two methods described above, it reads the first page again, with or without ECC, depending on the usePmecc parameter. Then it looks for a valid code programmed just after the header offset 0xD0. If the code is valid, the program is copied at the beginning of the internal SRAM. Note: Booting on 16-bit NAND Flash is not possible, only 8-bit NAND Flash memories are supported.
12.3.4.2 NAND Flash Boot: PMECC Error Detection and Correction NAND Flash boot procedure uses PMECC to detect and correct errors during NAND Flash read operations in two cases:
z z
When the usePmecc flag is set in a specific NAND header. If the flag is not set, no ECC correction is performed during the NAND Flash page read. When the NAND Flash has been detected using ONFI parameters.
The ROM memory embeds the Galois field tables. The user does not need to embed them in his own software. The Galois field tables are mapped in the ROM just after the ROM code, as described in Figure 12-9.
Figure 12-9. Galois Field Table Mapping
0x0010_0000 0x0010_0000
ROM Code Code ROM 0x0010_8000 0x0010_8000 Galois field field Galois tables for for tables 512-byte 512-byte sectors sectors correction correction
0x0011_0000 0x0011_0000
Galois field field Galois tables for for tables 1024-byte 1024-byte sectors sectors correction correction
For a full description and an example of how to use the PMECC detection and correction feature, refer to the software package dedicated to this device on Atmels web site.
62
12.3.4.3 SD Card / eMMC Boot The SD Card / eMMC bootloader looks for a boot.bin file in the root directory of a FAT12/16/32 file system.
63
Before performing the jump to the application in the internal SRAM, all the PIOs and peripherals used in the boot program are set to their reset state.
Table 12-3. PIO Driven during Boot Program Execution NVM Bootloader Peripheral EBI CS3 SMC EBI CS3 SMC EBI CS3 SMC NAND EBI CS3 SMC EBI CS3 SMC EBI CS3 SMC MCI0 MCI0 MCI0 MCI0 MCI0 MCI0 SD Card / eMMC MCI1 MCI1 MCI1 MCI1 MCI1 MCI1 SPI0 SPI0 SPI Flash SPI0 SPI0 SPI0 TWI0 TWI0 EEPROM TWI0 DBGU SAM-BA Monitor DBGU DTXD PIOB31 TWCK0 DRXD PIOA31 PIOB30 MCI1_CK MCI1_CDA MCI1_D0 MCI1_D1 MCI1_D2 MCI1_D3 MOSI MISO SPCK NPCS0 NPCS1 TWD0 PIOB24 PIOB19 PIOB20 PIOB21 PIOB22 PIOB23 PIOD11 PIOD10 PIOD12 PIOD13 PIOD14 PIOA30 NAND ALE NAND CLE Cmd/Addr/Data MCI0_CK MCI0_CDA MCI0_D0 MCI0_D1 MCI0_D2 MCI0_D3 PIOD9 PIOD0 PIOD1 PIOD2 PIOD3 PIOD4 Pin NANDOE NANDWE NANDCS PIO Line -
64
12.4
SAM-BA Monitor
If no valid code is found in the NVM during the NVM bootloader sequence, the SAM-BA Monitor program is launched. The SAM-BA Monitor principle is to:
z z z
Initialize DBGU and USB Check if USB Device enumeration occurred Check if characters are received on the DBGU
Once the communication interface is identified, the application runs in an infinite loop waiting for different commands as listed in Table 12-4.
Figure 12-10. SAM-BA Monitor Diagram
No valid code in NVM
No
Table 12-4. Commands Available through the SAM-BA Monitor Command N T O o H h W w S R G V Action Set Normal Mode Set Terminal Mode Write a byte Read a byte Write a half word Read a half word Write a word Read a word Send a file Receive a file Go Display version Argument(s) No argument No argument Address, Value# Address,# Address, Value# Address,# Address, Value# Address,# Address,# Address, NbOfBytes# Address# No argument Example N# T# O200001,CA# o200001,# H200002,CAFE# h200002,# W200000,CAFEDECA# w200000,# S200000,# R200000,1234# G200200# V#
65
Mode commands:
z z
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. Address: Address in hexadecimal Value: Byte, halfword or word to write in hexadecimal Output: > Address: Address in hexadecimal Output: The byte, halfword or word read in hexadecimal followed by > Address: Address in hexadecimal Output: >
Write commands: Write a byte (O), a halfword (H) or a word (W) to the target
z z z
Read commands: Read a byte (o), a halfword (h) or a word (w) from the target
z z
Note:
z
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
z z z
Output: > Address: Address to jump in hexadecimal Output: > once returned from the program execution. If the executed program does not handle the link register at its entry and does not return, the prompt will not be displayed Output: version, date and time of ROM code followed by >
<SOH> = 01 hex <blk #> = binary number, starts at 01, increments by 1, and wraps 0FFH to 00H (not to 01) <255-blk #> = 1s complement of the blk#. <checksum> = 2 bytes CRC16
66
67
The device also handles some class requests defined in the CDC class.
Table 12-6. Handled Class Requests Request SET_LINE_CODING GET_LINE_CODING SET_CONTROL_LINE_STATE Definition Configures DTE rate, stop bits, parity and number of character bits Requests current DTE rate, stop bits, parity and number of character bits RS-232 signal used to indicate to the DCE device that the DTE device is now present
Unhandled requests are STALLed. 12.4.3.4 Communication Endpoints Endpoint 0 is used for the enumeration process. Endpoint 1 (64-byte Bulk OUT) and endpoint 2 (64-byte Bulk IN) are used as communication endpoints. SAM-BA Boot commands are sent by the host through Endpoint 1. If required, the message is split into several data payloads by the host driver. If the command requires a response, the host sends IN transactions to pick up the response.
68
13.
13.1
13.2
Embedded Characteristics
z
13.3
Product Dependencies
z
Product-dependent order
69
13.4
Table 13-1. Register Mapping Offset 0x0 Register Boot Sequence Configuration Register Name BSC_CR Access Read-write Reset
23
22
21
20 BOOTKEY
19
18
17
16
15 7
14 6
13 5
12 4 BOOT
11 3
10 2
9 1
8 0
BOOTKEY
0x6683 (BSC_KEY): valid key to write BSC_CR register; it needs to be written at the same time as the BOOT field. Other values disable the write access. This key field is write-only.
70
14.
14.1
14.2
Embedded Characteristics
z z z z z z z z
High Performance AXI Network Interconnect 1 AXI Slave Interface 1 AHB-Lite Slave Interface 3 AXI Master Interfaces 1 APB3 Slave Interface Single-cycle Arbitration Full Pipelining to prevent Master Stalls 2 Remap States
71
14.3
Operation
14.3.1 Remap
There are two remap states using bits 0 and 1 in the Remap Register (AXIMX_REMAP)
z z
Bit 1 is used to remap EBI @ addr 0x00000000 for external boot. Bit 0 is used to remap RAM @ addr 0x00000000
Refer to Section 14.4 AXI Matrix (AXIMX) User Interface" and Table 14-1, Register Mapping. The number of remap states can be defined using eight bits of the remap register, and a bit in the remap register controls each remap state. Each remap state can be used to control the address decoding for one or more slave interfaces. If a slave interface is affected by two remap states that are both asserted, the remap state with the lowest remap bit number takes precedence. Each slave interface can be configured independently so that a remap state can perform different functions for different masters. A remap state can:
z z z
Alias a memory region into two different address ranges Move an address region Remove an address region
Because of the nature of the distributed register sub-system, the masters receive the updated remap bit states in sequence, and not simultaneously. A slave interface does not update to the latest remap bit setting until:
z z
The address completion handshake accepts any transaction that is pending Any current lock sequence completes
The BRESP from a GPV after a remap update guarantees that the next transaction issued to each slave interface, or the first one after the completion of a locked sequence, uses the updated value. The AXI Matrix uses two remap bits. At powerup, ROM is seen at address 0 After powerup, ahbslave can be moved down to address 0 by means of the remap bits. Figure 14-1 shows the memory map when remap is set to 000, representing no remap,
72
ROM
0x000FFFFF 0x00100000 0x001FFFFF 0x00200000 0x002FFFFF 0x00300000 0x0007FFFFF 0x00800000 0x008FFFFF 0x00900000 0x09FFFFF 0x0A00000 0x001FFFFF 0x01000000 0x01FFFFFF 0x20000000 0x3FFFFFFF 0x40000000 0x7FFFFFFF 0x80000000 0xEFFFFFFF 0xF0000000 0xFFFFFFFF
ROM ahbslave ahbslave gpv_0 dap [apb3bridge] reserved ahbslave MPDDR ahbslave reserved ahbslave
Figure 14-2 shows mapping when remap state is 01 or 11. This state is used for RAM boot. RAM is seen at address 0 through ahbslave.
Figure 14-2. Remap state is 01 or 11
0x00000000
ahbslave (RAM)
0x000FFFFF 0x00100000 0x001FFFFF 0x00200000 0x002FFFFF 0x00300000 0x0007FFFFF 0x00800000 0x008FFFFF 0x00900000 0x09FFFFF 0x0A00000 0x001FFFFF 0x01000000 0x01FFFFFF 0x20000000 0x3FFFFFFF 0x40000000 0x7FFFFFFF 0x80000000 0xEFFFFFFF 0xF0000000 0xFFFFFFFF
ROM ahbslave ahbslave gpv_0 dap [apb3bridge] reserved ahbslave MPDDR ahbslave reserved ahbslave
Figure 14-3 shows mapping when remap state is 10. This state is used for external boot. EBI is seen at address 0 through ahbslave.
73
ahbslave (EBI)
0x000FFFFF 0x00100000 0x001FFFFF 0x00200000 0x002FFFFF 0x00300000 0x0007FFFFF 0x00800000 0x008FFFFF 0x00900000 0x009FFFFF 0x00A00000 0x001FFFFF 0x01000000 0x01FFFFFF 0x20000000 0x3FFFFFFF 0x40000000 0x7FFFFFFF 0x80000000 0xEFFFFFFF 0xF0000000 0xFFFFFFFF
ROM ahbslave ahbslave gpv_0 dap[apb3bridge] reserved ahbslave MPDDR ahbslave reserved ahbslave
74
14.4
Table 14-1. Register Mapping Offset 0x00 0x04 - 0x43108 Register Remap Register Reserved Name AXIMX_REMAP Access Write-only Reset 0x00000000 0x00000000
75
23
22
21
20
19
18
17
16
15
14
13
12
11
10
1 REMAP1
0 REMAP0
REMAP0 has higher priority than REMAP1, i.e., if both REMAP0 & REMAP1 are asserted, the matrix is in remap state 0.
76
15.
15.1
77
Table 15-1. List of Bus Matrix Slaves Slave 10 Slave 11 Slave 12 DDR2 Port3 Peripheral Bridge 0 Peripheral Bridge 1
Slaves 0 1 2 3 4 Internal SRAM0 Internal SRAM1 NFC SRAM Internal ROM SMD UDPHS RAM 5 UHP OHCI Reg UHP EHCI Reg EBI CS0..CS3 6 NFC Command Register DDR2 Port 0 DDR2 port1 DDR2 port2 DDR2 port3 APB 0 APB 1
A5 X X X X X X X X X X
DMAC0
DMAC1 X X
LCDC DMA
X X X
7 8 9 10 11 12
X X
X X
X X X X X X X X
X X
X X
78
15.2
Embedded Characteristics
z z z z z z z z z z
AMBA Advanced High-performance Bus (AHB Lite) Compliant Interfaces 32-bit or 64-bit Data Bus APB Compliant User Interface Configurable Number of Masters (Up to sixteen) Configurable Number of Slaves (Up to sixteen) One Decoder for Each Master Several Possible Boot Memories for Each Master before Remap One Remap Function for Each Master Support for Long Bursts of 32, 64, 128 and Up to the 256-beat Word Burst AHB Limit Enhanced Programmable Mixed Arbitration for Each Slave
z z
Round-Robin Fixed Priority No Default Master Last Accessed Default Master Fixed Default Master
z z z z z z
Deterministic Maximum Access Latency for Masters Zero or One Cycle Arbitration Latency for the First Access of a Burst Bus Lock Forwarding to Slaves Master Number Forwarding to Slaves One Special Function Register for Each Slave (Not dedicated) Write Protection of User Interface Registers
79
15.3
Memory Mapping
The Bus Matrix provides one decoder for every AHB master interface. The decoder offers each AHB master several memory mappings. Each memory area may be assigned to several slaves. Booting at the same address while using different AHB slaves (i.e. external RAM, internal ROM or internal Flash, etc.) becomes possible. The Bus Matrix user interface provides the Master Remap Control Register (MATRIX_MRCR), that performs remap action for every master independently. The Bus Matrix user interface provides Master Remap Control Register (MATRIX_MRCR) that performs remap action for every master independently.
15.4
To change from one type of default master to another, the Bus Matrix user interface provides the Slave Configuration Registers, one for every slave, that set a default master for each slave. The Slave Configuration Register contains two fields: DEFMSTR_TYPE and FIXED_DEFMSTR. The 2-bit DEFMSTR_TYPE field selects the default master type (no default, last access master, fixed default master), whereas the 4-bit FIXED_DEFMSTR field selects a fixed default master provided that DEFMSTR_TYPE is set to fixed default master. Refer to Section 15.10.2 Bus Matrix Slave Configuration Registers on page 87.
15.5
No Default Master
After the end of the current access, if no other request is pending, the slave is disconnected from all masters. This configuration incurs one latency clock cycle for the first access of a burst after bus Idle. Arbitration without default master may be used for masters that perform significant bursts or several transfers with no Idle in between, or if the slave bus bandwidth is widely used by one or more masters. This configuration provides no benefit on access latency or bandwidth when reaching maximum slave bus throughput whatever the number of requesting masters.
15.6
80
15.7
15.8
Arbitration
The Bus Matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to access the same slave at the same time. One arbiter per AHB slave is provided, thus arbitrating each slave specifically. The Bus Matrix provides the user with the possibility of choosing between 2 arbitration types or mixing them for each slave: 1. 2. Round-robin Arbitration (default) Fixed Priority Arbitration
The resulting algorithm may be complemented by selecting a default master configuration for each slave. When re-arbitration must be done, specific conditions apply. See Section 15.8.1 Arbitration Scheduling on page 81.
4.
15.8.1.1 Undefined Length Burst Arbitration In order to prevent long AHB burst lengths that can lock the access to the slave for an excessive period of time, the user can trigger the re-arbitration before the end of the incremental bursts. The re-arbitration period can be selected from the following Undefined Length Burst Type (ULBT) possibilities: 1. 2. 3. 4. 5. 6. Unlimited: no predetermined end of burst is generated. This value enables 1-kbyte burst lengths. 1-beat bursts: predetermined end of burst is generated at each single transfer during the INCR transfer. 4-beat bursts: predetermined end of burst is generated at the end of each 4-beat boundary during INCR transfer. 8-beat bursts: predetermined end of burst is generated at the end of each 8-beat boundary during INCR transfer. 16-beat bursts: predetermined end of burst is generated at the end of each 16-beat boundary during INCR transfer. 32-beat bursts: predetermined end of burst is generated at the end of each 32-beat boundary during INCR transfer.
81
7. 8.
64-beat bursts: predetermined end of burst is generated at the end of each 64-beat boundary during INCR transfer. 128-beat bursts: predetermined end of burst is generated at the end of each 128-beat boundary during INCR transfer.
The use of undefined length16-beat bursts, or less, is discouraged since this generally decreases significantly the overall bus bandwidth due to arbitration and slave latencies at each first access of a burst. If the master does not permanently and continuously request the same slave or has an intrinsically limited average throughput, the ULBT should be left at its default unlimited value, knowing that the AHB specification natively limits all word bursts to 256 beats and double-word bursts to 128 beats because of its 1 Kbyte address boundaries. Unless duly needed, the ULBT should be left at its default value of 0 for power saving. This selection can be done through the ULBT field of the Master Configuration Registers (MATRIX_MCFG). 15.8.1.2 Slot Cycle Limit Arbitration The Bus Matrix contains specific logic to break long accesses, such as very long bursts on a very slow slave (e.g., an external low speed memory). At each arbitration time, a counter is loaded with the value previously written in the SLOT_CYCLE field of the related Slave Configuration Register (MATRIX_SCFG) and decreased at each clock cycle. When the counter elapses, the arbiter has the ability to re-arbitrate at the end of the current AHB bus access cycle. Unless a master has a very tight access latency constraint, which could lead to data overflow or underflow due to a badly undersized internal FIFO with respect to its throughput, the Slot Cycle Limit should be disabled (SLOT_CYCLE = 0) or set to its default maximum value in order not to inefficiently break long bursts performed by some Atmel masters. In most cases, this feature is not needed and should be disabled for power saving. Warning: This feature cannot prevent any slave from locking its access indefinitely.
82
15.8.2.1 Fixed Priority Arbitration Fixed priority arbitration algorithm is the first and only arbitration algorithm applied between masters from distinct priority pools. It is also used in priority pools other than the highest and lowest priority pools (intermediate priority pools). Fixed priority arbitration allows the Bus Matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the user in the MxPR field for each master in the Priority Registers, MATRIX_PRAS and MATRIX_PRBS. If two or more master requests are active at the same time, the master with the highest priority MxPR number is serviced first. In intermediate priority pools, if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. 15.8.2.2 Round-Robin Arbitration This algorithm is only used in the highest and lowest priority pools. It allows the Bus Matrix arbiters to properly dispatch requests from different masters to the same slave. If two or more master requests are active at the same time in the priority pool, they are serviced in a round-robin increasing master number order.
15.9
83
84
Table 15-3. Register Mapping (Continued) Offset 0x008C 0x0090 0x0094 0x0098 0x009C 0x00A0 0x00A4 0x00A8 0x00AC 0x00B0 0x00B4 0x00B8 0x00BC 0x00C0 0x00C4 0x00C8 0x00CC 0x00D0 0x00D4 0x00D8 0x00DC 0x00E0 0x00E4 0x00E8 0x00EC 0x00F0 0x00F4 0x00F8 0x00FC 0x0100 0x0104 - 0x010C 0x01A0 - 0x01E0 0x01E4 0x01E8 Register Priority Register B for Slave 1 Priority Register A for Slave 2 Priority Register B for Slave 2 Priority Register A for Slave 3 Priority Register B for Slave 3 Priority Register A for Slave 4 Priority Register B for Slave 4 Priority Register A for Slave 5 Priority Register B for Slave 5 Priority Register A for Slave 6 Priority Register B for Slave 6 Priority Register A for Slave 7 Priority Register B for Slave 7 Priority Register A for Slave 8 Priority Register B for Slave 8 Priority Register A for Slave 9 Priority Register B for Slave 9 Priority Register A for Slave 10 Priority Register B for Slave 10 Priority Register A for Slave 11 Priority Register B for Slave 11 Priority Register A for Slave 12 Priority Register B for Slave 12 Priority Register A for Slave 13 Priority Register B for Slave 13 Priority Register A for Slave 14 Priority Register B for Slave 14 Priority Register A for Slave 15 Priority Register B for Slave 15 Master Remap Control Register Reserved Reserved Write Protect Mode Register Write Protect Status Register Name MATRIX_PRBS1 MATRIX_PRAS2 MATRIX_PRBS2 MATRIX_PRAS3 MATRIX_PRBS3 MATRIX_PRAS4 MATRIX_PRBS4 MATRIX_PRAS5 MATRIX_PRBS5 MATRIX_PRAS6 MATRIX_PRBS6 MATRIX_PRAS7 MATRIX_PRBS7 MATRIX_PRAS8 MATRIX_PRBS8 MATRIX_PRAS9 MATRIX_PRBS9 MATRIX_PRAS10 MATRIX_PRBS10 MATRIX_PRAS11 MATRIX_PRBS11 MATRIX_PRAS12 MATRIX_PRBS12 MATRIX_PRAS13 MATRIX_PRBS13 MATRIX_PRAS14 MATRIX_PRBS14 MATRIX_PRAS15 MATRIX_PRBS15 MATRIX_MRCR MATRIX_WPMR MATRIX_WPSR Access Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-only Reset 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x33333333(1) 0x00000000 0x00000000 0x00000000
Notes: 1. Values in the Bus Matrix Priority Registers are product dependent.
85
This register can only be written if the WPEN bit is cleared in the Write Protect Mode Register .
86
FIXED_DEFMSTR 12 4 SLOT_CYCLE 11 3 10 2
DEFMSTR_TYPE 9 1 8 SLOT_CYCLE 0
This register can only be written if the WPEN bit is cleared in the Write Protect Mode Register .
87
Read-write
30 22 14 6 5 M1PR 13 M3PR 4 21 M5PR 12 29 M7PR 20 28 27 19 11 3 26 18 10 2 1 M0PR 9 M2PR 0 17 M4PR 8 25 M6PR 16 24
This register can only be written if the WPE bit is cleared in the Write Protect Mode Register .
88
Read-write
30 22 14 6 5 M9PR 13 M11PR 4 21 M13PR 12 29 M15PR 20 28 27 19 11 3 26 18 10 2 1 M8PR 9 M10PR 0 17 M12PR 8 25 M14PR 16 24
This register can only be written if the WPEN bit is cleared in the Write Protect Mode Register .
89
This register can only be written if the WPEN bit is cleared in the Write Protect Mode Register .
90
For more details on MATRIX_WPMR, refer to Section 15.9 Write Protect Registers on page 83. The protected registers are: Bus Matrix Master Configuration Registers Bus Matrix Slave Configuration Registers Bus Matrix Priority Registers A For Slaves Bus Matrix Priority Registers B For Slaves Bus Matrix Master Remap Control Register
91
For more details on MATRIX_WPSR, refer to Section 15.9 Write Protect Registers on page 83.
92
16.
16.1
16.2
Embedded Characteristics
z
16.3
Table 16-1. Register Mapping Offset 0x00 -0x04 0x08-0x0C 0x10 0x14 0x18 0x1C 0x28 0x2C 0x30 0x40 0x44 0x48-0x3FFC Register Reserved Reserved OHCI Interrupt Configuration Register OHCI Interrupt Status Register Reserved Reserved Security Configuration Register Reserved UTMI Clock Trimming Register EBI Configuration Register Reserved Reserved Name SFR_OHCIICR SFR_OHCIISR SFR_SECURE SFR_UTMICKTRIM SFR_EBICFG Access Read-write Read-only Read-write Read-write Read-write Reset 0x0 0x0 0x00010000
93
23
22
21
20
19
18
17
16
UDPPUDIS
15
14
13
12
11
10
APPSTART
ARIE
RES2
RES1
RES0
APPSTART: Reserved
0: Must write 0.
94
23
22
21
20
19
18
17
16
15
14
13
12
11
10
RIS2
RIS1
RIS0
95
23
22
21
20
19
18
17
16
15
14
13
12
11
10
FUSE
0
ROM
96
23
22
21
20
19
18
17
16
15
14
13
12
11
10
FREQ
97
SFR_EBICFG
0xF0038040 Read-write
30 29 28 27 26 25 24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
BMS
8
SCH1
4 3
PULL1
2 1
DRIVE1
0
SCH0
PULL0
DRIVE0
This register controls EBI pins which are not multiplexed with PIO controller lines.
DRIVE0, PULL0, SCH0 control EBI Data pins when applicable. DRIVE1, PULL1, SCH1 control other EBI pins when applicable. DRIVEx: EBI Pins Drive Level
Drive level should be programmed depending on target frequency and board characteristics. Refer to pad characteristics to set correct drive level.
Value 0 1 2 3 Name LOW RESERVED MEDIUM HIGH Description Low drive level Low drive level Medium drive level High drive level
98
17.
17.1
17.2
Embedded Characteristics
z z
Controls the Interrupt Lines (nIRQ and nFIQ) of an ARM Processor 128 Individually Maskable and Vectored Interrupt Sources
z z z z z
Source 0 is Reserved for the Fast Interrupt Input (FIQ) Source 1 is Reserved for System Peripheral Interrupts Source 2 to Source 127, Control up to 126 Embedded Peripheral Interrupts or External Interrupts Programmable Edge-triggered or Level-sensitive Internal Sources Programmable Positive/Negative Edge-triggered or High/Low Level-sensitive External Sources Drives the Normal Interrupt of the Processor Handles Priority of the Interrupt Sources 1 to 127 Higher Priority Interrupts Can Be Served During Service of Lower Priority Interrupt Optimizes Interrupt Service Routine Branch and Execution One 32-bit Vector Register for all Interrupt Sources Interrupt Vector Register Reads the Corresponding Current Interrupt Vector Easy Debugging by Preventing Automatic Operations when Protect Models are Enabled Permits Redirecting any Normal Interrupt Source to the Fast Interrupt of the Processor Provides Processor Synchronization on Events Without Triggering an Interrupt
Vectoring
z z z
Protect Mode
z
Fast Forcing
z
99
17.3
Block Diagram
Figure 17-1. Block Diagram
FIQ IRQ0-IRQn AIC ARM Processor Up to 128 Sources nFIQ nIRQ
Peripheral
APB
17.4
17.5
nIRQ IRQ0-IRQn PIOIRQ Internal Source Input Stage Fast Forcing Interrupt Priority Controller Processor Clock Power Management Controller User Interface Wake Up
Embedded Peripherals
APB
100
17.6
Table 17-1. I/O Line Description Pin Name FIQ IRQ0 - IRQn Pin Description Fast Interrupt Interrupt 0 - Interrupt n Type Input Input
17.7
Product Dependencies
101
17.8
Functional Description
102
Edge
Detector Set Clear AIC_ISCR AIC_ICCR FF
AIC_IDCR
FF
103
The time the software masks the interrupts. Occurrence, either at the processor level or at the AIC level. The execution time of the instruction in progress when the interrupt occurs. The treatment of higher priority interrupts and the resynchronization of the hardware signals.
This section addresses only the hardware resynchronizations. It gives details of the latency times between the event on an external interrupt leading in a valid interrupt (edge or level) or the assertion of an internal interrupt source and the assertion of the nIRQ or nFIQ line on the processor. The resynchronization time depends on the programming of the interrupt source and on its type (internal or external). For the standard interrupt, resynchronization times are given assuming there is no higher priority in progress. The PIO Controller multiplexing has no effect on the interrupt latencies of the external interrupt sources. 17.8.2.1 External Interrupt Edge Triggered Source
Figure 17-6. External Interrupt Edge Triggered Source
MCK IRQ or FIQ (Positive Edge) IRQ or FIQ (Negative Edge)
104
nIRQ
105
17.8.3.2 Interrupt Nesting The priority controller utilizes interrupt nesting in order for the high priority interrupt to be handled during the service of lower priority interrupts. This requires the interrupt service routines of the lower interrupts to re-enable the interrupt at the processor level. When an interrupt of a higher priority happens during an already occurring interrupt service routine, the nIRQ line is reasserted. If the interrupt is enabled at the core level, the current execution is interrupted and the new interrupt service routine should read the AIC_IVR. At this time, the current interrupt number and its priority level are pushed into an embedded hardware stack, so that they are saved and restored when the higher priority interrupt servicing is finished and the AIC_EOICR is written. The AIC is equipped with an 8-level wide hardware stack in order to support up to eight interrupt nestings pursuant to having eight priority levels. 17.8.3.3 Interrupt Vectoring The interrupt handler address corresponding to the interrupt source selected by the INTSEL field can be stored in the registers AIC_SVR (Source Vector Register). When the processor reads AIC_IVR (Interrupt Vector Register), the value written into AIC_SVR corresponding to the current interrupt is returned. This feature offers a way to branch in one single instruction to the handler corresponding to the current interrupt, as AIC_IVR is mapped at the absolute address 0xFFFF F100 and thus accessible from the ARM interrupt vector at address 0x0000 0018 through the following instruction: LDR PC,[PC,# -&F20] When the processor executes this instruction, it loads the read value in AIC_IVR in its program counter, thus branching the execution on the correct interrupt handler. This feature is often not used when the application is based on an operating system (either real time or not). Operating systems often have a single entry point for all the interrupts and the first task performed is to discern the source of the interrupt. However, it is strongly recommended to port the operating system on SAMA5D3 Series devices by supporting the interrupt vectoring. This can be performed by defining the AIC_SVR of the interrupt sources to be handled by the operating system at the address of its interrupt handler. When doing so, the interrupt vectoring permits a critical interrupt to transfer the execution on a specific very fast handler and not onto the operating systems general interrupt handler. This facilitates the support of hard real-time tasks (input/outputs of voice/audio buffers and software peripheral handling) to be handled efficiently and independently of the application running under an operating system. 17.8.3.4 Interrupt Handlers This section gives an overview of the fast interrupt handling sequence when using the AIC. It is assumed that the programmer understands the architecture of the ARM processor, and especially the processor interrupt modes and the associated status bits. It is assumed that: 1. 2. The Advanced Interrupt Controller has been programmed, AIC_SVR registers are loaded with corresponding interrupt service routine addresses and interrupts are enabled. The instruction at the ARM interrupt exception vector address is required to work with the vectoring LDR PC, [PC, # -&F20] When nIRQ is asserted, if the bit I of CPSR is 0, the sequence is as follows: 1. The CPSR is stored in SPSR_irq, the current value of the Program Counter is loaded in the Interrupt link register (R14_irq) and the Program Counter (R15) is loaded with 0x18. In the following cycle during fetch at address 0x1C, the ARM core adjusts R14_irq, decrementing it by four. The ARM core enters Interrupt mode, if it has not already done so.
2.
106
3.
When the instruction loaded at address 0x18 is executed, the program counter is loaded with the value read in AIC_IVR. Reading the AIC_IVR has the following effects:
z z z z z
Sets the current interrupt to be the pending and enabled interrupt with the highest priority. The current level is the priority level of the current interrupt. De-asserts the nIRQ line on the processor. Even if vectoring is not used, AIC_IVR must be read in order to de-assert nIRQ. Automatically clears the interrupt, if it has been programmed to be edge-triggered. Pushes the current level and the current interrupt number on to the stack. Returns the value written in the AIC_SVR corresponding to the current interrupt.
4.
The previous step has the effect of branching to the corresponding interrupt service routine. This should start by saving the link register (R14_irq) and SPSR_IRQ. The link register must be decremented by four when it is saved if it is to be restored directly into the program counter at the end of the interrupt. For example, the instruction SUB PC, LR, #4 may be used. Further interrupts can then be unmasked by clearing the I bit in CPSR, allowing re-assertion of the nIRQ to be taken into account by the core. This can happen if an interrupt with a higher priority than the current interrupt occurs. The interrupt handler can then proceed as required, saving the registers that will be used and restoring them at the end. During this phase, an interrupt of higher priority than the current level will restart the sequence from step 1. If the interrupt is programmed to be level sensitive, the source of the interrupt must be cleared during this phase. The I bit in CPSR must be set in order to mask interrupts before exiting to ensure that the interrupt is completed in an orderly manner. The End of Interrupt Command Register (AIC_EOICR) must be written in order to indicate to the AIC that the current interrupt is finished. This causes the current level to be popped from the stack, restoring the previous current level if one exists on the stack. If another interrupt is pending, with lower or equal priority than the old current level but with higher priority than the new current level, the nIRQ line is re-asserted, but the interrupt sequence does not immediately start because the I bit is set in the core. SPSR_irq is restored. Finally, the saved value of the link register is restored directly into the PC. This has the effect of returning from the interrupt to whatever was being executed before, and of loading the CPSR with the stored SPSR, masking or unmasking the interrupts depending on the state saved in SPSR_irq. The I bit in SPSR is significant. If it is set, it indicates that the ARM core was on the verge of masking an interrupt when the mask instruction was interrupted. Hence, when SPSR is restored, the mask instruction is completed (interrupt is masked).
5.
6. Note: 7. 8.
Note:
107
17.8.4.3 Fast Interrupt Vectoring The fast interrupt handler address can be stored through the AIC_SVR (Source Vector Register). The value written into this register when INTSEL = 0 is returned when the processor reads AIC_FVR (Fast Vector Register). This offers a way to branch in one single instruction to the interrupt handler, as AIC_FVR is mapped at the absolute address 0xFFFF F104 and thus accessible from the ARM fast interrupt vector at address 0x0000 001C through the following instruction: LDR PC,[PC,# -&F20] When the processor executes this instruction it loads the value read in AIC_FVR in its program counter, thus branching the execution on the fast interrupt handler. It also automatically performs the clear of the fast interrupt source if it is programmed in edge-triggered mode. 17.8.4.4 Fast Interrupt Handlers This section gives an overview of the fast interrupt handling sequence when using the AIC. It is assumed that the programmer understands the architecture of the ARM processor, and especially the processor interrupt modes and associated status bits. Assuming that: 1. 2. 3. 1. The Advanced Interrupt Controller has been programmed, AIC_SVR is loaded with the fast interrupt service routine address, and the interrupt source 0 is enabled. The Instruction at address 0x1C (FIQ exception vector address) is required to vector the fast interrupt: LDR PC, [PC, # -&F20] The user does not need nested fast interrupts. The CPSR is stored in SPSR_fiq, the current value of the program counter is loaded in the FIQ link register (R14_FIQ) and the program counter (R15) is loaded with 0x1C. In the following cycle, during fetch at address 0x20, the ARM core adjusts R14_fiq, decrementing it by four. The ARM core enters FIQ mode. When the instruction loaded at address 0x1C is executed, the program counter is loaded with the value read in AIC_FVR. Reading the AIC_FVR has effect of automatically clearing the fast interrupt, if it has been programmed to be edge triggered. In this case only, it de-asserts the nFIQ line on the processor. The previous step enables branching to the corresponding interrupt service routine. It is not necessary to save the link register R14_fiq and SPSR_fiq if nested fast interrupts are not needed. The Interrupt Handler can then proceed as required. It is not necessary to save registers R8 to R13 because FIQ mode has its own dedicated registers and the user R8 to R13 are banked. The other registers, R0 to R7, must be saved before being used, and restored at the end (before the next step). Note that if the fast interrupt is programmed to be level sensitive, the source of the interrupt must be cleared during this phase in order to de-assert the interrupt source 0. Finally, the Link Register R14_fiq is restored into the PC after decrementing it by four (with instruction SUB PC, LR, #4 for example). This has the effect of returning from the interrupt to whatever was being executed before, loading the CPSR with the SPSR and masking or unmasking the fast interrupt depending on the state saved in the SPSR. The F bit in SPSR is significant. If it is set, it indicates that the ARM core was just about to mask FIQ interrupts when the mask instruction was interrupted. Hence when the SPSR is restored, the interrupted instruction is completed (FIQ is masked).
2. 3.
4. 5.
6.
Note:
Another way to handle the fast interrupt is to map the interrupt service routine at the address of the ARM vector 0x1C. This method does not use the vectoring, so that reading AIC_FVR must be performed at the very beginning of the handler operation. However, this method saves the execution of a branch instruction.
108
17.8.4.5 Fast Forcing The Fast Forcing feature of the advanced interrupt controller provides redirection of any normal Interrupt source on the fast interrupt controller. Fast Forcing is enabled or disabled by writing to the Fast Forcing Enable Register (AIC_FFER) and the Fast Forcing Disable Register (AIC_FFDR). Writing to these registers results in an update of the Fast Forcing Status Register (AIC_FFSR) that controls the feature for each internal or external interrupt source. When Fast Forcing is disabled, the interrupt sources are handled as described in the previous pages. When Fast Forcing is enabled, the edge/level programming and, in certain cases, edge detection of the interrupt source is still active but the source cannot trigger a normal interrupt to the processor and is not seen by the priority handler. If the interrupt source is programmed in level-sensitive mode and an active level is sampled, Fast Forcing results in the assertion of the nFIQ line to the core. If the interrupt source is programmed in edge-triggered mode and an active edge is detected, Fast Forcing results in the assertion of the nFIQ line to the core. The Fast Forcing feature does not affect the Source 0 pending bit in the Interrupt Pending Register (AIC_IPR). The FIQ Vector Register (AIC_FVR) reads the contents of the Source Vector Register 0 (AIC_SVR0), whatever the source of the fast interrupt may be. The read of the FVR does not clear the Source 0 when the fast forcing feature is used and the interrupt source should be cleared by writing to the Interrupt Clear Command Register (AIC_ICCR). All enabled and pending interrupt sources that have the fast forcing feature enabled and that are programmed in edgetriggered mode must be cleared by writing to the Interrupt Clear Command Register. In doing so, they are cleared independently and thus lost interrupts are prevented. The read of AIC_IVR does not clear the source that has the fast forcing feature enabled. The source 0, reserved to the fast interrupt, continues operating normally and becomes one of the Fast Interrupt sources.
Figure 17-10. Fast Forcing
Source 0 _ FIQ Input Stage AIC_IMR AIC_IPR
Automatic Clear
nFIQ
Read FVR if Fast Forcing is disabled on Sources 1 to 127. AIC_FFSR Source n Input Stage Automatic Clear AIC_IMR AIC_IPR Priority Manager nIRQ
Read IVR if Source n is the current interrupt and if Fast Forcing is disabled on Source n.
109
If an enabled interrupt with a higher priority than the current one is pending, it is stacked. If there is no enabled pending interrupt, the spurious vector is returned.
In either case, an End of Interrupt command is necessary to acknowledge and to restore the context of the AIC. This operation is generally not performed by the debug system as the debug system would become strongly intrusive and cause the application to enter an undesired state. This is avoided by using the Protect Mode. Writing PROT in AIC_DCR (Debug Control Register) at 0x1 enables the Protect Mode. When the Protect Mode is enabled, the AIC performs interrupt stacking only when a write access is performed on the AIC_IVR. Therefore, the Interrupt Service Routines must write (arbitrary data) to the AIC_IVR just after reading it. The new context of the AIC, including the value of the Interrupt Status Register (AIC_ISR), is updated with the current interrupt only when AIC_IVR is written. An AIC_IVR read on its own (e.g., by a debugger), modifies neither the AIC context nor the AIC_ISR. Extra AIC_IVR reads perform the same operations. However, it is recommended to not stop the processor between the read and the write of AIC_IVR of the interrupt service routine to make sure the debugger does not modify the AIC context. To summarize, in normal operating mode, the read of AIC_IVR performs the following operations within the AIC: 1. 2. 3. 4. 5. Calculates active interrupt (higher than current or spurious). Determines and returns the vector of the active interrupt. Memorizes the interrupt. Pushes the current priority level onto the internal stack. Acknowledges the interrupt.
However, while the Protect Mode is activated, only operations 1 to 3 are performed when AIC_IVR is read. Operations 4 and 5 are only performed by the AIC when AIC_IVR is written. Software that has been written and debugged using the Protect Mode runs correctly in Normal Mode without modification. However, in Normal Mode the AIC_IVR write has no effect and can be removed to optimize the code.
An external interrupt source is programmed in level-sensitive mode and an active level occurs for only a short time. An internal interrupt source is programmed in level sensitive and the output signal of the corresponding embedded peripheral is activated for a short time. (As in the case for the Watchdog.) An interrupt occurs just a few cycles before the software begins to mask it, thus resulting in a pulse on the interrupt source.
The AIC detects a spurious interrupt at the time the AIC_IVR is read while no enabled interrupt source is pending. When this happens, the AIC returns the value stored by the programmer in AIC_SPU (Spurious Vector Register). The programmer must store the address of a spurious interrupt handler in AIC_SPU as part of the application, to enable an as fast as possible return to the normal execution flow. This handler writes in AIC_EOICR and performs a return from interrupt.
110
AIC Source Mode Register AIC Source Vector Register AIC Spurious Interrupt Vector Register AIC Debug Control Register
111
17.9
Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 0x5C 0x6C 0xE4 0xE8
Table 17-3. Register Mapping Name AIC_SSR AIC_SMR AIC_SVR AIC_IVR AIC_FVR AIC_ISR AIC_IPR0 AIC_IPR1 AIC_IPR2 AIC_IPR3 AIC_IMR AIC_CISR AIC_EOICR AIC_SPU AIC_IECR AIC_IDCR AIC_ICCR AIC_ISCR AIC_FFER AIC_FFDR AIC_FFSR AIC_DCR AIC_WPMR AIC_WPSR Access Read-write Read-write Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Write-only Read-write Write-only Write-only Write-only Write-only Write-only Write-only Read-only Read-write Read-write Read-only Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0(1) 0x0(1) 0x0(1) 0x0(1) 0x0 0x0 0x0 0x0 0x0 0x0 0x0
Interrupt Pending Register 2(2) Interrupt Pending Register 3(2) Interrupt Mask Register Core Interrupt Status Register End of Interrupt Command Register Spurious Interrupt Vector Register Interrupt Enable Command Register Interrupt Disable Command Register Interrupt Clear Command Register Interrupt Set Command Register Fast Forcing Enable Register Fast Forcing Disable Register Fast Forcing Status Register Reserved Debug Control Register Write Protect Mode Register Write Protect Status Register Reserved
0xEC - 0xFC
Notes: 1. The reset value of this register depends on the level of the external interrupt source. All other sources are cleared at reset, thus not pending. 2. PID2...PID127 bit fields refer to the identifiers as defined in the Peripheral Identifiers Section of the product datasheet.
112
113
0x1
INT_EDGE_TRIGGERED
0x2
EXT_HIGH_LEVEL
0x3
EXT_POSITIVE_EDGE
Value 0 0 1 1 0 1 0 1
Internal Interrupt High level sensitive Positive edge triggered High level sensitive Positive edge triggered
External Interrupt Low level sensitive Negative edge triggered High level sensitive Positive edge triggered
114
Reset:
31
0x0
30 29 28 VECTOR 23 22 21 20 VECTOR 15 14 13 12 VECTOR 7 6 5 4 VECTOR 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
115
Reset:
31
0x0
30 29 28 IRQV 23 22 21 20 IRQV 15 14 13 12 IRQV 7 6 5 4 IRQV 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
116
Reset:
31
0x0
30 29 28 FIQV 23 22 21 20 FIQV 15 14 13 12 FIQV 7 6 5 4 FIQV 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
117
Reset:
31 23 15 7
0x0
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 IRQID 26 18 10 2 25 17 9 1 24 16 8 0
118
Reset:
31 PID31 23 PID23 15 PID15 7 PID7
0x0
30 PID30 22 PID22 14 PID14 6 PID6 29 PID29 21 PID21 13 PID13 5 PID5 28 PID28 20 PID20 12 PID12 4 PID4 27 PID27 19 PID19 11 PID11 3 PID3 26 PID26 18 PID18 10 PID10 2 PID2 25 PID25 17 PID17 9 PID9 1 SYS 24 PID24 16 PID16 8 PID8 0 FIQ
Reset:
31 PID63 23 PID55 15 PID47 7 PID39
0x0
30 PID62 22 PID54 14 PID46 6 PID38 29 PID61 21 PID53 13 PID45 5 PID37 28 PID60 20 PID52 12 PID44 4 PID36 27 PID59 19 PID51 11 PID43 3 PID35 26 PID58 18 PID50 10 PID42 2 PID34 25 PID57 17 PID49 9 PID41 1 PID33 24 PID56 16 PID48 8 PID40 0 PID32
119
Reset:
31 PID95 23 PID87 15 PID79 7 PID71
0x0
30 PID94 22 PID86 14 PID78 6 PID70 29 PID93 21 PID85 13 PID77 5 PID69 28 PID92 20 PID84 12 PID76 4 PID68 27 PID91 19 PID83 11 PID75 3 PID67 26 PID90 18 PID82 10 PID74 2 PID66 25 PID89 17 PID81 9 PID73 1 PID65 24 PID88 16 PID80 8 PID72 0 PID64
Reset:
31 PID127 23 PID119 15 PID111 7 PID103
0x0
30 PID126 22 PID118 14 PID110 6 PID102 29 PID125 21 PID117 13 PID109 5 PID101 28 PID124 20 PID116 12 PID108 4 PID100 27 PID123 19 PID115 11 PID107 3 PID99 26 PID122 18 PID114 10 PID106 2 PID98 25 PID121 17 PID113 9 PID105 1 PID97 24 PID120 16 PID112 8 PID104 0 PID96
120
Reset:
31 23 15 7
0x0
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 INTM
121
Reset:
31 23 15 7
0x0
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 NIRQ 24 16 8 0 NFIQ
122
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 ENDIT
123
Access: Reset:
31
Read-write 0x0
30 29 28 SIVR 27 26 25 24
23
22
21
20 SIVR
19
18
17
16
15
14
13
12 SIVR
11
10
4 SIVR
124
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 INTEN
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 INTD
125
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 INTCLR
126
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 INTSET
127
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 FFEN
Access:
31 23 15 7
Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 FFDIS
128
Access:
31 23 15 7
Read-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0 FFS
129
Access: Reset:
31 23 15 7
Read-write 0x0
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 25 17 9 1 GMSK 24 16 8 0 PROT
130
AIC Source Mode Register AIC Source Vector Register AIC Spurious Interrupt Vector Register AIC Debug Control Register WPKEY: Write Protect KEY
Should be written at value 0x414943 (AIC in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0.
131
132
18.
18.1
18.2
Embedded Characteristics
z z z
12-bit Key-protected Programmable Counter Provides Reset or Interrupt Signals to the System Counter May Be Stopped While the Processor is in Debug State or in Idle Mode
133
18.3
Block Diagram
12-bit Down Counter WDT_MR WDD Current Value reload 1/128 SLCK
set set read WDT_SR or reset WDERR reset WDUNF reset WDFIEN WDT_MR
134
18.4
Functional Description
The Watchdog Timer can be used to prevent system lock-up if the software becomes trapped in a deadlock. It is supplied with VDDCORE. It restarts with initial values on processor reset. The Watchdog is built around a 12-bit down counter, which is loaded with the value defined in the field WDV of the Mode Register (WDT_MR). The Watchdog Timer uses the Slow Clock divided by 128 to establish the maximum Watchdog period to be 16 seconds (with a typical Slow Clock of 32768 kHz). After a Processor Reset, the value of WDV is 0xFFF, corresponding to the maximum value of the counter with the external reset generation enabled (field WDRSTEN at 1 after a Backup Reset). This means that a default Watchdog is running at reset, i.e., at power-up. The user must either disable it (by setting the WDDIS bit in WDT_MR) if he does not expect to use it or must reprogram it to meet the maximum Watchdog period the application requires. If the watchdog is restarted by writing into the WDT_CR register, the WDT_MR register must not be programmed during a period of time of 3 slow clock periods following the WDT_CR write access. In any case, programming a new value in the WDT_MR register automatically initiates a restart instruction. The Watchdog Mode Register (WDT_MR) can be written only once. Only a processor reset resets it. Writing the WDT_MR register reloads the timer with the newly programmed mode parameters. In normal operation, the user reloads the Watchdog at regular intervals before the timer underflow occurs, by writing the Control Register (WDT_CR) with the bit WDRSTT to 1. The Watchdog counter is then immediately reloaded from WDT_MR and restarted, and the Slow Clock 128 divider is reset and restarted. The WDT_CR register is write-protected. As a result, writing WDT_CR without the correct hard-coded key has no effect. If an underflow does occur, the wdt_fault signal to the Reset Controller is asserted if the bit WDRSTEN is set in the Mode Register (WDT_MR). Moreover, the bit WDUNF is set in the Watchdog Status Register (WDT_SR). To prevent a software deadlock that continuously triggers the Watchdog, the reload of the Watchdog must occur while the Watchdog counter is within a window between 0 and WDD, WDD is defined in the WatchDog Mode Register WDT_MR. Any attempt to restart the Watchdog while the Watchdog counter is between WDV and WDD results in a Watchdog error, even if the Watchdog is disabled. The bit WDERR is updated in the WDT_SR and the wdt_fault signal to the Reset Controller is asserted. Note that this feature can be disabled by programming a WDD value greater than or equal to the WDV value. In such a configuration, restarting the Watchdog Timer is permitted in the whole range [0; WDV] and does not generate an error. This is the default configuration on reset (the WDD and WDV values are equal). The status bits WDUNF (Watchdog Underflow) and WDERR (Watchdog Error) trigger an interrupt, provided the bit WDFIEN is set in the mode register. The signal wdt_fault to the reset controller causes a Watchdog reset if the WDRSTEN bit is set as already explained in the reset controller programmer Datasheet. In that case, the processor and the Watchdog Timer are reset, and the WDERR and WDUNF flags are reset. If a reset is generated or if WDT_SR is read, the status bits are reset, the interrupt is cleared, and the wdt_fault signal to the reset controller is deasserted. Writing the WDT_MR reloads and restarts the down counter. While the processor is in debug state or in idle mode, the counter may be stopped depending on the value programmed for the bits WDIDLEHLT and WDDBGHLT in the WDT_MR.
135
Watchdog Fault
136
18.5
Table 18-1. Register Mapping Offset 0x00 0x04 0x08 Register Control Register Mode Register Status Register Name WDT_CR WDT_MR WDT_SR Access Write-only Read-write Once Read-only Reset 0x3FFF_2FFF 0x0000_0000
137
23 15 7
22 14 6
21 13 5
20 12 4
19 11 3
18 10 2
17 9 1
16 8 0 WDRSTT
KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
138
23
22
15 WDDIS 7
14 WDRPROC 6
13 WDRSTEN 5
12 WDFIEN 4 WDV
11
10 WDV
139
140
19.
19.1
19.2
Embedded Characteristics
z
External Devices Through the NRST Pin Processor Reset Peripheral Set Reset Backed-up Peripheral Reset
z z
Status of the Last Reset Either General Reset, Wake-up Reset, Software Reset, User Reset, Watchdog Reset
141
19.3
Block Diagram
Reset Controller
Main Supply POR Backup Supply POR Startup Counter rstc_irq Reset State Manager proc_nreset
user_reset
NRST
nrst_out
NRST Manager
exter_nreset
periph_nreset
SLCK
142
19.4
Functional Description
proc_nreset: Processor reset line. It also resets the Watchdog Timer. backup_nreset: Affects all the peripherals powered by VDDBU. periph_nreset: Affects the whole set of embedded peripherals. nrst_out: Drives the NRST pin.
These reset signals are asserted by the Reset Controller, either on external events or on software action. The Reset State Manager controls the generation of reset signals and provides a signal to the NRST Manager when an assertion of the NRST pin is required. The NRST Manager shapes the NRST assertion during a programmable time, thus controlling external device resets. The startup counter waits for the complete crystal oscillator startup. The wait delay is given by the crystal oscillator startup time maximum value that can be found in the section Crystal Oscillator Characteristics in the Electrical Characteristics section of the product documentation. The Reset Controller Mode Register (RSTC_MR), allowing the configuration of the Reset Controller, is powered with VDDBU, so that its configuration is saved as long as VDDBU is on.
URSTS NRSTL
user_reset
NRST
RSTC_MR
NRST Signal The NRST Manager handles the NRST input line asynchronously. When the line is low, a User Reset is immediately reported to the Reset State Manager. When the NRST goes from low to high, the internal reset is synchronized with the Slow Clock to provide a safe internal de-assertion of reset. The level of the pin NRST can be read at any time in the bit NRSTL (NRST level) in RSTC_SR. As soon as the pin NRST is asserted, the bit URSTS in RSTC_SR is set. This bit clears only when RSTC_SR is read.
143
19.4.2.1 NRST External Reset Control The Reset State Manager asserts the signal ext_nreset to assert the NRST pin. When this occurs, the nrst_out signal is driven low by the NRST Manager for a time programmed by the field ERSTL in RSTC_MR. This assertion duration, named EXTERNAL_RESET_LENGTH, lasts 2(ERSTL+1) Slow Clock cycles. This gives the approximate duration of an assertion between 60 s and 2 seconds. Note that ERSTL at 0 defines a two-cycle duration for the NRST pulse. This feature allows the Reset Controller to shape the NRST pin level, and thus to guarantee that the NRST line is driven low for a time compliant with potential external devices connected on the system reset. As the field is within RSTC_MR, which is backed-up, this field can be used to shape the system power-up reset for devices requiring a longer startup time than the Slow Clock Oscillator.
SLCK
BMS Signal
H or L
proc_nreset
144
Startup Time
XXX
XXX
NRST (nrst_out)
EXTERNAL RESET LENGTH BMS Sampling = 2 cycles
145
19.4.4.2 Wake-up Reset The Wake-up Reset occurs when the Main Supply is down. When the Main Supply POR output is active, all the reset signals are asserted except backup_nreset. When the Main Supply powers up, the POR output is resynchronized on Slow Clock. The processor clock is then re-enabled during Y Slow Clock cycles, depending on the requirements of the ARM processor. At the end of this delay, the processor and other reset signals rise. The field RSTTYP in RSTC_SR is updated to report a Wake-up Reset. The nrst_out remains asserted for EXTERNAL_RESET_LENGTH cycles. As RSTC_MR is backed-up, the programmed number of cycles is applicable. When the Main Supply is detected falling, the reset signals are immediately asserted. This transition is synchronous with the output of the Main Supply POR.
Figure 19-5. Wake-up Reset
backup_nreset
Resynch. 2 cycles Processor Startup
proc_nreset
RSTTYP
XXX
XXX
periph_nreset
NRST (nrst_out)
EXTERNAL RESET LENGTH = 4 cycles (ERSTL = 1)
146
19.4.4.3 User Reset The User Reset is entered when a low level is detected on the NRST pin. When a falling edge occurs on NRST (reset activation), internal reset lines are immediately asserted. The Processor Reset and the Peripheral Reset are asserted. The User Reset is left when NRST rises, after a two-cycle resynchronization time and a Y-cycle processor startup. The processor clock is re-enabled as soon as NRST is confirmed high. When the processor reset signal is released, the RSTTYP field of the Status Register (RSTC_SR) is loaded with the value 0x4, indicating a User Reset. The NRST Manager guarantees that the NRST line is asserted for EXTERNAL_RESET_LENGTH Slow Clock cycles, as programmed in the field ERSTL. However, if NRST does not rise after EXTERNAL_RESET_LENGTH because it is driven low externally, the internal reset lines remain asserted until NRST actually rises.
Figure 19-6. User Reset State
SLCK MCK
Any Freq.
NRST
Resynch. 2 cycles Processor Startup
NRST (nrst_out)
>= EXTERNAL RESET LENGTH
147
19.4.4.4 Software Reset The Reset Controller offers several commands used to assert the different reset signals. These commands are performed by writing the Control Register (RSTC_CR) with the following bits at 1:
z z
PROCRST: Writing PROCRST at 1 resets the processor and the watchdog timer. PERRST: Writing PERRST at 1 resets all the embedded peripherals, including the memory system, and, in particular, the Remap Command. The Peripheral Reset is generally used for debug purposes. Except for Debug purposes, PERRST must always be used in conjunction with PROCRST (PERRST and PROCRST set both at 1 simultaneously.) EXTRST: Writing EXTRST at 1 asserts low the NRST pin during a time defined by the field ERSTL in the Mode Register (RSTC_MR).
The software reset is entered if at least one of these bits is set by the software. All these commands can be performed independently or simultaneously. The software reset lasts Y Slow Clock cycles. The internal reset signals are asserted as soon as the register write is performed. This is detected on the Master Clock (MCK). They are released when the software reset is left, i.e.; synchronously to SLCK. If EXTRST is set, the nrst_out signal is asserted depending on the programming of the field ERSTL. However, the resulting falling edge on NRST does not lead to a User Reset. If and only if the PROCRST bit is set, the Reset Controller reports the software status in the field RSTTYP of the Status Register (RSTC_SR). Other Software Resets are not reported in RSTTYP. As soon as a software operation is detected, the bit SRCMP (Software Reset Command in Progress) is set in the Status Register (RSTC_SR). It is cleared as soon as the software reset is left. No other software reset can be performed while the SRCMP bit is set, and writing any value in RSTC_CR has no effect.
Figure 19-7. Software Reset
SLCK MCK
Any Freq.
Write RSTC_CR
Resynch. 1 to 2 cycles Processor Startup = 3 cycles
Any
XXX
SRCMP in RSTC_SR
148
19.4.4.5 Watchdog Reset The Watchdog Reset is entered when a watchdog fault occurs. This state lasts Y Slow Clock cycles. When in Watchdog Reset, assertion of the reset signals depends on the WDRPROC bit in WDT_MR:
z
If WDRPROC is 0, the Processor Reset and the Peripheral Reset are asserted. The NRST line is also asserted, depending on the programming of the field ERSTL. However, the resulting low level on NRST does not result in a User Reset state. If WDRPROC = 1, only the processor reset is asserted.
The Watchdog Timer is reset by the proc_nreset signal. As the watchdog fault always causes a processor reset if WDRSTEN is set, the Watchdog Timer is always reset after a Watchdog Reset and the Watchdog is enabled by default and with a period set to a maximum. When the WDRSTEN in WDT_MR bit is reset, the watchdog fault has no impact on the reset controller.
Figure 19-8. Watchdog Reset
SLCK MCK
Any Freq.
wd_fault
Processor Startup = 3 cycles
proc_nreset RSTTYP periph_nreset Only if WDRPROC = 0 Any XXX 0x2 = Watchdog Reset
NRST (nrst_out)
EXTERNAL RESET LENGTH 8 cycles (ERSTL=2)
149
Backup Reset Wake-up Reset User Reset Watchdog Reset Software Reset When in User Reset:
z z
A watchdog event is impossible because the Watchdog Timer is being reset by the proc_nreset signal. A software reset is impossible, since the processor reset is being activated. A watchdog event has priority over the current state. The NRST has no effect. The processor reset is active and so a Software Reset cannot be programmed. A User Reset cannot be entered.
RSTTYP field: This field gives the type of the last reset, as explained in previous sections. SRCMP bit: This field indicates that a Software Reset Command is in progress and that no further software reset should be performed until the end of the current one. This bit is automatically cleared at the end of the current software reset. NRSTL bit: The NRSTL bit of the Status Register gives the level of the NRST pin sampled on each MCK rising edge. URSTS bit: A high-to-low transition of the NRST pin sets the URSTS bit of the RSTC_SR register. This transition is also detected on the Master Clock (MCK) rising edge (see Figure 19-9). Reading the RSTC_SR status register resets the URSTS bit.
z z
Peripheral Access
2 cycle resynchronization
150
19.5
Table 19-1. Register Mapping Offset 0x00 0x04 0x08 Register Control Register Status Register Mode Register Name RSTC_CR RSTC_SR RSTC_MR Access Write-only Read-only Read-write Reset 0x0000_0001(1) 0x0000_0000 0x0000_0000 Back-up Reset
Note:
1. The reset value of RSTC_SR either reports a General Reset or a Wake-up Reset depending on the last rising power supply.
151
23 15 7
22 14 6
21 13 5
20 12 4
19 11 3 EXTRST
18 10 2 PERRST
17 9
16 8 0 PROCRST
KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
152
0 URSTS
153
23 15 7
22 14 6
21 13 5
20 12 4
19 11
18 10 ERSTL
17 9
16 8
KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
154
20.
20.1
20.2
Embedded Characteristics
z
Software Assertion of the SHDW Output Pin Programmable De-assertion from the WKUP Input Pins
20.3
Block Diagram
WAKEUP0 SHDW_SR
set
read SHDW_SR
Wake-up
reset
SHDW_MR
RTCWK
set
SHDW_SR SHDW_CR
SHDN
SHDW
155
20.4
Table 20-1. I/O Lines Description Name WKUP0 SHDN Description Wake-up 0 input Shutdown output Type Input Output
20.5
Product Dependencies
20.6
Functional Description
The Shutdown Controller manages the main power supply. To do so, it is supplied with VDDBU and manages wake-up input pins and one output pin, SHDN. A typical application connects the pin SHDN to the shutdown input of the DC/DC Converter providing the main power supplies of the system, and especially VDDCORE and/or VDDIO. The wake-up inputs (WKUP0) connect to any pushbuttons or signal that wake up the system. The software is able to control the pin SHDN by writing the Shutdown Control Register (SHDW_CR) with the bit SHDW at 1. The shutdown is taken into account only 2 slow clock cycles after the write of SHDW_CR. This register is passwordprotected and so the value written should contain the correct key for the command to be taken into account. As a result, the system should be powered down. A level change on WKUP0 is used as wake-up. Wake-up is configured in the Shutdown Mode Register (SHDW_MR). The transition detector can be programmed to detect either a positive or negative transition or any level change on WKUP0. The detection can also be disabled. Programming is performed by defining WKMODE0. Moreover, a debouncing circuit can be programmed for WKUP0. The debouncing circuit filters pulses on WKUP0 shorter than the programmed number of 16 SLCK cycles in CPTWK0 of the SHDW_MR register. If the programmed level change is detected on a pin, a counter starts. When the counter reaches the value programmed in the corresponding field, CPTWK0, the SHDN pin is released. If a new input change is detected before the counter reaches the corresponding value, the counter is stopped and cleared. WAKEUP0 of the Status Register (SHDW_SR) reports the detection of the programmed events on WKUP0 with a reset after the read of SHDW_SR. The Shutdown Controller can be programmed so as to activate the wake-up using the RTC alarm (the detection of the rising edge of the RTC alarm is synchronized with SLCK). This is done by writing the SHDW_MR register using the RTCWKEN field. When enabled, the detection of the RTC alarm is reported in the RTCWK bit of the SHDW_SR Status register. It is reset after the read of SHDW_SR. When using the RTC alarm to wake up the system, the user must ensure that the RTC alarm status flag is cleared before shutting down the system.Otherwise, no rising edge of the status flag may be detected and the wake-up fails fail.
156
20.7
Table 20-2. Register Mapping Offset 0x00 0x04 0x08 Register Shutdown Control Register Shutdown Mode Register Shutdown Status Register Name SHDW_CR SHDW_MR SHDW_SR Access Write-only Read-write Read-only Reset 0x0000_0000
157
23 15 7
22 14 6
21 13 5
20 12 4
19 11 3
18 10 2
17 9 1
16 8 0 SHDW
KEY: Password
Should be written at value 0xA5. Writing any other value in this field aborts the write operation.
158
WKMODE[1:0] 0 0 1 1 0 1 0 1
Wake-up Input Transition Selection None. No detection is performed on the wake-up input Low to high level High to low level Both levels change
159
160
21.
21.1
21.2
Embedded Characteristics
z
161
21.3
Table 21-1. Register Mapping Offset 0x0 ... 0x6C Register General Purpose Backup Register 0 ... General Purpose Backup Register 3 Name SYS_GPBR0 ... SYS_GPBR3 Access Read-write ... Read-write Reset ...
GPBR_VALUE
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
162
22.
22.1
22.2
Embedded Characteristics
z z z z z
Ultra Low -power Consumption Full Asynchronous Design Gregorian Calendar up to 2099 Programmable Periodic Interrupt Valid Time and Date Programmation Check
163
22.3
Block Diagram
32768 Divider
Time
Date
Bus Interface
Bus Interface
Entry Control
Interrupt Control
RTC Interrupt
164
22.4
Product Dependencies
22.4.2 Interrupt
Within the System Controller, the RTC interrupt is OR-wired with all the other module interrupts. Only one System Controller interrupt line is connected on one of the internal sources of the interrupt controller. RTC interrupt requires the interrupt controller to be programmed first. When a System Controller interrupt occurs, the service routine must first determine the cause of the interrupt. This is done by reading each status register of the System Controller peripherals successively.
Table 22-1. Peripheral IDs Instance RTC ID 1
22.5
Functional Description
The RTC provides a full binary-coded decimal (BCD) clock that includes century (19/20), year (with leap years), month, date, day, hours, minutes and seconds. The valid year range is 1900 to 2099 in Gregorian mode, a two-hundred-year calendar. The RTC can operate in 24-hour mode or in 12-hour mode with an AM/PM indicator. Corrections for leap years are included (all years divisible by 4 being leap years). This is correct up to the year 2099.
22.5.2 Timing
The RTC is updated in real time at one-second intervals in normal mode for the counters of seconds, at one-minute intervals for the counter of minutes and so on. Due to the asynchronous operation of the RTC with respect to the rest of the chip, to be certain that the value read in the RTC registers (century, year, month, date, day, hours, minutes, seconds) are valid and stable, it is necessary to read these registers twice. If the data is the same both times, then it is valid. Therefore, a minimum of two and a maximum of three accesses are required.
22.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:
z z
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.
165
166
Begin
ACKUPD =1?
No
Yes
End
167
22.6
Table 22-2. Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C
Note:
168
23
22
21
20
19
18
17
16
15
14
13
12
11
10 9
CALEVSEL
8
2 1
TIMEVSEL
0
UPDCAL
UPDTIM
169
23
22
21
20
19
18
17
16
15
14
13
12
11
10
HRMOD
170
23
22
21
20
19
18
17
16
15
AMPM
14 13 12 11
HOUR
10 9 8
7 6 5 4
MIN
3 2 1 0
SEC
171
23
22 21 20 19
DATE
18 17 16
DAY
15 14 13 12 11
MONTH
10 9 8
YEAR
7 6 5 4 3 2 1 0
CENT
172
23
22
21
20
19
18
17
16
HOUREN
15
AMPM
14 13 12 11
HOUR
10 9 8
MINEN
7 6 5 4
MIN
3 2 1 0
SECEN
SEC
173
DATEEN
23
22 21 20 19
DATE
18 17 16
MTHEN
15
14
13 12 11
MONTH
10 9 8
174
23
22
21
20
19
18
17
16
15
14
13
12
11
10
CALEV
TIMEV
SEC
ALARM
ACKUPD
175
23
22
21
20
19
18
17
16
15
14
13
12
11
10
CALCLR
TIMCLR
SECCLR
ALRCLR
ACKCLR
176
23
22
21
20
19
18
17
16
15
14
13
12
11
10
CALEN
TIMEN
SECEN
ALREN
ACKEN
177
23
22
21
20
19
18
17
16
15
14
13
12
11
10
CALDIS
TIMDIS
SECDIS
ALRDIS
ACKDIS
178
23
22
21
20
19
18
17
16
15
14
13
12
11
10
CAL
TIM
SEC
ALR
ACK
179
23
22
21
20
19
18
17
16
15
14
13
12
11
10
NVCALALR
NVTIMALR
NVCAL
NVTIM
180
23.
23.1
23.2
Embedded Characteristics
z z
181
23.3
Block Diagram
Figure 23-1. Block Diagram
RCEN
On Chip RC OSC Slow Clock SLCK XIN32 XOUT32 Slow Clock Oscillator OSCSEL OSC32EN OSC32BYP
RCEN, OSC32EN, OSCSEL and OSC32BYP bits are located in the Slow Clock Configuration Register (SCKC_CR) located at the address 0xFFFFFE50 in the backed up part of the System Controller and, thus, they are preserved while VDDBU is present. After a VDDBU power on reset, the default configuration is RCEN = 1, OSC32EN = 0 and OSCSEL = 0, allowing the system to start on the internal 32 kHz RC oscillator. The programmer controls the slow clock switching by software and so must take precautions during the switching phase.
182
Switch the master clock to a source different from slow clock (PLL or Main Oscillator) through the Power Management Controller. Enable the 32768 Hz oscillator by setting the bit OSC32EN to 1. Wait 32768 Hz Startup Time for clock stabilization (software loop). Switch from internal 32 kHz RC oscillator to 32768 Hz oscillator by setting the bit OSCSEL to 1. Wait 5 slow clock cycles for internal resynchronization. Disable the 32 kHz RC oscillator by setting the bit RCEN to 0.
An external clock must be connected on XIN32. Enable the bypass path OSC32BYP bit set to 1. Disable the 32768 Hz oscillator by setting the bit OSC32EN to 0.
Switch the master clock to a source different from slow clock (PLL or Main Oscillator). Enable the internal 32 kHz RC oscillator for low power by setting the bit RCEN to 1 Wait internal 32 kHz RC Startup Time for clock stabilization (software loop). Switch from 32768 Hz oscillator to internal RC by setting the bit OSCSEL to 0. Wait 5 slow clock cycles for internal resynchronization. Disable the 32768 Hz oscillator by setting the bit OSC32EN to 0.
183
23.4
Table 23-1. Register Mapping Offset 0x0 Register Slow Clock Configuration Register Name SCKC_CR Access Read-write Reset 0x0000_0001
184
24.
24.1
Clock Generator
Description
The Clock Generator User Interface is embedded within the Power Management Controller and is described in Section 25.13 Power Management Controller (PMC) User Interface. However, the Clock Generator registers are named CKGR_.
24.2
Embedded characteristics
The Clock Generator is made up of:
z z z z z z
Low-power 32768 Hz Slow Clock Oscillator with bypass mode Low-power RC Oscillator 8 to 48 MHz Crystal Oscillator or a 24/48 MHz XRCGB Crystal Resonator, which can be bypassed (12 MHz, 24 MHz (preferred) or 48 MHz must be used in case of USB operations) Fast RC Oscillator, at 12 MHz 480 MHz UTMI PLL providing a clock for the USB High Speed Device Controller 400 to 1000 MHz programmable PLL (input from 8 to 50 MHz), capable of providing the clock MCK to the processor and to the peripherals SLCK, the Slow Clock, which is the only permanent clock within the system MAINCK is the output of the Main Clock Oscillator selection: either Crystal Oscillator or 12 MHz Fast RC Oscillator PLLACK is the output of the Divider and 400 to 1000 MHz programmable PLL (PLLA) UPLLCK is the output of the 480 MHz UTMI PLL (UPLL) SMDCK is the Software Modem Clock Main crystal oscillator clock failure detector Frequency counter on main clock and an on-the-fly adjustable main RC oscillator frequency
The Power Management Controller also provides the following operations on clocks:
z z
185
24.3
Block Diagram
Figure 24-1. Clock Generator Block Diagram
Clock Generator RCEN On Chip 32K RC OSC XIN32 XOUT32 Slow Clock Oscillator
UPLL
UPLLCK
Status
Control
186
24.4
XIN XOUT
MOSCRCEN, MOSCXTEN, MOSCSEL and MOSCXTBY bits are located in the PMC Clock Generator Main Oscillator Register (CKGR_MOR). After a VDDBU power on reset, the default configuration is MOSCRCEN = 1, MOSCXTEN = 0 and MOSCSEL = 0, the 12 MHz RC is started as Main clock.
12 MHz RC
187
Enable the 12 MHz oscillator by setting the bit MOSCXTEN to 1. Wait for 12 MHz oscillator status MAINRDY is 1. Switch from internal 12 MHz RC to the 12 MHz oscillator by setting the bit MOSCSEL to 1. If not the bit MOSCSEL is set to 0 by the PMC. Disable the 12 MHz RC oscillator by setting the bit MOSCRCEN to 0.
An external clock must be connected on XIN. Enable the bypass path MOSCXTBY bit set to 1. Disable the 12 MHz oscillator by setting the bit MOSCXTEN to 0.
24.4.4 Switch from the 12 MHz Crystal Oscillator to internal 12 MHz RC Oscillator
The same procedure must be followed to switch from a 12 MHz crystal oscillator to the internal 12 MHz RC oscillator.
z z z z
Enable the internal 12 MHz RC oscillator for low power by setting the bit MOSCRCEN to 1 Wait internal 12 MHz RC Startup Time for clock stabilization (software loop). Switch from 12 MHz oscillator to internal 12 MHz RC by setting the bit MOSCSEL to 0. Disable the 12 MHz oscillator by setting the bit MOSCXTEN to 0.
188
24.5
Main Clock
Figure 24-4. Main Clock Block Diagram
MOSCRCEN MOSCRCF MOSCRCS 12 MHz Fast RC Oscillator MOSCSEL MOSCSELS
1
MOSCXTEN
XIN XOUT
MOSCXTCNT
MOSCXTS
MAINF MAINRDY
12 MHz Fast RC Oscillator which starts very quickly and is used at startup 8 to 48 MHz Crystal Oscillator, which can be bypassed
189
190
MCK must select the slow clock (CSS=0 in PLL_MCKR register). Wait for the MCKRDY flag in the PLL_SR register to be 1. The fast crystal must be enabled by programming 1 in the MOSCXTEN field in the CKGR_MOR register, with the MOSCXTST field being programmed to the appropriate value (see the electrical characteristics chapter). Wait for the MOSCXTS flag to be 1 in the PLL_SR register to get the end of startup period of the fast crystal oscillator. Then, MOSCSEL must be programmed to 1 in the CKGR_MOR register to select the fast main crystal oscillator for the main clock. The MOSCSEL must be read until its value equals 1. Then the MOSCSELS status flag must be checked in the PLL_SR register. If MOSCSELS = 1, there is a valid crystal connected and its frequency can be determined by initiating a frequency measure by programming RCMEAS in the CKGR_MCFR register. If MOSCSELS = 0, there is no fast crystal clock (either no crystal connected or a crystal clock out of specification). A frequency measure can reinforce this status by initiating a frequency measure by programming RCMEAS in the CKGR_MCFR register. If MOSCSELS=0, the selection of the main clock must be programmed back to the main RC oscillator by writing MOSCSEL to 0 prior to disabling the fast crystal oscillator. If MOSCSELS=0, the crystal oscillator can be disabled (MOSCXTEN=0 in the CKGR_MOR register).
z z
When the 12 MHz Fast RC Oscillator clock is selected as the source of Main Clock and when this oscillator becomes stable (i.e., when the MOSCRCS bit is set) When the Crystal Oscillator is selected as the source of Main Clock and when this oscillator becomes stable (i.e., when the MOSCXTS bit is set) When the Main Clock Oscillator selection is modified
Then, at the 16th falling edge of Slow Clock, the MAINFRDY bit in the Clock Generator Main Clock Frequency Register (CKGR_MCFR) is set and the counter stops counting. Its value can be read in the MAINF field of CKGR_MCFR and gives the number of Main Clock cycles during 16 periods of Slow Clock, so that the frequency of the 12 MHz Fast RC Oscillator or the Crystal Oscillator can be determined.
191
24.6
MAINCK
Divider
PLLA
PLLACK
PLLACOUNT SLCK
PLLA Counter
LOCKA
192
24.7
MAINCK
UTMI PLL
UPLLCK
UPLLCOUNT SLCK
LOCKU
Whenever the UTMI PLL is enabled by writing UPLLEN in CKGR_UCKR, the LOCKU bit in PMC_SR is automatically cleared. The values written in the PLLCOUNT field in CKGR_UCKR are loaded in the UTMI PLL counter. The UTMI PLL counter then decrements at the speed of the Slow Clock divided by 8 until it reaches 0. At this time, the LOCKU bit is set in PMC_SR and can trigger an interrupt to the processor. The user has to load the number of Slow Clock cycles required to cover the UTMI PLL transient time into the PLLCOUNT field.
193
25.
25.1
MCK, the Master Clock, programmable from a few hundred Hz to the maximum operating frequency of the device. It is available to the modules running permanently. Processor Clock (PCK), must be switched off when entering the processor in Sleep Mode. The USB Device HS Clock (UDPCK) The Software Modem Clock (SMDCK) Peripheral Clocks, typically MCK, provided to the embedded peripherals (USART, SSC, SPI, TWI, TC, HSMCI, etc.) and independently controllable. In order to reduce the number of clock names in a product, the Peripheral Clocks are named MCK in the product datasheet. Programmable Clock Outputs can be selected from the clocks provided by the clock generator and driven on the PCKx pins.
25.2
194
25.3
Block Diagram
UPLLCK
PCK int
/2
/1 /2
/3
Divider
Periph_clk[..]
195
25.4
25.5
25.6
DDR2/LPDDR/LPDDR2 Clock
The Power Management Controller controls the clocks of the DDR memory. The DDR clock can be enabled and disabled with the DDRCK bit respectively in the PMC_SCER and PMC_SDER registers. At reset, the DDR clock is disabled to save power consumption. In the case MDIV = 00, (PCK = MCK) SysClk DDR and DDRCK clocks are not available. If the Input clock is PLLACK/2, the DDR Controller can drive DDR2, LPDDR and LPDDR2 at up to 166 MHz with MDIV = 11. To save PLLA power consumption, the user can choose UPLLCK an Input clock for the system. In this case the DDR Controller can drive LD-DDR at up to 120 MHz.
25.7
196
25.8
25.9
197
198
199
The MDIV field is used to control the Master Clock divider. It is possible to choose between different values (0, 1, 2, 3). The Master Clock output is Master/Processor Clock Prescaler output divided by 1, 2, 4 or 3, depending on the value programmed in MDIV. The PMC PLLA Clock input must be divided by 2, thanks to the PLLADIV2 field. By default, MDIV and PLLLADIV2 are set to 0, which indicates that Processor Clock is equal to the Master Clock. Once the PMC_MCKR register has been written, the user must wait for the MCKRDY bit to be set in the PMC_SR register. This can be done either by polling the status register or by waiting for the interrupt line to be raised if the associated interrupt to MCKRDY has been enabled in the PMC_IER register. The PMC_MCKR register must not be programmed in a single write operation. The preferred programming sequence for the PMC_MCKR register is as follows:
z
Program the PRES field in the PMC_MCKR register. Wait for the MCKRDY bit to be set in the PMC_SR register. Program the CSS field in the PMC_MCKR register. Wait for the MCKRDY bit to be set in the PMC_SR register. Program the CSS field in the PMC_MCKR register. Wait for the MCKRDY bit to be set in the PMC_SR register. Program the PRES field in the PMC_MCKR register. Wait for the MCKRDY bit to be set in the PMC_SR register.
If a new value for CSS field corresponds to Main Clock or Slow Clock,
z z z z
If at some stage one of the following parameters, CSS or PRES, is modified, the MCKRDY bit will go low to indicate that the Master Clock and the Processor Clock are not ready yet. The user must wait for MCKRDY bit to be set again before using the Master and Processor Clocks. Note: IF PLLA clock was selected as the Master Clock and the user decides to modify it by writing in CKGR_PLLAR, the MCKRDY flag will go low while PLLA is unlocked. Once PLLA is locked again, LOCK goes high and MCKRDY is set. While PLLA is unlocked, the Master Clock selection is automatically changed to Main Clock. For further information, see Section 25.12.2. Clock Switching Waveforms on page 203. Code Example: write_register(PMC_MCKR,0x00000001) wait (MCKRDY=1) write_register(PMC_MCKR,0x00000011) wait (MCKRDY=1) The Master Clock is main clock divided by 16. The Processor Clock is the Master Clock. 5. Selecting Programmable Clocks Programmable clocks are controlled via registers; PMC_SCER, PMC_SCDR and PMC_SCSR. Programmable clocks can be enabled and/or disabled via the PMC_SCER and PMC_SCDR registers. Depending on the system used, 3 programmable clocks can be enabled or disabled. The PMC_SCSR provides a clear indication as to which Programmable clock is enabled. By default all Programmable clocks are disabled. PMC_PCKx registers are used to configure programmable clocks. The CSS and CSSMCK fields are used to select the programmable clock divider source. Five clock options are available: main clock, slow clock, master clock, PLLACK, UPLLCK. By default, the clock source selected is slow clock. The PRES field is used to control the programmable clock prescaler. It is possible to choose between different values (1, 2, 4, 8, 16, 32, 64). Programmable clock output is prescaler input divided by PRES parameter. By default, the PRES parameter is set to 1 which means that master clock is equal to slow clock.
200
Once the PMC_PCKx register has been programmed, The corresponding programmable clock must be enabled and the user is constrained to wait for the PCKRDYx bit to be set in the PMC_SR register. This can be done either by polling the status register or by waiting the interrupt line to be raised if the associated interrupt to PCKRDYx has been enabled in the PMC_IER register. All parameters in PMC_PCKx can be programmed in a single write operation. If the CSS and PRES parameters are to be modified, the corresponding programmable clock must be disabled first. The parameters can then be modified. Once this has been done, the user must re-enable the programmable clock and wait for the PCKRDYx bit to be set. Code Example: write_register(PMC_PCK0,0x00000015) Programmable clock 0 is main clock divided by 32. 6. Enabling Peripheral Clocks Once all of the previous steps have been completed, the peripheral clocks can be enabled and/or disabled via registers PMC_PCER and PMC_PCDR. Depending on the system used, 19 peripheral clocks can be enabled or disabled. The PMC_PCSR provides a clear view as to which peripheral clock is enabled. Note: Each enabled peripheral clock corresponds to Master Clock. Code Examples: write_register(PMC_PCER,0x00000110) Peripheral clocks 4 and 8 are enabled. write_register(PMC_PCDR,0x00000010) Peripheral clock 4 is disabled.
201
PLL Clock
Notes: 1. 2.
PLL designates either the PLLA or the UPLL Clock. PLLCOUNT designates either PLLACOUNT or UPLLCOUNT.
Table 25-2. Clock Switching Timings between Two PLLs (Worst Case) From To PLLA Clock 2.5 x PLLA Clock + 4 x SLCK + PLLACOUNT x SLCK 3 x UPLL Clock + 4 x SLCK + 1.5 x UPLL Clock 3 x PLLA Clock + 4 x SLCK + 1.5 x PLLA Clock 2.5 x UPLL Clock + 4 x SLCK + UPLLCOUNT x SLCK PLLA Clock UPLL Clock
UPLL Clock
202
Slow Clock
PLL Clock
LOCK
MCKRDY
Master Clock
Write PMC_MCKR
Figure 25-4. Switch Master Clock from Main Clock to Slow Clock
Slow Clock
Main Clock
MCKRDY
Master Clock
Write PMC_MCKR
203
Slow Clock
PLLA Clock
LOCKA
MCKRDY
PLL Clock
PCKRDY
PCKx Output
Write PMC_PCKx
Write PMC_SCER
PCKx is enabled
Write PMC_SCDR
PCKx is disabled
204
205
Table 25-3. Register Mapping Offset 0x0108 0x010C 0x0110 Register Peripheral Clock Status Register 1 Peripheral Control Register Oscillator Calibration Register Name PMC_PCSR1 PMC_PCR PMC_OCR Access Read-only Read-write Read-write Reset 0x0000_0000 0x0000_0000 0x0040_4040
206
207
208
209
This register can only be written if the WPEN bit is cleared in PMC Write Protect Mode Register on page 230.
210
This register can only be written if the WPEN bit is cleared in PMC Write Protect Mode Register on page 230.
211
212
23
22 UPLLCOUNT
21
20
15 7
14 6
13 5
12 4
213
15
14
13
12 MOSCXTST
11
10
5 0
3 MOSCRCEN
1 MOSCXTBY
0 MOSCXTEN
Warning: Bit 4,5,6 must always be set to 0 when programming the CKGR_MOR register.
KEY: Password
0x37 (PASSWD): Should be written at value 0x37. Writing any other value in this field aborts the write operation.
214
215
216
15 OUTA 7
14
13
Possible limitations on PLL 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 register.
DIVA: Divider A
Value 0 1 2 - 255 Name 0 BYPASS Description Divider output is 0 Divider is bypassed Divider output is the selected clock divided by DIVA.
217
218
PCK_DIV2
PCK_DIV4
PCK_DIV3
219
220
0 SMDS
221
222
MOSCXTS: Main Crystal Oscillator Status Interrupt Enable LOCKA: PLLA Lock Interrupt Enable MCKRDY: Master Clock Ready Interrupt Enable LOCKU: UTMI PLL Lock Interrupt Enable PCKRDYx: Programmable Clock Ready x Interrupt Enable MOSCSELS: Main Oscillator Selection Status Interrupt Enable MOSCRCS: Main On-Chip RC Status Interrupt Enable CFDEV: Clock Failure Detector Event Interrupt Enable
223
MOSCXTS: Main Crystal Oscillator Status Interrupt Disable LOCKA: PLLA Lock Interrupt Disable MCKRDY: Master Clock Ready Interrupt Disable LOCKU: UTMI PLL Lock Interrupt Enable PCKRDYx: Programmable Clock Ready x Interrupt Disable MOSCSELS: Main Oscillator Selection Status Interrupt Disable MOSCRCS: Main On-Chip RC Status Interrupt Disable CFDEV: Clock Failure Detector Event Interrupt Disable
224
225
226
MOSCXTS: Main Crystal Oscillator Status Interrupt Mask LOCKA: PLLA Lock Interrupt Mask MCKRDY: Master Clock Ready Interrupt Mask PCKRDYx: Programmable Clock Ready x Interrupt Mask MOSCSELS: Main Oscillator Selection Status Interrupt Mask MOSCRCS: Main On-Chip RC Status Interrupt Mask CFDEV: Clock Failure Detector Event Interrupt Mask
227
228
229
23
22
21
20 WPKEY
19
18
17
16
15
14
13
12 WPKEY
11
10
0 WPEN
PMC System Clock Enable Register on page 207 PMC System Clock Disable Register on page 208 PMC Clock Generator Main Clock Frequency Register on page 216 PMC Clock Generator PLLA Register on page 217 PMC Clock Generator PLLA Register on page 217 PMC Master Clock Register on page 218 PMC USB Clock Register on page 220 PMC Programmable Clock Register on page 222 PLL Charge Pump Current Register on page 229 PMC Peripheral Clock Enable Register 0 on page 210 PMC Peripheral Clock Disable Register 1 on page 233 PMC Oscillator Calibration Register on page 236 WPKEY: Write Protect KEY
Should be written at value 0x504D43 (PMC in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0.
230
15
14
13
12 WPVSRC
11
10
0 WPVS
231
This register can only be written if the WPEN bit is cleared in PMC Write Protect Mode Register on page 230.
232
This register can only be written if the WPEN bit is cleared in PMC Write Protect Mode Register on page 230.
233
234
PID: Peripheral ID
Peripheral ID selection from PID2 to PID31 PID2 to PID31 refer to identifiers as defined in the section Peripheral Identifiers in the product datasheet.
CMD: Command
0: Read mode 1: Write mode
EN: Enable
0: Selected Peripheral clock is disabled 1: Selected Peripheral clock is enabled
235
This register can only be written if the WPEN bit is cleared in PMC Write Protect Mode Register on page 230.
236
26.
26.1
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 PIO 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.
26.2
Embedded Characteristics
z z z z
Up to 32 Programmable I/O Lines Fully Programmable through Set/Clear Registers Multiplexing of Four Peripheral Functions per I/O Line For each I/O Line (Whether Assigned to a Peripheral or Used as General Purpose I/O)
z z z z z z z z
Input Change Interrupt Programmable Glitch Filter Programmable Debouncing Filter Multi-drive Option Enables Driving in Open Drain Programmable Pull Up on Each I/O Line Pin Data Status Register, Supplies Visibility of the Level on the Pin at Any Time Additional Interrupt Modes on a Programmable Event: Rising Edge, Falling Edge, Low Level or High Level Lock of the Configuration by the Connected Peripheral
z z z z
Synchronous Output, Provides Set and Clear of Several I/O lines in a Single Write Write Protect Registers Programmable Schmitt Trigger Inputs Programmable I/O Drive
237
26.3
Block Diagram
PIO Controller
Interrupt Controller PIO Interrupt
PMC
PIO Clock
Data, Enable
Embedded Peripheral
Up to 32 peripheral IOs
PIN 0 Data, Enable PIN 1 Up to 32 pins Embedded Peripheral Up to 32 peripheral IOs PIN 31
APB
PIO Controller
Keyboard Driver General Purpose I/Os External Devices
238
26.4
Product Dependencies
239
26.5
Functional Description
The PIO Controller features up to 32 fully-programmable I/O lines. Most of the control logic associated to each I/O is represented in Figure 26-3. In this description each signal shown represents but one of up to 32 possible indexes.
Peripheral A Output Enable Peripheral B Output Enable Peripheral C Output Enable Peripheral D Output Enable PIO_ABCDSR1[0] PIO_ABCDSR2[0] Peripheral A Output Peripheral B Output Peripheral C Output Peripheral D Output
0 0
PIO_MDER[0] PIO_MDSR[0]
0
PIO_MDDR[0] 0
Pad 1
PIO_PDSR[0] PIO_ISR[0] 0
D Q DFF D DFF Q
EVENT DETECTOR
PIO_SCDR
240
241
242
APB Access
APB Access
26.5.8 Inputs
The level on each I/O line can be read through PIO_PDSR (Pin Data Status Register). 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.
If PIO_IFSCSR[i] = 0: The glitch filter can filter a glitch with a duration of less than 1/2 Period of Master Clock. If PIO_IFSCSR[i] = 1: The debouncing filter can filter a pulse with a duration of less than 1/2 Period of the Programmable Divided Slow Clock.
For the debouncing filter, the Period of the Divided Slow Clock is performed by writing in the DIV field of the PIO_SCDR (Slow Clock Divider Register) Tdiv_slclk = ((DIV+1)*2).Tslow_clock When the glitch or debouncing filter is enabled, a glitch or pulse with a duration of less than 1/2 Selected Clock Cycle (Selected Clock represents MCK or Divided Slow Clock depending on PIO_IFSCDR and PIO_IFSCER programming) is automatically rejected, while a pulse with a duration of 1 Selected Clock (MCK or Divided Slow Clock) cycle or more is accepted. For pulse durations between 1/2 Selected Clock cycle and 1 Selected Clock cycle the pulse may or may not be taken into account, depending on the precise timing of its occurrence. Thus for a pulse to be visible it must exceed 1
243
Selected Clock cycle, whereas for a glitch to be reliably filtered out, its duration must not exceed 1/2 Selected Clock cycle. The filters also introduce some latencies, this is illustrated in Figure 26-5 and Figure 26-6. The glitch filters are controlled by the register set: PIO_IFER (Input Filter Enable Register), PIO_IFDR (Input Filter Disable Register) and PIO_IFSR (Input Filter Status Register). Writing PIO_IFER and PIO_IFDR respectively sets and clears bits in PIO_IFSR. This last register enables the glitch filter on the I/O lines. When the glitch and/or debouncing filter is enabled, it does not modify the behavior of the inputs on the peripherals. It acts only on the value read in PIO_PDSR and on the input change interrupt detection. The glitch and debouncing filters require that the PIO Controller clock is enabled.
Figure 26-5. Input Glitch Filter Timing
PIO_IFCSR = 0
MCK up to 1.5 cycles Pin Level 1 cycle PIO_PDSR if PIO_IFSR = 0 2 cycles PIO_PDSR if PIO_IFSR = 1 up to 2.5 cycles up to 2 cycles 1 cycle 1 cycle 1 cycle 1 cycle
PIO_IFCSR = 1
Divided Slow Clock
1 cycle Tdiv_slclk
244
Rising Edge Detection Falling Edge Detection Low Level Detection High Level Detection The type of event detection (Edge or Level) must be selected by writing in the set of registers; PIO_ESR (Edge Select Register) and PIO_LSR (Level Select Register) which enable respectively, the Edge and Level Detection. The current status of this selection is accessible through the PIO_ELSR (Edge/Level Status Register). The Polarity of the event detection (Rising/Falling Edge or High/Low Level) must be selected by writing in the set of registers; PIO_FELLSR (Falling Edge /Low Level Select Register) and PIO_REHLSR (Rising Edge/High Level Select Register) which allow to select Falling or Rising Edge (if Edge is selected in the PIO_ELSR) Edge or High or Low Level Detection (if Level is selected in the PIO_ELSR). The current status of this selection is accessible through the PIO_FRLHSR (Fall/Rise - Low/High Status Register).
When an input Edge or Level is detected on an I/O line, the corresponding bit in PIO_ISR (Interrupt Status Register) is set. If the corresponding bit in PIO_IMR is set, the PIO Controller interrupt line is asserted.The interrupt signals of the thirty-two channels are ORed-wired together to generate a single interrupt signal to the interrupt controller. When the software reads PIO_ISR, all the interrupts are automatically cleared. This signifies that all the interrupts that are pending when PIO_ISR is read must be handled. When an Interrupt is enabled on a Level, the interrupt is generated as long as the interrupt source is not cleared, even if some read accesses in PIO_ISR are performed.
245
0 0
Rising edge on PIO line 0 Falling edge on PIO line 1 Rising edge on PIO line 2 Low Level on PIO line 3 High Level on PIO line 4 High Level on PIO line 5 Falling edge on PIO line 6 Rising edge on PIO line 7 Any edge on the other lines
The configuration required is described below. 26.5.10.2 Interrupt Mode Configuration All the interrupt sources are enabled by writing 32hFFFF_FFFF in PIO_IER. Then the Additional Interrupt Mode is enabled for line 0 to 7 by writing 32h0000_00FF in PIO_AIMER. 26.5.10.3 Edge or Level Detection Configuration Lines 3, 4 and 5 are configured in Level detection by writing 32h0000_0038 in PIO_LSR. 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. 26.5.10.4 Falling/Rising Edge or Low/High Level Detection Configuration. Lines 0, 2, 4, 5 and 7 are configured in Rising Edge or High Level detection by writing 32h0000_00B5 in PIO_REHLSR. 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.
246
Figure 26-8. Input Change Interrupt Timings if there are no Additional Interrupt Modes
MCK
Pin Level
PIO_ISR
Read PIO_ISR
APB Access
APB Access
247
PIO Enable Register on page 252 PIO Disable Register on page 252 PIO Output Enable Register on page 253 PIO Output Disable Register on page 254 PIO Input Filter Enable Register on page 255 PIO Input Filter Disable Register on page 255 PIO Multi-driver Enable Register on page 260 PIO Multi-driver Disable Register on page 261 PIO Pull Up Disable Register on page 262 PIO Pull Up Enable Register on page 262 PIO Peripheral ABCD Select Register 1 on page 264 PIO Peripheral ABCD Select Register 2 on page 265 PIO Output Write Enable Register on page 270 PIO Output Write Disable Register on page 270 PIO Pad Pull Down Disable Register on page 268 PIO Pad Pull Down Status Register on page 269
248
26.6
4-bit output port on I/O lines 0 to 3, (should be written in a single write operation), open-drain, with pull-up resistor Four output signals on I/O lines 4 to 7 (to drive LEDs for example), driven high and low, no pull-up resistor, no pulldown resistor Four input signals on I/O lines 8 to 11 (to read push-button states for example), with pull-up resistors, glitch filters and input change interrupts Four input signals on I/O line 12 to 15 to read an external device status (polled, thus no input change interrupt), no pull-up resistor, no glitch filter I/O lines 16 to 19 assigned to peripheral A functions with pull-up resistor I/O lines 20 to 23 assigned to peripheral B functions with pull-down resistor I/O line 24 to 27 assigned to peripheral C with Input Change Interrupt, no pull-up resistor and no pull-down resistor I/O line 28 to 31 assigned to peripheral D, no pull-up resistor and no pull-down resistor
Table 26-1. Programming Example Register PIO_PER PIO_PDR PIO_OER PIO_ODR PIO_IFER PIO_IFDR PIO_SODR PIO_CODR PIO_IER PIO_IDR PIO_MDER PIO_MDDR PIO_PUDR PIO_PUER PIO_PPDDR PIO_PPDER PIO_ABCDSR1 PIO_ABCDSR2 PIO_OWER PIO_OWDR Value to be Written 0x0000_FFFF 0xFFFF_0000 0x0000_00FF 0xFFFF_FF00 0x0000_0F00 0xFFFF_F0FF 0x0000_0000 0x0FFF_FFFF 0x0F00_0F00 0xF0FF_F0FF 0x0000_000F 0xFFFF_FFF0 0xFFF0_00F0 0x000F_FF0F 0xFF0F_FFFF 0x00F0_0000 0xF0F0_0000 0xFF00_0000 0x0000_000F 0x0FFF_ FFF0
249
26.7
Table 26-2. Register Mapping Offset 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028 0x002C 0x0030 0x0034 0x0038 0x003C 0x0040 0x0044 0x0048 0x004C 0x0050 0x0054 0x0058 0x005C 0x0060 0x0064 0x0068 0x006C 0x0070 0x0074 0x0078 to 0x007C 0x0080 0x0084 0x0088 Register PIO Enable Register PIO Disable Register PIO Status Register Reserved Output Enable Register Output Disable Register Output Status Register Reserved Glitch Input Filter Enable Register Glitch Input Filter Disable Register Glitch Input Filter Status Register Reserved Set Output Data Register Clear Output Data Register Output Data Status Register Pin Data Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Interrupt Status Register
(4)
Name PIO_PER PIO_PDR PIO_PSR PIO_OER PIO_ODR PIO_OSR PIO_IFER PIO_IFDR PIO_IFSR PIO_SODR PIO_CODR PIO_ODSR PIO_PDSR PIO_IER PIO_IDR PIO_IMR PIO_ISR PIO_MDER PIO_MDDR PIO_MDSR PIO_PUDR PIO_PUER PIO_PUSR PIO_ABCDSR1 PIO_ABCDSR2 PIO_IFSCDR PIO_IFSCER PIO_IFSCSR
Access Write-only Write-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only or(2) Read-write Read-only Write-only Write-only Read-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only Read-write Read-write Write-only Write-only Read-only
Reset
(1)
(3)
Multi-driver Enable Register Multi-driver Disable Register Multi-driver Status Register Reserved Pull-up Disable Register Pull-up Enable Register Pad Pull-up Status Register Reserved Peripheral Select Register 1 Peripheral Select Register 2 Reserved Input Filter Slow Clock Disable Register Input Filter Slow Clock Enable Register Input Filter Slow Clock Status Register
250
Table 26-2. Register Mapping (Continued) Offset 0x008C 0x0090 0x0094 0x0098 0x009C 0x00A0 0x00A4 0x00A8 0x00AC 0x00B0 0x00B4 0x00B8 0x00BC 0x00C0 0x00C4 0x00C8 0x00CC 0x00D0 0x00D4 0x00D8 0x00DC 0x00E0 0x00E4 0x00E8 0x00EC to 0x00F8 0x0100 0x01040x010C 0x0110 0x0114 0x0118 0x011C 0x0120 to 0x014C Register Slow Clock Divider Debouncing Register Pad Pull-down Disable Register Pad Pull-down Enable Register Pad Pull-down Status Register Reserved Output Write Enable Output Write Disable Output Write Status Register Reserved Additional Interrupt Modes Enable Register Additional Interrupt Modes Disables Register Additional Interrupt Modes Mask Register Reserved Edge Select Register Level Select Register Edge/Level Status Register Reserved Falling Edge/Low Level Select Register Rising Edge/ High Level Select Register Fall/Rise - Low/High Status Register Reserved Lock Status Write Protect Mode Register Write Protect Status Register Reserved Schmitt Trigger Register Reserved Reserved Reserved I/O Drive Register 1 I/O Drive Register 2 Reserved PIO_LOCKSR PIO_WPMR PIO_WPSR PIO_SCHMITT PIO_DRIVER1 PIO_DRIVER2 Read-only Read-write Read-only Read-write Read-write Read-write 0x00000000 0x0 0x0 0x00000000 0x00000000 0x00000000 Name PIO_SCDR PIO_PPDDR PIO_PPDER PIO_PPDSR PIO_OWER PIO_OWDR PIO_OWSR PIO_AIMER PIO_AIMDR PIO_AIMMR PIO_ESR PIO_LSR PIO_ELSR PIO_FELLSR PIO_REHLSR PIO_FRLHSR Access Read-write Write-only Write-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only Reset 0x00000000
(1)
Notes: 1. Reset value depends on the product implementation. 2. PIO_ODSR is Read-only or Read/Write depending on PIO_OWSR I/O lines. 3. Reset value of PIO_PDSR depends on the level of the I/O lines. 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. 4. PIO_ISR is reset at 0x0. However, the first read of the register may read a different value as input changes may have occurred. Note: If an offset is not listed in the table it must be considered as reserved.
251
PIO_PER 0xFFFFF200 (PIOA), 0xFFFFF400 (PIOB), 0xFFFFF600 (PIOC), 0xFFFFF800 (PIOD), 0xFFFFFA00 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_PDR 0xFFFFF204 (PIOA), 0xFFFFF404 (PIOB), 0xFFFFF604 (PIOC), 0xFFFFF804 (PIOD), 0xFFFFFA04 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
252
PIO_PSR 0xFFFFF208 (PIOA), 0xFFFFF408 (PIOB), 0xFFFFF608 (PIOC), 0xFFFFF808 (PIOD), 0xFFFFFA08 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_OER 0xFFFFF210 (PIOA), 0xFFFFF410 (PIOB), 0xFFFFF610 (PIOC), 0xFFFFF810 (PIOD), 0xFFFFFA10 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
253
PIO_ODR 0xFFFFF214 (PIOA), 0xFFFFF414 (PIOB), 0xFFFFF614 (PIOC), 0xFFFFF814 (PIOD), 0xFFFFFA14 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_OSR 0xFFFFF218 (PIOA), 0xFFFFF418 (PIOB), 0xFFFFF618 (PIOC), 0xFFFFF818 (PIOD), 0xFFFFFA18 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
254
PIO_IFER 0xFFFFF220 (PIOA), 0xFFFFF420 (PIOB), 0xFFFFF620 (PIOC), 0xFFFFF820 (PIOD), 0xFFFFFA20 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_IFDR 0xFFFFF224 (PIOA), 0xFFFFF424 (PIOB), 0xFFFFF624 (PIOC), 0xFFFFF824 (PIOD), 0xFFFFFA24 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
255
PIO_IFSR 0xFFFFF228 (PIOA), 0xFFFFF428 (PIOB), 0xFFFFF628 (PIOC), 0xFFFFF828 (PIOD), 0xFFFFFA28 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_SODR 0xFFFFF230 (PIOA), 0xFFFFF430 (PIOB), 0xFFFFF630 (PIOC), 0xFFFFF830 (PIOD), 0xFFFFFA30 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
256
PIO_CODR 0xFFFFF234 (PIOA), 0xFFFFF434 (PIOB), 0xFFFFF634 (PIOC), 0xFFFFF834 (PIOD), 0xFFFFFA34 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_ODSR 0xFFFFF238 (PIOA), 0xFFFFF438 (PIOB), 0xFFFFF638 (PIOC), 0xFFFFF838 (PIOD), 0xFFFFFA38 (PIOE) Read-only or Read-write
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
257
PIO_PDSR 0xFFFFF23C (PIOA), 0xFFFFF43C (PIOB), 0xFFFFF63C (PIOC), 0xFFFFF83C (PIOD), 0xFFFFFA3C (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_IER 0xFFFFF240 (PIOA), 0xFFFFF440 (PIOB), 0xFFFFF640 (PIOC), 0xFFFFF840 (PIOD), 0xFFFFFA40 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
258
PIO_IDR 0xFFFFF244 (PIOA), 0xFFFFF444 (PIOB), 0xFFFFF644 (PIOC), 0xFFFFF844 (PIOD), 0xFFFFFA44 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_IMR 0xFFFFF248 (PIOA), 0xFFFFF448 (PIOB), 0xFFFFF648 (PIOC), 0xFFFFF848 (PIOD), 0xFFFFFA48 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
259
PIO_ISR 0xFFFFF24C (PIOA), 0xFFFFF44C (PIOB), 0xFFFFF64C (PIOC), 0xFFFFF84C (PIOD), 0xFFFFFA4C (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_MDER 0xFFFFF250 (PIOA), 0xFFFFF450 (PIOB), 0xFFFFF650 (PIOC), 0xFFFFF850 (PIOD), 0xFFFFFA50 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
260
PIO_MDDR 0xFFFFF254 (PIOA), 0xFFFFF454 (PIOB), 0xFFFFF654 (PIOC), 0xFFFFF854 (PIOD), 0xFFFFFA54 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_MDSR 0xFFFFF258 (PIOA), 0xFFFFF458 (PIOB), 0xFFFFF658 (PIOC), 0xFFFFF858 (PIOD), 0xFFFFFA58 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
261
PIO_PUDR 0xFFFFF260 (PIOA), 0xFFFFF460 (PIOB), 0xFFFFF660 (PIOC), 0xFFFFF860 (PIOD), 0xFFFFFA60 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_PUER 0xFFFFF264 (PIOA), 0xFFFFF464 (PIOB), 0xFFFFF664 (PIOC), 0xFFFFF864 (PIOD), 0xFFFFFA64 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
262
PIO_PUSR 0xFFFFF268 (PIOA), 0xFFFFF468 (PIOB), 0xFFFFF668 (PIOC), 0xFFFFF868 (PIOD), 0xFFFFFA68 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
263
PIO_ABCDSR1 Read-write
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
264
PIO_ABCDSR2 Read-write
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
265
PIO_IFSCDR 0xFFFFF280 (PIOA), 0xFFFFF480 (PIOB), 0xFFFFF680 (PIOC), 0xFFFFF880 (PIOD), 0xFFFFFA80 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_IFSCER 0xFFFFF284 (PIOA), 0xFFFFF484 (PIOB), 0xFFFFF684 (PIOC), 0xFFFFF884 (PIOD), 0xFFFFFA84 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
266
PIO_IFSCSR 0xFFFFF288 (PIOA), 0xFFFFF488 (PIOB), 0xFFFFF688 (PIOC), 0xFFFFF888 (PIOD), 0xFFFFFA88 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_SCDR 0xFFFFF28C (PIOA), 0xFFFFF48C (PIOB), 0xFFFFF68C (PIOC), 0xFFFFF88C (PIOD), 0xFFFFFA8C (PIOE) Read-write
30 29 28 27 26 25 24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
6 5 4 3
DIV
2 1 0
DIV
267
PIO_PPDDR 0xFFFFF290 (PIOA), 0xFFFFF490 (PIOB), 0xFFFFF690 (PIOC), 0xFFFFF890 (PIOD), 0xFFFFFA90 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_PPDER 0xFFFFF294 (PIOA), 0xFFFFF494 (PIOB), 0xFFFFF694 (PIOC), 0xFFFFF894 (PIOD), 0xFFFFFA94 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
268
PIO_PPDSR 0xFFFFF298 (PIOA), 0xFFFFF498 (PIOB), 0xFFFFF698 (PIOC), 0xFFFFF898 (PIOD), 0xFFFFFA98 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
269
PIO_OWER 0xFFFFF2A0 (PIOA), 0xFFFFF4A0 (PIOB), 0xFFFFF6A0 (PIOC), 0xFFFFF8A0 (PIOD), 0xFFFFFAA0 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
PIO_OWDR 0xFFFFF2A4 (PIOA), 0xFFFFF4A4 (PIOB), 0xFFFFF6A4 (PIOC), 0xFFFFF8A4 (PIOD), 0xFFFFFAA4 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
This register can only be written if the WPEN bit is cleared in PIO Write Protect Mode Register .
270
PIO_OWSR 0xFFFFF2A8 (PIOA), 0xFFFFF4A8 (PIOB), 0xFFFFF6A8 (PIOC), 0xFFFFF8A8 (PIOD), 0xFFFFFAA8 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_AIMER 0xFFFFF2B0 (PIOA), 0xFFFFF4B0 (PIOB), 0xFFFFF6B0 (PIOC), 0xFFFFF8B0 (PIOD), 0xFFFFFAB0 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
271
PIO_AIMDR 0xFFFFF2B4 (PIOA), 0xFFFFF4B4 (PIOB), 0xFFFFF6B4 (PIOC), 0xFFFFF8B4 (PIOD), 0xFFFFFAB4 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_AIMMR 0xFFFFF2B8 (PIOA), 0xFFFFF4B8 (PIOB), 0xFFFFF6B8 (PIOC), 0xFFFFF8B8 (PIOD), 0xFFFFFAB8 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
272
PIO_ESR 0xFFFFF2C0 (PIOA), 0xFFFFF4C0 (PIOB), 0xFFFFF6C0 (PIOC), 0xFFFFF8C0 (PIOD), 0xFFFFFAC0 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_LSR 0xFFFFF2C4 (PIOA), 0xFFFFF4C4 (PIOB), 0xFFFFF6C4 (PIOC), 0xFFFFF8C4 (PIOD), 0xFFFFFAC4 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
273
PIO_ELSR 0xFFFFF2C8 (PIOA), 0xFFFFF4C8 (PIOB), 0xFFFFF6C8 (PIOC), 0xFFFFF8C8 (PIOD), 0xFFFFFAC8 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
PIO_FELLSR 0xFFFFF2D0 (PIOA), 0xFFFFF4D0 (PIOB), 0xFFFFF6D0 (PIOC), 0xFFFFF8D0 (PIOD), 0xFFFFFAD0 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
274
PIO_REHLSR 0xFFFFF2D4 (PIOA), 0xFFFFF4D4 (PIOB), 0xFFFFF6D4 (PIOC), 0xFFFFF8D4 (PIOD), 0xFFFFFAD4 (PIOE) Write-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
275
PIO_FRLHSR 0xFFFFF2D8 (PIOA), 0xFFFFF4D8 (PIOB), 0xFFFFF6D8 (PIOC), 0xFFFFF8D8 (PIOD), 0xFFFFFAD8 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
276
PIO_LOCKSR 0xFFFFF2E0 (PIOA), 0xFFFFF4E0 (PIOB), 0xFFFFF6E0 (PIOC), 0xFFFFF8E0 (PIOD), 0xFFFFFAE0 (PIOE) Read-only
30 29 28 27 26 25 24
P31
23
P30
22
P29
21
P28
20
P27
19
P26
18
P25
17
P24
16
P23
15
P22
14
P21
13
P20
12
P19
11
P18
10
P17
9
P16
8
P15
7
P14
6
P13
5
P12
4
P11
3
P10
2
P9
1
P8
0
P7
P6
P5
P4
P3
P2
P1
P0
277
PIO_WPMR 0xFFFFF2E4 (PIOA), 0xFFFFF4E4 (PIOB), 0xFFFFF6E4 (PIOC), 0xFFFFF8E4 (PIOD), 0xFFFFFAE4 (PIOE) Read-write See Table 26-2
30 29 28 WPKEY 23 22 21 20 WPKEY 15 14 13 12 WPKEY 7 6 5 4 3 2 1 0 WPEN 11 10 9 8 19 18 17 16 27 26 25 24
For more information on Write Protection Registers, refer to Section 26.7 Parallel Input/Output Controller (PIO) User Interface.
PIO Enable Register on page 252 PIO Disable Register on page 252 PIO Output Enable Register on page 253 PIO Output Disable Register on page 254 PIO Input Filter Enable Register on page 255 PIO Input Filter Disable Register on page 255 PIO Multi-driver Enable Register on page 260 PIO Multi-driver Disable Register on page 261 PIO Pull Up Disable Register on page 262 PIO Pull Up Enable Register on page 262 PIO Peripheral ABCD Select Register 1 on page 264 PIO Peripheral ABCD Select Register 2 on page 265 PIO Output Write Enable Register on page 270 PIO Output Write Disable Register on page 270 PIO Pad Pull Down Disable Register on page 268 PIO Pad Pull Down Status Register on page 269 WPKEY: Write Protect KEY
Should be written at value 0x50494F (PIO in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0.
278
PIO_WPSR 0xFFFFF2E8 (PIOA), 0xFFFFF4E8 (PIOB), 0xFFFFF6E8 (PIOC), 0xFFFFF8E8 (PIOD), 0xFFFFFAE8 (PIOE) Read-only See Table 26-2
30 29 28 27 26 25 24
23
22
21
20 WPVSRC
19
18
17
16
15
14
13
12 WPVSRC
11
10
0 WPVS
279
PIO_SCHMITT 0xFFFFF300 (PIOA), 0xFFFFF500 (PIOB), 0xFFFFF700 (PIOC), 0xFFFFF900 (PIOD), 0xFFFFFB00 (PIOE) Read-write See Table 26-2
30 SCHMITT30 22 SCHMITT22 14 SCHMITT14 6 SCHMITT6 29 SCHMITT29 21 SCHMITT21 13 SCHMITT13 5 SCHMITT5 28 SCHMITT28 20 SCHMITT20 12 SCHMITT12 4 SCHMITT4 27 SCHMITT27 19 SCHMITT19 11 SCHMITT11 3 SCHMITT3 26 SCHMITT26 18 SCHMITT18 10 SCHMITT10 2 SCHMITT2 25 SCHMITT25 17 SCHMITT17 9 SCHMITT9 1 SCHMITT1 24 SCHMITT24 16 SCHMITT16 8 SCHMITT8 0 SCHMITT0
SCHMITTx [x=0..31]:
0: Schmitt Trigger is enabled. 1: Schmitt Trigger is disabled.
280
PIO_DRIVER1 0xFFFFF318 (PIOA), 0xFFFFF518 (PIOB), 0xFFFFF718 (PIOC), 0xFFFFF918 (PIOD), 0xFFFFFB18 (PIOE) Read-write 0x0
30 29 LINE14 20 19 LINE9 10 9 LINE4 0 28 27 LINE13 18 17 LINE8 8 26 25 LINE12 16 24
281
PIO_DRIVER2 0xFFFFF31C (PIOA), 0xFFFFF51C (PIOB), 0xFFFFF71C (PIOC), 0xFFFFF91C (PIOD), 0xFFFFFB1C (PIOE) Read-write 0x0
30 29 LINE30 20 19 LINE25 10 9 LINE20 0 28 27 LINE29 18 17 LINE24 8 26 25 LINE28 16 24
282
27.
External Memories
The product features:
z z
Multiport DDR Controller (MPDDRC) External Bus Interface (EBI) that embeds a NAND Flash controller and a Static Memory Controller (HSMC)
EBI NAND Flash Controller Bus Matrix Static Memory Controller Static Memory Device NAND Flash Device
z z
MPDDRC is a standalone multi-port DDRSDR controller. It supports only DDR2, LPDDR, and LPDDR2-S4 devices. Its user interface is located at 0xFFFFEA00. HSMC supports Static Memories and MLC/SLC NAND Flashes. It embeds Multi-Bit ECC. Its user interface is located at 0xFFFFC000.
283
27.1
27.1.1 Description
The DDR2 Controller is dedicated to 8-port DDR2/LPDDR/LPDDR2 support. Data transfers are performed through a 32bit data bus on one chip select. The Controller operates with 1.8V Power Supply for DDR2 and LP-DDR, 1.2V Power Supply for LP-DDR2.
z z
2K, 4K, 8K, 16K Row Address Memory Parts DDR2 with Four or Eight Internal Banks (DDR2_SDRAM/Low-Power DDR2-SDRAM) DDR2/LPDDR with 32-bit Data Path One Chip Select for DDR2/LPDDR Device (512 Mbytes Address Space) Multibank Ping-pong Access (Up to 4 or 8 Banks Opened at Same Time = Reduces Average Latency of Transactions) Timing Parameters Specified by Software Automatic Refresh Operation, Refresh Rate is Programmable Automatic Update of DS, TCR and PASR Parameters (Low-power DDR-SDRAM Devices) Self-refresh, Power-down, Active Power-down and Deep Power-down Modes Supported
Programming Facilities
z z z z
Energy-saving Capabilities
z
z z z z z z
Power-up Initialization by Software CAS Latency of 2, 3, 4, 5, 6 supported Reset function supported (DDR2) Auto Precharge Command Not Used On Die Termination not supported OCD mode not supported
284
MPDDRC
DDR_A0-DDR_A13 DDR_D0-DDR_D31 Bus Matrix DDR_CS DDR_CKE DDR_RAS, DDR_CAS AHB DDR2 LPDDR LPDDR2-S4 Controller DDR_CLK,#DDR_CLK DDR_DQS[3:0] DDR_DQSN[3:0] DDR_DQM[3:0] DDR_WE DDR_BA[2:0] Address Decoders DDR_CALP DDR_CALN
APB
285
In LPDDR2 mode, DQS and DQSN are connected to the LPDDR2 memory.
286
287
Hardware Configuration
Figure 27-3. 2x16-bit DDR2 Hardware Configuration
Software Configuration
The following configuration has to be performed:
z
Initialize the DDR2 Controller depending on the DDR2 device and system bus frequency.
The DDR2 initialization sequence is described in the sub-section DDR2 Device Initialization of the DDRSDRC section.
288
Hardware Configuration
Figure 27-4. 2x16-bit LPDDR2 Hardware Configuration
Table 27-3.
CA0 CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 CA9
Higher CAs
Software Configuration
The following configuration has to be performed:
z
Initialize the DDR2 Controller depending on the LPDDR2 device and system bus frequency.
The DDR2 initialization sequence is described in the sub-section LPDDR2 Device Initialization of the DDRSDRC section.
289
27.2
27.2.1 Description
The External Bus Interface is designed to ensure the successful data transfer between several external devices and the ARM processor-based device. The External Bus Interface of the device consists of a Static Memory Controller (HSMC). This HSMC is capable of handling several types of external memory and peripheral devices, such as SRAM, PSRAM, PROM, EPROM, EEPROM, LCD Module, NOR Flash and NAND Flash. The HSMC generates the signals that control the access to external memory devices or peripheral devices. It has 4 Chip Selects and a 26-bit address bus. The 16-bit data bus can be configured to interface with 8- or 16-bit external devices. Separate read and write control signals allow for direct memory and peripheral interfacing. Read and write signal waveforms are fully parametrizable. The HSMC can manage wait requests from external devices to extend the current access. The HSMC 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 HSMC embeds a NAND Flash Controller (NFC). The NFC can handle automatic transfers, sending the commands and address cycles to the NAND Flash and transferring the contents of the page (for read and write) to the NFC SRAM. It minimizes the CPU overhead. The HSMC includes programmable hardware error correcting code with one-bit error correction capability and supports two-bit error detection. In order to improve the overall system performance, the DATA phase of the transfer can be DMAassisted. The External Data Bus can be scrambled/unscrambled by means of user keys. The full description is available in the HSMC section. 27.2.1.1 External Bus Interface (EBI)
z
z z z z z
Additional logic for NAND Flash Optional 16-bit External Data Bus Up to 26-bit Address Bus (up to 64 MBytes linear per chip select) Up to 4 chip selects, Configurable Assignment NAND Flash chip select is programmable:
64-MByte Address Space per Chip Select 8- or 16-bit Data Bus Word, Halfword, Byte Transfers Byte Write or Byte Select Lines Programmable Setup, Pulse and Hold Time for Read Signals per Chip Select Programmable Setup, Pulse and Hold Time for Write Signals per Chip Select Programmable Data Float Time per Chip Select External Data Bus Scrambling/Unscrambling Function External Wait Request Automatic Switch to Slow Clock Mode NAND Flash Controller Supporting NAND Flash with Multiplexed Data/Address Buses Supports SLC and MLC NAND Flash Technology Programmable Timing on a per Chip Select Basis
290
Programmable Flash Data Width 8 bits or 16 bits. Supports NAND Flash and SmartMedia Devices with 8- or 16-bit Data Path. Supports 1-bit Correction for a Page of 512, 1024, 2048 and 4096 Bytes with 8- or 16-bit Data Path. Supports 1-bit Correction per 512 Bytes of Data for a Page Size of 512, 2048 and 4096 Bytes with 8-bit Data Path. Supports 1-bit Correction per 256 Bytes of Data for a Page Size of 512, 2048 and 4096 Bytes with 8-bit Data Path. Multibit Error Correcting Code (ECC)
z z z z z z z z z z z z z
ECC Algorithm based on binary shortened Bose, Chaudhuri and Hocquenghem (BCH) codes. Programmable Error Correcting Capability: 2, 4, 8, 12 and 24 bits of errors per block. Programmable block size: 512 Bytes or 1024 Bytes. Programmable number of block per page: 1, 2, 4 or 8 blocks of data per page. Programmable spare area size. Supports spare area ECC protection. Supports 8 kBytes page size using 1024 Bytes/block and 4 kBytes page size using 512 Bytes/block. Multibit Error detection is interrupt driven. Provides hardware acceleration for determining roots of polynomials defined over a finite field Programmable finite Field GF(2^13) or GF(2^14) Finds roots of error-locator polynomial. Programmable finite Field GF(2^13) or GF(2^14) Finds roots of error-locator polynomial.
291
Hardware Configuration
Software Configuration
The following configuration has to be performed:
z z z z z z
Select the NAND Flash Chip Select by setting the field CSID in NFCADDR_CMD register. Configure the NFC and HSMC according to the used NAND Flash. Enable the NFC with NFCEN bit in HSMC_CTRL register in HSMC User interface. Reserve A21/A22 for ALE/CLE functions. Address and Command Latches are controlled respectively by setting to 1 the address bits A21 and A22 during accesses. Configure a PIO line as an input to manage the Ready/Busy signal. Configure Static Memory Controller CS3 Setup, Pulse, Cycle and Mode accordingly to NAND Flash timings, the data bus width and the system bus frequency.
292
Hardware Configuration
Software Configuration
The software configuration is the same as for an 8-bit NAND Flash except for the data bus width programmed in the mode register of the Static Memory Controller.
293
Hardware Configuration
D[0..15] A[1..22] U1 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22
25 24 23 22 21 20 19 18 8 7 6 5 4 3 2 1 48 17 16 15 10 9 12 11 14 13 26 28
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 RESET WE WP VPP CE OE
DQ0 DQ1 DQ2 DQ3 DQ4 DQ5 DQ6 DQ7 DQ8 DQ9 DQ10 DQ11 DQ12 DQ13 DQ14 DQ15
AT49BV6416
29 31 33 35 38 40 42 44 30 32 34 36 39 41 43 45
3V3
47 37 46 27
C2 100NF
C1 100NF
TSOP48 PACKAGE
Software Configuration
The default configuration for the Static Memory Controller, byte select mode, 16-bit data bus, Read/Write controlled by Chip Select, allows boot on 16-bit non-volatile memory at slow clock. For another configuration, configure the Static Memory Controller CS0 Setup, Pulse, Cycle and Mode depending on Flash timings and system bus frequency.
294
28.
28.1
295
28.2
Embedded Characteristics
z z z z
Four Advanced High Performance Bus (AHB) Interfaces, Management of All Accesses Maximizes Memory Bandwidth and Minimizes Transaction Latency Bus Transfer: Dword, Word, Half Word, Byte Access Supports Low-power DDR2-SDRAM-S4 (LPDDR2), DDR2-SDRAM, Low-power DDR1-SDRAM (LPDDR1) Numerous Configurations Supported
z z z z
2K, 4K, 8K, 16K Row Address Memory Parts DDR-SDRAM with Four or Eight Internal Banks (DDR2-SDRAM/ Low-power DDR2-SDRAM-S4) DDR-SDRAM with 32-bit Data Path for System Oriented Dword Access One Chip Select for SDRAM Device (512-Mbyte Address Space) Multibank Ping-pong Access (Up to 4 or 8 Banks Opened at the Same Time = Reduced Average Latency of Transactions) Timing Parameters Specified by Software Automatic Refresh Operation, Refresh Rate is Programmable Automatic Update of DS, TCR and PASR Parameters (Low-power DDR-SDRAM Devices) Self-refresh, Power-down, Active Power-down and Deep Power-down Modes Supported
Programming Facilities
z z z z
Energy-saving Capabilities
z
z z z z z z z z
DDR-SDRAM Power-up Initialization by Software CAS Latency of 2, 3, 4, 5, 6 Supported Reset Function Supported (DDR2-SDRAM) ODT (On-die Termination) Not Supported Auto-refresh per bank Supported (Low-power DDR2-SDRAM-S4) Automatic Adjust Refresh Rate (Low-power DDR2-SDRAM-S4) Auto-precharge Command Not Used OCD (Off-chip Driver) Mode Not Supported
296
28.3
clk/nclk AHB Slave Interface 1 Input Stage Output Stage AHB Slave Interface 2 Input Stage Arbiter Memory Controller Finite State Machine SDRAM Signal Management ras, cas, we, cke Addr, DQM DDR-Devices DQS Data odt AHB Slave Interface 3 Input Stage Asynchronous Timing Refresh Management
Interconnect Matrix
APB
Interface APB
An Interconnect-Matrix that manages concurrent accesses on the AHB bus between four AHB masters and integrates an arbiter. A controller that translates AHB requests (Read/Write) in the DDR-SDRAM protocol.
297
28.4
3.
5.
6.
7.
8.
9.
10. A Mode Register set (MRS) cycle is issued to program the parameters of the DDR1-SDRAM devices, in particular CAS latency, burst length. The application must set MODE to 3 in the Mode Register (see Section 28.7.1 on page 319) and perform a write access to the Low-power DDR1-SDRAM to acknowledge this command. The write address must be chosen so that BA[1:0] bits are set to 0. For example, the SDRAM write access should be done at the address (BASE_ADDRESS_DDR). 11. The application must go into Normal Mode, setting MODE to 0 in the Mode Register (see Section 28.7.1 on page 319) and performing a write access at any location in the Low-power DDR1-SDRAM to acknowledge this command. 12. Perform a write access to any Low-power DDR1-SDRAM address. 13. Write the refresh rate into the COUNT field in the MPDDRC Refresh Timer register (see page 320). (Refresh rate = delay between refresh cycles). The Low-power DDR1-SDRAM device requires a refresh every 15.625 s or 7.81 s. With a 100 MHz frequency, the refresh timer count register must be set with (15.625 * 100 MHz) = 1562 i.e. 0x061A or (7.81 *100 MHz) = 781 i.e. 0x030d. 14. After initialization, the Low-power DDR1-SDRAM device is fully functional.
298
3.
5.
6.
7. 8.
9.
10. An additional 200 cycles of clock are required for locking DLL 11. Program DLL field into the Configuration Register (see Section 28.7.3 on page 321) to high (Enable DLL reset). 12. A Mode Register set (MRS) cycle is issued to reset DLL. The application must set MODE to 3 in the Mode Register (see Section 28.7.1 on page 319) and perform a write access to the DDR2-SDRAM to acknowledge this command. The write address must be chosen so that BA[1:0] bits are set to 0. For example, the SDRAM write access should be done at the address (BASE_ADDRESS_DDR). 13. An all banks precharge command is issued to the DDR2-SDRAM. Program all banks precharge command into the Mode Register, the application must set MODE to 2 in the Mode Register (see Section 28.7.1 on page 319). Perform a write access to any DDR2-SDRAM address to acknowledge this command 14. Two auto-refresh (CBR) cycles are provided. Program the auto refresh command (CBR) into the Mode Register, the application must set MODE to 4 in the Mode Register (see Section 28.7.1 on page 319). Performs a write access to any DDR2-SDRAM location twice to acknowledge these commands. 15. Program DLL field into the Configuration Register (see Section 28.7.3 on page 321) to low (Disable DLL reset). 16. A Mode Register set (MRS) cycle is issued to program the parameters of the DDR2-SDRAM devices, in particular CAS latency, burst length and to disable DLL reset. The application must set MODE to 3 in the Mode Register (see
299
Section 28.7.1 on page 319) and perform a write access to the DDR2-SDRAM to acknowledge this command. The write address must be chosen so that BA[1:0] are set to 0. 17. Program OCD field into the Configuration Register (see Section 28.7.3 on page 321) to high (OCD calibration default). 18. An Extended Mode Register set (EMRS1) cycle is issued to OCD default value. The application must set MODE to 5 in the Mode Register (see Section 28.7.1 on page 319) and perform a write access to the DDR2-SDRAM to acknowledge this command. The write address must be chosen so that BA[1] is set to 0 and BA[0] is set to 1. For example, with a 32-bit 1Gbit SDRAM (14 rows, 10 columns, 8 banks), the SDRAM write access should be done at the address (BASE_ADDRESS_DDR + 0x04000000). 19. Program OCD field in the Configuration Register (see Section 28.7.3 on page 321) to low (OCD calibration mode exit). 20. An Extended Mode Register set (EMRS1) cycle is issued to enable OCD exit. The application must set MODE to 5 in the Mode Register (see Section 28.7.1 on page 319) and perform a write access to the DDR2-SDRAM to acknowledge this command. The write address must be chosen so that BA[1] is set to 0 and BA[0] is set to 1. For example, with a 32-bit 1Gbit SDRAM (14 rows, 10 columns, 8 banks), the SDRAM write access should be done at the address (BASE_ADDRESS_DDR + 0x04000000). 21. A Normal mode command is provided. Program the normal mode into Mode Register (see Section 28.7.1 on page 319). Perform a write access to any DDR2-SDRAM address to acknowledge this command. 22. Perform a write access to any DDR2-SDRAM address. 23. Write the refresh rate into the count field in the Refresh Timer register (see page 320). (Refresh rate = delay between refresh cycles). The DDR2-SDRAM device requires a refresh every 15.625 s or 7.81 s. With a 133 MHz frequency, the refresh timer count register must be set with (15.625 *133 MHz) = 2079 i.e. 0x081f or (7.81 *133 MHz) = 1039 i.e. 0x040f After initialization, the DDR2-SDRAM devices are fully functional.
3.
300
(See Section 28.7.1 on page 319). Perform a write access to any Low-power DDR2-SDRAM address to acknowledge this command. Now, the Mode Register Read command is issued. A minimum pause of 10 s must be satisfied before any commands. 7. A calibration command is issued to the Low-power DDR2-SDRAM. Program the type of calibration into the Configuration Register, ZQ field, RESET value (see Section 28.7.3 MPDDRC Configuration Register on page 321). In the Mode Register, program the MODE field to LPDDR2_CMD value, and the MRS field; the application must set MODE to 7 and MRS to 10 (see Section 28.7.1 MPDDRC Mode Register on page 319). Perform a write access to any Low-power DDR2-SDRAM address to acknowledge this command. Now, the ZQ Calibration command is issued. Program the type of calibration into the Configuration Register, ZQ field, SHORT value (see Section 28.7.3 MPDDRC Configuration Register on page 321). A Mode Register Write command is issued to the Low-power DDR2-SDRAM. Program LPDDR2_CMD in the MODE and MRS field in the Mode Register, the application must set MODE to 7 and must set MRS field to 1. (see Section 28.7.1 on page 319). The Mode Register Write command cycle is issued to program the parameters of the Low-power DDR2-SDRAM devices, in particular burst length. Perform a write access to any Low-power DDR2SDRAM address to acknowledge this command. Now, the Mode Register Write command is issued. A Mode Register Write Command is issued to the Low-power DDR2-SDRAM. Program LPDDR2_CMD in the MODE and MRS field in the Mode Register, the application must set MODE to 7 and must set MRS field to 2. (see Section 28.7.1 on page 319). The Mode Register Write command cycle is issued to program the parameters of the Low-power DDR2-SDRAM devices, in particular CAS latency. Perform a write access to any Low-power DDR2SDRAM address to acknowledge this command. Now, the Mode Register Write command is issued.
8.
9.
10. A Mode Register Write Command is issued to the Low-power DDR2-SDRAM. Program LPDDR2_CMD in the MODE and MRS field of the Mode Register, the application must set MODE to 7 and must set MRS field to 3. (see Section 28.7.1 on page 319). The Mode Register Write command cycle is issued to program the parameters of the Low-power DDR2-SDRAM devices, in particular Drive Strength and Slew Rate. Perform a write access to any Low-power DDR2-SDRAM address to acknowledge this command. Now, the Mode Register Write command is issued. 11. A Mode Register Write Command is issued to the Low-power DDR2-SDRAM. Program LPDDR2_CMD in the MODE and MRS field of the Mode Register, the application must set MODE to 7 and must set MRS field to 16. (see Section 28.7.1 on page 319). Mode Register Write command cycle is issued to program the parameters of the Low-power DDR2-SDRAM devices, in particular Partial Array Self Refresh (PASR). Perform a write access to any Low-power DDR2-SDRAM address to acknowledge this command. Now, the Mode Register Write command is issued. 12. Write the refresh rate into the COUNT field in the Refresh Timer register (see page 320). (Refresh rate = delay between refresh cycles). The Low-power DDR2-SDRAM device requires a refresh every 7.81 s. With a 133 MHz frequency, the refresh timer count register must be set with (7.81 *133 MHz) = 1039 i.e. 0x040f. After initialization, the Low-power DDR2-SDRAM devices are fully functional.
301
28.5
Functional Description
302
Figure 28-2. Single Write Access, Row Closed, DDR-SDRAM Devices SDCLK
Da
Db
t RP = 2
t RCD = 2
Da
Db
t RP = 2
t RCD = 2
303
A[12:0]
Row a
col a
COMMAND
NOP
PRCHG
NOP
ACT
NOP
WRITE
NOP
3 Da Db Dc Dd
0 De Df Dg Dh
t RP = 2
t RCD = 2
A[12:0]
Row a
col a
COMMAND
NOP
PRCHG
NOP
ACT
NOP
WRITE
NOP
3 Da Db Dc Dd
0 De Df Dg Dh
t RP = 2
t RCD = 2
A write command can be followed by a read command. To avoid breaking the current write burst, tWTR/tWRD (bl/2 + 2 = 6 cycles) should be met. See Figure 28-6 on page 305.
304
Figure 28-6. Write Command Followed by a Read Command without Burst Write Interrupt, DDR-SDRAM Devices
SDCLK A[12:0] COMMAND BA[1:0] DQS[1:0] DM[1:0] D[15:0]
3 0 Da Db Dc Dd De Df Dg Dh 3 Da Db 0 col a col a
NOP
WRITE
NOP
READ
BST
NOP
In the case of a single write access, write operation should be interrupted by a read access but DM must be input 1 cycle prior to the read command to avoid writing invalid data. See Figure 28-7 on page 305.
Figure 28-7. SINGLE Write Access followed by a Read Access, DDR-SDRAM Devices
SDCLK A[12:0] COMMAND BA[1:0] DQS[1:0] DM[1:0] D[15:0]
3 0 3 Da Db NOP 0 PRCHG Row a NOP ACT NOP WRITE col a NOP READ BST NOP
Da
Db
Data masked
305
Figure 28-8. SINGLE Write Access followed by a Read Access, DDR2-SDRAM Devices
Da
Db
Data masked
t WTR
306
In the case of incrementing burst (INCR/INCR4/INCR8/INCR16), the addresses can cross the 16-byte boundary of the DDR-SDRAM device. For example, when a transfer (INCR4) starts at address 0x0C, the next access is 0x10, but since the burst length is programmed to 8, the next access is 0x00. Since the boundary is reached, the burst wraps. The MPDDRC takes into account this feature of the SDRAM device. In the case of a DDR-SDRAM device, transfers start at address 0x04/0x08/0x0C. Two read commands are issued to avoid wrapping when the boundary is reached. The last read command may generate additional reading (1 read cmd = 4 DDR words). To avoid additional reading, it is possible to use the burst stop command to truncate the read burst and to decrease power consumption. DDR2-SDRAM devices do not support the burst stop command.
Figure 28-9. Single Read Access, Row Closed, Latency = 2, DDR-SDRAM Devices
3 DaDb
Latency = 2
Figure 28-10. Single Read Access, Row Closed, Latency = 3, DDR2-SDRAM Devices
SDCLK A[12:0] COMMAND BA[1:0] DQS[1] DQS[0] DM[1:0] D[15:0] t RP t RCD Latency = 3
3 Da Db NOP 0 PRCHG NOP Row a ACT Col a NOP READ
307
28.5.2.1 Auto Refresh all Banks An All Banks Auto Refresh command performs a refresh operation on all banks. An auto refresh command is used to refresh the MPDDRC. Refresh addresses are generated internally by the DDR-SDRAM device and incremented after each auto-refresh automatically. The MPDDRC generates these auto-refresh commands periodically. A timer is loaded with the value in MPDDRC_RTR (see Section 28.7.2 MPDDRC Refresh Timer Register)that indicates the number of clock cycles between refresh cycles. When the MPDDRC initiates a refresh of a DDR-SDRAM device, internal memory accesses are not delayed. However, if the CPU tries to access the DDR-SDRAM device, the slave indicates that the device is busy. A refresh request does not interrupt a burst transfer in progress. This feature is activated by setting refresh per bank bit [REF_PB] to 0 in MPDDRC_RTR (see Section 28.7.2 MPDDRC Refresh Timer Register). 28.5.2.2 Auto Refresh per Bank Low-power DDR2-SDRAM embeds a new command, the Per Bank Auto Refresh command which performs a refresh operation on the bank which is scheduled by the bank counter in the memory device. The bank sequence of Per Bank Refresh is fixed to be a sequential round-robin: 0-1-2-3-4-5-6-7-0-1-.... The bank count is synchronized between the controller and the SDRAM upon issuing a RESET command or at every exit from self refresh, by resetting bank count to zero. The bank addressing for the per-bank refresh count is the same as established in the single-bank Precharge command. This feature is activated by setting refresh per bank bit [REF_PB] to 1 in MPDDRC_RTR (see Section 28.7.2 MPDDRC Refresh Timer Register on page 320). This feature allows to mask the latency do to the refresh procedure.
308
The target bank is inaccessible during the Per Bank Refresh cycle time (tRFCpb), however other banks within the device are accessible and may be addressed during the Per Bank Refresh cycle. During the REFpb operation, any of the banks other than the one being refreshed can be maintained in active state or accessed by a read or a write command. When the Per Bank Refresh cycle has completed, the affected bank will be in the Idle state. 28.5.2.3 Adjust Auto Refresh Rate Low-power DDR2-SDRAM embeds an internal register, Mode Register 19 (Refresh Mode). The content of this register allows to adjust the interval of auto-refresh operations according to temperature variation. This feature is activated by setting adjust refresh bit [ADJ_REF] to 1 in MPDDRC_RTR (see Section 28.7.2 MPDDRC Refresh Timer Register). When this feature is enabled, a mode register read command (MRR) is performed every 16*tREFI (average time between REFRESH commands). In function of the read value, the auto refresh interval will be modified. In the case of high temperature, the interval is reduced and in the case of low temperature, the interval is increased.
00 = Self refresh mode is enabled as soon as the DDR-SDRAM device is not selected 01 = Self refresh mode is enabled 64 clock cycles after completion of the last access 10 = Self refresh mode is enabled 128 clock cycles after completion of the last access
This controller also interfaces Low-power DDR-SDRAM. These devices add a feature: a single quarter, one-half quarter or all banks of the DDR-SDRAM array can be enabled in self refresh mode. Disabled banks are not refreshed in self refresh mode. This feature permits to reduce the self refresh current. In the case of Low-power DDR1-SDRAM, the extended mode register controls this feature, it includes Temperature Compensated Self Refresh (TSCR), Partial Array Self refresh (PASR) parameters and drives strength (DS) (see Section 28.7.7 MPDDRC Low-power Register on page 328). In the case of Low-power DDR2-SDRAM, the mode register 16 and 17 control this feature, it includes PASR Bank Mask (BK_MASK), PASR Segment Mask (SEG_MASK) parameters and drives strength (DS) (see Section 28.7.8 MPDDRC Low-power DDR2 Low-power Register on page 331). These parameters are set during the initialization phase. After initialization, as soon as PASR/DS/TCSR fields or BK_MASK/SEG_MASK/DS are modified, the Extended Mode Register or Mode Register 3/16/17 in the memory of the external device is accessed automatically and PASR/DS/TCSR and BK_MASK/SEG_MASK/DS bits are updated before entry into self refresh mode if MPDDRC does not share an external bus with another controller or during a refresh command, and a pending read or write access, if MPDDRC does share an external bus with another controller. This type of update is a function of the UPD_MR bit (see Section 28.7.7 MPDDRC Low-power Register on page 328). The Low-power DDR1-SDRAM must remain in self refresh mode for a minimum of TRFC periods and may remain in self refresh mode for an indefinite period. The DDR2-SDRAM must remain in self refresh mode for a minimum of TCKE periods and may remain in self refresh mode for an indefinite period. The Low-power DDR2-SDRAM must remain in self refresh mode for a minimum of TCKESR periods and may remain in self refresh mode for an indefinite period.
309
t RP
Figure 28-14. Self Refresh Mode Entry, Time-out = 1 or 2
t RP
310
28.5.3.2 Power-down Mode This mode is activated by setting the low-power command bit [LPCB] to 10. Power-down mode is used when no access to the DDR-SDRAM device is possible. In this mode, power consumption is greater than in self refresh mode. This state is similar to normal mode (No low-power mode/No self refresh mode), but the CKE pin is low and the input and output buffers are deactivated as soon the DDR-SDRAM device is no longer accessible. In contrast to self refresh mode, the DDR-SDRAM device cannot remain in low-power mode longer than the refresh period (64 ms). As no auto-refresh operations are performed in this mode, the MPDDRC carries out the refresh operation. For Low-power DDR1-SDRAM devices, the controller generates a NOP command during a delay of at least TXP. In addition, Low-power DDR-SDRAM and DDR2-SDRAM must remain in power-down mode for a minimum period of TCKE periods. The exit procedure is faster than in self refresh mode. See Figure 28-16 on page 311. The MPDDRC returns to powerdown mode as soon as the DDR-SDRAM device is not selected. It is possible to define when power-down mode is enabled by setting the LPR register time-out command bit.
z z z
00 = Power-down mode is enabled as soon as the DDR-SDRAM device is not selected 01 = Power-down mode is enabled 64 clock cycles after completion of the last access 10 = Power-down mode is enabled 128 clock cycles after completion of the last access
28.5.3.3 Deep Power-down Mode The deep power-down mode is a feature of Low-power DDR-SDRAM. When this mode is activated, all internal voltage generators inside the device are stopped and all data is lost. Deep power-down mode is activated by setting the low-power command bit [LPCB] to 11. When this mode is enabled, the MPDDRC leaves normal mode (mode == 000) and the controller is frozen. Before enabling this mode, the user must assume there is no any access in progress. To exit deep power-down mode the low-power command bit (LPCB) must be set to 00, an initialization sequence must be generated by software. See Section 28.4.1 Low-power DDR1-SDRAM Initialization on page 298 or Section 28.4.3 Low-power DDR2-SDRAM Initialization on page 300.
311
t RP
28.5.3.4 Change Frequency During Power-down Mode with Low-power DDR2-SDRAM Devices To change frequency, power-down mode must be activated by setting the low-power command bit [LPCB] to 10 and changing frequency bit command [CHG_FR] to 1. Once the Low-power DDR2-SDRAM is in precharge power-down mode, the clock frequency may change. The device input clock frequency is allowed to change only within minimum and maximum operating frequencies as specified by Low-power DDR2-SDRAM providers. Once the input clock frequency is changed, new stable clocks must be provided to the device before exiting from the precharge power-down mode. Depending on the new clock frequency, the user can change the CAS latency in the user interface. (See CAS: CAS Latency on page 321.) It is recommended to check that no access is in progress. Once the controller detects a change of latency during the change frequency procedure, a Load Mode Register command is performed. During a change frequency procedure, the change frequency bit command [CHG_FR] sets to 0 automatically. 28.5.3.5 Reset Mode The reset mode is a feature of DDR2-SDRAM. This mode is activated by setting the low-power command bit [LPCB] to 11 and the clock frozen command bit [CLK_FR] to 1. When this mode is enabled, the MPDDRC leaves normal mode (mode == 000) and the controller is frozen. Before enabling this mode, the user must assume there is no any access in progress. To exit reset mode, the low-power command bit [LPCB] must be set to 00, clock frozen command bit [CLK_FR] set to 0 and an initialization sequence must be generated by software. (See Section 28.4.2 DDR2-SDRAM Initialization).
312
Da
Db
The multi-port controller is designed to mask these timings and thus improve the bandwidth of the system. MPDDRC is a multi-port controller whereby four masters can simultaneously reach the controller. This feature improves the bandwidth of the system because it can detect four requests on the AHB slave inputs and thus anticipate the commands that follow, Precharge and Activate Command in bank X during the current access in bank Y. This allows tRP and tRCD timings to be masked (see Figure 28-19). In the best case, all accesses are done as if the banks and rows were already open. The best condition is met when the four masters work in different banks. In the case of four simultaneous read accesses, when the four or eight banks and associated rows are open, the controller reads with a continuous flow and masks the CAS latency for each access. To allow a continuous flow, the read command must be set at 2 or 6 cycles (CAS latency) before the end of the current access. This requires that the scheme of arbitration changes since the roundrobin arbitration cannot be respected. If the controller anticipates a read access, and thus a master with a high priority arises before the end of the current access, then this master will not be serviced.
Figure 28-19. Anticipate Precharge/Activate Command in Bank 2 during Read Access in Bank 1
SDCK A[12:0] COMMAND BA[1:0] DQS[1:0] DM1:0] D[15:0]
3 Da Db Dc Dd De Df Dg Dh Di Dj Dk Dl NOP 0 READ 1 PRECH 2 NOP ACT READ 1 NOP
313
The arbitration mechanism reduces latency when conflicts occur, that is when two or more masters try to access the DDR-SDRAM device at the same time. The arbitration type is round-robin arbitration. This algorithm dispatches requests from different masters to the DDRSDRAM device in a round-robin manner. If two or more master requests arise at the same time, the master with the lowest number is serviced first, then the others are serviced in a round-robin manner. To avoid burst breaking and to provide the maximum throughput for the DDR-SDRAM device, arbitration must only take place during the following cycles: 1. 2. 3. Idle cycles: When no master is connected to the DDR-SDRAM device. Single cycles: When a slave is currently doing a single access. End of Burst cycles: When the current cycle is the last cycle of a burst transfer.
z z
For bursts of defined length, predicted end of burst matches the size of the transfer. For bursts of undefined length, predicted end of burst is generated at the end of each four-beat boundary inside the INCR transfer.
4.
Anticipated Access: When an anticipated read access is done while the current access is not complete, the arbitration scheme can be changed if the anticipated access is not the next access serviced by the arbitration scheme.
314
28.6
28.6.1 DDR-SDRAM Address Mapping for 32-bit Memory Data Bus Width
Table 28-1. Sequential Mapping DDR-SDRAM Configuration Mapping: 2K Rows /512/1024/2048 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 Row[10:0] Row[10:0] Row[10:0] 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Table 28-2. Interleaved Mapping DDR-SDRAM Configuration Mapping: 2K Rows /512/1024/2048 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 Row[10:0] Row[10:0] Row[10:0] 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Table 28-3. Sequential Mapping DDR-SDRAM Configuration Mapping:4K Rows /512/1024/2048 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Table 28-4. Interleaved Mapping DDR-SDRAM Configuration Mapping: 4K Rows /512/1024/2048 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
315
Table 28-5. Sequential Mapping DDR-SDRAM Configuration Mapping:8K Rows /512/1024/2048 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 Row[12:0] Row[12:0] Row[12:0] 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Table 28-6. Interleaved Mapping DDR-SDRAM Configuration Mapping: 8K Rows /512/1024/2048 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 Row[13:0] Row[13:0] Row[13:0] 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Table 28-7. Sequential Mapping DDR-SDRAM Configuration Mapping:8K Rows /1024 Columns, 8banks
CPU Address Line 2 8 2 7 2 6 Bk[2:0] 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 Row[12:0] 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Column[9:0]
M[1:0]
Table 28-8. Interleaved Mapping DDR-SDRAM Configuration Mapping: 8K Rows /1024 Columns, 8banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 Row[12:0] 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 Bk[2:0] 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Column[9:0]
M[1:0]
Table 28-9. Sequential Mapping DDR-SDRAM Configuration Mapping:16K Rows /1024 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Bk[1:0]
Row[13:0]
Column[9:0]
M[1:0]
Table 28-10. Interleaved Mapping DDR-SDRAM Configuration Mapping: 16K Rows /1024 Columns, 4 banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Row[13:0]
Bk[1:0]
Column[9:0]
M[1:0]
316
Table 28-11. Sequential Mapping DDR-SDRAM Configuration Mapping:16K Rows /1024 Columns, 8 banks
CPU Address Line 2 8 2 7 Bk[2:0] 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Row[13:0]
Column[9:0]
M[1:0]
Table 28-12. Interleaved Mapping DDR-SDRAM Configuration Mapping: 16K Rows /1024 Columns, 8banks
CPU Address Line 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 Bk[2:0] 1 2 1 1 1 0 9 8 7 6 5 4 3 2 1 0
Row[13:0]
Column[9:0]
M[1:0]
Notes: 1. M[1:0] is the byte address inside a 32-bit word. 2. BK[2] = BA2, Bk[1] = BA1, Bk[0] = BA0
317
28.7
The User Interface is connected to the APB bus. The MPDDRC is programmed using the registers listed in Table 28-13
Table 28-13. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44x70 0x74 0x78 0x7C 0x80 0x84 0x88 0x8C 0x94xE0 0xE4 0xE8 0x1580x1CC 0x1DC0x1F8 Register MPDDRC Mode Register MPDDRC Refresh Timer Register MPDDRC Configuration Register MPDDRC Timing Parameter 0 Register MPDDRC Timing Parameter 1 Register MPDDRC Timing Parameter 2 Register Reserved MPDDRC Low-power Register MPDDRC Memory Device Register MPDDRC High Speed Register MPDDRC LPDDR2 Low-power Register MPDDRC LPDDR2 Calibration and MR4 Register MPDDRC LPDDR2 Timing Calibration Register MPDDRC IO Calibration MPDDRC OCMS Register MPDDRC OCMS KEY1 Register MPDDRC OCMS KEY2 Register Reserved MPDDRC DLL Master Offset Register MPDDRC DLL Slave Offset Register MPDDRC DLL Status Master Register MPDDRC DLL Status Slave 0 Register MPDDRC DLL Status Slave 1 Register MPDDRC DLL Status Slave 2 Register MPDDRC DLL Status Slave 3 Register Reserved MPDDRC Write Protect Control Register MPDDRC Write Protect Status Register Reserved. Reserved. Name MPDDRC_MR MPDDRC_RTR MPDDRC_CR MPDDRC_TPR0 MPDDRC_TPR1 MPDDRC_TPR2 MPDDRC_LPR MPDDRC_MD MPDDRC_HS MPDDRC_LPDDR2_LPR MPDDRC_LPDDR2_CAL_MR4 MPDDRC_LPDDR2_TIM_CAL MPDDRC_IO_CALIBR MPDDRC_OCMS MPDDRC_OCMS_KEY1 MPDDRC_OCMS_KEY2 MPDDRC_DLL_MO MPDDRC_DLL_SOF MPDDRC_DLL_MS MPDDRC_DLL_SS0 MPDDRC_DLL_SS1 MPDDRC_DLL_SS2 MPDDRC_DLL_SS3 MPDDRC_WPCR MPDDRC_WPSR Access Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Write-only Write-only Read-write Read-write Read-only Read-only Read-only Read-only Read-only Read-write Read-only Reset 0x00000000 0x00000000 0x024 0x20227225 0x3c80808 0x00042062 0x0 0x10 0x00000000 0x00000000 0x00000000 0x040 0x00870002 0x00000000 0x00000000 0x00000000 0x-(1) 0x-(1) 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
Notes: 1. Values in the DLL Master Offset Register and in the DLL Slave Offset Register vary with the product implementation.
318
010
011
LMR_CMD
100
RFSH_CMD
319
ADJ_REF: Adjust Refresh Rate The reset value is 0. 0: Adjust refresh rate is not enabled. 1: Adjust refresh rate is enabled. This mode is unique to Low-power DDR2-SDRAM devices. REF_PB: Refresh Per Bank The reset value is 0. 0: Refresh all banks during auto-refresh operation. 1: Refresh the scheduled bank by the bank counter in the memory interface. This mode is unique to Low-power DDR2-SDRAM devices. MR4_VALUE: Content of MR4 Register
The reset value is 3. This field (read-only) gives the content of MR4 register. This field is updated when MRR command is generated and Adjust Refresh Rate bit is enabled. Update is done when read value is different from MR4_VALUE. LPDDR2 JEDEC memory standards impose derating LPDDR2 AC timings (tRCD, tRC, tRAS, tRP and tRRD) when the value of MR4 is equal to 6. If the application needs to work in extreme conditions, the derating value must be added to AC timings before the power up sequence. This mode is unique to Low-power DDR2-SDRAM devices.
320
321
ZQ: ZQ Calibration
Reset value is 0.
Value 00 01 10 11 Name INIT LONG SHORT RESET Description Calibration command after initialization Long calibration Short calibration ZQ Reset
This parameter is used to calibrate DRAM On resistance (Ron) values over PVT. This field is found only in Low-power DDR2-SDRAM devices.
OCD is NOT supported by the controller, but these values MUST be programmed during the initialization sequence.
Name EXIT DEFAULT Description OCD calibration mode exit, maintain setting OCD calibration default
322
323
324
325
TRFC: Row Cycle Delay Reset Value is 8 cycles. This field defines the delay between a Refresh command or a Refresh and Activate command in number of cycles. The number of cycles is between 0 and 127. In the case of Low-power DDR2-SDRAM, this field is equivalent to TRFCab timing. If the user enables the function Refresh Per Bank (See REF_PB: Refresh Per Bank on page 320.) this field is equivalent to TRFCpb. TXSNR: Exit Self Refresh Delay to Non Read Command Reset Value is 8 cycles. This field defines the delay between CKE set high and a Non Read command in number of cycles. The number of cycles is between 0 and 255. This field is used by DDR-SDRAM devices. In the case of Low-power DDR-SDRAM, this field is equivalent to tXSR timing. TXSRD: Exit Self Refresh Delay to Read Command Reset Value is 200 cycles. This field defines the delay between CKE set high and a Read command in number of cycles. The number of cycles is between 0 and 255 cycles. This field is found only in DDR2-SDRAM devices. TXP: Exit Power-down Delay to First Command Reset Value is 3 cycles.
This field defines the delay between CKE set high and a Valid command in number of cycles. The number of cycles is between 0 and 15 cycles.
326
TXARD: Exit Active Power Down Delay to Read Command in Mode Fast Exit. The Reset Value is 2 cycles. This field defines the delay between CKE set high and a Read Command in number of cycles. The number of cycles is between 0 and 15.
This field is found only in DDR2-SDRAM devices.
TXARDS: Exit Active Power Down Delay to Read Command in Mode Slow Exit. The Reset Value is 6 cycles. This field defines the delay between CKE set high and a Read Command in number of cycles. The number of cycles is between 0 and 15.
This field is found only in DDR2-SDRAM devices.
327
01
SELFREFRESH
10 11
POWERDOWN DEEP_PWD
328
After the initialization sequence, as soon as PASR field is modified, Extended Mode Register in the external device memory is accessed automatically and PASR bits are updated. In function of the UPD_MR bit, update is done before entering in self refresh mode or during a refresh command and a pending read or write access. DS: Drive Strength
Reset value is 0. This field is unique to Low-power DDR-SDRAM. It selects the driver strength of DDR- SDRAM output. After the initialization sequence, as soon as DS field is modified, Extended Mode Register is accessed automatically and DS bits are updated. In function of UPD_MR bit, update is done before entering in self refresh mode or during a refresh command and a pending read or write access.
329
330
331
332
333
334
TZQIO: IO Calibration This field defines the delay between an IO Calibration Command and any Valid commands in number of cycles. The number of cycles is between 0 and 7. The TZQIO configuration code must be correctly set depending on the clock frequency using the following formula: TZQIO = (DDRCLK* 20ns) + 1. CALCODEP: Number of Transistor P This Register is Read Only. The Reset Value is 7. This value gives the number of transistor P to perform the calibration. CALCODEN: Number of Transistor N This Register is Read Only. The Reset Value is 8. This value gives the number of transistor N to perform the calibration. SAMA5D3 Series [DATASHEET]
11121BATARM08-Mar-13
335
336
23
22
21
20 KEY1
19
18
17
16
15
14
13
12 KEY1
11
10
4 KEY1
337
338
339
340
341
342
0xFFFFEA74 Read-write
See Table 28-13 30 22 14 6 29 21 13 5 28 20 12 27 19 11 26 18 10 CLK90OFF 2 MOFF 25 17 9 24 16 SELOFF 8
If SELOFF=0: the hard-coded Master delay line offset is read. If SELOFF=1: the programmable Master delay line offset is read. CLK90OFF: DLL CLK90 Delay Line Offset
The value stored by this field is signed. When this field is written, the programmable CLK90 delay line offset is written. When this field is read:
If SELOFF=0: the hard-coded CLK90 delay line offset is read. If SELOFF=1: the programmable CLK90 delay line offset is read. SELOFF: DLL Offset Selection
0: The hard-coded Master/Slave x/CLK90 delay line offsets are selected. 1: The programmable Master/Slave x/CLK90 delay line offsets are selected.
343
0xFFFFEA78 Read-write
See Table 28-13 30 22 14 6 29 21 13 5 28 27 26 S3OFF 18 S2OFF 10 S1OFF 2 S0OFF 25 24
20
19
17
16
12
11
If MPDDRC_DLL MOR.SELOFF=0: the hard-coded Slave x delay line offset is read. If MPDDRC_DLL MOR.SELOFF=1: the programmable Slave x delay line offset is read.
344
0xFFFFEA7C Read-only
See Table 28-13 30 22 14 29 21 13 28 20 12 MDVAL 27 19 11 26 18 10 25 17 9 24 16 8
2 MDOVF
1 MDDEC
0 MDINC
345
0xFFFFEA80 Read-only
See Table 28-13 30 22 29 21 28 20 SDCVAL 27 19 26 18 25 17 24 16
15
14
13
12 SDVAL
11
10
2 SDERF
1 SDCUDF
0 SDCOVF
346
29.
29.1
347
29.2
Embedded Characteristics
z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z
64-Mbyte Address Space per Chip Select 8-bit or 16-bit Data Bus Word, Halfword, Byte Transfers Byte Write or Byte Select Lines Programmable Setup, Pulse and Hold Time for Read Signals per Chip Select Programmable Setup, Pulse and Hold Time for Write Signals per Chip Select Programmable Data Float Time per Chip Select External Data Bus Scrambling/Unscrambling Function External Wait Request Automatic Switch to Slow Clock Mode NAND Flash Controller Supporting NAND Flash with Multiplexed Data/Address Buses Supports SLC and MLC NAND Flash Technology Hardware Configurable Number of Chip Selects from 1 to 4 Programmable Timing on a Per-chip Select Basis Programmable Flash Data Width 8 bits or 16 bits Supports NAND Flash and SmartMedia Devices with 8-bit or 16-bit Data Path Supports NAND Flash with Page Sizes of 528, 1056, 2112 and 4224 Bytes, Specified by Software Supports 1-bit Correction for a Page of 512, 1024, 2048 and 4096 Bytes with 8- or 16-bit Data Path Supports 1-bit Correction per 512 Bytes of Data for a Page Size of 512, 2048 and 4096 Bytes with 8-bit Data Path Supports 1-bit Correction per 256 Bytes of Data for a Page Size of 512, 2048 and 4096 Bytes with 8-bit Data Path Multibit Error Correcting Code (ECC) ECC Algorithm based on binary shortened Bose, Chaudhuri and Hocquenghem (BCH) codes Programmable Error Correcting Capability: 2, 4, 8, 12 and 24 bits of errors per block Programmable block size: 512 Bytes or 1024 Bytes Programmable number of block per page: 1, 2, 4 or 8 blocks of data per page Programmable spare area size Supports spare area ECC protection Supports 8 Kbytes page size using 1024 Bytes/block and 4 Kbytes page size using 512 Bytes/block Multibit Error detection is interrupt driven Provides hardware acceleration for determining roots of polynomials defined over a finite field Programmable finite Field GF(2^13) or GF(2^14) Finds roots of error-locator polynomial Programmable number of roots
348
29.3
Block Diagram
AHB arbiter
SMC Scrambler
SMC Interface
D[15:0] A[0]/NBS0 A[20:1] A21/NANDALE A22/NANDCLE A[25:23] NCS[3:0] NRD NWR0/NWE NWR1/NBS1 NANDOE NANDWE NANDRDY NWAIT
SRAM Scrambler
User Interface NFC (8 KBytes) Internal SRAM Control & Status Registers
APB interface
349
29.4
Table 29-1. I/O Line Description Name NCS[3:0] NRD NWR0/NWE A0/NBS0 NWR1/NBS1 A[25:1] D[15:0] NWAIT NANDRDY NANDWE NANDOE NANDALE NANDCLE Description Static Memory Controller Chip Select Lines Read Signal Write 0/Write Enable Signal Address Bit 0/Byte 0 Select Signal Write 1/Byte 1 Select Signal Address Bus Data Bus External Wait Signal NAND Flash Ready/Busy NAND Flash Write Enable NAND Flash Output Enable NAND Flash Address Latch Enable NAND Flash Command Latch Enable Type Output Output Output Output Output Output I/O Input Input Output Output Output Output Low Low Low Active Level Low Low Low Low Low
29.5
Multiplexed Signals
Table 29-2. Static Memory Controller (HSMC) Multiplexed Signals Multiplexed Signals NWR0 A0 A22 A21 NWR1 A1 NWE NBS0 NANDCLE NANDALE NBS1 Related Function Byte-write or Byte-select access, see Figure 29-4 "Memory Connection for an 8-bit Data Bus" and Figure 29-5 "Memory Connection for a 16-bit Data Bus" 8-bit or 16-bit data bus, see Section 29.9.1 Data Bus Width NAND Flash Command Latch Enable NAND Flash Address Latch Enable Byte-write or Byte-select access, see Figure 29-4 and Figure 29-5 8-/16-bit data bus, see Section 29.9.1 Data Bus Width Byte-write or Byte-select access, see Figure 29-4 and Figure 29-5
350
29.6
Application Example
D0 - D7
128K x 8 SRAM
D0 - D7 CS A0 - A16 A2 - A18
D8-D15
128K x 8 SRAM
D0-D7 CS A0 - A16 A2 - A18
OE WE
NRD NWR1/NBS1
OE WE
A2 - A23
351
29.7
Product Dependencies
29.7.3 Interrupt
The HSMC has an interrupt line connected to the Nested Vector Interrupt Controller (NVIC). Handling the HSMC interrupt requires programming the NVIC before configuring the HSMC.
Table 29-3. Peripheral IDs Instance HSMC ID 5
29.8
8 or 16
D[15:0] or D[7:0]
352
29.9
29.9.2.1 Byte Write Access Byte write access supports one write signal per Byte of the data bus and a single read signal. Note that the HSMC does not allow boot in Byte Write Access mode. z For 16-bit devices: the HSMC provides NWR0 and NWR1 write signals for respectively, Byte0 (lower Byte) and Byte1 (upper Byte) of a 16-bit bus. One single read signal (NRD) is provided. Byte Write Access is used to connect 2 x 8-bit devices as a 16-bit memory. 29.9.2.2 Byte Select Access In this mode, read/write operations can be enabled/disabled at Byte level. One Byte-select line per Byte of the data bus is provided. One NRD and one NWE signal control read and write. z For 16-bit devices: the HSMC provides NBS0 and NBS1 selection signals for respectively Byte0 (lower Byte) and Byte1 (upper Byte) of a 16-bit bus. Byte Select Access is used to connect one 16-bit device.
353
Figure 29-6. Connection of 2 x 8-bit Devices on a 16-bit Bus: Byte Write Option
D[7:0] D[15:8] A[24:2] A[23:1] A[0] Write Enable Read Enable Memory Enable D[7:0]
SMC
29.9.2.3 Signal Multiplexing Depending on the Byte Access Type (BAT), only the write signals or the Byte select signals are used. To save IOs at the external bus interface, control signals at the HSMC interface are multiplexed. Table 29-4 shows signal multiplexing depending on the data bus width and the Byte Access Type. For 16-bit devices, bit A0 of address is unused. When Byte Select Option is selected, NWR1 is unused. When Byte Write option is selected, NBS0 is unused.
Table 29-4. HSMC Multiplexed Signal Translation Signal Name Device Type Byte Access Type (BAT) NBS0_A0 NWE_NWR0 NBS1_NWR1 A1 1x16-bit Byte Select NBS0 NWE NBS1 A1 NWR0 NWR1 A1 A1 16-bit Bus 2 x 8-bit Byte Write A0 NWE 8-bit Bus 1 x 8-bit
354
A[25:2]
NBS0,NBS1, A0, A1
NRD
NCS
NCS_RD_SETUP
NCS_RD_PULSE NRD_CYCLE
NCS_RD_HOLD
29.10.1.1 NRD Waveform The NRD signal is characterized by a setup timing, a pulse width and a hold timing. 1. 2. 3. NRD_SETUP: the NRD setup time is defined as the setup of address before the NRD falling edge. NRD_PULSE: the NRD pulse length is the time between NRD falling edge and NRD rising edge. NRD_HOLD: the NRD hold time is defined as the hold time of address after the NRD rising edge.
29.10.1.2 NCS Waveform Similarly, the NCS signal can be divided into a setup time, pulse length and hold time: 1. 2. 3. NCS_RD_SETUP: the NCS setup time is defined as the setup time of address before the NCS falling edge. NCS_RD_PULSE: the NCS pulse length is the time between NCS falling edge and NCS rising edge. NCS_RD_HOLD: the NCS hold time is defined as the hold time of address after the NCS rising edge.
355
29.10.1.3 Read Cycle The NRD_CYCLE time is defined as the total duration of the read cycle, i.e., from the time where address is set on the address bus to the point where address may change. The total read cycle time is equal to: NRD_CYCLE = NRD_SETUP + NRD_PULSE + NRD_HOLD = NCS_RD_SETUP + NCS_RD_PULSE + NCS_RD_HOLD All NRD and NCS timings are defined separately for each chip select as an integer number of Master Clock cycles. To ensure that the NRD and NCS timings are coherent, the user must define the total read cycle instead of the hold timing. NRD_CYCLE implicitly defines the NRD hold time and NCS hold time as: NRD_HOLD = NRD_CYCLE - NRD SETUP - NRD PULSE NCS_RD_HOLD = NRD_CYCLE - NCS_RD_SETUP - NCS_RD_PULSE
A[25:2]
NBS0,NBS1, A0, A1
NRD
Data Sampling
356
29.10.2.2 Read is Controlled by NCS (READ_MODE = 0) Figure 29-9 shows the typical read cycle. The read data is valid tPACC after the falling edge of the NCS signal and remains valid until the rising edge of NCS. Data must be sampled when NCS is raised. In that case, the READ_MODE must be set to 0 (read is controlled by NCS): the HSMC internally samples the data on the rising edge of the Master Clock that generates the rising edge of NCS, whatever the programmed waveform of NRD.
Figure 29-9. READ_MODE = 0: Data is Sampled by HSMC before the Rising Edge of NCS
MCK
A[25:2]
NBS0,NBS1, A0, A1
NRD
Data Sampling
357
The NWE waveforms apply to all Byte-write lines in Byte Write access mode: NWR0 to NWR3. 29.10.3.2 NCS Waveforms The NCS signal waveforms in write operation are not the same as those applied in read operations, but are separately defined: 1. 2. 3. NCS_WR_SETUP: the NCS setup time is defined as the setup time of address before the NCS falling edge. NCS_WR_PULSE: the NCS pulse length is the time between NCS falling edge and NCS rising edge. NCS_WR_HOLD: the NCS hold time is defined as the hold time of address after the NCS rising edge.
A[25:2]
NWE
NCS
NWE_SETUP
NWE_PULSE
NWE_HOLD
NCS_WR_SETUP
NCS_WR_PULSE NWE_CYCLE
NCS_WR_HOLD
358
29.10.3.3 Write Cycle The write cycle time is defined as the total duration of the write cycle, that is, from the time where address is set on the address bus to the point where address may change. The total write cycle time is equal to: NWE_CYCLE = NWE_SETUP + NWE_PULSE + NWE_HOLD = NCS_WR_SETUP + NCS_WR_PULSE + NCS_WR_HOLD All NWE and NCS (write) timings are defined separately for each chip select as an integer number of Master Clock cycles. To ensure that the NWE and NCS timings are coherent, the user must define the total write cycle instead of the hold timing. This implicitly defines the NWE hold time and NCS (write) hold times as: NWE_HOLD = NWE_CYCLE - NWE_SETUP - NWE_PULSE NCS_WR_HOLD = NWE_CYCLE - NCS_WR_SETUP - NCS_WR_PULSE
A[25:2]
NCS D[15:0]
359
29.10.4.2 Write is Controlled by NCS (WRITE_MODE = 0) Figure 29-12 shows the waveforms of a write operation with WRITE_MODE set to 0. The data is put on the bus during the pulse and hold steps of the NCS signal. The internal data buffers are switched to output mode after the NCS_WR_SETUP time, and until the end of the write cycle, regardless of the programmed waveform on NWE.
Figure 29-12. WRITE_MODE = 0. The write operation is controlled by NCS
MCK
A[25:2]
NCS
D[15:0]
The HSMC_SETUP register groups the definition of all setup parameters: NRD_SETUP, NCS_RD_SETUP, NWE_SETUP, NCS_WR_SETUP The HSMC_PULSE register groups the definition of all pulse parameters: NRD_PULSE, NCS_RD_PULSE, NWE_PULSE, NCS_WR_PULSE The HSMC_CYCLE register groups the definition of all cycle parameters: NRD_CYCLE, NWE_CYCLE
Table 29-5 shows how the timing parameters are coded and their permitted range.
Table 29-5. Coding and Range of Timing Parameters Permitted Range Coded Value setup [5:0] Number of Bits 6 Effective Value 128 x setup[5] + setup[4:0] Coded Value 0 setup 31 32 setup 63 0 pulse 63 64 pulse 127 0 cycle 127 cycle [8:0] 9 256 x cycle[8:7] + cycle[6:0] 128 cycle 255 256 cycle 383 384 cycle 511 Effective Value 0..31 128..(128+31) 0..63 256..(256+63) 0..127 256..(256+127) 512..(512+127) 768..(768+127)
pulse [6:0]
360
361
362
A[25:2]
NCS0
363
If the write controlling signal has no hold time and the read controlling signal has no setup time (Figure 29-14). In NCS write controlled mode (WRITE_MODE = 0), if there is no hold timing on the NCS signal and the NCS_RD_SETUP parameter is set to 0, regardless of the read mode (Figure 29-15). The write operation must end with an NCS rising edge. Without an Early Read Wait State, the write operation could not complete properly. In NWE controlled mode (WRITE_MODE = 1) and if there is no hold timing (NWE_HOLD = 0), the feedback of the write control signal is used to control address, data, chip select and Byte select lines. If the external write control signal is not inactivated as expected due to load capacitances, an Early Read Wait State is inserted and address, data and control signals are maintained one more cycle. See Figure 29-16.
Figure 29-14. Early Read Wait State: Write with No Hold Followed by Read with No Setup
MCK
A[25:2]
NWE
write cycle
read cycle
364
Figure 29-15. Early Read Wait State: NCS Controlled Write with No Hold Followed by a Read with No NCS Setup
MCK
A[25:2]
NCS
read cycle write cycle Early Read (WRITE_MODE = 0) wait state (READ_MODE = 0 or READ_MODE = 1)
Figure 29-16. Early Read Wait State: NWE-controlled Write with No Hold Followed by a Read with one Set-up Cycle
MCK
A[25:2]
NBS0, NBS1, A0, A1 Internal write controlling signal External write controlling signal (NWE) No hold NRD Read setup = 1
D[15:0]
Write cycle Early Read Read cycle (WRITE_MODE = 1) wait state (READ_MODE = 0 or READ_MODE = 1)
365
366
Before starting a read access to a different external memory Before starting a write access to the same device or to a different external one.
The Data Float Output Time (tDF) for each external memory device is programmed in the TDF_CYCLES field of the HSMC_MODE register for the corresponding chip select. The value of TDF_CYCLES indicates the number of data float wait cycles (between 0 and 15) before the external device releases the bus, and represents the time allowed for the data output to go to high impedance after the memory is disabled. Data float wait states do not delay internal memory accesses. Hence, a single access to an external memory with long tDF will not slow down the execution of a program from internal memory. The data float wait states management depends on the READ_MODE and the TDF_MODE fields of the HSMC_MODE register for the corresponding chip select.
29.13.1 READ_MODE
Setting READ_MODE to 1 indicates to the HSMC 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 29-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 29-18 shows the read operation when controlled by NCS (READ_MODE = 0) and the TDF_CYCLES parameter equals 3.
Figure 29-17. TDF Period in NRD Controlled Read Access (TDF = 2)
MCK
A[25:2]
NRD
367
A[25:2]
NRD
368
Figure 29-19. TDF Optimization: No TDF wait states are inserted if the TDF period is over when the next access begins
MCK
A[25:2]
NWE_SETUP= 3 NCS0
TDF_CYCLES = 6
D[15:0]
Read access followed by a read access on another chip select, Read access followed by a write access on another chip select, Read access followed by a write access on the same chip select, with no TDF optimization.
369
Figure 29-20. TDF Optimization Disabled (TDF Mode = 0). TDF wait states between 2 read accesses on different chip selects
MCK
A[25:2]
read1 hold = 1
read2 setup = 1
TDF_CYCLES = 6
5 TDF WAIT STATES read1 cycle TDF_CYCLES = 6 Chip Select Wait State read2 cycle TDF_MODE = 0 (optimization disabled)
Figure 29-21. TDF Mode = 0: TDF wait states between a read and a write access on different chip selects
MCK
A[25:2]
read1 hold = 1
write2 setup = 1
TDF_CYCLES = 4
D[15:0]
370
Figure 29-22. TDF Mode = 0: TDF wait states between read and write accesses on the same chip select
MCK
read1 hold = 1
write2 setup = 1
TDF_CYCLES = 5
D[15:0]
4 TDF WAIT STATES read1 cycle TDF_CYCLES = 5 write2 cycle TDF_MODE = 0 (optimization disabled)
29.14.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 Slow Clock Mode (Slow Clock Mode on page 377). The NWAIT signal is assumed to be a response of the external device to the read/write request of the HSMC. NWAIT is then examined by the HSMC 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 the HSMC behavior.
371
Figure 29-23. Write Access with NWAIT Assertion in Frozen Mode (EXNW_MODE = 10)
MCK
A[25:2]
D[15:0]
NWAIT
Write cycle
EXNW_MODE = 10 (Frozen) WRITE_MODE = 1 (NWE_controlled) NWE_PULSE = 5 NCS_WR_PULSE = 7
372
Figure 29-24. Read Access with NWAIT Assertion in Frozen Mode (EXNW_MODE = 10)
MCK
A[25:2]
NWAIT
Read cycle
EXNW_MODE = 10 (Frozen) READ_MODE = 0 (NCS_controlled) NRD_PULSE = 2, NRD_HOLD = 6 NCS_RD_PULSE =5, NCS_RD_HOLD =3 Assertion is ignored
373
A[25:2]
D[15:0]
NWAIT
Write cycle
EXNW_MODE = 11 (Ready mode) WRITE_MODE = 1 (NWE_controlled) NWE_PULSE = 5 NCS_WR_PULSE = 7
374
Figure 29-26. NWAIT Assertion in Read Access: Ready Mode (EXNW_MODE = 11)
MCK
A[25:2]
NRD
NWAIT
Read cycle
EXNW_MODE = 11(Ready mode) READ_MODE = 0 (NCS_controlled) Assertion is ignored NRD_PULSE = 7 NCS_RD_PULSE =7 Assertion is ignored
375
MCK A[25:2]
376
A[25:2]
NWE
1 1
Table 29-7.
Read and Write Timing Parameters in Slow Clock Mode Duration (cycles) 1 1 0 2 2 Write Parameters NWE_SETUP NWE_PULSE NCS_WR_SETUP NCS_WR_PULSE NWE_CYCLE Duration (cycles) 1 1 0 3 3
377
29.15.2 Switching from (to) Slow Clock Mode to (from) Normal Mode
When switching from slow clock mode to normal mode, the current slow clock mode transfer is completed at high clock rate, with the set of slow clock mode parameters. See Figure 29-29. The external device may not be fast enough to support such timings. Figure 29-30 illustrates the recommended procedure to properly switch from one mode to the other.
Figure 29-29. Clock Rate Transition occurs while the HSMC is performing a Write Operation
Slow Clock Mode internal signal from PMC MCK A[25:2] NBS0, NBS1, A0, A1 NWE
1 NCS
NWE_CYCLE = 3
SLOW CLOCK MODE WRITE SLOW CLOCK MODE WRITE
NWE_CYCLE = 7
NORMAL MODE WRITE
This write cycle finishes with the slow clock mode set of parameters after the clock rate transition
378
Figure 29-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[25:2]
NWE 1 NCS 1 1 2 3 2
IDLE STATE
Reload Configuration Wait State
379
The address of the register (NFCADDR_CMD) is the command used The data of the register (NFCDATA_ADDT) is the address to be sent to the NAND Flash
So, in one single access the command is sent and immediately executed by the NFC. Two commands can even be programmed within a single access (CMD1, CMD2) depending on the VCMD2 value. The NFC can send up to 5 Address cycles. Figure 29-31 below shows a typical NAND Flash Page Read Command of a NAND Flash Memory and correspondence with NFC Address Command Register.
Figure 29-31. NFC/NAND Flash Access Example
00h Col. Add1 Col. Add2 Row Add1 Row Add2 Row Add3 Row Address 30h
Column Address
CMD1
ADD cycles (0 to 5)
CMD2
If VCMD2 = 1
For more details refer to NFC Address Command on page 382. Reading the NFC command register (to any address) will give the status of the NFC. Especially useful to know if the NFC is busy, for example.
380
29.16.2.1 Building NFC Address Command Example The base address is made of HOST_ADDR address. Page read operation example: // Build the Address Command (NFCADDR_CMD) AddressCommand = (HOST_ADDR | NFCCMD=1 | // NFC Command Enable NFCWR=0 |// NFC Read Data from NAND Flash DATAEN=1 | // NFC Data phase Enable. CSID=1 | // Chip Select ID = 1 ACYCLE= 5 | // Number of address cycle. VCMD2=1 | // CMD2 is sent after Address Cycles CMD2=0x30 | // CMD2 = 30h CMD1=0x0) // CMD1 = Read Command = 00h // Set the Address for Cycle 0 HSMC_ADDR = Col. Add1 // Write command with the Address Command built above *AddressCommand = (Col. Add2 |// ADDR_CYCLE1 Row Add1 | // ADDR_CYCLE2 Row Add2 |// ADDR_CYCLE3 Row Add3 )// ADDR_CYCLE4
381
11
382
23
22
21
18
17
16
15
14
13
10
383
11
384
Use NWE_SETUP, NWE_PULSE and NWE_CYCLE to define the write enable waveform according to the device datasheet. Use TADL field in the HSMC_TIMINGS register to configure the timing between the last address latch cycle and the first rising edge of WEN for data input.
Figure 29-32. Write Enable Timing Configuration
mck
wen
tWEN_SETUP
tWEN_PULSE tWEN_CYCLES
tWEN_HOLD
Figure 29-33. Write Enable Timing for NAND Flash Device Data Input Mode.
mck ale
wen
t ADL
z
Use NRD_SETUP, NRD_PULSE and NRD_CYCLE to define the read enable waveform according to the device datasheet. Use TAR field in the HSMC_TIMINGS register to configure the timings between the address latch enable falling edge to read the enable falling edge. Use TCLR field in the HSMC_TIMINGS register to configure the timings between the command latch enable falling edge to read the enable falling edge.
385
Figure 29-34. Read Enable Timing Configuration Working with NAND Flash Device
mck
cen
ale
cle
ren
tCLR tAR
z
tREN_SETUP
tREN_PULSE tREN_CYCLE
tREH
Use TWB field in HSMC_TIMINGS register to configure the maximum elapsed time between the rising edge of the wen signal and the falling edge of the rbn signal. Use TRR field in the HSMC_TIMINGS register to program the number of clock cycles between the rising edge of the rbn signal and the falling edge of the ren signal.
Figure 29-35. Ready/Busy Timing Configuration
mck
rbn
ren
wen
tWB
busy
tRR
386
29.16.3.1 NAND Flash Controller Timing Engine When the NFC Command register is written, the NFC issues a NAND Flash Command and optionally performs a data transfer between the NFC SRAM and the NAND Flash device. The NAND Flash Controller Timing Engine guarantees valid NAND Flash timings, depending on the set of parameters decoded from the address bus. These timings are defined in the HSMC_TIMINGS register. For information on the timing used depending on the command, see Figure 29-36:
Figure 29-36. NAND Flash Controller Timing Engine
Timing Check Engine
NFCEN=1 NFCWR =1 TADL =1 Wait TADL NFCEN=1 NFCWR=0 TWB != 0 Wait TWB NFCEN=0 VCMD2=1 TCLR != 0 Wait TCLR !NFCEN=1 VCMD2=0 ACYCLE!=0 NFCWR=1 TADL != 0 Wait TADL !NFCEN=1 VCMD2=0 ACYCLE!=0 NFCWR=0 TAR != 0 Wait TAR !NFCEN=1 VCMD2=0 ACYCLE!=0 TCLR != 0 Wait TCLR
See the NFC Address Command register description and the Timings Register.
387
29.16.4.2 NFC SRAM Access Prioritization Algorithm When the NAND Flash Controller (NFC) is reading from or writing to an NFC SRAM bank, the other bank is available. If an NFC SRAM access occurs when the NFC performs a read or write operation in the same bank, then the access is discarded. The write operation is not performed. The read operation returns undefined data. If this situation is encountered, the AWB status flag located in the NFC status Register is raised and indicates that a shared resource access violation has occurred.
Using NFC
Copy data from NFC SRAM to application memory (via DMA for example)
Note that, instead of using the interrupt, one can poll the NFCBUSY Flag. For more information on the NFC Control Register, see Section 29.16.2.2 NFC Address Command.
388
Write ECC
Writing the ECC cannot be done using the NFC; it needs to be done manually. Note that, instead of using the interrupt, one can poll the NFCBUSY Flag. For more information on the NFC Control Register, see Section 29.16.2.2 NFC Address Command.
389
All decoding steps involve finite field computation. It means that a library of finite field arithmetic must be available to perform addition, multiplication and inversion. These arithmetic operations can be performed through the use of a memory mapped look-up table, or direct software implementation. The software implementation presented is based on look-up tables. Two tables named gf_log and gf_antilog are used. If alpha is the primitive element of the field, then a power of alpha is in the field. Assuming that beta = alpha ^ index, then beta belongs to the field, and gf_log(beta) = gf_log(alpha ^ index) = index. The gf_antilog table provides exponent inverse of the element; if beta = alpha ^ index, then gf_antilog(index) = beta. The first step consists in the syndrome computation. The PMECC module computes the remainders and the software must substitute the power of the primitive element. The procedure implementation is given in Section 29.18.1 Remainder Substitution Procedure on page 397. The second step is the most software intensive. It is the Berlekamps iterative algorithm for finding the error-location polynomial. The procedure implementation is given in Section 29.18.2 Find the Error Location Polynomial Sigma(x) on page 398. The Last step is finding the root of the error location polynomial. This step can be very software intensive. Indeed there is no straightforward method of finding the roots, except evaluating each element of the field in the error location polynomial. However, a hardware accelerator can be used to find the roots of the polynomial. The PMERRLOC module provides this kind of hardware acceleration.
390
Software
Hardware Accelerator
Software
Hardware Accelerator
Configure PMECC : error correction capability sector size/page size NAND write field set to true spare area desired layout
Configure PMECC : error correction capability sector size/page size NAND write field set to false spare area desired layout
Move the NAND Page to external Memory whether using DMA or Processor
Move the NAND Page from external Memory whether using DMA or Processor
PMECC computes polynomial remainders as the data is read from external memory
Copy redundancy from PMECC user interface to user-defined spare area using DMA or Processor. If a sector is corrupted use the substitute() function to determine the syndromes.
When the table of syndromes is completed, use the get_sigma() function to get the error location polynomial.
Find the error positions finding the roots of the error location polynomial And correct the bits.
391
Table 29-10. Number of Relevant ECC Bytes per Sector, Copied from LSByte to MSByte BCH_ERR Field 0 1 2 3 4 Sector Size Set to 512 Bytes 4 Bytes 7 Bytes 13 Bytes 20 Bytes 39 Bytes Sector Size Set to 1024 Bytes 4 Bytes 7 Bytes 14 Bytes 21 Bytes 42 Bytes
392
29.17.1.1 SLC/MLC Write Operation with Spare Enable Bit Set When the SPAREEN field of the PMECCFG register is set to one, the spare area of the page is encoded with the stream of data of the last sector of the page. This mode is entered by writing 1 in the DATA field of the PMECCTRL register. When the encoding process is over, the redundancy shall be written to the spare area in user mode. The USER field of the PMECCTRL register must be set to one.
Figure 29-40. NAND Write Operation with Spare Encoding
pagesize = n * sectorsize
Sector 1
Sector 2
29.17.1.2 SLC/MLC Write Operation with Spare Disable When the SPAREEN field of PMECCFG is set to zero, the spare area is not encoded with the stream of data. This mode is entered by writing 1 to the DATA field of the PMECCTRL register.
Figure 29-41. NAND Write Operation
pagesize = n * sectorsize
Sector 1
Sector 2
Sector 3
393
Table 29-11. Relevant Remainder Registers BCH_ERR Field 0 1 2 Sector Size Set to 512 Bytes PMECCREM0 PMECCREM0, PMECCREM1 PMECCREM0, PMECCREM1, PMECCREM2, PMECCREM3, PMECCREM0, PMECCREM1, PMECCREM2, PMECCREM3, PMECCREM4, PMECCREM5, PMECCREM6, PMECCREM7 PMECCREM0, PMECCREM1, PMECCREM2, PMECCREM3, PMECCREM4, PMECCREM5, PMECCREM6, PMECCREM7, PMECCREM8, PMECCREM9, PMECCREM10, PMECCREM11 Sector Size Set to 1024 Bytes PMECCREM0 PMECCREM0, PMECCREM1 PMECCREM0, PMECCREM1, PMECCREM2, PMECCREM3 PMECCREM0, PMECCREM1, PMECCREM2, PMECCREM3, PMECCREM4, PMECCREM5, PMECCREM6, PMECCREM7 PMECCREM0, PMECCREM1, PMECCREM2, PMECCREM3, PMECCREM4, PMECCREM5, PMECCREM6, PMECCREM7, PMECCREM8, PMECCREM9, PMECCREM10, PMECCREM11
29.17.2.1 MLC/SLC Read Operation with Spare Decoding When the spare area is protected, it contains valid data. As the redundancy may be included in the middle of the information stream, the user shall program the start address and the end address of the ECC area. The controller will automatically skip the ECC area. This mode is entered writing 1 in the DATA field of the PMECCTRL register. When the page has been fully retrieved from the NAND, the ECC area shall be read using the user mode, writing 1 to the USER field of the PMECCTRL register.
Figure 29-42. Read Operation with Spare Decoding
Read NAND operation with SPAREEN set to One and AUTO set to Zero pagesize = n * sectorsize sparesize Sector 3 Spare
Sector 1
Sector 2
394
29.17.2.2 MLC/SLC Read Operation If the spare area is not protected with the error correcting code, the redundancy area is retrieved directly. This mode is entered writing 1 in the DATA field of the PMECCTRL register. When AUTO field is set to one, the ECC is retrieved automatically; otherwise, the ECC must be read using the user mode.
Figure 29-43. Read Operation
Read NAND operation with SPAREEN set to Zero and AUTO set to One pagesize = n * sectorsize sparesize Sector 3 Spare
Sector 1
Sector 2
ecc_area start_addr
ECC_BLK0 ECC_BLK1 ECC_BLK2
end_addr
ECC_BLK3
29.17.2.3 MLC/SLC User Read ECC Area This mode allows a manual retrieve of the ECC. It is entered writing 1 in the USER field of the PMECCTRL register.
Figure 29-44. Read User Mode
ecc_area_size ECC
395
Not used
Used
Not used
Used
396
si[i] = 0; } for (i = 1; i < 2*NB_ERROR; i++) { for (j = 0; j < oo[i]; j++) { if (REM2NPX[i][j]) { si[i] = gf_antilog[(i * j)%NB_FIELD_ELEMENTS] ^ si[i]; } } } return 0; }
397
398
/* delta set to 0 */ delta[1] = (mu[1] * 2 - lmu[1]) >> 1; for (i=1; i <= NB_ERROR; i++) { mu[i+1] = i << 1; /*************************************************/ /* */ /* */ /* Compute Sigma (Mu+1) */ /* And L(mu) */ /* check if discrepancy is set to 0 */ if (dmu[i] == 0) { /* copy polynom */ for (j=0; j<2*NB_ERROR_MAX+1; j++) { smu[i+1][j] = smu[i][j]; } /* copy previous polynom order to the next */ lmu[i+1] = lmu[i]; } else { ro = 0; largest = -1; /* find largest delta with dmu != 0 */ for (j=0; j<i; j++) { if (dmu[j]) { if (delta[j] > largest) { largest = delta[j]; ro = j; } } } /* initialize signal ro */ for (k = 0; k < 2*NB_ERROR_MAX+1; k ++) { sro[k] = 0; } /* compute difference */ diff = (mu[i] - mu[ro]); /* compute X ^ (2(mu-ro)) */ for (k = 0; k < (2*NB_ERROR_MAX+1); k ++) { sro[k+diff] = smu[ro][k]; } /* multiply by dmu * dmu[ro]^-1 */ for (k = 0; k < 2*NB_ERROR_MAX+1; k ++) { /* dmu[ro] is not equal to zero by definition */ /* check that operand are different from 0 */ if (sro[k] && dmu[i])
399
{ /* galois inverse */ sro[k] = gf_antilog[(gf_log[dmu[i]] + (NB_FIELD_ELEMENTSgf_log[dmu[ro]]) + gf_log[sro[k]]) % NB_FIELD_ELEMENTS]; } } /* multiply by dmu * dmu[ro]^-1 */ for (k = 0; k < 2*NB_ERROR_MAX+1; k++) { smu[i+1][k] = smu[i][k] ^ sro[k]; if (smu[i+1][k]) { /* find the order of the polynom */ lmu[i+1] = k << 1; } } } /* */ /* */ /* End Compute Sigma (Mu+1) */ /* And L(mu) */ /*************************************************/ /* In either case compute delta */ delta[i+1] = (mu[i+1] * 2 - lmu[i+1]) >> 1; /* In either case compute the discrepancy */ for (k = 0 ; k <= (lmu[i+1]>>1); k++) { if (k == 0) dmu[i+1] = si[2*(i-1)+3]; /* check if one operand of the multiplier is null, its index is -1 */ else if (smu[i+1][k] && si[2*(i-1)+3-k]) dmu[i+1] = gf_antilog[(gf_log[smu[i+1][k]] + gf_log[si[2*(i-1)+3-k]])%nn] ^ dmu[i+1]; } } return 0; }
400
Table 29-13. ENINIT Field Value for a Sector Size of 512 Bytes Error Correcting Capability 2 4 8 12 24 ENINIT Value 4122 4148 4200 4252 4408
Table 29-14. ENINIT Field Value for a Sector Size of 1024 Bytes Error Correcting Capability 2 4 8 12 24 ENINIT Value 8220 8248 8304 8360 8528
When the PMECC engine is searching for roots, the BUSY field of the ELSR register remains asserted. An interrupt is asserted at the end of the computation, and the DONE bit of the ELSIR register is set. The ERR_CNT field of the ELISR register indicates the number of errors. The error position can be read in the PMERRLOCX registers.
401
402
Table 29-15. Register Mapping (Continued) Offset 0x2B0+sec_num*(0x40)+0x04 0x2B0+sec_num*(0x40)+0x08 0x2B0+sec_num*(0x40)+0x0C 0x2B0+sec_num*(0x40)+0x10 0x2B0+sec_num*(0x40)+0x14 0x2B0+sec_num*(0x40)+0x18 0x2B0+sec_num*(0x40)+0x1C 0x2B0+sec_num*(0x40)+0x20 0x2B0+sec_num*(0x40)+0x24 0x2B0+sec_num*(0x40)+0x28 0x2B0+sec_num*(0x40)+0x2C 0x4A0-0x4FC 0x500 0x504 0x508 0x50C 0x510 0x514 0x518 0x51C 0x520 0x524-0x52C 0x528 ... 0x588 0x58C ... 0x5E8 0x5EC-0x5FC 0x14*CS_number+0x600 0x14*CS_number+0x604 0x14*CS_number+0x608 0x14*CS_number+0x60C 0x14*CS_number+0x610 Register PMECC Remainder 1 Register PMECC Remainder 2 Register PMECC Remainder 3 Register PMECC Remainder 4 Register PMECC Remainder 5 Register PMECC Remainder 6 Register PMECC Remainder 7 Register PMECC Remainder 8 Register PMECC Remainder 9 Register PMECC Remainder 10 Register PMECC Remainder 11 Register Reserved PMECC Error Location Configuration Register PMECC Error Location Primitive Register PMECC Error Location Enable Register PMECC Error Location Disable Register PMECC Error Location Status Register PMECC Error Location Interrupt Enable register PMECC Error Location Interrupt Disable Register PMECC Error Location Interrupt Mask Register PMECC Error Location Interrupt Status Register Reserved PMECC Error Location SIGMA 0 Register ... PMECC Error Location SIGMA 24 Register PMECC Error Location 0 Register ... PMECC Error Location 23 Register Reserved HSMC Setup Register HSMC Pulse Register HSMC Cycle Register HSMC Timings Register HSMC Mode Register Name HSMC_REM1 HSMC_REM2 HSMC_REM3 HSMC_REM4 HSMC_REM5 HSMC_REM6 HSMC_REM7 HSMC_REM8 HSMC_REM9 HSMC_REM10 HSMC_REM11 HSMC_ELCFG HSMC_ELPRIM HSMC_ELEN HSMC_ELDIS HSMC_ELSR HSMC_ELIER HSMC_ELIDR HSMC_ELIMR HSMC_ELISR HSMC_SIGMA0 ... HSMC_SIGMA24 HSMC_ERRLOC0 ... HSMC_ERRLOC23 HSMC_SETUP HSMC_PULSE HSMC_CYCLE HSMC_TIMINGS HSMC_MODE Access Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-write Read-only Write Write Read Write Write Read Read Read-write ... Read-write Read-only ... Read-only Read-write Read-write Read-write Read-write Read-write Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x401A 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 ... 0x0 0x0 ... 0x0
403
Table 29-15. Register Mapping (Continued) Offset 0x6A0 0x6A4 0x6A8 0x6AC-0x6E0 0x6E4 0x6E8 0x6FC Register HSMC OCMS Register HSMC OCMS KEY1 Register HSMC OCMS KEY2 Register Reserved HSMC Write Protection Control Register HSMC Write Protection Status Register Reserved Name HSMC_OCMS HSMC_KEY1 HSMC_KEY2 HSMC_WPCR HSMC_WPSR Access Read-write Write-only Write-only Write-only Read-only Reset 0x0 0x0 0x0 0x0 0x0
404
22
21 DTOMUL 13 RBEDGE 5
20
18 DTOCYC
17
16
14 6
12 EDGECTRL 4
11 3
10 2
9 RSPARE 1 PAGESIZE
8 WSPARE 0
PAGESIZE
This field defines the page size of the NAND Flash device.
Value 0 1 2 3 4 PS512 PS1024 PS2048 PS4096 PS8192 Name Main area 512 Bytes Main area 1024 Bytes Main area 2048 Bytes Main area 4096 Bytes Main area 8192 Bytes Description
405
If the data timeout set by DTOCYC and DTOMUL has been exceeded, the Data Timeout Error flag (DTOE) in the NFC Status Register (NFC_SR) raises.
NFCSPARESIZE: NAND Flash Spare Area Size Retrieved by the Host Controller
The spare size is set to (NFCSPARESIZE+1) * 4 Bytes. The spare area is only retrieved when RSPARE or WSPARE is activated.
406
407
4 RB_RISE
408
409
410
411
412
413
414
415
4 3 ADDR_CYCLE0
416
417
SECTORSZ: Sector Size 0: The ECC computation is based on a sector of 512 Bytes.
1: The ECC computation is based on a sector of 1024 Bytes.
418
419
420
421
422
423
424
425
426
427
428
Access: Reset:
31
429
Access: Reset:
31 23
430
12 4
11 3
9 1
8 0 SECTORSZ
431
432
433
434
435
436
437
438
0 DONE
439
440
ERRLOCN: Error Position within the Set {sector area, spare area}
ERRLOCN points to 1 when the first bit of the main area is corrupted. If the sector size is set to 512 Bytes, the ERRLOCN points to 4096 when the last bit of the sector area is corrupted. If the sector size is set to 1024 Bytes, the ERRLOCN points to 8192 when the last bit of the sector area is corrupted. If the sector size is set to 512 Bytes, the ERRLOCN points to 4097 when the first bit of the spare area is corrupted. If the sector size is set to 1024 Bytes, the ERRLOCN points to 8193 when the first bit of the spare area is corrupted.
441
HSMC_SETUPx [x=0..3] 0xFFFFC600 [0], 0xFFFFC614 [1], 0xFFFFC628 [2], 0xFFFFC63C [3] Write-only
30 22 14 6 29 28 27 26 NCS_RD_SETUP 19 NRD_SETUP 13 12 11 10 NCS_WR_SETUP 3 NWE_SETUP 2 9 8 18 25 24
21
20
17
16
442
HSMC_PULSEx [x=0..3] 0xFFFFC604 [0], 0xFFFFC618 [1], 0xFFFFC62C [2], 0xFFFFC640 [3] Write-only
30 22 14 6 29 28 27 26 NCS_RD_PULSE 19 NRD_PULSE 13 12 11 10 NCS_WR_PULSE 3 NWE_PULSE 2 9 8 18 25 24
21
20
17
16
443
HSMC_CYCLEx [x=0..3] 0xFFFFC608 [0], 0xFFFFC61C [1], 0xFFFFC630 [2], 0xFFFFC644 [3] Read-write
30 22 29 21 28 20 NRD_CYCLE 15 7 14 6 13 5 12 4 NWE_CYCLE 11 3 10 2 9 1 8 NWE_CYCLE 0 27 19 26 18 25 17 24 NRD_CYCLE 16
444
HSMC_TIMINGSx [x=0..3] 0xFFFFC60C [0], 0xFFFFC620 [1], 0xFFFFC634 [2], 0xFFFFC648 [3] Read-write
30 29 RBNSEL 21 13 5 TADL 28 27 26 TWB 20 12 OCMS 4 19 18 TRR 11 10 TAR 3 2 TCLR 1 0 9 8 17 16 25 24
22 14 6
445
HSMC_MODEx [x=0..3] 0xFFFFC610 [0], 0xFFFFC624 [1], 0xFFFFC638 [2], 0xFFFFC64C [3] Read-write
30 22 14 6 29 21 13 5 EXNW_MODE 28 20 TDF_MODE 12 DBW 4 27 19 26 25 24 16
18 17 TDF_CYCLES 10 2 9
11 3
8 BAT
1 0 WRITE_MODE READ_MODE
READ_MODE
1 (NRD_CTRL): The Read operation is controlled by the NRD signal. 0 (NCS_CTRL): The Read operation is controlled by the NCS signal.
WRITE_MODE
1 (NWE_CTRL): The Write operation is controlled by the NWE signal. 0 (NCS_CTRL): The Write operation is controller by the NCS signal.
Disabled: 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. Ready Mode: The NWAIT signal indicates the availability of the external device at the end of the pulse of the controlling read or write signal, to complete the access. If high, the access normally completes. If low, the access is extended until NWAIT returns high. BAT: Byte Access Type
This field is used only if DBW defines a 16-bit data bus. 1 (BYTE_WRITE): Byte write access type:
Write operation is controlled using NCS, NWR0, NWR1. Read operation is controlled using NCS and NRD.
446
Write operation is controlled using NCS, NWE, NBS0, NBS1. Read operation is controlled using NCS, NRD, NBS0, NBS1. DBW: Data Bus Width
Value 0 1 Name BIT_8 BIT_16 Description 8-bit bus 16-bit bus
The number of TDF wait states is optimized using the setup period of the next read/write access.
0: TDF optimization is disabled.
The number of TDF wait states is inserted before the next access begins.
447
448
23
22
21
20 KEY1
19
18
17
16
15
14
13
12 KEY1
11
10
4 KEY1
449
23
22
21
20 KEY2
19
18
17
16
15
14
13
12 KEY2
11
10
4 KEY2
450
23
22
21
20 WP_KEY
19
18
17
16
15
14
13
12 WP_KEY
11
10
0 WP_EN
451
15
14
13
12 WP_VSRC
11
10
7 -
6 -
5 -
4 -
2 WP_VS
452
30.
30.1
30.2
Embedded Characteristics
z z z z z z z z z z z z z z z z
3 AHB-Lite Master Interfaces DMA Module Supports the Following Transfer Schemes: Peripheral-to-Memory, Memory-to-Peripheral, Peripheralto-Peripheral and Memory-to-Memory Source and Destination Operate independently on BYTE (8-bit), HALF-WORD (16-bit) and WORD (32-bit) Supports Hardware and Software Initiated Transfers Supports Multiple Buffer Chaining Operations Supports Incrementing/decrementing/fixed Addressing Mode Independently for Source and Destination Supports Programmable Address Increment/decrement on User-defined Boundary Condition to Enable Picture-inPicture Mode Programmable Arbitration Policy, Modified Round Robin and Fixed Priority are Available Supports Specified Length and Unspecified Length AMBA AHB Burst Access to Maximize Data Bandwidth AMBA APB Interface Used to Program the DMA Controller 8 DMA Channels on DMAC0 8 DMA Channels on DMAC1 16 External Request Lines on DMAC0 22 External Request Lines on DMAC1 Embedded FIFO Channel Locking and Bus Locking Capability
453
454
455
30.3
Block Diagram
DMA Channel n DMA Destination DMA Channel 2 DMA Channel 1 DMA Channel 0
DMA Channel 0 Write data path to destination
DMA Interrupt
Trigger Manager
External Triggers
Soft Triggers
DMA Read Datapath Bundles DMA Global Control and Data Mux
456
30.4
Functional Description
457
Buffer
Buffer
Buffer
Chunk Transfer
Chunk Transfer
Chunk Transfer
Single Transfer
Buffer
Buffer
Buffer
Buffer: A buffer of DMAC data. The amount of data (length) is determined by the flow controller. For transfers between the DMAC and memory, a buffer is broken directly into a sequence of AMBA bursts and AMBA single transfers. For transfers between the DMAC and a non-memory peripheral, a buffer is broken into a sequence of DMAC transactions (single and chunks). These are in turn broken into a sequence of AMBA transfers. Transaction: A basic unit of a DMAC transfer as determined by either the hardware or software handshaking interface. A transaction is only relevant for transfers between the DMAC and a source or destination peripheral if the source or destination peripheral is a non-memory device. There are two types of transactions: single transfer and chunk transfer.
z z
Single transfer: The length of a single transaction is always 1 and is converted to a single AMBA access. Chunk transfer: The length of a chunk is programmed into the DMAC. The chunk is then converted into a sequence of AHB access.DMAC executes each AMBA burst transfer by performing incremental bursts that are no longer than 16 beats.
DMAC transfer: Software controls the number of buffers in a DMAC transfer. Once the DMAC transfer has completed, then hardware within the DMAC disables the channel and can generate an interrupt to signal the completion of the DMAC transfer. You can then re-program the channel for a new DMAC transfer. Single-buffer DMAC transfer: Consists of a single buffer.
458
Multi-buffer DMAC transfer: A DMAC transfer may consist of multiple DMAC buffers. Multi-buffer DMAC transfers are supported through buffer chaining (linked list pointers), auto-reloading of channel registers, and contiguous buffers. The source and destination can independently select which method to use.
z
Linked lists (buffer chaining) A descriptor pointer (DSCR) points to the location in system memory where the next linked list item (LLI) exists. The LLI is a set of registers that describe the next buffer (buffer descriptor) and a descriptor pointer register. The DMAC fetches the LLI at the beginning of every buffer when buffer chaining is enabled. Replay The DMAC automatically reloads the channel registers at the end of each buffers to the value when the channel was first enabled. Contiguous buffers Where the address of the next buffer is selected to be a continuation from the end of the previous buffer.
z z
Picture-in-Picture Mode: DMAC contains a Picture-in-Picture mode support. When this mode is enabled, addresses are automatically incremented by a programmable value when the DMAC channel transfer count reaches a user defined boundary. Figure 30-4 on page 459 illustrates a memory mapped image 4:2:2 encoded located at image_base_address in memory. A user defined start address is defined at Picture_start_address. The incremented value is set to memory_hole_size = image_width - picture_width, and the boundary is set to picture_width.
Figure 30-4. Picture-In-Picture Mode Support
DMAC PIP transfers
Channel locking: Software can program a channel to keep the AHB master interface by locking the arbitration for the master bus interface for the duration of a DMAC transfer, buffer, or chunk. Bus locking: Software can program a channel to maintain control of the AMBA bus by asserting hmastlock for the duration of a DMAC transfer, buffer, or transaction (single or chunk). Channel locking is asserted for the duration of bus locking at a minimum.
459
Software selects between the hardware or software handshaking interface on a per-channel basis. Software handshaking is accomplished through memory-mapped registers, while hardware handshaking is accomplished using a dedicated handshaking interface. 30.4.3.1 Software Handshaking When the slave peripheral requires the DMAC to perform a DMAC transaction, it communicates this request by sending an interrupt to the CPU or interrupt controller. The interrupt service routine then uses the software registers to initiate and control a DMAC transaction. These software registers are used to implement the software handshaking interface. The SRC_H2SEL/DST_H2SEL bit in the DMAC_CFGx channel configuration register must be set to zero to enable software handshaking. When the peripheral is not the flow controller, then the last transaction register DMAC_LAST is not used, and the values in these registers are ignored.
Chunk Transactions
Writing a 1 to the DMAC_CREQ[2x] register starts a source chunk transaction request, where x is the channel number. Writing a 1 to the DMAC_CREQ[2x+1] register starts a destination chunk transfer request, where x is the channel number. Upon completion of the chunk transaction, the hardware clears the DMAC_CREQ[2x] or DMAC_CREQ[2x+1].
Single Transactions
Writing a 1 to the DMAC_SREQ[2x] register starts a source single transaction request, where x is the channel number. Writing a 1 to the DMAC_SREQ[2x+1] register starts a destination single transfer request, where x is the channel number. Upon completion of the chunk transaction, the hardware clears the DMAC_SREQ[x] or DMAC_SREQ[2x+1]. The software can poll the relevant channel bit in the DMAC_CREQ[2x]/DMAC_CREQ[2x+1] and DMAC_SREQ[x]/DMAC_SREQ[2x+1] registers. When both are 0, then either the requested chunk or single transaction has completed.
460
Buffer chaining using linked lists Replay mode Contiguous address between buffers
On successive buffers of a multi-buffer transfer, the DMAC_CTRLAx and DMAC_CTRLBx registers in the DMAC are reprogrammed using either of the following methods:
z z
When buffer chaining using linked lists is the multi-buffer method of choice, and on successive buffers, the DMAC_DSCRx register in the DMAC is re-programmed using the following method:
z
A buffer descriptor (LLI) consists of following registers, DMAC_SADDRx, DMAC_DADDRx, DMAC_DSCRx, DMAC_CTRLAx, DMAC_CTRLBx.These registers, along with the DMAC_CFGx register, are used by the DMAC to set up and describe the buffer transfer. 30.4.4.1 Multi-buffer Transfers
461
System Memory LLI(0) DSCRx(1)= DSCRx(0) + 0x10 CTRLBx= DSCRx(0) + 0xC CTRLAx= DSCRx(0) + 0x8 DADDRx= DSCRx(0) + 0x4 SADDRx= DSCRx(0) + 0x0 DSCRx(1)
LLI(1) DSCRx(2)= DSCRx(1) + 0x10 CTRLBx= DSCRx(1) + 0xC CTRLBx= DSCRx(1) + 0x8 DADDRx= DSCRx(1) + 0x4 SADDRx= DSCRx(1) + 0x0 DSCRx(2) (points to 0 if LLI(1) is the last transfer descriptor
DSCRx(0)
LLI(1)
CRCx(1)= DSCRx(0) + 0x14 DSCRx(1)= DSCRx(0) + 0x10 CTRLBx= DSCRx(0) + 0xC CTRLAx= DSCRx(0) + 0x8 DADDRx= DSCRx(0) + 0x4 SADDRx= DSCRx(0) + 0x0 DSCRx(1)
CRCx(2)= DSCRx(1) + 0x14 DSCRx(2)= DSCRx(1) + 0x10 CTRLBx= DSCRx(1) + 0xC CTRLBx= DSCRx(1) + 0x8 DADDRx= DSCRx(1) + 0x4 SADDRx= DSCRx(1) + 0x0 DSCRx(2) (points to 0 if LLI(1) is the last transfer descriptor
DSCRx(0)
462
0 0 0 0 0
0 1
0 1
0 1 0 0 1
1 0 0 1 0
REP
USR
LLI
CONT
LLI
REP
USR
CONT
LLI
LLI
REP
USR
CONT
CONT
REP
REP
USR
REP
REP
REP
REP
USR
REP
CONT
REP
Notes: 1. USR means that the register field is manually programmed by the user. 2. CONT means that address are contiguous. 3. REP means that the register field is updated with its previous value. If the transfer is the first one, then the user must manually program the value. 4. Channel stalled is true if the relevant BTC interrupt is not masked. 5. LLI means that the register field is updated with the content of the linked list item.
463
The channel buffer interrupt is unmasked, DMAC_EBCIMR.BTCx = 1, where x is the channel number. The Buffer Transfer Completed Interrupt is generated at the completion of the buffer transfer to the destination. The channel end of the Chained Buffer Transfer Completed Interrupt is unmasked, DMAC_EBCIMR.CBTCx = 1, when n is the channel number.
Note:
z
At the end of a chain of multiple buffers, an end of linked list interrupt is asserted if:
30.4.4.3 Ending Multi-buffer Transfers All multi-buffer transfers must end as shown in Row 1 of Table 30-3 on page 463. At the end of every buffer transfer, the DMAC samples the row number, and if the DMAC is in Row 1 state, then the previous buffer transferred was the last buffer and the DMAC transfer is terminated. For rows 9, 10 and 11 of Table 30-3 on page 463, (DMAC_DSCRx = 0 and DMAC_CTRLBx.AUTO is set), multi-buffer DMAC transfers continue until the automatic mode is disabled by writing a 1 in DMAC_CTRLBx.AUTO bit. This bit should be programmed to zero in the end of buffer interrupt service routine that services the next-to-last buffer transfer. This puts the DMAC into Row 1 state. For rows 2, 3, 4, 5, and 6 (DMAC_CRTLBx.AUTO cleared), the user must set up the last buffer descriptor in memory so that LLI.DMAC_DSCRx is set to 0.
464
6.
Write the channel configuration information into the DMAC_CFGx register for channel x. i. Designate the handshaking interface type (hardware or software) for the source and destination peripherals. This is not required for memory. This step requires programming the SRC_H2SEL/DST_H2SEL bits, respectively. Writing a 1 activates the hardware handshaking interface to handle source/destination requests. Writing a 0 activates the software handshaking interface to handle source/destination requests. ii. If the hardware handshaking interface is activated for the source or destination peripheral, assign a handshaking interface to the source and destination peripheral. This requires programming the SRC_PER and DST_PER bits, respectively.
7. 8. 4.
If source Picture-in-Picture mode is enabled (DMAC_CTRLBx.SRC_PIP is enabled), program the DMAC_SPIPx register for channel x. If destination Picture-in-Picture mode is enabled (DMAC_CTRLBx.DST_PIP is enabled), program the DMAC_DPIPx register for channel x.
After the DMAC selected channel has been programmed, enable the channel by writing a 1 to the DMAC_CHER.ENAx bit, where x is the channel number. Make sure that bit 0 of DMAC_EN.ENABLE register is enabled. Source and destination request single and chunk DMAC transactions to transfer the buffer of data (assuming nonmemory peripherals). The DMAC acknowledges at the completion of every transaction (chunk and single) in the buffer and carries out the buffer transfer. Once the transfer completes, the hardware sets the interrupts and disables the channel. At this time, you can either respond to the Buffer Transfer Completed Interrupt or Chained Buffer Transfer Completed Interrupt, or poll for the Channel Handler Status Register (DMAC_CHSR.ENAx) bit until it is cleared by hardware, to detect when the transfer is complete.
5.
6.
Multi-buffer Transfer with Linked List for Source and Linked List for Destination (Row 4)
1. 2. Read the Channel Handler Status register to choose a free (disabled) channel. Set up the chain of Linked List Items (otherwise known as buffer descriptors) in memory. Write the control information in the LLI.DMAC_CTRLAx and LLI.DMAC_CTRLBx registers location of the buffer descriptor for each LLI in memory (see Figure 30-7 on page 467) for channel x. For example, in the register, you can program the following: 1. 2. Set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the FC of the DMAC_CTRLBx register. Set up the transfer characteristics, such as: i. Transfer width for the source in the SRC_WIDTH field. ii. Transfer width for the destination in the DST_WIDTH field. iii. Source AHB master interface layer in the SIF field where source resides. iv. Destination AHB master interface layer in the DIF field where destination resides. v. Incrementing/decrementing or fixed address for source in SRC_INCR field. vi. Incrementing/decrementing or fixed address for destination DST_INCR field. 3. Write the channel configuration information into the DMAC_CFGx register for channel x. 1. Designate the handshaking interface type (hardware or software) for the source and destination peripherals. This is not required for memory. This step requires programming the SRC_H2SEL/DST_H2SEL bits, respectively. Writing a 1 activates the hardware handshaking interface to handle source/destination requests for the specific channel. Writing a 0 activates the software handshaking interface to handle source/destination requests. If the hardware handshaking interface is activated for the source or destination peripheral, assign the handshaking interface to the source and destination peripheral. This requires programming the SRC_PER and DST_PER bits, respectively.
2.
465
4.
Make sure that the LLI.DMAC_CTRLBx register locations of all LLI entries in memory (except the last) are set as shown in Row 4 of Table 30-3 on page 463. The LLI.DMAC_CTRLBx register of the last Linked List Item must be set as described in Row 1 of Table 30-3. Figure 30-5 on page 462 shows a Linked List example with two list items. Make sure that the LLI.DMAC_DSCRx register locations of all LLI entries in memory (except the last) are non-zero and point to the base address of the next Linked List Item. Make sure that the LLI.DMAC_SADDRx/LLI.DMAC_DADDRx register locations of all LLI entries in memory point to the start source/destination buffer address preceding that LLI fetch. Make sure that the LLI.DMAC_CTRLAx.DONE field of the LLI.DMAC_CTRLAx register locations of all LLI entries in memory are cleared. If source Picture-in-Picture mode is enabled (DMAC_CTRLBx.SRC_PIP is enabled), program the DMAC_SPIPx register for channel x. If destination Picture-in-Picture is enabled (DMAC_CTRLBx.DST_PIP is enabled), program the DMAC_DPIPx register for channel x.
5. 6. 7. 8. 9.
10. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the status register: DMAC_EBCISR. 11. Program the DMAC_CTRLBx, DMAC_CFGx registers according to Row 4 as shown in Table 30-3 on page 463. 12. Program the DMAC_DSCRx register with DMAC_DSCRx(0), the pointer to the first Linked List item. 13. Finally, enable the channel by writing a 1 to the DMAC_CHER.ENAx bit, where x is the channel number. The transfer is performed. 14. The DMAC fetches the first LLI from the location pointed to by DMAC_DSCRx(0). Note: The LLI.DMAC_SADDRx, LLI. DMAC_DADDRx, LLI.DMAC_DSCRx, LLI.DMAC_CTRLAx and LLI.DMAC_CTRLBx registers are fetched. The DMAC automatically reprograms the DMAC_SADDRx, DMAC_DADDRx, DMAC_DSCRx, DMAC_CTRLBx and DMAC_CTRLAx channel registers from the DMAC_DSCRx(0).
15. Source and destination request single and chunk DMAC transactions to transfer the buffer of data (assuming nonmemory peripheral). The DMAC acknowledges at the completion of every transaction (chunk and single) in the buffer and carries out the buffer transfer. 16. Once the buffer of data is transferred, the DMAC_CTRLAx register is written out to system memory at the same location and on the same layer (DMAC_DSCRx.DSCR_IF) where it was originally fetched, that is, the location of the DMAC_CTRLAx register of the linked list item fetched prior to the start of the buffer transfer. Only DMAC_CTRLAx register is written out because only the DMAC_CTRLAx.BTSIZE and DMAC_CTRLAX.DONE bits have been updated by DMAC hardware. Additionally, the DMAC_CTRLAx.DONE bit is asserted when the buffer transfer has completed. Note: Do not poll the DMAC_CTRLAx.DONE bit in the DMAC memory map. Instead, poll the LLI.DMAC_CTRLAx.DONE bit in the LLI for that buffer. If the poll LLI.DMAC_CTRLAx.DONE bit is asserted, then this buffer transfer has completed. This LLI.DMAC_CTRLAx.DONE bit was cleared at the start of the transfer.
17. The DMAC does not wait for the buffer interrupt to be cleared, but continues fetching the next LLI from the memory location pointed to by current DMAC_DSCRx register and automatically reprograms the DMAC_SADDRx, DMAC_DADDRx, DMAC_DSCRx, DMAC_CTRLAx and DMAC_CTRLBx channel registers. The DMAC transfer continues until the DMAC determines that the DMAC_CTRLBx and DMAC_DSCRx registers at the end of a buffer transfer match described in Row 1 of Table 30-3 on page 463. The DMAC then knows that the previous buffer transferred was the last buffer in the DMAC transfer. The DMAC transfer might look like that shown in Figure 30-7 on page 467.
466
Figure 30-7. Multi-buffer with Linked List Address for Source and Destination
Buffer 2
Buffer 1
Buffer 0
Destination Buffers
If the user needs to execute a DMAC transfer where the source and destination address are contiguous but the amount of data to be transferred is greater than the maximum buffer size DMAC_CTRLAx.BTSIZE, then this can be achieved using the type of multi-buffer transfer as shown in Figure 30-8 on page 468.
467
Figure 30-8. Multi-buffer with Linked Address for Source and Destination Buffers are Contiguous
Buffer 2 DADDR(3) Buffer 2 SADDR(3) Buffer 2 SADDR(2) Buffer 1 SADDR(1) Buffer 0 SADDR(0) Source Buffers Destination Buffers Buffer 0 DADDR(0) Buffer 1 DADDR(1) Buffer 2 DADDR(2)
468
Figure 30-9. DMAC Transfer Flow for Source and Destination Linked List Address
Channel enabled by software
LLI Fetch
Writeback of DMAC_CTRLAx register in system memory Chained Buffer Transfer Completed Interrupt generated here
no
yes
469
Multi-buffer Transfer with Source Address Auto-reloaded and Destination Address Auto-reloaded (Row 10)
1. 2. Read the Channel Handler Status register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the interrupt status register. Program the following channel registers: 1. 2. 3. 4. Write the starting source address in the DMAC_SADDRx register for channel x. Write the starting destination address in the DMAC_DADDRx register for channel x. Program DMAC_CTRLAx, DMAC_CTRLBx and DMAC_CFGx according to Row 10 as shown in Table 30-3 on page 463. Program the DMAC_DSCRx register with 0. Write the control information for the DMAC transfer in the DMAC_CTRLAx and DMAC_CTRLBx register for channel x. For example, in the register, you can program the following: i. Set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the FC of the DMAC_CTRLBx register. ii. Set up the transfer characteristics, such as:
z z z z z z
Transfer width for the source in the SRC_WIDTH field. Transfer width for the destination in the DST_WIDTH field. Source AHB master interface layer in the SIF field where source resides. Destination AHB master interface layer in the DIF field where destination resides. Incrementing/decrementing or fixed address for source in SRC_INCR field. Incrementing/decrementing or fixed address for destination in DST_INCR field.
5. 6. 7.
If source Picture-in-Picture mode is enabled (DMAC_CTRLBx.SPIP is enabled), program the DMAC_SPIPx register for channel x. If destination Picture-in-Picture is enabled (DMAC_CTRLBx.DPIP), program the DMAC_DPIPx register for channel x. Write the channel configuration information into the DMAC_CFGx register for channel x. Ensure that the reload bits, DMAC_CFGx.SRC_REP, DMAC_CFGx.DST_REP and DMAC_CTRLBx.AUTO are enabled. i. Designate the handshaking interface type (hardware or software) for the source and destination peripherals. This is not required for memory. This step requires programming the SRC_H2SEL/DST_h2SEL bits, respectively. Writing a 1 activates the hardware handshaking interface to handle source/destination requests for the specific channel. Writing a 0 activates the software handshaking interface to handle source/destination requests. ii. If the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. This requires programming the SRC_PER and DST_PER bits, respectively.
3. 4.
After the DMAC selected channel has been programmed, enable the channel by writing a 1 to the DMAC_CHER.ENAx bit where the channel number is. Make sure that bit 0 of the DMAC_EN register is enabled. Source and destination request single and chunk DMAC transactions to transfer the buffer of data (assuming nonmemory peripherals). The DMAC acknowledges on completion of each chunk/single transaction and carries out the buffer transfer. When the buffer transfer has completed, the DMAC reloads the DMAC_SADDRx, DMAC_DADDRx and DMAC_CTRLAx registers. The hardware sets the Buffer Transfer Completed Interrupt. The DMAC then samples the row number as shown in Table 30-3 on page 463. If the DMAC is in Row 1, then the DMAC transfer has completed. The hardware sets the Chained Buffer Transfer Completed Interrupt and disables the channel. So you can either respond to the Buffer Transfer Completed Interrupt or Chained Buffer Transfer Completed Interrupt, or poll for the Channel Enable in the Channel Status Register (DMAC_CHSR.ENAx) until it is disabled, to detect when the transfer is complete. If the DMAC is not in Row 1, the next step is performed.
5.
470
6.
The DMAC transfer proceeds as follows: 1. If the Buffer Transfer Completed Interrupt is unmasked (DMAC_EBCIMR.BTCx = 1, where x is the channel number), the hardware sets the Buffer Transfer Completed Interrupt when the buffer transfer has completed. It then stalls until the STALx bit of DMAC_CHSR register is cleared by software, writing 1 to DMAC_CHER.KEEPx bit, where x is the channel number. If the next buffer is to be the last buffer in the DMAC transfer, then the buffer complete ISR (interrupt service routine) should clear the automatic mode bit in the DMAC_CTRLBx.AUTO bit. This puts the DMAC into Row 1 as shown in Table 30-3 on page 463. If the next buffer is not the last buffer in the DMAC transfer, then the reload bits should remain enabled to keep the DMAC in Row 4. If the Buffer Transfer Completed Interrupt is masked (DMAC_EBCIMR.BTCx = 0, where x is the channel number), the hardware does not stall until it detects a write to the Buffer Transfer Completed Interrupt Enable register DMAC_EBCIER register, but starts the next buffer transfer immediately. In this case, the software must clear the automatic mode bit in the DMAC_CTRLB to put the DMAC into ROW 1 of Table 303 on page 463 before the last buffer of the DMAC transfer has completed. The transfer is similar to that shown in Figure 30-10 on page 471. The DMAC transfer flow is shown in Figure 30-11 on page 472.
2.
Figure 30-10. Multi-buffer DMAC Transfer with Source and Destination Address Auto-reloaded
Address of Source Layer Address of Destination Layer
SADDR
DADDR
471
Figure 30-11. DMAC Transfer Flow for Source and Destination Address Auto-reloaded
Channel enabled by software
Buffer Transfer
Replay mode for SADDRx, DADDRx, CTRLAx, CTRLBx Buffer Transfer Completed Interrupt generated here DMAC Chained Buffer Transfer Completed Interrupt generated here
yes
no
EBCIMR[x]=1?
no
yes
472
Multi-buffer Transfer with Source Address Auto-reloaded and Linked List Destination Address (Row 6)
1. 2. Read the Channel Handler Status register to choose a free (disabled) channel. Set up the chain of linked list items (otherwise known as buffer descriptors) in memory. Write the control information in the LLI.DMAC_CTRLAx and DMAC_CTRLBx registers location of the buffer descriptor for each LLI in memory for channel x. For example, in the register, you can program the following: 1. 2. Set up the transfer type (memory or non-memory peripheral for source and destination) and flow control peripheral by programming the FC of the DMAC_CTRLBx register. Set up the transfer characteristics, such as: i. Transfer width for the source in the SRC_WIDTH field. ii. Transfer width for the destination in the DST_WIDTH field. iii. Source AHB master interface layer in the SIF field where source resides. iv. Destination AHB master interface layer in the DIF field where destination resides. v. Incrementing/decrementing or fixed address for source in SRC_INCR field. vi. Incrementing/decrementing or fixed address for destination DST_INCR field. 3. Note: 4. Write the starting source address in the DMAC_SADDRx register for channel x. The values in the LLI.DMAC_SADDRx register locations of each of the Linked List Items (LLIs) set up in memory, although fetched during an LLI fetch, are not used. Write the channel configuration information into the DMAC_CFGx register for channel x. 1. Designate the handshaking interface type (hardware or software) for the source and destination peripherals. This is not required for memory. This step requires programming the SRC_H2SEL/DST_H2SEL bits, respectively. Writing a 1 activates the hardware handshaking interface to handle source/destination requests for the specific channel. Writing a 0 activates the software handshaking interface source/destination requests. If the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. This requires programming the SRC_PER and DST_PER bits, respectively.
2.
5.
Make sure that the LLI.DMAC_CTRLBx register locations of all LLIs in memory (except the last one) are set as shown in Row 6 of Table 30-3 on page 463 while the LLI.DMAC_CTRLBx register of the last Linked List item must be set as described in Row 1 of Table 30-3. Figure 30-5 on page 462 shows a Linked List example with two list items. Make sure that the LLI.DMAC_DSCRx register locations of all LLIs in memory (except the last one) are non-zero and point to the next Linked List Item. Make sure that the LLI.DMAC_DADDRx register locations of all LLIs in memory point to the start destination buffer address proceeding that LLI fetch. Make sure that the LLI.DMAC_CTLx.DONE field of the LLI.DMAC_CTRLA register locations of all LLIs in memory is cleared. If source Picture-in-Picture is enabled (DMAC_CTRLBx.SPIP is enabled), program the DMAC_SPIPx register for channel x.
6. 7. 8. 9.
10. If destination Picture-in-Picture is enabled (DMAC_CTRLBx.DPIP is enabled), program the DMAC_DPIPx register for channel x. 11. Clear any pending interrupts on the channel from the previous DMAC transfer by reading to the DMAC_EBCISR register. 12. Program the DMAC_CTLx and DMAC_CFGx registers according to Row 6 as shown in Table 30-3 on page 463. 13. Program the DMAC_DSCRx register with DMAC_DSCRx(0), the pointer to the first Linked List item. 14. Finally, enable the channel by writing a 1 to the DMAC_CHER.ENAx bit, where x is the channel number. The transfer is performed. Make sure that bit 0 of the DMAC_EN register is enabled.
473
15. The DMAC fetches the first LLI from the location pointed to by DMAC_DSCRx(0). Note: The LLI.DMAC_SADDRx, LLI.DMAC_DADDRx, LLI. DMAC_LLPx LLI.DMAC_CTRLAx and LLI.DMAC_CTRLBx registers are fetched. The LLI.DMAC_SADDRx register, although fetched, is not used.
16. Source and destination request single and chunk DMAC transactions to transfer the buffer of data (assuming nonmemory peripherals). DMAC acknowledges at the completion of every transaction (chunk and single) in the buffer and carries out the buffer transfer. 17. The DMAC_CTRLAx register is written out to the system memory. The DMAC_CTRLAx register is written out to the same location on the same layer (DMAC_DSCRx.DSCR_IF) where it was originally fetched, that is the location of the DMAC_CTRLAx register of the linked list item fetched prior to the start of the buffer transfer. Only DMAC_CTRLAx register is written out, because only the DMAC_CTRLAx.BTSIZE and DMAC_CTRLAx.DONE fields have been updated by hardware within the DMAC. The LLI.DMAC_CTRLAx.DONE bit is asserted to indicate buffer completion. Therefore, the software can poll the LLI.DMAC_CTRLAx.DONE field of the DMAC_CTRLAx register in the LLi to ascertain when a buffer transfer has completed. Note: Do not poll the DMAC_CTRLAx.DONE bit in the DMAC memory map. Instead, poll the LLI.DMAC_CTRLAx.DONE bit in the LLI for that buffer. If the polled LLI.DMAC_CTRLAx.DONE bit is asserted, then this buffer transfer has completed. This LLI.DMAC_CTRLA.DONE bit was cleared at the start of the transfer.
18. The DMAC reloads the DMAC_SADDRx register from the initial value. The hardware sets the Buffer Transfer Completed Interrupt. The DMAC samples the row number as shown in Table 30-3 on page 463. If the DMAC is in Row 1, then the DMAC transfer has completed. The hardware sets the Chained Buffer Transfer Completed Interrupt and disables the channel. You can either respond to the Buffer Transfer Completed Interrupt or Chained Buffer Transfer Completed Interrupt, or poll for the Channel Enable. (DMAC_CHSR.ENAx) bit until it is cleared by hardware, to detect when the transfer is complete. If the DMAC is not in Row 1 as shown in Table 30-3 on page 463, the following step is performed. 19. The DMAC fetches the next LLI from the memory location pointed to by the current DMAC_DSCRx register, and automatically reprograms the DMAC_DADDRx, DMAC_CTRLAx, DMAC_CTRLBx and DMAC_DSCRx channel registers. Note that the DMAC_SADDRx is not re-programmed as the reloaded value is used for the next DMAC buffer transfer. If the next buffer is the last buffer of the DMAC transfer, then the DMAC_CTRLBx and DMAC_DSCRx registers just fetched from the LLI should match Row 1 of Table 30-3 on page 463. The DMAC transfer might look like that shown in Figure 30-12 on page 475.
474
Figure 30-12. Multi-buffer DMAC Transfer with Source Address Auto-reloaded and Linked List Destination Address
Address of Source Layer Address of Destination Layer
Buffer0 DADDR(0)
BufferN DADDR(N)
Source Buffers
Destination Buffers
475
Figure 30-13. DMAC Transfer Flow for Replay Mode at Source and Linked List Destination Address
Channel enabled by software
LLI Fetch
Reload SADDRx Buffer Transfer Completed Interrupt generated here yes DMAC Chained Buffer Transfer Completed Interrupt generated here Is DMAC in Row 1 of DMAC State Machine Table?
no
476
Multi-buffer Transfer with Source Address Auto-reloaded and Contiguous Destination Address (Row 11)
1. 2. 3. Read the Channel Handler Status register to choose a free (disabled) channel. Clear any pending interrupts on the channel from the previous DMAC transfer by reading to the Interrupt Status Register. Program the following channel registers: 1. 2. 3. Write the starting source address in the DMAC_SADDRx register for channel x. Write the starting destination address in the DMAC_DADDRx register for channel x. Program DMAC_CTRLAx, DMAC_CTRLBx and DMAC_CFGx according to Row 11 as shown in Table 30-3 on page 463. Program the DMAC_DSCRx register with 0. DMAC_CTRLBx.AUTO field is set to 1 to enable automatic mode support. Write the control information for the DMAC transfer in the DMAC_CTRLBx and DMAC_CTRLAx register for channel x. For example, in this register, you can program the following: i. Set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the FC of the DMAC_CTRLBx register. ii. Set up the transfer characteristics, such as:
z z z z z z
4.
Transfer width for the source in the SRC_WIDTH field. Transfer width for the destination in the DST_WIDTH field. Source AHB master interface layer in the SIF field where source resides. Destination AHB master interface master layer in the DIF field where destination resides. Incrementing/decrementing or fixed address for source in SRC_INCR field. Incrementing/decrementing or fixed address for destination in DST_INCR field.
5. 6. 7.
If source Picture-in-Picture is enabled (DMAC_CTRLBx.SPIP is enabled), program the DMAC_SPIPx register for channel x. If destination Picture-in-Picture is enabled (DMAC_CTRLBx.DPIP), program the DMAC_DPIPx register for channel x. Write the channel configuration information into the DMAC_CFGx register for channel x. i. Designate the handshaking interface type (hardware or software) for the source and destination peripherals. This is not required for memory. This step requires programming the SRC_H2SEL/DST_H2SEL bits, respectively. Writing a 1 activates the hardware handshaking interface to handle source/destination requests for the specific channel. Writing a 0 activates the software handshaking interface to handle source/destination requests. ii. If the hardware handshaking interface is activated for the source or destination peripheral, assign the handshaking interface to the source and destination peripheral. This requires programming the SRC_PER and DST_PER bits, respectively.
4. 5.
After the DMAC channel has been programmed, enable the channel by writing a 1 to the DMAC_CHER.ENAx bit, where x is the channel number. Make sure that bit 0 of the DMAC_EN.ENABLE register is enabled. Source and destination request single and chunk DMAC transactions to transfer the buffer of data (assuming nonmemory peripherals). The DMAC acknowledges at the completion of every transaction (chunk and single) in the buffer and carries out the buffer transfer. When the buffer transfer has completed, the DMAC reloads the DMAC_SADDRx register. The DMAC_DADDRx register remains unchanged. The hardware sets the Buffer Transfer Completed Interrupt. The DMAC then samples the row number as shown in Table 30-3 on page 463. If the DMAC is in Row 1, then the DMAC transfer has completed. The hardware sets the Chained Buffer Transfer Completed Interrupt and disables the channel. So you can either respond to the Buffer Transfer Completed Interrupt or Chained Buffer Transfer Completed Interrupt, or poll for the enable (ENAx) field in the Channel Status Register (DMAC_CHSR.ENAx bit) until it is cleared by hardware, to detect when the transfer is complete. If the DMAC is not in Row 1, the next step is performed.
6.
477
7.
The DMAC transfer proceeds as follows: 1. If the Buffer Transfer Completed Interrupt is unmasked (DMAC_EBCIMR.BTCx = 1, where x is the channel number), the hardware sets the Buffer Transfer Completed Interrupt when the buffer transfer has completed. It then stalls until STALx bit of DMAC_CHSR is cleared by writing in the KEEPx field of DMAC_CHER register, where x is the channel number. If the next buffer is to be the last buffer in the DMAC transfer, then the buffer complete ISR (interrupt service routine) should clear the automatic mode bit, DMAC_CTRLBx.AUTO. This puts the DMAC into Row 1 as shown in Table 30-3 on page 463. If the next buffer is not the last buffer in the DMAC transfer, then the automatic transfer mode bit should remain enabled to keep the DMAC in Row 11 as shown in Table 30-3 on page 463. If the Buffer Transfer Completed Interrupt is masked (DMAC_EBCIMR.BTCx = 0, where x is the channel number), the hardware does not stall until it detects a write to the Buffer Transfer Completed Interrupt Enable register, but starts the next buffer transfer immediately. In this case, the software must clear the automatic mode bit, DMAC_CTRLBx.AUTO, to put the device into ROW 1 of Table 30-3 on page 463 before the last buffer of the DMAC transfer has completed.
2.
The transfer is similar to that shown in Figure 30-14 on page 478. The DMAC Transfer flow is shown in Figure 30-15 on page 479.
Figure 30-14. Multi-buffer Transfer with Source Address Auto-reloaded and Contiguous Destination Address
Address of Source Layer Address of Destination Layer
Source Buffers
Destination Buffers
478
Figure 30-15. DMAC Transfer Replay Mode is Enabled for the Source and Contiguous Destination Address
Channel enabled by software
Buffer Transfer
Replay mode for SADDRx, Contiguous mode for DADDRx CTRLAx, CTRLBx Buffer Transfer Completed Interrupt generated here Buffer Transfer Completed Interrupt generated here Is DMAC in Row 1 of DMAC State Machine Table?
yes
no
no DMA_EBCIMR[x]=1?
yes Stall until STALLx field is cleared by software writing KEEPx field
Multi-buffer DMAC Transfer with Linked List for Source and Contiguous Destination Address (Row 2)
1. 2. Read the Channel Handler Status register to choose a free (disabled) channel. Set up the linked list in memory. Write the control information in the LLI.DMAC_CTRLAx and LLI.DMAC_CTRLBx register location of the buffer descriptor for each LLI in memory for channel x. For example, in the register, you can program the following: 1. 2. Set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the FC of the DMAC_CTRLBx register. Set up the transfer characteristics, such as: i. Transfer width for the source in the SRC_WIDTH field. ii. Transfer width for the destination in the DST_WIDTH field. iii. Source AHB master interface layer in the SIF field where source resides. iv. Destination AHB master interface layer in the DIF field where destination resides. v. Incrementing/decrementing or fixed address for source in SRC_INCR field. vi. Incrementing/decrementing or fixed address for destination DST_INCR field.
479
3. Note: 4.
Write the starting destination address in the DMAC_DADDRx register for channel x. The values in the LLI.DMAC_DADDRx register location of each Linked List Item (LLI) in memory, although fetched during an LLI fetch, are not used. Write the channel configuration information into the DMAC_CFGx register for channel x. 1. Designate the handshaking interface type (hardware or software) for the source and destination peripherals. This is not required for memory. This step requires programming the SRC_H2SEL/DST_H2SEL bits, respectively. Writing a 1 activates the hardware handshaking interface to handle source/destination requests for the specific channel. Writing a 0 activates the software handshaking interface to handle source/destination requests. If the hardware handshaking interface is activated for the source or destination peripheral, assign the handshaking interface to the source and destination peripherals. This requires programming the SRC_PER and DST_PER bits, respectively.
2.
5.
Make sure that all LLI.DMAC_CTRLBx register locations of the LLI (except the last) are set as shown in Row 2 of Table 30-3 on page 463, while the LLI.DMAC_CTRLBx register of the last Linked List item must be set as described in Row 1 of Table 30-3. Figure 30-5 on page 462 shows a Linked List example with two list items. Make sure that the LLI.DMAC_DSCRx register locations of all LLIs in memory (except the last) are non-zero and point to the next Linked List Item. Make sure that the LLI.DMAC_SADDRx register locations of all LLIs in memory point to the start source buffer address proceeding that LLI fetch. Make sure that the LLI.DMAC_CTRLAx.DONE field of the LLI.DMAC_CTRLAx register locations of all LLIs in memory is cleared. If source Picture-in-Picture is enabled (DMAC_CTRLBx.SPIP is enabled), program the DMAC_SPIPx register for channel x.
6. 7. 8. 9.
10. If destination Picture-in-Picture is enabled (DMAC_CTRLBx.DPIP is enabled), program the DMAC_DPIPx register for channel x. 11. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the interrupt status register. 12. Program the DMAC_CTRLAx, DMAC_CTRLBx and DMAC_CFGx registers according to Row 2 as shown in Table 30-3 on page 463 13. Program the DMAC_DSCRx register with DMAC_DSCRx(0), the pointer to the first Linked List item. 14. Finally, enable the channel by writing a 1 to the DMAC_CHER.ENAx bit. The transfer is performed. Make sure that bit 0 of the DMAC_EN register is enabled. 15. The DMAC fetches the first LLI from the location pointed to by DMAC_DSCRx(0). Note: The LLI.DMAC_SADDRx, LLI.DMAC_DADDRx, LLI.DMAC_DSCRx and LLI.DMAC_CTRLA/Bx registers are fetched. The LLI.DMAC_DADDRx register location of the LLI, although fetched, is not used. The DMAC_DADDRx register in the DMAC remains unchanged.
16. Source and destination requests single and chunk DMAC transactions to transfer the buffer of data (assuming non-memory peripherals). The DMAC acknowledges at the completion of every transaction (chunk and single) in the buffer and carries out the buffer transfer. 17. Once the buffer of data is transferred, the DMAC_CTRLAx register is written out to the system memory at the same location and on the same layer (DMAC_DSCRx.DSCR_IF) where it was originally fetched, that is, the location of the DMAC_CTRLAx register of the linked list item fetched prior to the start of the buffer transfer. Only DMAC_CTRLAx register is written out because only the DMAC_CTRLAx.BTSIZE and DMAC_CTRLAX.DONE fields have been updated by DMAC hardware. Additionally, the DMAC_CTRLAx.DONE bit is asserted when the buffer transfer has completed. Note: Do not poll the DMAC_CTRLAx.DONE bit in the DMAC memory map. Instead, poll the LLI.DMAC_CTRLAx.DONE bit in the LLI for that buffer. If the poll LLI.DMAC_CTRLAx.DONE bit is asserted, then this buffer transfer has completed. This LLI.DMAC_CTRLAx.DONE bit was cleared at the start of the transfer.
480
18. The DMAC does not wait for the buffer interrupt to be cleared, but continues and fetches the next LLI from the memory location pointed to by the current DMAC_DSCRx register, then automatically reprograms the DMAC_SADDRx, DMAC_CTRLAx, DMAC_CTRLBx and DMAC_DSCRx channel registers. The DMAC_DADDRx register is left unchanged. The DMAC transfer continues until the DMAC samples the DMAC_CTRLAx, DMAC_CTRLBx and DMAC_DSCRx registers at the end of a buffer transfer match that described in Row 1 of Table 30-3 on page 463. The DMAC then knows that the previous buffer transferred was the last buffer in the DMAC transfer. The DMAC transfer might look like that shown in Figure 30-16 on page 481. Note that the destination address is decrementing.
Figure 30-16. DMAC Transfer with Linked List Source Address and Contiguous Destination Address
Buffer 1 SADDR(1)
Buffer 1 DADDR(1)
Source Buffers
The DMAC transfer flow is shown in Figure 30-17 on page 482.
Destination Buffers
481
Figure 30-17. DMAC Transfer Flow for Linked List Source Address and Contiguous Destination Address
Channel enabled by software
LLI Fetch
Is DMAC in Row 1 ?
no
yes
482
2. 3.
When DMAC_CTRLAx.SRC_WIDTH is less than DMAC_CTRLAx.DST_WIDTH and the DMAC_CHSRx.SUSPx bit is high, the DMAC_CHSRx.EMPTx is asserted once the contents of the FIFO does not permit a single word of DMAC_CTRLAx.DST_WIDTH to be formed. However, there may still be data in the channel FIFO but not enough to form a single transfer of DMAC_CTLx.DST_WIDTH width. In this configuration, once the channel is disabled, the remaining data in the channel FIFO are not transferred to the destination peripheral. It is permitted to remove the channel from the suspension state by writing a 1 to the DMAC_CHER.RESx field register. The DMAC transfer completes in the normal manner. n defines the channel number. Note: If a channel is disabled by software, an active single or chunk transaction is not guaranteed to receive an acknowledgement.
30.4.6.1 Abnormal Transfer Termination A DMAC transfer may be terminated abruptly by software by clearing the channel enable bit, DMAC_CHDR.ENAx, where x is the channel number. This does not mean that the channel is disabled immediately after the DMAC_CHSR.ENAx bit is cleared over the APB interface. Consider this as a request to disable the channel. The DMAC_CHSR.ENAx must be polled and then it must be confirmed that the channel is disabled by reading back 0. The software may terminate all channels abruptly by clearing the global enable bit in the DMAC Configuration Register (DMAC_EN.ENABLE bit). Again, this does not mean that all channels are disabled immediately after the DMAC_EN.ENABLE is cleared over the APB slave interface. Consider this as a request to disable all channels. The DMAC_CHSR.ENABLE must be polled and then it must be confirmed that all channels are disabled by reading back 0. Note: If the channel enable bit is cleared while there is data in the channel FIFO, this data is not sent to the destination peripheral and is not present when the channel is re-enabled. For read sensitive source peripherals, such as a source FIFO, this data is therefore lost. When the source is not a read sensitive device (i.e., memory), disabling a channel without waiting for the channel FIFO to empty may be acceptable as the data is available from the source peripheral upon request and is not lost. If a channel is disabled by software, an active single or chunk transaction is not guaranteed to receive an acknowledgement.
Note:
483
30.5
There must not be any write operation to Channel registers in an active channel after the channel enable is made HIGH. If any channel parameters must be reprogrammed, this can only be done after disabling the DMAC channel. You must program the DMAC_SADDRx and DMAC_DADDRx channel registers with a byte, half-word and word aligned address depending on the source width and destination width. After the software disables a channel by writing into the channel disable register, it must re-enable the channel only after it has polled a 0 in the corresponding channel enable status register. This is because the current AHB Burst must terminate properly. If you program the BTSIZE field in the DMAC_CTRLA as zero, and the DMAC has been defined as the flow controller, then the channel is automatically disabled. When hardware handshaking interface protocol is fully implemented, a peripheral is expected to deassert any sreq or breq signals on receiving the ack signal irrespective of the request the ack was asserted in response to. Multiple Transfers involving the same peripheral must not be programmed and enabled on different channels, unless this peripheral integrates several hardware handshaking interfaces. When a Peripheral has been defined as the flow controller, the targeted DMAC Channel must be enabled before the Peripheral. If you do not ensure this and the First DMAC request is also the last transfer, the DMAC Channel might miss a Last Transfer Flag. When the AUTO Field is set to TRUE, then the BTSIZE Field is automatically reloaded from its previous value. BTSIZE must be initialized to a non zero value if the first transfer is initiated with the AUTO field set to TRUE, even if LLI mode is enabled, because the LLI fetch operation will not update this field.
z z
z z z z
30.6
DMAC Global Configuration Register on page 486 DMAC Enable Register on page 487 DMAC Channel x [x = 0..7] Source Address Register on page 498 DMAC Channel x [x = 0..7] Destination Address Register on page 499 DMAC Channel x [x = 0..7] Descriptor Address Register on page 500 DMAC Channel x [x = 0..7] Control A Register on page 501 DMAC Channel x [x = 0..7] Control B Register on page 502 DMAC Channel x [x = 0..7] Configuration Register on page 505
484
30.7
Offset 0x000 0x004 0x008 0x00C 0x010 0x014 0x018 0x01C 0x020 0x024 0x028 0x02C 0x030 0x034 0x038
0x03C+ch_num*(0x28)+(0x0) 0x03C+ch_num*(0x28)+(0x4) 0x03C+ch_num*(0x28)+(0x8) 0x03C+ch_num*(0x28)+(0xC) 0x03C+ch_num*(0x28)+(0x10) 0x03C+ch_num*(0x28)+(0x14) 0x03C+ch_num*(0x28)+(0x18) 0x03C+ch_num*(0x28)+(0x1C) 0x03C+ch_num*(0x28)+(0x20) 0x03C+ch_num*(0x28)+(0x24) 0x1E4 0x1E8 0x01EC- 0x1FC
485
Note: Bit fields 0, 1, 2, 3, have a default value of 0. This should not be changed. This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register .
486
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register .
487
488
489
490
30.7.6 DMAC Error, Buffer Transfer and Chained Buffer Transfer Interrupt Enable Register
Name: Address: Access: Reset:
31 DICERR7 23 ERR7 15 CBTC7 7 BTC7
491
30.7.7 DMAC Error, Buffer Transfer and Chained Buffer Transfer Interrupt Disable Register
Name: Address: Access: Reset:
31 DICERR7 23 ERR7 15 CBTC7 7 BTC7
492
30.7.8 DMAC Error, Buffer Transfer and Chained Buffer Transfer Interrupt Mask Register
Name: Address: Access: Reset:
31 DICERR7 23 ERR7 15 CBTC7 7 BTC7
493
30.7.9 DMAC Error, Buffer Transfer and Chained Buffer Transfer Status Register
Name: Address: Access: Reset:
31 DICERR7 23 ERR7 15 CBTC7 7 BTC7
494
495
496
497
Access: Reset:
31
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register .
498
Access: Reset:
31
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register .
499
Access: Reset:
31
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register .
500
Access: Reset:
31 DONE 23 15
14
12
10
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register on page 509
501
DONE: Current Descriptor Stop Command and Transfer Completed Memory Indicator
0: The transfer is performed. 1: If SOD field of DMAC_CFG register is set to true, then the DMAC is automatically disabled when an LLI updates the content of this register. The DONE field is written back to memory at the end of the current descriptor transfer.
Address: 0xFFFFE64C (0)[0], 0xFFFFE674 (0)[1], 0xFFFFE69C (0)[2], 0xFFFFE6C4 (0)[3], 0xFFFFE6EC (0)[4], 0xFFFFE714 (0)[5], 0xFFFFE73C (0)[6], 0xFFFFE764 (0)[7], 0xFFFFE84C (1)[0], 0xFFFFE874 (1)[1], 0xFFFFE89C (1)[2], 0xFFFFE8C4 (1)[3], 0xFFFFE8EC (1)[4], 0xFFFFE914 (1)[5], 0xFFFFE93C (1)[6], 0xFFFFE964 (1)[7] Access: Reset:
31 AUTO 23 15 7
Read-write 0x00000000
30 IEN 22 FC 14 6 13 29 DST_INCR 21 20 DST_DSCR 12 DST_PIP 4 DIF 28 27 19 11 3 26 18 10 2 25 SRC_INCR 17 9 1 SIF 16 SRC_DSCR 8 SRC_PIP 0 24
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register .
502
503
504
Access: Reset:
31 23
18
16 SOD 8 SRC_REP 0
15 14 DST_PER_MSB 7 6
11 10 SRC_PER_MSB 3 2
This register can only be written if the WPEN bit is cleared in DMAC Write Protect Mode Register on page 509
505
AHB_PROT[1]
AHB_PROT[2]
506
Access: Reset:
31 23
20 19 SPIP_BOUNDARY 12 SPIP_HOLE 11
15
14
13
10
4 SPIP_HOLE
507
Access: Reset:
31 23
20 19 DPIP_BOUNDARY 12 DPIP_HOLE 11
15
14
13
10
4 DPIP_HOLE
508
DMAC Global Configuration Register on page 486 DMAC Enable Register on page 487 DMAC Channel x [x = 0..7] Source Address Register on page 498 DMAC Channel x [x = 0..7] Destination Address Register on page 499 DMAC Channel x [x = 0..7] Descriptor Address Register on page 500 DMAC Channel x [x = 0..7] Control A Register on page 501 DMAC Channel x [x = 0..7] Control B Register on page 502 DMAC Channel x [x = 0..7] Configuration Register on page 505 WPKEY: Write Protect KEY
Should be written at value 0x444D41 (DMA in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0.
509
510
31.
31.1
31.2
Embedded Characteristics
z z z z z z z z z z z z z z z z z z z z z z z z z z z
Dual AHB Master Interface Supports Single Scan Active TFT Display Supports 12-bit, 16-bit, 18-bit and 24-bit Output Mode through the Spatial Dithering Unit Asynchronous Output Mode Supported (at synthesis time) 1, 2, 4, 8 bits per pixel (palletized) 12, 16, 18, 19, 24, 25 and 32 bits per pixel (non palletized) Supports One Base Layer (background) Supports Two Overlay Layer Windows Supports One High End Overlay (HEO) Window Supports One Hardware Cursor, Fixed or Free Size Hardware Cursor Fixed Size on the following patterns: 32x32, 64x64 and 128x128 Little Endian Memory Organization Programmable Timing Engine, with Integer Clock Divider Programmable Polarity for Data, Line Synchro and Frame Synchro. Display Size up to 2048x2048 Color Lookup Table with up to 256 entries and Predefined 8-bit Alpha Programmable Negative and Positive Row Striding for all Layers Programmable Negative and Positive Pixel Striding for all Overlay1, Overlay2 and HEO layers High End Overlay supports 4:2:0 Planar Mode and Semiplanar Mode High End Overlay supports 4:2:2 Planar Mode, Semiplanar Mode and Packed High End Overlay includes Chroma Upsampling Unit Horizontal and Vertical Rescaling unit with Edge Interpolation and Independent Non Integer Ratio Hidden Layer Removal supported. Integrates Fully Programmable Color Space Conversion Overlay1, Overlay2 and High End Overlay Integrate Rotation Engine: 90, 180, 270 Blender Function Supports Arbitrary 8-bit Alpha Value and Chroma Keying DMA User interface uses Linked List Structure and Add-to-queue Structure
511
31.3
Block Diagram
SYSCTRL Unit
PP Layer
HCC Layer AHB Bus OVR2 Layer 64-bit Dual AHB Master Interface DEAG Unit CLUT
ROT CLUT
LCD_DAT[23:0] LCD_VSYNC
OVR1 Layer
HEO Layer
HEO : High End Overlay CUE : Chroma Upsampling Engine CSC : Color Space Conversion 2DSC : Two Dimension Scaler DEAG : DMA Engine Address Generation
HCC: Hardware Cursor Channel GAB : Global Alpha Blender LTE: LCD Timing Engine ROT : Hardware Rotation
512
31.4
Description Contrast control signal, using Pulse Width Modulation Horizontal Synchronization Pulse Vertical Synchronization Pulse LCD 24-bit data bus Data Enable Display Enable signal Pixel Clock
31.5
Product Dependencies
513
Table 31-1. I/O Lines LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDC LCDDAT18 LCDDAT18 LCDDAT19 LCDDAT19 LCDDAT20 LCDDAT20 LCDDAT21 LCDDAT21 LCDDAT22 LCDDAT22 LCDDAT23 LCDDAT23 LCDDEN LCDDISP LCDHSYNC LCDPCK LCDPWM LCDVSYNC PA18 PC12 PA19 PC11 PA20 PC10 PA21 PC15 PA22 PE27 PA23 PE28 PA29 PA25 PA27 PA28 PA24 PA26 A C A C A C A C A C A C A A A A A A
514
31.6
Functional Description
The LCD module integrates the following digital blocks:
z z z z z z z z z
DMA Engine Address Generation (DEAG). This block performs data prefetch and requests access to the AHB interface. Input Overlay FIFO stores the stream of pixels. Color Lookup Table (CLUT). These 256 RAM-based lookup table entries are selected when the color depth is set to 1, 2, 4 or 8 bpp. Chroma Upsampling Engine (CUE). This block is selected when the input image sampling format is YUV (YCbCr) 4:2:0 and converts it to higher quality 4:4:4 image. Color Space Conversion (CSC) changes the color spare from YUV to RGB. Two Dimension Scaler (2DSC) resizes the image. Global Alpha Blender (GAB) performs programmable 256 level alpha blending. Output FIFO stores the blended pixel prior to display. LCD Timing Engine provides a fully programmable HSYNC-VSYNC interface.
The DMA controller reads the image through the AHB master interface. The LCD controller engine formats the display data, then the GAB performs alpha blending if required, and writes the final pixel into the output FIFO. The programmable timing engine drives a valid pixel onto the LCD_DAT[23:0] display bus.
HSPW field VSPW field VFPW field VBPW field HFPW field HBPW field PPL field RPF field
The polarity of output signals is also programmable. 31.6.1.3 Timing Engine Power Up Software Operation The following sequence is used to enable the display: 1. 2. 3. 4. 5. Configure LCD timing parameters, signal polarity and clock period. Enable the Pixel Clock by writing one to the CLKEN field of the LCDC_LCDEN register. Poll CLKSTS field of the LCDC_LCDSR register to check that the clock is running. Enable Horizontal and Vertical Synchronization by writing one to the SYNCEN field of the LCDC_LCDEN register. Poll LCDSTS field of the LCDC_LCDSR register to check that the synchronization is up.
515
6. 7.
Enable the display power signal by writing one to the DISPEN field of the LCDC_LCDEN register. Poll DISPSTS field of the LCDC_LCDSR register to check that the power signal is activated.
The GUARDTIME field of the LCDC_LCDCFG5 register is used to configure the number of frames before the assertion of the DISP signal. 31.6.1.4 Timing Engine Power Down Software Operation The following sequence is used to disable the display: 1. 2. 3. 4. 5. Disable the DISP signal by writing DISPDIS field of the LCDC_LCDDIS register. Poll DISPSTS field of the LCDC_LCDSR register to verify that the DISP is no longer activated. Disable the HSYNC and VSYNC signals by writing one to SYNCDIS field of the LCDC_LCDDIS register. Poll LCDSTS field of the LCDC_LCDSR register to check that the synchronization is off. Disable the Pixel clock by writing one in the CLKDIS field of the LCDC_LCDDIS register.
DSCR.CHXADDR: Frame Buffer base address register DSCR.CHXCTRL: Transfer Control register. DSCR.CHXNEXT: Next Descriptor Address register.
Table 31-3. DMA Channel Descriptor Structure System Memory DSCR + 0x0 DSCR + 0x4 DSCR + 0x8 CTRL NEXT Structure Field for Channel CHX ADDR
31.6.2.2 Programming a DMA Channel 1. 2. 3. 4. 5. 6. Check the status of the channel by reading the CHXCHSR register. Write the channel descriptor (DSCR) structure in the system memory by writing DSCR.CHXADDR Frame base address, DSCR.CHXCTRL channel control and DSCR.CHXNEXT next descriptor location. If more than one descriptor is expected, the field DFETCH of DSCR.CHXCTRL is set to one to enable the descriptor fetch operation. Write the DSCR.CHXNEXT register with the address location of the descriptor structure and set DFETCH field of the DSCR.CHXCTRL register to one. Enable the relevant channel by writing one to the CHEN field of the CHXCHER register. An interrupt may be raised if unmasked when the descriptor has been loaded.
31.6.2.3 Disabling a DMA channel 1. 2. 3. 4. 5. Clearing the DFETCH bit in the DSCR.CHXCTRL field of the DSCR structure will disable the channel at the end of the frame. Setting the DSCR.CHXNEXT field of the DSCR structure will disable the channel at the end of the frame. Writing one to the CHDIS field of the CHXCHDR register will disable the channel at the end of the frame. Writing one to the CHRST field of the CHXCHDR register will disable the channel immediately. This may occur in the middle of the image. Polling CHSR field in the CHXCHSR register until the channel is successfully disabled.
516
31.6.2.4 DMA Dynamic Linking of a New Transfer Descriptor 1. 2. 3. 4. 5. Write the new descriptor structure in the system memory. Write the address of the new structure in the CHXHEAD register. Add the new structure to the queue of descriptors by writing one to the A2QEN field of the CHXCHER register. The new descriptor will be added to the queue on the next frame. An interrupt will be raised if unmasked, when the head descriptor structure has been loaded by the DMA channel.
31.6.2.5 DMA Interrupt Generation The DMA controller operation sets the following interrupt flags in the interrupt status register CHXISR:
z z z z
DMA field indicates that the DMA transfer is completed. DSCR field indicates that the descriptor structure is loaded in the DMA controller. ADD field indicates that a descriptor has been added to the descriptor queue. DONE field indicates that the channel transfer has terminated and the channel is automatically disabled.
31.6.2.6 DMA Address Alignment Requirements When programming the DSCR.CHXADDR field of the DSCR structure the following requirement must be met.
Table 31-4. DMA Address Alignment when CLUT Mode is Selected CLUT Mode 1 bpp 2 bpp 4 bpp 8 bpp 8 bits 8 bits 8 bits 8 bits DMA Address Alignment
Table 31-5. DMA Address Alignment when RGB Mode is Selected RGB Mode 12 bpp RGB 444 16 bpp ARGB 4444 16 bpp RGBA 4444 16 bpp RGB 565 16 bpp TRGB 1555 18 bpp RGB 666 18 bpp RGB 666 PACKED 19 bpp TRGB 1666 19 bpp TRGB 1666 24 bpp RGB 888 24 bpp RGB 888 PACKED 25 bpp TRGB 1888 32 bpp ARGB 8888 32 bpp RGBA 8888 16 bits 16 bits 16 bits 16 bits 16 bits 32 bits 8 bits 32 bits 8 bits 32 bits 8 bits 32 bits 32 bits 32 bits DMA Address Alignment
517
Table 31-6. DMA Address Alignment when YUV Mode is Selected YUV Mode 32 bpp AYCrCb 16 bpp YCrCb 4:2:2 16 bpp semiplanar YCrCb 4:2:2 CrCb 16 bits Y 8 bits 16 bpp planar YCrCb 4:2:2 Cr 8 bits Cb 8 bits Y 8 bits 12 bpp YCrCb 4:2:0 CrCb 16 bits Y 8 bits 12 bpp YCrCb 4:2:0 Cr 8 bits Cb 8 bits 32 bits 32 bits Y 8 bits DMA Address Alignment
LOCKDIS field: when set to one the AHB lock signal is not asserted when the PSTRIDE value is different from zero (rotation in progress). ROTDIS field: when set to one the Pixel Striding optimization is disabled. DLBO field: when set to one only defined burst lengths are performed when the DMA channel retrieves the data from the memory. BLEN field: defines the maximum burst length of the DMA channel. SIF field: defines the targeted DMA interface.
CLUTMODE field: selects one color lookup mode RGBMODE field: selects the RGB mode. YUVMODE field: selects the Luminance Chrominance mode.
XPOS: YPOS fields define the position of the overlay window. XSIZE: YSIZE fields define the size of the displayed window. XMEMSIZE: YMEMSIZE fields define the size of the image frame buffer. XSTRIDE: PSTRIDE fields define the line and pixel striding. XFACTOR: YFACTOR fields define the scaling ratio.
The position and size attributes are to be programmed to keep the window within the display area.
518
When the color lookup mode is enabled the following restrictions apply on the horizontal and vertical window size:
Table 31-7. Color Lookup Mode and Window Size CLUT MODE 1 bpp 2 bpp 4 bpp 8 bpp x-y Size Requirement multiple of 8 pixels multiple of 4 pixels multiple of 2 pixels free size
Pixel striding is disabled when CLUT mode is enabled. When YUV mode is enabled the following restrictions apply on the window size:
Table 31-8. YUV Mode and Window Size YUV MODE AYUV YUV 4:2:2 packed x-y Requirement, Scaling Turned Off Free size xsize is greater than 2 pixels x-y Requirement, Scaling Turned On x-y size is greater than 5 x-y size is greater than 5 x-y size is greater than 5 x-y size is greater than 5 x-y size is greater than 5 x-y size is greater than 5
YUV 4:2:2 semiplanar xsize is greater than 2 pixels YUV 4:2:2 planar xsize is greater than 2 pixels
YUV 4:2:0 semiplanar xsize is greater that 2 pixels YUV 4:2:0 planar xsize is greater than 2 pixels
In RGB mode, there is no restriction on the line length. 31.6.3.4 Overlay Blender Attributes When two or more video layers are used, alpha blending is performed to define the final image displayed. Each window has its own blending attributes.
z z z z z z z z z z z z
CRKEY Field: enables the chroma keying and match logic. INV Field: performs bit inversion at pixel level. ITER2BL Field: when set the iterated data path is selected. ITER Field. REVALPHA Field: uses the reverse alpha value. GAEN Field: enables the global alpha value in the data path. LAEN Field: enables the local alpha value from the pixel. OVR Field: when set the overlay is selected as an input of the blender. DMA Field: the DMA data path is activated. REP Field: enables the bit replication to fill the 24-bit internal data path. DSTKEY Field: when set, Destination keying is enabled. GA Field: defines the global alpha value.
31.6.3.5 Overlay Attributes Software Operation 1. 2. 3. When required, write the overlay attributes configuration registers. Set UPDATEEN field of the CHXCHER register. Poll UPDATESR field in the CHXCHSR, the update applies when that field is reset.
519
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
p3 p3 p2 p2 p2 p2 p2 p2 p2 p2 p2 p2 p1 p1 p1 p1 p1 p1 p1 p1 p1 p11 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 0
0x3
0x2
0x1
8 p4
0x0
7 6 p3 5 4 p2 3 2 p1 1 0 p0
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
p7
p6
p5
p4
p3
p2
p1
p0
0x3
0x2
0x1
8
0x0
7 6 5 4 3 p0 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 p3 p2 p1
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
G0[3:0]
B0[3:0]
520
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
G0[3:0]
B0[3:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
B0[3:0]
A0[3:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
G0[5:0]
B0[4:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
G0[4:0]
B0[4:0]
31.6.4.10 18 bpp Unpacked Memory Mapping with Transparency Bit, RGB 6:6:6
Table 31-18. 18 bpp Unpacked Memory Mapping, Little Endian Organization Mem addr
Bit Pixel 18 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 R0[5:0]
G0[5:0]
B0[5:0]
521
31.6.4.11 18 bpp Packed Memory Mapping with Transparency Bit, RGB 6:6:6
Table 31-19. 18 bpp Packed Memory Mapping, Little Endian Organization at Address 0x0, 0x1, 0x2, 0x3 Mem addr
Bit Pixel 18 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
G0[5:0]
B0[5:0]
Table 31-20. 18 bpp Packed Memory Mapping, Little Endian Organization at Address 0x4, 0x5, 0x6, 0x7 Mem addr
Bit Pixel 18 bpp
0x7
0x6
0x5
8
0x4
7 6 5 4 3 2 1 0
R1[5:2]
G1[5:2]
Table 31-21. 18 bpp Packed Memory Mapping, Little Endian Organization at Address 0x8, 0x9, 0xA, 0xB Mem addr
Bit Pixel 18 bpp
0xB
0xA
0x9
8
0x8
7 6 5 4 3 2 1 0
B3[3:0]
R2[5:4]
31.6.4.12 19 bpp Unpacked Memory Mapping with Transparency Bit, RGB 1:6:6:6
Table 31-22. 19 bpp Unpacked Memory Mapping, Little Endian Organization Mem addr
Bit Pixel 19 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 A0 R0[5:0]
G0[5:0]
B0[5:0]
31.6.4.13 19 bpp Packed Memory Mapping with Transparency Bit, ARGB 1:6:6:6
Table 31-23. 19 bpp Packed Memory Mapping, Little Endian Organization at Address 0x0, 0x1, 0x2, 0x3 Mem addr
Bit Pixel 19 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
G0[5:0]
B0[5:0]
Table 31-24. 19 bpp Packed Memory Mapping, Little Endian Organization at Address 0x4, 0x5, 0x6, 0x7 Mem addr
Bit Pixel 19 bpp
0x7
0x6
0x5
8
0x4
7 6 5 4 3 2 1 0
R1[5:2]
G1[5:2]
522
Table 31-25. 18 bpp Packed Memory Mapping, Little Endian Organization at Address 0x8, 0x9, 0xA, 0xB Mem addr
Bit Pixel 19 bpp
0xB
0xA
0x9
8
0x8
7 6 5 4 3 2 1 0
B3[3:0]
R2[5:4]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 R0[7:0] G0[7:0]
B0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
B0[7:0]
Table 31-28. 24 bpp Packed Memory Mapping, Little Endian Organization at Address 0x4, 0x5, 0x6, 0x7 Mem addr
Bit Pixel 24 bpp
0x7
0x6
0x5
8
0x4
7 6 5 4 3 2 1 0
G1[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 A0 R0[7:0] G0[7:0]
B0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
B0[7:0]
523
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
A0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Cr0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Y0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Cb0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Y0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Cr0[7:0]
524
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Y0[7:0]
Table 31-38. 4:2:2 Semiplanar Chrominance Memory Mapping, Little Endian Organization for Byte 0x0, 0x1, 0x2, 0x3 Mem addr
Bit Pixel 16 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Cr0[7:0]
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Y0[7:0]
Table 31-40. 4:2:2 Planar Mode Chrominance Memory Mapping, Little Endian Organization for Byte 0x0, 0x1, 0x2, 0x3 Mem addr
Bit Pixel 16 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
C0[7:0]
31.6.5.5 4:2:0 Planar Mode Frame Buffer Memory Mapping In Planar Mode, the three video components Y, Cr and Cb are split into 3 memory areas and stored in a raster-scan order. These three memory planes are contiguous and always aligned on a 32-bit boundary.
Table 31-41. 4:2:0 Planar Mode Luminance Memory Mapping, Little Endian Organization for Byte 0x0, 0x1, 0x2, 0x3 Mem addr
Bit Pixel 12 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Y0[7:0]
Table 31-42. 4:2:0 Planar Mode Luminance Memory Mapping, Little Endian Organization for Byte 0x4, 0x5, 0x6, 0x7 Mem addr
Bit Pixel 12 bpp
0x7
0x6
0x5
8
0x4
7 6 5 4 3 2 1 0
Y4[7:0]
525
Table 31-43. 4:2:0 Planar Mode Chrominance Memory Mapping, Little Endian Organization for Byte 0x0, 0x1, 0x2, 0x3 Mem addr
Bit Pixel 12 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
C0[7:0]
Table 31-44. 4:2:0 Planar Mode Chrominance Memory Mapping, Little Endian Organization for Byte 0x4, 0x5, 0x6, 0x7 Mem addr
Bit Pixel 12 bpp
0x7
0x6
0x5
8
0x4
7 6 5 4 3 2 1 0
C4[7:0]
0x7
0x6
0x5
8
0x4
7 6 5 4 3 2 1 0
Y0[7:0]
Table 31-46. 4:2:0 Semiplanar Mode Chrominance Memory Mapping, Little Endian Organization Mem addr
Bit Pixel 12 bpp
0x3
0x2
0x1
8
0x0
7 6 5 4 3 2 1 0
Cr0[7:0]
526
C[0,0]
C[x/2,0]
C[x,0]
C[0,y/2]
C[x/2,y/2]
C[x,y/2]
C[0,y]
C[x/2,y]
C[x,y]
527
C[0,0]
C[x/2,0]
C[x,0]
C[0,y/2]
C[x/2,y/2]
C[x,y/2]
C[0,y]
C[x/2,y]
C[x,y]
528
Figure 31-4. 4:2:2 Semiplanar and Planar Upsampling Algorithm - 90 or 270 Degree Rotation Activated
C[0,0]
C[x/2,0]
C[x,0]
C[0,y/2]
C[x/2,y/2]
C[x,y/2]
C[0,y]
C[x/2,y]
C[x,y]
529
C[0,0]
C[x/2,0]
C[x,0]
C[0,y/2]
C[x/2,y/2]
C[x,y/2]
C[0,y]
C[x/2,y]
C[x,y]
Y sample Cr Cb calculated at encoding time Cr Cb interpolated from 2 Chroma Component Cr Cb interpolated from 4 Chroma Component
x Cr [ 0, 0 ] + Cr [ 0, x ] -, 0 = --------------------------------------------------Chroma -2 2
530
31.6.6.1 Chrominance Upsampling Algorithm 1. Read line n from chrominance cache and interpolate [x/2,0] chrominance component filling the 1 x 2 kernel with line n. If the chrominance cache is empty, then fetch the first line from external memory and interpolate from the external memory. Duplicate the last chrominance at the end of line. Fetch line n+1 from external memory, write line n + 1 to chrominance cache, read line n from the chrominance cache. interpolate [0,y/2], [x/2,y/2] and [x, y/2] filling the 2x2 kernel with line n and n+1. Duplicate the last chrominance line to generate the last interpolated line. Repeat step 1 and step 2.
2.
3.
R CSCRY CSCRU CSCRV Y Yoff = G CSCGY CSCGU CSCGV Cb Cboff B CSCBY CSCBU CSCBV Cr Croff
Color space conversion coefficients are defined with the following equation:
8
1 - CSC ij = ----7 2
2 c9 +
cn
n=0
Color space conversion coefficients are defined with one sign bit, 2 integer bits and 7 fractional bits. The range of the CSCij coefficients is defined below with a step of 1/128.
4 CSC ij 3.9921875
Additionally a set scaling factor {Yoff, Cboff, Croff} can be applied.
531
Taking into account the linear phase condition and anticipating the filter length M, the desired frequency response is modified.
--- j M 2 H ( ) = Ie
vI
vD
hI
hD
532
This ideal filter is non-causal and cannot be realized. The unit sample response h(n) is infinite in duration and must be truncated depending on the expected length M of the filter. This truncation is equivalent to the multiplication of the impulse response by a window function w(n).
Table 31-47. Window Function for a Filter Length M Name of the Window Function Time Domain Sequence w(n) 1 2 nM ------------2 1 -----------------------------------M1 2 n4 n0.42 0.5 cos ------------+ 0.08 cos ------------M1 M1 2 n0.54 0.46 cos ------------M1 2 n0.5 0.5 cos ------------M1
Barlett
Blackman
Hamming
Hanning
The horizontal resampler includes an 8-phase 5-tap filter equivalent to a 40-tap FIR described in Figure 31-8. The vertical resampler includes an 8-phase 3-tap filter equivalent to a 24-tap FIR described in Figure 31-8.
Figure 31-7. Horizontal Resampler Filter Architecture
x(n)
Coefficient storage
coeff4
coeff3
coeff2
coeff1
coeff0
y(m)
-1
-1
Coefficient storage
coeff2
coeff1
coeff0
y(m)
533
31.6.9.2 Horizontal Scaler The XMEMSIZE field of the LCDC_HEOCFG4 register indicates the horizontal size minus one of the image in the system memory. The XSIZE field of the LCDC_HEOCFG3 register contains the horizontal size minus one of the window.The SCALEN field of the LCDC_HEOCFG13 register is set to one. The scaling factor is programmed in the XFACTOR field of the LCDC_HEOCFG13 register. Use the following algorithm to find the XFACTOR value.
XFACTOR 1 st = XFACTOR 1 st + 1 XFACTOR 1 st XSIZE + 256 XPHIDEF XMEMSIZE max = floor -------------------------------------------------------------------------------------------------------------- 2048
31.6.9.3 Vertical Scaler The YMEMSIZE field of the LCDC_HEOCFG4 register indicates the vertical size minus one of the image in the system memory. The YSIZE field of the LCDC_HEOCFG3 register contains the vertical size minus one of the window. The SCALEN field of the LCDC_HEOCFG13 register is set to one. The scaling factor is programmed in the YFACTOR field of the LCDC_HEOCFG13 register.
YFACTOR 1 st = YFACTOR 1 st + 1 YFACTOR 1 st YSIZE + 256 YPHIDEF YMEMSIZE max = floor ------------------------------------------------------------------------------------------------------------- 2048
The LCD module integrates a hardware cursor database. This layer features only a minimal set of color among 1, 2, 4 and 8 bpp palletized and 16 bpp to 32 bpp true color. The cursor size is limited to 128 x 128 pixels.
534
o0(x,y)
HEO
o1(x,y)
Overl ay1 OVR1
HEO height
HCC
OVR1 height
Base Image Video Prioritization Algorithm 1 : HCC > OVR1 > HEO > BASE
Base Image
HEO
Video Prioritization Algorithm 2 : HCC > HEO > OVR1 > BASE
535
31.6.11.2 Base Layer, with Window Overlay Optimization When the base layer is combined with at least one active overlay, the whole base layer frame is retrieved from the memory though it is not visible. A set of registers is used to disable the Base DMA when this condition is met. These registers are listed below:
z z z z z
LCDC_CFG5: DISCXPOS field discard area horizontal position LCDC_CFG5: DISCYPOS field discard area vertical position LCDC_CFG6: DISCXSIZE field discard area horizontal size LCDC_CFG6: DISCYSIZE field discard area vertical size LCDC_CFG4: DISCEN field discard area enable
536
Base height
{discxpos, discypos}
Overlay1
Discarded Area
discysize
Base Image
HEO Video
HEO height
Base Image
537
31.6.11.3 Overlay Blending The blending function requires two pixels (one iterated from the previous blending stage and one from the current overlay color) and a set of blending configuration parameters. These parameters define the color operation.
Figure 31-11. Alpha Blender Function
iter[n-1] la ovr
GA OVR From LAEN Shadow REVALPHA Registers ITER ITER2BL CRKEY INV DMA GAEN RGBKEY RGBMASK OVRDEF
blending function
iter[n]
"0"
0
"0"
0
MATCH LOGIC
0
Inverted INV
iter[n]
538
iter[n-1]
iter[n-1]
la
ovr
iter[n-1]
la
ovr
iter[n-1]
la
ovr
539
OVR1 25 %
HEO 75 %
540
31.6.11.6 Color Keying Color keying involves a method of bit-block image transfer (Blit). This entails blitting one image onto another where not all the pixels are copied. Blitting usually involves two bitmaps, a source bitmap and a destination bitmap. A raster operation (ROP) is performed to define whether the iterated color or the overlay color is to be visible or not.
Select the Overlay to Blit Set DSTKEY field to zero Activate Color Keying setting CRKEY field to 1 Program Color Key writing RKEY, GKEY and BKEY fields Program Color Mask writing RKEY, GKEY and BKEY fields
When the Mask register is set to zero, the comparison is disabled and the raster operation is activated.
Select the Overlay to Blit Set DSTKEY field to one Activate Color Keying setting CRKEY field to 1 Program Color Key writing RKEY, GKEY and BKEY fields Program Color Mask writing RKEY, GKEY and BKEY fields
When the Mask register is set to zero, the comparison is disabled and the raster operation is activated.
541
Y CSCYR CSCYG CSCYB R Yoff U = CSCUR CSCUG CSCUB G + Uoff V CSCVR CSCVG CSCUB B Voff
Table 31-48. CLUT Pixel Performance CLUT MODE 1 bpp 2 bpp 3 bpp 4 bpp Pixels/Cycle 64 32 16 8 ROTATION Not supported Not supported Not supported Not supported SCALING Supported Supported Supported Supported
RGB Mode 12 bpp 16 bpp 18 bpp 18 bpp RGB PACKED 19 bpp 19 bpp PACKED 24 bpp 24 bpp PACKED 25 bpp 32 bpp
Note:
542
Table 31-50. Single Stream for 0 Wait State Memory Pixels/Cycle Memory Burst Mode 2 4 1 Not Supported Rotation Peak Random Memory Access (pixels/cycle) Rotation Optimization 0.2 Not Supported Normal Mode SCALING Burst Mode or Rotation Optimization is Available Supported Supported
Note:
Table 31-51. Multiple Stream for 0 Wait State Memory Comp/cycle Memory Burst Mode 8 Y, 4 UV 8 Y, 8 U, 8 V 8 Y, 4 UV 8 Y, 8 U, 8 V Rotation Peak Random Memory Access (Pixels/cycle) Rotation Optimization 1 Y, 1 UV (2 streams) 1 Y, 1 U, 1 V (3 streams) 1 Y, 1 UV (2 streams) 1 Y, 1 U, 1 V (3 streams) Normal Mode 0.2 Y 0.2 UV (2 streams) SCALING Burst Mode or Rotation Optimization is Available Supported
YUV Mode 16 bpp 422 semiplanar 16 bpp 422 planar 12 bpp 4:2:0 semiplanar 12 bpp 4:2:0 planar
Note:
In order to provide more bandwidth, when multiple streams are used to transfer Y, UV, U or V components, two AHB interfaces are recommended or multiple AXI ID are required.
Table 31-52. YUV Planar Overall Performance 1 AHB Interface for 0 Wait State Memory Pix/cycle Memory Burst Mode 4 4 5.32 5.32 Rotation Peak Random Memory Access (Pixels/cycle) Rotation Optimization 0.66 0.5 0.8 0.66 0.132 0.1 0.16 0.132 Normal Mode SCALING Burst Mode or Rotation Optimization is Available Supported Supported Supported Supported
YUV Mode 16 bpp 422 semiplanar 16 bpp 422 planar 12 bpp 4:2:0 semiplanar 12 bpp 4:2:0 planar
In order to provide more bandwidth, when multiple streams are used to transfer Y, UV, U or V components, two AHB interfaces are recommended or multiple AXI ID are required.
543
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
LCD_BIAS_DEN
LCD_DAT[23:0]
HSW
VSW
VBP
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
LCD_BIAS_DEN
LCD_DAT[23:0]
HSW
HBP
PPL
HFP
HSW
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
LCD_BIAS_DEN
LCD_DAT[23:0]
PPL
HFP
HSW
VFP
544
LCD_VSYNC
LCD_HSYNC
VSW VSPHO = 0
VBP
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
VSW VSPHO = 0
VBP
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
VSW VSPHO = 0
VBP
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
VSW VSPHO = 0
VBP
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
HSW
VSW
VBP
HBP
545
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
VSW VSPHO = 1
VBP
HBP
LCD_PCLK
LCD_VSYNC
LCD_HSYNC
HSW
VSW
VBP
HBP
546
LCD_VSYNC
LCD_DISP
LCD_VSYNC
LCD_DISP
lcd display on
LCD_PCLK
LCD_VSYNC
LCD_DISP
LCD_VSYNC
LCD_DISP
547
Table 31-53. Active Mode Output with 24 bits Bus Interface Configuration Pin ID LCD_DAT[23] LCD_DAT[22] LCD_DAT[21] LCD_DAT[20] LCD_DAT[19] LCD_DAT[18] LCD_DAT[17] LCD_DAT[16] LCD_DAT[15] LCD_DAT[14] LCD_DAT[13] LCD_DAT[12] LCD_DAT[11] LCD_DAT[10] LCD_DAT[9] LCD_DAT[8] LCD_DAT[7] LCD_DAT[6] LCD_DAT[5] LCD_DAT[4] LCD_DAT[3] LCD_DAT[2] LCD_DAT[1] LCD_DAT[0] TFT 24 bits R[7] R[6] R[5] R[4] R[3] R[2] R[1] R[0] G[7] G[6] G[5] G[4] G[3] G[2] G[1] G[0] B[7] B[6] B[5] B[4] B[3] B[2] B[1] B[0] TFT 18 bits R[5] R[4] R[3] R[2] R[1] R[0] G[5] G[4] G[3] G[2] G[1] G[0] B[5] B[4] B[3] B[2] B[1] B[0] TFT 16 bits R[4] R[3] R[2] R[1] R[0] G[5] G[4] G[3] G[2] G[1] G[0] B[4] B[3] B[2] B[1] B[0] TFT 12 bits R[3] R[2] R[1] R[0] G[3] G[2] G[1] G[0] B[3] B[2] B[1] B[0]
548
31.7
0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028 0x0000002C 0x00000030 0x00000034 0x00000038 0x0000003C 0x00000040 0x00000044 0x00000048 0x0000004C 0x00000050 0x00000054 0x00000058 0x0000005C 0x00000060 0x00000064 0x00000068 0x0000006C 0x00000070 0x00000074 0x00000078 0x0000007C 0x00000080 0x00000084 0x88-0x13C 0x00000140 0x00000144 0x00000148
549
Table 31-54. Register Mapping (Continued) 0x0000014C 0x00000150 0x00000154 0x00000158 0x0000015C 0x00000160 0x00000164 0x00000168 0x0000016C 0x00000170 0x00000174 0x00000178 0x0000017C 0x00000180 0x00000184 0x00000188 0x0000018C 0x00000190 0x194-0x23C 0x00000240 0x00000244 0x00000248 0x0000024C 0x00000250 0x00000254 0x00000258 0x0000025C 0x00000260 0x00000264 0x00000268 0x0000026C 0x00000270 0x00000274 0x00000278 0x0000027C 0x00000280 0x00000284 0x00000288 0x0000028C 0x00000290 Overlay 1 Interrupt Enable Register Overlay 1 Interrupt Disable Register Overlay 1 Interrupt Mask Register Overlay 1 Interrupt Status Register Overlay 1 DMA Head Register Overlay 1 DMA Address Register Overlay1 DMA Control Register Overlay1 DMA Next Register Overlay 1 Configuration 0 Register Overlay 1 Configuration 1 Register Overlay 1 Configuration 2 Register Overlay 1 Configuration 3 Register Overlay 1 Configuration 4 Register Overlay 1 Configuration 5 Register Overlay 1 Configuration 6 Register Overlay 1 Configuration 7 Register Overlay 1 Configuration 8Register Overlay 1 Configuration 9 Register Reserved Overlay 2 Channel Enable Register Overlay 2 Channel Disable Register Overlay 2 Channel Status Register Overlay 2 Interrupt Enable Register Overlay 2 Interrupt Disable Register Overlay 2 Interrupt Mask Register Overlay 2 Interrupt status Register Overlay 2 DMA Head Register Overlay 2 DMA Address Register Overlay 2 DMA Control Register Overlay 2 DMA Next Register Overlay 2 Configuration 0 Register Overlay 2 Configuration 1 Register Overlay 2 Configuration 2 Register Overlay 2 Configuration 3 Register Overlay 2 Configuration 4 Register Overlay 2 Configuration 5 Register Overlay 2 Configuration 6 Register Overlay 2 Configuration 7 Register Overlay 2 Configuration 8 Register Overlay 2 Configuration 9 Register LCDC_OVR1IER LCDC_OVR1IDR LCDC_OVR1IMR LCDC_OVR1ISR LCDC_OVR1HEAD LCDC_OVR1ADDR LCDC_OVR1CTRL LCDC_OVR1NEXT LCDC_OVR1CFG0 LCDC_OVR1CFG1 LCDC_OVR1CFG2 LCDC_OVR1CFG3 LCDC_OVR1CFG4 LCDC_OVR1CFG5 LCDC_OVR1CFG6 LCDC_OVR1CFG7 LCDC_OVR1CFG8 LCDC_OVR1CFG9 LCDC_OVR2CHER LCDC_OVR2CHDR LCDC_OVR2CHSR LCDC_OVR2IER LCDC_OVR2IDR LCDC_OVR2IMR LCDC_OVR2ISR LCDC_OVR2HEAD LCDC_OVR2ADDR LCDC_OVR2CTRL LCDC_OVR2NEXT LCDC_OVR2CFG0 LCDC_OVR2CFG1 LCDC_OVR2CFG2 LCDC_OVR2CFG3 LCDC_OVR2CFG4 LCDC_OVR2CFG5 LCDC_OVR2CFG6 LCDC_OVR2CFG7 LCDC_OVR2CFG8 LCDC_OVR2CFG9 Write-only Write-only Read-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Write-only Write-only Read-only Write-only Write-only Read-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
550
Table 31-54. Register Mapping (Continued) 0x294-33C 0x00000340 0x00000344 0x00000348 0x0000034C 0x00000350 0x00000354 0x00000358 0x0000035C 0x00000360 0x00000364 0x00000368 0x0000036C 0x00000370 0x00000374 0x00000378 0x0000037C 0x00000380 0x00000384 0x00000388 0x0000038C 0x00000390 0x00000394 0x00000398 0x0000039C 0x000003A0 0x000003A4 0x000003A8 0x000003AC 0x000003B0 0x000003B4 0x000003B8 0x000003BC 0x000003C0 0x000003C4 0x000003C8 0x000003CC 0x000003D0 0x000003D4 0x000003D8 Reserved High-End Overlay Channel Enable Register High-End Overlay Channel Disable Register High-End Overlay Channel Status Register High-End Overlay Interrupt Enable Register High-End Overlay Interrupt Disable Register High-End Overlay Interrupt Mask Register High-End Overlay Interrupt Status Register High-End Overlay DMA Head Register High-End Overlay DMA Address Register High-End Overlay DMA Control Register High-End Overlay DMA Next Register High-End Overlay U DMA Head Register High-End Overlay U DMA Address Register High-End Overlay U DMA control Register High-End Overlay U DMA Next Register High-End Overlay V DMA Head Register High-End Overlay V DMA Address Register High-End Overlay V DMA control Register High-End Overlay VDMA Next Register High-End Overlay Configuration Register 0 High-End Overlay Configuration Register 1 High-End Overlay Configuration Register 2 High-End Overlay Configuration Register 3 High-End Overlay Configuration Register 4 High-End Overlay Configuration Register 5 High-End Overlay Configuration Register 6 High-End Overlay Configuration Register 7 High-End Overlay Configuration Register 8 High-End Overlay Configuration Register 9 High-End Overlay Configuration Register 10 High-End Overlay Configuration Register 11 High-End Overlay Configuration Register 12 High-End Overlay Configuration Register 13 High-End Overlay Configuration Register 14 High-End Overlay Configuration Register 15 High-End Overlay Configuration Register 16 High-End Overlay Configuration Register 17 High-End Overlay Configuration Register 18 High-End Overlay Configuration Register 19 LCDC_HEOCHER LCDC_HEOCHDR LCDC_HEOCHSR LCDC_HEOIER LCDC_HEOIDR LCDC_HEOIMR LCDC_HEOISR LCDC_HEOHEAD LCDC_HEOADDR LCDC_HEOCTRL LCDC_HEONEXT LCDC_HEOUHEAD LCDC_HEOUADDR LCDC_HEOUCTRL LCDC_HEOUNEXT LCDC_HEOVHEAD LCDC_HEOVADDR LCDC_HEOVCTRL LCDC_HEOVNEXT LCDC_HEOCFG0 LCDC_HEOCFG1 LCDC_HEOCFG2 LCDC_HEOCFG3 LCDC_HEOCFG4 LCDC_HEOCFG5 LCDC_HEOCFG6 LCDC_HEOCFG7 LCDC_HEOCFG8 LCDC_HEOCFG9 LCDC_HEOCFG10 LCDC_HEOCFG11 LCDC_HEOCFG12 LCDC_HEOCFG13 LCDC_HEOCFG14 LCDC_HEOCFG15 LCDC_HEOCFG16 LCDC_HEOCFG17 LCDC_HEOCFG18 LCDC_HEOCFG19 Write-only Write-only Read-only Write-only Write-only Read-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
551
Table 31-54. Register Mapping (Continued) 0x000003DC 0x000003E0 0x000003E4 0x000003E8 0x000003EC 0x000003F0 0x000003F4 0x000003F8 0x000003FC 0x00000400 0x00000404 0x00000408 0x0000040C 0x00000410 0x00000414 0x00000418 0x0000041C 0x00000420 0x00000424 0x00000428 0x0000042C 0x00000430 0x434-0x43C 0x00000440 0x00000444 0x00000448 0x0000044C 0x00000450 0x00000454 0x00000458 0x0000045C 0x00000460 0x00000464 0x00000468 0x0000046C 0x00000470 0x00000474 0x00000478 0x0000047C 0x00000480 High-End Overlay Configuration Register 20 High-End Overlay Configuration Register 21 High-End Overlay Configuration Register 22 High-End Overlay Configuration Register 23 High-End Overlay Configuration Register 24 High-End Overlay Configuration Register 25 High-End Overlay Configuration Register 26 High-End Overlay Configuration Register 27 High-End Overlay Configuration Register 28 High-End Overlay Configuration Register 29 High-End Overlay Configuration Register 30 High-End Overlay Configuration Register 31 High-End Overlay Configuration Register 32 High-End Overlay Configuration Register 33 High-End Overlay Configuration Register 34 High-End Overlay Configuration Register 35 High-End Overlay Configuration Register 36 High-End Overlay Configuration Register 37 High-End Overlay Configuration Register 38 High-End Overlay Configuration Register 39 High-End Overlay Configuration Register 40 High-End Overlay Configuration Register 41 Reserved Hardware Cursor Channel Enable Register Hardware Cursor Channel disable Register Hardware Cursor Channel Status Register Hardware Cursor Interrupt Enable Register Hardware Cursor Interrupt Disable Register Hardware Cursor Interrupt Mask Register Hardware Cursor Interrupt Status Register Hardware Cursor DMA Head Register Hardware cursor DMA Address Register Hardware Cursor DMA Control Register Hardware Cursor DMA NExt Register Hardware Cursor Configuration 0 Register Hardware Cursor Configuration 1 Register Hardware Cursor Configuration 2 Register Hardware Cursor Configuration 3 Register Hardware Cursor Configuration 4 Register Reserved LCDC_HEOCFG20 LCDC_HEOCFG21 LCDC_HEOCFG22 LCDC_HEOCFG23 LCDC_HEOCFG24 LCDC_HEOCFG25 LCDC_HEOCFG26 LCDC_HEOCFG27 LCDC_HEOCFG28 LCDC_HEOCFG29 LCDC_HEOCFG30 LCDC_HEOCFG31 LCDC_HEOCFG32 LCDC_HEOCFG33 LCDC_HEOCFG34 LCDC_HEOCFG35 LCDC_HEOCFG36 LCDC_HEOCFG37 LCDC_HEOCFG38 LCDC_HEOCFG39 LCDC_HEOCFG40 LCDC_HEOCFG41 LCDC_HCRCHER LCDC_HCRCHDR LCDC_HCRCHSR LCDC_HCRIER LCDC_HCRIDR LCDC_HCRIMR LCDC_HCRISR LCDC_HCRHEAD LCDC_HCRADDR LCDC_HCRCTRL LCDC_HCRNEXT LCDC_HCRCFG0 LCDC_HCRCFG1 LCDC_HCRCFG2 LCDC_HCRCFG3 LCDC_HCRCFG4 Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Write-only Write-only Read-only Write-only Write-only Read-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
552
Table 31-54. Register Mapping (Continued) 0x00000484 0x00000488 0x0000048C 0x00000490 0x494-0x53C 0x00000540 0x00000544 0x00000548 0x0000054C 0x00000550 0x00000554 0x00000558 0x0000055C 0x00000560 0x00000564 0x00000568 0x0000056C 0x00000570 0x00000574 0x00000578 0x0000057C 0x00000580 0x584-0x5FC 0x600 ... 0x8FC 0xA00 ... 0xDFC 0xE00 ... 0x11FC 0x1200 ... 0x15FC 0x1600 ... 0x19FC Hardware Cursor Configuration 6 Register Hardware Cursor Configuration 7 Register Hardware Cursor Configuration 8 Register Hardware Cursor Configuration 9 Register Reserved Post Processing Channel Enable Register Post Processing Channel Disable Register Post Processing Channel Status Register Post Processing Interrupt Enable Register Post Processing Interrupt Disable Register Post Processing Interrupt Mask Register Post Processing Interrupt Status Register Post Processing Head Register Post Processing Address Register Post Processing Control Register Post Processing Next Register Post Processing Configuration Register 0 Post Processing Configuration Register 1 Post Processing Configuration Register 2 Post Processing Configuration Register 3 Post Processing Configuration Register 4 Post Processing Configuration Register 5 Reserved Base CLUT Register 0 ... Base CLUT Register 255 Overlay 1 CLUT Register 0 ... Overlay 1 CLUT Register 255 Overlay 2 CLUT Register 0 ... Overlay 2 CLUT Register 255 High End Overlay CLUT Register 0 ... High End Overlay CLUT Register 255 Hardware Cursor CLUT Register 0 ... Hardware Cursor CLUT Register 255 LCDC_HCRCFG6 LCDC_HCRCFG7 LCDC_HCRCFG8 LCDC_HCRCFG9 LCDC_PPCHER LCDC_PPCHDR LCDC_PPCHSR LCDC_PPIER LCDC_PPIDR LCDC_PPIMR LCDC_PPISR LCDC_PPHEAD LCDC_PPADDR LCDC_PPCTRL LCDC_PPNEXT LCDC_PPCFG0 LCDC_PPCFG1 LCDC_PPCFG2 LCDC_PPCFG3 LCDC_PPCFG4 LCDC_PPCFG5 LCDC_BASECLUT0 ... LCDC_BASECLUT255 LCDC_OVR1CLUT0 ... LCDC_OVR1CLUT255 LCDC_OVR2CLUT0 ... LCDC_OVR2CLUT255 LCDC_HEOCLUT0 ... LCDC_HEOCLUT255 LCDC_HCRCLUT0 ... LCDC_HCRCLUT255 Read-write Read-write Read-write Read-write Write-only Write-only Read-only Write-only Write-only Read-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write ... Read-write Read-write ... Read-write Read-write ... Read-write Read-write ... Read-write Read-write ... Read-write 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 ... 0x00000000 0x00000000 ... 0x00000000 0x00000000 ... 0x00000000 0x00000000 ... 0x00000000 0x00000000 ... 0x00000000
0x1A00-0x1FE4 Reserved
Note:
553
CGDISHEO: Clock Gating Disable Control for the High End Overlay
0: Automatic Clock Gating is enabled for the High End Overlay Layer. 1: Clock is running continuously.
CGDISHCR: Clock Gating Disable Control for the Hardware Cursor Layer
0: Automatic Clock Gating is enabled for the Hardware Cursor Layer. 1: Clock is running continuously.
554
CGDISPP: Clock Gating Disable Control for the Post Processing Layer
0: Automatic Clock Gating is enabled for the Post Processing Layer. 1: Clock is running continuously.
555
556
557
558
559
560
561
PWMCVAL 4 3 PWMPOL
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
AHB_INCR4
AHB_INCR8
AHB_INCR16
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
AHB_BLEN_INCR4
AHB_BLEN_INCR8
AHB Access is started as soon as there is enough space in the FIFO to store a total amount of 16 data. AHB_BLEN_INCR16 An AHB INCR16 Burst is used. SINGLE, INCR, INCR4, INCR8 and INCR16 bursts are used. INCR is used for a burst of 2 and 3 beats.
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
AHB_INCR4
AHB_INCR8
AHB_INCR16
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
UDMA: End of DMA Transfer for U or UV Chrominance Component Interrupt Disable Register
0: No effect. 1: Interrupt source is disabled.
UADD: Head Descriptor Loaded for U or UV Chrominance Component Interrupt Disable Register
0: No effect. 1: Interrupt source is disabled.
639
VDMA: End of DMA Transfer for V Chrominance Component Interrupt Disable Register
0: No effect. 1: Interrupt source is disabled.
VADD: Head Descriptor Loaded for V Chrominance Component Interrupt Disable Register
0: No effect. 1: Interrupt source is disabled.
640
UDMA: End of DMA Transfer for U or UV Chrominance Component Interrupt Mask Register
0: Interrupt source is disabled. 1: Interrupt source is enabled.
641
VDMA: End of DMA Transfer for V Chrominance Component Interrupt Mask Register
0: Interrupt source is disabled. 1: Interrupt source is enabled.
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
AHB_BLEN_INCR4
AHB_BLEN_INCR8
AHB Access is started as soon as there is enough space in the FIFO to store a total amount of 16 data. AHB_BLEN_INCR16 An AHB INCR16 Burst is used. SINGLE, INCR, INCR4, INCR8 and INCR16 bursts are used. INCR is used for a burst of 2 and 3 beats.
AHB_INCR4
AHB_INCR8
AHB_INCR16
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
CSCRY: Color Space Conversion Y coefficient for Red Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
CSCRU: Color Space Conversion U coefficient for Red Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
CSCRV: Color Space Conversion V coefficient for Red Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
674
CSCGY: Color Space Conversion Y coefficient for Green Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
CSCGU: Color Space Conversion U coefficient for Green Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
CSCGV: Color Space Conversion V coefficient for Green Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
675
CSCBY: Color Space Conversion Y coefficient for Blue Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
CSCBU: Color Space Conversion U coefficient for Blue Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
CSCBV: Color Space Conversion V coefficient for Blue Component 1:2:7 format
Color Space Conversion coefficient format is 1 sign bit, 2 magnitude bits and 7 fractional bits.
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
AHB_BLEN_INCR4
AHB_BLEN_INCR8
AHB Access is started as soon as there is enough space in the FIFO to store a total amount of 16 data. AHB_BLEN_INCR16 An AHB INCR16 Burst is used. SINGLE, INCR, INCR4, INCR8 and INCR16 bursts are used. INCR is used for a burst of 2 and 3 beats.
713
714
715
716
717
BDEF: Blue Default Default Blue color when the Hardware Cursor DMA channel is disabled.
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
AHB_BLEN_INCR4
AHB_BLEN_INCR8
AHB Access is started as soon as there is enough space in the FIFO to store a total amount of 16 data. AHB_BLEN_INCR16 An AHB INCR16 Burst is used. SINGLE, INCR, INCR4, INCR8 and INCR16 bursts are used. INCR is used for a burst of 2 and 3 beats.
734
735
736
CSCYR: Color Space Conversion R coefficient for Luminance component, signed format, step set to 1/1024
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
CSCYG: Color Space Conversion G coefficient for Luminance component, signed format, step set to 1/512
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
CSCYB: Color Space Conversion B coefficient for Luminance component, signed format, step set to 1/1024
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
737
CSCUR: Color Space Conversion R coefficient for Chrominance B component, signed format. (step 1/1024)
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
CSCUG: Color Space Conversion G coefficient for Chrominance B component, signed format. (step 1/512)
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
CSCUB: Color Space Conversion B coefficient for Chrominance B component, signed format. (step 1/512)
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
738
CSCVR: Color Space Conversion R coefficient for Chrominance R component, signed format. (step 1/1024)
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
CSCVG: Color Space Conversion G coefficient for Chrominance R component, signed format. (step 1/512)
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
CSCVB: Color Space Conversion B coefficient for Chrominance R component, signed format. (step 1/1024)
Color Space Conversion coefficient format is 1 sign bit, 9 fractional bits.
739
740
741
742
743
744
32.
32.1
32.2
Embedded Characteristics
z z z z z z z z
1 Device High Speed 1 UTMI transceiver shared between Host and Device USB v2.0 High Speed Compliant, 480 Mbits Per Second 16 Endpoints up to 1024 bytes Embedded Dual-port RAM for Endpoints Suspend/Resume Logic (Command of UTMI) Up to Three Memory Banks for Endpoints (Not for Control Endpoint) 8 Kbytes of DPRAM
745
32.3
Block Diagram
APB bus
DHSDP DHSDM
AHB bus
USB2.0 CORE
UTMI
DFSDP DFSDM
DP DM
AHB bus
EPT Alloc
32 bits
DPRAM
16/8 bits
746
32.4
Typical Connection
Figure 32-2. Board Schematic
DHSDM/DFSDM
15k 22k
(1)
(1)
CRPB:1F to 10F
Note:
The values shown on the 22 k and 15 k resistors are only valid with 3V3 supplied PIOs.
747
32.5
Product Dependencies
32.5.2 Interrupt
The UDPHS interrupt line is connected on one of the internal sources of the Interrupt Controller. Using the UDPHS
Table 32-1. Peripheral IDs Instance UDPHS ID 33
748
32.6
Functional Description
EN_UDPHS 0 Others Ports HS USB Host HS EHCI FS OHCI DMA PA HS USB Device DMA 1
Control Transfers: Used to configure a device at attach time and can be used for other device-specific purposes, including control of other pipes on the device. Bulk Data Transfers: Generated or consumed in relatively large burst quantities and have wide dynamic latitude in transmission constraints. Interrupt Data Transfers: Used for timely but reliable delivery of data, for example, characters or coordinates with human-perceptible echo or feedback response characteristics. Isochronous Data Transfers: Occupy a prenegotiated amount of USB bandwidth with a prenegotiated delivery latency. (Also called streaming real time transfers.)
As indicated below, transfers are sequential events carried out on the USB bus. Endpoints must be configured according to the transfer type they handle.
Table 32-2. USB Communication Flow Transfer Control Isochronous Interrupt Bulk Direction Bidirectional Unidirectional Unidirectional Unidirectional Bandwidth Not guaranteed Guaranteed Not guaranteed Not guaranteed Endpoint Size 8, 16, 32, 64 8-1024 8-1024 8-512 Error Detection Yes Yes Yes Yes Retrying Automatic No Yes Yes
749
Data IN transaction Data IN transaction Data IN transaction Data IN transaction Data IN transaction Data IN transaction Data OUT transaction Data OUT transaction Data OUT transaction Data OUT transaction Data OUT transactionData OUT transaction
Notes: 1. Control transfer must use endpoints with one bank and can be aborted using a stall handshake. 2. Isochronous transfers must use endpoints configured with two or three banks. An endpoint handles all transactions related to the type of transfer for which it has been configured.
Table 32-4. UDPHS Endpoint Description Endpoint # Mnemonic 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 EPT_0 EPT_1 EPT_2 EPT_3 EPT_4 EPT_5 EPT_6 EPT_7 EPT_8 EPT_9 EPT_10 EPT_11 EPT_12 EPT_13 EPT_14 EPT_15 Nb Bank 1 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 DMA N Y Y Y Y Y Y Y N N N N N N N N High Band Width N Y Y N N N N N N N N N N N N N Max. Endpoint Size 64 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 Endpoint Type Control Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt Ctrl/Bulk/Iso(32.3)/Interrupt
Note:
1. In Isochronous Mode (Iso), it is preferable that High Band Width capability is available. The size of internal DPRAM is 8 KB. Suspend and resume are automatically detected by the UDPHS device, which notifies the processor by raising an interrupt.
750
Setup Stage
Data Stage
Status Stage
Control Write
Setup TX
Data OUT TX
Data OUT TX
Status IN TX
Setup Stage
Data Stage
Status Stage
Control Read
Setup TX
Data IN TX
Data IN TX
Status OUT TX
Setup Stage
Status Stage
No Data Control
Setup TX
Status IN TX
Fill the configuration register (UDPHS_EPTCFG) with the endpoint size, direction (IN or OUT), type (CTRL, Bulk, IT, ISO) and the number of banks. Fill the number of transactions (NB_TRANS) for isochronous endpoints. Verify that the EPT_MAPD flag is set. This flag is set if the endpoint size and the number of banks are correct compared to the FIFO maximum capacity and the maximum number of allowed banks. Configure control flags of the endpoint and enable it in UDPHS_EPTCTLENBx according to UDPHS Endpoint Control Disable Register (Isochronous Endpoint) on page 791.
Control endpoints can generate interrupts and use only 1 bank. All endpoints (except endpoint 0) can be configured either as Bulk, Interrupt or Isochronous. See Table 32-4. UDPHS Endpoint Description.
751
The maximum packet size they can accept corresponds to the maximum endpoint size. Note: The endpoint size of 1024 is reserved for isochronous endpoints. The size of the DPRAM is 8 KB. The DPR is shared by all active endpoints. The memory size required by the active endpoints must not exceed the size of the DPRAM. SIZE_DPRAM = SIZE _EPT0 + NB_BANK_EPT1 x SIZE_EPT1 + NB_BANK_EPT2 x SIZE_EPT2 + NB_BANK_EPT3 x SIZE_EPT3 + NB_BANK_EPT4 x SIZE_EPT4 + NB_BANK_EPT5 x SIZE_EPT5 + NB_BANK_EPT6 x SIZE_EPT6 +... (refer to 32.7.8 UDPHS Endpoint Configuration Register) If a user tries to configure endpoints with a size the sum of which is greater than the DPRAM, then the EPT_MAPD is not set. The application has access to the physical block of DPR reserved for the endpoint through a 64 KB logical address space. The physical block of DPR allocated for the endpoint is remapped all along the 64 KB logical address space. The application can write a 64 KB buffer linearly.
Figure 32-5. Logical Address Space for DPR Access
DPR 8 to 64 B Logical address 8 to 64 B 64 KB EP0 8 to1024 B 64 KB 8 to1024 B 8 to1024 B EP1 ... 64 KB EP2 64 KB EP3 ... 8 to1024 B x banks 1 bank
8 to1024 B
y banks
z banks 8 to1024 B
752
Configuration examples of UDPHS_EPTCTLx (UDPHS Endpoint Control Disable Register (Isochronous Endpoint)) for Bulk IN endpoint type follow below.
z
With DMA
z z
AUTO_VALID: Automatically validate the packet and switch to the next bank. EPT_ENABL: Enable endpoint. TXRDY: An interrupt is generated after each transmission. EPT_ENABL: Enable endpoint.
Without DMA:
z z
With DMA
z z
AUTO_VALID: Automatically validate the packet and switch to the next bank. EPT_ENABL: Enable endpoint. RXRDY_TXKL: An interrupt is sent after a new packet has been stored in the endpoint FIFO. EPT_ENABL: Enable endpoint.
Without DMA
z z
The Endpoint Banks (UDPHS_EPTCFGx.BK_NUMBER), The Endpoint Size (UDPHS_EPTCFGx.EPT_SIZE), The Endpoint Direction (UDPHS_EPTCFGx.EPT_DIR), and The Endpoint Type (UDPHS_EPTCFGx.EPT_TYPE).
To free its memory, the user shall write a zero to the UDPHS_EPTCFGx.BK_NUMBER field. The x+1 endpoint memory window then slides down and its data is lost. Note that the following endpoint memory windows (from x+2) do not slide. Figure 32-6 on page 754 illustrates the allocation and reorganization of the DPRAM in a typical example.
753
EPT5
EPT5
EPT5
EPT4 EPT3
EPT2
EPT2
EPT2
EPT1
EPT1
EPT1
EPT1
EPT0 Device:
EPT0 Device:
EPT0
Endpoint 3 Disabled
Endpoint 3 Activated
1. 2. 3. 4.
The endpoints 0 to 5 are enabled, configured and allocated in ascending order. Each endpoint then owns a memory area in the DPRAM. The endpoint 3 is disabled, but its memory is kept allocated by the controller. In order to free its memory, its UDPHS_EPTCFGx.BK_NUMBER field is written to zero. The endpoint 4 memory window slides down, but the endpoint 5 does not move. If the user chooses to reconfigure the endpoint 3 with a larger size, the controller allocates a memory area after the endpoint 2 memory area and automatically slides up the endpoint 4 memory window. The endpoint 5 does not move and a memory conflict appears as the memory windows of the endpoints 4 and 5 overlap. The data of these endpoints is potentially lost. There is no way the data of the endpoint 0 can be lost (except if it is de-allocated) as the memory allocation and de-allocation may affect only higher endpoints. Deactivating then reactivating the same endpoint with the same configuration only modifies temporarily the controller DPRAM pointer and size for this endpoint. Nothing changes in the DPRAM, higher endpoints seem not to have been moved and their data is preserved as far as nothing has been written or received into them while changing the allocation state of the first endpoint. When the user writes a value different from zero to the UDPHS_EPTCFGx.BK_NUMBER field, the Endpoint Mapped bit (UDPHS_EPTCFGx.EPT_MAPD) is set only if the configured size and number of banks are correct as compared to the endpoint maximal allowed values and to the maximal FIFO size (i.e. the DPRAM size). The UDPHS_EPTCFGx.EPT_MAPD value does not consider memory allocation conflicts.
Notes: 1. 2.
3.
754
The USB 2.0 device average throughput may be up to nearly 60 MBytes. Its internal slave average access latency decreases as burst length increases due to the 0 wait-state side effect of unchanged endpoints. If at least 0 wait-state word burst capability is also provided by the external DMA AHB bus slaves, each of both DMA AHB busses need less than 50% bandwidth allocation for full USB 2.0 bandwidth usage at 30 MHz, and less than 25% at 60 MHz. The UDPHS DMA Channel Transfer Descriptor is described in UDPHS DMA Channel Transfer Descriptor on page 810. Note: In case of debug, be careful to address the DMA to an SRAM address even if a remap is done.
755
The UDPHS device automatically acknowledges the setup packet (sends an ACK response) Payload data is written in the endpoint Sets the RX_SETUP interrupt The BYTE_COUNT field in the UDPHS_EPTSTAx register is updated
An endpoint interrupt is generated while RX_SETUP in the UDPHS_EPTSTAx register is not cleared. This interrupt is carried out to the microcontroller if interrupts are enabled for this endpoint. Thus, firmware must detect RX_SETUP polling UDPHS_EPTSTAx or catching an interrupt, read the setup packet in the FIFO, then clear the RX_SETUP bit in the UDPHS_EPTCLRSTA register to acknowledge the setup stage. If STALL_SNT was set to 1, then this bit is automatically reset when a setup token is detected by the device. Then, the device still accepts the setup stage. (See Section 32.6.10.15 STALL on page 766).
756
32.6.10.2 NYET NYET is a High Speed only handshake. It is returned by a High Speed endpoint as part of the PING protocol. High Speed devices must support an improved NAK mechanism for Bulk OUT and control endpoints (except setup stage). This mechanism allows the device to tell the host whether it has sufficient endpoint space for the next OUT transfer (see USB 2.0 spec 8.5.1 NAK Limiting via Ping Flow Control). The NYET/ACK response to a High Speed Bulk OUT transfer and the PING response are automatically handled by hardware in the UDPHS_EPTCTLx register (except when the user wants to force a NAK response by using the NYET_DIS bit). If the endpoint responds instead to the OUT/DATA transaction with an NYET handshake, this means that the endpoint accepted the data but does not have room for another data payload. The host controller must return to using a PING token until the endpoint indicates it has space available.
Figure 32-8. NYET Example with Two Endpoint Banks
data 0 ACK
data 1 NYET
PING
ACK
data 0 NYET
PING
NACK
PING
ACK
t=0
t = 125 s
t = 250 s
t = 375 s
t = 500 s
t = 625 s
Bank 1 E Bank 0 F
Bank 1 F Bank 0 E
Bank 1 F Bank 0 F
Bank 1 E Bank 0 F
32.6.10.3 Data IN 32.6.10.4 Bulk IN or Interrupt IN Data IN packets are sent by the device during the data or the status stage of a control transfer or during an (interrupt/bulk/isochronous) IN transfer. Data buffers are sent packet by packet under the control of the application or under the control of the DMA channel. There are three ways for an application to transfer a buffer in several packets over the USB:
z z z
32.6.10.5 Bulk IN or Interrupt IN: Sending a Packet Under Application Control (Device to Host) The application can write one or several banks. A simple algorithm can be used by the application to send packets regardless of the number of banks associated to the endpoint. Algorithm Description for Each Packet:
z z z
The application waits for TXRDY flag to be cleared in the UDPHS_EPTSTAx register before it can perform a write access to the DPR. The application writes one USB packet of data in the DPR through the 64 KB endpoint logical memory window. The application sets TXRDY flag in the UDPHS_EPTSETSTAx register.
The application is notified that it is possible to write a new packet to the DPR by the TXRDY interrupt. This interrupt can be enabled or masked by setting the TXRDY bit in the UDPHS_EPTCTLENB/UDPHS_EPTCTLDIS register. Algorithm Description to Fill Several Packets: Using the previous algorithm, the application is interrupted for each packet. It is possible to reduce the application overhead by writing linearly several banks at the same time. The AUTO_VALID bit in the UDPHS_EPTCTLx must be set by writing the AUTO_VALID bit in the UDPHS_EPTCTLENBx register.
757
The auto-valid-bank mechanism allows the transfer of data (IN and OUT) without the intervention of the CPU. This means that bank validation (set TXRDY or clear the RXRDY_TXKL bit) is done by hardware.
z z z
The application checks the BUSY_BANK_STA field in the UDPHS_EPTSTAx register. The application must wait that at least one bank is free. The application writes a number of bytes inferior to the number of free DPR banks for the endpoint. Each time the application writes the last byte of a bank, the TXRDY signal is automatically set by the UDPHS. If the last packet is incomplete (i.e., the last byte of the bank has not been written) the application must set the TXRDY bit in the UDPHS_EPTSETSTAx register.
The application is notified that all banks are free, so that it is possible to write another burst of packets by the BUSY_BANK interrupt. This interrupt can be enabled or masked by setting the BUSY_BANK flag in the UDPHS_EPTCTLENB and UDPHS_EPTCTLDIS registers. This algorithm must not be used for isochronous transfer. In this case, the ping-pong mechanism does not operate. A Zero Length Packet can be sent by setting just the TXRDY flag in the UDPHS_EPTSETSTAx register. 32.6.10.6 Bulk IN or Interrupt IN: Sending a Buffer Using DMA (Device to Host) The UDPHS integrates a DMA host controller. This DMA controller can be used to transfer a buffer from the memory to the DPR or from the DPR to the processor memory under the UDPHS control. The DMA can be used for all transfer types except control transfer. Example DMA configuration: 1. 2. 3. Program UDPHS_DMAADDRESS x with the address of the buffer that should be transferred. Enable the interrupt of the DMA in UDPHS_IEN Program UDPHS_ DMACONTROLx:
z z
Size of buffer to send: size of the buffer to be sent to the host. END_B_EN: The endpoint can validate the packet (according to the values programmed in the AUTO_VALID and SHRT_PCKT fields of UDPHS_EPTCTLx.) (See UDPHS Endpoint Control Disable Register (Isochronous Endpoint) on page 791 and Figure 32-13. Autovalid with DMA) END_BUFFIT: generate an interrupt when the BUFF_COUNT in UDPHS_DMASTATUSx reaches 0. CHANN_ENB: Run and stop at end of buffer
z z
The auto-valid-bank mechanism allows the transfer of data (IN & OUT) without the intervention of the CPU. This means that bank validation (set TXRDY or clear the RXRDY_TXKL bit) is done by hardware. A transfer descriptor can be used. Instead of programming the register directly, a descriptor should be programmed and the address of this descriptor is then given to UDPHS_DMANXTDSC to be processed after setting the LDNXT_DSC field (Load Next Descriptor Now) in UDPHS_DMACONTROLx register. The structure that defines this transfer descriptor must be aligned. Each buffer to be transferred must be described by a DMA Transfer descriptor (see UDPHS DMA Channel Transfer Descriptor on page 810). Transfer descriptors are chained. Before executing transfer of the buffer, the UDPHS may fetch a new transfer descriptor from the memory address pointed by the UDPHS_DMANXTDSCx register. Once the transfer is complete, the transfer status is updated in the UDPHS_DMASTATUSx register. To chain a new transfer descriptor with the current DMA transfer, the DMA channel must be stopped. To do so, INTDIS_DMA and TXRDY may be set in the UDPHS_EPTCTLENBx register. It is also possible for the application to wait for the c omple tion of all trans fers. In t his ca se the LDNXT_DSC f ield in the las t trans fer desc ripto r UDPHS_DMACONTROLx register must be set to 0 and CHANN_ENB set to 1. Then the application can chain a new transfer descriptor. The INTDIS_DMA can be used to stop the current DMA transfer if an enabled interrupt is triggered. This can be used to stop DMA transfers in case of errors. The application can be notified at the end of any buffer transfer (ENB_BUFFIT bit in the UDPHS_DMACONTROLx register).
758
Token IN
Data IN 1
ACK
Token IN
NAK
Token IN
Data IN 2
ACK
Cleared by hardware
Cleared by firmware
FIFO Content
Data IN 1
Load in progress
Token IN
Data IN
ACK
Token IN
Data IN
ACK
Set by Firmware, Cleared by Hardware Data Payload Written switch to next bank in FIFO Bank 0 Virtual TXRDY bank 0 (UDPHS_EPTSTAx) Virtual TXRDY bank 1 (UDPHS_EPTSTAx)
Set by Firmware, Data Payload Written in FIFO Bank 1 Interrupt Pending Set by Hardware Interrupt Cleared by Firmware Set by Hardware
Written by Microcontroller
Written by Microcontroller
Written by Microcontroller
759
Figure 32-11. Data IN Followed By Status OUT Transfer at the End of a Control Transfer
Device Sends the Last Data Payload to Host USB Bus Packets Device Sends a Status OUT to Host ACK ACK
Token IN
Data IN
ACK
Token OUT
Token OUT
Interrupt Pending
RXRDY (UDPHS_EPTSTAx) Set by Hardware Cleared by Firmware TX_COMPLT (UDPHS_EPTSTAx) Set by Hardware Cleared by Firmware
Note:
Token OUT
Data OUT
ACK
Token IN
Data IN
ACK
Interrupt Pending RXRDY (UDPHS_EPTSTAx) Set by Hardware TXRDY (UDPHS_EPTSTAx) Set by Firmware Clear by Hardware
Cleared by Firmware
Note:
Before proceeding to the status stage, the software should determine that there is no risk of extra data from the host (data stage). If not certain (non-predictable data stage length), then the software should wait for a NAK-IN interrupt before proceeding to the status stage. This precaution should be taken to avoid collision in the FIFO.
760
Write
write bank 0
bank 0 is full
Bank 1
Bank (usb)
Bank 0
Bank 1
Bank 0
Bank 1
Note:
In the illustration above Autovalid validates a bank as full, although this might not be the case, in order to continue processing data and to send to DMA.
32.6.10.7 Isochronous IN Isochronous-IN is used to transmit a stream of data whose timing is implied by the delivery rate. Isochronous transfer provides periodic, continuous communication between host and device. It guarantees bandwidth and low latencies appropriate for telephony, audio, video, etc. If the endpoint is not available (TXRDY_TRER = 0), then the device does not answer to the host. An ERR_FL_ISO interrupt is generated in the UDPHS_EPTSTAx register and once enabled, then sent to the CPU. The STALL_SNT command bit is not used for an ISO-IN endpoint. 32.6.10.8 High Bandwidth Isochronous Endpoint Handling: IN Example For high bandwidth isochronous endpoints, the DMA can be programmed with the number of transactions (BUFF_LENGTH field in UDPHS_DMACONTROLx) and the system should provide the required number of packets per microframe, otherwise, the host will notice a sequencing problem. A response should be made to the first token IN recognized inside a microframe under the following conditions:
z
If at least one bank has been validated, the correct DATAx corresponding to the programmed Number Of Transactions per Microframe (NB_TRANS) should be answered. In case of a subsequent missed or corrupted token IN inside the microframe, the USB 2.0 Core available data bank(s) that should normally have been transmitted during that microframe shall be flushed at its end. If this flush occurs, an error condition is flagged (ERR_FLUSH is set in UDPHS_EPTSTAx).
761
z z
If no bank is validated yet, the default DATA0 ZLP is answered and underflow is flagged (ERR_FL_ISO is set in UDPHS_EPTSTAx). Then, no data bank is flushed at microframe end. If no data bank has been validated at the time when a response should be made for the second transaction of NB_TRANS = 3 transactions microframe, a DATA1 ZLP is answered and underflow is flagged (ERR_FL_ISO is set in UDPHS_EPTSTAx). If and only if remaining untransmitted banks for that microframe are available at its end, they are flushed and an error condition is flagged (ERR_FLUSH is set in UDPHS_EPTSTAx). If no data bank has been validated at the time when a response should be made for the last programmed transaction of a microframe, a DATA0 ZLP is answered and underflow is flagged (ERR_FL_ISO is set in UDPHS_EPTSTAx). If and only if the remaining untransmitted data bank for that microframe is available at its end, it is flushed and an error condition is flagged (ERR_FLUSH is set in UDPHS_EPTSTAx). If at the end of a microframe no valid token IN has been recognized, no data bank is flushed and no error condition is reported.
At the end of a microframe in which at least one data bank has been transmitted, if less than NB_TRANS banks have been validated for that microframe, an error condition is flagged (ERR_TRANS is set in UDPHS_EPTSTAx). Cases of Error (in UDPHS_EPTSTAx)
z z
ERR_FL_ISO: There was no data to transmit inside a microframe, so a ZLP is answered by default. ERR_FLUSH: At least one packet has been sent inside the microframe, but the number of token IN received is lesser than the number of transactions actually validated (TXRDY_TRER) and likewise with the NB_TRANS programmed. ERR_TRANS: At least one packet has been sent inside the microframe, but the number of token IN received is lesser than the number of programmed NB_TRANS transactions and the packets not requested were not validated. ERR_FL_ISO + ERR_FLUSH: At least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token IN. ERR_FL_ISO + ERR_TRANS: At least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token IN and the data can be discarded at the microframe end. ERR_FLUSH + ERR_TRANS: The first token IN has been answered and it was the only one received, a second bank has been validated but not the third, whereas NB_TRANS was waiting for three transactions. ERR_FL_ISO + ERR_FLUSH + ERR_TRANS: The first token IN has been treated, the data for the second Token IN was not available in time, but the second bank has been validated before the end of the microframe. The third bank has not been validated, but three transactions have been set in NB_TRANS.
z z z z
32.6.10.9 Data OUT 32.6.10.10 Bulk OUT or Interrupt OUT Like data IN, data OUT packets are sent by the host during the data or the status stage of control transfer or during an interrupt/bulk/isochronous OUT transfer. Data buffers are sent packet by packet under the control of the application or under the control of the DMA channel. 32.6.10.11 Bulk OUT or Interrupt OUT: Receiving a Packet Under Application Control (Host to Device) Algorithm Description for Each Packet:
z z z z
The application enables an interrupt on RXRDY_TXKL. When an interrupt on RXRDY_TXKL is received, the application knows that UDPHS_EPTSTAx register BYTE_COUNT bytes have been received. The application reads the BYTE_COUNT bytes from the endpoint. The application clears RXRDY_TXKL. If the application does not know the size of the transfer, it may not be a good option to use AUTO_VALID. Because if a zero-length-packet is received, the RXRDY_TXKL is automatically cleared by the AUTO_VALID hardware and if the endpoint interrupt is triggered, the software will not find its originating flag when reading the UDPHS_EPTSTAx register.
Note:
762
The application enables the interrupts of BUSY_BANK and AUTO_VALID. When a BUSY_BANK interrupt is received, the application knows that all banks available for the endpoint have been filled. Thus, the application can read all banks available.
If the application doesnt know the size of the receive buffer, instead of using the BUSY_BANK interrupt, the application must use RXRDY_TXKL. 32.6.10.12 Bulk OUT or Interrupt OUT: Sending a Buffer Using DMA (Host To Device) To use the DMA setting, the AUTO_VALID field is mandatory. See 32.6.10.6 Bulk IN or Interrupt IN: Sending a Buffer Using DMA (Device to Host) for more information. DMA Configuration Example: 1. 2. 3. First program UDPHS_DMAADDRESSx with the address of the buffer that should be transferred. Enable the interrupt of the DMA in UDPHS_IEN Program the DMA Channelx Control Register:
z z z z z
Size of buffer to be sent. END_B_EN: Can be used for OUT packet truncation (discarding of unbuffered packet data) at the end of DMA buffer. END_BUFFIT: Generate an interrupt when BUFF_COUNT in the UDPHS_DMASTATUSx register reaches 0. END_TR_EN: End of transfer enable, the UDPHS device can put an end to the current DMA transfer, in case of a short packet. END_TR_IT: End of transfer interrupt enable, an interrupt is sent after the last USB packet has been transferred by the DMA, if the USB transfer ended with a short packet. (Beneficial when the receive size is unknown.) CHANN_ENB: Run and stop at end of buffer.
For OUT transfer, the bank will be automatically cleared by hardware when the application has read all the bytes in the bank (the bank is empty). Notes: 1. 2. When a zero-length-packet is received, RXRDY_TXKL bit in UDPHS_EPTSTAx is cleared automatically by AUTO_VALID, and the application knows of the end of buffer by the presence of the END_TR_IT. If the host sends a zero-length packet, and the endpoint is free, then the device sends an ACK. No data is written in the endpoint, the RXRDY_TXKL interrupt is generated, and the BYTE_COUNT field in UDPHS_EPTSTAx is null.
763
Figure 32-14. Data OUT Transfer for Endpoint with One Bank
Host Sends Data Payload Microcontroller Transfers Data Host Sends the Next Data Payload Host Resends the Next Data Payload
Token OUT
Data OUT 1
ACK
Token OUT
Data OUT 2
NAK
Token OUT
Data OUT 2
ACK
RXRDY (UDPHS_EPTSTAx)
Interrupt Pending Set by Hardware Cleared by Firmware, Data Payload Written in FIFO Data OUT 2 Written by UDPHS Device
Figure 32-15. Data OUT Transfer for an Endpoint with Two Banks
Host sends first data payload Microcontroller reads Data 1 in bank 0, Host sends second data payload Microcontroller reads Data 2 in bank 1, Host sends third data payload
Token OUT
Data OUT 1
ACK
Token OUT
Data OUT 2
ACK
Token OUT
Data OUT 3
Interrupt pending Set by Hardware, Data payload written in FIFO endpoint bank 0 Set by Hardware Data Payload written in FIFO endpoint bank 1
Cleared by Firmware
Virtual RXRDY Bank 1 RXRDY = (virtual bank 0 | virtual bank 1) (UDPHS_EPTSTAx) FIFO (DPR) Bank 0 Data OUT 1 Write by UDPHS Device FIFO (DPR) Bank 1
MDATA0
MDATA1
DATA2
MDATA0
MDATA1
DATA2
t = 125 s RXRDY
USB line
Read Bank 1
Read Bank 2
Read Bank 3
Read Bank 1
764
USB 2.0 supports individual High Speed isochronous endpoints that require data rates up to 192 Mb/s (24 MB/s): 3x1024 data bytes per microframe. To support such a rate, two or three banks may be used to buffer the three consecutive data packets. The microcontroller (or the DMA) should be able to empty the banks very rapidly (at least 24 MB/s on average). NB_TRANS field in UDPHS_EPTCFGx register = Number Of Transactions per Microframe. If NB_TRANS > 1 then it is High Bandwidth. Example:
z
32.6.10.14 Isochronous Endpoint Handling: OUT Example The user can ascertain the bank status (free or busy), and the toggle sequencing of the data packet for each bank with the UDPHS_EPTSTAx register in the three bit fields as follows:
z z z
TOGGLESQ_STA: PID of the data stored in the current bank CURBK: Number of the bank currently being accessed by the microcontroller. BUSY_BANK_STA: Number of busy bank
This is particularly useful in case of a missing data packet. If the inter-packet delay between the OUT token and the Data is greater than the USB standard, then the ISO-OUT transaction is ignored. (Payload data is not written, no interrupt is generated to the CPU.) If there is a data CRC (Cyclic Redundancy Check) error, the payload is, none the less, written in the endpoint. The ERR_CRC_NTR flag is set in UDPHS_EPTSTAx register. If the endpoint is already full, the packet is not written in the DPRAM. The ERR_FL_ISO flag is set in UDPHS_EPTSTAx. If the payload data is greater than the maximum size of the endpoint, then the ERR_OVFLW flag is set. It is the task of the CPU to manage this error. The data packet is written in the endpoint (except the extra data). If the host sends a Zero Length Packet, and the endpoint is free, no data is written in the endpoint, the RXRDY_TXKL flag is set, and the BYTE_COUNT field in UDPHS_EPTSTAx register is null. The FRCESTALL command bit is unused for an isochonous endpoint. Otherwise, payload data is written in the endpoint, the RXRDY_TXKL interrupt is generated and the BYTE_COUNT in UDPHS_EPTSTAx register is updated.
765
32.6.10.15 STALL STALL is returned by a function in response to an IN token or after the data phase of an OUT or in response to a PING transaction. STALL indicates that a function is unable to transmit or receive data, or that a control pipe request is not supported.
z
OUT
To stall an endpoint, set the FRCESTALL bit in UDPHS_EPTSETSTAx register and after the STALL_SNT flag has been set, set the TOGGLE_SEG bit in the UDPHS_EPTCLRSTAx register.
z
IN
Token IN
Stall PID
FRCESTALL Set by Firmware Cleared by Firmware Interrupt Pending STALL_SNT Set by Hardware Cleared by Firmware
766
767
(UDPHS_EPTCTLENBx) SHRT_PCKT BUSY_BANK NAK_OUT NAK_IN/ERR_FLUSH STALL_SNT/ER_CRC_NTR EPT0 IT Sources RX_SETUP/ERR_FL_ISO TXRDY_TRER TX_COMPLT RXRDY_TXKL ERR_OVFLW MDATA_RX DATAX_RX EP mask EP sources (UDPHS_IEN) EPT_x EP sources EP mask (UDPHS_IEN) EPT_0 husb2dev interrupt
EPT1-6 IT Sources
(UDPHS_DMACONTROLx) EN_BUFFIT
DMA CH x
768
Attached
Hub Reset Hub or Configured Deconfigured Bus Inactive Powered Bus Activity Power Interruption Reset Bus Inactive Default Reset Address Assigned Bus Inactive Address Bus Activity Device Deconfigured Device Configured Bus Inactive Suspended Bus Activity Suspended Bus Activity Suspended Suspended
Configured
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 may not consume more than 500 A on the USB bus. While in Suspend Mode, the host may wake up a device by sending a resume signal (bus activity) or a USB device may send a wake-up request to the host, e.g., waking up a PC by moving a USB mouse. The wake-up feature is not mandatory for all devices and must be negotiated with the host.
769
32.6.14.2 Not Powered State Self powered devices can detect 5V VBUS using a PIO. When the device is not connected to a host, device power consumption can be reduced by the DETACH bit in UDPHS_CTRL. Disabling the transceiver is automatically done. HSDM, HSDP, FSDP and FSDP lines are tied to GND pull-downs integrated in the hub downstream ports. 32.6.14.3 Entering Attached State When no device is connected, the USB FSDP and FSDM signals are tied to GND by 15 K pull-downs integrated in the hub downstream ports. When a device is attached to an hub downstream port, the device connects a 1.5 K pull-up on FSDP. The USB bus line goes into IDLE state, FSDP is pulled-up by the device 1.5 K resistor to 3.3V and FSDM is pulled-down by the 15 K resistor to GND of the host. After pull-up connection, the device enters the powered state. The transceiver remains disabled until bus activity is detected. In case of low power consumption need, the device can be stopped. When the device detects the VBUS, the software must enable the USB transceiver by enabling the EN_UDPHS bit in UDPHS_CTRL register. The software can detach the pull-up by setting DETACH bit in UDPHS_CTRL register. 32.6.14.4 From Powered State to Default State (Reset) After its connection to a USB host, the USB device waits for an end-of-bus reset. The unmasked flag ENDRESET is set in the UDPHS_IEN register and an interrupt is triggered. Once the ENDRESET interrupt has been triggered, the device enters Default State. In this state, the UDPHS software must:
z
Enable the default endpoint, setting the EPT_ENABL flag in the UDPHS_EPTCTLENB[0] register and, optionally, enabling the interrupt for endpoint 0 by writing 1 in EPT_0 of the UDPHS_IEN register. The enumeration then begins by a control transfer. Configure the Interrupt Mask Register which has been reset by the USB reset detection Enable the transceiver.
z z
In this state, the EN_UDPHS bit in UDPHS_CTRL register must be enabled. 32.6.14.5 From Default State to Address State (Address Assigned) After a Set Address standard device request, the USB host peripheral enters the address state. Warning: before the device enters address state, it must achieve the Status IN transaction of the control transfer, i.e., the UDPHS device sets its new address once the TX_COMPLT flag in the UDPHS_EPTCTL[0] register has been received and cleared. To move to address state, the driver software sets the DEV_ADDR field and the FADDR_EN flag in the UDPHS_CTRL register. 32.6.14.6 From Address State to Configured State (Device Configured) Once a valid Set Configuration standard request has been received and acknowledged, the device enables endpoints corresponding to the current configuration. This is done by setting the BK_NUMBER, EPT_TYPE, EPT_DIR and EPT_SIZE fields in the UDPHS_EPTCFGx registers and enabling them by setting the EPT_ENABL flag in the UDPHS_EPTCTLENBx registers, and, optionally, enabling corresponding interrupts in the UDPHS_IEN register. 32.6.14.7 Entering Suspend State (Bus Activity) When a Suspend (no bus activity on the USB bus) is detected, the DET_SUSPD signal in the UDPHS_STA register is set. This triggers an interrupt if the corresponding bit is set in the UDPHS_IEN register. This flag is cleared by writing to the UDPHS_CLRINT register. Then the device enters Suspend Mode. In this state bus powered devices must drain less than 500 A from the 5V VBUS. As an example, the microcontroller switches to slow clock, disables the PLL and main oscillator, and goes into Idle Mode. It may also switch off other devices on the board. The UDPHS device peripheral clocks can be switched off. Resume event is asynchronously detected.
770
32.6.14.8 Receiving a Host Resume In Suspend mode, a resume event on the USB bus line is detected asynchronously, transceiver and clocks disabled (however the pull-up should not be removed). Once the resume is detected on the bus, the signal WAKE_UP in the UDPHS_INTSTA is set. It may generate an interrupt if the corresponding bit in the UDPHS_IEN register is set. This interrupt may be used to wake-up the core, enable PLL and main oscillators and configure clocks. 32.6.14.9 Sending an External Resume In Suspend State it is possible to wake-up the host by sending an external resume. The device waits at least 5 ms after being entered in Suspend State before sending an external resume. The device must force a K state from 1 to 15 ms to resume the host.
32.6.15 Test Mode A device must support the TEST_MODE feature when in the Default, Address or Configured High Speed device states. TEST_MODE can be: z Test_J z Test_K z Test_Packet z Test_SEO_NAK
(See Section 32.7.7 UDPHS Test Register on page 781 for definitions of each test mode.) const char test_packet_buffer[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE, 0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, JJJJJJJKKKKKKK * 8 0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD, 0xFC,0x7E,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0x7E 10}, JK };
771
32.7
Offset
0x00 0x04
Access
Read-write Read-only Read-write Read-only Write-only Write-only Read-write Read-write Write-only Write-only Read-only Write-only Write-only Read-only
Reset
0x0000_0200 0x0000_0000 0x0000_0010 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000(1) 0x0000_0040
0x08 - 0x0C 0x10 0x14 0x18 0x1C 0x20 - 0xCC 0xE0 0xE4 - 0xE8 0x100 + endpoint * 0x20 + 0x00 0x100 + endpoint * 0x20 + 0x04 0x100 + endpoint * 0x20 + 0x08 0x100 + endpoint * 0x20 + 0x0C 0x100 + endpoint * 0x20 + 0x10 0x100 + endpoint * 0x20 + 0x14 0x100 + endpoint * 0x20 + 0x18 0x100 + endpoint * 0x20 + 0x1C 0x120 - 0x2FC 0x300 + channel * 0x10 + 0x00 0x300 + channel * 0x10 + 0x04 0x300 + channel * 0x10 + 0x08 0x300 + channel * 0x10 + 0x0C 0x310 - 0x36C
Registers
Notes: 1. The reset value for UDPHS_EPTCTL0 is 0x0000_0001. 2. The addresses for the UDPHS Endpoint registers shown here are for UDPHS Endpoint0. The structure of this group of registers is repeated successively for each endpoint according to the consecution of endpoint registers located between 0x120 and 0x2FC. 3. The DMA channel index refers to the corresponding EP number. When no DMA channel is assigned to one EP, the associated registers are reserved. This is the case for EP0, so DMA Channel 0 registers are reserved.
772
773
774
11 10 FRAME_NUMBER 3 2
5 FRAME_NUMBER
1 MICRO_FRAME_NUM
775
DET_SUSPD: Suspend Interrupt Enable 0 = Disable Suspend Interrupt. 1 = Enable Suspend Interrupt. MICRO_SOF: Micro-SOF Interrupt Enable 0 = Disable Micro-SOF Interrupt. 1 = Enable Micro-SOF Interrupt. INT_SOF: SOF Interrupt Enable 0 = Disable SOF Interrupt. 1 = Enable SOF Interrupt. ENDRESET: End Of Reset Interrupt Enable 0 = Disable End Of Reset Interrupt. 1 = Enable End Of Reset Interrupt. Automatically enabled after USB reset. WAKE_UP: Wake Up CPU Interrupt Enable 0 = Disable Wake Up CPU Interrupt. 1 = Enable Wake Up CPU Interrupt. ENDOFRSM: End Of Resume Interrupt Enable 0 = Disable Resume Interrupt. 1 = Enable Resume Interrupt. UPSTR_RES: Upstream Resume Interrupt Enable 0 = Disable Upstream Resume Interrupt. 1 = Enable Upstream Resume Interrupt. EPT_x: Endpoint x Interrupt Enable 0 = Disable the interrupts for this endpoint. 1 = Enable the interrupts for this endpoint. DMA_x: DMA Channel x Interrupt Enable 0 = Disable the interrupts for this channel. 1 = Enable the interrupts for this channel. SAMA5D3 Series [DATASHEET]
11121BATARM08-Mar-13
776
777
778
779
780
OPMODE2: OpMode2
0 = No effect. 1 = Set to force the OpMode signal (UTMI interface) to 10, to disable the bit-stuffing and the NRZI encoding. Note: For the Test mode, Test_SE0_NAK (see Universal Serial Bus Specification, Revision 2.0: 7.1.20, Test Mode Support). Force the device in High Speed mode, and configure a bulk-type endpoint. Do not fill this endpoint for sending NAK to the host.
781
Upon command, a ports transceiver must enter the High Speed receive mode and remain in that mode until the exit action is taken. This enables the testing of output impedance, low level output voltage and loading characteristics. In addition, while in this mode, upstream facing ports (and only upstream facing ports) must respond to any IN token packet with a NAK handshake (only if the packet CRC is determined to be correct) within the normal allowed device response time. This enables testing of the device squelch level circuitry and, additionally, provides a general purpose stimulus/response test for basic functional testing.
782
Access:
31 EPT_MAPD 23 15 7
Note:
783
Endpoint Type
Value 0 1 2 3 Name CTRL8 ISO BULK INT Description Control endpoint Isochronous endpoint Bulk endpoint Interrupt endpoint
The fifo max capacity (FIFO_MAX_SIZE in UDPHS_IPFEATURES register) The number of endpoints/banks already allocated The number of allowed banks for this endpoint
784
32.7.9 UDPHS Endpoint Control Enable Register (Control, Bulk, Interrupt Endpoints)
Name: Access:
31 SHRT_PCKT 23 15 NAK_OUT 7
This register view is relevant only if EPT_TYPE=0x0, 0x2 or 0x3 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Control Register (Control, Bulk, Interrupt Endpoints) on page 793.
NYET_DIS: NYET Disable (Only for High Speed Bulk OUT endpoints)
0 = No effect. 1 = Forces an ACK response to the next High Speed Bulk OUT transfer instead of a NYET response.
785
786
Access:
31 SHRT_PCKT 23 15
7 MDATA_RX
6 DATAX_RX
3 INTDIS_DMA
1 AUTO_VALID
0 EPT_ENABL
This register view is relevant only if EPT_TYPE=0x1 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Control Register (Isochronous Endpoint) on page 796.
DATAX_RX: DATAx Interrupt Enable (Only for high bandwidth Isochronous OUT endpoints)
0 = No effect. 1 = Enable DATAx Interrupt.
MDATA_RX: MDATA Interrupt Enable (Only for high bandwidth Isochronous OUT endpoints)
0 = No effect. 1 = Enable MDATA Interrupt.
787
788
32.7.11 UDPHS Endpoint Control Disable Register (Control, Bulk, Interrupt Endpoints)
Name: Address: UDPHS_EPTCTLDISx [x=0..15] 0xF8030108 [0], 0xF8030128 [1], 0xF8030148 [2], 0xF8030168 [3], 0xF8030188 [4], 0xF80301A8 [5], 0xF80301C8 [6], 0xF80301E8 [7], 0xF8030208 [8], 0xF8030228 [9], 0xF8030248 [10], 0xF8030268 [11], 0xF8030288 [12], 0xF80302A8 [13], 0xF80302C8 [14], 0xF80302E8 [15] Write-only
30 22 14 NAK_IN 6 29 21 13 STALL_SNT 5 28 20 12 RX_SETUP 4 NYET_DIS 27 19 11 TXRDY 3 INTDIS_DMA 26 18 BUSY_BANK 10 TX_COMPLT 2 25 17 9 RXRDY_TXKL 1 AUTO_VALID 24 16 8 ERR_OVFLW 0 EPT_DISABL
Access:
31 SHRT_PCKT 23 15 NAK_OUT 7
This register view is relevant only if EPT_TYPE=0x0, 0x2 or 0x3 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Control Register (Control, Bulk, Interrupt Endpoints) on page 793.
NYET_DIS: NYET Enable (Only for High Speed Bulk OUT endpoints)
0 = No effect. 1 = Let the hardware handle the handshake response for the High Speed Bulk OUT transfer.
789
790
Access:
31 SHRT_PCKT 23 15
7 MDATA_RX
6 DATAX_RX
3 INTDIS_DMA
1 AUTO_VALID
0 EPT_DISABL
This register view is relevant only if EPT_TYPE=0x1 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Control Register (Isochronous Endpoint) on page 796.
DATAX_RX: DATAx Interrupt Disable (Only for High Bandwidth Isochronous OUT endpoints)
0 = No effect. 1 = Disable DATAx Interrupt.
MDATA_RX: MDATA Interrupt Disable (Only for High Bandwidth Isochronous OUT endpoints)
0 = No effect. 1 = Disable MDATA Interrupt.
791
792
This register view is relevant only if EPT_TYPE=0x0, 0x2 or 0x3 in UDPHS Endpoint Configuration Register on page 783
For IN Transfer: If this bit is set, then the UDPHS_EPTSTAx register TXRDY bit is set automatically when the current bank is full and at the end of DMA buffer if the UDPHS_DMACONTROLx register END_B_EN bit is set. The user may still set the UDPHS_EPTSTAx register TXRDY bit if the current bank is not full, unless the user wants to send a Zero Length Packet by software. For OUT Transfer: If this bit is set, then the UDPHS_EPTSTAx register RXRDY_TXKL bit is automatically reset for the current bank when the last packet byte has been read from the bank FIFO or at the end of DMA buffer if the UDPHS_DMACONTROLx register END_B_EN bit is set. For example, to truncate a padded data packet when the actual data transfer size is reached. The user may still clear the UDPHS_EPTSTAx register RXRDY_TXKL bit, for example, after completing a DMA buffer by software if UDPHS_DMACONTROLx register END_B_EN bit was disabled or in order to cancel the read of the remaining data bank(s). INTDIS_DMA: Interrupt Disables DMA
If set, when an enabled endpoint-originated interrupt is triggered, the DMA request is disabled regardless of the UDPHS_IEN register EPT_x bit for this endpoint. Then, the firmware will have to clear or disable the interrupt source or clear this bit if transfer completion is needed. If the exception raised is associated with the new system bank packet, then the previous DMA packet transfer is normally completed, but the new DMA packet transfer is not started (not requested). If the exception raised is not associated to a new system bank packet (NAK_IN, NAK_OUT...), then the request cancellation may happen at any time and may immediately stop the current DMA transfer. This may be used, for example, to identify or prevent an erroneous packet to be transferred into a buffer or to complete a DMA buffer by software after reception of a short packet.
793
NYET_DIS: NYET Disable (Only for High Speed Bulk OUT endpoints)
0 = If cleared, this bit lets the hardware handle the handshake response for the High Speed Bulk OUT transfer. 1 = If set, this bit forces an ACK response to the next High Speed Bulk OUT transfer instead of a NYET response. Note: According to the Universal Serial Bus Specification, Rev 2.0 (8.5.1.1 NAK Responses to OUT/DATA During PING Protocol), a NAK response to an HS Bulk OUT transfer is expected to be an unusual occurrence.
Caution: Interrupt source is active as long as the corresponding UDPHS_EPTSTAx register TXRDY flag remains low. If there are no more banks available for transmitting after the software has set UDPHS_EPTSTAx/TXRDY for the last transmit packet, then the interrupt source remains inactive until the first bank becomes free again to transmit at UDPHS_EPTSTAx/TXRDY hardware clear. RX_SETUP: Received SETUP Interrupt Enabled
0 = Received SETUP is masked. 1 = Received SETUP is enabled.
For OUT endpoints: an interrupt is sent when all banks are busy. For IN endpoints: an interrupt is sent when all banks are free. SAMA5D3 Series [DATASHEET]
11121BATARM08-Mar-13
794
SHRT_PCKT: Short Packet Interrupt Enabled For OUT endpoints: send an Interrupt when a Short Packet has been received. 0 = Short Packet Interrupt is masked. 1 = Short Packet Interrupt is enabled. For IN endpoints: a Short Packet transmission is guaranteed upon end of the DMA Transfer, thus signaling a BULK or INTERRUPT end of transfer, but only if the UDPHS_DMACONTROLx register END_B_EN and UDPHS_EPTCTLx register AUTO_VALID bits are also set.
795
Access:
31 SHRT_PCKT 23 15
7 MDATA_RX
6 DATAX_RX
3 INTDIS_DMA
1 AUTO_VALID
0 EPT_ENABL
This register view is relevant only if EPT_TYPE=0x1 in UDPHS Endpoint Configuration Register on page 783
For IN Transfer: If this bit is set, then the UDPHS_EPTSTAx register TXRDY_TRER bit is set automatically when the current bank is full and at the end of DMA buffer if the UDPHS_DMACONTROLx register END_B_EN bit is set. The user may still set the UDPHS_EPTSTAx register TXRDY_TRER bit if the current bank is not full, unless the user wants to send a Zero Length Packet by software. For OUT Transfer: If this bit is set, then the UDPHS_EPTSTAx register RXRDY_TXKL bit is automatically reset for the current bank when the last packet byte has been read from the bank FIFO or at the end of DMA buffer if the UDPHS_DMACONTROLx register END_B_EN bit is set. For example, to truncate a padded data packet when the actual data transfer size is reached. The user may still clear the UDPHS_EPTSTAx register RXRDY_TXKL bit, for example, after completing a DMA buffer by software if UDPHS_DMACONTROLx register END_B_EN bit was disabled or in order to cancel the read of the remaining data bank(s). INTDIS_DMA: Interrupt Disables DMA
If set, when an enabled endpoint-originated interrupt is triggered, the DMA request is disabled regardless of the UDPHS_IEN register EPT_x bit for this endpoint. Then, the firmware will have to clear or disable the interrupt source or clear this bit if transfer completion is needed.
796
If the exception raised is associated with the new system bank packet, then the previous DMA packet transfer is normally completed, but the new DMA packet transfer is not started (not requested). If the exception raised is not associated to a new system bank packet (ex: ERR_FL_ISO), then the request cancellation may happen at any time and may immediately stop the current DMA transfer. This may be used, for example, to identify or prevent an erroneous packet to be transferred into a buffer or to complete a DMA buffer by software after reception of a short packet, or to perform buffer truncation on ERR_FL_ISO interrupt for adaptive rate.
DATAX_RX: DATAx Interrupt Enabled (Only for High Bandwidth Isochronous OUT endpoints)
0 = No effect. 1 = Send an interrupt when a DATA2, DATA1 or DATA0 packet has been received meaning the whole microframe data payload has been received.
MDATA_RX: MDATA Interrupt Enabled (Only for High Bandwidth Isochronous OUT endpoints)
0 = No effect. 1 = Send an interrupt when an MDATA packet has been received and so at least one packet of the microframe data payload has been received.
Caution: Interrupt source is active as long as the corresponding UDPHS_EPTSTAx register TXRDY_TRER flag remains low. If there are no more banks available for transmitting after the software has set UDPHS_EPTSTAx/TXRDY_TRER for the last transmit packet, then the interrupt source remains inactive until the first bank becomes free again to transmit at UDPHS_EPTSTAx/TXRDY_TRER hardware clear. ERR_FL_ISO: Error Flow Interrupt Enabled
0 = Error Flow Interrupt is masked. 1 = Error Flow Interrupt is enabled.
797
For OUT endpoints: An interrupt is sent when all banks are busy. For IN endpoints: An interrupt is sent when all banks are free. SHRT_PCKT: Short Packet Interrupt Enabled For OUT endpoints: send an Interrupt when a Short Packet has been received. 0 = Short Packet Interrupt is masked. 1 = Short Packet Interrupt is enabled. For IN endpoints: a Short Packet transmission is guaranteed upon end of the DMA Transfer, thus signaling an end of isochronous (micro-)frame data, but only if the UDPHS_DMACONTROLx register END_B_EN and UDPHS_EPTCTLx register AUTO_VALID bits are also set.
798
32.7.15 UDPHS Endpoint Set Status Register (Control, Bulk, Interrupt Endpoints)
Name: Access:
31 23 15 7
This register view is relevant only if EPT_TYPE=0x0, 0x2 or 0x3 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Status Register (Control, Bulk, Interrupt Endpoints) on page 803
This flag is used to generate a Data IN transaction (device to host). Device firmware checks that it can write a data payload in the FIFO, checking that TXRDY is cleared. Transfer to the FIFO is done by writing in the Buffer Address register. Once the data payload has been transferred to the FIFO, the firmware notifies the UDPHS device setting TXRDY to one. UDPHS bus transactions can start. TXCOMP is set once the data payload has been received by the host. Data should be written into the endpoint FIFO only after this bit has been cleared. Set this bit without writing data to the endpoint FIFO to send a Zero Length Packet.
799
Access:
31 23 15 7
This register view is relevant only if EPT_TYPE=0x1 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Status Register (Isochronous Endpoint) on page 806.
This flag is used to generate a Data IN transaction (device to host). Device firmware checks that it can write a data payload in the FIFO, checking that TXRDY_TRER is cleared. Transfer to the FIFO is done by writing in the Buffer Address register. Once the data payload has been transferred to the FIFO, the firmware notifies the UDPHS device setting TXRDY_TRER to one. UDPHS bus transactions can start. TXCOMP is set once the data payload has been sent. Data should be written into the endpoint FIFO only after this bit has been cleared. Set this bit without writing data to the endpoint FIFO to send a Zero Length Packet.
800
32.7.17 UDPHS Endpoint Clear Status Register (Control, Bulk, Interrupt Endpoints)
Name: Access:
31 23 15 NAK_OUT 7
This register view is relevant only if EPT_TYPE=0x0, 0x2 or 0x3 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Status Register (Control, Bulk, Interrupt Endpoints) on page 803.
FRCESTALL: Stall Handshake Request Clear 0 = No effect. 1 = Clear the STALL request. The next packets from host will not be STALLed. TOGGLESQ: Data Toggle Clear 0 = No effect. 1 = Clear the PID data of the current bank For OUT endpoints, the next received packet should be a DATA0. For IN endpoints, the next packet will be sent with a DATA0 PID. RXRDY_TXKL: Received OUT Data Clear 0 = No effect. 1 = Clear the RXRDY_TXKL flag of UDPHS_EPTSTAx. TX_COMPLT: Transmitted IN Data Complete Clear 0 = No effect. 1 = Clear the TX_COMPLT flag of UDPHS_EPTSTAx. RX_SETUP: Received SETUP Clear 0 = No effect. 1 = Clear the RX_SETUP flags of UDPHS_EPTSTAx. STALL_SNT: Stall Sent Clear 0 = No effect. 1 = Clear the STALL_SNT flags of UDPHS_EPTSTAx. NAK_IN: NAKIN Clear 0 = No effect. 1 = Clear the NAK_IN flags of UDPHS_EPTSTAx. NAK_OUT: NAKOUT Clear 0 = No effect. 1 = Clear the NAK_OUT flag of UDPHS_EPTSTAx.
801
Access:
31 23 15
6 TOGGLESQ
This register view is relevant only if EPT_TYPE=0x1 in UDPHS Endpoint Configuration Register on page 783 For additional Information, see UDPHS Endpoint Status Register (Isochronous Endpoint) on page 806.
802
20
15 NAK_OUT
12 RX_SETUP 4
7 6 TOGGLESQ_STA
This register view is relevant only if EPT_TYPE=0x0, 0x2 or 0x3 in UDPHS Endpoint Configuration Register on page 783
IN endpoint: It indicates the PID Data Toggle that will be used for the next packet sent. This is not relative to the current bank. CONTROL and OUT endpoint: These bits are set by hardware to indicate the PID data of the current bank:
Value 0 1 2 3 Name DATA0 DATA1 DATA2 MDATA Description DATA0 DATA1 Reserved for High Bandwidth Isochronous Endpoint Reserved for High Bandwidth Isochronous Endpoint
Notes: 1. In OUT transfer, the Toggle information is meaningful only when the current bank is busy (Received OUT Data = 1). 2. These bits are updated for OUT transfer: - A new data has been written into the current bank. - The user has just cleared the Received OUT Data bit to switch to the next bank. 3. This field is reset to DATA1 by the UDPHS_EPTCLRSTAx register TOGGLESQ bit, and by UDPHS_EPTCTLDISx (disable endpoint).
803
RXRDY_TXKL: Received OUT Data/KILL Bank Received OUT Data (for OUT endpoint or Control endpoint):
This bit is set by hardware after a new packet has been stored in the endpoint FIFO. This bit is cleared by the device firmware after reading the OUT data from the endpoint. For multi-bank endpoints, this bit may remain active even when cleared by the device firmware, this if an other packet has been received meanwhile. Hardware assertion of this bit may generate an interrupt if enabled by the UDPHS_EPTCTLx register RXRDY_TXKL bit. This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by UDPHS_EPTCTLDISx (disable endpoint).
KILL Bank (for IN endpoint): The bank is really cleared or the bank is sent, BUSY_BANK_STA is decremented. The bank is not cleared but sent on the IN transfer, TX_COMPLT The bank is not cleared because it was empty. The user should wait that this bit is cleared before trying to clear another packet.
Note: Kill a packet may be refused if at the same time, an IN token is coming and the current packet is sent on the UDPHS line. In this case, the TX_COMPLT bit is set. Take notice however, that if at least two banks are ready to be sent, there is no problem to kill a packet even if an IN token is coming. In fact, in that case, the current bank is sent (IN transfer) and the last bank is killed.
NAK_IN: NAK IN
This bit is set by hardware when a NAK handshake has been sent in response to an IN request from the Host. This bit is cleared by software.
804
CURBK_CTLDIR: Current Bank/Control Direction Current Bank (not relevant for Control endpoint):
These bits are set by hardware to indicate the number of the current bank.
Value 0 1 2 Name BANK0 BANK1 BANK2 Description Bank 0 (or single bank) Bank 1 Bank 2
Note:
The current bank is updated each time the user: - Sets the TX Packet Ready bit to prepare the next IN transfer and to switch to the next bank. - Clears the received OUT data bit to access the next bank.
This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by UDPHS_EPTCTLDISx (disable endpoint).
IN endpoint: It indicates the number of busy banks filled by the user, ready for IN transfer. OUT endpoint: It indicates the number of busy banks filled by OUT transaction from the Host.
Value 0 1 2 Name 1BUSYBANK 2BUSYBANKS 3BUSYBANKS Description 1 busy bank 2 busy banks 3 busy banks
805
Access:
31 SHRT_PCKT 23
20
17 CURBK 9 RXRDY_TXKL
16
15
12 ERR_FL_ISO
8 ERR_OVFLW
7 6 TOGGLESQ_STA
This register view is relevant only if EPT_TYPE=0x1 in UDPHS Endpoint Configuration Register on page 783
IN endpoint: It indicates the PID Data Toggle that will be used for the next packet sent. This is not relative to the current bank. OUT endpoint: These bits are set by hardware to indicate the PID data of the current bank:
Value 0 1 2 3 Name DATA0 DATA1 DATA2 MDATA Description DATA0 DATA1 Data2 (only for High Bandwidth Isochronous Endpoint) MData (only for High Bandwidth Isochronous Endpoint)
Notes: 1. In OUT transfer, the Toggle information is meaningful only when the current bank is busy (Received OUT Data = 1). 2. These bits are updated for OUT transfer: - A new data has been written into the current bank. - The user has just cleared the Received OUT Data bit to switch to the next bank. 3. For High Bandwidth Isochronous Out endpoint, it is recommended to check the UDPHS_EPTSTAx/TXRDY_TRER bit to know if the toggle sequencing is correct or not. 4. This field is reset to DATA1 by the UDPHS_EPTCLRSTAx register TOGGLESQ bit, and by UDPHS_EPTCTLDISx (disable endpoint).
806
RXRDY_TXKL: Received OUT Data/KILL Bank Received OUT Data (for OUT endpoint or Control endpoint):
This bit is set by hardware after a new packet has been stored in the endpoint FIFO. This bit is cleared by the device firmware after reading the OUT data from the endpoint. For multi-bank endpoints, this bit may remain active even when cleared by the device firmware, this if an other packet has been received meanwhile. Hardware assertion of this bit may generate an interrupt if enabled by the UDPHS_EPTCTLx register RXRDY_TXKL bit. This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by UDPHS_EPTCTLDISx (disable endpoint).
KILL Bank (for IN endpoint): The bank is really cleared or the bank is sent, BUSY_BANK_STA is decremented. The bank is not cleared but sent on the IN transfer, TX_COMPLT The bank is not cleared because it was empty. The user should wait that this bit is cleared before trying to clear another packet.
Note: Kill a packet may be refused if at the same time, an IN token is coming and the current packet is sent on the UDPHS line. In this case, the TX_COMPLT bit is set. Take notice however, that if at least two banks are ready to be sent, there is no problem to kill a packet even if an IN token is coming. In fact, in that case, the current bank is sent (IN transfer) and the last bank is killed.
Isochronous IN transaction is missed, the micro has no time to fill the endpoint (underflow). Isochronous OUT data is dropped because the bank is busy (overflow).
This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by UDPHS_EPTCTLDISx (disable endpoint).
807
ERR_CRC_NTR: CRC ISO Error/Number of Transaction Error CRC ISO Error (for Isochronous OUT endpoints) (Read-only):
This bit is set by hardware if the last received data is corrupted (CRC error on data). This bit is updated by hardware when new data is received (Received OUT Data bit).
Note:
The current bank is updated each time the user: - Sets the TX Packet Ready bit to prepare the next IN transfer and to switch to the next bank. - Clears the received OUT data bit to access the next bank.
This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by UDPHS_EPTCTLDISx (disable endpoint).
IN endpoint: It indicates the number of busy banks filled by the user, ready for IN transfer. OUT endpoint: It indicates the number of busy banks filled by OUT transaction from the Host.
Value 0 1 2 Name 1BUSYBANK 2BUSYBANKS 3BUSYBANKS Description 1 busy bank 2 busy banks 3 busy banks
808
809
810
UDPHS_DMANXTDSCx [x = 0..6] 0xF8030300 [0], 0xF8030310 [1], 0xF8030320 [2], 0xF8030330 [3], 0xF8030340 [4], 0xF8030350 [5], 0xF8030360 [6] Read-write
30 29 28 27 NXT_DSC_ADD 20 19 NXT_DSC_ADD 12 11 NXT_DSC_ADD 4 3 NXT_DSC_ADD 26 25 24
23
22
21
18
17
16
15
14
13
10
Note:
811
UDPHS_DMAADDRESSx [x = 0..6] 0xF8030304 [0], 0xF8030314 [1], 0xF8030324 [2], 0xF8030334 [3], 0xF8030344 [4], 0xF8030354 [5], 0xF8030364 [6] Read-write
30 29 28 BUFF_ADD 27 26 25 24
23
22
21
20 BUFF_ADD
19
18
17
16
15
14
13
12 BUFF_ADD
11
10
4 BUFF_ADD
Note:
812
UDPHS_DMACONTROLx [x = 0..6] 0xF8030308 [0], 0xF8030318 [1], 0xF8030328 [2], 0xF8030338 [3], 0xF8030348 [4], 0xF8030358 [5], 0xF8030368 [6] Read-write
30 29 28 27 BUFF_LENGTH 20 19 BUFF_LENGTH 12 4 END_TR_IT 11 3 END_B_EN 26 25 24
23
22
21
18
17
16
15 7 BURST_LCK
14 6 DESC_LD_IT
13 5 END_BUFFIT
10 2 END_TR_EN
9 1 LDNXT_DSC
8 0 CHANN_ENB
Note:
813
814
UDPHS_DMASTATUSx [x = 0..6] 0xF803030C [0], 0xF803031C [1], 0xF803032C [2], 0xF803033C [3], 0xF803034C [4], 0xF803035C [5], 0xF803036C [6] Read-write
30 29 28 27 BUFF_COUNT 20 19 BUFF_COUNT 12 4 END_TR_ST 11 3 26 25 24
23
22
21
18
17
16
15 7
14 6 DESC_LDST
13 5 END_BF_ST
10 2
9 1 CHANN_ACT
8 0 CHANN_ENB
Note:
815
816
33.
33.1
33.2
Embedded Characteristics
z
Compliant with USB V2.0 High-speed Supports High-speed 480 Mbps Compliant with USB V2.0 Full-speed and Low-speed Specification Supports both Low-speed 1.5 Mbps and Full-speed 12 Mbps USB devices
z z z z
Root Hub Integrated with 3 Downstream USB HS Ports Embedded USB Transceivers Supports Power Management 3 Hosts (A, B and C) High Speed (EHCI), Port A shared with UDPHS
817
33.3
Block Diagram
List Processor Block ED & TD Registers Root Hub and Host SIE
PORT S/M 1
Embedded USB v2.0 Transceiver USB High-speed Transceiver HFSDPC HFSDMC HHSDPC HHSDMC HFSDPB HFSDMB HHSDPB HHSDMB HFSDPA HFSDMA HHSDPA HHSDMA
Master AHB
Data
SOF generator HCI Slave Block Slave AHB EHCI Registers Control Packet Buffer FIFO
Access to the USB host operational registers is achieved through the AHB bus slave interface. The Open HCI host controller and Enhanced HCI host controller initialize master DMA transfers through the AHB bus master interface as follows:
z z z z
Fetches endpoint descriptors and transfer descriptors Access to endpoint data from system memory Access to the HC communication area Write status and retire transfer descriptor
Memory access errors (abort, misalignment) lead to an Unrecoverable Error indicated by the corresponding flag in the host controller operational registers. The USB root hub is integrated in the USB host. Several USB downstream ports are available. The number of downstream ports can be determined by the software driver reading the root hubs operational registers. Device connection is automatically detected by the USB host port logic. USB physical transceivers are integrated in the product and driven by the root hubs ports. Over current protection on ports can be activated by the USB host controller. Atmels standard product does not dedicate pads to external over current protection.
818
33.4
Typical Connection
HHSDM/HFSDM
Shell = Shield
1 2
819
33.5
Product Dependencies
Enable UHP peripheral clock, bit (1 << AT91C_ID_UHPHS) in PMC_PCER register. Write CKGR_PLLCOUNT field in PMC_UCKR register. Enable UPLL, bit AT91C_CKGR_UPLLEN in PMC_UCKR register. Wait until UTMI_PLL is locked. LOCKU bit in PMC_SR register Enable BIAS, bit AT91C_CKGR_BIASEN in PMC_UCKR register. Select UPLLCK as Input clock of OHCI part, USBS bit in PMC_USB register. Program the OHCI clocks (UHP48M and UHP12M) with USBDIV field in PMC_USB register. USBDIV must be 9 (division by 10) if UPLLCK is selected. Enable OHCI clocks, UHP bit in PMC_SCER register. Enable UHP peripheral clock, bit (1 << AT91C_ID_UHPHS) in PMC_PCER register. Select PLLACK as Input clock of OHCI part, USBS bit in PMC_USB register. Program the OHCI clocks (UHP48M and UHP12M) with USBDIV field in PMC_USB register. USBDIV value is to calculated regarding the PLLACK value and USB Full-speed accuracy. Enable the OHCI clocks, UHP bit in PMC_SCER register.
For OHCI Full-speed operations only, the user has to perform the following:
z z z z
820
AHB
30 MHz
UTMI transceiver
Port Router
30 MHz 30 MHz
MCK OHCI Master Interface OHCI User Interface USB 1.1 OHCI Host Controller
UHP12M
OHCI clocks
33.5.3 Interrupt
The USB host interface has an interrupt line connected to the Advanced Interrupt Controller (AIC). Handling USB host interrupts requires programming the AIC before configuring the UHP HS.
UHP48M
821
33.6
Functional Description
EN_UDPHS 0 Other Ports HS USB Host HS EHCI FS OHCI DMA PA HS USB Device DMA 1
33.6.2 EHCI
The USB Host Port controller is fully compliant with the Enhanced HCI specification. The USB Host Port User Interface (registers description) can be found in the Enhanced HCI Rev 1.0 Specification available on http://www.intel.com/technology/usb/ehcispec.htm. The standard EHCI USB stack driver can be easily ported to Atmels architecture in the same way all existing class drivers run, without hardware specialization.
33.6.3 OHCI
The USB Host Port integrates a root hub and transceivers on downstream ports. It provides several Full-speed halfduplex serial communication ports at a baud rate of 12 Mbit/s. Up to 127 USB devices (printer, camera, mouse, keyboard, disk, etc.) and the USB hub can be connected to the USB host in the USB tiered star topology. The USB Host Port controller is fully compliant with the Open HCI specification. The USB Host Port User Interface (registers description) can be found in the Open HCI Rev 1.0 Specification available on http://h18000.www1.hp.com/productinfo/development/openhci.html. The standard OHCI USB stack driver can be easily ported to Atmels architecture, in the same way all existing class drivers run without hardware specialization. This means that all standard class devices are automatically detected and available to the users application. As an example, integrating an HID (Human Interface Device) class driver provides a plug & play feature for all USB keyboards and mouses.
822
34.
34.1
GEM_MAC controlling transmit, receive, address checking and loopback GEM_TSU calculates the IEEE 1588 timer values
34.2
Embedded Characteristics
z z z z z z z z z z z z z z z z z z z z z z z z z
Compatible with IEEE Standard 802.3 10, 100 and 1000 Mbps operation Full and half duplex operation at all supported speeds of operation Statistics Counter Registers for RMON/MIB MII/GMII/RGMII interface to the physical layer Integrated physical coding Direct memory access (DMA) interface to external memory Support for up to eight priority queues in DMA Programmable burst length and endianism for DMA Interrupt generation to signal receive and transmit completion, or errors Automatic pad and cyclic redundancy check (CRC) generation on transmitted frames Frame extension and frame bursting at 1000 Mbps in half duplex mode Automatic discard of frames received with errors Receive and transmit IP, TCP and UDP checksum offload. Both IPv4 and IPv6 packet types supported Address checking logic for four specific 48-bit addresses, four type IDs, promiscuous mode, hash matching of unicast and multicast destination addresses and Wake-on-LAN Management Data Input/Output (MDIO) interface for physical layer management Support for jumbo frames up to 10240 bytes Full duplex flow control with recognition of incoming pause frames and hardware generation of transmitted pause frames Half duplex flow control by forcing collisions on incoming frames Support for 802.1Q VLAN tagging with recognition of incoming VLAN and priority tagged frames Support for 802.1Qbb priority-based flow control Programmable Inter Packet Gap (IPG) Stretch Recognition of IEEE 1588 PTP frames IEEE 1588 time stamp unit (TSU) Support for 802.1AS timing and synchronization
823
34.3
Block Diagram
Status & Statistic Registers APB Register Interface MDIO Control Registers
MAC Transmitter AHB AHB DMA Interface FIFO Interface Media Interface MAC Receiver
Frame Filtering
824
34.4
Signal Interface
The GMAC includes the following signal interfaces
z z z z
MII, GMII and RGMII to an external PHY MDIO interface for external PHY management Slave APB interface for accessing GMAC registers Master AHB interface for memory access
Table 34-1. GMAC connections in the different modes Signal Name GTXCK G125CK G125CKO GTXEN GTX[7..0] GTXER GRXCK GRXDV GRX[7..0] GRXER GCRS GCOL GMDC GMDIO Function Transmit Clock or Reference Clock 125 MHz input Clock 125 MHz output Clock Transmit Enable Transmit Data Transmit Coding Error Receive Clock Receive Data Valid Receive Data Receive Error Carrier Sense and Data Valid Collision Detect Management Data Clock Management Data Input/Output MII TXCK Not Used Not Used TXEN TXD[3:0] TXER RXCK RXDV RXD[3:0] RXER CRS COL MDC MDIO GMII Not Used 125 MHz Ref Clk TXCK TXEN TXD[7:0] TXER RXCK RXDV RXD[7:0] RXER CRS COL MDC MDIO RGMII TXCK 125 MHz Ref Clk Not Used TXCTL TXD[3:0] Not Used RXCK Not Used RXD[3:0] RXCTL Not Used Not Used MDC MDIO
825
34.5
Functional Description
Receive buffer manager write/read Transmit buffer manager write/read Receive data DMA write Transmit data DMA read
The DMA is configured in packet buffer mode, where dual-port memories are used to buffer multiple frames. The packet buffer DMA features follow. 34.5.3.1 Packet Buffer DMA
z z z z z z
Easier to guarantee maximum line rate due to the ability to store multiple frames in the packet buffer Full store and forward, or partial store and forward programmable options (partial store will cater for shorter latency requirements) Support for Transmit TCP/IP checksum offload Support for priority queueing When a collision on the line occurs during transmission, the packet will be automatically replayed directly from the packet buffer memory rather than having to re-fetch through the AHB (full store and forward ONLY) Received errored packets are automatically dropped before any of the packet is presented to the AHB (full store and forward ONLY), thus reducing AHB activity
826
z z
Supports manual RX packet flush capabilities Optional RX packet flush when there is lack of AHB resource
34.5.3.2 Partial Store and Forward Using Packet Buffer DMA When the DMA is configured to use SRAM-based packet buffers, it can be programmed into a low latency mode, known as partial store and forward. This mode allows the integrator to attach small SRAMs to the GMAC DMA, smaller than the maximum sized packets to be transmitted/received. This allows for a reduced latency as the full packet is not buffered before forwarding. Note that this option is only available when the device is configured for full duplex operation. This feature is enabled via the TX and RX partial store and forward programmable registers. When the transmit partial store and forward mode is activated, the transmitter will only begin to forward the packet to the MAC when there is enough packet data stored in the packet buffer. Likewise, when the receive partial store and forward mode is activated, the receiver will only begin to forward the packet to the AHB when enough packet data is stored in the packet buffer. The amount of packet data required to activate the forwarding process is programmable via watermark registers which are located at the same address as the partial store and forward enable bits. Note that the minimum operational value for the TX partial store and forward watermark is 20. There is no operational limit for the RX partial store and forward watermark. Enabling partial store and forward is a useful means to reduce latency and reduce the size of the attached SRAMs, but there are performance implications. The GMAC DMA uses separate transmit and receive lists of buffer descriptors, with each descriptor describing a buffer area in memory. This allows Ethernet packets to be broken up and scattered around the AHB memory space. 34.5.3.3 Receive AHB Buffers Received frames, optionally including FCS, are written to receive AHB buffers stored in memory. The receive buffer depth is programmable in the range of 64 bytes to 16 Kbytes through the DMA Configuration Register, with the default being 128 bytes. The start location for each receive AHB buffer is stored in memory in a list of receive buffer descriptors at an address location pointed to by the receive buffer queue pointer. The base address for the receive buffer queue pointer is configured in software using the Receive Buffer Queue Base Address Register. Each list entry consists of two words. The first is the address of the receive AHB buffer and the second the receive status. If the length of a receive frame exceeds the AHB buffer length, the status word for the used buffer is written with zeroes except for the start of frame bit, which is always set for the first buffer in a frame. Bit zero of the address field is written to 1 to show the buffer has been used. The receive buffer manager then reads the location of the next receive AHB buffer and fills that with the next part of the received frame data. AHB buffers are filled until the frame is complete and the final buffer descriptor status word contains the complete frame status. Refer to Table 34-2, Receive Buffer Descriptor Entry for details of the receive buffer descriptor list. Each receive AHB buffer start location is a word address. The start of the first AHB buffer in a frame can be offset by up to three bytes, depending on the value written to bits 14 and 15 of the Network Configuration Register. For 64-bit datapaths, the start of the frame can be offset by up to a further four bytes if bit 2 of the AHB buffer start location in the buffer descriptor is set. If the start location of the AHB buffer is offset, the available length of the first AHB buffer is reduced by the corresponding number of bytes.
Table 34-2. Receive Buffer Descriptor Entry Bit Function Word 0 31:2 1 0 Address of beginning of buffer Wrap - marks last descriptor in receive buffer descriptor list. Ownership - needs to be zero for the GMAC to write data to the receive buffer. The GMAC sets this to one once it has successfully written a frame to memory. Software has to clear this bit before the buffer can be used again. Word 1 31 Global all ones broadcast address detected
827
Table 34-2. Receive Buffer Descriptor Entry (Continued) Bit 30 29 28 27 Function Multicast hash match Unicast hash match Specific Address Register match found, bit 25 and bit 26 indicate which Specific Address Register causes the match. Specific Address Register match. Encoded as follows: 00 - Specific Address Register 1 match 26:25 01 - Specific Address Register 2 match 10 - Specific Address Register 3 match 11 - Specific Address Register 4 match If more than one specific address is matched only one is indicated with priority 4 down to 1. This bit has a different meaning depending on whether RX checksum offloading is enabled. With RX checksum offloading disabled: (bit 24 clear in Network Configuration Register) Type ID register match found, bit 22 and bit 23 indicate which type ID register causes the match. 24 With RX checksum offloading enabled: (bit 24 set in Network Configuration Register) 0 - the frame was not SNAP encoded and/or had a VLAN tag with the Canonical Format Indicator (CFI) bit set. 1 - the frame was SNAP encoded and had either no VLAN tag or a VLAN tag with the CFI bit not set. This bit has a different meaning depending on whether RX checksum offloading is enabled. With RX checksum offloading disabled: (bit 24 clear in Network Configuration) Type ID register match. Encoded as follows: 00 - Type ID register 1 match 01 - Type ID register 2 match 10 -Type ID register 3 match 11 - Type ID register 4 match 23:22 If more than one Type ID is matched only one is indicated with priority 4 down to 1. With RX checksum offloading enabled: (bit 24 set in Network Configuration Register) 00 - Neither the IP header checksum nor the TCP/UDP checksum was checked. 01 - The IP header checksum was checked and was correct. Neither the TCP nor UDP checksum was checked. 10 - Both the IP header and TCP checksum were checked and were correct. 11 - Both the IP header and UDP checksum were checked and were correct. 21 VLAN tag detected - type ID of 0x8100. For packets incorporating the stacked VLAN processing feature, this bit will be set if the second VLAN tag has a type ID of 0x8100 Priority tag detected - type ID of 0x8100 and null VLAN identifier. For packets incorporating the stacked VLAN processing feature, this bit will be set if the second VLAN tag has a type ID of 0x8100 and a null VLAN identifier. VLAN priority - only valid if bit 21 is set.
20 19:17
828
Table 34-2. Receive Buffer Descriptor Entry (Continued) Bit 16 15 14 Function Canonical format indicator (CFI) bit (only valid if bit 21 is set). End of frame - when set the buffer contains the end of a frame. If end of frame is not set, then the only valid status bit is start of frame (bit 14). Start of frame - when set the buffer contains the start of a frame. If both bits 15 and 14 are set, the buffer contains a whole frame. This bit has a different meaning depending on whether jumbo frames and ignore FCS modes are enabled. If neither mode is enabled this bit will be zero. With jumbo frame mode enabled: (bit 3 set in Network Configuration Register) Additional bit for length of frame (bit[13]), that is concatenated with bits[12:0] 13 With ignore FCS mode enabled and jumbo frames disabled: (bit 26 set in Network Configuration Register and bit 3 clear in Network Configuration Register) This indicates per frame FCS status as follows: 0 - Frame had good FCS 1 - Frame had bad FCS, but was copied to memory as ignore FCS enabled. These bits represent the length of the received frame which may or may not include FCS depending on whether FCS discard mode is enabled. With FCS discard mode disabled: (bit 17 clear in Network Configuration Register) 12:0 Least significant 12 bits for length of frame including FCS. If jumbo frames are enabled, these 12 bits are concatenated with bit[13] of the descriptor above. With FCS discard mode enabled: (bit 17 set in Network Configuration Register) Least significant 12 bits for length of frame excluding FCS. If jumbo frames are enabled, these 12 bits are concatenated with bit[13] of the descriptor above.
To receive frames, the AHB buffer descriptors must be initialized by writing an appropriate address to bits 31:2 in the first word of each list entry. Bit 0 must be written with zero. Bit 1 is the wrap bit and indicates the last entry in the buffer descriptor list. The start location of the receive buffer descriptor list must be written with the receive buffer queue base address before reception is enabled (receive enable in the Network Control Register). Once reception is enabled, any writes to the Receive Buffer Queue Base Address Register are ignored. When read, it will return the current pointer position in the descriptor list, though this is only valid and stable when receive is disabled. If the filter block indicates that a frame should be copied to memory, the receive data DMA operation starts writing data into the receive buffer. If an error occurs, the buffer is recovered. An internal counter within the GMAC represents the receive buffer queue pointer and it is not visible through the CPU interface. The receive buffer queue pointer increments by two words after each buffer has been used. It re-initializes to the receive buffer queue base address if any descriptor has its wrap bit set. As receive AHB buffers are used, the receive AHB buffer manager sets bit zero of the first word of the descriptor to logic one indicating the AHB buffer has been used. Software should search through the used bits in the AHB buffer descriptors to find out how many frames have been received, checking the start of frame and end of frame bits. When the DMA is configured in the packet buffer partial store and forward mode, received frames are written out to the AHB buffers as soon as enough frame data exists in the packet buffer. For both cases, this may mean several full AHB buffers are used before some error conditions can be detected. If a receive error is detected the receive buffer currently being written will be recovered. Previous buffers will not be recovered. As an example, when receiving frames with cyclic redundancy check (CRC) errors or excessive length, it is possible that a frame fragment might be stored in a sequence of
829
AHB receive buffers. Software can detect this by looking for start of frame bit set in a buffer following a buffer with no end of frame bit set. For a properly working 10/100/1000 Ethernet system there should be no excessive length frames or frames greater than 128 bytes with CRC errors. Collision fragments will be less than 128 bytes long, therefore it will be a rare occurrence to find a frame fragment in a receive AHB buffer, when using the default value of 128 bytes for the receive buffers size. When in packet buffer full store and forward mode, only good received frames are written out of the DMA, so no fragments will exist in the AHB buffers due to MAC receiver errors. There is still the possibility of fragments due to DMA errors, for example used bit read on the second buffer of a multi-buffer frame. If bit zero of the receive buffer descriptor is already set when the receive buffer manager reads the location of the receive AHB buffer, then the buffer has been already used and cannot be used again until software has processed the frame and cleared bit zero. In this case, the buffer not available bit in the receive status register is set and an interrupt triggered. The receive resource error statistics register is also incremented. When the DMA is configured in the packet buffer full store and forward mode, the user can optionally select whether received frames should be automatically discarded when no AHB buffer resource is available. This feature is selected via bit 24 of the DMA Configuration Register (by default, the received frames are not automatically discarded). If this feature is off, then received packets will remain to be stored in the SRAM-based packet buffer until AHB buffer resource next becomes available. This may lead to an eventual packet buffer overflow if packets continue to be received when bit zero (used bit) of the receive buffer descriptor remains set. Note that after a used bit has been read, the receive buffer manager will reread the location of the receive buffer descriptor every time a new packet is received. When the DMA is not configured in the packet buffer full store and forward mode and a used bit is read, the frame currently being received will be automatically discarded. When the DMA is configured in the packet buffer full store and forward mode, a receive overrun condition occurs when the receive SRAM-based packet buffer is full, or because HRESP was not OK. In all other modes, a receive overrun condition occurs when either the AHB bus was not granted quickly enough, or because HRESP was not OK, or because a new frame has been detected by the receive block, but the status update or write back for the previous frame has not yet finished. For a receive overrun condition, the receive overrun interrupt is asserted and the buffer currently being written is recovered. The next frame that is received whose address is recognized reuses the buffer. When the DMA is configured for packet buffer mode, a write to bit 18 of the Network Control Register will force a packet from the external SRAM-based receive packet buffer to be flushed. This feature is only acted upon when the RX DMA is not currently writing packet data out to AHB, i.e., it is in an IDLE state. If the RX DMA is active, a write to this bit is ignored. 34.5.3.4 Transmit AHB Buffers Frames to transmit are stored in one or more transmit AHB buffers. Transmit frames can be between 1 and 16384 bytes long, so it is possible to transmit frames longer than the maximum length specified in the IEEE 802.3 standard. It should be noted that zero length AHB buffers are allowed and that the maximum number of buffers permitted for each transmit frame is 128. The start location for each transmit AHB buffer is stored in memory in a list of transmit buffer descriptors at a location pointed to by the transmit buffer queue pointer. The base address for this queue pointer is set in software using the Transmit Buffer Queue Base Address Register. Each list entry consists of two words. The first is the byte address of the transmit buffer and the second containing the transmit control and status. For the packet buffer DMA, the start location for each AHB buffer is a byte address, the bottom bits of the address being used to offset the start of the data from the data-word boundary (i.e. bits 2,1 and 0 are used to offset the address for 64-bit datapaths). For bus widths of 64 or 128bits however, the address of the buffer must be aligned to the correct 64-bit or 128-bit boundary, plus an offset of less than 4 bytes. (Note this alignment restriction in FIFO-based DMA mode only should be sufficient for applications as the main purpose is to allow alignment of the encapsulated IP packet - Given the 14 bytes of MAC encapsulation, an offset of 2 will always align the IP header to a 128-bit boundary.) Frames can be transmitted with or without automatic CRC generation. If CRC is automatically generated, pad will also be automatically generated to take frames to a minimum length of 64 bytes. When CRC is not automatically generated (as
830
defined in word 1 of the transmit buffer descriptor or through the control bus of FIFO), the frame is assumed to be at least 64 bytes long and pad is not generated. An entry in the transmit buffer descriptor list is described in Table 34-3, Transmit Buffer Descriptor Entry. To transmit frames, the buffer descriptors must be initialized by writing an appropriate byte address to bits [31:0] in the first word of each descriptor list entry. The second word of the transmit buffer descriptor is initialized with control information that indicates the length of the frame, whether or not the MAC is to append CRC and whether the buffer is the last buffer in the frame. After transmission the status bits are written back to the second word of the first buffer along with the used bit. Bit 31 is the used bit which must be zero when the control word is read if transmission is to take place. It is written to one once the frame has been transmitted. Bits[29:20] indicate various transmit error conditions. Bit 30 is the wrap bit which can be set for any buffer within a frame. If no wrap bit is encountered the queue pointer continues to increment. The Transmit Buffer Queue Base Address Register can only be updated while transmission is disabled or halted; otherwise any attempted write will be ignored. When transmission is halted the transmit buffer queue pointer will maintain its value. Therefore when transmission is restarted the next descriptor read from the queue will be from immediately after the last successfully transmitted frame. while transmit is disabled (bit 3 of the network control set low), the transmit buffer queue pointer resets to point to the address indicated by the Transmit Buffer Queue Base Address Register. Note that disabling receive does not have the same effect on the receive buffer queue pointer. Once the transmit queue is initialized, transmit is activated by writing to the transmit start bit (bit 9) of the Network Control Register. Transmit is halted when a buffer descriptor with its used bit set is read, a transmit error occurs, or by writing to the transmit halt bit of the Network Control Register. Transmission is suspended if a pause frame is received while the pause enable bit is set in the Network Configuration Register. Rewriting the start bit while transmission is active is allowed. This is implemented with TXGO variable which is readable in the Transmit Status Register at bit location 3. The TXGO variable is reset when:
z z z z
Transmit is disabled. A buffer descriptor with its ownership bit set is read. Bit 10, THALT, of the Network Control Register is written. There is a transmit error such as too many retries, late collision (gigabit mode only) or a transmit under run.
To set TXGO, write TSTART to the bit 9 of the Network Control Register. Transmit halt does not take effect until any ongoing transmit finishes. If the DMA is configured for internal FIFO mode, or for packet buffer partial store and forward mode and a collision occurs during transmission of a multi-buffer frame, transmission will automatically restart from the first buffer of the frame. For packet buffer mode, the entire contents of the frame are read into the transmit packet buffer memory, so the retry attempt will be replayed directly from the packet buffer memory rather than having to re-fetch through the AHB. If a used bit is read mid way through transmission of a multi buffer frame this is treated as a transmit error. Transmission stops, GTXER is asserted and the FCS will be bad. If transmission stops due to a transmit error or a used bit being read, transmission will restart from the first buffer descriptor of the frame being transmitted when the transmit start bit is rewritten.
Table 34-3. Transmit Buffer Descriptor Entry Bit Function Word 0 31:0 Byte address of buffer Word 1 31 Used - must be zero for the GMAC to read data to the transmit buffer. The GMAC sets this to one for the first buffer of a frame once it has been successfully transmitted. Software must clear this bit before the buffer can be used again. Wrap - marks last descriptor in transmit buffer descriptor list. This can be set for any buffer within the frame.
30
831
Table 34-3. Transmit Buffer Descriptor Entry (Continued) Bit 29 Function Retry limit exceeded, transmit error detected Transmit under run - occurs when the start of packet data has been written into the FIFO and either HRESP is not OK, or the transmit data could not be fetched in time, or when buffers are exhausted. This is not set when the DMA is configured for packet buffer mode. Transmit frame corruption due to AHB error - set if an error occurs while midway through reading transmit frame from the AHB, including HRESP errors and buffers exhausted mid frame (if the buffers run out during transmission of a frame then transmission stops, FCS shall be bad and GTXER asserted). Also set in DMA packet buffer mode if single frame is too large for configured packet buffer memory size. 26 25:23 Late collision, transmit error detected. Late collisions only force this status bit to be set in gigabit mode. Reserved Transmit IP/TCP/UDP checksum generation offload errors: 000 No Error. 001 The Packet was identified as a VLAN type, but the header was not fully complete, or had an error in it. 010 The Packet was identified as a SNAP type, but the header was not fully complete, or had an error in it. 22:20 011 The Packet was not of an IP type, or the IP packet was invalidly short, or the IP was not of type IPv4/IPv6. 100 The Packet was not identified as VLAN, SNAP or IP. 101 110 111 19:17 Non supported packet fragmentation occurred. For IPv4 packets, the IP checksum was generated and inserted. Packet type detected was not TCP or UDP. TCP/UDP checksum was therefore not generated. For IPv4 packets, the IP checksum was generated and inserted. A premature end of packet was detected and the TCP/UDP checksum could not be generated.
28
27
Reserved No CRC to be appended by MAC. When set, this implies that the data in the buffers already contains a valid CRC, hence no CRC or padding is to be appended to the current frame by the MAC.
16
This control bit must be set for the first buffer in a frame and will be ignored for the subsequent buffers of a frame. Note that this bit must be clear when using the transmit IP/TCP/UDP checksum generation offload, otherwise checksum generation and substitution will not occur.
15 14 13:0
Last buffer, when set this bit will indicate the last buffer in the current frame has been reached. Reserved Length of buffer
832
34.5.3.5 DMA Bursting on the AHB The DMA will always use SINGLE, or INCR type AHB accesses for buffer management operations. When performing data transfers, the AHB burst length used can be programmed using bits [4:0] of the DMA Configuration Register so that either SINGLE, INCR or fixed length incrementing bursts (INCR4, INCR8 or INCR16) are used where possible. When there is enough space and enough data to be transferred, the programmed fixed length bursts will be used. If there is not enough data or space available, for example when at the beginning or the end of a buffer, SINGLE type accesses are used. Also SINGLE type accesses are used at 1024 byte boundaries, so that the 1 Kbytes boundaries are not burst over as per AHB requirements. The DMA will not terminate a fixed length burst early, unless an error condition occurs on the AHB or if receive or transmit are disabled in the Network Control Register. 34.5.3.6 DMA Packet Buffer The DMA can be configured to use packet buffers for both transmit and receive paths. This mode allows multiple packets to be buffered in both transmit and receive directions. This allows the DMA to withstand far greater access latencies on the AHB and make more efficient use of the AHB bandwidth. As described earlier, (see Section 34.5.3.2 Partial Store and Forward Using Packet Buffer DMA) when the DMA is configured to use packet buffers, it can be programmed into a low latency mode, known as partial store and forward. Further details of this mode have been given (see Section 34.5.3.2) and are not repeated here. When it is programmed in full store and forward mode, full packets are buffered which provides the possibility to:
z z z
Discard packets with error on the receive path before they are partially written out of the DMA, thus saving AHB bus bandwidth and driver processing overhead, Retry collided transmit frames from the buffer, thus saving AHB bus bandwidth, Implement transmit IP/TCP/UDP checksum generation offload.
With the packet buffers included, the structure of the GMAC data paths is shown in Figure 34-2 below.
833
TX Packet Buffer
TX DMA APB Register Interface Status and Statistic Registers RX DMA AHB DMA AHB
RX Packet Buffer
Frame Filtering
Ethernet MAC
34.5.3.7 Transmit Packet Buffer The transmitter packet buffer will continue attempting to fetch frame data from the AHB system memory until the packet buffer itself is full, at which point it will attempt to maintain its full level. To accommodate the status and statistics associated with each frame, 3 words per packet (or 2 if the GMAC is configured in 64-bit datapath mode) are reserved at the end of the packet data. If the packet is bad and requires to be dropped, the status and statistics are the only information held on that packet. Storing the status in the DPRAM is required in order to decouple the DMA interface of the buffer from the MAC interface, to update the MAC status/statistics and to generate interrupts in the order in which the packets that they represent were fetched from the AHB memory. If any errors occur on the AHB while reading the transmit frame, the fetching of packet data from AHB memory is halted. The MAC transmitter will continue to fetch packet data, thereby emptying the packet buffer and allowing any good nonerrored frames to be transmitted successfully. Once these have been fully transmitted, the status/statistics for the errored frame will be updated and software will be informed via an interrupt that an AHB error occurred. This way, the error is reported in the correct packet order.
834
The transmit packet buffer will only attempt to read more frame data from the AHB when space is available in the packet buffer memory. If space is not available it must wait until the a packet fetched by the MAC completes transmission and is subsequently removed from the packet buffer memory. Note that if full store and forward mode is active and if a single frame is fetched that is too large for the packet buffer memory, the frame is flushed and the DMA halted with an error status. This is because a complete frame must be written into the packet buffer before transmission can begin, and therefore the minimum packet buffer memory size should be chosen to satisfy the maximum frame to be transmitted in the application. In full store and forward mode, once the complete transmit frame is written into the packet buffer memory, a trigger is sent across to the MAC transmitter, which will then begin reading the frame from the packet buffer memory. Since the whole frame is present and stable in the packet buffer memory an underflow of the transmitter is not possible. The frame is kept in the packet buffer until notification is received from the MAC that the frame data has either been successfully transmitted or can no longer be re-transmitted (too many retries in half duplex mode). When this notification is received the frame is flushed from memory to make room for a new frame to be fetched from AHB system memory. In partial store and forward mode, a trigger is sent across to the MAC transmitter as soon as sufficient packet data is available, which will then begin fetching the frame from the packet buffer memory. If, after this point, the MAC transmitter is able to fetch data from the packet buffer faster than the AHB DMA can fill it, an underflow of the transmitter is possible. In this case, the transmission is terminated early, and the packet buffer is completely flushed. Transmission can only be restarted by writing to the transmit START bit. In half duplex mode, the frame is kept in the packet buffer until notification is received from the MAC that the frame data has either been successfully transmitted or can no longer be re-transmitted (too many retries in half duplex mode). When this notification is received the frame is flushed from memory to make room for a new frame to be fetched from AHB system memory. In full duplex mode, the frame is removed from the packet buffer on the fly. Other than underflow, the only MAC related errors that can occur are due to collisions during half duplex transmissions. When a collision occurs the frame still exists in the packet buffer memory so can be retried directly from there. Only once the MAC transmitter has failed to transmit after sixteen attempts is the frame finally flushed from the packet buffer. 34.5.3.8 Receive Packet Buffer The receive packet buffer stores frames from the MAC receiver along with their status and statistics. Frames with errors are flushed from the packet buffer memory, while good frames are pushed onto the DMA AHB interface. The receiver packet buffer monitors FIFO from the MAC receiver and translates the FIFO pushes into packet buffer writes. At the end of the received frame the status and statistics are buffered so that the information can be used when the frame is read out. When programmed in full store and forward mode, if the frame has an error the frame data is immediately flushed from the packet buffer memory allowing subsequent frames to utilise the freed up space. The status and statistics for bad frames are still used to update the GMAC registers. To accommodate the status and statistics associated with each frame, 3 words per packet (or 2 if configured in 64 bit datapath mode) are reserved at the end of the packet data. If the packet is bad and requires to be dropped, the status and statistics are the only information held on that packet. The receiver packet buffer will also detect a full condition so that an overflow condition can be detected. If this occurs, subsequent packets are dropped and an RX overflow interrupt is raised. For full store and forward, the DMA only begins packet fetches once the status and statistics for a frame are available. If the frame has a bad status due to a frame error, the status and statistics are passed onto the GMAC registers. If the frame has a good status, the information is used to read the frame from the packet buffer memory and burst onto the AHB using the DMA buffer management protocol. Once the last frame data has been transferred to the FIFO, the status and statistics are updated to the GMAC registers. If partial store and forward mode is active, the DMA will begin fetching the packet data before the status is available. As soon as the status becomes available, the DMA will fetch this information as soon as possible before continuing to fetch the remainder of the frame. Once the last frame data has been transferred to the FIFO, the status and statistics are updated to the GMAC registers.
835
34.5.3.9 Priority Queueing in the DMA The DMA by default uses a single transmit and receive queue. This means the list of transmit/receive buffer descriptors point to data buffers associated with a single transmit/receive data stream. When the DMA is configured to use packet buffer memories, the GMAC can optionally select up to 8 priority queues. Each queue has an independent list of buffer descriptors pointing to separate data streams. In the transmit direction, higher priority queues are always serviced before lower priority queues. This strict priority scheme requires the user to ensure that high priority traffic is constrained so that lower priority traffic will have required bandwidth. The GMAC DMA will determine the next queue to service by initiating a sequence of buffer descriptor reads interrogating the ownership bits of each. The buffer descriptor corresponding to the highest priority queue is read first. If the ownership bit of this descriptor is set, then the DMA will progress to reading the 2nd highest priority queue's descriptor. If that ownership bit read of this lower priority queue is set, then the DMA will read the 3rd highest priority queue's descriptor, and so on. If all the descriptors return an ownership bit set, then a resource error has occurred, an interrupt is generated and transmission is automatically halted. Transmission can only be restarted by setting the START bit in the Network Control Register. The GMAC DMA will need to identify the highest available queue to transmit from when the START bit in the Network Control Register is written to and the TX is in a halted state, or when the last word of any packet has been fetched from external AHB memory. The GMAC transmit DMA maximizes the effectiveness of priority queuing by ensuring that high priority traffic be transmitted as early as possible after being fetched from AHB. High priority traffic fetched from AHB will be pushed to the MAC layer before any lower priority traffic that may pre-exist in the transmit SRAM-based packet buffer. This is achieved by separating the transmit SRAM-based packet buffer into regions, one region per queue. The size of each region determines the amount of SRAM space allocated per queue. For each queue, there is an associated Transmit Buffer Queue Base Address Register. For the lowest priority queue (or the only queue when only 1 queue is selected), the Transmit Buffer Queue Base Address is located at address 0x1C. For all other queues, the Transmit Buffer Queue Base Address Registers are located at sequential addresses starting at address 0x440. In the receive direction each packet is written to AHB data buffers in the order that it is received. For each queue, there is an independent set of receive AHB buffers for each queue. There is therefore a separate Receive Buffer Queue Base Address Register for each queue. For the lowest priority queue (or the only queue when only one queue is selected), the Receive Buffer Queue Base Address is located at address 0x18. For all other queues, the Receive Buffer Queue Base Address Registers are located at sequential addresses starting at address 0x480. Every received packet will pass through a programmable screening algorithm which will allocate a particular queue to that frame. The user interface to the screeners is through two types of programmable registers.
z
Screener Type 1 Registers hold values to match against particular IP and UDP fields of the received frames. The fields used to match against are DS (Differentiated Services field of IPv4 frames), TC (Traffic class field of IPv6 frames) and/or the UDP destination port. Screener Type 2 Registers hold values to match against the VLAN priority field of the received frames.
Each screener type has an enable bit, a match pattern and a queue number. If a received frame matches on an enabled screener register, then the frame will be tagged with the queue value in the associated screener register, and forwarded onto the DMA and subsequently into the external memory associated with that queue. An APB address location is required for each screener register, and 16 of each type have been reserved in the default address map. If two screeners are matched then the one which resides at the lowest register address will take priority so care must be taken on the selection of the screener location. When the priority queuing feature is enabled, the number of interrupt outputs from the GMAC core is increased to match the number of supported queues. The number of Interrupt Status Registers is increased by the same number. Only DMA related events are reported using the individual interrupt outputs, as the GMAC can relate these events to specific queues. All other events generated within the GMAC are reported in the interrupt associated with the lowest priority queue. For the lowest priority queue (or the only queue when only 1 queue is selected), the Interrupt Status Register is located at address 0x24. For all other queues, the Interrupt Status Register is located at sequential addresses starting at address 0x400.
836
837
By setting when bit 28 is set in the Network Configuration Register, the Inter Packet Gap (IPG) may be stretched beyond 96 bits depending on the length of the previously transmitted frame and the value written to the IPG Stretch Register (GMAC_IPGS). The least significant 8 bits of the IPG Stretch Register multiply the previous frame length (including preamble). The next significant 8 bits (+1 so as not to get a divide by zero) divide the frame length to generate the IPG. IPG stretch only works in full duplex mode and when bit 28 is set in the Network Configuration Register. The IPG Stretch Register cannot be used to shrink the IPG below 96 bits. If the back pressure bit is set in the Network Control Register, or if the HDFC configuration bit is set in the GMAC_UR register (10M or 100M half duplex mode), the transmit block transmits 64 bits of data, which can consist of 16 nibbles of 1011 or in bit rate mode 64 1s, whenever it sees an incoming frame to force a collision. This provides a way of implementing flow control in half duplex mode. Note that this feature is not available in gigabit half duplex mode.
838
To calculate these checksums in software requires each byte of the packet to be processed. For TCP and UDP this can use a large amount of processing power. Offloading the checksum calculation to hardware can result in significant performance improvements. For IP, TCP or UDP checksum offload to be useful, the operating system containing the protocol stack must be aware that this offload is available so that it can make use of the fact that the hardware can either generate or verify the checksum. 34.5.6.1 Receiver Checksum Offload When receive checksum offloading is enabled in the GMAC, the IPv4 header checksum is checked as per RFC 791, where the packet meets the following criteria:
z z z z
If present, the VLAN header must be four octets long and the CFI bit must not be set. Encapsulation must be RFC 894 Ethernet Type Encoding or RFC 1042 SNAP Encoding. IPv4 packet. IP header is of a valid length.
The GMAC also checks the TCP checksum as per RFC 793, or the UDP checksum as per RFC 768, if the following criteria are met:
z z z z
IPv4 or IPv6 packet Good IP header checksum (if IPv4). No IP fragmentation. TCP or UDP packet.
When an IP, TCP or UDP frame is received, the receive buffer descriptor gives an indication if the GMAC was able to verify the checksums. There is also an indication if the frame had SNAP encapsulation. These indication bits will replace the type ID match indication bits when the receive checksum offload is enabled. For details of these indication bits refer to Table 34-2, Receive Buffer Descriptor Entry. If any of the checksums are verified as incorrect by the GMAC, the packet is discarded and the appropriate statistics counter incremented. 34.5.6.2 Transmitter Checksum Offload The transmitter checksum offload is only available if the GMAC is configured to use the DMA in packet buffer mode and full store and forward mode is enabled. This is because the complete frame to be transmitted must be read into the packet buffer memory before the checksum can be calculated and written back into the headers at the beginning of the frame. Transmitter checksum offload is enabled by setting bit [11] in the DMA Configuration Register. When enabled, it will monitor the frame as it is written into the transmitter packet buffer memory to automatically detect the protocol of the frame. Protocol support is identical to the receiver checksum offload. For transmit checksum generation and substitution to occur, the protocol of the frame must be recognized and the frame must be provided without the FCS field, by making sure that bit [16] of the transmit descriptor word 1 is clear. If the frame data already had the FCS field, this would be corrupted by the substitution of the new checksum fields. If these conditions are met, the transmit checksum offload engine will calculate the IP, TCP and UDP checksums as appropriate. Once the full packet is completely written into packet buffer memory, the checksums will be valid and the relevant DPRAM locations will be updated for the new checksum fields as per standard IP/TCP and UDP packet structures. If the transmitter checksum engine is prevented from generating the relevant checksums, bits [22:20] of the transmitter DMA writeback status will be updated to identify the reason for the error. Note that the frame will still be transmitted but without the checksum substitution, as typically the reason that the substitution did not occur was that the protocol was not recognized.
839
Note:
1.
840
The sequence above shows the beginning of an Ethernet frame. Byte order of transmission is from top to bottom as shown. For a successful match to specific address 1, the following address matching registers must be set up: Specific Address 1 Bottom [31:0] Register (GMAC_SAB1)(Address 0x088) 0x87654321 Specific Address 1 Top [47:32] Register (GMAC_SAT1) (Address 0x08C) 0x0000CBA9
And for a successful match to the type ID, the following type ID match 1 register must be set up: Type ID Match 1 Register (GMAC_TIDM1) (Address 0x0A8) 0x80004321
represents the most significant bit of the last byte received. If the hash index points to a bit that is set in the Hash Register then the frame will be matched according to whether the frame is multicast or unicast. A multicast match will be signalled if the multicast hash enable bit is set, da[0] is logic 1 and the hash index points to a bit set in the Hash Register. A unicast match will be signalled if the unicast hash enable bit is set, da[0] is logic 0 and the hash index points to a bit set in the Hash Register. To receive all multicast frames, the Hash Register should be set with all ones and the multicast hash enable bit should be set in the Network Configuration Register.
841
The VLAN tag is inserted at the 13th byte of the frame adding an extra four bytes to the frame. To support these extra four bytes, the GMAC can accept frame lengths up to 1536 bytes by setting bit 8 in the Network Configuration Register. If the VID (VLAN identifier) is null (0x000) this indicates a priority-tagged frame. The following bits in the receive buffer descriptor status word give information about VLAN tagged frames:z z z z
Bit 21 set if receive frame is VLAN tagged (i.e. type ID of 0x8100). Bit 20 set if receive frame is priority tagged (i.e. type ID of 0x8100 and null VID). (If bit 20 is set, bit 21 will be set also.) Bit 19, 18 and 17 set to priority if bit 21 is set. Bit 16 set to CFI if bit 21 is set.
The GMAC can be configured to reject all frames except VLAN tagged frames by setting the discard non-VLAN frames bit in the Network Configuration Register.
Magic packet Address Resolution Protocol (ARP) request to the device IP address Specific address 1 filter match Multicast hash filter match
These events can be individually enabled through bits [19:16] of the Wake on LAN Register. Also, for Wake on LAN detection to occur, receive enable must be set in the Network Control Register, however a receive buffer does not have to be available. In case of an ARP request, specific address 1 or multicast filter events will occur even if the frame is errored. For magic packet events, the frame must be correctly formed and error free. A magic packet event is detected if all of the following are true:
z z z z z
Magic packet events are enabled through bit 16 of the Wake on LAN Register The frame's destination address matches specific address 1 The frame is correctly formed with no errors The frame contains at least 6 bytes of 0xFF for synchronization There are 16 repetitions of the contents of Specific Address 1 Register immediately following the synchronization ARP request events are enabled through bit 17 of the Wake on LAN Register Broadcasts are allowed by bit 5 in the Network Configuration Register The frame has a broadcast destination address (bytes 1 to 6) The frame has a type ID field of 0x0806 (bytes 13 and 14) The frame has an ARP operation field of 0x0001 (bytes 21 and 22) The least significant 16 bits of the frame's ARP target protocol address (bytes 41 and 42) match the value programmed in bits[15:0] of the Wake on LAN Register
The decoding of the ARP fields adjusts automatically if a VLAN tag is detected within the frame. The reserved value of 0x0000 for the Wake on LAN target address value will not cause an ARP request event, even if matched by the frame.
842
A specific address 1 filter match event will occur if all of the following are true:
z z
Specific address 1 events are enabled through bit 18 of the Wake on LAN Register The frame's destination address matches the value programmed in the Specific Address 1 Registers Multicast hash events are enabled through bit 19 of the Wake on LAN Register Multicast hash filtering is enabled through bit 6 of the Network Configuration Register The frame destination address matches against the multicast hash filter The frame destination address is not a broadcast
A multicast filter match event will occur if all of the following are true:
z z z z
843
844
For 1588 version 1 messages, sync and delay request frames are indicated by the GMAC if the frame type field indicates TCP/IP, UDP protocol is indicated, the destination IP address is 224.0.1.129/130/131 or 132, the destination UDP port is 319 and the control field is correct. The control field is 0x00 for sync frames and 0x01 for delay request frames. For 1588 version 2 messages, the type of frame is determined by looking at the message type field in the first byte of the PTP frame. Whether a frame is version 1 or version 2 can be determined by looking at the version PTP field in the second byte of both version 1 and version 2 PTP frames. In version 2 messages sync frames have a message type value of 0x0, delay_req have 0x1, pdelay_req have 0x2 and pdelay_resp have 0x3. Example of a sync frame in the 1588 version 2 (UDP/IPv4) format
Preamble/SFD DA (Octets 0 - 5) SA (Octets 6 - 11) Type (Octets 12-13) IP stuff (Octets 14-22) UDP (Octet 23) IP stuff (Octets 24-29) IP DA (Octets 30-33) source IP port (Octets 34-35) dest IP port (Octets 36-37) other stuff (Octets 38-41) message type (Octet 42) version PTP (Octet 43) 00 02 013F E0000181 11 0800 55555555555555D5
845
Example of a sync frame in the 1588 version 2 (Ethernet multicast) format. For the multicast address 011B19000000 sync and delay request frames are recognized depending on the message type field, 00 for sync and 01 for delay request::
Preamble/SFD DA (Octets 0 - 5) SA (Octets 6 - 11) Type (Octets 12-13) message type (Octet 14) version PTP (Octet 15) 88F7 00 02 55555555555555D5 011B19000000
846
Example of a pdelay_req frame in the 1588 version 2 (Ethernet multicast) format, these need a special multicast address so they can get through ports blocked by the spanning tree protocol. For the multicast address 0180C200000E sync, pdelay request and pdelay response frames are recognized depending on the message type field, 00 for sync, 02 for pdelay request and 03 for pdelay response.
Preamble/SFD DA (Octets 0 - 5) SA (Octets 6 - 11) Type (Octets 12-13) message type (Octet 14) version PTP (Octet 15) 88F7 00 02 55555555555555D5 0180C200000E
847
The GMAC supports both hardware controlled pause of the transmitter, upon reception of a pause frame, and hardware generated pause frame transmission. 34.5.16.1 802.3 Pause Frame Reception Bit 13 of the Network Configuration Register is the pause enable control for reception. If this bit is set, transmission will pause if a non zero pause quantum frame is received. If a valid pause frame is received then the Pause Time Register is updated with the new frame's pause time, regardless of whether a previous pause frame is active or not. An interrupt (either bit 12 or bit 13 of the Interrupt Status Register) is triggered when a pause frame is received, but only if the interrupt has been enabled (bit 12 and bit 13 of the Interrupt Mask Register). Pause frames received with non zero quantum are indicated through the interrupt bit 12 of the Interrupt Status Register. Pause frames received with zero quantum are indicated on bit 13 of the Interrupt Status Register. Once the Pause Time Register is loaded and the frame currently being transmitted has been sent, no new frames are transmitted until the pause time reaches zero. The loading of a new pause time, and hence the pausing of transmission, only occurs when the GMAC is configured for full duplex operation. If the GMAC is configured for half duplex there will be no transmission pause, but the pause frame received interrupt will still be triggered. A valid pause frame is defined as having a destination address that matches either the address stored in Specific Address Register 1 or if it matches the reserved address of 0x0180C2000001. It must also have the MAC control frame type ID of 0x8808 and have the pause opcode of 0x0001. Pause frames that have frame check sequence (FCS) or other errors will be treated as invalid and will be discarded. 802.3 Pause frames that are received after Priority-based Flow Control (PFC) has been negotiated will also be discarded. Valid pause frames received will increment the pause frames received statistic register. The pause time register decrements every 512 bit times once transmission has stopped. For test purposes, the retry test bit can be set (bit 12 in the Network Configuration Register) which causes the Pause Time Register to decrement every GTXCK cycle once transmission has stopped. The interrupt (bit 13 in the Interrupt Status Register) is asserted whenever the Pause Time Register decrements to zero (assuming it has been enabled by bit 13 in the Interrupt Mask Register). This interrupt is also set when a zero quantum pause frame is received. 34.5.16.2 802.3 Pause Frame Transmission Automatic transmission of pause frames is supported through the transmit pause frame bits of the Network Control Register. If either bit 11 or bit 12 of the Network Control Register is written with logic 1, an 802.3 pause frame will be transmitted, providing full duplex is selected in the Network Configuration Register and the transmit block is enabled in the Network Control Register. Pause frame transmission will happen immediately if transmit is inactive or if transmit is active between the current frame and the next frame due to be transmitted. Transmitted pause frames comprise the following:
z z z z z z z
A destination address of 01-80-C2-00-00-01 A source address taken from Specific Address Register 1 A type ID of 88-08 (MAC control frame) A pause opcode of 00-01 A pause quantum register Fill of 00 to take the frame to minimum frame length Valid FCS
848
The pause quantum used in the generated frame will depend on the trigger source for the frame as follows:
z z
If bit 11 is written with a one, the pause quantum will be taken from the Transmit Pause Quantum Register. The Transmit Pause Quantum Register resets to a value of 0xFFFF giving maximum pause quantum as default. If bit 12 is written with a one, the pause quantum will be zero.
After transmission, a pause frame transmitted interrupt will be generated (bit 14 of the Interrupt Status Register) and the only statistics register that will be incremented will be the Pause Frames Transmitted Register. Pause frames can also be transmitted by the MAC using normal frame transmission methods.
The GMAC supports PFC priority-based pause transmission and reception. Before PFC pause frames can be received, bit 16 of the Network Control Register must be set. Note: Refer to the 802.1Qbb standard for a full description of priority-based pause operation.
34.5.17.1 PFC Pause Frame Reception The ability to receive and decode priority-based pause frames is enabled by setting bit 16 of the Network Control Register. When this bit is set, the GMAC will match either classic 802.3 pause frames or PFC priority-based pause frames. Once a priority-based pause frame has been received and matched, then from that moment on the GMAC will only match on priority-based pause frames (this is a 802.1Qbb requirement, known as PFC negotiation). Once prioritybased pause has been negotiated, any received 802.3x format pause frames will not be acted upon. If a valid priority-based pause frame is received then the GMAC will decode the frame and determine which, if any, of the 8 priorities require to be paused. Up to 8 Pause Time Registers are then updated with the 8 pause times extracted from the frame regardless of whether a previous pause operation is active or not. An interrupt (either bit 12 or bit 13 of the Interrupt Status Register) is triggered when a pause frame is received, but only if the interrupt has been enabled (bit 12 and bit 13 of the Interrupt Mask Register). Pause frames received with non zero quantum are indicated through the interrupt bit 12 of the Interrupt Status Register. Pause frames received with zero quantum are indicated on bit 13 of the Interrupt Status Register. The loading of a new pause time only occurs when the GMAC is configured for full duplex operation. If the GMAC is configured for half duplex, the pause time counters will not be loaded, but the pause frame received interrupt will still be triggered. A valid pause frame is defined as having a destination address that matches either the address stored in Specific Address Register 1 or if it matches the reserved address of 0x0180C2000001. It must also have the MAC control frame type ID of 0x8808 and have the pause opcode of 0x0101. Pause frames that have frame check sequence (FCS) or other errors will be treated as invalid and will be discarded. Valid pause frames received will increment the Pause Frames Received Statistic Register. The Pause Time Registers decrement every 512 bit times immediately following the PFC frame reception. For test purposes, the retry test bit can be set (bit 12 in the Network Configuration Register) which causes the Pause Time Register to decrement every GRXCK cycle once transmission has stopped. The interrupt (bit 13 in the Interrupt Status Register) is asserted whenever the Pause Time Register decrements to zero (assuming it has been enabled by bit 13 in the Interrupt Mask Register). This interrupt is also set when a zero quantum pause frame is received.
849
34.5.17.2 PFC Pause Frame Transmission Automatic transmission of pause frames is supported through the transmit priority-based pause frame bit of the Network Control Register. If bit 17 of the Network Control Register is written with logic 1, a PFC pause frame will be transmitted providing full duplex is selected in the Network Configuration Register and the transmit block is enabled in the Network Control Register. When bit 17 of the Network Control Register is set, the fields of the priority-based pause frame will be built using the values stored in the Transmit PFC Pause Register. Pause frame transmission will happen immediately if transmit is inactive or if transmit is active between the current frame and the next frame due to be transmitted. Transmitted pause frames comprise the following:
z z z z z z z z
A destination address of 01-80-C2-00-00-01 A source address taken from Specific Address Register 1 A type ID of 88-08 (MAC control frame) A pause opcode of 01-01 A priority enable vector taken from Transmit PFC Pause Register 8 pause quantum registers Fill of 00 to take the frame to minimum frame length Valid FCS If bit 17 of the Network Control Register is written with a one, then the priority enable vector of the priority-based pause frame will be set equal to the value stored in the Transmit PFC Pause Register [7:0]. For each entry equal to zero in the Transmit PFC Pause Register[15:8], the pause quantum field of the pause frame associated with that entry will be taken from the transmit pause quantum register. For each entry equal to one in the Transmit PFC Pause Register[15:8], the pause quantum associated with that entry will be zero. The Transmit Pause Quantum Register resets to a value of 0xFFFF giving maximum pause quantum as default.
The pause quantum registers used in the generated frame will depend on the trigger source for the frame as follows:
z
After transmission, a pause frame transmitted interrupt will be generated (bit 14 of the Interrupt Status Register) and the only statistics register that will be incremented will be the Pause Frames Transmitted Register. PFC Pause frames can also be transmitted by the MAC using normal frame transmission methods.
The GMII and RGMII should only be used for 1000 Mbps operation. The MII interface is provided for 10/100 operation and uses txd[3:0] and rxd[3:0].
850
34.6
Programming Interface
34.6.1 Initialization
34.6.1.1 Configuration Initialization of the GMAC configuration (e.g. loop back mode, frequency ratios) must be done while the transmit and receive circuits are disabled. See the description of the Network Control Register and Network Configuration Register earlier in this document. To change loop back mode, the following sequence of operations must be followed: 1. 2. 3. Note: Write to Network Control Register to disable transmit and receive circuits. Write to Network Control Register to change loop back mode. Write to Network Control Register to re-enable transmit or receive circuits. These writes to Network Control Register cannot be combined in any way.
34.6.1.2 Receive Buffer List Receive data is written to areas of data (i.e. buffers) in system memory. These buffers are listed in another data structure that also resides in main memory. This data structure (receive buffer queue) is a sequence of descriptor entries as defined in Table 34-2, Receive Buffer Descriptor Entry The Receive Buffer Queue Pointer Register points to this data structure.
Figure 34-3. Receive Buffer List
Receive Buffer 0 Receive Buffer Queue Pointer (MAC Register) Receive Buffer 1
Receive Buffer N Receive Buffer Descriptor List (In memory) (In memory)
To create the list of buffers: 1. 2. 3. 4. 5. Allocate a number (N) of buffers of X bytes in system memory, where X is the DMA buffer length programmed in the DMA Configuration Register. Allocate an area 8N bytes for the receive buffer descriptor list in system memory and create N entries in this list. Mark all entries in this list as owned by GMAC, i.e., bit 0 of word 0 set to 0. Mark the last descriptor in the queue with the wrap bit (bit 1 in word 0 set to 1). Write address of receive buffer descriptor list and control information to GMAC register receive buffer queue pointer The receive circuits can then be enabled by writing to the address recognition registers and the Network Control Register.
851
34.6.1.3 Transmit Buffer List Transmit data is read from areas of data (the buffers) in system memory. These buffers are listed in another data structure that also resides in main memory. This data structure (Transmit Buffer Queue) is a sequence of descriptor entries as defined in Table 34-3, Transmit Buffer Descriptor Entry. The Transmit Buffer Queue Pointer Register points to this data structure. To create this list of buffers: 1. 2. 3. 4. 5. Allocate a number (N) of buffers of between 1 and 2047 bytes of data to be transmitted in system memory. Up to 128 buffers per frame are allowed. Allocate an area 8N bytes for the transmit buffer descriptor list in system memory and create N entries in this list. Mark all entries in this list as owned by GMAC, i.e., bit 31 of word 1 set to 0. Mark the last descriptor in the queue with the wrap bit (bit 30 in word 1 set to 1). Write address of transmit buffer descriptor list and control information to GMAC register transmit buffer queue pointer. The transmit circuits can then be enabled by writing to the Network Control Register.
34.6.1.4 Address Matching The GMAC register pair hash address and the four Specific Address Register-pairs must be written with the required values. Each register pair comprises of a bottom register and top register with the bottom register being written first. The address matching is disabled for a particular register pair after the bottom register has been written and re-enabled when the top register is written. Each register pair may be written at any time, regardless of whether the receive circuits are enabled or disabled. As an example, to set Specific Address Register 1 to recognize destination address 21:43:65:87:A9:CB, the following values are written to Specific Address Register 1 bottom and Specific Address Register 1 top:
z z
Specific Address Register 1 bottom bits 31:0 (0x98): 8765_4321 hex. Specific Address Register 1 top bits 31:0 (0x9C): 0000_cba9 hex.
34.6.1.5 PHY Maintenance The PHY Maintenance Register is implemented as a shift register. Writing to the register starts a shift operation which is signalled as complete when bit two is set in the Network Status Register (about 2000 MCK cycles later when bits [18:16] are set to 010 in the Network Configuration Register). An interrupt is generated as this bit is set. During this time, the MSB of the register is output on the MDIO pin and the LSB updated from the MDIO pin with each Management Data Clock (MDC) cycle. This causes the transmission of a PHY management frame on MDIO. See section 22.2.4.5 of the IEEE 802.3 standard. Reading during the shift operation will return the current contents of the shift register. At the end of the management operation the bits will have shifted back to their original locations. For a read operation the data bits are updated with data read from the PHY. It is important to write the correct values to the register to ensure a valid PHY management frame is produced. The Management Data Clock (MDC) should not toggle faster than 2.5 MHz (minimum period of 400 ns), as defined by the IEEE 802.3 standard. MDC is generated by dividing down MCK. Three bits in the Network Configuration Register determine by how much MCK should be divided to produce MDC. 34.6.1.6 Interrupts There are 18 interrupt conditions that are detected within the GMAC. These are ORed to make a single interrupt (or multiple interrupts if priority queuing is enabled). Depending on the overall system design this may be passed through a further level of interrupt collection (interrupt controller). On receipt of the interrupt signal, the CPU enters the interrupt handler. Refer to the device interrupt controller documentation to identify that it is the GMAC that is generating the interrupt. To ascertain which interrupt, read the Interrupt Status Register. Note that in the default configuration this register will clear itself after being read, though this may be configured to be write-one-to-clear if desired.
852
At reset all interrupts are disabled. To enable an interrupt, write to Interrupt Enable Register with the pertinent interrupt bit set to 1. To disable an interrupt, write to Interrupt Disable Register with the pertinent interrupt bit set to 1. To check whether an interrupt is enabled or disabled, read Interrupt Mask Register. If the bit is set to 1, the interrupt is disabled. 34.6.1.7 Transmitting Frames To set up a frame for transmission: 1. 2. 3. 4. 5. 6. 7. Enable transmit in the Network Control Register. Allocate an area of system memory for transmit data. This does not have to be contiguous, varying byte lengths can be used if they conclude on byte borders. Set-up the transmit buffer list by writing buffer addresses to word zero of the transmit buffer descriptor entries and control and length to word one. Write data for transmission into the buffers pointed to by the descriptors. Write the address of the first buffer descriptor to transmit buffer descriptor queue pointer. Enable appropriate interrupts. Write to the transmit start bit (TSTART) in the Network Control Register.
34.6.1.8 Receiving Frames When a frame is received and the receive circuits are enabled, the GMAC checks the address and, in the following cases, the frame is written to system memory:
z z z z z
If it matches one of the four Specific Address Registers. If it matches one of the four type ID registers. If it matches the hash address function. If it is a broadcast address (0xFFFFFFFFFFFF) and broadcasts are allowed. If the GMAC is configured to copy all frames.
The register receive buffer queue pointer points to the next entry in the receive buffer descriptor list and the GMAC uses this as the address in system memory to write the frame to. Once the frame has been completely and successfully received and written to system memory, the GMAC then updates the receive buffer descriptor entry (see Table 34-2, Receive Buffer Descriptor Entry) with the reason for the address match and marks the area as being owned by software. Once this is complete, a receive complete interrupt is set. Software is then responsible for copying the data to the application area and releasing the buffer (by writing the ownership bit back to 0). If the GMAC is unable to write the data at a rate to match the incoming frame, then a receive overrun interrupt is set. If there is no receive buffer available, i.e., the next buffer is still owned by software, a receive buffer not available interrupt is set. If the frame is not successfully received, a Statistics Register is incremented and the frame is discarded without informing software.
853
These registers reset to zero on a read and stick at all ones when they count to their maximum value. They should be read frequently enough to prevent loss of data. In order to reduce overall design area, the Statistics Registers may be optionally removed in the configuration file if they are deemed unnecessary for a particular design. The Receive Statistics Registers are only incremented when the receive enable bit is set in the Network Control Register. Once a Statistics Register has been read, it is automatically cleared. When reading the Octets Transmitted and Octets Received Registers, bits 31:0 should be read prior to bits 47:32 to ensure reliable operation.
854
34.7
Table 34-7. Register Mapping Offset 0x000 0x004 0x008 0x00C 0x010 0x014 0x018 0x01C 0x020 0x024 0x028 0x02C 0x030 0x034 0x038 0x03C 0x040 0x044 0x048-0x07C 0x080 0x084 0x088 0x08C 0x090 0x094 0x098 0x09C 0x0A0 0x0A4 0x0A8 0x0AC 0x0B0 0x0B4 0x0B8 0x0BC Register Network Control Register Network Configuration Register Network Status Register User Register DMA Configuration Register Transmit Status Register Receive Buffer Queue Base Address Transmit Buffer Queue Base Address Receive Status Register Interrupt Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register PHY Maintenance Register Received Pause Quantum Register Transmit Pause Quantum Register TX Partial Store and Forward Register RX Partial Store and Forward Register Reserved Hash Register Bottom [31:0] Hash Register Top [63:32] Specific Address 1 Bottom [31:0] Register Specific Address 1 Top [47:32] Register Specific Address 2 Bottom [31:0] Register Specific Address 2 Top [47:32] Register Specific Address 3 Bottom [31:0] Register Specific Address 3 Top [47:32] Register Specific Address 4 Bottom [31:0] Register Specific Address 4 Top [47:32] Register Type ID Match 1 Register Type ID Match 2 Register Type ID Match 3 Register Type ID Match 4 Register Wake on LAN Register IPG Stretch Register Name GMAC_NCR GMAC_NCFGR GMAC_NSR GMAC_UR GMAC_DCFGR GMAC_TSR GMAC_RBQB GMAC_TBQB GMAC_RSR GMAC_ISR GMAC_IER GMAC_IDR GMAC_IMR GMAC_MAN GMAC_RPQ GMAC_TPQ GMAC_TPSF GMAC_RPSF GMAC_HRB GMAC_HRT GMAC_SAB1 GMAC_SAT1 GMAC_SAB2 GMAC_SAT2 GMAC_SAB3 GMAC_SAT3 GMAC_SAB4 GMAC_SAT4 GMAC_TIDM1 GMAC_TIDM2 GMAC_TIDM3 GMAC_TIDM4 GMAC_WOL GMAC_IPGS Access Read-write Read-write Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-only Write-only Write-only Read-only Read-write Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Reset 0x0000_0000 0x0008_0000 0b01x0 0x0000_0000 0x0002_0004 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x07FF_FFFF 0x0000_0000 0x0000_0000 0x0000_FFFF 0x0000_0FFF 0x0000_0FFF 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000
855
Table 34-7. Register Mapping (Continued) Offset 0x0C0 0x0C4 0x0C8 0x0CC 0x0FC 0x100 0x104 0x108 0x10C 0x110 0x114 0x118 0x11C 0x120 0x124 0x128 0x12C 0x130 0x134 0x138 0x13C 0x140 0x144 0x148 0x14C 0x150 0x154 0x158 0x15C 0x160 0x164 0x168 0x16C 0x170 0x174 0x178 0x17C Register Stacked VLAN Register Transmit PFC Pause Register Specific Address 1 Mask Bottom [31:0] Register Specific Address 1 Mask Top [47:32] Register Reserved Octets Transmitted [31:0] Register Octets Transmitted [47:32] Register Frames Transmitted Register Broadcast Frames Transmitted Register Multicast Frames Transmitted Register Pause Frames Transmitted Register 64 Byte Frames Transmitted Register 65 to 127 Byte Frames Transmitted Register 128 to 255 Byte Frames Transmitted Register 256 to 511 Byte Frames Transmitted Register 512 to 1023 Byte Frames Transmitted Register 1024 to 1518 Byte Frames Transmitted Register Greater Than 1518 Byte Frames Transmitted Register Transmit Under Runs Register Single Collision Frames Register Multiple Collision Frames Register Excessive Collisions Register Late Collisions Register Deferred Transmission Frames Register Carrier Sense Errors Register Octets Received [31:0] Received Octets Received [47:32] Received Frames Received Register Broadcast Frames Received Register Multicast Frames Received Register Pause Frames Received Register 64 Byte Frames Received Register 65 to 127 Byte Frames Received Register 128 to 255 Byte Frames Received Register 256 to 511Byte Frames Received Register 512 to 1023 Byte Frames Received Register 1024 to 1518 Byte Frames Received Register Name GMAC_SVLAN GMAC_TPFCP GMAC_SAMB1 GMAC_SAMT1 GMAC_OTLO GMAC_OTHI GMAC_FT GMAC_BCFT GMAC_MFT GMAC_PFT GMAC_BFT64 GMAC_TBFT127 GMAC_TBFT255 GMAC_TBFT511 GMAC_TBFT1023 GMAC_TBFT1518 GMAC_GTBFT1518 GMAC_TUR GMAC_SCF GMAC_MCF GMAC_EC GMAC_LC GMAC_DTF GMAC_CSE GMAC_ORLO GMAC_ORHI GMAC_FR GMAC_BCFR GMAC_MFR GMAC_PFR GMAC_BFR64 GMAC_TBFR127 GMAC_TBFR255 GMAC_TBFR511 GMAC_TBFR1023 GMAC_TBFR1518 Access Read-write Read-write Read-write Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Reset 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000
856
Table 34-7. Register Mapping (Continued) Offset 0x180 0x184 0x188 0x18C 0x190 0x194 0x198 0x19C 0x1A0 0x1A4 0x1A8 0x1AC 0x1B0 0x1C8 0x1CC 0x1D0 0x1D4 0x1D8 0x1DC 0x1E0 0x1E4 0x1E8 0x1EC 0x1F0 0x1F4 0x1F8 0x1FC 0x200-0x23C 0x280-0x298 0x400 ... 0x418 0x440 ... 0x458 0x480 Register 1519 to Maximum Byte Frames Received Register Undersize Frames Received Register Oversize Frames Received Register Jabbers Received Register Frame Check Sequence Errors Register Length Field Frame Errors Register Receive Symbol Errors Register Alignment Errors Register Receive Resource Errors Register Receive Overrun Register IP Header Checksum Errors Register TCP Checksum Errors Register UDP Checksum Errors Register 1588 Timer Sync Strobe Seconds Register 1588 Timer Sync Strobe Nanoseconds Register 1588 Timer Seconds Register 1588 Timer Nanoseconds Register 1588 Timer Adjust Register 1588 Timer Increment Register PTP Event Frame Transmitted Seconds PTP Event Frame Transmitted Nanoseconds PTP Event Frame Received Seconds PTP Event Frame Received Nanoseconds PTP Peer Event Frame Transmitted Seconds PTP Peer Event Frame Transmitted Nanoseconds PTP Peer Event Frame Received Seconds PTP Peer Event Frame Received Nanoseconds Reserved Reserved Interrupt Status Register Priority Queue 0 ... Interrupt Status Register Priority Queue 6 Transmit Buffer Queue Base Address Priority Queue 0 ... Transmit Buffer Queue Base Address Priority Queue 6 Receive Buffer Queue Base Address Priority Queue 0 Name GMAC_TMXBFR GMAC_UFR GMAC_OFR GMAC_JR GMAC_FCSE GMAC_LFFE GMAC_RSE GMAC_AE GMAC_RRE GMAC_ROE GMAC_IHCE GMAC_TCE GMAC_UCE GMAC_TSSS GMAC_TSSN GMAC_TS GMAC_TN GMAC_TA GMAC_TI GMAC_EFTS GMAC_EFTN GMAC_EFRS GMAC_EFRN GMAC_PEFTS GMAC_PEFTN GMAC_PEFRS GMAC_PEFRN GMAC_ISRPQ0 ... GMAC_ISRPQ6 GMAC_TBQBAPQ0 ... GMAC_TBQBAPQ6 GMAC_RBQBAPQ0 Access Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-write Read-write Read-write Read-write Write-only Read-write Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only Read-only ... Read-only Read-write ... Read-write Read-write 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 ... 0x0000_0000 0x0000_0000 ... 0x0000_0000 0x0000_0000 Reset 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000
857
Table 34-7. Register Mapping (Continued) Offset ... 0x498 0x4a0 ... 0x4b8 0x500 ... 0x53c 0x540 ... 0x57c 0x600 ... 0x618 0x620 ... 0x638 0x640 ... 0x658 Register ... Receive Buffer Queue Base Address Priority Queue 6 Receive Buffer Size Register Priority Queue 0 ... Receive Buffer Size Register Priority Queue 6 Screening Type1 Register Priority Queue 0 ... Screening Type1 Register Priority Queue 15 Screening Type2 Register Priority Queue 0 ... Screening Type2 Register Priority Queue 15 Interrupt Enable Register Priority Queue 0 ... Interrupt Enable Register Priority Queue 6 Interrupt Disable Register Priority Queue 0 ... Interrupt Disable Register Priority Queue 6 Interrupt Mask Register Priority Queue 0 ... Interrupt Mask Register Priority Queue 6 Name ... GMAC_RBQBAPQ6 GMAC_RBSRPQ0 ... GMAC_RBSRPQ6 GMAC_ST1RPQ0 ... GMAC_ST1RPQ15 GMAC_ST2RPQ0 ... GMAC_ST2RPQ15 GMAC_IERPQ0 ... GMAC_IERPQ6 GMAC_IDRPQ0 ... GMAC_IDRPQ6 GMAC_IMRPQ0 ... GMAC_IMRPQ6 Access ... Read-write Read-write ... Read-write Read-write ... Read-write Read-write ... Read-write Write-only ... Write-only Write-only ... Write-only Read-write ... Read-write Reset ... 0x0000_0000 0x0000_0002 ... 0x0000_0002 0x0000_0000 ... 0x0000_0000 0x0000_0000 ... 0x0000_0000 0x0000_0000 ... 0x0000_0000 0x0000_0000 ... 0x0000_0000 0x0000_0000 ... 0x0000_0000
858
23
22
21
20
19
16 ENPBPR 8 BP 0
15 SRTSM 7 WESTAT
14 RDS 6 INCSTAT
13 5 CLRSTAT
12 TXZQPF 4 MPE
11 TXPF 3 TXEN
859
860
10 GBE 2 DNVLAN
SPD: Speed
Set to logic one to indicate 100 Mbps operation, logic zero for 10 Mbps.
NBC: No Broadcast
When set to logic one, frames addressed to the broadcast address of all ones will not be accepted.
861
862
863
23
22
21
20
19
18
17
16
15
14
13
12
11
10
2 IDLE
1 MDIO
864
865
23
22
21
19
18
17
15 7 ESPA
14 6 ESMA
13 5
12 4
11 TXCOEN 3
10 TXPBMS 2 FBLDO
9 RXBMS 1
1/2 Kbyte Memory Size 1Kbyte Memory Size 2 Kbytes Memory Size 4 Kbytes Memory Size
866
For example: 0x02: 128 bytes 0x18: 1536 bytes (1*max length frame/buffer) 0xA0: 10240 bytes (1*10K jumbo frame/buffer) Note that this value should never be written as zero. DDRP: DMA Discard Receive Packets
When set, the GMAC DMA will automatically discard receive packets from the receiver packet buffer memory when no AHB resource is available. When low, the received packets will remain to be stored in the SRAM based packet buffer until AHB buffer resource next becomes available. A write to this bit is ignored if the DMA is not configured in the packet buffer full store and forward mode.
867
23
22
21
20
19
18
17
16
15
14
13
12 4 TFC
11
10
8 HRESP 0 UBR
7 LCO
6 UND
5 TXCOMP
3 TXGO
2 RLE
1 COL
TXGO: Transmit Go
Transmit go, if high transmit is active. When using FIFO, this bit represents bit 3 of the Network Control Register. When using the DMA interface this bit represents the TXGO variable as specified in the transmit buffer description.
868
869
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
5 ADDR
This register holds the start address of the receive buffer queue (receive buffers descriptor list). The receive buffer queue base address must be initialized before receive is enabled through bit 2 of the Network Control Register. Once reception is enabled, any write to the Receive Buffer Queue Base Address Register is ignored. Reading this register returns the location of the descriptor currently being accessed. This value increments as buffers are used. Software should not use this register for determining where to remove received frames from the queue as it constantly changes as new frames are received. Software should instead work its way through the buffer descriptor queue checking the used bits. In terms of AMBA AHB operation, the descriptors are read from memory using a single 32-bit AHB access. When the datapath is configured at 64 bits, the descriptors should be aligned at 64-bit boundaries and each pair of 32-bit descriptors is written to by using a single AHB access. The descriptors should be aligned at 32-bit boundaries and the descriptors are written to using two individual non sequential accesses for 32-bit datapaths.
870
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
5 ADDR
This register holds the start address of the transmit buffer queue (transmit buffers descriptor list). The Transmit Buffer Queue Base Address Register must be initialized before transmit is started through bit 9 of the Network Control Register. Once transmission has started, any write to the Transmit Buffer Queue Base Address Register is illegal and therefore ignored. Note that due to clock boundary synchronization, it takes a maximum of four MCK cycles from the writing of the transmit start bit before the transmitter is active. Writing to the Transmit Buffer Queue Base Address Register during this time may produce unpredictable results. Reading this register returns the location of the descriptor currently being accessed. Since the DMA handles two frames at once, this may not necessarily be pointing to the current frame being transmitted. In terms of AMBA AHB operation, the descriptors are written to memory using a single 32-bit AHB access. When the datapath is configured at 64 bits, the descriptors should be aligned at 64-bit boundaries and each pair of 32-bit descriptors is read from memory using a single AHB access. The descriptors should be aligned at 32-bit boundaries and the descriptors are read from memory using two individual non sequential accesses for 32-bit datapaths.
871
23
22
21
20
19
18
17
16
15
14
13
12
11
10
3 HNO
2 RXOVR
1 REC
0 BNA
This register, when read provides details of the status of a receive. Once read, individual bits may be cleared by writing 1 to them. It is not possible to set a bit to 1 by writing to the register.
872
This register indicates the source of the interrupt. In order the bits of this register are read to 1, the corresponding interrupt source must be enabled in the mask register. If any bit is set in this register, the GMAC interrupt signal will be asserted in the system.
873
874
At reset all interrupts are disabled. Writing a one to the relevant bit location enables the required interrupt. This register is write only and when read will return zero.
875
876
Writing a 1 to the relevant bit location disables that particular interrupt. This register is write only and when read will return zero.
877
878
The Interrupt Mask Register is a read-only register indicating which interrupts are masked. All bits are set at reset and can be reset individually by writing to the Interrupt Enable Register or set individually by writing to the Interrupt Disable Register. Having separate address locations for enable and disable saves the need for performing a read modify write when updating the Interrupt Mask Register. For test purposes there is a write-only function to this register that allows the bits in the Interrupt Status Register to be set or cleared, regardless of the state of the mask register.
879
A write to this register directly affects the state of the corresponding bit in the Interrupt Status Register, causing an interrupt to be generated if a 1 is written.
880
881
882
14
13
The PHY Maintenance Register is implemented as a shift register. Writing to the register starts a shift operation which is signalled as complete when bit 2 is set in the Network Status Register. It takes about 2000 MCK cycles to complete, when MDC is set for MCK divide by 32 in the Network Configuration Register. An interrupt is generated upon completion. During this time, the MSB of the register is output on the MDIO pin and the LSB updated from the MDIO pin with each MDC cycle. This causes transmission of a PHY management frame on MDIO. See Section 22.2.4.5 of the IEEE 802.3 standard. Reading during the shift operation will return the current contents of the shift register. At the end of management operation, the bits will have shifted back to their original locations. For a read operation, the data bits will be updated with data read from the PHY. It is important to write the correct values to the register to ensure a valid PHY management frame is produced. The MDIO interface can read IEEE 802.3 clause 45 PHYs as well as clause 22 PHYs. To read clause 45 PHYs, bit 30 should be written with a 0 rather than a 1. For a description of MDC generation, see Section 34.7.2 Network Configuration Register.
883
23
22
21
20
19
18
17
16
15
14
13
12 RPQ
11
10
4 RPQ
23
22
21
20
19
18
17
16
15
14
13
12 TPQ
11
10
4 TPQ
884
Partial store and forward is only applicable when using the AHB DMA configured in SRAM based packet buffer mode. It is also not available when the priority queueing feature is enabled.
885
Partial store and forward is only applicable when using the AHB DMA configured in SRAM based packet buffer mode. It is also not available when the priority queueing feature is enabled.
886
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
The unicast hash enable (UNIHEN) and the multicast hash enable (MITIHEN) bits in the Network Configuration Register (Section 34.7.2 Network Configuration Register) enable the reception of hash matched frames. See Section 34.5.9 Hash Addressing.
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
The unicast hash enable (UNIHEN) and the multicast hash enable (MITIHEN) bits in the Network Configuration Register enable the reception of hash matched frames. See Section 34.5.9 Hash Addressing.
887
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
888
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
889
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
890
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
The addresses stored in the Specific Address Registers are deactivated at reset or when their corresponding Specific Address Register Bottom is written. They are activated when Specific Address Register Top is written.
891
GMAC_TIDM1 Read-write
30 22 14 29 21 13 28 20 12 TID 7 6 5 4 TID 3 2 1 0 27 19 11 26 18 10 25 17 9 24 16 8
GMAC_TIDM2 Read-write
30 22 14 29 21 13 28 20 12 TID 7 6 5 4 TID 3 2 1 0 27 19 11 26 18 10 25 17 9 24 16 8
892
GMAC_TIDM3 Read-write
30 22 14 29 21 13 28 20 12 TID 7 6 5 4 TID 3 2 1 0 27 19 11 26 18 10 25 17 9 24 16 8
GMAC_TIDM4 Read-write
30 22 14 29 21 13 28 20 12 TID 7 6 5 4 TID 3 2 1 0 27 19 11 26 18 10 25 17 9 24 16 8
893
23
22
21
20
19 MTI 11 IP
18 SA1 10
17 ARP 9
16 MAG 8
15
14
13
12
4 IP
894
895
896
897
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
898
23
22
21
20 TXO
19
18
17
16
15
14
13
12 TXO
11
10
4 TXO
When reading the Octets Transmitted and Octets Received Registers, bits 31:0 should be read prior to bits 47:32 to ensure reliable operation.
23
22
21
20
19
18
17
16
15
14
13
12 TXO
11
10
4 TXO
When reading the Octets Transmitted and Octets Received Registers, bits 31:0 should be read prior to bits 47:32 to ensure reliable operation.
899
23
22
21
20 FTX
19
18
17
16
15
14
13
12 FTX
11
10
4 FTX
23
22
21
20 BFTX
19
18
17
16
15
14
13
12 BFTX
11
10
4 BFTX
900
23
22
21
20 MFTX
19
18
17
16
15
14
13
12 MFTX
11
10
4 MFTX
901
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
902
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
903
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
904
23
22
21
20 NFTX
19
18
17
16
15
14
13
12 NFTX
11
10
4 NFTX
905
906
907
908
23
22
21
20 RXO
19
18
17
16
15
14
13
12 RXO
11
10
4 RXO
When reading the Octets Transmitted and Octets Received Registers, bits [31:0] should be read prior to bits [47:32] to ensure reliable operation.
23
22
21
20
19
18
17
16
15
14
13
12 RXO
11
10
4 RXO
When reading the Octets Transmitted and Octets Received Registers, bits 31:0 should be read prior to bits 47:32 to ensure reliable operation.
909
23
22
21
20 FRX
19
18
17
16
15
14
13
12 FRX
11
10
4 FRX
23
22
21
20 BFRX
19
18
17
16
15
14
13
12 BFRX
11
10
4 BFRX
910
23
22
21
20 MFRX
19
18
17
16
15
14
13
12 MFRX
11
10
4 MFRX
911
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
912
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
913
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
914
23
22
21
20 NFRX
19
18
17
16
15
14
13
12 NFRX
11
10
4 NFRX
915
916
917
918
919
920
921
922
923
924
925
926
927
23
22
21
20 VTS
19
18
17
16
15
14
13
12 VTS
11
10
4 VTS
15
14
13
12 VTN
11
10
4 VTN
928
23
22
21
20 TCS
19
18
17
16
15
14
13
12 TCS
11
10
4 TCS
15
14
13
12 TNS
11
10
4 TNS
929
15
14
13
12 ITDT
11
10
4 ITDT
ITDT: Increment/Decrement
The number of nanoseconds to increment or decrement the 1588 Timer Nanoseconds Register. If necessary, the 1588 Seconds Register will be incremented or decremented.
930
15
14
13
12 AC NS
11
10
4 CNS
931
23
22
21
20 RUD
19
18
17
16
15
14
13
12 RUD
11
10
4 RUD
15
14
13
12 RUD
11
10
4 RUD
932
23
22
21
20 RUD
19
18
17
16
15
14
13
12 RUD
11
10
4 RUD
15
14
13
12 RUD
11
10
4 RUD
933
23
22
21
20 RUD
19
18
17
16
15
14
13
12 RUD
11
10
4 RUD
15
14
13
12 RUD
11
10
4 RUD
934
23
22
21
20 RUD
19
18
17
16
15
14
13
12 RUD
11
10
4 RUD
935
15
14
13
12 RUD
11
10
4 RUD
936
23
22
21
20
19
18
17
16
15
14
13
12
11 HRESP 3
10 ROVR 2 RXUBR
9 1 RCOMP
8 0
7 TCOMP
6 TFC
5 RLEX
RCOMP: Receive Complete RXUBR: RX Used Bit Read RLEX: Retry Limit Exceeded or Late Collision TFC: Transmit Frame Corruption due to AHB error
Transmit frame corruption due to AHB error - set if an error occurs whilst midway through reading transmit frame from the AHB, including HRESP errors and buffers exhausted mid frame
937
23
22
21
20
19
18
17
16
15
14
13
12
11
10
5 TXBQBA
These 7 registers hold the start address of the transmit buffer queues (transmit buffers descriptor lists) for the additional queues used when priority queues are employed.
938
23
22
21
20
19
18
17
16
15
14
13
12
11
10
5 RXBQBA
These 7 registers hold the start address of the receive buffer queues (receive buffers descriptor lists) for the additional queues used when priority queues are employed.
939
There are seven receive buffer size registers, one per priority que.
0x02: 128 bytes 0x18: 1536 bytes (1*max length frame/buffer) 0xA0: 10240 bytes (1*10K jumbo frame/buffer)
Note that this value should never be written as zero.
940
15
14 UDPM
13
12
11
10 DSTCM
6 DSTCM
2 QNB
Screening type 1 registers are used to allocate up to 8 priority queues to received frames based on certain IP or UDP fields of incoming frames.
1. When DS/TC match enable is set (bit 28), the DS (Differentiated Services) field of the received IPv4 header or TC field (traffic class) of IPv6 headers are matched against bits 11:4. 2. When UDP port match enable is set (bit 29), the UDP Destination Port of the received UDP frame is matched against bits 27:12. Both UDP and DS/TC matching can be enabled simultaneously or individually.
If a match is successful, then the queue value programmed in bits 3:0 is allocated to the frame. The required number of Type 1 screening registers is configured in the gem defines file. Up to 16 type 1 screening registers have been allocated APB address space.
941
Screening type 2 registers are used to allocate up to 8 priority queues to received frames based on the VLAN priority field of received ethernet frames. When VLAN match enable is set (bit 8), the VLAN priority field of the received frame is matched against bits [7:4] of this register. If a match is successful, then the queue value programmed in bits [3:0] is allocated to the frame. The required number of Type 2 screening registers is configured in the gem defines file. Up to 16 type 2 screening registers have been allocated APB address space.
942
23
22
21
20
19
18
17
16
15
14
13
12
11 HRESP 3
10 ROVR 2 RXUBR
9 1 RCOMP
8 0
7 TCOMP
6 TFC
5 RLEX
For each priority queue there are seven interrupt enable registers.
943
23
22
21
20
19
18
17
16
15
14
13
12
11 HRESP 3
10 ROVR 2 RXUBR
9 1 RCOMP
8 0
7 TCOMP
6 TFC
5 RLEX
For each priority queue there are seven interrupt disable registers.
944
23
22
21
20
19
18
17
16
15
14
13
12
11 HRESP 3
10 ROVR 2 RXUBR
9 1 RCOMP
8 0
7 TCOMP
6 AHB
5 RLEX
945
946
35.
35.1
35.2
Embedded Characteristics
z z z z z z z z z z z z z z z z z z z z
Supports RMII Interface to the physical layer Compatible with IEEE Standard 802.3 10 and 100 Mbit/s Operation Full-duplex and Half-duplex Operation Statistics Counter Registers Interrupt Generation to Signal Receive and Transmit Completion DMA Master on Receive and Transmit Channels Transmit and Receive FIFOs Automatic Pad and CRC Generation on Transmitted Frames Automatic Discard of Frames Received with Errors Address Checking Logic Supports Up to Four Specific 48-bit Addresses Supports Promiscuous Mode Where All Valid Received Frames are Copied to Memory Hash Matching of Unicast and Multicast Destination Addresses Physical Layer Management through MDIO Interface Half-duplex Flow Control by Forcing Collisions on Incoming Frames Full-duplex Flow Control with Recognition of Incoming Pause Frames Support for 802.1Q VLAN Tagging with Recognition of Incoming VLAN and Priority Tagged Frames Multiple Buffers per Receive and Transmit Frame Wake-on-LAN Support Jumbo Frames Up to 10240 bytes Supported
947
35.3
Block Diagram
Address Checker
APB Slave
Register Interface
Statistics Registers
MDIO
Control Registers
DMA Interface
RX FIFO TX FIFO
Ethernet Receive
AHB Master MII/RMII
Ethernet Transmit
948
35.4
Functional Description
The MACB has several clock domains:
z z z
System bus clock (AHB and APB): DMA and register blocks Transmit clock: transmit block Receive clock: receive and address checker block
The system bus clock must run at least as fast as the receive clock and transmit clock (25 MHz at 100 Mbps, and 2.5 MHZ at 10 Mbps). Figure 35-1 illustrates the different blocks of the EMAC module. The control registers drive the MDIO interface, setup up DMA activity, start frame transmission and select modes of operation such as full- or half-duplex. The receive block checks for valid preamble, FCS, alignment and length, and presents received frames to the address checking block and DMA interface. The transmit block takes data from the DMA interface, adds preamble and, if necessary, pad and FCS, and transmits data according to the CSMA/CD (carrier sense multiple access with collision detect) protocol. The start of transmission is deferred if CRS (carrier sense) is active. If COL (collision) becomes active during transmission, a jam sequence is asserted and the transmission is retried after a random back off. CRS and COL have no effect in full duplex mode. The DMA block connects to external memory through its AHB bus interface. It contains receive and transmit FIFOs for buffering frame data. It loads the transmit FIFO and empties the receive FIFO using AHB bus master operations. Receive data is not sent to memory until the address checking logic has determined that the frame should be copied. Receive or transmit frames are stored in one or more buffers. Receive buffers have a fixed length of 128 bytes. Transmit buffers range in length between 0 and 2047 bytes, and up to 128 buffers are permitted per frame. The DMA block manages the transmit and receive framebuffer queues. These queues can hold multiple frames.
35.4.1 Clock
Synchronization module in the EMAC requires that the bus clock (MCK) runs at the speed of the macb_tx/rx_clk at least, which is 25 MHz at 100 Mbps, and 2.5 MHz at 10 Mbps.
949
Thus the bus latency must be less than the time it takes to load the FIFO and transmit or receive three words (112 bytes) of data. At 100 Mbit/s, it takes 8960 ns to transmit or receive 112 bytes of data. In addition, six master clock cycles should be allowed for data to be loaded from the bus and to propagate through the FIFOs. For a 133 MHz master clock this takes 45 ns, making the bus latency requirement 8915 ns. 35.4.2.2 Receive Buffers Received frames, including CRC/FCS optionally, are written to receive buffers stored in memory. Each receive buffer is 128 bytes long. The start location for each receive buffer is stored in memory in a list of receive buffer descriptors at a location pointed to by the receive buffer queue pointer register. The receive buffer start location is a word address. For the first buffer of a frame, the start location can be offset by up to three bytes depending on the value written to bits 14 and 15 of the network configuration register. If the start location of the buffer is offset the available length of the first buffer of a frame is reduced by the corresponding number of bytes. Each list entry consists of two words, the first being the address of the receive buffer and the second being the receive status. If the length of a receive frame exceeds the buffer length, the status word for the used buffer is written with zeroes except for the start of frame bit and the offset bits, if appropriate. Bit zero of the address field is written to one to show the buffer has been used. The receive buffer manager then reads the location of the next receive buffer and fills that with receive frame data. The final buffer descriptor status word contains the complete frame status. Refer to Table 35-1 for details of the receive buffer descriptor list.
Table 35-1. Receive Buffer Descriptor Entry Bit Function Word 0 31:2 1 0 Address of beginning of buffer Wrap - marks last descriptor in receive buffer descriptor list. Ownership - needs to be zero for the EMAC to write data to the receive buffer. The EMAC sets this to one once it has successfully written a frame to memory. Software has to clear this bit before the buffer can be used again. Word 1 31 30 29 28 27 26 25 24 23 22 21 20 19:17 16 15 Global all ones broadcast address detected Multicast hash match Unicast hash match External address match Reserved for future use Specific address register 1 match Specific address register 2 match Specific address register 3 match Specific address register 4 match Type ID match VLAN tag detected (i.e., type id of 0x8100) Priority tag detected (i.e., type id of 0x8100 and null VLAN identifier) VLAN priority (only valid if bit 21 is set) Concatenation format indicator (CFI) bit (only valid if bit 21 is set) End of frame - when set the buffer contains the end of a frame. If end of frame is not set, then the only other valid status are bits 12, 13 and 14.
950
Table 35-1. Receive Buffer Descriptor Entry (Continued) Bit 14 Function Start of frame - when set the buffer contains the start of a frame. If both bits 15 and 14 are set, then the buffer contains a whole frame. Receive buffer offset - indicates the number of bytes by which the data in the first buffer is offset from the word address. Updated with the current values of the network configuration register. If jumbo frame mode is enabled through bit 3 of the network configuration register, then bits 13:12 of the receive buffer descriptor entry are used to indicate bits 13:12 of the frame length. Length of frame including FCS (if selected). Bits 13:12 are also used if jumbo frame mode is selected.
13:12
11:0
To receive frames, the buffer descriptors must be initialized by writing an appropriate address to bits 31 to 2 in the first word of each list entry. Bit zero must be written with zero. Bit one is the wrap bit and indicates the last entry in the list. The start location of the receive buffer descriptor list must be written to the receive buffer queue pointer register before setting the receive enable bit in the network control register to enable receive. As soon as the receive block starts writing received frame data to the receive FIFO, the receive buffer manager reads the first receive buffer location pointed to by the receive buffer queue pointer register. If the filter block then indicates that the frame should be copied to memory, the receive data DMA operation starts writing data into the receive buffer. If an error occurs, the buffer is recovered. If the current buffer pointer has its wrap bit set or is the 1024th descriptor, the next receive buffer location is read from the beginning of the receive descriptor list. Otherwise, the next receive buffer location is read from the next word in memory. There is an 11-bit counter to count out the 2048 word locations of a maximum length, receive buffer descriptor list. This is added with the value originally written to the receive buffer queue pointer register to produce a pointer into the list. A read of the receive buffer queue pointer register returns the pointer value, which is the queue entry currently being accessed. The counter is reset after receive status is written to a descriptor that has its wrap bit set or rolls over to zero after 1024 descriptors have been accessed. The value written to the receive buffer pointer register may be any word-aligned address, provided that there are at least 2048 word locations available between the pointer and the top of the memory. Section 3.6 of the AMBA 2.0 specification states that bursts should not cross 1K boundaries. As receive buffer manager writes are bursts of two words, to ensure that this does not occur, it is best to write the pointer register with the least three significant bits set to zero. As receive buffers are used, the receive buffer manager sets bit zero of the first word of the descriptor to indicate used. If a receive error is detected the receive buffer currently being written is recovered. Previous buffers are not recovered. Software should search through the used bits in the buffer descriptors to find out how many frames have been received. It should be checking the start-of-frame and end-of-frame bits, and not rely on the value returned by the receive buffer queue pointer register which changes continuously as more buffers are used. For CRC errored frames, excessive length frames or length field mismatched frames, all of which are counted in the statistics registers, it is possible that a frame fragment might be stored in a sequence of receive buffers. Software can detect this by looking for start of frame bit set in a buffer following a buffer with no end of frame bit set. For a properly working Ethernet system, there should be no excessively long frames or frames greater than 128 bytes with CRC/FCS errors. Collision fragments are less than 128 bytes long. Therefore, it is a rare occurrence to find a frame fragment in a receive buffer. If bit zero is set when the receive buffer manager reads the location of the receive buffer, then the buffer has already been used and cannot be used again until software has processed the frame and cleared bit zero. In this case, the DMA block sets the buffer not available bit in the receive status register and triggers an interrupt. If bit zero is set when the receive buffer manager reads the location of the receive buffer and a frame is being received, the frame is discarded and the receive resource error statistics register is incremented. A receive overrun condition occurs when bus was not granted in time or because HRESP was not OK (bus error). In a receive overrun condition, the receive overrun interrupt is asserted and the buffer currently being written is recovered. The next frame received with an address that is recognized reuses the buffer. If bit 17 of the network configuration register is set, the FCS of received frames shall not be copied to memory. The frame length indicated in the receive status field shall be reduced by four bytes in this case.
951
35.4.2.3 Transmit Buffer Frames to be transmitted are stored in one or more transmit buffers. Transmit buffers can be between 0 and 2047 bytes long, so it is possible to transmit frames longer than the maximum length specified in IEEE Standard 802.3. Zero length buffers are allowed. The maximum number of buffers permitted for each transmit frame is 128. The start location for each transmit buffer is stored in memory in a list of transmit buffer descriptors at a location pointed to by the transmit buffer queue pointer register. Each list entry consists of two words, the first being the byte address of the transmit buffer and the second containing the transmit control and status. Frames can be transmitted with or without automatic CRC generation. If CRC is automatically generated, pad is also automatically generated to take frames to a minimum length of 64 bytes. Table 35-2 on page 952 defines an entry in the transmit buffer descriptor list. To transmit frames, the buffer descriptors must be initialized by writing an appropriate byte address to bits 31 to 0 in the first word of each list entry. The second transmit buffer descriptor is initialized with control information that indicates the length of the buffer, whether or not it is to be transmitted with CRC and whether the buffer is the last buffer in the frame. After transmission, the control bits are written back to the second word of the first buffer along with the used bit and other status information. Bit 31 is the used bit which must be zero when the control word is read if transmission is to happen. It is written to one when a frame has been transmitted. Bits 27, 28 and 29 indicate various transmit error conditions. Bit 30 is the wrap bit which can be set for any buffer within a frame. If no wrap bit is encountered after 1024 descriptors, the queue pointer rolls over to the start in a similar fashion to the receive queue. The transmit buffer queue pointer register must not be written while transmit is active. If a new value is written to the transmit buffer queue pointer register, the queue pointer resets itself to point to the beginning of the new queue. If transmit is disabled by writing to bit 3 of the network control, the transmit buffer queue pointer register resets to point to the beginning of the transmit queue. Note that disabling receive does not have the same effect on the receive queue pointer. Once the transmit queue is initialized, transmit is activated by writing to bit 9, the Transmit Start bit of the network control register. Transmit is halted when a buffer descriptor with its used bit set is read, or if a transmit error occurs, or by writing to the transmit halt bit of the network control register. (Transmission is suspended if a pause frame is received while the pause enable bit is set in the network configuration register.) Rewriting the start bit while transmission is active is allowed. Transmission control is implemented with a Tx_go variable which is readable in the transmit status register at bit location 3. The Tx_go variable is reset when:
z z z z z
Transmit is disabled A buffer descriptor with its ownership bit set is read A new value is written to the transmit buffer queue pointer register Bit 10, tx_halt, of the network control register is written There is a transmit error such as too many retries or a transmit underrun.
To set tx_go, write to bit 9, tx_start, of the network control register. Transmit halt does not take effect until any ongoing transmit finishes. If a collision occurs during transmission of a multi-buffer frame, transmission automatically restarts from the first buffer of the frame. If a used bit is read midway through transmission of a multi-buffer frame, this is treated as a transmit error. Transmission stops, tx_er is asserted and the FCS is bad. If transmission stops due to a transmit error, the transmit queue pointer resets to point to the beginning of the transmit queue. Software needs to re-initialize the transmit queue after a transmit error. If transmission stops due to a used bit being read at the start of the frame, the transmission queue pointer is not reset and transmit starts from the same transmit buffer descriptor when the transmit start bit is written.
Table 35-2. Transmit Buffer Descriptor Entry Bit Function Word 0 31:0 Byte Address of buffer Word 1
952
Table 35-2. Transmit Buffer Descriptor Entry Bit Function Used. Needs to be zero for the EMAC to read data from the transmit buffer. The EMAC sets this to one for the first buffer of a frame once it has been successfully transmitted. 31 Software has to clear this bit before the buffer can be used again.
Note:
30 29 28 27 26:17 16 15 14:11 10:0
This bit is only set for the first buffer in a frame unlike receive where all buffers have the Used bit set once used.
Wrap. Marks last descriptor in transmit buffer descriptor list. Retry limit exceeded, transmit error detected Transmit underrun, occurs either when hresp is not OK (bus error) or the transmit data could not be fetched in time or when buffers are exhausted in mid frame. Buffers exhausted in mid frame Reserved No CRC. When set, no CRC is appended to the current frame. This bit only needs to be set for the last buffer of a frame. Last buffer. When set, this bit indicates the last buffer in the current frame has been reached. Reserved Length of buffer
953
The network configuration register contains a receive pause enable bit (13). If a valid pause frame is received, the pause time register is updated with the frames pause time, regardless of its current contents and regardless of the state of the configuration register bit 13. An interrupt (12) is triggered when a pause frame is received, assuming it is enabled in the interrupt mask register. If bit 13 is set in the network configuration register and the value of the pause time register is nonzero, no new frame is transmitted until the pause time register has decremented to zero. The loading of a new pause time, and hence the pausing of transmission, only occurs when the EMAC is configured for full-duplex operation. If the EMAC is configured for half-duplex, there is no transmission pause, but the pause frame received interrupt is still triggered. A valid pause frame is defined as having a destination address that matches either the address stored in specific address register 1 or matches 0x0180C2000001 and has the MAC control frame type ID of 0x8808 and the pause opcode of 0x0001. Pause frames that have FCS or other errors are treated as invalid and are discarded. Valid pause frames received increment the Pause Frame Received statistic register. The pause time register decrements every 512 bit times (i.e., 128 rx_clks in nibble mode) once transmission has stopped. For test purposes, the register decrements every rx_clk cycle once transmission has stopped if bit 12 (retry test) is set in the network configuration register. If the pause enable bit (13) is not set in the network configuration register, then the decrementing occurs regardless of whether transmission has stopped or not. An interrupt (13) is asserted whenever the pause time register decrements to zero (assuming it is enabled in the interrupt mask register).
954
Ethernet frames are transmitted a byte at a time, least significant bit first. The first six bytes (48 bits) of an Ethernet frame make up the destination address. The first bit of the destination address, the LSB of the first byte of the frame, is the group/individual bit: this is One for multicast addresses and Zero for unicast. The All Ones address is the broadcast address, and a special case of multicast. The EMAC supports recognition of four specific addresses. Each specific address requires two registers, specific address register bottom and specific address register top. Specific address register bottom stores the first four bytes of the destination address and specific address register top contains the last two bytes. The addresses stored can be specific, group, local or universal. The destination address of received frames is compared against the data stored in the specific address registers once they have been activated. The addresses are deactivated at reset or when their corresponding specific address register bottom is written. They are activated when specific address register top is written. If a receive frame address matches an active address, the frame is copied to memory. The following example illustrates the use of the address match registers for a MAC address of 21:43:65:87:A9:CB. Preamble 55 SFD D5 DA (Octet0 - LSB) 21 DA(Octet 1) 43 DA(Octet 2) 65 DA(Octet 3) 87 DA(Octet 4) A9 DA (Octet5 - MSB) CB SA (LSB) 00 SA 00 SA 00 SA 00 SA 00 SA (MSB) 43 SA (LSB) 21 The sequence above shows the beginning of an Ethernet frame. Byte order of transmission is from top to bottom as shown. For a successful match to specific address 1, the following address matching registers must be set up:
z z
Base address + 0x98 0x87654321 (Bottom) Base address + 0x9C 0x0000CBA9 (Top) Base address + 0xB8 0x00004321
And for a successful match to the Type ID register, the following should be set up:
z
955
hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47] hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46] hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45] hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44] hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43] hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42]
da[0] represents the least significant bit of the first byte received, that is, the multicast/unicast indicator, and da[47] represents the most significant bit of the last byte received. If the hash index points to a bit that is set in the hash register, then the frame is matched according to whether the frame is multicast or unicast. A multicast match is signalled if the multicast hash enable bit is set. da[0] is 1 and the hash index points to a bit set in the hash register. A unicast match is signalled if the unicast hash enable bit is set. da[0] is 0 and the hash index points to a bit set in the hash register. To receive all multicast frames, the hash register should be set with all ones and the multicast hash enable bit should be set in the network configuration register.
The VLAN tag is inserted at the 13th byte of the frame, adding an extra four bytes to the frame. If the VID (VLAN identifier) is null (0x000), this indicates a priority-tagged frame. The MAC can support frame lengths up to 1536 bytes, 18 bytes more than the original Ethernet maximum frame length of 1518 bytes. This is achieved by setting bit 8 in the network configuration register. The following bits in the receive buffer descriptor status word give information about VLAN tagged frames:
z z z z
Bit 21 set if receive frame is VLAN tagged (i.e. type id of 0x8100) Bit 20 set if receive frame is priority tagged (i.e. type id of 0x8100 and null VID). (If bit 20 is set bit 21 is set also.) Bit 19, 18 and 17 set to priority if bit 21 is set Bit 16 set to CFI if bit 21 is set
956
Magic packet ARP request to the device IP address Specific address 1 filter match Multicast hash filter match
If one of these events occurs Wake-on-LAN detection is indicated by asserting the wol output pin for 64 rx_clk cycles. These events can be individually enabled through bits[19:16] of the Wake-on-LAN register. Also, for Wake-onLAN detection to occur, receive enable must be set in the network control register, however a receive buffer does not have to be available. wol assertion due to ARP request, specific address 1 or multicast filter events occurs even if the frame is errored. For magic packet events, the frame must be correctly formed and error free. A magic packet event is detected if all of the following are true:
z z z z z
Magic packet events are enabled through bit 16 of the Wake-on-LAN register The frames destination address matches specific address 1 The frame is correctly formed with no errors The frame contains at least 6 bytes of 0xFF for synchronization There are 16 repetitions of the contents of specific address 1 register immediately following the synchronization ARP request events are enabled through bit 17 of the Wake-on-LAN register Broadcasts are allowed by bit 5 in the network configuration register The frame has a broadcast destination address (bytes 1 to 6) The frame has a type ID field of 0x0806 (bytes 13 and 14) The frame has an ARP operation field of 0x0001 (bytes 21 and 22) The least significant 16 bits of the frames ARP target protocol address (bytes 41 and 42) match the value programmed in bits[15:0] of the Wake-on-LAN register
The decoding of the ARP fields adjusts automatically if a VLAN tag is detected within the frame. The reserved value of 0x0000 for the Wake-on-LAN target address value does not cause an ARP request event, even if matched by the frame. A specific address 1 filter match event occurs if all of the following are true:
z z
Specific address 1 events are enabled through bit 18 of the Wake-on-LAN register The frames destination address matches the value programmed in the specific address 1 registers Multicast hash events are enabled through bit 19 of the Wake-on-LAN register Multicast hash filtering is enabled through bit 6 of the network configuration register The frames destination address matches against the multicast hash filter The frames destination address is not a broadcast
A multicast filter match event occurs if all of the following are true:
z z z z
957
Reading during the shift operation returns the current contents of the shift register. At the end of management operation, the bits have shifted back to their original locations. For a read operation, the data bits are updated with data read from the PHY. It is important to write the correct values to the register to ensure a valid PHY management frame is produced. The MDIO interface can read IEEE 802.3 clause 45 PHYs as well as clause 22 PHYs. To read clause 45 PHYs, bits[31:28] should be written as 0x0011. For a description of MDC generation, see the network configuration register in the Network Control Register on page 964.
The intent of the RMII is to provide a reduced pin count alternative to the IEEE 802.3u MII. It uses 2 bits for transmit (ETX0 and ETX1) and two bits for receive (ERX0 and ERX1). There is a Transmit Enable (ETXEN), a Receive Error (ERXER), a Carrier Sense (ECRS_DV), and a 50 MHz Reference Clock (ETXCK_EREFCK) for 100Mb/s data rate. 35.4.14.1 RMII Transmit and Receive Operation The RMII maps the signals in a more pin-efficient manner. The transmit and receive bits are converted from a 4-bit parallel format to a 2-bit parallel scheme that is clocked at twice the rate. The carrier sense and data valid signals are combined into the ECRSDV signal. This signal contains information on carrier sense, FIFO status, and validity of the data. Transmit error bit (ETXER) and collision detect (ECOL) are not used in RMII mode.
958
35.5
Programming Interface
35.5.1 Initialization
35.5.1.1 Configuration Initialization of the EMAC configuration (e.g., loop-back mode, frequency ratios) must be done while the transmit and receive circuits are disabled. See the description of the network control register and network configuration register earlier in this document. To change loop-back mode, the following sequence of operations must be followed: 1. 2. 3. Note: Write to network control register to disable transmit and receive circuits. Write to network control register to change loop-back mode. Write to network control register to re-enable transmit or receive circuits. These writes to network control register cannot be combined in any way.
35.5.1.2 Receive Buffer List Receive data is written to areas of data (i.e., buffers) in system memory. These buffers are listed in another data structure that also resides in main memory. This data structure (receive buffer queue) is a sequence of descriptor entries as defined in Receive Buffer Descriptor Entry on page 950. It points to this data structure.
Figure 35-2. Receive Buffer List
Receive Buffer 0 Receive Buffer Queue Pointer (MAC Register) Receive Buffer 1
Receive Buffer N Receive Buffer Descriptor List (In memory) (In memory)
To create the list of buffers: 1. 2. 3. 4. 5. Allocate a number (n) of buffers of 128 bytes in system memory. Allocate an area 2n words for the receive buffer descriptor entry in system memory and create n entries in this list. Mark all entries in this list as owned by EMAC, i.e., bit 0 of word 0 set to 0. If less than 1024 buffers are defined, the last descriptor must be marked with the wrap bit (bit 1 in word 0 set to 1). Write address of receive buffer descriptor entry to EMAC register receive_buffer queue pointer. The receive circuits can then be enabled by writing to the address recognition registers and then to the network control register.
959
35.5.1.3 Transmit Buffer List Transmit data is read from areas of data (the buffers) in system memory These buffers are listed in another data structure that also resides in main memory. This data structure (Transmit Buffer Queue) is a sequence of descriptor entries (as defined in Table 35-2 on page 952) that points to this data structure. To create this list of buffers: 1. 2. 3. 4. 5. Allocate a number (n) of buffers of between 1 and 2047 bytes of data to be transmitted in system memory. Up to 128 buffers per frame are allowed. Allocate an area 2n words for the transmit buffer descriptor entry in system memory and create N entries in this list. Mark all entries in this list as owned by EMAC, i.e. bit 31 of word 1 set to 0. If fewer than 1024 buffers are defined, the last descriptor must be marked with the wrap bit bit 30 in word 1 set to 1. Write address of transmit buffer descriptor entry to EMAC register transmit_buffer queue pointer. The transmit circuits can then be enabled by writing to the network control register.
35.5.1.4 Address Matching The EMAC register-pair hash address and the four specific address register-pairs must be written with the required values. Each register-pair comprises a bottom register and top register, with the bottom register being written first. The address matching is disabled for a particular register-pair after the bottom-register has been written and re-enabled when the top register is written. See Address Checking Block on page 954. for details of address matching. Each register-pair may be written at any time, regardless of whether the receive circuits are enabled or disabled. 35.5.1.5 Interrupts There are 15 interrupt conditions that are detected within the EMAC. These are ORed to make a single interrupt. Depending on the overall system design, this may be passed through a further level of interrupt collection (interrupt controller). On receipt of the interrupt signal, the CPU enters the interrupt handler (Refer to the Interrupt Controller). To ascertain which interrupt has been generated, read the interrupt status register. Note that this register clears itself when read. At reset, all interrupts are disabled. To enable an interrupt, write to interrupt enable register with the pertinent interrupt bit set to 1. To disable an interrupt, write to interrupt disable register with the pertinent interrupt bit set to 1. To check whether an interrupt is enabled or disabled, read interrupt mask register: if the bit is set to 1, the interrupt is disabled. 35.5.1.6 Transmitting Frames To set up a frame for transmission: 1. 2. 3. 4. 5. 6. 7. 8. Enable transmit in the network control register. Allocate an area of system memory for transmit data. This does not have to be contiguous, varying byte lengths can be used as long as they conclude on byte borders. Set-up the transmit buffer list. Set the network control register to enable transmission and enable interrupts. Write data for transmission into these buffers. Write the address to transmit buffer descriptor queue pointer. Write control and length to word one of the transmit buffer descriptor entry. Write to the transmit start bit in the network control register.
35.5.1.7 Receiving Frames When a frame is received and the receive circuits are enabled, the EMAC checks the address and, in the following cases, the frame is written to system memory:
z z z z
If it matches one of the four specific address registers. If it matches the hash address function. If it is a broadcast address (0xFFFFFFFFFFFF) and broadcasts are allowed. If the EMAC is configured to copy all frames.
960
The register receive buffer queue pointer points to the next entry (see Table 35-1 on page 950) and the EMAC uses this as the address in system memory to write the frame to. Once the frame has been completely and successfully received and written to system memory, the EMAC then updates the receive buffer descriptor entry with the reason for the address match and marks the area as being owned by software. Once this is complete an interrupt receive complete is set. Software is then responsible for handling the data in the buffer and then releasing the buffer by writing the ownership bit back to 0. If the EMAC is unable to write the data at a rate to match the incoming frame, then an interrupt receive overrun is set. If there is no receive buffer available, i.e., the next buffer is still owned by software, the interrupt receive buffer not available is set. If the frame is not successfully received, a statistic register is incremented and the frame is discarded without informing software.
961
35.6
Table 35-6. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 0x5C 0x60 0x64 0x68 0x6C 0x70 0x74 0x78 0x7C 0x80 0x84 0x88 Register Network Control Register Network Configuration Register Network Status Register Reserved Reserved Transmit Status Register Receive Buffer Queue Pointer Register Transmit Buffer Queue Pointer Register Receive Status Register Interrupt Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Phy Maintenance Register Pause Time Register Pause Frames Received Register Frames Transmitted Ok Register Single Collision Frames Register Multiple Collision Frames Register Frames Received Ok Register Frame Check Sequence Errors Register Alignment Errors Register Deferred Transmission Frames Register Late Collisions Register Excessive Collisions Register Transmit Underrun Errors Register Carrier Sense Errors Register Receive Resource Errors Register Receive Overrun Errors Register Receive Symbol Errors Register Excessive Length Errors Register Receive Jabbers Register Undersize Frames Register SQE Test Errors Register Received Length Field Mismatch Register EMAC_TSR EMAC_RBQP EMAC_TBQP EMAC_RSR EMAC_ISR EMAC_IER EMAC_IDR EMAC_IMR EMAC_MAN EMAC_PTR EMAC_PFR EMAC_FTO EMAC_SCF EMAC_MCF EMAC_FRO EMAC_FCSE EMAC_ALE EMAC_DTF EMAC_LCOL EMAC_ECOL EMAC_TUND EMAC_CSE EMAC_RRE EMAC_ROV EMAC_RSE EMAC_ELE EMAC_RJA EMAC_USF EMAC_STE EMAC_RLE Read-write Read-write Read-write Read-write Read-write Write-only Write-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_7FFF 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 Name EMAC_NCR EMAC_NCFGR EMAC_NSR Access Read-write Read-write Read-only Reset 0 0x800 -
962
Table 35-6. Register Mapping (Continued) Offset 0x90 0x94 0x98 0x9C 0xA0 0xA4 0xA8 0xAC 0xB0 0xB4 0xB8 0xC0 0xC4 0xC8 - 0xFC Register Hash Register Bottom [31:0] Register Hash Register Top [63:32] Register Specific Address 1 Bottom Register Specific Address 1 Top Register Specific Address 2 Bottom Register Specific Address 2 Top Register Specific Address 3 Bottom Register Specific Address 3 Top Register Specific Address 4 Bottom Register Specific Address 4 Top Register Type ID Checking Register User Input/Output Register Wake on LAN Register Reserved Name EMAC_HRB EMAC_HRT EMAC_SA1B EMAC_SA1T EMAC_SA2B EMAC_SA2T EMAC_SA3B EMAC_SA3T EMAC_SA4B EMAC_SA4T EMAC_TID EMAC_USRIO EMAC_WOL Access Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Reset 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000 0x0000_0000
963
LB: LoopBack Asserts the loopback signal to the PHY. LLB: Loopback local
Connects txd to rxd, tx_en to rx_dv, forces full duplex and drives rx_clk and tx_clk with MCK divided by 4. rx_clk and tx_clk may glitch as the EMAC is switched into and out of internal loop back. It is important that receive and transmit circuits have already been disabled when making the switch into and out of internal loop back.
RE: Receive enable When set, enables the EMAC to receive data. When reset, frame reception stops immediately and the receive FIFO is cleared. The receive queue pointer register is unaffected. TE: Transmit enable When set, enables the Ethernet transmitter to send data. When reset transmission, stops immediately, the transmit FIFO and control registers are cleared and the transmit queue pointer register resets to point to the start of the transmit descriptor list. MPE: Management port enable Set to one to enable the management port. When zero, forces MDIO to high impedance state and MDC low. CLRSTAT: Clear statistics registers This bit is write only. Writing a one clears the statistics registers. INCSTAT: Increment statistics registers This bit is write only. Writing a one increments all the statistics registers by one for test purposes. WESTAT: Write enable for statistics registers Setting this bit to one makes the statistics registers writable for functional test purposes. BP: Back pressure If set in half duplex mode, forces collisions on all received frames. TSTART: Start transmission Writing one to this bit starts transmission. THALT: Transmit halt Writing one to this bit halts transmission as soon as any ongoing frame transmission ends.
964
SPD: Speed
Set to 1 to indicate 100 Mbit/s operation, 0 for 10 Mbit/s. The value of this pin is reflected on the speed pin.
NBC: No Broadcast
When set to 1, frames addressed to the broadcast address of all ones are not received.
965
.
Value 0 1 2 3 Name MCK_8 MCK_16 MCK_32 MCK_64 Description MCK divided by 8 (MCK up to 20 MHz). MCK divided by 16 (MCK up to 40 MHz). MCK divided by 32 (MCK up to 80 MHz). MCK divided by 64 (MCK up to 160 MHz).
EFRHD:
Enable Frames to be received in half-duplex mode while transmitting.
966
MDIO
Returns status of the mdio_in pin. Use the PHY maintenance register for reading managed frames rather than this bit.
IDLE
0 = The PHY logic is running. 1 = The PHY management logic is idle (i.e., has completed).
967
This register, when read, provides details of the status of a transmit. Once read, individual bits may be cleared by writing 1 to them. It is not possible to set a bit to 1 by writing to the register.
TGO: Transmit Go
If high transmit is active.
968
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
5 ADDR
This register points to the entry in the receive buffer queue (descriptor list) currently being used. It is written with the start location of the receive buffer descriptor list. The lower order bits increment as buffers are used up and wrap to their original values after either 1024 buffers or when the wrap bit of the entry is set. Reading this register returns the location of the descriptor currently being accessed. This value increments as buffers are used. Software should not use this register for determining where to remove received frames from the queue as it constantly changes as new frames are received. Software should instead work its way through the buffer descriptor queue checking the used bits. Receive buffer writes also comprise bursts of two words and, as with transmit buffer reads, it is recommended that bit 2 is always written with zero to prevent a burst crossing a 1K boundary, in violation of section 3.6 of the AMBA specification.
969
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
5 ADDR
This register points to the entry in the transmit buffer queue (descriptor list) currently being used. It is written with the start location of the transmit buffer descriptor list. The lower order bits increment as buffers are used up and wrap to their original values after either 1024 buffers or when the wrap bit of the entry is set. This register can only be written when bit 3 in the transmit status register is low. As transmit buffer reads consist of bursts of two words, it is recommended that bit 2 is always written with zero to prevent a burst crossing a 1K boundary, in violation of section 3.6 of the AMBA specification.
970
This register, when read, provides details of the status of a receive. Once read, individual bits may be cleared by writing 1 to them. It is not possible to set a bit to 1 by writing to the register.
971
972
973
TXERR
Enable transmit buffers exhausted in mid-frame interrupt.
974
975
TXERR
Disable transmit buffers exhausted in mid-frame interrupt.
976
977
TXERR
Transmit buffers exhausted in mid-frame interrupt masked.
978
979
14
13
DATA
For a write operation this is written with the data to be written to the PHY. After a read operation this contains the data read from the PHY.
CODE:
Must be written to 10. Reads as written.
980
981
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
ADDR:
Bits 31:0 of the hash address register. See Hash Addressing on page 955.
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
ADDR:
Bits 63:32 of the hash address register. See Hash Addressing on page 955.
982
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
ADDR
Least significant bits of the destination address. Bit zero indicates whether the address is multicast or unicast and corresponds to the least significant bit of the first byte received.
ADDR
The most significant bits of the destination address, that is bits 47 to 32.
983
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
ADDR
Least significant bits of the destination address. Bit zero indicates whether the address is multicast or unicast and corresponds to the least significant bit of the first byte received.
ADDR
The most significant bits of the destination address, that is bits 47 to 32.
984
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
ADDR
Least significant bits of the destination address. Bit zero indicates whether the address is multicast or unicast and corresponds to the least significant bit of the first byte received.
ADDR
The most significant bits of the destination address, that is bits 47 to 32.
985
23
22
21
20 ADDR
19
18
17
16
15
14
13
12 ADDR
11
10
4 ADDR
ADDR
Least significant bits of the destination address. Bit zero indicates whether the address is multicast or unicast and corresponds to the least significant bit of the first byte received.
ADDR
The most significant bits of the destination address, that is bits 47 to 32.
986
987
988
EMAC_WOL Read-write
30 22 14 29 21 13 28 20 12 IP 7 6 5 4 IP 3 2 1 0 27 19 MTI 11 26 18 SA1 10 25 17 ARP 9 24 16 MAG 8
989
990
15
14
13
12 FTOK
11
10
4 FTOK
991
992
15
14
13
12 FROK
11
10
4 FROK
993
994
995
996
997
998
999
1000
36.
36.1
Using EAV/SAV for synchronization reduces the pin count (ISI_VSYNC, ISI_HSYNC not used). The polarity of the synchronization pulse is programmable to comply with the sensor signals.
Table 36-1. I/O Description Signal ISI_VSYNC ISI_HSYNC ISI_DATA[11..0] ISI_MCK ISI_PCK Dir IN IN IN OUT IN Description Vertical Synchronization Horizontal Synchronization Sensor Pixel Data Master Clock Provided to the Image Sensor Pixel Clock Provided by the Image Sensor
1001
36.2
Embedded Characteristics
z z z z z z z z z z z z z
Compatible with an Embedded 32-bit Microcontroller ITU-R BT. 601/656 8-bit Mode External Interface Support Supports up to 12-bit Grayscale CMOS Sensors Support for ITU-R BT.656-4 SAV and EAV Synchronization Vertical and Horizontal Resolutions up to 2048 x 2048 Preview Path up to 640*480 32 Bytes FIFO on Codec Path 32 Bytes FIFO on Preview Path Support for Packed Data Formatting for YCbCr 4:2:2 Formats Preview Scaler to Generate Smaller Size image Programmable Frame Capture Rate VGA, QVGA, CIF, QCIF Formats Supported for LCD Preview Custom Formats with Horizontal and Vertical Preview Size as Multiples of 16 Also Supported for LCD Preview
1002
36.3
Block Diagram
Hsync/Len Vsync/Fen
APB Interface
CCIR-656 Embedded Timing Decoder(SAV/EAV) CMOS sensor Pixel input up to 12 bit YCbCr 4:2:2 8:8:8 RGB 5:6:5
Frame Rate
Preview path
Clipping + Color Conversion YCC to RGB
Packed Formatter
codec_on
Codec path
1003
AHB bus
APB bus
36.4
Functional Description
The Image Sensor Interface (ISI) supports direct connection to the ITU-R BT. 601/656 8-bit mode compliant sensors and up to 12-bit grayscale sensors. It receives the image data stream from the image sensor on the 12-bit data bus. This module receives up to 12 bits for data, the horizontal and vertical synchronizations and the pixel clock. The reduced pin count alternative for synchronization is supported for sensors that embed SAV (start of active video) and EAV (end of active video) delimiters in the data stream. The Image Sensor Interface interrupt line is connected to the Advanced Interrupt Controller and can trigger an interrupt at the beginning of each frame and at the end of a DMA frame transfer. If the SAV/EAV synchronization is used, an interrupt can be triggered on each delimiter event. For 8-bit color sensors, the data stream received can be in several possible formats: YCbCr 4:2:2, RGB 8:8:8, RGB 5:6:5 and may be processed before the storage in memory. When the preview DMA channel is configured and enabled, the preview path is activated and an RGB frame is moved to memory. The preview path frame rate is configured with the FRATE field of the ISI_CFG1 register. When the codec DMA channel is configured and enabled, the codec path is activated and a YCbCr 4:2:2 frame is captured as soon as the ISI_CDC field of the ISI_CTRL register is set to 1. When the FULL field of the ISI_CFG1 register is set to 1, both preview DMA channel and codec DMA channel can operate simultaneously. When the FULL field of the ISI_CFG1 register is set to 0, a hardware scheduler checks the FRATE field. If its value is zero, a preview frame is skipped and a codec frame is moved to memory instead. If its value is different from zero, at least one free frame slot is available. The scheduler postpones the codec frame to that free available frame slot. The data stream may be sent on both preview path and codec path if the bit ISI_CDC in the ISI_CTRL is one. To optimize the bandwidth, the codec path should be enabled only when a capture is required. In grayscale mode, the input data stream is stored in memory without any processing. The 12-bit data, which represent the grayscale level for the pixel, is stored in memory one or two pixels per word, depending on the GS_MODE bit in the ISI_CFG2 register. The codec datapath is not available when grayscale image is selected. A frame rate counter allows users to capture all frames or 1 out of every 2 to 8 frames.
1004
ISI_VSYNC
1 line
ISI_HSYNC
ISI_PCK DATA[7..0]
Y Cb Y Cr Y Cb Y Cr Y Cb Y Cr
Table 36-3. RGB Format in Default Mode, RGB_CFG = 00, No Swap Mode Byte Byte 0 Byte 1 RGB 8:8:8 Byte 2 Byte 3 Byte 0 Byte 1 RGB 5:6:5 Byte 2 Byte 3 R4(i+1) G2(i+1) R3(i+1) G1(i+1) R2(i+1) G0(i+1) R1(i+1) B4(i+1) R0(i+1) B3(i+1) G5(i+1) B2(i+1) G4(i+1) B1(i+1) G3(i+1) B0(i+1) B7(i) R7(i+1) R4(i) G2(i) B6(i) R6(i+1) R3(i) G1(i) B5(i) R5(i+1) R2(i) G0(i) B4(i) R4(i+1) R1(i) B4(i) B3(i) R3(i+1) R0(i) B3(i) B2(i) R2(i+1) G5(i) B2(i) B1(i) R1(i+1) G4(i) B1(i) B0(i) R0(i+1) G3(i) B0(i) D7 R7(i) G7(i) D6 R6(i) G6(i) D5 R5(i) G5(i) D4 R4(i) G4(i) D3 R3(i) G3(i) D2 R2(i) G2(i) D1 R1(i) G1(i) D0 R0(i) G0(i)
1005
Table 36-4. RGB Format, RGB_CFG = 10 (Mode 2), No Swap Mode Byte Byte 0 Byte 1 RGB 5:6:5 Byte 2 Byte 3 G2(i+1) B4(i+1) G1(i+1) B3(i+1) G0(i+1) B2(i+1) R4(i+1) B1(i+1) R3(i+1) B0(i+1) R2(i+1) G5(i+1) R1(i+1) G4(i+1) R0(i+1) G3(i+1) D7 G2(i) B4(i) D6 G1(i) B3(i) D5 G0(i) B2(i) D4 R4(i) B1(i) D3 R3(i) B0(i) D2 R2(i) G5(i) D1 R1(i) G4(i) D0 R0(i) G3(i)
Table 36-5. RGB Format in Default Mode, RGB_CFG = 00, Swap Activated Mode Byte Byte 0 Byte 1 RGB 8:8:8 Byte 2 Byte 3 Byte 0 Byte 1 RGB 5:6:5 Byte 2 Byte 3 G3(i+1) B0(i+1) G4(i+1) B1(i+1) G5(i+1) B2(i+1) R0(i+1) B3(i+1) R1(i+1) B4(i+1) R2(i+1) G0(i+1) R3(i+1) G1(i+1) R4(i+1) G2(i+1) B0(i) R0(i+1) G3(i) B0(i) B1(i) R1(i+1) G4(i) B1(i) B2(i) R2(i+1) G5(i) B2(i) B3(i) R3(i+1) R0(i) B3(i) B4(i) R4(i+1) R1(i) B4(i) B5(i) R5(i+1) R2(i) G0(i) B6(i) R6(i+1) R3(i) G1(i) B7(i) R7(i+1) R4(i) G2(i) D7 R0(i) G0(i) D6 R1(i) G1(i) D5 R2(i) G2(i) D4 R3(i) G3(i) D3 R4(i) G4(i) D2 R5(i) G5(i) D1 R6(i) G6(i) D0 R7(i) G7(i)
The RGB 5:6:5 input format is processed to be displayed as RGB 5:6:5 format, compliant with the 16-bit mode of the LCD controller.
36.4.3 Clocks
The sensor master clock (ISI_MCK) can be generated either by the Advanced Power Management Controller (APMC) through a Programmable Clock output or by an external oscillator connected to the sensor. None of the sensors embed a power management controller, so providing the clock by the APMC is a simple and efficient way to control power consumption of the system. Care must be taken when programming the system clock. The ISI has two clock domains, the sensor master clock and the pixel clock provided by sensor. The two clock domains are not synchronized, but the sensor master clock must be faster than the pixel clock.
1006
Table 36-6. Decimation Factor Dec value Dec Factor 0->15 X 16 1 17 1.063 18 1.125 19 1.188 ... ... 124 7.750 125 7.813 126 7.875 127 7.938
Table 36-7. Decimation and Scaler Offset Values INPUT OUTPUT VGA 640*480 QVGA 320*240 CIF 352*288 QCIF 176*144 F 352*288 640*480 800*600 1280*1024 1600*1200 2048*1536
NA
16
20
32
40
51
16
32
40
64
80
102
16
26
33
56
66
85
32
53
66
113
133
170
Example: Input 1280*1024 Output = 640*480 Hratio = 1280/640 = 2 Vratio = 1024/480 = 2.1333 The decimation factor is 2 so 32/16.
1007
1024
480
1280
1024
288
36.4.4.2 Color Space Conversion This module converts YCrCb or YUV pixels to RGB color space. Clipping is performed to ensure that the samples value do not exceed the allowable range. The conversion matrix is defined below and is fully programmable:
1008
36.4.4.3 Memory Interface Preview datapath contains a data formatter that converts 8:8:8 pixel to RGB 5:6:5 format compliant with 16-bit format of the LCD controller. In general, when converting from a color channel with more bits to one with fewer bits, formatter module discards the lower-order bits. Example: Converting from RGB 8:8:8 to RGB 5:6:5, it discards the three LSBs from the red and blue channels, and two LSBs from the green channel. When grayscale mode is enabled, two memory formats are supported. One mode supports 2 pixels per word, and the other mode supports 1 pixel per word.
Table 36-8. Grayscale Memory Mapping Configuration for 12-bit Data GS_MODE 0 1 DATA[31:24] P_0[11:4] P_0[11:4] DATA[23:16] P_0[3:0], 0000 P_0[3:0], 0000 DATA[15:8] P_1[11:4] 0 DATA[7:0] P_1[3:0], 0000 0
36.4.4.4 FIFO and DMA Features Both preview and Codec datapaths contain FIFOs. These asynchronous buffers are used to safely transfer formatted pixels from Pixel clock domain to AHB clock domain. A video arbiter is used to manage FIFO thresholds and triggers a relevant DMA request through the AHB master interface. Thus, depending on FIFO state, a specified length burst is asserted. Regarding AHB master interface, it supports Scatter DMA mode through linked list operation. This mode of operation improves flexibility of image buffer location and allows the user to allocate two or more frame buffers. The destination frame buffers are defined by a series of Frame Buffer Descriptors (FBD). Each FBD controls the transfer of one entire frame and then optionally loads a further FBD to switch the DMA operation at another frame buffer address. The FBD is defined by a series of three words. The first one defines the current frame buffer address (named DMA_X_ADDR register), the second defines control information (named DMA_X_CTRL register) and the third defines the next descriptor address (named DMA_X_DSCR). DMA transfer mode with linked list support is available for both codec and preview datapath. The data to be transferred described by an FBD requires several burst accesses. In the example below, the use of 2 ping-pong frame buffers is described.
Example
The first FBD, stored at address 0x00030000, defines the location of the first frame buffer. This address is programmed in the ISI user interface DMA_P_DSCR. To enable Descriptor fetch operation DMA_P_CTRL register must be set to 0x00000001. LLI_0 and LLI_1 are the two descriptors of the Linked list. Destination Address: frame buffer ID0 0x02A000 (LLI_0.DMA_P_ADDR) Transfer 0 Control Information, fetch and writeback: 0x00000003 (LLI_0.DMA_P_CTRL) Next FBD address: 0x00030010 (LLI_0.DMA_P_DSCR) Second FBD, stored at address 0x00030010, defines the location of the second frame buffer. Destination Address: frame buffer ID1 0x0003A000 (LLI_1.DMA_P_ADDR Transfer 1 Control information fetch and writeback: 0x00000003 (LLI_1.DMA_P_CTRL) Next FBD address: 0x00030000, wrapping to first FBD (LLI_1.DMA_P_DSCR) Using this technique, several frame buffers can be configured through the linked list. Figure 36-6 illustrates a typical three frame buffer application. Frame n is mapped to frame buffer 0, frame n+1 is mapped to frame buffer 1, frame n+2 is mapped to Frame buffer 2, further frames wrap. A codec request occurs, and the full-size 4:2:2 encoded frame is stored in a dedicated memory space.
1009
frame n-1
frame n
frame n+1
frame n+2
frame n+3
frame n+4
Memory Space
Frame Buffer 3
Frame Buffer 0
LCD
Frame Buffer 1
36.4.5.2 Memory Interface Dedicated FIFOs are used to support packed memory mapping. YCrCb pixel components are sent in a single 32-bit word in a contiguous space (packed). Data is stored in the order of natural scan lines. Planar mode is not supported. 36.4.5.3 DMA Features
Like preview datapath, codec datapath DMA mode uses linked list operation.
1010
36.5
Table 36-9. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 0x5C-0xE0 0xE4 0xE8 0xEC-0xF8 0xFC Register ISI Configuration 1 Register ISI Configuration 2 Register ISI Preview Size Register ISI Preview Decimation Factor Register ISI CSC YCrCb To RGB Set 0 Register ISI CSC YCrCb To RGB Set 1 Register ISI CSC RGB To YCrCb Set 0 Register ISI CSC RGB To YCrCb Set 1 Register ISI CSC RGB To YCrCb Set 2 Register ISI Control Register ISI Status Register ISI Interrupt Enable Register ISI Interrupt Disable Register ISI Interrupt Mask Register DMA Channel Enable Register DMA Channel Disable Register DMA Channel Status Register DMA Preview Base Address Register DMA Preview Control Register DMA Preview Descriptor Address Register DMA Codec Base Address Register DMA Codec Control Register DMA Codec Descriptor Address Register Reserved Write Protection Control Register Write Protection Status Register Reserved Reserved Name ISI_CFG1 ISI_CFG2 ISI_PSIZE ISI_PDECF ISI_Y2R_SET0 ISI_Y2R_SET1 ISI_R2Y_SET0 ISI_R2Y_SET1 ISI_R2Y_SET2 ISI_CR ISI_SR ISI_IER ISI_IDR ISI_IMR ISI_DMA_CHER ISI_DMA_CHDR ISI_DMA_CHSR ISI_DMA_P_ADDR ISI_DMA_P_CTRL ISI_DMA_P_DSCR ISI_DMA_C_ADDR ISI_DMA_C_CTRL ISI_DMA_C_DSCR ISI_WPCR ISI_WPSR Access Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-write Write-only Read-only Write-only Write-only Read-only Write-only Write-only Read-only Read-write Read-write Read-write Read-write Read-write Read-write Read-write Read-only Reset Value 0x00000000 0x00000000 0x00000000 0x00000010 0x6832cc95 0x00007102 0x01324145 0x01245e38 0x01384a4b 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
Note:
Several parts of the ISI controller use the pixel clock provided by the image sensor (ISI_PCK). Thus the user must first program the image sensor to provide this clock (ISI_PCK) before programming the Image Sensor Controller.
1011
23
22
21
20 SLD
19
18
17
16
15 7 CRC_SYNC
14 THMASK 6 EMB_SYNC
13
12 FULL 4 PIXCLK_POL
11 DISCR 3 VSYNC_POL
10
9 FRATE 1
2 HSYNC_POL
1012
1013
18
16
15 COL_SPACE 7
14 RGB_SWAP 6
13 GRAYSCALE 5
12 RGB_MODE 4
11 GS_MODE 3
10
9 IM_VSIZE 1
IM_VSIZE
GS_MODE:
0: 2 pixels per word. 1: 1 pixel per word.
GRAYSCALE:
0: Grayscale mode is disabled. 1: Input image is assumed to be grayscale coded.
RGB_SWAP:
0: D7 -> R7. 1: D0 -> R7. The RGB_SWAP has no effect when the grayscale mode is enabled.
1014
If RGB_MODE is set to RGB 8:8:8, then RGB_CFG = 0 implies RGB color sequence, else it implies BGR color sequence.
1015
15 7
14 6
13 5
12 4 PREV_VSIZE
11 3
10 2
9 PREV_VSIZE 1
1016
1017
23
22
21
20 C2
19
18
17
16
15
14
13
12 C1
11
10
4 C0
1018
1019
14
13
12
10
1020
14
13
12
10
1021
14
13
12
10
1022
1023
1024
1025
DIS_DONE: Disable Done Interrupt Enable SRST: Software Reset Interrupt Enable VSYNC: Vertical Synchronization Interrupt Enable PXFR_DONE: Preview DMA Transfer Done Interrupt Enable CXFR_DONE: Codec DMA Transfer Done Interrupt Enable P_OVR: Preview Datapath Overflow Interrupt Enable C_OVR: Codec Datapath Overflow Interrupt Enable CRC_ERR: Embedded Synchronization CRC Error Interrupt Enable FR_OVR: Frame Rate Overflow Interrupt Enable
1026
DIS_DONE: Disable Done Interrupt Disable SRST: Software Reset Interrupt Disable VSYNC: Vertical Synchronization Interrupt Disable PXFR_DONE: Preview DMA Transfer Done Interrupt Disable CXFR_DONE: Codec DMA Transfer Done Interrupt Disable P_OVR: Preview Datapath Overflow Interrupt Disable C_OVR: Codec Datapath Overflow Interrupt Disable CRC_ERR: Embedded Synchronization CRC Error Interrupt Disable FR_OVR: Frame Rate Overflow Interrupt Disable
1027
1028
1029
1030
P_CH_DIS
Write one to this field to disable the channel. Poll P_CH_S in DMA_CHSR to verify that the preview channel status has been successfully modified.
C_CH_DIS
Write one to this field to disabled the channel. Poll C_CH_S in DMA_CHSR to verify that the codec channel status has been successfully modified.
1031
P_CH_S:
0: indicates that the Preview DMA channel is disabled 1: indicates that the Preview DMA channel is enabled.
C_CH_S:
0: indicates that the Codec DMA channel is disabled. 1: indicates that the Codec DMA channel is enabled.
1032
23
22
21
20 P_ADDR
19
18
17
16
15
14
13
12 P_ADDR
11
10
5 P_ADDR
1033
1034
23
22
21
20 P_DSCR
19
18
17
16
15
14
13
12 P_DSCR
11
10
5 P_DSCR
1035
23
22
21
20 C_ADDR
19
18
17
16
15
14
13
12 C_ADDR
11
10
5 C_ADDR
1036
1037
23
22
21
20 C_DSCR
19
18
17
16
15
14
13
12 C_DSCR
11
10
5 C_DSCR
1038
23
22
21
18
17
16
15
14
13
10
0 WP_EN
1039
15
14
13
12 WP_VSRC
11
10
7 -
6 -
5 -
4 -
2 WP_VS
1040
37.
37.1
37.2
Embedded Characteristics
z z z z z z z z z
Compatible with MultiMedia Card Specification Version 4.3 Compatible with SD Memory Card Specification Version 2.0 Compatible with SDIO Specification Version 2.0 Compatible with CE-ATA Specification 1.1 Cards Clock Rate Up to Master Clock Divided by 2 Boot Operation Mode Support High Speed Mode Support Embedded Power Management to Slow Down Clock Rate When Not Used Supports 1 Multiplexed Slot
z
Each Slot for either a High Speed MultiMedia Card Bus (Up to 30 Cards) or an SD Memory Card
z z
Support for Stream, Block and Multi-block Data Read and Write Supports Connection to DMA Controller (DMAC)
z
z z z
Built in FIFO (from 16 to 256 bytes) with Large Memory Aperture Supporting Incremental Access Support for CE-ATA Completion Signal Disable Command Protection Against Unexpected Modification On-the-Fly of the Configuration Registers
1041
37.3
Block Diagram
(1)
(1)
(1)
(1)
(1)
Interrupt Control
MCDA7
(1)
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.
1042
DMAC APB MCCK(1) MCCDA(1) HSMCI Interface PIO MCDA0(1) MCDA1(1) MCDA2(1) MCDA3(1) Interrupt Control
PMC
MCK
HSMCI Interrupt
37.4
1 2 3 4 5 6 7
1 2 3 4 5 6 78 9
9 1011 1213 8
MMC
SDCard
1043
37.5
Table 37-1. I/O Lines Description for 8-bit Configuration Pin Name(2) MCCDA/MCCDB MCCK MCDA0 - MCDA7 MCDB0 - MCDB7 MCDC0 - MCDC7 MCDD0 - MCDD7 Pin Description Command/response Clock Data 0..7 of Slot A Data 0..7 of Slot B Data 0..7 of Slot C Data 0..7 of Slot D Type(1) I/O/PP/OD I/O I/O/PP I/O/PP I/O/PP I/O/PP Comments CMD of an MMC or SDCard/SDIO CLK of an MMC or SD Card/SDIO DAT[0..7] of an MMC DAT[0..3] of an SD Card/SDIO DAT[0..7] of an MMC DAT[0..3] of an SD Card/SDIO DAT[0..7] of an MMC DAT[0..3] of an SD Card/SDIO DAT[0..7] of an MMC DAT[0..3] of an SD Card/SDIO
Notes: 1. I: Input, O: Output, PP: Push/Pull, OD: Open Drain. 2. When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA, MCCDB to HSMCIx_CDB, MCCDC to HSMCIx_CDC, MCCDD to HSMCIx_CDD, MCDAy to HSMCIx_DAy, MCDBy to HSMCIx_DBy, MCDCy to HSMCIx_DCy, MCDDy to HSMCIx_DDy.
Table 37-2. I/O Lines Description for 4-bit Configuration Pin Name(2) MCCDA/MCCDB MCCK MCDA0 - MCDA3 Pin Description Command/response Clock Data 0..3 of Slot A Type(1) I/O/PP/OD I/O I/O/PP Comments CMD of an MMC or SDCard/SDIO CLK of an MMC or SD Card/SDIO DAT[0..3] of an MMC DAT[0..3] of an SD Card/SDIO
Notes: 1. I: Input, O: Output, PP: Push/Pull, OD: Open Drain. 2. When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA, MCDAy to HSMCIx_DAy.
1044
37.6
Product Dependencies
37.6.3 Interrupt
The HSMCI interface has an interrupt line connected to the interrupt controller. Handling the HSMCI interrupt requires programming the interrupt controller before configuring the HSMCI.
Table 37-4. Peripheral IDs Instance HSMCI0 HSMCI1 HSMCI2 ID 21 22 23
1045
37.7
Bus Topology
Figure 37-4. High Speed MultiMedia Memory Card Bus Topology
1 2 3 4 5 6 7
9 1011
1213 8
MMC
The High Speed MultiMedia Card communication is based on a 13-pin serial bus interface. It has three communication lines and four supply lines.
Table 37-5. Bus Topology Pin Number 1 2 3 4 5 6 7 8 9 10 11 12 13 Name DAT[3] CMD VSS1 VDD CLK VSS2 DAT[0] DAT[1] DAT[2] DAT[4] DAT[5] DAT[6] DAT[7] Type(1) I/O/PP I/O/PP/OD S S I/O S I/O/PP I/O/PP I/O/PP I/O/PP I/O/PP I/O/PP I/O/PP Description Data Command/response Supply voltage ground Supply voltage Clock Supply voltage ground Data 0 Data 1 Data 2 Data 4 Data 5 Data 6 Data 7 HSMCI Pin Name(2) (Slot z) MCDz3 MCCDz VSS VDD MCCK VSS MCDz0 MCDz1 MCDz2 MCDz4 MCDz5 MCDz6 MCDz7
Notes: 1. 2.
I: Input, O: Output, PP: Push/Pull, OD: Open Drain. When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA, MCCDB to HSMCIx_CDB, MCDAy to HSMCIx_DAy, MCDBy to HSMCIx_DBy.
1046
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
9 1011
1213 8
9 1011
1213 8
9 1011
1213 8
MMC1
MMC2
MMC3
Note:
When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA MCDAy to HSMCIx_DAy.
The SD Memory Card bus includes the signals listed in Table 37-6.
Table 37-6. SD Memory Card Bus Signals Pin Number 1 2 3 4 5 6 7 8 9 Name CD/DAT[3] CMD VSS1 VDD CLK VSS2 DAT[0] DAT[1] DAT[2] Type(1) I/O/PP PP S S I/O S I/O/PP I/O/PP I/O/PP Description Card detect/ Data line Bit 3 Command/response Supply voltage ground Supply voltage Clock Supply voltage ground Data line Bit 0 Data line Bit 1 or Interrupt Data line Bit 2 HSMCI Pin Name(2) (Slot z) MCDz3 MCCDz VSS VDD MCCK VSS MCDz0 MCDz1 MCDz2
Notes: 1. 2.
I: input, O: output, PP: Push Pull, OD: Open Drain. When several HSMCI (x HSMCI) are embedded in a product, MCCK refers to HSMCIx_CK, MCCDA to HSMCIx_CDA, MCCDB to HSMCIx_CDB, MCDAy to HSMCIx_DAy, MCDBy to HSMCIx_DBy.
1047
SD CARD
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 register. 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.
1048
37.8
Command: A command is a token that starts an operation. A command is sent from the host either to a single card (addressed command) or to all connected cards (broadcast command). A command is transferred serially on the CMD line. Response: A response is a token which is sent from an addressed card or (synchronously) from all connected cards to the host as an answer to a previously received command. A response is transferred serially on the CMD line. Data: Data can be transferred from the card to the host or vice versa. Data is transferred via the data line.
Card addressing is implemented using a session address assigned during the initialization phase by the bus controller to all currently connected cards. Their unique CID number identifies individual cards. The structure of commands, responses and data blocks is described in the High Speed MultiMedia Card System Specification. See also Table 37-7 on page 1050. High Speed MultiMedia Card bus data transfers are composed of these tokens. There are different types of operations. Addressed operations always contain a command and a response token. In addition, some operations have a data token; the others transfer their information directly within the command or response structure. In this case, no data token is present in an operation. The bits on the DAT and the CMD lines are transferred synchronous to the clock HSMCI Clock. Two types of data transfer commands are defined:
z z
Sequential commands: These commands initiate a continuous data stream. They are terminated only when a stop command follows on the CMD line. This mode reduces the command overhead to an absolute minimum. Block-oriented commands: These commands send a data block succeeded by CRC bits.
Both read and write operations allow either single or multiple block transmission. A multiple block transmission is terminated when a stop command follows on the CMD line similarly to the sequential read or when a multiple block transmission has a pre-defined block count (See Data Transfer Operation on page 1052.). The HSMCI provides a set of registers to perform the entire range of High Speed MultiMedia Card operations.
1049
The command ALL_SEND_CID and the fields and values for the HSMCI_CMDR Control Register are described in Table 37-7 and Table 37-8.
Table 37-7. ALL_SEND_CID Command Description CMD Index Type Argument Resp Abbreviation Command Description Asks all cards to send their CID numbers on the CMD line
CMD2
bcr(1)
R2
ALL_SEND_CID
Note:
1.
Table 37-8. Fields and Values for HSMCI_CMDR Command Register Field CMDNB (command number) RSPTYP (response type) SPCMD (special command) OPCMD (open drain command) MAXLAT (max latency for command to response) TRCMD (transfer command) TRDIR (transfer direction) TRTYP (transfer type) IOSPCMD (SDIO special command) Value 2 (CMD2) 2 (R2: 136 bits response) 0 (not a special command) 1 0 (NID cycles ==> 5 cycles) 0 (No transfer) X (available only in transfer command) X (available only in transfer command) 0 (not a special command)
The HSMCI_ARGR contains the argument field of the command. To send a command, the user must perform the following steps:
z z
Fill the argument register (HSMCI_ARGR) with the command argument. Set the command register (HSMCI_CMDR) (see Table 37-8).
The command is sent immediately after writing the command register. While the card maintains a busy indication (at the end of a STOP_TRANSMISSION command CMD12, for example), a new command shall not be sent. The NOTBUSY flag in the status register (HSMCI_SR) is asserted when the card releases the busy indication. If the command requires a response, it can be read in the HSMCI Response Register (HSMCI_RSPR). The response size can be from 48 bits up to 136 bits depending on the command. The HSMCI embeds an error detection to prevent any corrupted data during the transfer. The following flowchart shows how to send a command to the card and read the response if needed. In this example, the status register bits are polled but setting the appropriate bits in the Interrupt Enable Register (HSMCI_IER) allows using an interrupt method.
1050
Read HSMCI_SR
0 CMDRDY
No
RETURN OK
Read HSMCI_SR
0 NOTBUSY
1 RETURN OK
Note:
1. 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).
1051
Open-ended/Infinite Multiple block read (or write): The number of blocks for the read (or write) multiple block operation is not defined. The card will continuously transfer (or program) data blocks until a stop transmission command is received.
Multiple block read (or write) with pre-defined block count (since version 3.1 and higher): The card will transfer (or program) the requested number of data blocks and terminate the transaction. The stop command is not required at the end of this type of multiple block read (or write), unless terminated with an error. In order to start a multiple block read (or write) with pre-defined block count, the host must correctly program the HSMCI Block Register (HSMCI_BLKR). Otherwise the card will start an open-ended multiple block read. The BCNT field of the Block Register defines the number of blocks to transfer (from 1 to 65535 blocks). Programming the value 0 in the BCNT field corresponds to an infinite block transfer.
1052
1053
Yes
Reset the DMAEN bit HSMCI_DMA &= ~DMAEN Set the block length (in bytes) HSMCI_MR l= (BlockLength<<16) (2) Set the block count (if neccessary) HSMCI_BLKR l= (BlockCount<<0)
Set the DMAEN bit HSMCI_DMA |= DMAEN Set the block length (in bytes) HSMCI_BLKR |= (BlockLength << 16)(2)
Configure the DMA channel X DMAC_SADDRx = Data Address DMAC_BTSIZE = BlockLength/4 DMACHEN[X] = TRUE
Yes Number of words to read = 0 ? Read status register HSMCI_SR No Read status register HSMCI_SR Poll the bit XFRDONE = 0? Yes
Yes No
RETURN
RETURN
Notes: 1. It is assumed that this command has been correctly sent (see Figure 37-8). 2. This field is also accessible in the HSMCI Block Register (HSMCI_BLKR).
1054
1055
Yes
Reset theDMAEN bit HSMCI_DMA &= ~DMAEN Set the block length (in bytes) HSMCI_MR |= (BlockLength) <<16)(2) Set the block count (if necessary) HSMCI_BLKR |= (BlockCount << 0)
Set the DMAEN bit HSMCI_DMA |= DMAEN Set the block length (in bytes) HSMCI_BLKR |= (BlockLength << 16)(2)
Configure the DMA channel X DMAC_DADDRx = Data Address to write DMAC_BTSIZE = BlockLength/4
DMAC_CHEN[X] = TRUE Yes Number of words to write = 0 ? Read status register HSMCI_SR No Read status register HSMCI_SR Poll the bit XFRDONE = 0? Poll the bit TXRDY = 0? Yes No Yes
No HSMCI_TDR = Data to write Number of words to write = Number of words to write -1 RETURN
RETURN
Note:
1. It is assumed that this command has been correctly sent (see Figure 37-8). 2. This field is also accessible in the HSMCI Block Register (HSMCI_BLKR). The following flowchart (Figure 37-11) shows how to manage read multiple block and write multiple block transfers with the DMA Controller. Polling or interrupt method can be used to wait for the end of write according to the contents of the Interrupt Mask Register (HSMCI_IMR).
1056
Set the block length HSMCI_MR |= (BlockLength << 16) Set the DMAEN bit HSMCI_DMA |= DMAEN
DMAC_CHEN[X] = TRUE
Yes
No
Yes RETURN
Notes: 1. 2.
It is assumed that this command has been correctly sent (see Figure 37-8). Handle errors reported in HSMCI_SR.
1057
OFFSET field with dma_offset. CHKSIZE is user defined and set according to DMAC_DCSIZE. DMAEN is set to true to enable DMA hardware handshaking in the HSMCI. This bit was previously set to false.
5. 6.
Issue a WRITE_SINGLE_BLOCK command writing HSMCI_ARG then HSMCI_CMDR. Program the DMA Controller. 1. 2. 3. 4. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the DMAC_EBCISR register. Program the channel registers. The DMAC_SADDRx register for Channel x must be set to the location of the source data. When the first data location is not word aligned, the two LSB bits define the temporary value called dma_offset. The two LSB bits of DMAC_SADDRx must be set to 0. The DMAC_DADDRx register for Channel x must be set with the starting address of the HSMCI_FIFO address. Program the DMAC_CTRLAx register of Channel x with the following fields values:
5. 6.
DST_WIDTH is set to WORD. SRC_WIDTH is set to WORD. DCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with CEILING((block_length + dma_offset) / 4), where the ceiling function is the function that returns the smallest integer not less than x.
7. Program the DMAC_CTRLBx register for Channel x with the following fields values:
DST_INCR is set to INCR, the block_length value must not be larger than the HSMCI_FIFO aperture. SRC_INCR is set to INCR. FC field is programmed with memory to peripheral flow control mode. both DST_DSCR and SRC_DSCR are set to 1 (descriptor fetch is disabled). DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA controller is able to prefetch data and write HSMCI simultaneously.
8. Program the DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMAC channel FIFO. DST_H2SEL is set to true to enable hardware handshaking on the destination. DST_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
9. 7. Enable Channel x, writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request. Wait for XFRDONE in the HSMCI_SR register.
1058
ROPT field is set to 0. OFFSET field is set to 0. CHKSIZE is user defined. DMAEN is set to true to enable DMAC hardware handshaking in the HSMCI. This bit was previously set to false.
6. 7.
Issue a READ_SINGLE_BLOCK command. Program the DMA controller. 1. 2. 3. 4. 5. 6. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMA transfer by reading the DMAC_EBCISR register. Program the channel registers. The DMAC_SADDRx register for Channel x must be set with the starting address of the HSMCI_FIFO address. The DMAC_DADDRx register for Channel x must be word aligned. Program the DMAC_CTRLAx register of Channel x with the following fields values:
DST_WIDTH is set to WORD. SRC_WIDTH is set to WORD. SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with block_length/4.
7. Program the DMAC_CTRLBx register for Channel x with the following fields values:
DST_INCR is set to INCR. SRC_INCR is set to INCR. FC field is programmed with peripheral to memory flow control mode. both DST_DSCR and SRC_DSCR are set to 1 (descriptor fetch is disabled). DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA controller is able to prefetch data and write HSMCI simultaneously.
8. Program the DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller. Enable Channel x, writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request.
8. Wait for XFRDONE in the HSMCI_SR register.
1059
37.8.6.2 Block Length is Not Multiple of 4 and Padding Not Used (ROPT field in HSMCI_DMA register set to 0) In the previous DMA transfer flow (block length multiple of 4), the DMA controller is configured to use only WORD AHB access. When the block length is no longer a multiple of 4 this is no longer true. The DMA controller is programmed to copy exactly the block length number of bytes using 2 transfer descriptors. 1. 2. Use the previous step until READ_SINGLE_BLOCK then Program the DMA controller to use a two descriptors linked list. 1. 2. 3. 4. 5. 6. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMA transfer by reading the DMAC_EBCISR register. Program the channel registers in the Memory for the first descriptor. This descriptor will be word oriented. This descriptor is referred to as LLI_W, standing for LLI word oriented transfer. The LLI_W.DMAC_SADDRx field in memory must be set with the starting address of the HSMCI_FIFO address. The LLI_W.DMAC_DADDRx field in the memory must be word aligned. Program LLI_W.DMAC_CTRLAx with the following fields values:
DST_WIDTH is set to WORD. SRC_WIDTH is set to WORD. SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with block_length/4. If BTSIZE is zero, this descriptor is skipped later.
7. Program LLI_W.DMAC_CTRLBx with the following fields values:
DST_INCR is set to INCR SRC_INCR is set to INCR FC field is programmed with peripheral to memory flow control mode. SRC_DSCR is set to zero. (descriptor fetch is enabled for the SRC) DST_DSCR is set to one. (descriptor fetch is disabled for the DST) DIF and SIF are set with their respective layer ID. If SIF is different from DIF, DMA controller is able to prefetch data and write HSMCI simultaneously.
8. Program the LLI_W.DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. DST_REP is set to zero meaning that address are contiguous. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
9. Program LLI_W.DMAC_DSCRx with the address of LLI_B descriptor. And set DSCRx_IF to the AHB Layer ID. This operation actually links the Word oriented descriptor on the second byte oriented descriptor. When block_length[1:0] is equal to 0 (multiple of 4) LLI_W.DMAC_DSCRx points to 0, only LLI_W is relevant.
10. Program the channel registers in the Memory for the second descriptor. This descriptor will be byte oriented. This descriptor is referred to as LLI_B, standing for LLI Byte oriented. 11. The LLI_B.DMAC_SADDRx field in memory must be set with the starting address of the HSMCI_FIFO address. 12. The LLI_B.DMAC_DADDRx is not relevant if previous word aligned descriptor was enabled. If 1, 2 or 3 bytes are transferred that address is user defined and not word aligned. 13. Program LLI_B.DMAC_CTRLAx with the following fields values:
1060
SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with block_length[1:0]. (last 1, 2, or 3 bytes of the buffer).
14. Program LLI_B.DMAC_CTRLBx with the following fields values:
DST_INCR is set to INCR SRC_INCR is set to INCR FC field is programmed with peripheral to memory flow control mode. Both SRC_DSCR and DST_DSCR are set to 1 (descriptor fetch is disabled) or Next descriptor location points to 0. DIF and SIF are set with their respective layer ID. If SIF is different from DIF, DMA Controller is able to prefetch data and write HSMCI simultaneously.
15. Program LLI_B.DMAC_CFGx memory location for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
16. Program LLI_B.DMAC_DSCR with 0. 17. Program the DMAC_CTRLBx register for Channel x with 0. its content is updated with the LLI fetch operation. 18. Program DMAC_DSCRx with the address of LLI_W if block_length greater than 4 else with address of LLI_B. 19. Enable Channel x writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request. 3. Wait for XFRDONE in the HSMCI_SR register.
37.8.6.3 Block Length is Not Multiple of 4, with Padding Value (ROPT field in HSMCI_DMA register set to 1) When the ROPT field is set to one, The DMA Controller performs only WORD access on the bus to transfer a nonmultiple of 4 block length. Unlike previous flow, in which the transfer size is rounded to the nearest multiple of 4. 1. 2. Program the HSMCI Interface, see previous flow.
z
ROPT field is set to 1. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMA transfer by reading the DMAC_EBCISR register. Program the channel registers. The DMAC_SADDRx register for Channel x must be set with the starting address of the HSMCI_FIFO address. The DMAC_DADDRx register for Channel x must be word aligned. Program the DMAC_CTRLAx register of Channel x with the following fields values:
DST_WIDTH is set to WORD SRC_WIDTH is set to WORD SCSIZE must be set according to the value of HSMCI_DMA.CHKSIZE Field. BTSIZE is programmed with CEILING(block_length/4).
7. Program the DMAC_CTRLBx register for Channel x with the following fields values:
DST_INCR is set to INCR SRC_INCR is set to INCR FC field is programmed with peripheral to memory flow control mode.
1061
Both DST_DSCR and SRC_DSCR are set to 1. (descriptor fetch is disabled) DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA Controller is able to prefetch data and write HSMCI simultaneously.
8. Program the DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller. Enable Channel x writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request.
3. Wait for XFRDONE in the HSMCI_SR register.
37.8.7 WRITE_MULTIPLE_BLOCK
37.8.7.1 One Block per Descriptor 1. 2. 3. 4. Wait until the current command execution has successfully terminated. 1. Check that CMDRDY and NOTBUSY are asserted in HSMCI_SR. Program the block length in the card. This value defines the value block_length. Program the block length in the HSMCI Configuration Register with block_length value. Program the HSMCI_DMA register with the following fields:
z z z
OFFSET field with dma_offset. CHKSIZE is user defined. DMAEN is set to true to enable DMAC hardware handshaking in the HSMCI. This bit was previously set to false.
5. 6.
Issue a WRITE_MULTIPLE_BLOCK command. Program the DMA Controller to use a list of descriptors. Each descriptor transfers one block of data. Block n of data is transferred with descriptor LLI(n). 1. 2. 3. 4. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the DMAC_EBCISR register. Program a List of descriptors. The LLI(n).DMAC_SADDRx memory location for Channel x must be set to the location of the source data. When the first data location is not word aligned, the two LSB bits define the temporary value called dma_offset. The two LSB bits of LLI(n).DMAC_SADDRx must be set to 0. The LLI(n).DMAC_DADDRx register for Channel x must be set with the starting address of the HSMCI_FIFO address. Program the LLI(n).DMAC_CTRLAx register of Channel x with the following fields values:
5. 6.
DST_WIDTH is set to WORD. SRC_WIDTH is set to WORD. DCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with CEILING((block_length + dma_offset)/4).
7. Program the LLI(n).DMAC_CTRLBx register for Channel x with the following fields values:
DST_INCR is set to INCR. SRC_INCR is set to INCR. DST_DSCR is set to 0 (fetch operation is enabled for the destination). SRC_DSCR is set to 1 (source address is contiguous). FC field is programmed with memory to peripheral flow control mode.
1062
Both DST_DSCR and SRC_DSCR are set to 1 (descriptor fetch is disabled). DIF and SIF are set with their respective layer ID. If SIF is different from DIF, DMA Controller is able to prefetch data and write HSMCI simultaneously.
8. Program the LLI(n).DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. DST_H2SEL is set to true to enable hardware handshaking on the destination. SRC_REP is set to 0. (contiguous memory access at block boundary) DST_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
9. If LLI(n) is the last descriptor, then LLI(n).DSCR points to 0 else LLI(n) points to the start address of LLI(n+1).
10. Program DMAC_CTRLBx for the Channel Register x with 0. Its content is updated with the LLI fetch operation. 11. Program DMAC_DSCRx for the Channel Register x with the address of the first descriptor LLI(0). 12. Enable Channel x writing one to DMAC_CHER[x]. The DMA is ready and waiting for request. 7. 8. 9. Poll CBTC[x] bit in the DMAC_EBCISR Register. If a new list of buffers shall be transferred, repeat step 6. Check and handle HSMCI errors. Poll FIFOEMPTY field in the HSMCI_SR.
10. Send The STOP_TRANSMISSION command writing HSMCI_ARG then HSMCI_CMDR. 11. Wait for XFRDONE in the HSMCI_SR register.
37.8.8 READ_MULTIPLE_BLOCK
37.8.8.1 Block Length is a Multiple of 4 1. 2. 3. 4. 5. Wait until the current command execution has successfully terminated. 1. Check that CMDRDY and NOTBUSY are asserted in HSMCI_SR. Program the block length in the card. This value defines the value block_length. Program the block length in the HSMCI Configuration Register with block_length value. Set RDPROOF bit in HSMCI_MR to avoid overflow. Program the HSMCI_DMA register with the following fields:
z z z z
ROPT field is set to 0. OFFSET field is set to 0. CHKSIZE is user defined. DMAEN is set to true to enable DMAC hardware handshaking in the HSMCI. This bit was previously set to false.
6. 7.
Issue a READ_MULTIPLE_BLOCK command. Program the DMA Controller to use a list of descriptors: 1. 2. 3. 4. 5. 6. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMA transfer by reading the DMAC_EBCISR register. Program the channel registers in the Memory with the first descriptor. This descriptor will be word oriented. This descriptor is referred to as LLI_W(n), standing for LLI word oriented transfer for block n. The LLI_W(n).DMAC_SADDRx field in memory must be set with the starting address of the HSMCI_FIFO address. The LLI_W(n).DMAC_DADDRx field in the memory must be word aligned. Program LLI_W(n).DMAC_CTRLAx with the following fields values:
1063
SRC_WIDTH is set to WORD SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with block_length/4.
7. Program LLI_W(n).DMAC_CTRLBx with the following fields values:
DST_INCR is set to INCR. SRC_INCR is set to INCR. FC field is programmed with peripheral to memory flow control mode. SRC_DSCR is set to 0 (descriptor fetch is enabled for the SRC). DST_DSCR is set to TRUE (descriptor fetch is disabled for the DST). DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA Controller is able to prefetch data and write HSMCI simultaneously.
8. Program the LLI_W(n).DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. DST_REP is set to zero. Addresses are contiguous. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
9. Program LLI_W(n).DMAC_DSCRx with the address of LLI_W(n+1) descriptor. And set the DSCRx_IF to the AHB Layer ID. This operation actually links descriptors together. If LLI_W(n) is the last descriptor then LLI_W(n).DMAC_DSCRx points to 0.
10. Program the DMAC_CTRLBx register for Channel x with 0. its content is updated with the LLI Fetch operation. 11. Program DMAC_DSCRx register for Channel x with the address of LLI_W(0). 12. Enable Channel x writing one to DMAC_CHER[x]. The DMA is ready and waiting for request. 8. 9. Poll CBTC[x] bit in the DMAC_EBCISR Register. If a new list of buffer shall be transferred repeat step 6. Check and handle HSMCI errors.
10. Poll FIFOEMPTY field in the HSMCI_SR. 11. Send The STOP_TRANSMISSION command writing the HSMCI_ARG then the HSMCI_CMDR. 12. Wait for XFRDONE in the HSMCI_SR register. 37.8.8.2 Block Length is Not Multiple of 4. (ROPT field in HSMCI_DMA register set to 0) Two DMA Transfer descriptors are used to perform the HSMCI block transfer. 1. 2. 3. Use the previous step to configure the HSMCI to perform a READ_MULTIPLE_BLOCK command. Issue a READ_MULTIPLE_BLOCK command. Program the DMA Controller to use a list of descriptors. 1. 2. 3. 4. 5. 6. 7. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the DMAC_EBCISR register. For every block of data repeat the following procedure: Program the channel registers in the Memory for the first descriptor. This descriptor will be word oriented. This descriptor is referred to as LLI_W(n) standing for LLI word oriented transfer for block n. The LLI_W(n).DMAC_SADDRx field in memory must be set with the starting address of the HSMCI_FIFO address. The LLI_W(n).DMAC_DADDRx field in the memory must be word aligned. Program LLI_W(n).DMAC_CTRLAx with the following fields values:
1064
SRC_WIDTH is set to WORD. SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with block_length/4. If BTSIZE is zero, this descriptor is skipped later.
8. Program LLI_W(n).DMAC_CTRLBx with the following fields values:
DST_INCR is set to INCR. SRC_INCR is set to INCR. FC field is programmed with peripheral to memory flow control mode. SRC_DSCR is set to 0 (descriptor fetch is enabled for the SRC). DST_DSCR is set to TRUE (descriptor fetch is disabled for the DST). DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA Controller is able to prefetch data and write HSMCI simultaneously.
9. Program the LLI_W(n).DMAC_CFGx register for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMA channel FIFO. DST_REP is set to zero. Address are contiguous. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
10. Program LLI_W(n).DMAC_DSCRx with the address of LLI_B(n) descriptor. And set the DSCRx_IF to the AHB Layer ID. This operation actually links the Word oriented descriptor on the second byte oriented descriptor. When block_length[1:0] is equal to 0 (multiple of 4) LLI_W(n).DMAC_DSCRx points to 0, only LLI_W(n) is relevant. 11. Program the channel registers in the Memory for the second descriptor. This descriptor will be byte oriented. This descriptor is referred to as LLI_B(n), standing for LLI Byte oriented. 12. The LLI_B(n).DMAC_SADDRx field in memory must be set with the starting address of the HSMCI_FIFO address. 13. The LLI_B(n).DMAC_DADDRx is not relevant if previous word aligned descriptor was enabled. If 1, 2 or 3 bytes are transferred, that address is user defined and not word aligned. 14. Program LLI_B(n).DMAC_CTRLAx with the following fields values:
DST_WIDTH is set to BYTE. SRC_WIDTH is set to BYTE. SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with block_length[1:0]. (last 1, 2, or 3 bytes of the buffer).
15. Program LLI_B(n).DMAC_CTRLBx with the following fields values:
DST_INCR is set to INCR. SRC_INCR is set to INCR. FC field is programmed with peripheral to memory flow control mode. Both SRC_DSCR and DST_DSCR are set to 1 (descriptor fetch is disabled) or Next descriptor location points to 0. DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA Controller is able to prefetch data and write HSMCI simultaneously.
16. Program LLI_B(n).DMAC_CFGx memory location for Channel x with the following fields values:
FIFOCFG defines the watermark of the DMAC channel FIFO. SRC_H2SEL is set to true to enable hardware handshaking on the destination.
1065
SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller
17. Program LLI_B(n).DMAC_DSCR with address of descriptor LLI_W(n+1). If LLI_B(n) is the last descriptor, then program LLI_B(n).DMAC_DSCR with 0. 18. Program the DMAC_CTRLBx register for Channel x with 0, its content is updated with the LLI Fetch operation. 19. Program DMAC_DSCRx with the address of LLI_W(0) if block_length is greater than 4 else with address of LLI_B(0). 20. Enable Channel x writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request. 4. 5. 6. 7. 8. 9. Enable DMADONE interrupt in the HSMCI_IER register. Poll CBTC[x] bit in the DMAC_EBCISR Register. If a new list of buffers shall be transferred, repeat step 7. Check and handle HSMCI errors. Poll FIFOEMPTY field in the HSMCI_SR. Send The STOP_TRANSMISSION command writing HSMCI_ARG then HSMCI_CMDR. Wait for XFRDONE in the HSMCI_SR register.
37.8.8.3 Block Length is Not a Multiple of 4. (ROPT field in HSMCI_DMA register set to 1) One DMA Transfer descriptor is used to perform the HSMCI block transfer, the DMA writes a rounded up value to the nearest multiple of 4. 1. 2. 3. 4. Use the previous step to configure the HSMCI to perform a READ_MULTIPLE_BLOCK. Set the ROPT field to 1 in the HSMCI_DMA register. Issue a READ_MULTIPLE_BLOCK command. Program the DMA controller to use a list of descriptors: 1. 2. 3. 4. 5. 6. Read the channel register to choose an available (disabled) channel. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the DMAC_EBCISR register. Program the channel registers in the Memory with the first descriptor. This descriptor will be word oriented. This descriptor is referred to as LLI_W(n), standing for LLI word oriented transfer for block n. The LLI_W(n).DMAC_SADDRx field in memory must be set with the starting address of the HSMCI_FIFO address. The LLI_W(n).DMAC_DADDRx field in the memory must be word aligned. Program LLI_W(n).DMAC_CTRLAx with the following fields values:
DST_WIDTH is set to WORD. SRC_WIDTH is set to WORD. SCSIZE must be set according to the value of HSMCI_DMA, CHKSIZE field. BTSIZE is programmed with Ceiling(block_length/4).
7. Program LLI_W(n).DMAC_CTRLBx with the following fields values:
DST_INCR is set to INCR SRC_INCR is set to INCR FC field is programmed with peripheral to memory flow control mode. SRC_DSCR is set to 0. (descriptor fetch is enabled for the SRC) DST_DSCR is set to TRUE. (descriptor fetch is disabled for the DST) DIF and SIF are set with their respective layer ID. If SIF is different from DIF, the DMA Controller is able to prefetch data and write HSMCI simultaneously.
8. Program the LLI_W(n).DMAC_CFGx register for Channel x with the following fields values:
1066
DST_REP is set to zero. Address are contiguous. SRC_H2SEL is set to true to enable hardware handshaking on the destination. SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller.
9. Program LLI_W(n).DMAC_DSCRx with the address of LLI_W(n+1) descriptor. And set the DSCRx_IF to the AHB Layer ID. This operation actually links descriptors together. If LLI_W(n) is the last descriptor then LLI_W(n).DMAC_DSCRx points to 0.
10. Program the DMAC_CTRLBx register for Channel x with 0. its content is updated with the LLI Fetch operation. 11. Program the DMAC_DSCRx register for Channel x with the address of LLI_W(0). 12. Enable Channel x writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request. 5. 6. 7. 8. 9. Poll CBTC[x] bit in the DMAC_EBCISR register. If a new list of buffers shall be transferred repeat step 7. Check and handle HSMCI errors. Poll FIFOEMPTY field in the HSMCI_SR. Send The STOP_TRANSMISSION command writing the HSMCI_ARG then the HSMCI_CMDR. Wait for XFRDONE in the HSMCI_SR register.
1067
37.9
1068
GO_IDLE_STATE (CMD0): used for hard reset. STOP_TRANSMISSION (CMD12): causes the ATA command currently executing to be aborted. FAST_IO (CMD39): Used for single register access to the ATA taskfile registers, 8 bit access only. RW_MULTIPLE_REGISTERS (CMD60): used to issue an ATA command or to access the control/status registers. RW_MULTIPLE_BLOCK (CMD61): used to transfer data for an ATA command.
CE-ATA utilizes the same MMC command sequences for initialization as traditional MMC devices.
No response to an MMC command, such as RW_MULTIPLE_REGISTER (CMD60). CRC is invalid for an MMC command or response. CRC16 is invalid for an MMC data packet. ATA Status register reflects an error by setting the ERR bit to one. The command completion signal does not arrive within a host specified time out period.
Error conditions are expected to happen infrequently. Thus, a robust error recovery mechanism may be used for each error event. The recommended error recovery procedure after a timeout is:
z z z
Issue the command completion signal disable if nIEN was cleared to zero and the RW_MULTIPLE_BLOCK (CMD61) response has been received. Issue STOP_TRANSMISSION (CMD12) and successfully receive the R1 response. Issue a software reset to the CE-ATA device using FAST_IO (CMD39).
If STOP_TRANMISSION (CMD12) is successful, then the device is again ready for ATA commands. However, if the error recovery procedure does not work as expected or there is another timeout, the next step is to issue GO_IDLE_STATE (CMD0) to the device. GO_IDLE_STATE (CMD0) is a hard reset to the device and completely resets all device states. Note that after issuing GO_IDLE_STATE (CMD0), all device initialization needs to be completed again. If the CE-ATA device completes all MMC commands correctly but fails the ATA command with the ERR bit set in the ATA Status
1069
register, no error recovery action is required. The ATA command itself failed implying that the device could not complete the action requested, however, there was no communication or protocol failure. After the device signals an error by setting the ERR bit to one in the ATA Status register, the host may attempt to retry the command.
1070
CMDRDY flag
The CMDRDY flag is released 8 tbit after the end of the card response.
XFRDONE flag
CMDRDY flag
The CMDRDY flag is released 8 tbit after the end of the card response.
Last Block
XFRDONE flag
1071
HSMCI Mode Register on page 1075 HSMCI Data Timeout Register on page 1076 HSMCI SDCard/SDIO Register on page 1077 HSMCI Completion Signal Timeout Register on page 1082 HSMCI DMA Configuration Register on page 1094 HSMCI Configuration Register on page 1095
1072
Name HSMCI_CR HSMCI_MR HSMCI_DTOR HSMCI_SDCR HSMCI_ARGR HSMCI_CMDR HSMCI_BLKR HSMCI_CSTOR HSMCI_RSPR HSMCI_RSPR HSMCI_RSPR HSMCI_RSPR HSMCI_RDR HSMCI_TDR HSMCI_SR HSMCI_IER HSMCI_IDR HSMCI_IMR HSMCI_DMA HSMCI_CFG HSMCI_WPMR HSMCI_WPSR HSMCI_FIFO0 ... HSMCI_FIFO255
Access Write Read-write Read-write Read-write Read-write Write Read-write Read-write Read Read Read Read Read Write Read Write Write Read Read-write Read-write Read-write Read-only Read-write ... Read-write
Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xC0E5 0x0 0x00 0x00 0x0 ... 0x0
Response Register(1) Receive Data Register Transmit Data Register Reserved Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register DMA Configuration Register Configuration Register Reserved Write Protection Mode Register Write Protection Status Register Reserved Reserved FIFO Memory Aperture0 ... FIFO Memory Aperture255
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.
1073
1074
31 23 15 7
30 22 14 PADV 6
29 21 13 FBYTE 5
28 20 12 WRPROOF 4 CLKDIV
27 19 11 RDPROOF 3
26 18 10
25 17 9 PWSDIV 1
24 16 CLKODD 8
This register can only be written if the WPEN bit is cleared in HSMCI Write Protect Mode Register on page 1096.
CLKDIV: Clock Divider High Speed MultiMedia Card Interface clock (MCCK or HSMCI_CK) is Master Clock (MCK) divider by ({CLKDIV,CLKODD}+2). PWSDIV: Power Saving Divider High Speed MultiMedia Card Interface clock is divided by 2(PWSDIV) + 1 when entering Power Saving Mode. Warning: This value must be different from 0 before enabling the Power Save Mode in the HSMCI_CR (HSMCI_PWSEN bit). RDPROOF: Read Proof Enable Enabling Read Proof allows to stop the HSMCI Clock during read access if the internal FIFO is full. This will guarantee data integrity, not bandwidth. 0 = Disables Read Proof. 1 = Enables Read Proof. WRPROOF: Write Proof Enable Enabling Write Proof allows to stop the HSMCI Clock during write access if the internal FIFO is full. This will guarantee data integrity, not bandwidth. 0 = Disables Write Proof. 1 = Enables Write Proof. FBYTE: Force Byte Transfer Enabling Force Byte Transfer allow byte transfers, so that transfer of blocks with a size different from modulo 4 can be supported. Warning: BLKLEN value depends on FBYTE. 0 = Disables Force Byte Transfer. 1 = Enables Force Byte Transfer. PADV: Padding Value 0 = 0x00 value is used when padding data in write transfer. 1 = 0xFF value is used when padding data in write transfer. PADV may be only in manual transfer. CLKODD: Clock divider is odd This field is the least significant bit of the clock divider and indicates the clock divider parity. SAMA5D3 Series [DATASHEET]
11121BATARM08-Mar-13
1075
This register can only be written if the WPEN bit is cleared in HSMCI Write Protect Mode Register on page 1096.
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.
1076
This register can only be written if the WPEN bit is cleared in HSMCI Write Protect Mode Register on page 1096.
Slot A is selected.
Reserved Reserved Reserved
1 bit Reserved
4 bit 8 bit
1077
23
22
21
20 ARG
19
18
17
16
15
14
13
12 ARG
11
10
4 ARG
1078
13 5
11 OPDCMD 3 CMDNB
This register is write-protected while CMDRDY is 0 in HSMCI_SR. If an Interrupt command is sent, this register is only writable by an interrupt response (field SPCMD). This means that the current command execution cannot be interrupted or modified.
CE_ATA
4 5 6 7
1079
1080
23
22
21
20 BLKLEN
19
18
17
16
15
14
13
12 BCNT
11
10
4 BCNT
1081
This register can only be written if the WPEN bit is cleared in HSMCI Write Protect Mode Register on page 1096.
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.
1082
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.
1083
23
22
21
20 DATA
19
18
17
16
15
14
13
12 DATA
11
10
4 DATA
23
22
21
20 DATA
19
18
17
16
15
14
13
12 DATA
11
10
4 DATA
1084
1085
For the Single Block Reads, the NOTBUSY flag is set at the end of the data read block. For the Multiple Block Reads with pre-defined block count, the NOTBUSY flag is set at the end of the last received data block. The NOTBUSY flag allows to deal with these different states. 0 = The HSMCI is not ready for new data transfer. Cleared at the end of the card response. 1 = The HSMCI is ready for new data transfer. Set when the busy state on the data line has ended. This corresponds to a free internal data receive buffer of the card.
1086
OVRE: Overrun
0 = No error. 1 = At least one 8-bit received data has been lost (not read). Cleared when sending a new data transfer command. When FERRCTRL in HSMCI_CFG is set to 1, OVRE becomes reset after read.
UNRE: Underrun
0 = No error. 1 = At least one 8-bit data has been sent without valid information (not written). Cleared when sending a new data transfer command or when setting FERRCTRL in HSMCI_CFG to 1. When FERRCTRL in HSMCI_CFG is set to 1, UNRE becomes reset after read.
1087
CMDRDY: Command Ready Interrupt Enable RXRDY: Receiver Ready Interrupt Enable TXRDY: Transmit Ready Interrupt Enable BLKE: Data Block Ended Interrupt Enable DTIP: Data Transfer in Progress Interrupt Enable NOTBUSY: Data Not Busy Interrupt Enable SDIOIRQA: SDIO Interrupt for Slot A Interrupt Enable SDIOWAIT: SDIO Read Wait Operation Status Interrupt Enable CSRCV: Completion Signal Received Interrupt Enable RINDE: Response Index Error Interrupt Enable RDIRE: Response Direction Error Interrupt Enable RCRCE: Response CRC Error Interrupt Enable RENDE: Response End Bit Error Interrupt Enable RTOE: Response Time-out Error Interrupt Enable DCRCE: Data CRC Error Interrupt Enable DTOE: Data Time-out Error Interrupt Enable CSTOE: Completion Signal Timeout Error Interrupt Enable BLKOVRE: DMA Block Overrun Error Interrupt Enable DMADONE: DMA Transfer completed Interrupt Enable
1088
FIFOEMPTY: FIFO empty Interrupt enable XFRDONE: Transfer Done Interrupt enable ACKRCV: Boot Acknowledge Interrupt Enable ACKRCVE: Boot Acknowledge Error Interrupt Enable OVRE: Overrun Interrupt Enable UNRE: Underrun Interrupt Enable
0 = No effect. 1 = Enables the corresponding interrupt.
1089
CMDRDY: Command Ready Interrupt Disable RXRDY: Receiver Ready Interrupt Disable TXRDY: Transmit Ready Interrupt Disable BLKE: Data Block Ended Interrupt Disable DTIP: Data Transfer in Progress Interrupt Disable NOTBUSY: Data Not Busy Interrupt Disable SDIOIRQA: SDIO Interrupt for Slot A Interrupt Disable SDIOWAIT: SDIO Read Wait Operation Status Interrupt Disable CSRCV: Completion Signal received interrupt Disable RINDE: Response Index Error Interrupt Disable RDIRE: Response Direction Error Interrupt Disable RCRCE: Response CRC Error Interrupt Disable RENDE: Response End Bit Error Interrupt Disable RTOE: Response Time-out Error Interrupt Disable DCRCE: Data CRC Error Interrupt Disable DTOE: Data Time-out Error Interrupt Disable CSTOE: Completion Signal Time out Error Interrupt Disable BLKOVRE: DMA Block Overrun Error Interrupt Disable DMADONE: DMA Transfer completed Interrupt Disable
1090
FIFOEMPTY: FIFO empty Interrupt Disable XFRDONE: Transfer Done Interrupt Disable ACKRCV: Boot Acknowledge Interrupt Disable ACKRCVE: Boot Acknowledge Error Interrupt Disable OVRE: Overrun Interrupt Disable UNRE: Underrun Interrupt Disable
0 = No effect. 1 = Disables the corresponding interrupt.
1091
CMDRDY: Command Ready Interrupt Mask RXRDY: Receiver Ready Interrupt Mask TXRDY: Transmit Ready Interrupt Mask BLKE: Data Block Ended Interrupt Mask DTIP: Data Transfer in Progress Interrupt Mask NOTBUSY: Data Not Busy Interrupt Mask SDIOIRQA: SDIO Interrupt for Slot A Interrupt Mask SDIOWAIT: SDIO Read Wait Operation Status Interrupt Mask CSRCV: Completion Signal Received Interrupt Mask RINDE: Response Index Error Interrupt Mask RDIRE: Response Direction Error Interrupt Mask RCRCE: Response CRC Error Interrupt Mask RENDE: Response End Bit Error Interrupt Mask RTOE: Response Time-out Error Interrupt Mask DCRCE: Data CRC Error Interrupt Mask DTOE: Data Time-out Error Interrupt Mask CSTOE: Completion Signal Time-out Error Interrupt Mask BLKOVRE: DMA Block Overrun Error Interrupt Mask DMADONE: DMA Transfer Completed Interrupt Mask
1092
FIFOEMPTY: FIFO Empty Interrupt Mask XFRDONE: Transfer Done Interrupt Mask ACKRCV: Boot Operation Acknowledge Received Interrupt Mask ACKRCVE: Boot Operation Acknowledge Error Interrupt Mask OVRE: Overrun Interrupt Mask UNRE: Underrun Interrupt Mask
0 = The corresponding interrupt is not enabled. 1 = The corresponding interrupt is enabled.
1093
23 15 7
22 14 6
This register can only be written if the WPEN bit is cleared in HSMCI Write Protect Mode Register on page 1096.
Value 0 1 2 3 4
Name 1 4 8 16 32
Description 1 data available 4 data available 8 data available 16 data available 32 data available
1094
23 15 7
22 14 6
This register can only be written if the WPEN bit is cleared in HSMCI Write Protect Mode Register on page 1096.
1095
23
22
21
18
17
16
15
14
13
10
0 WP_EN
HSMCI Mode Register on page 1075 HSMCI Data Timeout Register on page 1076 HSMCI SDCard/SDIO Register on page 1077 HSMCI Completion Signal Timeout Register on page 1082 HSMCI DMA Configuration Register on page 1094 HSMCI Configuration Register on page 1095
1096
15
14
13
12 WP_VSRC
11
10
2 WP_VS
1097
23
22
21
20 DATA
19
18
17
16
15
14
13
12 DATA
11
10
4 DATA
1098
38.
38.1
Master Out Slave In (MOSI): This data line supplies the output data from the master shifted into the input(s) of the slave(s). Master In Slave Out (MISO): This data line supplies the output data from a slave to the input of the master. There may be no more than one slave transmitting data during any particular transfer. Serial Clock (SPCK): This control line is driven by the master and regulates the flow of the data bits. The master may transmit data at a variety of baud rates; the SPCK line cycles once for each bit that is transmitted. Slave Select (NSS): This control line allows slaves to be turned on and off by hardware.
38.2
Embedded Characteristics
z
Master Mode can drive SPCK up to peripheral clock (bounded by maximum bus clock divided by 2) Slave Mode operates on SPCK, asynchronously to Core and Bus Clock Four Chip Selects with External Decoder Support Allow Communication with Up to 15 Peripherals Serial Memories, such as DataFlash and 3-wire EEPROMs Serial Peripherals, such as ADCs, DACs, LCD Controllers, CAN Controllers and Sensors External Coprocessors 8-bit to 16-bit Programmable Data Length Per Chip Select Programmable Phase and Polarity Per Chip Select Programmable Transfer Delay Between Consecutive Transfers and Delay before SPI Clock per Chip Select Programmable Delay Between Chip Selects Selectable Mode Fault Detection One channel for the Receiver, One Channel for the Transmitter
1099
38.3
Block Diagram
Peripheral Bridge APB SPCK MISO MCK SPI Interface PIO MOSI NPCS0/NSS NPCS1 NPCS2 Interrupt Control NPCS3
PMC
SPI Interrupt
1100
38.4
38.5
Signal Description
Signal Description
Pin Name Pin Description Master MISO MOSI SPCK NPCS1-NPCS3 NPCS0/NSS Master In Slave Out Master Out Slave In Serial Clock Peripheral Chip Selects Peripheral Chip Select/Slave Select Input Output Output Output Output Type Slave Output Input Input Unused Input
1101
38.6
Product Dependencies
38.6.3 Interrupt
The SPI interface has an interrupt line connected to the Interrupt Controller. Handling the SPI interrupt requires programming the interrupt controller before configuring the SPI.
Table 38-2. Peripheral IDs Instance SPI0 SPI1 ID 24 25
1102
38.7
Functional Description
1103
SPCK (CPOL = 1)
MSB
LSB
MSB
LSB
SPCK (CPOL = 1)
MSB
LSB
MSB
LSB
1104
1105
MCK
SPCK
SPI_RDR RD
RDRF OVRES
Shift Register
MSB
MOSI
SPI_TDR TD SPI_CSR0..3 SPI_RDR CSAAT PS SPI_MR PCS 0 SPI_TDR PCS 1 NPCS0 PCSDEC Current Peripheral PCS NPCS3 NPCS2 NPCS1 TDRE
MODF
1106
NPCS = SPI_TDR(PCS)
Delay DLYBCS
Delay DLYBCS
NPCS = SPI_TDR(PCS)
Delay DLYBS
Data Transfer
Delay DLYBCT
0 TDRE ?
1 CSAAT ?
0 NPCS = 0xF
Delay DLYBCS
1107
Figure 38-7 shows Transmit Data Register Empty (TDRE), Receive Data Register (RDRF) and Transmission Register Empty (TXEMPTY) status flags behavior within the SPI_SR (Status Register) during an 8-bit data transfer in fixed mode and no Peripheral Data Controller involved.
Figure 38-7. Status Register Flags Behavior
1 SPCK NPCS0 MOSI (from master) TDRE RDR read Write in SPI_TDR RDRF MISO (from slave) TXEMPTY MSB 6 5 4 3 2 1 LSB 2 3 4 5 6 7 8
MSB
LSB
38.7.3.3 Clock Generation The SPI Baud rate clock is generated by dividing the Master Clock (MCK), by a value between 1 and 255. This allows a maximum operating baud rate at up to Master Clock and a minimum operating baud rate of MCK divided by 255. Programming the SCBR field at 0 is forbidden. Triggering a transfer while SCBR is at 0 can lead to unpredictable results. At reset, SCBR is 0 and the user has to program it at a valid value before performing the first transfer. The divisor can be defined independently for each chip select, as it has to be programmed in the SCBR field of the Chip Select Registers. This allows the SPI to automatically adapt the baud rate for each interfaced peripheral without reprogramming. 38.7.3.4 Transfer Delays Figure 38-8 shows a chip select transfer change and consecutive transfers on the same chip select. Three delays can be programmed to modify the transfer waveforms:
z z z
The delay between chip selects, programmable only once for all the chip selects by writing the DLYBCS field in the Mode Register. Allows insertion of a delay between release of one chip select and before assertion of a new one. The delay before SPCK, independently programmable for each chip select by writing the field DLYBS. Allows the start of SPCK to be delayed after the chip select has been asserted. The delay between consecutive transfers, independently programmable for each chip select by writing the DLYBCT field. Allows insertion of a delay between two transfers occurring on the same chip select
These delays allow the SPI to be adapted to the interfaced peripherals and their speed and bus release time.
1108
Chip Select 1
Chip Select 2
38.7.3.5 Peripheral Selection The serial peripherals are selected through the assertion of the NPCS0 to NPCS3 signals. By default, all the NPCS signals are high before and after each transfer.
z
Fixed Peripheral Select: SPI exchanges data with only one peripheral
Fixed Peripheral Select is activated by writing the PS bit to zero in SPI_MR (Mode Register). In this case, the current peripheral is defined by the PCS field in SPI_MR and the PCS field in the SPI_TDR has no effect.
z
Variable Peripheral Select: Data can be exchanged with more than one peripheral without having to reprogram the NPCS field in the SPI_MR register.
Variable Peripheral Select is activated by setting PS bit to one. The PCS field in SPI_TDR is used to select the current peripheral. This means that the peripheral selection can be defined for each new data. The value to write in the SPI_TDR register as the following format. [xxxxxxx(7-bit) + LASTXFER(1-bit)(1)+ xxxx(4-bit) + PCS (4-bit) + DATA (8 to 16-bit)] with PCS equals to the chip select to assert as defined in Section 38.8.4 (SPI Transmit Data Register) and LASTXFER bit at 0 or 1 depending on CSAAT bit. Note: 1. Optional. CSAAT, LASTXFER and CSNAAT bits are discussed in Section 38.7.3.8 Peripheral Deselection with DMAC . If LASTXFER is used, the command must be issued before writing the last character. Instead of LASTXFER, the user can use the SPIDIS command. After the end of the DMA transfer, wait for the TXEMPTY flag, then write SPIDIS into the SPI_CR register (this will not change the configuration register values); the NPCS will be deactivated after the last character transfer. Then, another DMA transfer can be started if the SPIEN was previously written in the SPI_CR register. 38.7.3.6 SPI Direct Access Memory Controller (DMAC) In both fixed and variable mode the Direct Memory Access Controller (DMAC) can be used to reduce processor overhead. The Fixed Peripheral Selection allows buffer transfers with a single peripheral. Using the DMAC is an optimal means, as the size of the data transfer between the memory and the SPI is either 8 bits or 16 bits. However, changing the peripheral selection requires the Mode Register to be reprogrammed. The Variable Peripheral Selection allows buffer transfers with multiple peripherals without reprogramming the Mode Register. Data written in SPI_TDR is 32 bits wide and defines the real data to be transmitted and the peripheral it is destined to. Using the DMAC in this mode requires 32-bit wide buffers, with the data in the LSBs and the PCS and LASTXFER fields in the MSBs, however the SPI still controls the number of bits (8 to16) to be transferred through MISO and MOSI lines with the chip select configuration registers. This is not the optimal means in term of memory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor.
1109
38.7.3.7 Peripheral Chip Select Decoding The user can program the SPI to operate with up to 15 peripherals by decoding the four Chip Select lines, NPCS0 to NPCS3 with 1 of up to 16 decoder/demultiplexer. This can be enabled by writing the PCSDEC bit at 1 in the Mode Register (SPI_MR). When operating without decoding, the SPI makes sure that in any case only one chip select line is activated, i.e., one NPCS line driven low at a time. If two bits are defined low in a PCS field, only the lowest numbered chip select is driven low. When operating with decoding, the SPI directly outputs the value defined by the PCS field on NPCS lines of either the Mode Register or the Transmit Data Register (depending on PS). As the SPI sets a default value of 0xF on the chip select lines (i.e. all chip select lines at 1) when not processing any transfer, only 15 peripherals can be decoded. The SPI has only four Chip Select Registers, not 15. As a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. As an example, SPI_CRS0 defines the characteristics of the externally decoded peripherals 0 to 3, corresponding to the PCS values 0x0 to 0x3. Thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14. Figure 38-9 below shows such an implementation. If the CSAAT bit is used, with or without the DMAC, the Mode Fault detection for NPCS0 line must be disabled. This is not needed for all other chip select lines since Mode Fault Detection is only on NPCS0.
Figure 38-9. Chip Select Decoding Application Block Diagram: Single Master/Multiple Slave Implementation
SPCK MISO MOSI SPCK MISO MOSI Slave 0 SPI Master NSS NPCS0 NPCS1 NPCS2 NPCS3 SPCK MISO MOSI Slave 1 NSS SPCK MISO MOSI Slave 14 NSS
1-of-n Decoder/Demultiplexer
Peripheral Deselection without DMA During a transfer of more than one data on a Chip Select without the DMA, the SPI_TDR is loaded by the processor, the flag TDRE rises as soon as the content of the SPI_TDR is transferred into the internal shift register. When this flag is detected high, the SPI_TDR can be reloaded. If this reload by the processor occurs before the end of the current transfer and if the next transfer is performed on the same chip select as the current transfer, the Chip Select is not de-asserted between the two transfers. But depending on the application software handling the SPI status register flags (by interrupt or polling method) or servicing other interrupts or other tasks, the processor may not reload the SPI_TDR in time to keep the chip select active (low). A null Delay Between Consecutive Transfer (DLYBCT) value in the SPI_CSR register, will give even less time for the processor to reload the SPI_TDR. With some SPI slave peripherals, requiring the chip select line to remain active (low) during a full set of transfers might lead to communication errors.
1110
To facilitate interfacing with such devices, the Chip Select Register [CSR0...CSR3] can be programmed with the CSAAT bit (Chip Select Active After Transfer) at 1. This allows the chip select lines to remain in their current state (low = active) until transfer to another chip select is required. Even if the SPI_TDR is not reloaded the chip select will remain active. To have the chip select line to raise at the end of the transfer the Last transfer Bit (LASTXFER) in the SPI_MR register must be set at 1 before writing the last data to transmit into the SPI_TDR. 38.7.3.8 Peripheral Deselection with DMAC When the Direct Memory Access Controller is used, the chip select line will remain low during the whole transfer since the TDRE flag is managed by the DMAC itself. The reloading of the SPI_TDR by the DMAC is done as soon as TDRE flag is set to one. In this case the use of CSAAT bit might not be needed. However, it may happen that when other DMAC channels connected to other peripherals are in use as well, the SPI DMAC might be delayed by another (DMAC with a higher priority on the bus). Having DMAC buffers in slower memories like flash memory or SDRAM compared to fast internal SRAM, may lengthen the reload time of the SPI_TDR by the DMAC as well. This means that the SPI_TDR might not be reloaded in time to keep the chip select line low. In this case the chip select line may toggle between data transfer and according to some SPI Slave devices, the communication might get lost. The use of the CSAAT bit might be needed. If chip select must be deasserted between each data when communicating with a slave device such as an SPI ADC for example, one can workaround this by using another ghost chip select line. In this case, the variable mode must be used. In this mode, the assertion of the corresponding chip select (CS) depends on the PCS field within SPI_TDR.
z z
Thereafter, an example of such implementation: NPCS0(1): Actual SPI Slave Device NPCS1(1): Ghost SPI Slave Device
Transmit Buffer must be initialized in the following way according to the SPI_TDR register (See Section 38.8.4 SPI Transmit Data Register on page 1120) to send data equal to 0xAB with NPCS0 and to send data equal to 0xCD on NPCS1. [BUFFER_ADDR(2)] = 0x0000 00AB <------ Transfer on NPCS0 [BUFFER_ADDR + 0x4] = 0x0001 000CD <------ Dummy transfer on NPCS1 [BUFFER_ADDR + 0x8] = 0x0000 000AB <------ Transfer on NPCS0 [BUFFER_ADDR + 0xC] = 0x0001 000CD <------ Dummy transfer on NPCS1 Please note that in this case the size of the buffer will be twice the actual size needed. Notes: 1. 2. Can be any other chip select line. Transmit Buffer address.
When the CSAAT bit is set at 0, the NPCS does not rise in all cases between two transfers on the same peripheral. During a transfer on a Chip Select, the flag TDRE rises as soon as the content of the SPI_TDR is transferred into the internal shifter. When this flag is detected the SPI_TDR can be reloaded. If this reload occurs before the end of the current transfer and if the next transfer is performed on the same chip select as the current transfer, the Chip Select is not de-asserted between the two transfers. This might lead to difficulties for interfacing with some serial peripherals requiring the chip select to be de-asserted after each transfer. To facilitate interfacing with such devices, the Chip Select Register can be programmed with the CSNAAT bit (Chip Select Not Active After Transfer) at 1. This allows to de-assert systematically the chip select lines during a time DLYBCS. (The value of the CSNAAT bit is taken into account only if the CSAAT bit is set at 0 for the same Chip Select). Figure 38-10 shows different peripheral deselection cases and the effect of the CSAAT and CSNAAT bits.
1111
TDRE
NPCS[0..3]
Write SPI_TDR
TDRE
NPCS[0..3]
Write SPI_TDR
TDRE NPCS[0..3]
Write SPI_TDR
NPCS[0..3]
A DLYBCS
PCS = A
1112
38.7.3.9 Mode Fault Detection A mode fault is detected when the SPI is programmed in Master Mode and a low level is driven by an external master on the NPCS0/NSS signal. In this case, multi-master configuration, NPCS0, MOSI, MISO and SPCK pins must be configured in open drain (through the PIO controller). When a mode fault is detected, the MODF bit in the SPI_SR is set until the SPI_SR is read and the SPI is automatically disabled until re-enabled by writing the SPIEN bit in the SPI_CR (Control Register) at 1. By default, the Mode Fault detection circuitry is enabled. The user can disable Mode Fault detection by setting the MODFDIS bit in the SPI Mode Register (SPI_MR).
When all the bits are processed, the received data is transferred in the Receive Data Register and the RDRF bit rises. If the SPI_RDR (Receive Data Register) has not been read before new data is received, the Overrun Error bit (OVRES) in SPI_SR is set. As long as this flag is set, data is loaded in SPI_RDR. The user has to read the status register to clear the OVRES bit. When a transfer starts, the data shifted out is the data present in the Shift Register. If no data has been written in the Transmit Data Register (SPI_TDR), the last data received is transferred. If no data has been received since the last reset, all bits are transmitted low, as the Shift Register resets at 0. When a first data is written in SPI_TDR, it is transferred immediately in the Shift Register and the TDRE bit rises. If new data is written, it remains in SPI_TDR until a transfer occurs, i.e. NSS falls and there is a valid clock on the SPCK pin. When the transfer occurs, the last data written in SPI_TDR is transferred in the Shift Register and the TDRE bit rises. This enables frequent updates of critical variables with single transfers. Then, a new data is loaded in the Shift Register from the Transmit Data Register. In case no character is ready to be transmitted, i.e. no character has been written in SPI_TDR since the last load from SPI_TDR to the Shift Register, the Shift Register is not modified and the last received character is retransmitted. In this case the Underrun Error Status Flag (UNDES) is set in the SPI_SR. Figure 38-11 shows a block diagram of the SPI when operating in Slave Mode.
1113
Shift Register
MSB
MISO
SPI_TDR TD TDRE
1114
38.8
Table 38-4. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 - 0x2C 0x30 0x34 0x38 0x3C 0x4C - 0xE0 0xE4 0xE8 0x00E8 - 0x00F8 0x00FC 0x100 - 0x124 Control Register Mode Register Receive Data Register Transmit Data Register Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Reserved Chip Select Register 0 Chip Select Register 1 Chip Select Register 2 Chip Select Register 3 Reserved Write Protection Control Register Write Protection Status Register Reserved Reserved Reserved for PDC Registers SPI_CSR0 SPI_CSR1 SPI_CSR2 SPI_CSR3 SPI_WPMR SPI_WPSR Read-write Read-write Read-write Read-write Read-write Read-only 0x0 0x0 0x0 0x0 0x0 0x0 Register Name SPI_CR SPI_MR SPI_RDR SPI_TDR SPI_SR SPI_IER SPI_IDR SPI_IMR Access Write-only Read-write Read-only Write-only Read-only Write-only Write-only Read-only Reset --0x0 0x0 --0x000000F0 ----0x0
1115
23
22
21
20
19
18
17
LASTXFER
16
15
14
13
12
11
10
SWRST
SPIDIS
SPIEN
1116
DLYBCS
23 22 21 20 19 18 17 16
15
14
13
12 11 10
PCS
9 8
LLB
WDRBT
MODFDIS
PCSDEC
PS
MSTR
This register can only be written if the WPEN bit is cleared in SPI Write Protection Mode Register.
1117
1118
23
22
21
20
19
18
17
16
15
14
13
12 11 10
PCS
9 8
RD
7 6 5 4 3 2 1 0
RD
1119
23
22
21
20
19
18
17
LASTXFER
16
15
14
13
12 11 10
PCS
9 8
TD
7 6 5 4 3 2 1 0
TD
1120
23
22
21
20
19
18
17
16
15
14
13
12
11
10
SPIENS
8
UNDES
2
TXEMPTY
1
NSSR
0
OVRES
MODF
TDRE
RDRF
RDRF: Receive Data Register Full 0 = No data has been received since the last read of SPI_RDR
1 = Data has been received and the received data has been transferred from the serializer to SPI_RDR since the last read of SPI_RDR.
TDRE: Transmit Data Register Empty 0 = Data has been written to SPI_TDR and not yet transferred to the serializer.
1 = The last data written in the Transmit Data Register has been transferred to the serializer. TDRE equals zero when the SPI is disabled or at reset. The SPI enable command sets this bit to one.
MODF: Mode Fault Error 0 = No Mode Fault has been detected since the last read of SPI_SR.
1 = A Mode Fault occurred since the last read of the SPI_SR.
OVRES: Overrun Error Status 0 = No overrun has been detected since the last read of SPI_SR.
1 = An overrun has occurred since the last read of SPI_SR. An overrun occurs when SPI_RDR is loaded at least twice from the serializer since the last read of the SPI_RDR.
NSSR: NSS Rising 0 = No rising edge detected on NSS pin since last read.
1 = A rising edge occurred on NSS pin since last read.
UNDES: Underrun Error Status (Slave Mode Only) 0 = No underrun has been detected since the last read of SPI_SR.
1 = A transfer begins whereas no data has been loaded in the Transmit Data Register.
1121
23
22
21
20
19
18
17
16
15
14
13
12
11
10
UNDES
2
TXEMPTY
1
NSSR
0
OVRES
MODF
TDRE
RDRF
RDRF: Receive Data Register Full Interrupt Enable TDRE: SPI Transmit Data Register Empty Interrupt Enable MODF: Mode Fault Error Interrupt Enable OVRES: Overrun Error Interrupt Enable NSSR: NSS Rising Interrupt Enable TXEMPTY: Transmission Registers Empty Enable UNDES: Underrun Error Interrupt Enable
0 = No effect. 1 = Enables the corresponding interrupt.
1122
23
22
21
20
19
18
17
16
15
14
13
12
11
10
UNDES
2
TXEMPTY
1
NSSR
0
OVRES
MODF
TDRE
RDRF
RDRF: Receive Data Register Full Interrupt Disable TDRE: SPI Transmit Data Register Empty Interrupt Disable MODF: Mode Fault Error Interrupt Disable OVRES: Overrun Error Interrupt Disable NSSR: NSS Rising Interrupt Disable TXEMPTY: Transmission Registers Empty Disable UNDES: Underrun Error Interrupt Disable
0 = No effect. 1 = Disables the corresponding interrupt.
1123
23
22
21
20
19
18
17
16
15
14
13
12
11
10
UNDES
2
TXEMPTY
1
NSSR
0
OVRES
MODF
TDRE
RDRF
RDRF: Receive Data Register Full Interrupt Mask TDRE: SPI Transmit Data Register Empty Interrupt Mask MODF: Mode Fault Error Interrupt Mask OVRES: Overrun Error Interrupt Mask NSSR: NSS Rising Interrupt Mask TXEMPTY: Transmission Registers Empty Mask UNDES: Underrun Error Interrupt Mask
0 = The corresponding interrupt is not enabled. 1 = The corresponding interrupt is enabled.
1124
DLYBCT
23 22 21 20 19 18 17 16
DLYBS
15 14 13 12 11 10 9 8
SCBR
7 6 5 4 3 2 1 0
BITS
CSAAT
CSNAAT
NCPHA
CPOL
This register can only be written if the WPEN bit is cleared in SPI Write Protection Mode Register. Note: SPI_CSRx registers must be written even if the user wants to use the defaults. The BITS field will not be updated with the translated value unless the register is written.
1125
DLYBS Delay Before SPCK = -----------------MCK DLYBCT: Delay Between Consecutive Transfers
This field defines the delay between two consecutive transfers with the same peripheral without removing the chip select. The delay is always inserted after each transfer and before removing the chip select if needed. When DLYBCT equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. Otherwise, the following equation determines the delay:
1126
WPKEY
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
Section 38.8.2 SPI Mode Register Section 38.8.9 SPI Chip Select Register
1127
WPVSRC
7 6 5 4 3 2 1 0
WPVS
1128
39.
39.1
39.2
Embedded Characteristics
z z z
20-bit Programmable Counter plus 12-bit Interval Counter Reset-on-read Feature Both Counters Work on Master Clock/16
1129
39.3
Block Diagram
PIV
PIT_MR
PITIEN
set
PIT_SR
PITS
reset
pit_irq
12-bit Adder
read PIT_PIVR
MCK
20-bit Counter
Prescaler
MCK/16
CPIV
PIT_PIVR
PICNT
CPIV
PIT_PIIR
PICNT
1130
39.4
Functional Description
The Periodic Interval Timer aims at providing periodic interrupts for use by operating systems. The PIT provides a programmable overflow counter and a reset-on-read feature. It is built around two counters: a 20-bit CPIV counter and a 12-bit PICNT counter. Both counters work at Master Clock /16. The first 20-bit CPIV counter increments from 0 up to a programmable overflow value set in the field PIV of the Mode Register (PIT_MR). When the counter CPIV reaches this value, it resets to 0 and increments the Periodic Interval Counter, PICNT. The status bit PITS in the Status Register (PIT_SR) rises and triggers an interrupt, provided the interrupt is enabled (PITIEN in PIT_MR). Writing a new PIV value in PIT_MR does not reset/restart the counters. When CPIV and PICNT values are obtained by reading the Periodic Interval Value Register (PIT_PIVR), the overflow counter (PICNT) is reset and the PITS is cleared, thus acknowledging the interrupt. The value of PICNT gives the number of periodic intervals elapsed since the last read of PIT_PIVR. When CPIV and PICNT values are obtained by reading the Periodic Interval Image Register (PIT_PIIR), there is no effect on the counters CPIV and PICNT, nor on the bit PITS. For example, a profiler can read PIT_PIIR without clearing any pending interrupt, whereas a timer interrupt clears the interrupt by reading PIT_PIVR. The PIT may be enabled/disabled using the PITEN bit in the PIT_MR register (disabled on reset). The PITEN bit only becomes effective when the CPIV value is 0. Figure 39-2 illustrates the PIT counting. After the PIT Enable bit is reset (PITEN= 0), the CPIV goes on counting until the PIV value is reached, and is then reset. PIT restarts counting, only if the PITEN is set again. The PIT is stopped when the core enters debug state.
1 0
PIV - 1
PIV 1
0 0
read PIT_PIVR
1131
39.5
Table 39-1. Register Mapping Offset 0x00 0x04 0x08 0x0C Register Mode Register Status Register Periodic Interval Value Register Periodic Interval Image Register Name PIT_MR PIT_SR PIT_PIVR PIT_PIIR Access Read-write Read-only Read-only Read-only Reset 0x000F_FFFF 0x0000_0000 0x0000_0000 0x0000_0000
1132
1133
1134
23
22 PICNT
21
20
19
18 CPIV
17
16
15
14
13
12 CPIV
11
10
4 CPIV
1135
23
22 PICNT
21
20
19
18 CPIV
17
16
15
14
13
12 CPIV
11
10
4 CPIV
1136
40.
40.1
Note:
1.
1137
40.2
Embedded Characteristics
z z z z z z z z z
3 TWIs Compatible with Atmel Two-wire Interface Serial Memory and IC Compatible Devices(1) One, Two or Three Bytes for Slave Address Sequential Read-write Operations Master, Multi-master and Slave Mode Operation Bit Rate: Up to 400 Kbits General Call Supported in Slave mode SMBUS Quick Command Supported in Master Mode Connection to DMA Controller (DMA) Channel Capabilities Optimizes Data Transfers
1. See Table 40-1 for details on compatibility with IC Standard.
Note:
40.3
List of Abbreviations
Table 40-2. Abbreviations Abbreviation TWI A NA P S Sr SADR ADR R W Description Two-wire Interface Acknowledge Non Acknowledge Stop Start Repeated Start Slave Address Any address except SADR Read Write
1138
40.4
Block Diagram
Figure 40-1. Block Diagram
APB Bridge
PMC
MCK
TWI Interrupt
Interrupt Controller
40.5
IC RTC Slave 2
1139
40.6
Product Dependencies
Program the PIO controller to dedicate TWD and TWCK as peripheral lines.
The user must not program TWD and TWCK as open-drain. It is already done by the hardware.
Table 40-4. I/O Lines Instance TWI0 TWI0 TWI1 TWI1 TWI2 TWI2 Signal TWCK0 TWD0 TWCK1 TWD1 TWCK2 TWD2 I/O Line PA31 PA30 PC27 PC26 PA19 PA18 Peripheral A A B B B B
The TWI interface may be clocked through the Power Management Controller (PMC), thus the programmer must first configure the PMC to enable the TWI clock.
40.6.3 Interrupt
The TWI interface has an interrupt line connected to the Interrupt Controller. In order to handle interrupts, the Interrupt Controller must be programmed before configuring the TWI.
Table 40-5. Peripheral IDs Instance TWI0 TWI1 TWI2 ID 18 19 20
1140
40.7
Functional Description
A high-to-low transition on the TWD line while TWCK is high defines the START condition. A low-to-high transition on the TWD line while TWCK is high defines a STOP condition.
TWD
TWD
TWCK
Start
Address
R/W
Ack
Data
Ack
Data
Ack
Stop
Master transmitter mode Master receiver mode Multi-master transmitter mode Multi-master receiver mode Slave transmitter mode
z Slave receiver mode These modes are described in the following chapters.
1141
40.8
Master Mode
40.8.1 Definition
The Master is the device that starts a transfer, generates a clock and stops it.
IC RTC Slave 2
1142
TWD
DADR
DATA
TXCOMP
TWD
DADR
DATA n
DATA n+1
DATA n+2
TWCK
TXCOMP
TXRDY Write THR (Data n) Write THR (Data n+1) Write THR (Data n+2) Last data sent
Figure 40-8. Master Write with One Byte Internal Address and Multiple Data Bytes
STOP command performed (by writing in the TWI_CR)
TWD
DADR
IADR
DATA n
DATA n+1
DATA n+2
TWCK
TXCOMP
TXRDY Write THR (Data n) Write THR (Data n+1) Write THR (Data n+2) Last data sent
1143
TXCOMP Write START Bit RXRDY Read RHR DATA n Read RHR DATA (n+1) Read RHR DATA (n+m)-1 Read RHR DATA (n+m)
1144
Figure 40-11. Master Read Clock Stretching with Multiple Data Bytes
STOP command performed (by writing in the TWI_CR) Clock Streching
TWD
DADR
DATA n
DATA n+1
DATA n+2
TWCK
TXCOMP
RXRDY
S Sr P W R A N DADR IADR
Start Repeated Start Stop Write Read Acknowledge Not Acknowledge Device Address Internal Address
1145
Figure 40-12. Master Write with One, Two or Three Bytes Internal Address and One Data Byte
Three bytes internal address TWD
S DADR W A IADR(23:16) A IADR(15:8) A IADR(7:0) A DATA A P
Figure 40-13. 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 Two bytes internal address TWD S DADR W A IADR(15:8) A IADR(7:0) A Sr DADR R A DATA
40.8.6.2 10-bit Slave Addressing For a slave address higher than 7 bits, the user must configure the address size (IADRSZ) and set the other slave address bits in the internal address register (TWI_IADR). The two remaining Internal address bytes, IADR[15:8] and IADR[23:16] can be used the same as in 7-bit Slave Addressing. Example: Address a 10-bit device (10-bit device address is b1 b2 b3 b4 b5 b6 b7 b8 b9 b10) 1. 2. 3. Program IADRSZ = 1, Program DADR with 1 1 1 1 0 b1 b2 (b1 is the MSB of the 10-bit address, b2, etc.) Program TWI_IADR with b3 b4 b5 b6 b7 b8 b9 b10 (b10 is the LSB of the 10-bit address)
Figure 40-14 below shows a byte write to an Atmel AT24LC512 EEPROM. This demonstrates the use of internal addresses to access the device.
Figure 40-14. Internal Address Usage
S T A R T W R I T E S T O P
Device Address 0 M S B
DATA
LR A S / C BW K
M S B
A C K
LA SC BK
A C K
1146
40.8.7.1 Data Transmit with the DMA 1. 2. 3. 4. 5. 6. 7. 8. 9. Initialize the DMA (channels, memory pointers, size -1, etc.); Configure the master mode (DADR, CKDIV, etc.) or slave mode. Enable the DMA. Wait for the DMA BTC flag. Disable the DMA. Wait for the TXRDY flag in TWI_SR register Set the STOP command in TWI_CR. Write the last character in TWI_THR (Optional) Wait for the TXCOMP flag in TWI_SR register before disabling the peripheral clock if required
40.8.7.2 Data Receive with the DMA The DMA transfer size must be defined with the buffer size minus 2. The two remaining characters must be managed without DMA to ensure that the exact number of bytes are received whatever the system bus latency conditions encountered during the end of buffer transfer period. In slave mode, the number of characters to receive must be known in order to configure the DMA. 1. 2. 3. 4. 5. 6. 7. 8. 9. Initialize the DMA (channels, memory pointers, size -2, etc.); Configure the master mode (DADR, CKDIV, etc.) or slave mode. Enable the DMA. (Master Only) Write the START bit in the TWI_CR register to start the transfer Wait for the DMA BTC flag. Disable the DMA. Wait for the RXRDY flag in the TWI_SR register Set the STOP command in TWI_CR Read the penultimate character in TWI_RHR
10. Wait for the RXRDY flag in the TWI_SR register 11. Read the last character in TWI_RHR 12. (Optional) Wait for the TXCOMP flag in TWI_SR register before disabling the peripheral clock if required
TXCOMP
1147
Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once)
Set the Master Mode register: - Device slave address (DADR) - Transfer direction bit Write ==> bit MREAD = 0
1148
Figure 40-17. TWI Write Operation with Single Data Byte and Internal Address
BEGIN
Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once)
Set the Master Mode register: - Device slave address (DADR) - Internal address size (IADRSZ) - Transfer direction bit Write ==> bit MREAD = 0
1149
Figure 40-18. TWI Write Operation with Multiple Data Bytes with or without Internal Address
BEGIN
Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once)
Set the Master Mode register: - Device slave address - Internal address size (if IADR used) - Transfer direction bit Write ==> bit MREAD = 0
Yes
No
END
1150
Figure 40-19. TWI Read Operation with Single Data Byte without Internal Address
BEGIN
Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once)
Set the Master Mode register: - Device slave address - Transfer direction bit Read ==> bit MREAD = 1
No
1151
Figure 40-20. TWI Read Operation with Single Data Byte and Internal Address
BEGIN
Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once)
Set the Master Mode register: - Device slave address - Internal address size (IADRSZ) - Transfer direction bit Read ==> bit MREAD = 1
1152
Figure 40-21. TWI Read Operation with Multiple Data Bytes with or without Internal Address
BEGIN
Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once)
Set the Master Mode register: - Device slave address - Internal address size (if IADR used) - Transfer direction bit Read ==> bit MREAD = 1
No
No
Last data to read but one? Yes Stop the transfer TWI_CR = STOP
No
1153
40.9
Multi-master Mode
40.9.1 Definition
More than one master may handle the bus at the same time without data corruption by using arbitration. Arbitration starts as soon as two or more masters place information on the bus at the same time, and stops (arbitration is lost) for the master that intends to send a logical one while the other master sends a logical zero. As soon as arbitration is lost by a master, it stops sending data and listens to the bus in order to detect a stop. When the stop is detected, the master who has lost arbitration may put its data on the bus by respecting arbitration. Arbitration is illustrated in Figure 40-23 on page 1155.
40.9.2.1 TWI as Master Only In this mode, TWI is considered as a Master only (MSEN is always at one) and must be driven like a Master with the ARBLST (ARBitration Lost) flag in addition. If arbitration is lost (ARBLST = 1), the programmer must reinitiate the data transfer. If the user starts a transfer (ex.: DADR + START + W + Write in THR) and if the bus is busy, the TWI automatically waits for a STOP condition on the bus to initiate the transfer (see Figure 40-22 on page 1155). Note: The state of the bus (busy or free) is not indicated in the user interface.
40.9.2.2 TWI as Master or Slave The automatic reversal from Master to Slave is not supported in case of a lost arbitration. Then, in the case where TWI may be either a Master or a Slave, the programmer must manage the pseudo Multi-master mode described in the steps below. 1. 2. 3. 4. 5. 6. 7. Note: Program TWI in Slave mode (SADR + MSDIS + SVEN) and perform Slave Access (if TWI is addressed). If TWI has to be set in Master mode, wait until TXCOMP flag is at 1. Program Master mode (DADR + SVDIS + MSEN) and start the transfer (ex: START + Write in THR). As soon as the Master mode is enabled, TWI scans the bus in order to detect if it is busy or free. When the bus is considered as free, TWI initiates the transfer. 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. If the arbitration is lost (ARBLST is set to 1), the user must program the TWI in Slave mode in the case where the Master that won the arbitration wanted to access the TWI. If TWI has to be set in Slave mode, wait until TXCOMP flag is at 1 and then program the Slave mode. In the case where the arbitration is lost and TWI is addressed, TWI will not acknowledge even if it is programmed in Slave mode as soon as ARBLST is set to 1. Then, the Master must repeat SADR.
1154
TWCK STOP sent by the master TWD DATA sent by a master Bus is busy Bus is free TWI DATA transfer Transfer is kept START sent by the TWI DATA sent by the TWI
TWCK TWD
S S
1 1 1
0 0 0
0 1 0 1
1 1
Data from the TWI
0 0
1 1
ARBLST
Bus is busy Bus is free
Transfer is kept
The flowchart shown in Figure 40-24 on page 1156 gives an example of read and write operations in Multi-master mode.
1155
Yes
GACC = 1 ?
No No No
SVREAD = 1 ? Yes
No
GENERAL CALL TREATMENT Yes Decoding of the programming sequence Prog seq OK ? Change SADR Program the Master mode DADR + SVDIS + MSEN + CLK + R / W No
Yes ARBLST = 1 ?
No
MREAD = 1 ?
TXCOMP = 0 ?
1156
Master
As the device receives the clock, values written in TWI_CWGR are not taken into account.
1157
40.10.4.2 Write Sequence In the case of a Write sequence (SVREAD is low), the RXRDY (Receive Holding Register Ready) flag is set as soon as a character has been received in the TWI_RHR (TWI Receive Holding Register). RXRDY is reset when reading the TWI_RHR. TWI continues receiving data until a STOP condition or a REPEATED_START + an address different from SADR is detected. Note that at the end of the write sequence TXCOMP flag is set and SVACC reset. See Figure 40-27 on page 1159. 40.10.4.3 Clock Synchronization Sequence In the case where TWI_THR or TWI_RHR is not written/read in time, TWI performs a clock synchronization. Clock stretching information is given by the SCLWS (Clock Wait state) bit. See Figure 40-29 on page 1160 and Figure 40-30 on page 1161. 40.10.4.4 General Call In the case where a GENERAL CALL is performed, GACC (General Call ACCess) flag is set. After GACC is set, it is up to the programmer to interpret the meaning of the GENERAL CALL and to decode the new address programming sequence. See Figure 40-28 on page 1159.
ADR
NA
DATA
NA
P/S/Sr
SADR R
DATA
Write THR
Read RHR
Notes: 1. When SVACC is low, the state of SVREAD becomes irrelevant. 2. TXRDY is reset when data has been transmitted from TWI_THR to the shift register and set when this data has been acknowledged or non acknowledged.
1158
40.10.5.2 Write Operation The write mode is defined as a data transmission from the master. After a START or a REPEATED START, the decoding of the address starts. If the slave address is decoded, SVACC is set and SVREAD indicates the direction of the transfer (SVREAD is low in this case). Until a STOP or REPEATED START condition is detected, TWI stores the received data in the TWI_RHR register. If a STOP condition or a REPEATED START + an address different from SADR is detected, SVACC is reset. Figure 40-27 on page 1159 describes the Write operation.
Figure 40-27. Write Access Ordered by a Master
SADR does not match, TWI answers with a NACK SADR matches, TWI answers with an ACK Read RHR
ADR
NA
DATA
NA
P/S/Sr
SADR W
DATA
DATA
NA
S/Sr
Notes: 1. When SVACC is low, the state of SVREAD becomes irrelevant. 2. RXRDY is set when data has been transmitted from the shift register to the TWI_RHR and reset when this data is read. 40.10.5.3 General Call The general call is performed in order to change the address of the slave. If a GENERAL CALL is detected, GACC is set. After the detection of General Call, it is up to the programmer to decode the commands which come afterwards. In case of a WRITE command, the programmer has to decode the programming sequence and program a new SADR if the programming sequence matches. Figure 40-28 on page 1159 describes the General Call access.
Figure 40-28. Master Performs a General Call
0000000 + W RESET command = 00000110X WRITE command = 00000100X
TXD
GENERAL CALL
DATA1
DATA2
New SADR
Note:
This method allows the user to create an own programming sequence by choosing the programming bytes and the number of them. The programming sequence has to be provided to the master.
1159
40.10.5.4 Clock Synchronization In both read and write modes, it may happen that TWI_THR/TWI_RHR buffer is not filled /emptied before the emission/reception of a new character. In this case, to avoid sending/receiving undesired data, a clock stretching mechanism is implemented.
TWI_THR
DATA0
DATA1
DATA2
SADR
DATA0
DATA1
XXXXXXX 2
DATA2
NA
TWCK
Write THR CLOCK is tied low by the TWI as long as THR is empty
TWI_THR is transmitted to the shift register 1 2 The data is memorized in TWI_THR until a new value is written
The clock is stretched after the ACK, the state of TWD is undefined during clock stretching
Notes: 1. TXRDY is reset when data has been written in the TWI_THR to the shift register 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 synchronization mechanism is started.
1160
NA
ADR
TWI_RHR SCLWS
DATA1
DATA2
Rd DATA1
Rd DATA2
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.
1161
TWD
SADR
DATA0
DATA1
NA
Sr
SADR
DATA2
DATA3
A DATA3
DATA2
Note:
1.
TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
TWI_THR
SADR
DATA0
DATA1
Sr
SADR
DATA2
DATA3
NA
DATA0
DATA1
Read TWI_RHR
As soon as a START is detected
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.
1162
SVACC = 1 ?
No No
GACC = 1 ?
No
SVREAD = 0 ?
No
EOSACC = 1 ?
TXRDY= 1 ?
No
No
Prog seq OK ?
No
Change SADR
1163
1164
Register Control Register Master Mode Register Slave Mode Register Internal Address Register Clock Waveform Generator Register Reserved Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Receive Holding Register Transmit Holding Register Protection Mode Register Protection Status Register Reserved
Name TWI_CR TWI_MMR TWI_SMR TWI_IADR TWI_CWGR TWI_SR TWI_IER TWI_IDR TWI_IMR TWI_RHR TWI_THR TWI_WPROT_MODE TWI_WPROT_STATUS
Access Write-only Read-write Read-write Read-write Read-write Read-only Write-only Write-only Read-only Read-only Write-only Read-write Read-only
Reset N/A 0x00000000 0x00000000 0x00000000 0x00000000 0x0000F009 N/A N/A 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
Note:
1165
In single data byte master read, the START and STOP must both be set. In multiple data bytes master read, the STOP must be set after the last data received but one. In master read mode, if a NACK bit is received, the STOP is automatically performed. In master data write operation, a STOP condition will be sent after the transmission of the current data is finished. MSEN: TWI Master Mode Enabled
0 = No effect. 1 = If MSDIS = 0, the master mode is enabled. Note: Switching from Slave to Master mode is only permitted when TXCOMP = 1.
1166
1167
14 6
13 5
12 MREAD 4
10 2
9 IADRSZ 1
1168
14 6
13 5
12 4
10 2
This register can only be written if the WPEN bit is cleared in the TWI Write Protection Mode Register.
1169
1170
15
14
13
12 CHDIV
11
10
4 CLDIV
This register can only be written if the WPEN bit is cleared in the TWI Write Protection Mode Register. TWI_CWGR is only used in Master mode.
) + 4 ) T MCK
) + 4 ) T MCK
1171
1172
If TXRDY is high and if a NACK has been detected, the transmission will be stopped. Thus when TRDY = NACK = 1, the programmer must not fill TWI_THR to avoid losing it. TXRDY behavior in Slave mode can be seen in Figure 40-26 on page 1158, Figure 40-29 on page 1160, Figure 40-31 on page 1162 and Figure 40-32 on page 1162.
1173
1174
TXCOMP: Transmission Completed Interrupt Enable RXRDY: Receive Holding Register Ready Interrupt Enable TXRDY: Transmit Holding Register Ready Interrupt Enable SVACC: Slave Access Interrupt Enable GACC: General Call Access Interrupt Enable OVRE: Overrun Error Interrupt Enable NACK: Not Acknowledge Interrupt Enable ARBLST: Arbitration Lost Interrupt Enable SCL_WS: Clock Wait State Interrupt Enable EOSACC: End Of Slave Access Interrupt Enable
0 = No effect. 1 = Enables the corresponding interrupt.
1175
TXCOMP: Transmission Completed Interrupt Disable RXRDY: Receive Holding Register Ready Interrupt Disable TXRDY: Transmit Holding Register Ready Interrupt Disable SVACC: Slave Access Interrupt Disable GACC: General Call Access Interrupt Disable OVRE: Overrun Error Interrupt Disable NACK: Not Acknowledge Interrupt Disable ARBLST: Arbitration Lost Interrupt Disable SCL_WS: Clock Wait State Interrupt Disable EOSACC: End Of Slave Access Interrupt Disable
0 = No effect. 1 = Disables the corresponding interrupt.
1176
TXCOMP: Transmission Completed Interrupt Mask RXRDY: Receive Holding Register Ready Interrupt Mask TXRDY: Transmit Holding Register Ready Interrupt Mask SVACC: Slave Access Interrupt Mask GACC: General Call Access Interrupt Mask OVRE: Overrun Error Interrupt Mask NACK: Not Acknowledge Interrupt Mask ARBLST: Arbitration Lost Interrupt Mask SCL_WS: Clock Wait State Interrupt Mask EOSACC: End Of Slave Access Interrupt Mask
0 = The corresponding interrupt is disabled. 1 = The corresponding interrupt is enabled.
1177
1178
23
22
21
18
17
16
15
14
13
10
0 WPROT
1179
23
22
21
18
17
16
15
14
13
10
0 WPROTERR
1180
41.
41.1
CODECs in master or slave mode DAC through dedicated serial interface, particularly I2S Magnetic card reader
41.2
Embedded Characteristics
z z z z z z
Provides Serial Synchronous Communication Links Used in Audio and Telecom Applications Contains an Independent Receiver and Transmitter and a Common Clock Divider Interfaced with the DMA Controller (DMAC) to Reduce Processor Overhead Offers a Configurable Frame Sync and Data Length Receiver and Transmitter Can be Programmed to Start Automatically or on Detection of Different Events on the Frame Sync Signal Receiver and Transmitter Include a Data Signal, a Clock Signal and a Frame Synchronization Signal
1181
41.3
Block Diagram
APB Bridge
PMC
MCK
SSC Interrupt
1182
41.4
OS or RTOS Driver
Serial AUDIO
Codec
Line Interface
41.5
Table 41-1. I/O Lines Description Pin Name RF RK RD TF TK TD Pin Description Receiver Frame Synchro Receiver Clock Receiver Data Transmitter Frame Synchro Transmitter Clock Transmitter Data Type Input/Output Input/Output Input Input/Output Input/Output Output
1183
41.6
Product Dependencies
41.6.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
Table 41-3. Peripheral IDs Instance SSC0 SSC1 ID 38 39
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.
1184
41.7
Functional Description
This chapter contains the functional description of the following: SSC Functional Block, Clock Management, Data format, Start, Transmitter, Receiver and Frame Sync. The receiver and transmitter operate separately. However, they can work synchronously by programming the receiver to use the transmit clock and/or to start a data transfer when transmission starts. Alternatively, this can be done by programming the transmitter to use the receive clock and/or to start a data transfer when reception starts. The transmitter and the receiver can be programmed to operate with the clock signals provided on either the TK or RK pins. This allows the SSC to support many slave-mode data transfers. The maximum clock speed allowed on the TK and RK pins is the master clock divided by 2.
TK
MCK
Clock Divider
TF
Data Controller
TD
Receiver
RK
Receive Clock RX Clock Controller RX Start Receive Shift Register Receive Sync Holding Register
RF
Data Controller
RD
Interrupt Control
To Interrupt Controller
1185
An external clock received on the TK I/O pad The receiver clock The internal clock divider An external clock received on the RK I/O pad The transmitter clock The internal clock divider
Furthermore, the transmitter block can generate an external clock on the TK I/O pad, and the receiver block can generate an external clock on the RK I/O pad. This allows the SSC to support many Master and Slave Mode data transfers. 41.7.1.1 Clock Divider
Figure 41-4. Divided Clock Block Diagram
Clock Divider SSC_CMR MCK /2
12-bit Counter
Divided Clock
The Master Clock divider is determined by the 12-bit field DIV counter and comparator (so its maximal value is 4095) in the Clock Mode Register SSC_CMR, allowing a Master Clock division by up to 8190. The Divided Clock is provided to both the Receiver and Transmitter. When this field is programmed to 0, the Clock Divider is not used and remains inactive. When DIV is set to a value equal to or greater than 1, the Divided Clock has a frequency of Master Clock divided by 2 times DIV. Each level of the Divided Clock has a duration of the Master Clock multiplied by DIV. This ensures a 50% duty cycle for the Divided Clock regardless of whether the DIV value is even or odd.
Figure 41-5. Divided Clock Generation
Master Clock
Master Clock
1186
41.7.1.2 Transmitter Clock Management The transmitter clock is generated from the receiver clock or the divider clock or an external clock scanned on the TK I/O pad. The transmitter clock is selected by the CKS field in SSC_TCMR (Transmit Clock Mode Register). Transmit Clock can be inverted independently by the CKI bits in SSC_TCMR. The transmitter can also drive the TK I/O pad continuously or be limited to the actual data transfer. The clock output is configured by the SSC_TCMR register. The Transmit Clock Inversion (CKI) bits have no effect on the clock outputs. Programming the TCMR register to select TK pin (CKS field) and at the same time Continuous Transmit Clock (CKO field) might lead to unpredictable results.
Figure 41-6. Transmitter Clock Management
TK (pin)
Tri_state Controller
Clock Output
CKS
INV MUX
Tri-state Controller
Transmitter Clock
CKI
CKG
41.7.1.3 Receiver Clock Management The receiver clock is generated from the transmitter clock or the divider clock or an external clock scanned on the RK I/O pad. The Receive Clock is selected by the CKS field in SSC_RCMR (Receive Clock Mode Register). Receive Clocks can be inverted independently by the CKI bits in SSC_RCMR. The receiver can also drive the RK I/O pad continuously or be limited to the actual data transfer. The clock output is configured by the SSC_RCMR register. The Receive Clock Inversion (CKI) bits have no effect on the clock outputs. Programming the RCMR register to select RK pin (CKS field) and at the same time Continuous Receive Clock (CKO field) can lead to unpredictable results.
1187
Clock Output
CKS
INV MUX
Tri-state Controller
Receiver Clock
CKI
CKG
41.7.1.4 Serial Clock Ratio Considerations The Transmitter and the Receiver can be programmed to operate with the clock signals provided on either the TK or RK pins. This allows the SSC to support many slave-mode data transfers. In this case, the maximum clock speed allowed on the RK pin is:
z z
Master Clock divided by 2 if Receiver Frame Synchro is input Master Clock divided by 3 if Receiver Frame Synchro is output Master Clock divided by 6 if Transmit Frame Synchro is input Master Clock divided by 2 if Transmit Frame Synchro is output
1188
TX Controller TD
Transmitter Clock
SSC_TFMR.DATLEN
SSC_THR
SSC_TSHR
SSC_TFMR.FSLEN
1189
Receiver Clock
SSC_RFMR.FSLEN
41.7.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:
z z z z z
Continuous. In this case, the transmission starts as soon as a word is written in SSC_THR and the reception starts as soon as the Receiver is enabled. Synchronously with the transmitter/receiver On detection of a falling/rising edge on TF/RF On detection of a low level/high level on TF/RF On detection of a level change or an edge on TF/RF
A start can be programmed in the same manner on either side of the Transmit/Receive Clock Register (RCMR/TCMR). Thus, the start could be on TF (Transmit) or RF (Receive). Moreover, the Receiver can start when data is detected in the bit stream with the Compare Functions. Detection on TF/RF input/output is done by the field FSOS of the Transmit/Receive Frame Mode Register (TFMR/RFMR).
1190
TD (Output) TD (Output)
BO
B1 STTDLY
BO
B1 STTDLY X BO B1 STTDLY
TD (Output) TD (Output) X
BO
B1 STTDLY
BO
B1
BO
B1 STTDLY
BO
B1
BO
B1 STTDLY
RD (Input) RD (Input)
BO
B1 STTDLY
BO
B1 STTDLY X BO B1 STTDLY
BO
B1 STTDLY
BO
B1
BO
B1 STTDLY
BO
B1
BO
B1 STTDLY
1191
Programmable low or high levels during data transfer are supported. Programmable high levels before the start of data transfers or toggling are also supported.
If a pulse waveform is selected, the Frame Sync Length (FSLEN) field in SSC_RFMR and SSC_TFMR programs the length of the pulse, from 1 bit time up to 256 bit time. The periodicity of the Receive and Transmit Frame Sync pulse output can be programmed through the Period Divider Selection (PERIOD) field in SSC_RCMR and SSC_TCMR. 41.7.5.1 Frame Sync Data Frame Sync Data transmits or receives a specific tag during the Frame Sync signal. During the Frame Sync signal, the Receiver can sample the RD line and store the data in the Receive Sync Holding Register and the transmitter can transfer Transmit Sync Holding Register in the Shifter Register. The data length to be sampled/shifted out during the Frame Sync signal is programmed by the FSLEN field in SSC_RFMR/SSC_TFMR and has a maximum value of 16. Concerning the Receive Frame Sync Data operation, if the Frame Sync Length is equal to or lower than the delay between the start event and the actual data reception, the data sampling operation is performed in the Receive Sync Holding Register through the Receive Shift Register. The Transmit Frame Sync Operation is performed by the transmitter only if the bit Frame Sync Data Enable (FSDEN) in SSC_TFMR is set. If the Frame Sync length is equal to or lower than the delay between the start event and the actual data transmission, the normal transmission has priority and the data contained in the Transmit Sync Holding Register is transferred in the Transmit Register, then shifted out. 41.7.5.2 Frame Sync Edge Detection The Frame Sync Edge detection is programmed by the FSEDGE field in SSC_RFMR/SSC_TFMR. This sets the corresponding flags RXSYN/TXSYN in the SSC Status Register (SSC_SR) on frame synchro edge detection (signals RF/TF).
RD (Input)
CMP0
CMP1
CMP2
CMP3 Start
Ignored
B0
B1
B2
STDLY
DATLEN
41.7.6.1 Compare Functions Length of the comparison patterns (Compare 0, Compare 1) and thus the number of bits they are compared to is defined by FSLEN, but with a maximum value of 16 bits. Comparison is always done by comparing the last bits received with the comparison pattern. Compare 0 can be one start event of the Receiver. In this case, the receiver compares at each new sample the last bits received at the Compare 0 pattern contained in the Compare 0 Register (SSC_RC0R). When this start event is selected, the user can program the Receiver to start a new data transfer either by writing a new Compare 0, or by receiving continuously until Compare 1 occurs. This selection is done with the bit (STOP) in SSC_RCMR.
1192
The event that starts the data transfer (START) The delay in number of bit periods between the start event and the first data bit (STTDLY) The length of the data (DATLEN) The number of data to be transferred for each start event (DATNB). The length of synchronization transferred for each start event (FSLEN) The bit sense: most or lowest significant bit first (MSBF)
Additionally, the transmitter can be used to transfer synchronization and select the level driven on the TD pin while not in data transfer operation. This is done respectively by the Frame Sync Data Enable (FSDEN) and by the Data Default Value (DATDEF) bits in SSC_TFMR.
Table 41-4. Data Frame Registers Transmitter SSC_TFMR SSC_TFMR SSC_TFMR SSC_TFMR SSC_TFMR SSC_TFMR SSC_TCMR SSC_TCMR SSC_RCMR SSC_RCMR Receiver SSC_RFMR SSC_RFMR SSC_RFMR SSC_RFMR Field DATLEN DATNB MSBF FSLEN DATDEF FSDEN PERIOD STTDLY Up to 512 Up to 255 Up to 16 0 or 1 Length Up to 32 Up to 16 Comment Size of word Number of words transmitted in frame Most significant bit first Size of Synchro data register Data default value ended Enable send SSC_TSHR Frame size Size of transmit start delay
Figure 41-13. Transmit and Receive Frame Format in Edge/Pulse Start Modes
Start PERIOD TF/RF
(1)
Start
FSLEN TD (If FSDEN = 1) Sync Data Default Data From SSC_THR Data From SSC_THR Data To SSC_RHR DATLEN Data From SSC_THR Data From SSC_THR Data To SSC_RHR DATLEN Default FromDATDEF Default From DATDEF Ignored Sync Data Sync Data
From SSC_TSHR FromDATDEF Default From DATDEF Sync Data To SSC_RSHR STTDLY Ignored
TD (If FSDEN = 0) RD
DATNB
Note:
1193
TD
Default
Note:
1.
STTDLY is set to 0. In this example, SSC_THR is loaded twice. FSDEN value has no effect on the transmission. SyncData cannot be output in continuous mode.
RD
Note:
1.
STTDLY is set to 0.
41.7.9 Interrupt
Most bits in SSC_SR have a corresponding bit in interrupt management registers. The SSC can be programmed to generate an interrupt when it detects an event. The interrupt is controlled by writing SSC_IER (Interrupt Enable Register) and SSC_IDR (Interrupt Disable Register) These registers enable and disable, respectively, the corresponding interrupt by setting and clearing the corresponding bit in SSC_IMR (Interrupt Mask Register), which controls the generation of interrupts by asserting the SSC interrupt line connected to the interrupt controller.
1194
SSC Interrupt
1195
41.8
Data SD
LSB
Serial Data Clock (SCLK) Frame sync (FSYNC) First Time Slot Dstart Serial Data Out Dend
Serial Data In
1196
Serial Data Clock (SCLK) Frame sync (FSYNC) Serial Data Out First Time Slot Dstart Second Time Slot Dend
Serial Data in
1197
SSC Clock Mode Register on page 1201 SSC Receive Clock Mode Register on page 1202 SSC Receive Frame Mode Register on page 1204 SSC Transmit Clock Mode Register on page 1206 SSC Transmit Frame Mode Register on page 1208 SSC Receive Compare 0 Register on page 1214 SSC Receive Compare 1 Register on page 1215
1198
41.9
Table 41-5. Register Mapping Offset 0x0 0x4 0x8 0xC 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0xE4 0xE8 0x50-0xFC 0x100-0x124 Register Control Register Clock Mode Register Reserved Reserved Receive Clock Mode Register Receive Frame Mode Register Transmit Clock Mode Register Transmit Frame Mode Register Receive Holding Register Transmit Holding Register Reserved Reserved Receive Sync. Holding Register Transmit Sync. Holding Register Receive Compare 0 Register Receive Compare 1 Register Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Write Protect Mode Register Write Protect Status Register Reserved Reserved Name SSC_CR SSC_CMR SSC_RCMR SSC_RFMR SSC_TCMR SSC_TFMR SSC_RHR SSC_THR SSC_RSHR SSC_TSHR SSC_RC0R SSC_RC1R SSC_SR SSC_IER SSC_IDR SSC_IMR SSC_WPMR SSC_WPSR Access Write-only Read-write Read-write Read-write Read-write Read-write Read-only Write-only Read-only Read-write Read-write Read-write Read-only Write-only Write-only Read-only Read-write Read-only Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x000000CC 0x0 0x0 0x0
1199
1200
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1201
23
22
21
20 STTDLY
19
18
17
16
15 7 CKG
14 6
13 5 CKI
12 STOP 4
11
10 START
3 CKO
1 CKS
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1202
1203
23 15 7 MSBF
22
21 FSOS 13 5 LOOP
20
14 6
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1204
1205
23
22
21
20 STTDLY
19
18
17
16
15 7 CKG
14 6
13 5 CKI
12 4
11
10 START
3 CKO
1 CKS
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1206
1207
23 FSDEN 15 7 MSBF
22
21 FSOS 13 5 DATDEF
20
14 6
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1208
1209
23
22
21
20 RDAT
19
18
17
16
15
14
13
12 RDAT
11
10
4 RDAT
1210
23
22
21
20 TDAT
19
18
17
16
15
14
13
12 TDAT
11
10
4 TDAT
1211
1212
1213
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1214
This register can only be written if the WPEN bit is cleared in SSC Write Protect Mode Register .
1215
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.
1216
1217
1218
1219
1220
SSC Clock Mode Register on page 1201 SSC Receive Clock Mode Register on page 1202 SSC Receive Frame Mode Register on page 1204 SSC Transmit Clock Mode Register on page 1206 SSC Transmit Frame Mode Register on page 1208 SSC Receive Compare 0 Register on page 1214 SSC Receive Compare 1 Register on page 1215 WPKEY: Write Protect KEY
Should be written at value 0x535343 (SSC in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0.
1221
1222
42.
42.1
42.2
Embedded Characteristics
z z
System Peripheral to Facilitate Debug of Atmel ARM-based Systems Composed of Four Functions
z z z z
Two-pin UART Debug Communication Channel (DCC) Support Chip ID Registers ICE Access Prevention Implemented Features are USART Compatible Independent Receiver and Transmitter with a Common Programmable Baud Rate Generator Even, Odd, Mark or Space Parity Generation Parity, Framing and Overrun Error Detection Automatic Echo, Local Loopback and Remote Loopback Channel Modes Interrupt Generation Support for Two DMA Channels with Connection to Receiver and Transmitter Offers Visibility of COMMRX and COMMTX Signals from the ARM Processor Interrupt Generation Identification of the Device Revision, Sizes of the Embedded Memories, Set of Peripherals Enables Software to Prevent System Access Through the ARM Processors ICE Prevention is Made by Asserting the NTRST Line of the ARM Processors ICE
Two-pin UART
z z z z z z z
Chip ID Registers
z
1223
42.3
Block Diagram
APB
Debug Unit
DTXD
COMMTX
DCC Handler
Chip ID
Interrupt Control
dbgu_irq
Table 42-1. Debug Unit Pin Description Pin Name DRXD DTXD Description Debug Receive Data Debug Transmit Data Type Input Output
Debug Unit
1224
42.4
Product Dependencies
42.5
UART Operations
The Debug Unit operates as a UART, (asynchronous mode only) and supports only 8-bit character handling (with parity). It has no clock pin. The Debug Unit's UART is made up of a receiver and a transmitter that operate independently, and a common baud rate generator. Receiver timeout and transmitter time guard are not implemented. However, all the implemented features are compatible with those of a standard USART.
1225
OUT
42.5.2 Receiver
42.5.2.1 Receiver Reset, Enable and Disable After device reset, the Debug Unit receiver is disabled and must be enabled before being used. The receiver can be enabled by writing the control register DBGU_CR with the bit RXEN at 1. At this command, the receiver starts looking for a start bit. The programmer can disable the receiver by writing DBGU_CR with the bit RXDIS at 1. If the receiver is waiting for a start bit, it is immediately stopped. However, if the receiver has already detected a start bit and is receiving the data, it waits for the stop bit before actually stopping its operation. The programmer can also put the receiver in its reset state by writing DBGU_CR with the bit RSTRX at 1. In doing so, the receiver immediately stops its current operations and is disabled, whatever its current state. If RSTRX is applied when data is being processed, this data is lost. 42.5.2.2 Start Detection and Data Sampling The Debug Unit only supports asynchronous operations, and this affects only its receiver. The Debug Unit receiver detects the start of a received character by sampling the DRXD signal until it detects a valid start bit. A low level (space) on DRXD is interpreted as a valid start bit if it is detected for more than 7 cycles of the sampling clock, which is 16 times the baud rate. Hence, a space that is longer than 7/16 of the bit period is detected as a valid start bit. A space which is 7/16 of a bit period or shorter is ignored and the receiver continues to wait for a valid start bit. When a valid start bit has been detected, the receiver samples the DRXD at the theoretical midpoint of each bit. It is assumed that each bit lasts 16 cycles of the sampling clock (1-bit period) so the bit sampling point is eight cycles (0.5-bit period) after the start of the bit. The first sampling point is therefore 24 cycles (1.5-bit periods) after the falling edge of the start bit was detected. Each subsequent bit is sampled 16 cycles (1-bit period) after the previous one.
Figure 42-4. Start Bit Detection
Sampling Clock
DRXD
D0
1226
DRXD
Sampling
D2
D3
D4
D5
D6
D7 Parity Bit
Stop Bit
42.5.2.3 Receiver Ready When a complete character is received, it is transferred to the DBGU_RHR and the RXRDY status bit in DBGU_SR (Status Register) is set. The bit RXRDY is automatically cleared when the receive holding register DBGU_RHR is read.
Figure 42-6. Receiver Ready
DRXD S D0 D1 D2 D3 D4 D5 D6 D7 P S D0 D1 D2 D3 D4 D5 D6 D7 P
RXRDY
Read DBGU_RHR
42.5.2.4 Receiver Overrun If DBGU_RHR has not been read by the software (or the Peripheral Data Controller or DMA Controller) since the last transfer, the RXRDY bit is still set and a new character is received, the OVRE status bit in DBGU_SR is set. OVRE is cleared when the software writes the control register DBGU_CR with the bit RSTSTA (Reset Status) at 1.
Figure 42-7. Receiver Overrun
DRXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY OVRE
RSTSTA
42.5.2.5 Parity Error Each time a character is received, the receiver calculates the parity of the received data bits, in accordance with the field PAR in DBGU_MR. It then compares the result with the received parity bit. If different, the parity error bit PARE in DBGU_SR is set at the same time the RXRDY is set. The parity bit is cleared when the control register DBGU_CR is written with the bit RSTSTA (Reset Status) at 1. If a new character is received before the reset status command is written, the PARE bit remains at 1.
Figure 42-8. Parity Error
DRXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY PARE
RSTSTA
1227
42.5.2.6 Receiver Framing Error When a start bit is detected, it generates a character reception when all the data bits have been sampled. The stop bit is also sampled and when it is detected at 0, the FRAME (Framing Error) bit in DBGU_SR is set at the same time the RXRDY bit is set. The bit FRAME remains high until the control register DBGU_CR is written with the bit RSTSTA at 1.
Figure 42-9. Receiver Framing Error
DRXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY FRAME
RSTSTA
42.5.3 Transmitter
42.5.3.1 Transmitter Reset, Enable and Disable After device reset, the Debug Unit transmitter is disabled and it must be enabled before being used. The transmitter is enabled by writing the control register DBGU_CR with the bit TXEN at 1. From this command, the transmitter waits for a character to be written in the Transmit Holding Register DBGU_THR before actually starting the transmission. The programmer can disable the transmitter by writing DBGU_CR with the bit TXDIS at 1. If the transmitter is not operating, it is immediately stopped. However, if a character is being processed into the Shift Register and/or a character has been written in the Transmit Holding Register, the characters are completed before the transmitter is actually stopped. The programmer can also put the transmitter in its reset state by writing the DBGU_CR with the bit RSTTX at 1. This immediately stops the transmitter, whether or not it is processing characters. 42.5.3.2 Transmit Format The Debug Unit transmitter drives the pin DTXD at the baud rate clock speed. The line is driven depending on the format defined in the Mode Register and the data stored in the Shift Register. One start bit at level 0, then the 8 data bits, from the lowest to the highest bit, one optional parity bit and one stop bit at 1 are consecutively shifted out as shown on the following figure. The field PARE in the mode register DBGU_MR defines whether or not a parity bit is shifted out. When a parity bit is enabled, it can be selected between an odd parity, an even parity, or a fixed space or mark bit.
Figure 42-10. Character Transmission
Example: Parity enabled Baud Rate Clock DTXD
Start Bit
D0
D1
D2
D3
D4
D5
D6
D7
Parity Bit
Stop Bit
1228
42.5.3.3 Transmitter Control When the transmitter is enabled, the bit TXRDY (Transmitter Ready) is set in the status register DBGU_SR. The transmission starts when the programmer writes in the Transmit Holding Register DBGU_THR, and after the written character is transferred from DBGU_THR to the Shift Register. The bit TXRDY remains high until a second character is written in DBGU_THR. As soon as the first character is completed, the last character written in DBGU_THR is transferred into the shift register and TXRDY rises again, showing that the holding register is empty. When both the Shift Register and the DBGU_THR are empty, i.e., all the characters written in DBGU_THR have been processed, the bit TXEMPTY rises after the last stop bit has been completed.
Figure 42-11. Transmitter Control
DBGU_THR
Data 0 Data 1
Shift Register
Data 0
Data 1
DTXD
Data 0
stop
Data 1
stop
TXRDY TXEMPTY
1229
Transmitter
Disabled
TXD
RXD
VDD Transmitter
Disabled
TXD
Transmitter
Disabled
TXD
Writes the value in Rd to the debug communication data write register. The bits COMMRX and COMMTX, which indicate, respectively, that the read register has been written by the debugger but not yet read by the processor, and that the write register has been written by the processor and not yet read by the debugger, are wired on the two highest bits of the status register DBGU_SR. These bits can generate an interrupt. This feature permits handling under interrupt a debug link between a debug monitor running on the target system and a debugger.
1230
EXT - shows the use of the extension identifier register NVPTYP and NVPSIZ - identifies the type of embedded non-volatile memory and its size ARCH - identifies the set of embedded peripherals SRAMSIZ - indicates the size of the embedded SRAM EPROC - indicates the embedded ARM processor VERSION - gives the revision of the silicon
1231
42.6
Table 42-3. Register Mapping Offset 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 - 0x003C 0x0040 0x0044 0x0048 0x004C - 0x00FC Register Control Register Mode Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Status Register Receive Holding Register Transmit Holding Register Baud Rate Generator Register Reserved Chip ID Register Chip ID Extension Register Force NTRST Register Reserved Name DBGU_CR DBGU_MR DBGU_IER DBGU_IDR DBGU_IMR DBGU_SR DBGU_RHR DBGU_THR DBGU_BRGR DBGU_CIDR DBGU_EXID DBGU_FNR Access Write-only Read-write Write-only Write-only Read-only Read-only Read-only Write-only Read-write Read-only Read-only Read-write Reset 0x0 0x0 0x0 0x0 0x0
1232
23
22
21
20
19
18
17
16
15
14
13
12
11
10
8 RSTSTA 0
7 TXDIS
6 TXEN
5 RXDIS
4 RXEN
3 RSTTX
2 RSTRX
1233
23
22
21
20
19
18
17
16
15 CHMODE 7
14
13
12
11
10 PAR
6 5
4 3
1 0
1234
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
RXRDY: Enable RXRDY Interrupt TXRDY: Enable TXRDY Interrupt OVRE: Enable Overrun Error Interrupt FRAME: Enable Framing Error Interrupt PARE: Enable Parity Error Interrupt TXEMPTY: Enable TXEMPTY Interrupt COMMTX: Enable COMMTX (from ARM) Interrupt COMMRX: Enable COMMRX (from ARM) Interrupt
0 = No effect. 1 = Enables the corresponding interrupt.
1235
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
RXRDY: Disable RXRDY Interrupt TXRDY: Disable TXRDY Interrupt OVRE: Disable Overrun Error Interrupt FRAME: Disable Framing Error Interrupt PARE: Disable Parity Error Interrupt TXEMPTY: Disable TXEMPTY Interrupt COMMTX: Disable COMMTX (from ARM) Interrupt COMMRX: Disable COMMRX (from ARM) Interrupt
0 = No effect. 1 = Disables the corresponding interrupt.
1236
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
RXRDY: Mask RXRDY Interrupt TXRDY: Disable TXRDY Interrupt OVRE: Mask Overrun Error Interrupt FRAME: Mask Framing Error Interrupt PARE: Mask Parity Error Interrupt TXEMPTY: Mask TXEMPTY Interrupt COMMTX: Mask COMMTX Interrupt COMMRX: Mask COMMRX Interrupt
0 = The corresponding interrupt is disabled. 1 = The corresponding interrupt is enabled.
1237
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
1238
23
22
21
20
19
18
17
16
15
14
13
12
11
10
4 RXCHR
1239
23
22
21
20
19
18
17
16
15
14
13
12
11
10
4 TXCHR
1240
23
22
21
20
19
18
17
16
15
14
13
12 CD
11
10
4 CD
1241
1242
1243
1244
1245
23
22
21
20
19
18
17
16
15
14
13
12
11
10
0 FNTRST
1246
43.
43.1
43.2
Embedded Characteristics
z z z z
Passed NIST Special Publication 800-22 Tests Suite Passed Diehard Random Tests Suite May be used as Entropy Source for seeding an NIST approved DRNG (Deterministic RNG) as required by FIPS PUB 140-2 and 140-3 Provides a 32-bit Random Number Every 84 Clock Cycles
1247
43.3
Block Diagram
MCK PMC
User Interface
Entropy Source
APB
1248
43.4
Product Dependencies
43.4.2 Interrupt
The TRNG interface has an interrupt line connected to the Interrupt Controller. In order to handle interrupts, the Interrupt Controller must be programmed before configuring the TRNG.
Table 43-1. Peripheral IDs Instance TRNG ID 45
43.5
Functional Description
As soon as the TRNG is enabled (TRNG_CTRL register), the generator provides one 32-bit value every 84 clock cycles. Interrupt trng_int can be enabled through the TRNG_IER register (respectively disabled in TRNG_IDR). This interrupt is set when a new random value is available and is cleared when the status register is read (TRNG_SR register). The flag DATRDY of the status register (TRNG_ISR) is set when the random data is ready to be read out on the 32-bit output data register (TRNG_ODATA). The normal mode of operation checks that the status register flag equals 1 before reading the output data register when a 32-bit random value is required by the software application.
Figure 43-2. TRNG Data Generation Sequence
84 clock cycles
84 clock cycles
84 clock cycles
trng_int
1249
43.6
Table 43-2. Register Mapping Offset 0x00 0x10 0x14 0x18 0x1C 0x50 Control Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Interrupt Status Register Output Data Register Register Name TRNG_CR TRNG_IER TRNG_IDR TRNG_IMR TRNG_ISR TRNG_ODATA Access Write-only Write-only Write-only Read-only Read-only Read-only Reset 0x0000_0000 0x0000_0000 0x0000_0000
1250
KEY
23 22 21 20 19 18 17 16
KEY
15 14 13 12 11 10 9 8
KEY
7 6 5 4 3 2 1 0
ENABLE
1251
23
22
21
20
19
18
17
16
15
14
13
12
11
10
DATRDY
1252
23
22
21
20
19
18
17
16
15
14
13
12
11
10
DATRDY
1253
TRNG_IMR 0xF8040018
0x0000_0000
Read-only
30 29 28 27 26 25 24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
DATRDY
1254
TRNG_ISR 0xF804001C
0x0000_0000
Read-only
30 29 28 27 26 25 24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
7 6 5
DATRDY
1255
TRNG_ODATA 0xF8040050
0x0000_0000
Read-only
30 29 28 27 26 25 24
ODATA
23 22 21 20 19 18 17 16
ODATA
15 14 13 12 11 10 9 8
ODATA
7 6 5 4 3 2 1 0
ODATA
1256
44.
44.1
44.2
Embedded Characteristics
z
Two-pin UART
z z z z z z
Independent Receiver and Transmitter with a Common Programmable Baud Rate Generator Even, Odd, Mark or Space Parity Generation Parity, Framing and Overrun Error Detection Automatic Echo, Local Loopback and Remote Loopback Channel Modes Interrupt Generation Support for Two DMA Channels with Connection to Receiver and Transmitter
1257
44.3
Block Diagram
APB
UART
UTXD
Interrupt Control
uart_irq
Table 44-1. UART Pin Description Pin Name URXD UTXD Description UART Receive Data UART Transmit Data Type Input Output
1258
44.4
Product Dependencies
1259
44.5
UART Operations
The UART operates in asynchronous mode only and supports only 8-bit character handling (with parity). It has no clock pin. The UART is made up of a receiver and a transmitter that operate independently, and a common baud rate generator. Receiver timeout and transmitter time guard are not implemented. However, all the implemented features are compatible with those of a standard USART.
The baud rate clock is the master clock divided by 16 times the value (CD) written in UART_BRGR (Baud Rate Generator Register). If UART_BRGR is set to 0, the baud rate clock is disabled and the UART remains inactive. The maximum allowable baud rate is Master Clock divided by 16. The minimum allowable baud rate is Master Clock divided by (16 x 65536). MCK Baud Rate = ----------------------16 CD
Figure 44-2. Baud Rate Generator
CD CD MCK 16-bit Counter
OUT
44.5.2 Receiver
44.5.2.1 Receiver Reset, Enable and Disable After device reset, the UART receiver is disabled and must be enabled before being used. The receiver can be enabled by writing the control register UART_CR with the bit RXEN at 1. At this command, the receiver starts looking for a start bit. The programmer can disable the receiver by writing UART_CR with the bit RXDIS at 1. If the receiver is waiting for a start bit, it is immediately stopped. However, if the receiver has already detected a start bit and is receiving the data, it waits for the stop bit before actually stopping its operation. The programmer can also put the receiver in its reset state by writing UART_CR with the bit RSTRX at 1. In doing so, the receiver immediately stops its current operations and is disabled, whatever its current state. If RSTRX is applied when data is being processed, this data is lost. 44.5.2.2 Start Detection and Data Sampling The UART only supports asynchronous operations, and this affects only its receiver. The UART receiver detects the start of a received character by sampling the URXD signal until it detects a valid start bit. A low level (space) on URXD is interpreted as a valid start bit if it is detected for more than 7 cycles of the sampling clock, which is 16 times the baud rate. Hence, a space that is longer than 7/16 of the bit period is detected as a valid start bit. A space which is 7/16 of a bit period or shorter is ignored and the receiver continues to wait for a valid start bit.
1260
When a valid start bit has been detected, the receiver samples the URXD at the theoretical midpoint of each bit. It is assumed that each bit lasts 16 cycles of the sampling clock (1-bit period) so the bit sampling point is eight cycles (0.5-bit period) after the start of the bit. The first sampling point is therefore 24 cycles (1.5-bit periods) after the falling edge of the start bit was detected. Each subsequent bit is sampled 16 cycles (1-bit period) after the previous one.
Figure 44-3. Start Bit Detection
Sampling Clock
URXD
D0
URXD
Sampling
D2
D3
D4
D5
D6
D7 Parity Bit
Stop Bit
44.5.2.3 Receiver Ready When a complete character is received, it is transferred to the UART_RHR and the RXRDY status bit in UART_SR (Status Register) is set. The bit RXRDY is automatically cleared when the receive holding register UART_RHR is read.
Figure 44-5. Receiver Ready
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
1261
44.5.2.4 Receiver Overrun If UART_RHR has not been read by the software (or the Peripheral Data Controller or DMA Controller) since the last transfer, the RXRDY bit is still set and a new character is received, the OVRE status bit in UART_SR is set. OVRE is cleared when the software writes the control register UART_CR with the bit RSTSTA (Reset Status) at 1.
Figure 44-6. Receiver Overrun
URXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY OVRE
RSTSTA
44.5.2.5 Parity Error Each time a character is received, the receiver calculates the parity of the received data bits, in accordance with the field PAR in UART_MR. It then compares the result with the received parity bit. If different, the parity error bit PARE in UART_SR is set at the same time the RXRDY is set. The parity bit is cleared when the control register UART_CR is written with the bit RSTSTA (Reset Status) at 1. If a new character is received before the reset status command is written, the PARE bit remains at 1.
Figure 44-7. Parity Error
URXD S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RXRDY PARE
RSTSTA
44.5.2.6 Receiver Framing Error When a start bit is detected, it generates a character reception when all the data bits have been sampled. The stop bit is also sampled and when it is detected at 0, the FRAME (Framing Error) bit in UART_SR is set at the same time the RXRDY bit is set. The FRAME bit remains high until the control register UART_CR is written with the bit RSTSTA at 1.
Figure 44-8. Receiver Framing Error
URXD RXRDY FRAME S D0 D1 D2 D3 D4 D5 D6 D7 P stop
RSTSTA
1262
44.5.3 Transmitter
44.5.3.1 Transmitter Reset, Enable and Disable After device reset, the UART transmitter is disabled and it must be enabled before being used. The transmitter is enabled by writing the control register UART_CR with the bit TXEN at 1. From this command, the transmitter waits for a character to be written in the Transmit Holding Register (UART_THR) before actually starting the transmission. The programmer can disable the transmitter by writing UART_CR with the bit TXDIS at 1. If the transmitter is not operating, it is immediately stopped. However, if a character is being processed into the Shift Register and/or a character has been written in the Transmit Holding Register, the characters are completed before the transmitter is actually stopped. The programmer can also put the transmitter in its reset state by writing the UART_CR with the bit RSTTX at 1. This immediately stops the transmitter, whether or not it is processing characters. 44.5.3.2 Transmit Format The UART transmitter drives the pin UTXD at the baud rate clock speed. The line is driven depending on the format defined in the Mode Register and the data stored in the Shift Register. One start bit at level 0, then the 8 data bits, from the lowest to the highest bit, one optional parity bit and one stop bit at 1 are consecutively shifted out as shown in the following figure. The field PARE in the mode register UART_MR defines whether or not a parity bit is shifted out. When a parity bit is enabled, it can be selected between an odd parity, an even parity, or a fixed space or mark bit.
Figure 44-9. Character Transmission
Example: Parity enabled Baud Rate Clock UTXD
Start Bit
D0
D1
D2
D3
D4
D5
D6
D7
Parity Bit
Stop Bit
1263
44.5.3.3 Transmitter Control When the transmitter is enabled, the bit TXRDY (Transmitter Ready) is set in the status register UART_SR. The transmission starts when the programmer writes in the Transmit Holding Register (UART_THR), and after the written character is transferred from UART_THR to the Shift Register. The TXRDY bit remains high until a second character is written in UART_THR. As soon as the first character is completed, the last character written in UART_THR is transferred into the shift register and TXRDY rises again, showing that the holding register is empty. When both the Shift Register and UART_THR are empty, i.e., all the characters written in UART_THR have been processed, the TXEMPTY bit rises after the last stop bit has been completed.
Figure 44-10. Transmitter Control
UART_THR
Data 0 Data 1
Shift Register
Data 0
Data 1
UTXD
Data 0
stop
Data 1
stop
TXRDY TXEMPTY
1264
Transmitter
Disabled
TXD
RXD
VDD Transmitter
Disabled
TXD
VDD
Disabled
RXD
Disabled
Transmitter
TXD
1265
44.6
Table 44-3. Register Mapping Offset 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 - 0x003C 0x004C - 0x00FC Register Control Register Mode Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Status Register Receive Holding Register Transmit Holding Register Baud Rate Generator Register Reserved Reserved Name UART_CR UART_MR UART_IER UART_IDR UART_IMR UART_SR UART_RHR UART_THR UART_BRGR Access Write-only Read-write Write-only Write-only Read-only Read-only Read-only Write-only Read-write Reset 0x0 0x0 0x0 0x0
1266
23
22
21
20
19
18
17
16
15
14
13
12
11
10
8 RSTSTA 0
7 TXDIS
6 TXEN
5 RXDIS
4 RXEN
3 RSTTX
2 RSTRX
1267
23
22
21
20
19
18
17
16
15 CHMODE 7
14
13
12
11
10 PAR
6 5
4 3
1 0
1268
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
RXRDY: Enable RXRDY Interrupt TXRDY: Enable TXRDY Interrupt OVRE: Enable Overrun Error Interrupt FRAME: Enable Framing Error Interrupt PARE: Enable Parity Error Interrupt TXEMPTY: Enable TXEMPTY Interrupt
0 = No effect. 1 = Enables the corresponding interrupt.
1269
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
RXRDY: Disable RXRDY Interrupt TXRDY: Disable TXRDY Interrupt OVRE: Disable Overrun Error Interrupt FRAME: Disable Framing Error Interrupt PARE: Disable Parity Error Interrupt TXEMPTY: Disable TXEMPTY Interrupt
0 = No effect. 1 = Disables the corresponding interrupt.
1270
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
RXRDY: Mask RXRDY Interrupt TXRDY: Disable TXRDY Interrupt OVRE: Mask Overrun Error Interrupt FRAME: Mask Framing Error Interrupt PARE: Mask Parity Error Interrupt TXEMPTY: Mask TXEMPTY Interrupt
0 = The corresponding interrupt is disabled. 1 = The corresponding interrupt is enabled.
1271
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9 TXEMPTY 1 TXRDY
7 PARE
6 FRAME
5 OVRE
0 RXRDY
1272
23
22
21
20
19
18
17
16
15
14
13
12
11
10
4 RXCHR
23
22
21
20
19
18
17
16
15
14
13
12
11
10
4 TXCHR
1273
23
22
21
20
19
18
17
16
15
14
13
12 CD
11
10
4 CD
1274
45.
45.1
1275
45.2
Embedded Characteristics
z z
Programmable Baud Rate Generator 5-bit to 9-bit Full-duplex Synchronous or Asynchronous Serial Communications
z z z z z z z z z
1, 1.5 or 2 Stop Bits in Asynchronous Mode or 1 or 2 Stop Bits in Synchronous Mode Parity Generation and Error Detection Framing Error Detection, Overrun Error Detection MSB-first or LSB-first Optional Break Generation and Detection By-8 or by-16 Over-sampling Receiver Frequency Optional Hardware Handshaking RTS-CTS Receiver Time-out and Transmitter Timeguard Optional Multidrop Mode with Address Generation and Detection
z z
RS485 with Driver Control Signal ISO7816, T = 0 or T = 1 Protocols for Interfacing with Smart Cards
z
NACK Handling, Error Counter with Repetition and Iteration Limit Communication at up to 115.2 Kbps Master or Slave Serial Clock Programmable Phase and Polarity SPI Serial Clock (SCK) Frequency up to Internal Clock Frequency MCK/6 Remote Loopback, Local Loopback, Automatic Echo Two DMA Controller Channels (DMAC)
SPI Mode
z z z
Test Modes
z
1276
45.3
Block Diagram
Figure 45-1. USART Block Diagram
(Peripheral) DMA Controller Channel Channel
USART
PIO Controller
RXD Receiver RTS Interrupt Controller USART Interrupt TXD Transmitter CTS
DIV
APB
Table 45-1. SPI Operating Mode PIN RXD TXD RTS CTS USART RXD TXD RTS CTS SPI Slave MOSI MISO CS SPI Master MISO MOSI CS
1277
45.4
USART
RS232 Drivers
RS485 Drivers
IrDA Transceivers
SPI Bus
Serial Port
Differential Bus
45.5
Table 45-2. I/O Line Description Name SCK Description Serial Clock Transmit Serial Data TXD or Master Out Slave In (MOSI) in SPI Master Mode or Master In Slave Out (MISO) in SPI Slave Mode Receive Serial Data RXD or Master In Slave Out (MISO) in SPI Master Mode or Master Out Slave In (MOSI) in SPI Slave Mode CTS Clear to Send or Slave Select (NSS) in SPI Slave Mode Request to Send or Slave Select (NSS) in SPI Master Mode Input Low Input I/O Type I/O Active Level
RTS
Output
Low
1278
45.6
Product Dependencies
1279
45.6.3 Interrupt
The USART interrupt line is connected on one of the internal sources of the Interrupt Controller. Using the USART interrupt requires the Interrupt Controller to be programmed first. Note that it is not recommended to use the USART interrupt line in edge sensitive mode.
Table 45-4. Peripheral IDs Instance USART0 USART1 USART2 USART3 ID 12 13 14 15
45.7
Functional Description
The USART is capable of managing several types of serial synchronous or asynchronous communications. It supports the following communication modes:
z
MSB-first or LSB-first 1, 1.5 or 2 stop bits Parity even, odd, marked, space or none By-8 or by-16 over-sampling receiver frequency Optional hardware handshaking Optional break management Optional multidrop serial communication MSB-first or LSB-first 1 or 2 stop bits Parity even, odd, marked, space or none By-8 or by-16 over-sampling frequency Optional hardware handshaking Optional break management Optional multidrop serial communication
z z
RS485 with driver control signal ISO7816, T0 or T1 protocols for interfacing with smart cards
z
NACK handling, error counter with repetition and iteration limit, inverted data.
z z
Master or Slave Serial Clock Programmable Phase and Polarity SPI Serial Clock (SCK) Frequency up to Internal Clock Frequency MCK/6 Remote loopback, local loopback, automatic echo
Test modes
z
1280
The Master Clock MCK A division of the Master Clock, the divider being product dependent, but generally set to 8 The external clock, available on the SCK pin
The Baud Rate Generator is based upon a 16-bit divider, which is programmed with the CD field of the Baud Rate Generator Register (US_BRGR). If CD is programmed to 0, the Baud Rate Generator does not generate any clock. If CD is programmed to 1, the divider is bypassed and becomes inactive. If the external SCK clock is selected, the duration of the low and high levels of the signal provided on the SCK pin must be longer than a Master Clock (MCK) period. The frequency of the signal provided on SCK must be at least 3 times lower than MCK in USART mode, or 6 times lower in SPI mode.
Figure 45-3. Baud Rate Generator
USCLKS MCK MCK/DIV SCK Reserved CD CD 0 1 2 3 0 16-bit Counter >1 1 0 1 1 SYNC USCLKS = 3 Sampling Clock 0 OVER Sampling Divider 0 Baud Rate Clock FIDI SYNC
SCK
45.7.1.1 Baud Rate in Asynchronous Mode If the USART is programmed to operate in asynchronous mode, the selected clock is first divided by CD, which is field programmed in the Baud Rate Generator Register (US_BRGR). The resulting clock is provided to the receiver as a sampling clock and then divided by 16 or 8, depending on the programming of the OVER bit in US_MR. If OVER is set to 1, the receiver sampling is 8 times higher than the baud rate clock. If OVER is cleared, the sampling is performed at 16 times the baud rate clock. The following formula performs the calculation of the Baud Rate.
SelectedClock Baudrate = -------------------------------------------( 8 ( 2 Over ) CD )
This gives a maximum baud rate of MCK divided by 8, assuming that MCK is the highest possible clock and that OVER is programmed to 1.
1281
BaudRate = MCK CD 16
The baud rate error is calculated with the following formula. It is not recommended to work with an error higher than 5%.
ExpectedBaudRate -------------------------------------------------- Error = 1 ActualBaudRate
45.7.1.2 Fractional Baud Rate in Asynchronous Mode The Baud Rate generator previously defined is subject to the following limitation: the output frequency changes by only integer multiples of the reference frequency. An approach to this problem is to integrate a fractional N clock generator that has a high resolution. The generator architecture is modified to obtain Baud Rate changes by a fraction of the reference source clock. This fractional part is programmed with the FP field in the Baud Rate Generator Register (US_BRGR). If FP is not 0, the fractional part is activated. The resolution is one eighth of the clock divider. This feature is only available when using USART normal mode. The fractional Baud Rate is calculated using the following formula:
SelectedClock Baudrate = --------------------------------------------------------------- 8 ( 2 Over ) CD + FP ------ 8
1282
CD
Modulus Control FP CD SCK FIDI 0 OVER Sampling Divider 1 1 SYNC USCLKS = 3 Sampling Clock 0 Baud Rate Clock SYNC
>1 1
45.7.1.3 Baud Rate in Synchronous Mode or SPI Mode If the USART is programmed to operate in synchronous mode, the selected clock is simply divided by the field CD in US_BRGR.
BaudRate = SelectedClock ------------------------------------CD
In synchronous mode, if the external clock is selected (USCLKS = 3), the clock is provided directly by the signal on the USART SCK pin. No division is active. The value written in US_BRGR has no effect. The external clock frequency must be at least 3 times lower than the system clock. In synchronous mode master (USCLKS = 0 or 1, CLK0 set to 1), the receive part limits the SCK maximum frequency to MCK/3 in USART mode, or MCK/6 in SPI mode. When either the external clock SCK or the internal clock divided (MCK/DIV) is selected, the value programmed in CD must be even if the user has to ensure a 50:50 mark/space ratio on the SCK pin. If the internal clock MCK is selected, the Baud Rate Generator ensures a 50:50 duty cycle on the SCK pin, even if the value programmed in CD is odd. 45.7.1.4 Baud Rate in ISO 7816 Mode The ISO7816 specification defines the bit rate with the following formula:
Di - f B = ----Fi
where:
z z z z
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)
1283
Di is a binary value encoded on a 4-bit field, named DI, as represented in Table 45-6.
Table 45-6. Binary and Decimal Values for Di DI field Di (decimal) 0001 1 0010 2 0011 4 0100 8 0101 16 0110 32 1000 12 1001 20
Fi is a binary value encoded on a 4-bit field, named FI, as represented in Table 45-7.
Table 45-7. Binary and Decimal Values for Fi FI field Fi (decimal) 0000 372 0001 372 0010 558 0011 744 0100 1116 0101 1488 0110 1860 1001 512 1010 768 1011 1024 1100 1536 1101 2048
Table 45-8 shows the resulting Fi/Di Ratio, which is the ratio between the ISO7816 clock and the baud rate clock.
Table 45-8. Possible Values for the Fi/Di Ratio Fi/Di 1 2 4 8 16 32 12 20 372 372 186 93 46.5 23.25 11.62 31 18.6 558 558 279 139.5 69.75 34.87 17.43 46.5 27.9 774 744 372 186 93 46.5 23.25 62 37.2 1116 1116 558 279 139.5 69.75 34.87 93 55.8 1488 1488 744 372 186 93 46.5 124 74.4 1806 1860 930 465 232.5 116.2 58.13 155 93 512 512 256 128 64 32 16 42.66 25.6 768 768 384 192 96 48 24 64 38.4 1024 1024 512 256 128 64 32 85.33 51.2 1536 1536 768 384 192 96 48 128 76.8 2048 2048 1024 512 256 128 64 170.6 102.4
If the USART is configured in ISO7816 Mode, the clock selected by the USCLKS field in the Mode Register (US_MR) is first divided by the value programmed in the field CD in the Baud Rate Generator Register (US_BRGR). The resulting clock can be provided to the SCK pin to feed the smart card clock inputs. This means that the CLKO bit can be set in US_MR. This clock is then divided by the value programmed in the FI_DI_RATIO field in the FI_DI_Ratio register (US_FIDI). This is performed by the Sampling Divider, which performs a division by up to 2047 in ISO7816 Mode. The non-integer values of the Fi/Di Ratio are not supported and the user must program the FI_DI_RATIO field to a value as close as possible to the expected value. The FI_DI_RATIO field resets to the value 0x174 (372 in decimal) and is the most common divider between the ISO7816 clock and the bit rate (Fi = 372, Di = 1). Figure 45-5 shows the relation between the Elementary Time Unit, corresponding to a bit time, and the ISO 7816 clock.
Figure 45-5. Elementary Time Unit (ETU)
FI_DI_RATIO ISO7816 Clock Cycles ISO7816 Clock on SCK ISO7816 I/O Line on TXD
1 ETU
1284
Start Bit
D0
D1
D2
D3
D4
D5
D6
D7
Parity Bit
Stop Bit
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.
1285
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.
Figure 45-7. Transmitter Status
Baud Rate Clock TXD
Start D0 Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Start D0 Bit Bit Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Bit Bit
TXEMPTY
45.7.3.2 Manchester Encoder When the Manchester encoder is in use, characters transmitted through the USART are encoded based on biphase Manchester II format. To enable this mode, set the MAN field in the US_MR register to 1. Depending on polarity configuration, a logic level (zero or one), is transmitted as a coded signal one-to-zero or zero-to-one. Thus, a transition always occurs at the midpoint of each bit time. It consumes more bandwidth than the original NRZ signal (2x) but the receiver has more error control since the expected input must show a change at the center of a bit cell. An example of Manchester encoded sequence is: the byte 0xB1 or 10110001 encodes to 10 01 10 10 01 01 01 10, assuming the default polarity of the encoder. Figure 45-8 illustrates this coding scheme.
Figure 45-8. NRZ to Manchester Encoding
NRZ encoded data Manchester encoded data 1 0 1 1 0 0 0 1
Txd
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 pre-defined pattern with a programmable length from 1 to 15 bit times. If the preamble length is set to 0, the preamble waveform is not generated prior to any character. The preamble pattern is chosen among the following sequences: ALL_ONE, ALL_ZERO, ONE_ZERO or ZERO_ONE, writing the field TX_PP in the US_MAN register, the field TX_PL is used to configure the preamble length. Figure 45-9 illustrates and defines the valid patterns. To improve flexibility, the encoding scheme can be configured using the TX_MPOL field in the US_MAN register. If the TX_MPOL field is set to zero (default), a logic zero is encoded with a zero-to-one transition and a logic one is encoded with a one-to-zero transition. If the TX_MPOL field is set to one, a logic one is encoded with a one-to-zero transition and a logic zero is encoded with a zero-to-one transition.
1286
Txd
SFD
DATA
Txd
SFD
DATA
Txd
SFD
DATA
Txd
SFD
DATA
A start frame delimiter is to be configured using the ONEBIT field in the US_MR register. It consists of a user-defined pattern that indicates the beginning of a valid data. Figure 45-10 illustrates these patterns. If the start frame delimiter, also known as the start bit, is one bit, (ONEBIT to 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 (ONEBIT to 0), a sequence of 3 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 field in the US_MR register 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 field in US_MR register must be set to 1. In this case, the MODSYNC field in US_MR is bypassed and the sync configuration is held in the TXSYNH in the US_THR register. The USART character format is modified and includes sync information.
1287
Command Sync start frame delimiter DATA 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.
Figure 45-11. Bit Resynchronization
Oversampling 16x Clock RXD
Sampling point Expected edge Synchro. Error Synchro. Jump Tolerance Sync Jump Synchro. Error
1288
45.7.3.3 Asynchronous Receiver If the USART is programmed in asynchronous operating mode (SYNC = 0), the receiver oversamples the RXD input line. The oversampling is either 16 or 8 times the Baud Rate clock, depending on the OVER bit in the Mode Register (US_MR). The receiver samples the RXD line. If the line is sampled during one half of a bit time to 0, a start bit is detected and data, parity and stop bits are successively sampled on the bit rate clock. If the oversampling is 16, (OVER to 0), a start is detected at the eighth sample to 0. Then, data bits, parity bit and stop bit are sampled on each 16 sampling clock cycle. If the oversampling is 8 (OVER to 1), a start bit is detected at the fourth sample to 0. Then, data bits, parity bit and stop bit are sampled on each 8 sampling clock cycle. The number of data bits, first bit sent and parity mode are selected by the same fields and bits as the transmitter, i.e. respectively CHRL, MODE9, MSBF and PAR. For the synchronization mechanism only , the number of stop bits has no effect on the receiver as it considers only one stop bit, regardless of the field NBSTOP, so that resynchronization between the receiver and the transmitter can occur. Moreover, as soon as the stop bit is sampled, the receiver starts looking for a new start bit so that resynchronization can also be accomplished when the transmitter is operating with one stop bit. Figure 45-12 and Figure 45-13 illustrate start detection and character reception when USART operates in asynchronous mode.
Figure 45-12. Asynchronous Start Detection
Baud Rate Clock 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 Sampling
0 1 Start Rejection
1289
D0
D1
D2
D3
D4
D5
D6
D7
Parity Bit
Stop Bit
45.7.3.4 Manchester Decoder When the MAN field in US_MR register is set to 1, the Manchester decoder is enabled. The decoder performs both preamble and start frame delimiter detection. One input line is dedicated to Manchester encoded input data. An optional preamble sequence can be defined, its length is user-defined and totally independent of the emitter side. Use RX_PL in US_MAN register to configure the length of the preamble sequence. If the length is set to 0, no preamble is detected and the function is disabled. In addition, the polarity of the input stream is programmable with RX_MPOL field in US_MAN register. Depending on the desired application the preamble pattern matching is to be defined via the RX_PP field in US_MAN. See Figure 45-9 for available preamble patterns. Unlike preamble, the start frame delimiter is shared between Manchester Encoder and Decoder. So, if ONEBIT field is set to 1, only a zero encoded Manchester can be detected as a valid start frame delimiter. If ONEBIT is set to 0, only a sync pattern is detected as a valid start frame delimiter. Decoder operates by detecting transition on incoming stream. If RXD is sampled during one quarter of a bit time to zero, a start bit is detected. See Figure 45-14. The sample pulse rejection mechanism applies. In order to increase the compatibility the RXIDLV bit in the US_MAN register allows to inform the USART block of the Rx line idle state value (Rx line undriven), it can be either level one (pull-up) or level zero (pull-down). By default this bit is set to one (Rx line is at level 1 if undriven).
Figure 45-14. Asynchronous Start Bit Detection
Sampling Clock (16 x) Manchester encoded data
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 re-synchronizes 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 45-15 illustrates Manchester
1290
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 US_CSR register is raised. It is cleared by writing the Control Register (US_CR) with the RSTSTA bit to 1. See Figure 45-16 for an example of Manchester error detection during data phase.
Figure 45-15. Preamble Pattern Mismatch
Preamble Mismatch Manchester coding error Preamble Mismatch invalid pattern
Txd
SFD
DATA
sampling points
When the start frame delimiter is a sync pattern (ONEBIT field to 0), both command and data delimiter are supported. If a valid sync is detected, the received character is written as RXCHR field in the US_RHR register and the RXSYNH is updated. RXCHR is set to 1 when the received character is a command, and it is set to 0 if the received character is a data. This mechanism alleviates and simplifies the direct memory access as the character contains its own sync field in the same register. As the decoder is setup to be used in unipolar mode, the first bit of the frame has to be a zero-to-one transition.
1291
45.7.3.5 Radio Interface: Manchester Encoded USART Application This section describes low data rate RF transmission systems and their integration with a Manchester encoded USART. These systems are based on transmitter and receiver ICs that support ASK and FSK modulation schemes. The goal is to perform full duplex radio transmission of characters using two different frequency carriers. See the configuration in Figure 45-17.
Figure 45-17. Manchester Encoded Characters RF Transmission
Upstream Emitter
Manchester decoder
USART Receiver
Downstream Receiver
USART Emitter
control
The USART module is configured as a Manchester encoder/decoder. Looking at the downstream communication channel, Manchester encoded characters are serially sent to the RF emitter. This may also include a user defined preamble and a start frame delimiter. Mostly, preamble is used in the RF receiver to distinguish between a valid data from a transmitter and signals due to noise. The Manchester stream is then modulated. See Figure 45-18 for an example of ASK modulation scheme. When a logic one is sent to the ASK modulator, the power amplifier, referred to as PA, is enabled and transmits an RF signal at downstream frequency. When a logic zero is transmitted, the RF signal is turned off. If the FSK modulator is activated, two different frequencies are used to transmit data. When a logic 1 is sent, the modulator outputs an RF signal at frequency F0 and switches to F1 if the data sent is a 0. See Figure 45-19. From the receiver side, another carrier frequency is used. The RF receiver performs a bit check operation examining demodulated data stream. If a valid pattern is detected, the receiver switches to receiving mode. The demodulated stream is sent to the Manchester decoder. Because of bit checking inside RF IC, the data transferred to the microcontroller is reduced by a user-defined number of bits. The Manchester preamble length is to be defined in accordance with the RF IC configuration.
1292
Txd
Txd
45.7.3.6 Synchronous Receiver In synchronous mode (SYNC = 1), the receiver samples the RXD signal on each rising edge of the Baud Rate Clock. If a low level is detected, it is considered as a start. All data bits, the parity bit and the stop bits are sampled and the receiver waits for the next start bit. Synchronous mode operations provide a high speed transfer capability. Configuration fields and bits are the same as in asynchronous mode. Figure 45-20 illustrates a character reception in synchronous mode.
Figure 45-20. Synchronous Mode Character Reception
Example: 8-bit, Parity Enabled 1 Stop Baud Rate Clock
RXD Sampling
Start
D0
D1
D2
D3
D4
D5
D6
D7 Parity Bit
Stop Bit
1293
45.7.3.7 Receiver Operations When a character reception is completed, it is transferred to the Receive Holding Register (US_RHR) and the RXRDY bit in the Status Register (US_CSR) rises. If a character is completed while the RXRDY is set, the OVRE (Overrun Error) bit is set. The last character is transferred into US_RHR and overwrites the previous one. The OVRE bit is cleared by writing the Control Register (US_CR) with the RSTSTA (Reset Status) bit to 1.
Figure 45-21. Receiver Status
Baud Rate Clock RXD
Start D0 Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Start D0 Bit Bit Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Bit Bit
RSTSTA = 1
RXRDY OVRE
45.7.3.8 Parity The USART supports five parity modes selected by programming the PAR field in the Mode Register (US_MR). The PAR field also enables the Multidrop mode, see Multidrop Mode on page 1295. 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 45-9 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 to 1, 1 bit is added when a parity is odd, or 0 is added when a parity is even.
1294
Table 45-9. Parity Bit Examples Character A A A A A Hexa 0x41 0x41 0x41 0x41 0x41 Binary 0100 0001 0100 0001 0100 0001 0100 0001 0100 0001 Parity Bit 1 0 1 0 None Parity Mode Odd Even Mark Space None
When the receiver detects a parity error, it sets the PARE (Parity Error) bit in the Channel Status Register (US_CSR). The PARE bit can be cleared by writing the Control Register (US_CR) with the RSTSTA bit to 1. Figure 45-22 illustrates the parity bit status setting and clearing.
Figure 45-22. Parity Error
RSTSTA = 1
RXRDY
45.7.3.9 Multidrop Mode If the PAR field in the Mode Register (US_MR) is programmed to the value 0x6 or 0x07, the USART runs in Multidrop Mode. This mode differentiates the data characters and the address characters. Data is transmitted with the parity bit to 0 and addresses are transmitted with the parity bit to 1. If the USART is configured in multidrop mode, the receiver sets the PARE parity error bit when the parity bit is high and the transmitter is able to send a character with the parity bit high when the Control Register is written with the SENDA bit to 1. To handle parity error, the PARE bit is cleared when the Control Register is written with the bit RSTSTA to 1. The transmitter sends an address byte (parity bit set) when SENDA is written to US_CR. In this case, the next byte written to US_THR is transmitted as an address. Any character written in US_THR without having written the command SENDA is transmitted normally with the parity to 0.
1295
45.7.3.10 Transmitter Timeguard The timeguard feature enables the USART interface with slow remote devices. The timeguard function enables the transmitter to insert an idle state on the TXD line between two characters. This idle state actually acts as a long stop bit. The duration of the idle state is programmed in the TG field of the Transmitter Timeguard Register (US_TTGR). When this field is programmed to zero no timeguard is generated. Otherwise, the transmitter holds a high level on TXD after each transmitted byte during the number of bit periods programmed in TG in addition to the number of stop bits. As illustrated in Figure 45-23, the behavior of TXRDY and TXEMPTY status bits is modified by the programming of a timeguard. TXRDY rises only when the start bit of the next character is sent, and thus remains to 0 during the timeguard transmission if a character has been written in US_THR. TXEMPTY remains low until the timeguard transmission is completed as the timeguard is part of the current character being transmitted.
Figure 45-23. Timeguard Operations
TG = 4 Baud Rate Clock TXD
Start D0 Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Bit Bit Start D0 Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Bit Bit
TG = 4
TXEMPTY
Table 45-10 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the function of the Baud Rate.
Table 45-10. Maximum Timeguard Length Depending on Baud Rate Baud Rate Bit/sec 1 200 9 600 14400 19200 28800 33400 56000 57600 115200 Bit time s 833 104 69.4 52.1 34.7 29.9 17.9 17.4 8.7 Timeguard ms 212.50 26.56 17.71 13.28 8.85 7.63 4.55 4.43 2.21
1296
45.7.3.11 Receiver Time-out The Receiver Time-out provides support in handling variable-length frames. This feature detects an idle condition on the RXD line. When a time-out is detected, the bit TIMEOUT in the Channel Status Register (US_CSR) rises and can generate an interrupt, thus indicating to the driver an end of frame. The time-out delay period (during which the receiver waits for a new character) is programmed in the TO field of the Receiver Time-out Register (US_RTOR). If the TO field is programmed to 0, the Receiver Time-out is disabled and no time-out is detected. The TIMEOUT bit in US_CSR remains to 0. Otherwise, the receiver loads a 16-bit counter with the value programmed in TO. This counter is decremented at each bit period and reloaded each time a new character is received. If the counter reaches 0, the TIMEOUT bit in the Status Register rises. Then, the user can either:
z
Stop the counter clock until a new character is received. This is performed by writing the Control Register (US_CR) with the STTTO (Start Time-out) bit to 1. In this case, the idle state on RXD before a new character is received will not provide a time-out. This prevents having to handle an interrupt before a character is received and allows waiting for the next idle state on RXD after a frame is received. Obtain an interrupt while no character is received. This is performed by writing US_CR with the RETTO (Reload and Start Time-out) bit to 1. If RETTO is performed, the counter starts counting down immediately from the value TO. This enables generation of a periodic interrupt so that a user time-out can be handled, for example when no key is pressed on a keyboard.
If STTTO is performed, the counter clock is stopped until a first character is received. The idle state on RXD before the start of the frame does not provide a time-out. This prevents having to obtain a periodic interrupt and enables a wait of the end of frame when the idle state on RXD is detected. If RETTO is performed, the counter starts counting down immediately from the value TO. This enables generation of a periodic interrupt so that a user time-out can be handled, for example when no key is pressed on a keyboard. Figure 45-24 shows the block diagram of the Receiver Time-out feature.
Figure 45-24. Receiver Time-out Block Diagram
Baud Rate Clock TO
1 STTTO
Clock
Clear
1297
Table 45-11 gives the maximum time-out period for some standard baud rates.
Table 45-11. Maximum Time-out Period Baud Rate bit/sec 600 1 200 2 400 4 800 9 600 14400 19200 28800 33400 56000 57600 200000 Bit Time s 1 667 833 417 208 104 69 52 35 30 18 17 5 Time-out ms 109 225 54 613 27 306 13 653 6 827 4 551 3 413 2 276 1 962 1 170 1 138 328
45.7.3.12 Framing Error The receiver is capable of detecting framing errors. A framing error happens when the stop bit of a received character is detected at level 0. This can occur if the receiver and the transmitter are fully desynchronized. A framing error is reported on the FRAME bit of the Channel Status Register (US_CSR). The FRAME bit is asserted in the middle of the stop bit as soon as the framing error is detected. It is cleared by writing the Control Register (US_CR) with the RSTSTA bit to 1.
Figure 45-25. Framing Error Status
Baud Rate Clock RXD
Start D0 Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Bit Bit
RSTSTA = 1
RXRDY
1298
45.7.3.13 Transmit Break The user can request the transmitter to generate a break condition on the TXD line. A break condition drives the TXD line low during at least one complete character. It appears the same as a 0x00 character sent with the parity and the stop bits to 0. However, the transmitter holds the TXD line at least during one character until the user requests the break condition to be removed. A break is transmitted by writing the Control Register (US_CR) with the STTBRK bit to 1. This can be performed at any time, either while the transmitter is empty (no character in either the Shift Register or in US_THR) or when a character is being transmitted. If a break is requested while a character is being shifted out, the character is first completed before the TXD line is held low. Once STTBRK command is requested further STTBRK commands are ignored until the end of the break is completed. The break condition is removed by writing US_CR with the STPBRK bit to 1. If the STPBRK is requested before the end of the minimum break duration (one character, including start, data, parity and stop bits), the transmitter ensures that the break condition completes. The transmitter considers the break as though it is a character, i.e. the STTBRK and STPBRK commands are taken into account only if the TXRDY bit in US_CSR is to 1 and the start of the break condition clears the TXRDY and TXEMPTY bits as if a character is processed. Writing US_CR with both STTBRK and STPBRK bits to 1 can lead to an unpredictable result. All STPBRK commands requested without a previous STTBRK command are ignored. A byte written into the Transmit Holding Register while a break is pending, but not started, is ignored. After the break condition, the transmitter returns the TXD line to 1 for a minimum of 12 bit times. Thus, the transmitter ensures that the remote receiver detects correctly the end of break and the start of the next character. If the timeguard is programmed with a value higher than 12, the TXD line is held high for the timeguard period. After holding the TXD line for this period, the transmitter resumes normal operations. Figure 45-26 illustrates the effect of both the Start Break (STTBRK) and Stop Break (STPBRK) commands on the TXD line.
Figure 45-26. Break Transmission
Baud Rate Clock TXD
Start D0 Bit D1 D2 D3 D4 D5 D6 D7 Parity Stop Bit Bit
End of Break
TXEMPTY
1299
45.7.3.14 Receive Break The receiver detects a break condition when all data, parity and stop bits are low. This corresponds to detecting a framing error with data to 0x00, but FRAME remains low. When the low stop bit is detected, the receiver asserts the RXBRK bit in US_CSR. This bit may be cleared by writing the Control Register (US_CR) with the bit RSTSTA to 1. An end of receive break is detected by a high level for at least 2/16 of a bit period in asynchronous operating mode or one sample at high level in synchronous operating mode. The end of break detection also asserts the RXBRK bit. 45.7.3.15 Hardware Handshaking The USART features a hardware handshaking out-of-band flow control. The RTS and CTS pins are used to connect with the remote device, as shown in Figure 45-27.
Figure 45-27. Connection with a Remote Device for Hardware Handshaking
Setting the USART to operate with hardware handshaking is performed by writing the USART_MODE field in the Mode Register (US_MR) to the value 0x2. The USART behavior when hardware handshaking is enabled is the same as the behavior in standard synchronous or asynchronous mode, except that the receiver drives the RTS pin as described below and the level on the CTS pin modifies the behavior of the transmitter as described below. Using this mode requires using the DMAC channel for reception. The transmitter can handle hardware handshaking in any case. Figure 45-28 shows how the transmitter operates if hardware handshaking is enabled. The CTS pin disables the transmitter. If a character is being processing, the transmitter is disabled only after the completion of the current character and transmission of the next character happens as soon as the pin CTS falls.
Figure 45-28. Transmitter Behavior when Operating with Hardware Handshaking
CTS
TXD
1300
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 USART Mode Register on page 1317 and PAR: Parity Type on page 1318. The USART cannot operate concurrently in both receiver and transmitter modes as the communication is unidirectional at a time. It has to be configured according to the required mode by enabling or disabling either the receiver or the transmitter as desired. Enabling both the receiver and the transmitter at the same time in ISO7816 mode may lead to unpredictable results. The ISO7816 specification defines an inverse transmission format. Data bits of the character must be transmitted on the I/O line at their negative value. 45.7.4.2 Protocol T = 0 In T = 0 protocol, a character is made up of one start bit, eight data bits, one parity bit and one guard time, which lasts two bit times. The transmitter shifts out the bits and does not drive the I/O line during the guard time. If no parity error is detected, the I/O line remains to 1 during the guard time and the transmitter can continue with the transmission of the next character, as shown in Figure 45-30. If a parity error is detected by the receiver, it drives the I/O line to 0 during the guard time, as shown in Figure 45-31. This error bit is also named NACK, for Non Acknowledge. In this case, the character lasts 1 bit time more, as the guard time length is the same and is added to the error bit time which lasts 1 bit time.
1301
When the USART is the receiver and it detects an error, it does not load the erroneous character in the Receive Holding Register (US_RHR). It appropriately sets the PARE bit in the Status Register (US_SR) so that the software can handle the error.
Figure 45-30. T = 0 Protocol without Parity Error
Baud Rate Clock RXD Start Bit D0 D1 D2 D3 D4 D5 D6 D7 Parity Guard Guard Next Bit Time 1 Time 2 Start Bit
Repetition
1302
45.7.4.3 Protocol T = 1 When operating in ISO7816 protocol T = 1, the transmission is similar to an asynchronous format with only one stop bit. The parity is generated when transmitting and checked when receiving. Parity error detection sets the PARE bit in the Channel Status Register (US_CSR).
IrDA Transceivers
The receiver and the transmitter must be enabled or disabled according to the direction of the transmission to be managed. To receive IrDA signals, the following needs to be done: z Disable TX and Enable RX z 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). z Receive data 45.7.5.1 IrDA Modulation For baud rates up to and including 115.2 Kbits/sec, the RZI modulation scheme is used. 0 is represented by a light pulse of 3/16th of a bit time. Some examples of signal pulse duration are shown in Table 45-12.
Table 45-12. IrDA Pulse Duration Baud Rate 2.4 Kb/s 9.6 Kb/s 19.2 Kb/s 38.4 Kb/s 57.6 Kb/s 115.2 Kb/s Pulse Duration (3/16) 78.13 s 19.53 s 9.77 s 4.88 s 3.26 s 1.63 s
1303
TXD
Bit Period
3 16 Bit Period
45.7.5.2 IrDA Baud Rate Table 45-13 gives some examples of CD values, baud rate error and pulse duration. Note that the requirement on the maximum acceptable error of 1.87% must be met.
Table 45-13. IrDA Baud Rate Error Peripheral Clock 3 686 400 20 000 000 32 768 000 40 000 000 3 686 400 20 000 000 32 768 000 40 000 000 3 686 400 20 000 000 32 768 000 40 000 000 3 686 400 20 000 000 32 768 000 40 000 000 3 686 400 20 000 000 32 768 000 40 000 000 3 686 400 20 000 000 32 768 000 Baud Rate 115 200 115 200 115 200 115 200 57 600 57 600 57 600 57 600 38 400 38 400 38 400 38 400 19 200 19 200 19 200 19 200 9 600 9 600 9 600 9 600 2 400 2 400 2 400 CD 2 11 18 22 4 22 36 43 6 33 53 65 12 65 107 130 24 130 213 260 96 521 853 Baud Rate Error 0.00% 1.38% 1.25% 1.38% 0.00% 1.38% 1.25% 0.93% 0.00% 1.38% 0.63% 0.16% 0.00% 0.16% 0.31% 0.16% 0.00% 0.16% 0.16% 0.16% 0.00% 0.03% 0.04% Pulse Time 1.63 1.63 1.63 1.63 3.26 3.26 3.26 3.26 4.88 4.88 4.88 4.88 9.77 9.77 9.77 9.77 19.53 19.53 19.53 19.53 78.13 78.13 78.13
1304
45.7.5.3 IrDA Demodulator The demodulator is based on the IrDA Receive filter comprised of an 8-bit down counter which is loaded with the value programmed in US_IF. When a falling edge is detected on the RXD pin, the Filter Counter starts counting down at the Master Clock (MCK) speed. If a rising edge is detected on the RXD pin, the counter stops and is reloaded with US_IF. If no rising edge is detected when the counter reaches 0, the input of the receiver is driven low during one bit time. Figure 45-34 illustrates the operations of the IrDA demodulator.
Figure 45-34. IrDA Demodulator Operations
MCK
RXD
Counter Value
Receiver Input
4 3 Pulse Rejected
Pulse Accepted
The programmed value in the US_IF register must always meet the following criteria: TMCK * (IRDA_FILTER + 3) < 1.41 us As the IrDA mode uses the same logic as the ISO7816, note that the FI_DI_RATIO field in US_FIDI must be set to a value higher than 0 in order to assure IrDA communications operate correctly.
RXD
TXD RTS
Differential Bus
The USART is set in RS485 mode by programming the USART_MODE field in the Mode Register (US_MR) to the value 0x1. The RTS pin is at a level inverse to the TXEMPTY bit. Significantly, the RTS pin remains high when a timeguard is programmed so that the line can remain driven after the last character completion. Figure 45-36 gives an example of the RTS waveform during a character transmission when the timeguard is enabled.
1305
TXEMPTY
RTS
1306
Operation in SPI Slave Mode is programmed by writing to 0xF the USART_MODE field in the Mode Register. In this case the SPI lines must be connected as described below: z The MOSI line drives the input pin RXD z The MISO line is driven by the output pin TXD z The SCK line drives the input pin SCK z The NSS line drives the input pin CTS In order to avoid unpredicted behavior, any change of the SPI Mode must be followed by a software reset of the transmitter and of the receiver (except the initial configuration after a hardware reset). 45.7.7.2 Baud Rate In SPI Mode, the baudrate generator operates in the same way as in USART synchronous mode: See Baud Rate in Synchronous Mode or SPI Mode on page 1283. However, there are some restrictions: In SPI Master Mode: z The external clock SCK must not be selected (USCLKS 0x3), and the bit CLKO must be set to 1 in the Mode Register (US_MR), in order to generate correctly the serial clock on the SCK pin. z To obtain correct behavior of the receiver and the transmitter, the value programmed in CD must be superior or equal to 6. z If the internal clock divided (MCK/DIV) is selected, the value programmed in CD must be even to ensure a 50:50 mark/space ratio on the SCK pin, this value can be odd if the internal clock is selected (MCK). In SPI Slave Mode: z The external clock (SCK) selection is forced regardless of the value of the USCLKS field in the Mode Register (US_MR). Likewise, the value written in US_BRGR has no effect, because the clock is provided directly by the signal on the USART SCK pin. z To obtain correct behavior of the receiver and the transmitter, the external clock (SCK) frequency must be at least 6 times lower than the system clock. 45.7.7.3 Data Transfer Up to 9 data bits are successively shifted out on the TXD pin at each rising or falling edge (depending of CPOL and CPHA) of the programmed serial clock. There is no Start bit, no Parity bit and no Stop bit. The number of data bits is selected by the CHRL field and the MODE 9 bit in the Mode Register (US_MR). The 9 bits are selected by setting the MODE 9 bit regardless of the CHRL field. The MSB data bit is always sent first in SPI Mode (Master or Slave). Four combinations of polarity and phase are available for data transfers. The clock polarity is programmed with the CPOL bit in the Mode Register. The clock phase is programmed with the CPHA bit. These two parameters determine the edges of the clock signal upon which data is driven and sampled. Each of the two parameters has two possible states, resulting in four possible combinations that are incompatible with one another. Thus, a master/slave pair must use the same parameter pair values to communicate. If multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a different slave.
Table 45-14. SPI Bus Protocol Mode SPI Bus Protocol Mode 0 1 2 3 CPOL 0 0 1 1 CPHA 1 0 1 0
1307
SCK (CPOL = 1)
MSB
LSB
MSB
LSB
SCK (CPOL = 1)
MSB
LSB
MSB
LSB
1308
45.7.7.4 Receiver and Transmitter Control See Receiver and Transmitter Control on page 1285. 45.7.7.5 Character Transmission The characters are sent by writing in the Transmit Holding Register (US_THR). An additional condition for transmitting a character can be added when the USART is configured in SPI master mode. In the USART_MR register, the value configured on INACK field can prevent any character transmission (even if US_THR has been written) while the receiver side is not ready (character not read). When WRDBT equals 0, the character is transmitted whatever the receiver status. If WRDBT is set to 1, the transmitter waits for the receiver holding register to be read before transmitting the character (RXRDY flag cleared), thus preventing any overflow (character loss) on the receiver side. 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. If the USART is in SPI Slave Mode and if a character must be sent while the Transmit Holding Register (US_THR) is empty, the UNRE (Underrun Error) bit is set. The TXD transmission line stays at high level during all this time. The UNRE bit is cleared by writing the Control Register (US_CR) with the RSTSTA (Reset Status) bit to 1. In SPI Master Mode, the slave select line (NSS) is asserted at low level 1 Tbit (Time bit) before the transmission of the MSB bit and released at high level 1 Tbit after the transmission of the LSB bit. So, the slave select line (NSS) is always released between each character transmission and a minimum delay of 3 Tbits always inserted. However, in order to address slave devices supporting the CSAAT mode (Chip Select Active After Transfer), the slave select line (NSS) can be forced at low level by writing the Control Register (US_CR) with the RTSEN bit to 1. The slave select line (NSS) can be released at high level only by writing the Control Register (US_CR) with the RTSDIS bit to 1 (for example, when all data have been transferred to the slave device). In SPI Slave Mode, the transmitter does not require a falling edge of the slave select line (NSS) to initiate a character transmission but only a low level. However, this low level must be present on the slave select line (NSS) at least 1 Tbit before the first serial clock cycle corresponding to the MSB bit. 45.7.7.6 Character Reception When a character reception is completed, it is transferred to the Receive Holding Register (US_RHR) and the RXRDY bit in the Status Register (US_CSR) rises. If a character is completed while RXRDY is set, the OVRE (Overrun Error) bit is set. The last character is transferred into US_RHR and overwrites the previous one. The OVRE bit is cleared by writing the Control Register (US_CR) with the RSTSTA (Reset Status) bit to 1. To ensure correct behavior of the receiver in SPI Slave Mode, the master device sending the frame must ensure a minimum delay of 1 Tbit between each character transmission. The receiver does not require a falling edge of the slave select line (NSS) to initiate a character reception but only a low level. However, this low level must be present on the slave select line (NSS) at least 1 Tbit before the first serial clock cycle corresponding to the MSB bit. 45.7.7.7 Receiver Timeout Because the receiver baudrate clock is active only during data transfers in SPI Mode, a receiver timeout is impossible in this mode, whatever the Time-out value is (field TO) in the Time-out Register (US_RTOR).
1309
TXD Transmitter
45.7.8.2 Automatic Echo Mode Automatic echo mode allows bit-by-bit retransmission. When a bit is received on the RXD pin, it is sent to the TXD pin, as shown in Figure 45-40. Programming the transmitter has no effect on the TXD pin. The RXD pin is still connected to the receiver input, thus the receiver remains active.
Figure 45-40. Automatic Echo Mode Configuration
RXD Receiver
TXD Transmitter
45.7.8.3 Local Loopback Mode Local loopback mode connects the output of the transmitter directly to the input of the receiver, as shown in Figure 45-41. The TXD and RXD pins are not used. The RXD pin has no effect on the receiver and the TXD pin is continuously driven high, as in idle state.
Figure 45-41. Local Loopback Mode Configuration
RXD Receiver
Transmitter
TXD
1310
45.7.8.4 Remote Loopback Mode Remote loopback mode directly connects the RXD pin to the TXD pin, as shown in Figure 45-42. The transmitter and the receiver are disabled and have no effect. This mode allows bit-by-bit retransmission.
Figure 45-42. Remote Loopback Mode Configuration
Receiver 1 RXD
TXD Transmitter
USART Mode Register USART Baud Rate Generator Register USART Receiver Time-out Register USART Transmitter Timeguard Register USART FI DI RATIO Register USART IrDA FILTER Register USART Manchester Configuration Register
1311
45.8
Table 45-15. Register Mapping Offset 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028 0x2C - 0x3C 0x0040 0x0044 0x0048 0x004C 0x0050 0xE4 0xE8 0x5C - 0xFC Register Control Register Mode Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Channel Status Register Receiver Holding Register Transmitter Holding Register Baud Rate Generator Register Receiver Time-out Register Transmitter Timeguard Register Reserved FI DI Ratio Register Number of Errors Register Reserved IrDA Filter Register Manchester Encoder Decoder Register Write Protect Mode Register Write Protect Status Register Reserved Name US_CR US_MR US_IER US_IDR US_IMR US_CSR US_RHR US_THR US_BRGR US_RTOR US_TTGR US_FIDI US_NER US_IF US_MAN US_WPMR US_WPSR Access Write-only Read-write Write-only Write-only Read-only Read-only Read-only Write-only Read-write Read-write Read-write Read-write Read-only Read-write Read-write Read-write Read-only Reset 0x0 0x0 0x0 0x0 0x0 0x174 0x0 0xB0011004 0x0 0x0
1312
US_CR 0xF001C000 (0), 0xF0020000 (1), 0xF8020000 (2), 0xF8024000 (3) Write-only
30 22 14 RSTNACK 6 TXEN 29 21 13 RSTIT 5 RXDIS 28 20 12 SENDA 4 RXEN 27 19 RTSDIS 11 STTTO 3 RSTTX 26 18 RTSEN 10 STPBRK 2 RSTRX 25 17 9 STTBRK 1 24 16 8 RSTSTA 0
For SPI control, see USART Control Register (SPI_MODE) on page 1315.
1313
1314
US_CR (SPI_MODE) 0xF001C000 (0), 0xF0020000 (1), 0xF8020000 (2), 0xF8024000 (3) Write-only
30 22 14 6 TXEN 29 21 13 5 RXDIS 28 20 12 4 RXEN 27 19 RCS 11 3 RSTTX 26 18 FCS 10 2 RSTRX 25 17 9 1 24 16 8 RSTSTA 0
This configuration is relevant only if USART_MODE=0xE or 0xF in USART Mode Register on page 1317.
1315
FCS: Force SPI Chip Select Applicable if USART operates in SPI Master Mode (USART_MODE = 0xE):
FCS = 0: No effect. FCS = 1: Forces the Slave Select Line NSS (RTS pin) to 0, even if USART is no transmitting, in order to address SPI slave devices supporting the CSAAT Mode (Chip Select Active After Transfer).
RCS: Release SPI Chip Select Applicable if USART operates in SPI Master Mode (USART_MODE = 0xE):
RCS = 0: No effect. RCS = 1: Releases the Slave Select Line NSS (RTS pin).
1316
US_MR 0xF001C004 (0), 0xF0020004 (1), 0xF8020004 (2), 0xF8024004 (3) Read-write
30 MODSYNC 22 VAR_SYNC 14 29 MAN 21 DSNACK 13 NBSTOP 4 3 28 FILTER 20 INACK 12 27 19 OVER 11 26 25 MAX_ITERATION 17 MODE9 9 24
18 CLKO 10 PAR 2
16 MSBF 8 SYNC 0
1 USART_MODE
This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341. For SPI configuration, see USART Mode Register (SPI_MODE) on page 1320.
1317
1318
1319
US_MR (SPI_MODE) 0xF001C004 (0), 0xF0020004 (1), 0xF8020004 (2), 0xF8024004 (3) Read-write
30 22 14 6 29 21 13 5 USCLKS 28 20 WRDBT 12 4 27 19 26 18 10 2 USART_MODE 25 17 24 16 CPOL 8 CPHA 0
11 3
9 1
This configuration is relevant only if USART_MODE=0xE or 0xF in USART Mode Register on page 1317. This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
CPHA: SPI Clock Phase Applicable if USART operates in SPI Mode (USART_MODE = 0xE or 0xF):
CPHA = 0: Data is changed on the leading edge of SPCK and captured on the following edge of SPCK. CPHA = 1: Data is captured on the leading edge of SPCK and changed on the following edge of SPCK. CPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. CPHA is used with CPOL to produce the required clock/data relationship between master and slave devices.
1320
CPOL: SPI Clock Polarity Applicable if USART operates in SPI Mode (Slave or Master, USART_MODE = 0xE or 0xF):
CPOL = 0: The inactive state value of SPCK is logic level zero. CPOL = 1: The inactive state value of SPCK is logic level one. CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with CPHA to produce the required clock/data relationship between master and slave devices.
1321
US_IER 0xF001C008 (0), 0xF0020008 (1), 0xF8020008 (2), 0xF8024008 (3) Write-only
30 22 14 6 FRAME 29 21 13 NACK 5 OVRE 28 20 12 4 27 19 CTSIC 11 3 26 18 10 ITER 2 RXBRK 25 17 9 TXEMPTY 1 TXRDY 24 MANE 16 8 TIMEOUT 0 RXRDY
For SPI specific configuration, see USART Interrupt Enable Register (SPI_MODE) on page 1323.
RXRDY: RXRDY Interrupt Enable TXRDY: TXRDY Interrupt Enable RXBRK: Receiver Break Interrupt Enable OVRE: Overrun Error Interrupt Enable FRAME: Framing Error Interrupt Enable PARE: Parity Error Interrupt Enable TIMEOUT: Time-out Interrupt Enable TXEMPTY: TXEMPTY Interrupt Enable ITER: Max number of Repetitions Reached Interrupt Enable NACK: Non Acknowledge Interrupt Enable CTSIC: Clear to Send Input Change Interrupt Enable MANE: Manchester Error Interrupt Enable
0: No effect 1: Enables the corresponding interrupt.
1322
US_IER (SPI_MODE) 0xF001C008 (0), 0xF0020008 (1), 0xF8020008 (2), 0xF8024008 (3) Write-only
30 22 14 6 29 21 13 5 OVRE 28 20 12 4 27 19 11 3 26 18 10 UNRE 2 25 17 9 TXEMPTY 1 TXRDY 24 16 8 0 RXRDY
This configuration is relevant only if USART_MODE=0xE or 0xF in USART Mode Register on page 1317.
RXRDY: RXRDY Interrupt Enable TXRDY: TXRDY Interrupt Enable OVRE: Overrun Error Interrupt Enable TXEMPTY: TXEMPTY Interrupt Enable UNRE: SPI Underrun Error Interrupt Enable
0: No effect 1: Enables the corresponding interrupt.
1323
45.8.7
Name:
Address: Access:
31 23 15 7 PARE
For SPI specific configuration, see USART Interrupt Disable Register (SPI_MODE) on page 1325.
RXRDY: RXRDY Interrupt Disable TXRDY: TXRDY Interrupt Disable RXBRK: Receiver Break Interrupt Disable OVRE: Overrun Error Interrupt Enable FRAME: Framing Error Interrupt Disable PARE: Parity Error Interrupt Disable TIMEOUT: Time-out Interrupt Disable TXEMPTY: TXEMPTY Interrupt Disable ITER: Max Number of Repetitions Reached Interrupt Disable NACK: Non Acknowledge Interrupt Disable CTSIC: Clear to Send Input Change Interrupt Disable MANE: Manchester Error Interrupt Disable
0: No effect 1: Disables the corresponding interrupt.
1324
US_IDR (SPI_MODE) 0xF001C00C (0), 0xF002000C (1), 0xF802000C (2), 0xF802400C (3) Write-only
30 22 14 6 29 21 13 5 OVRE 28 20 12 4 27 19 11 3 26 18 10 UNRE 2 25 17 9 TXEMPTY 1 TXRDY 24 16 8 0 RXRDY
This configuration is relevant only if USART_MODE=0xE or 0xF in USART Mode Register on page 1317.
RXRDY: RXRDY Interrupt Disable TXRDY: TXRDY Interrupt Disable OVRE: Overrun Error Interrupt Disable TXEMPTY: TXEMPTY Interrupt Disable UNRE: SPI Underrun Error Interrupt Disable
0: No effect 1: Disables the corresponding interrupt.
1325
45.8.9
Name:
Address: Access:
31 23 15 7 PARE
For SPI specific configuration, see USART Interrupt Mask Register (SPI_MODE) on page 1327.
RXRDY: RXRDY Interrupt Mask TXRDY: TXRDY Interrupt Mask RXBRK: Receiver Break Interrupt Mask OVRE: Overrun Error Interrupt Mask FRAME: Framing Error Interrupt Mask PARE: Parity Error Interrupt Mask TIMEOUT: Time-out Interrupt Mask TXEMPTY: TXEMPTY Interrupt Mask ITER: Max Number of Repetitions Reached Interrupt Mask NACK: Non Acknowledge Interrupt Mask CTSIC: Clear to Send Input Change Interrupt Mask MANE: Manchester Error Interrupt Mask
0: The corresponding interrupt is not enabled. 1: The corresponding interrupt is enabled.
1326
US_IMR (SPI_MODE) 0xF001C010 (0), 0xF0020010 (1), 0xF8020010 (2), 0xF8024010 (3) Read-only
30 22 14 6 29 21 13 5 OVRE 28 20 12 4 27 19 11 3 26 18 10 UNRE 2 25 17 9 TXEMPTY 1 TXRDY 24 16 8 0 RXRDY
This configuration is relevant only if USART_MODE=0xE or 0xF in USART Mode Register on page 1317.
RXRDY: RXRDY Interrupt Mask TXRDY: TXRDY Interrupt Mask OVRE: Overrun Error Interrupt Mask TXEMPTY: TXEMPTY Interrupt Mask UNRE: SPI Underrun Error Interrupt Mask
0: The corresponding interrupt is not enabled. 1: The corresponding interrupt is enabled.
1327
US_CSR 0xF001C014 (0), 0xF0020014 (1), 0xF8020014 (2), 0xF8024014 (3) Read-only
30 22 14 6 FRAME 29 21 13 NACK 5 OVRE 28 20 12 4 27 19 CTSIC 11 3 26 18 10 ITER 2 RXBRK 25 17 9 TXEMPTY 1 TXRDY 24 MANERR 16 8 TIMEOUT 0 RXRDY
For SPI specific configuration, see USART Channel Status Register (SPI_MODE) on page 1330.
1328
1329
US_CSR (SPI_MODE) 0xF001C014 (0), 0xF0020014 (1), 0xF8020014 (2), 0xF8024014 (3) Read-only
30 22 14 6 29 21 13 5 OVRE 28 20 12 4 27 19 11 3 26 18 10 UNRE 2 25 17 9 TXEMPTY 1 TXRDY 24 16 8 0 RXRDY
This configuration is relevant only if USART_MODE=0xE or 0xF in USART Mode Register on page 1317.
1330
US_RHR 0xF001C018 (0), 0xF0020018 (1), 0xF8020018 (2), 0xF8024018 (3) Read-only
30 22 14 6 29 21 13 5 28 20 12 4 RXCHR 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 RXCHR 0
1331
US_THR 0xF001C01C (0), 0xF002001C (1), 0xF802001C (2), 0xF802401C (3) Write-only
30 22 14 6 29 21 13 5 28 20 12 4 TXCHR 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 TXCHR 0
1332
US_BRGR 0xF001C020 (0), 0xF0020020 (1), 0xF8020020 (2), 0xF8024020 (3) Read-write
30 22 14 29 21 13 28 20 12 CD 7 6 5 4 CD 3 2 1 0 27 19 11 26 18 25 17 FP 9 24 16
10
This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
USART_MODE = ISO7816
1333
US_RTOR 0xF001C024 (0), 0xF0020024 (1), 0xF8020024 (2), 0xF8024024 (3) Read-write
30 29 28 27 26 25 24
23 15
22 14
21 13
20 12 TO
19 11
18 10
17 9
16 8
4 TO
This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
1334
US_TTGR 0xF001C028 (0), 0xF0020028 (1), 0xF8020028 (2), 0xF8024028 (3) Read-write
30 22 14 6 29 21 13 5 28 20 12 4 TG 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0
This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
1335
US_FIDI 0xF001C040 (0), 0xF0020040 (1), 0xF8020040 (2), 0xF8024040 (3) Read-write 0x174
30 22 14 29 21 13 28 20 12 FI_DI_RATIO 7 6 5 4 FI_DI_RATIO 3 2 1 0 27 19 11 26 18 10 25 17 9 24 16 8
This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
1336
US_NER 0xF001C044 (0), 0xF0020044 (1), 0xF8020044 (2), 0xF8024044 (3) Read-only
30 22 14 6 29 21 13 5 28 20 12 4 NB_ERRORS 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0
This register is relevant only if USART_MODE=0x4 or 0x6 in USART Mode Register on page 1317.
1337
US_IF 0xF001C04C (0), 0xF002004C (1), 0xF802004C (2), 0xF802404C (3) Read-write
30 22 14 6 29 21 13 5 28 20 12 4 IRDA_FILTER 27 19 11 3 26 18 10 2 25 17 9 1 24 16 8 0
This register is relevant only if USART_MODE=0x8 in USART Mode Register on page 1317. This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
1338
US_MAN 0xF001C050 (0), 0xF0020050 (1), 0xF8020050 (2), 0xF8024050 (3) Read-write
30 DRIFT 22 14 6 29 ONE 21 13 5 28 RX_MPOL 20 12 TX_MPOL 4 27 19 26 18 RX_PL 11 3 10 2 TX_PL 9 TX_PP 1 0 8 25 RX_PP 17 16 24
This register can only be written if the WPEN bit is cleared in USART Write Protect Mode Register on page 1341.
TX_PL: Transmitter Preamble Length 0: The Transmitter Preamble pattern generation is disabled
1 - 15: The Preamble Length is TX_PL x Bit Period
TX_PP: Transmitter Preamble Pattern The following values assume that TX_MPOL field is not set:
Value 00 01 10 11 Name ALL_ONE ALL_ZERO ZERO_ONE ONE_ZERO Description The preamble is composed of 1s The preamble is composed of 0s The preamble is composed of 01s The preamble is composed of 10s
TX_MPOL: Transmitter Manchester Polarity 0: Logic Zero is coded as a zero-to-one transition, Logic One is coded as a one-to-zero transition.
1: Logic Zero is coded as a one-to-zero transition, Logic One is coded as a zero-to-one transition.
RX_PL: Receiver Preamble Length 0: The receiver preamble pattern detection is disabled
1 - 15: The detected preamble length is RX_PL x Bit Period
RX_PP: Receiver Preamble Pattern detected The following values assume that RX_MPOL field is not set:
Value 00 01 10 11 Name ALL_ONE ALL_ZERO ZERO_ONE ONE_ZERO Description The preamble is composed of 1s The preamble is composed of 0s The preamble is composed of 01s The preamble is composed of 10s
1339
RX_MPOL: Receiver Manchester Polarity 0: Logic Zero is coded as a zero-to-one transition, Logic One is coded as a one-to-zero transition.
1: Logic Zero is coded as a one-to-zero transition, Logic One is coded as a zero-to-one transition.
ONE: Must Be Set to 1 Bit 29 must always be set to 1 when programming the US_MAN register. DRIFT: Drift Compensation 0: The USART can not recover from an important clock drift
1: The USART can recover from clock drift. The 16X clock mode must be enabled.
1340
US_WPMR 0xF001C0E4 (0), 0xF00200E4 (1), 0xF80200E4 (2), 0xF80240E4 (3) Read-write See Table 45-15
30 29 28 WPKEY 23 22 21 20 WPKEY 15 14 13 12 WPKEY 7 6 5 4 3 2 1 0 WPEN 11 10 9 8 19 18 17 16 27 26 25 24
USART Mode Register on page 1317 USART Baud Rate Generator Register on page 1333 USART Receiver Time-out Register on page 1334 USART Transmitter Timeguard Register on page 1335 USART FI DI RATIO Register on page 1336 USART IrDA FILTER Register on page 1338 USART Manchester Configuration Register on page 1339 WPKEY: Write Protect KEY
Should be written at value 0x555341 (USA in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0.
1341
US_WPSR 0xF001C0E8 (0), 0xF00200E8 (1), 0xF80200E8 (2), 0xF80240E8 (3) Read-only See Table 45-15
30 22 29 21 28 20 WPVSRC 15 14 13 12 WPVSRC 7 6 5 4 3 2 1 0 WPVS 11 10 9 8 27 19 26 18 25 17 24 16
1342
46.
46.1
46.2
Embedded Characteristics
z z z
Fully Compliant with CAN 2.0 Part A and 2.0 Part B Bit Rates up to 1 Mbps 8 Object Oriented Mailboxes with the Following Properties:
z z z z z z
CAN Specification 2.0 Part A or 2.0 Part B Programmable for Each Message Object Configurable in Receive (with Overwrite or Not) or Transmit Modes Independent 29-bit Identifier and Mask Defined for Each Mailbox 32-bit Access to Data Registers for Each Mailbox Data Object Uses a 16-bit Timestamp on Receive and Transmit Messages Hardware Concatenation of ID Masked Bitfields To Speed Up Family ID Processing
z z z z z z z
16-bit Internal Timer for Timestamping and Network Synchronization Programmable Reception Buffer Length up to 8 Mailbox Objects Priority Management between Transmission Mailboxes Autobaud and Listening Mode Low-power Mode and Programmable Wake-up on Bus Activity or by the Application Data, Remote, Error and Overload Frame Handling Write Protected Registers
1343
46.3
Block Diagram
Figure 46-1. CAN Block Diagram
CANTX
Error Counter
MBx
(x = number of mailboxes - 1)
Internal Bus
46.4
Figure 46-2.
Layers
CAN-based Profiles CAN-based Application Layer CAN Data Link Layer CAN Physical Layer
Implementation
Software Software CAN Controller Transceiver
1344
46.5
Table 46-1. I/O Lines Description Name CANRX CANTX Description CAN Receive Serial Data CAN Transmit Serial Data Type Input Output
46.6
Product Dependencies
46.6.3 Interrupt
The CAN interrupt line is connected on one of the internal sources of the Advanced Interrupt Controller. Using the CAN interrupt requires the AIC to be programmed first. Note that it is not recommended to use the CAN interrupt line in edgesensitive mode.
Table 46-3. Peripheral IDs Instance CAN0 CAN1 ID 40 41
1345
46.7
Data frames: They carry data from a transmitter node to the receiver nodes. The overall maximum data frame length is 108 bits for a standard frame and 128 bits for an extended frame. Remote frames: A destination node can request data from the source by sending a remote frame with an identifier that matches the identifier of the required data frame. The appropriate data source node then sends a data frame as a response to this node request. Error frames: An error frame is generated by any node that detects a bus error. Overload frames: They provide an extra delay between the preceding and the successive data frames or remote frames.
z z
The Atmel CAN controller provides the CPU with full functionality of the CAN protocol V2.0 Part A and V2.0 Part B. It minimizes the CPU load in communication overhead. The Data Link Layer and part of the physical layer are automatically handled by the CAN controller itself. The CPU reads or writes data or messages via the CAN controller mailboxes. An identifier is assigned to each mailbox. The CAN controller encapsulates or decodes data messages to build or to decode bus data frames. Remote frames, error frames and overload frames are automatically handled by the CAN controller under supervision of the software application.
1346
&
&
==
Yes Message Accepted
No
Message Refused
CAN_MFIDx
If a mailbox is dedicated to receiving several messages (a family of messages) with different IDs, the acceptance mask defined in the CAN_MAMx register must mask the variable part of the ID family. Once a message is received, the application must decode the masked bits in the CAN_MIDx. To speed up the decoding, masked bits are grouped in the family ID register (CAN_MFIDx). For example, if the following message IDs are handled by the same mailbox: ID0 101000100100010010000100 0 11 00b ID1 101000100100010010000100 0 11 01b ID2 101000100100010010000100 0 11 10b ID3 101000100100010010000100 0 11 11b ID4 101000100100010010000100 1 11 00b ID5 101000100100010010000100 1 11 01b ID6 101000100100010010000100 1 11 10b ID7 101000100100010010000100 1 11 11b The CAN_MIDx and CAN_MAMx of Mailbox x must be initialized to the corresponding values: CAN_MIDx = 001 101000100100010010000100 x 11 xxb CAN_MAMx = 001 111111111111111111111111 0 11 00b If Mailbox x receives a message with ID6, then CAN_MIDx and CAN_MFIDx are set: CAN_MIDx = 001 101000100100010010000100 1 11 10b CAN_MFIDx = 00000000000000000000000000000110b If the application associates a handler for each message ID, it may define an array of pointers to functions: void (*pHandler[8])(void); When a message is received, the corresponding handler can be invoked using CAN_MFIDx register and there is no need to check masked bits: unsigned int MFID0_register; MFID0_register = Get_CAN_MFID0_Register(); // Get_CAN_MFID0_Register() returns the value of the CAN_MFID0 register pHandler[MFID0_register]();
1347
46.7.2.2 Receive Mailbox When the CAN module receives a message, it looks for the first available mailbox with the lowest number and compares the received message ID with the mailbox ID. If such a mailbox is found, then the message is stored in its data registers. Depending on the configuration, the mailbox is disabled as long as the message has not been acknowledged by the application (Receive only), or, if new messages with the same ID are received, then they overwrite the previous ones (Receive with overwrite). It is also possible to configure a mailbox in Consumer Mode. In this mode, after each transfer request, a remote frame is automatically sent. The first answer received is stored in the corresponding mailbox data registers. Several mailboxes can be chained to receive a buffer. They must be configured with the same ID in Receive Mode, except for the last one, which can be configured in Receive with Overwrite Mode. The last mailbox can be used to detect a buffer overflow.
Table 46-4. Receive Mailbox Object Types Mailbox Object Type Receive Description The first message received is stored in mailbox data registers. Data remain available until the next transfer request. The last message received is stored in mailbox data register. The next message always overwrites the previous one. The application has to check whether a new message has not overwritten the current one while reading the data registers. A remote frame is sent by the mailbox. The answer received is stored in mailbox data register. This extends Receive mailbox features. Data remain available until the next transfer request.
Consumer
46.7.2.3 Transmit Mailbox When transmitting a message, the message length and data are written to the transmit mailbox with the correct identifier. For each transmit mailbox, a priority is assigned. The controller automatically sends the message with the highest priority first (set with the field PRIOR in CAN_MMRx register). It is also possible to configure a mailbox in Producer Mode. In this mode, when a remote frame is received, the mailbox data are sent automatically. By enabling this mode, a producer can be done using only one mailbox instead of two: one to detect the remote frame and one to send the answer.
Table 46-5. Transmit Mailbox Object Types Mailbox Object Type Transmit Description The message stored in the mailbox data registers will try to win the bus arbitration immediately or later according to or not the Time Management Unit configuration (see Section 46.7.3). The application is notified that the message has been sent or aborted. Producer The message prepared in the mailbox data registers will be sent after receiving the next remote frame. This extends transmit mailbox features.
1348
After a reset When the CAN controller is in Low-power Mode is enabled (LPM bit set in the CAN_MR and SLEEP bit set in the CAN_SR) After a reset of the CAN controller (CANEN bit in the CAN_MR register) In Time-triggered Mode, when a message is accepted by the last mailbox (rising edge of the MRDY signal in the CAN_MSRlast_mailbox_number register).
The application can also reset the internal timer by setting TIMRST in the CAN_TCR register. The current value of the internal timer is always accessible by reading the CAN_TIM register. When the timer rolls-over from FFFFh to 0000h, TOVF (Timer Overflow) signal in the CAN_SR register is set. TOVF bit in the CAN_SR register is cleared by reading the CAN_SR register. Depending on the corresponding interrupt mask in the CAN_IMR register, an interrupt is generated while TOVF is set. In a CAN network, some CAN devices may have a larger counter. In this case, the application can also decide to freeze the internal counter when the timer reaches FFFFh and to wait for a restart condition from another device. This feature is enabled by setting TIMFRZ in the CAN_MR register. The CAN_TIM register is frozen to the FFFFh value. A clear condition described above restarts the timer. A timer overflow (TOVF) interrupt is triggered. To monitor the CAN bus activity, the CAN_TIM register is copied to the CAN _TIMESTP register after each start of frame or end of frame and a TSTP interrupt is triggered. If TEOF bit in the CAN_MR register is set, the value is captured at each End Of Frame, else it is captured at each Start Of Frame. Depending on the corresponding mask in the CAN_IMR register, an interrupt is generated while TSTP is set in the CAN_SR. TSTP bit is cleared by reading the CAN_SR register. The time management unit can operate in one of the two following modes:
z z
Timestamping mode: The value of the internal timer is captured at each Start Of Frame or each End Of Frame Time Triggered mode: A mailbox transfer operation is triggered when the internal timer reaches the mailbox trigger.
Timestamping Mode is enabled by clearing TTM field in the CAN_MR register. Time Triggered Mode is enabled by setting TTM field in the CAN_MR register.
SYNC_SEG
PROP_SEG
PHASE_SEG1
PHASE_SEG2
Sample Point
1349
TIME QUANTUM
The TIME QUANTUM (TQ) is a fixed unit of time derived from the MCK period. The total number of TIME QUANTA in a bit time is programmable from 8 to 25. SYNC SEG: SYNChronization Segment. This part of the bit time is used to synchronize the various nodes on the bus. An edge is expected to lie within this segment. It is 1 TQ long.
z
This part of the bit time is used to compensate for the physical delay times within the network. It is twice the sum of the signals propagation time on the bus line, the input comparator delay, and the output driver delay. It is programmable to be 1,2,..., 8 TQ long. This parameter is defined in the PROPAG field of the CAN Baudrate Register.
z
The Phase-Buffer-Segments are used to compensate for edge phase errors. These segments can be lengthened (PHASE SEG1) or shortened (PHASE SEG2) by resynchronization. Phase Segment 1 is programmable to be 1,2,..., 8 TQ long. Phase Segment 2 length has to be at least as long as the Information Processing Time (IPT) and may not be more than the length of Phase Segment 1. These parameters are defined in the PHASE1 and PHASE2 fields of the CAN Baudrate Register.
z
The Information Processing Time (IPT) is the time required for the logic to determine the bit level of a sampled bit. The IPT begins at the sample point, is measured in TQ and is fixed at 2 TQ for the Atmel CAN. Since Phase Segment 2 also begins at the sample point and is the last segment in the bit time, PHASE SEG2 shall not be less than the IPT.
z
SAMPLE POINT:
The SAMPLE POINT is the point in time at which the bus level is read and interpreted as the value of that respective bit. Its location is at the end of PHASE_SEG1.
z
The ReSynchronization Jump Width defines the limit to the amount of lengthening or shortening of the Phase Segments. SJW is programmable to be the minimum of PHASE SEG1 and 4 TQ. If the SMP field in the CAN_BR register is set, then the incoming bit stream is sampled three times with a period of half a CAN clock period, centered on sample point. In the CAN controller, the length of a bit on the CAN bus is determined by the parameters (BRP, PROPAG, PHASE1 and PHASE2).
t PRS = t CSC ( PROPAG + 1 ) t PHS1 = t CSC ( PHASE1 + 1 ) t PHS2 = t CSC ( PHASE2 + 1 ) To compensate for phase shifts between clock oscillators of different controllers on the bus, the CAN controller must resynchronize on any relevant signal edge of the current transmission. The resynchronization shortens or lengthens the bit time so that the position of the sample point is shifted with regard to the detected edge. The resynchronization jump width (SJW) defines the maximum of time by which a bit period may be shortened or lengthened by resynchronization. t SJW = t CSC ( SJW + 1 )
1350
PROP_SEG
PHASE_SEG1
PHASE_SEG2
Sample Point
Transmission Point
Example of bit timing determination for CAN baudrate of 500 Kbit/s: MCK = 48MHz CAN baudrate= 500kbit/s => bit time= 2us Delay of the bus driver: 50 ns Delay of the receiver: 30ns Delay of the bus line (20m): 110ns The total number of time quanta in a bit time must be comprised between 8 and 25. If we fix the bit time to 16 time quanta: Tcsc = 1 time quanta = bit time / 16 = 125 ns => BRP = (Tcsc x MCK) - 1 = 5 The propagation segment time is equal to twice the sum of the signals propagation time on the bus line, the receiver delay and the output driver delay: Tprs = 2 * (50+30+110) ns = 380 ns = 3 Tcsc => PROPAG = Tprs/Tcsc - 1 = 2 The remaining time for the two phase segments is: Tphs1 + Tphs2 = bit time - Tcsc - Tprs = (16 - 1 - 3)Tcsc Tphs1 + Tphs2 = 12 Tcsc Because this number is even, we choose Tphs2 = Tphs1 (else we would choose Tphs2 = Tphs1 + Tcsc) Tphs1 = Tphs2 = (12/2) Tcsc = 6 Tcsc => PHASE1 = PHASE2 = Tphs1/Tcsc - 1 = 5 The resynchronization jump width must be comprised between 1 Tcsc and the minimum of 4 Tcsc and Tphs1. We choose its maximum value: Tsjw = Min(4 Tcsc,Tphs1) = 4 Tcsc => SJW = Tsjw/Tcsc - 1 = 3 Finally: CAN_BR = 0x00053255
1351
The phase error is positive, then PHASE_SEG1 is lengthened by an amount equal to the resynchronization jump width. The phase error is negative, then PHASE_SEG2 is shortened by an amount equal to the resynchronization jump width.
SYNC_ SEG
PROP_SEG
PHASE_SEG1 PHASE_SEG2
SYNC_ SEG
SYNC_ SEG
PROP_SEG
PHASE_SEG1
PHASE_SEG2
SYNC_ SEG
THE PHASE ERROR IS NEGATIVE (the transmitter is faster than the receiver) Received data bit
PHASE_SEG2
SYNC_ SEG
PROP_SEG
PHASE_SEG1 PHASE_SEG2
SYNC_ SEG
Phase error
PROP_SEG
PHASE_SEG1 PHASE_SEG2
SYNC_ SEG
Autobaud Mode
The autobaud feature is enabled by setting the ABM field in the CAN_MR register. In this mode, the CAN controller is only listening to the line without acknowledging the received messages. It can not send any message. The errors flags are updated. The bit timing can be adjusted until no error occurs (good configuration found). In this mode, the error counters are frozen. To go back to the standard mode, the ABM bit must be cleared in the CAN_MR register.
1352
46.7.4.2 Error Detection There are five different error types that are not mutually exclusive. Each error concerns only specific fields of the CAN data frame (refer to the Bosch CAN specification for their correspondence):
z
CRC error (CERR bit in the CAN_SR register): With the CRC, the transmitter calculates a checksum for the CRC bit sequence from the Start of Frame bit until the end of the Data Field. This CRC sequence is transmitted in the CRC field of the Data or Remote Frame. Bit-stuffing error (SERR bit in the CAN_SR register): If a node detects a sixth consecutive equal bit level during the bit-stuffing area of a frame, it generates an Error Frame starting with the next bit-time. Bit error (BERR bit in CAN_SR register): A bit error occurs if a transmitter sends a dominant bit but detects a recessive bit on the bus line, or if it sends a recessive bit but detects a dominant bit on the bus line. An error frame is generated and starts with the next bit time. Form Error (FERR bit in the CAN_SR register): If a transmitter detects a dominant bit in one of the fix-formatted segments CRC Delimiter, ACK Delimiter or End of Frame, a form error has occurred and an error frame is generated. Acknowledgment error (AERR bit in the CAN_SR register): The transmitter checks the Acknowledge Slot, which is transmitted by the transmitting node as a recessive bit, contains a dominant bit. If this is the case, at least one other node has received the frame correctly. If not, an Acknowledge Error has occurred and the transmitter will start in the next bit-time an Error Frame transmission.
z z
Fault Confinement
To distinguish between temporary and permanent failures, every CAN controller has two error counters: REC (Receive Error Counter) and TEC (Transmit Error Counter). The two counters are incremented upon detected errors and are decremented upon correct transmissions or receptions, respectively. Depending on the counter values, the state of the node changes: the initial state of the CAN controller is Error Active, meaning that the controller can send Error Active flags. The controller changes to the Error Passive state if there is an accumulation of errors. If the CAN controller fails or if there is an extreme accumulation of errors, there is a state transition to Bus Off.
Figure 46-7. Line Error Mode
Init
ERROR PASSIVE
BUS OFF
An error active unit takes part in bus communication and sends an active error frame when the CAN controller detects an error. An error passive unit cannot send an active error frame. It takes part in bus communication, but when an error is detected, a passive error frame is sent. Also, after a transmission, an error passive unit waits before initiating further transmission. A bus off unit is not allowed to have any influence on the bus.
1353
For fault confinement, two errors counters (TEC and REC) are implemented. These counters are accessible via the CAN_ECR register. The state of the CAN controller is automatically updated according to these counter values. If the CAN controller enters Error Active state, then the ERRA bit is set in the CAN_SR register. The corresponding interrupt is pending while the interrupt is not masked in the CAN_IMR register. If the CAN controller enters Error Passive Mode, then the ERRP bit is set in the CAN_SR register and an interrupt remains pending while the ERRP bit is set in the CAN_IMR register. If the CAN enters Bus Off Mode, then the BOFF bit is set in the CAN_SR register. As for ERRP and ERRA, an interrupt is pending while the BOFF bit is set in the CAN_IMR register. When one of the error counters values exceeds 96, an increased error rate is indicated to the controller through the WARN bit in CAN_SR register, but the node remains error active. The corresponding interrupt is pending while the interrupt is set in the CAN_IMR register. Refer to the Bosch CAN specification v2.0 for details on fault confinement.
Detection of a dominant bit during the first two bits of the intermission field Detection of a dominant bit in the last bit of EOF by a receiver, or detection of a dominant bit by a receiver or a transmitter at the last bit of an error or overload frame delimiter
The CAN controller can generate a request overload frame automatically after each message sent to one of the CAN controller mailboxes. This feature is enabled by setting the OVL bit in the CAN_MR register. Reactive overload frames are automatically handled by the CAN controller even if the OVL bit in the CAN_MR register is not set. An overload flag is generated in the same way as an error flag, but error counters do not increment.
1354
Reception is disabled while the SLEEP signal is set to one in the CAN_SR register. It is important to note that those messages with higher priority than the last message transmitted can be received between the LPM command and entry in Low-power Mode. Once in Low-power Mode, the CAN controller clock can be switched off by programming the chips Power Management Controller (PMC). The CAN controller drains only the static current. Error counters are disabled while the SLEEP signal is set to one. Thus, to enter Low-power Mode, the software application must:
z z
Set LPM field in the CAN_MR register Wait for SLEEP signal rising
Now the CAN Controller clock can be disabled. This is done by programming the Power Management Controller (PMC).
Figure 46-8. Enabling Low-power Mode
Arbitration lost
CAN BUS LPEN= 1 LPM (CAN_MR) SLEEP (CAN_SR) WAKEUP (CAN_SR) MRDY (CAN_MSR1) MRDY (CAN_MSR3) CAN_TIM
Mailbox 1
Mailbox 3
0x0
46.7.5.2 Disabling Low-power Mode The CAN controller can be awake after detecting a CAN bus activity. Bus activity detection is done by an external module that may be embedded in the chip. When it is notified of a CAN bus activity, the software application disables Low-power Mode by programming the CAN controller. To disable Low-power Mode, the software application must:
z z
Enable the CAN Controller clock. This is done by programming the Power Management Controller (PMC). Clear the LPM field in the CAN_MR register
The CAN controller synchronizes itself with the bus activity by checking for eleven consecutive recessive bits. Once synchronized, the WAKEUP signal in the CAN_SR register is set. Depending on the corresponding mask in the CAN_IMR register, an interrupt is generated while WAKEUP is set. The SLEEP signal in the CAN_SR register is automatically cleared once WAKEUP is set. WAKEUP signal is automatically cleared once SLEEP is set. If no message is being sent on the bus, then the CAN controller is able to send a message eleven bit times after disabling Low-power Mode. If there is bus activity when Low-power mode is disabled, the CAN controller is synchronized with the bus activity in the next interframe. The previous message is lost (see Figure 46-9).
1355
Message lost
MRDY (CAN_MSRx)
1356
46.8
Functional Description
Yes
CANEN = 1 (ABM == 0)
End of Initialization
1357
Data registers in the mailbox object are available to the application. In Receive Mode, a new message was received. In Transmit Mode, a message was transmitted successfully. A sent transmission was aborted. Bus off interrupt: The CAN module enters the bus off state. Error passive interrupt: The CAN module enters Error Passive Mode. Error Active Mode: The CAN module is neither in Error Passive Mode nor in Bus Off mode. Warn Limit interrupt: The CAN module is in Error-active Mode, but at least one of its error counter value exceeds 96. Wake-up interrupt: This interrupt is generated after a wake-up and a bus synchronization. Sleep interrupt: This interrupt is generated after a Low-power Mode enable once all pending messages in transmission have been sent. Internal timer counter overflow interrupt: This interrupt is generated when the internal timer rolls over. Timestamp interrupt: This interrupt is generated after the reception or the transmission of a start of frame or an end of frame. The value of the internal counter is copied in the CAN_TIMESTP register.
System interrupts
z z z z z z z z
All interrupts are cleared by clearing the interrupt source except for the internal timer counter overflow interrupt and the timestamp interrupt. These interrupts are cleared by reading the CAN_SR register.
1358
Message 1
Message 2 lost
Message 3
Message 1
Message 3
Note:
In the case of ARM architecture, CAN_MSRx, CAN_MDLx, CAN_MDHx can be read using an optimized ldm assembler instruction.
1359
CAN BUS MRDY (CAN_MSRx) MMI (CAN_MSRx) (CAN_MDLx CAN_MDHx) MTCR (CAN_MCRx)
Message 1
Message 2
Message 3
Message 4
Message 1
Message 2
Message 3
Message 4
Chaining Mailboxes
Several mailboxes may be used to receive a buffer split into several messages with the same ID. In this case, the mailbox with the lowest number is serviced first. In the receive and receive with overwrite modes, the field PRIOR in the CAN_MMRx register has no effect. If Mailbox 0 and Mailbox 5 accept messages with the same ID, the first message is received by Mailbox 0 and the second message is received by Mailbox 5. Mailbox 0 must be configured in Receive Mode (i.e., the first message received is considered) and Mailbox 5 must be configured in Receive with Overwrite Mode. Mailbox 0 cannot be configured in Receive with Overwrite Mode; otherwise, all messages are accepted by this mailbox and Mailbox 5 is never serviced. If several mailboxes are chained to receive a buffer split into several messages, all mailboxes except the last one (with the highest number) must be configured in Receive Mode. The first message received is handled by the first mailbox, the second one is refused by the first mailbox and accepted by the second mailbox, the last message is accepted by the last mailbox and refused by previous ones (see Figure 46-13).
1360
Figure 46-13. Chaining Three Mailboxes to Receive a Buffer Split into Three Messages
Buffer split in 3 messages
CAN BUS MRDY (CAN_MSRx) MMI (CAN_MSRx) MRDY (CAN_MSRy) MMI (CAN_MSRy) MRDY (CAN_MSRz) MMI (CAN_MSRz)
Message s1
Message s2
Message s3
Reading CAN_MSRx, CAN_MSRy and CAN_MSRz Reading CAN_MDH & CAN_MDL for mailboxes x, y and z Writing MBx MBy MBz in CAN_TCR
If the number of mailboxes is not sufficient (the MMI flag of the last mailbox raises), the user must read each data received on the last mailbox in order to retrieve all the messages of the buffer split (see Figure 46-14).
Figure 46-14. Chaining Three Mailboxes to Receive a Buffer Split into Four Messages
Buffer split in 4 messages
CAN BUS MRDY (CAN_MSRx) MMI (CAN_MSRx) MRDY (CAN_MSRy) MMI (CAN_MSRy) MRDY (CAN_MSRz) MMI (CAN_MSRz)
Message s1
Message s2
Message s3
Message s4
Reading CAN_MSRx, CAN_MSRy and CAN_MSRz Reading CAN_MDH & CAN_MDL for mailboxes x, y and z Writing MBx MBy MBz in CAN_TCR
1361
46.8.3.2 Transmission Handling A mailbox is in Transmit Mode once the MOT field in the CAN_MMRx register has been configured. Message ID and Message Acceptance mask must be set before Receive Mode is enabled. After Transmit Mode is enabled, the MRDY flag in the CAN_MSR register is automatically set until the first command is sent. When the MRDY flag is set, the software application can prepare a message to be sent by writing to the CAN_MDx registers. The message is sent once the software asks for a transfer command setting the MTCR bit and the message data length in the CAN_MCRx register. The MRDY flag remains at zero as long as the message has not been sent or aborted. It is important to note that no access to the mailbox data register is allowed while the MRDY flag is cleared. An interrupt is pending for the mailbox while the MRDY flag is set. This interrupt can be masked depending on the mailbox flag in the CAN_IMR global register. It is also possible to send a remote frame setting the MRTR bit instead of setting the MDLC field. The answer to the remote frame is handled by another reception mailbox. In this case, the device acts as a consumer but with the help of two mailboxes. It is possible to handle the remote frame emission and the answer reception using only one mailbox configured in Consumer Mode. Refer to the section Remote Frame Handling on page 1363. Several messages can try to win the bus arbitration in the same time. The message with the highest priority is sent first. Several transfer request commands can be generated at the same time by setting MBx bits in the CAN_TCR register. The priority is set in the PRIOR field of the CAN_MMRx register. Priority 0 is the highest priority, priority 15 is the lowest priority. Thus it is possible to use a part of the message ID to set the PRIOR field. If two mailboxes have the same priority, the message of the mailbox with the lowest number is sent first. Thus if mailbox 0 and mailbox 5 have the same priority and have a message to send at the same time, then the message of the mailbox 0 is sent first. Setting the MACR bit in the CAN_MCRx register aborts the transmission. Transmission for several mailboxes can be aborted by writing MBx fields in the CAN_MACR register. If the message is being sent when the abort command is set, then the application is notified by the MRDY bit set and not the MABT in the CAN_MSRx register. Otherwise, if the message has not been sent, then the MRDY and the MABT are set in the CAN_MSR register. When the bus arbitration is lost by a mailbox message, the CAN controller tries to win the next bus arbitration with the same message if this one still has the highest priority. Messages to be sent are re-tried automatically until they win the bus arbitration. This feature can be disabled by setting the bit DRPT in the CAN_MR register. In this case if the message was not sent the first time it was transmitted to the CAN transceiver, it is automatically aborted. The MABT flag is set in the CAN_MSRx register until the next transfer command. Figure 46-15 shows three MBx message attempts being made (MRDY of MBx set to 0). The first MBx message is sent, the second is aborted and the last one is trying to be aborted but too late because it has already been transmitted to the CAN transceiver.
Figure 46-15. Transmitting Messages
CAN BUS MRDY (CAN_MSRx) MABT (CAN_MSRx) MTCR (CAN_MCRx) MACR (CAN_MCRx) Reading CAN_MSRx Writing CAN_MDHx & CAN_MDLx Abort MBx message Try to Abort MBx message MBx message MBx message
1362
46.8.3.3 Remote Frame Handling Producer/consumer model is an efficient means of handling broadcasted messages. The push model allows a producer to broadcast messages; the pull model allows a customer to ask for messages.
Figure 46-16. Producer / Consumer Model
Producer
Request
PUSH MODEL
CAN Data Frame
Consumer
Indication(s)
PULL MODEL
Producer
Indications CAN Remote Frame
Consumer
Request(s)
Response
In Pull Mode, a consumer transmits a remote frame to the producer. When the producer receives a remote frame, it sends the answer accepted by one or many consumers. Using transmit and receive mailboxes, a consumer must dedicate two mailboxes, one in Transmit Mode to send remote frames, and at least one in Receive Mode to capture the producers answer. The same structure is applicable to a producer: one reception mailbox is required to get the remote frame and one transmit mailbox to answer. Mailboxes can be configured in Producer or Consumer Mode. A lonely mailbox can handle the remote frame and the answer. With 8 mailboxes, the CAN controller can handle 8 independent producers/consumers.
Producer Configuration
A mailbox is in Producer Mode once the MOT field in the CAN_MMRx register has been configured. Message ID and Message Acceptance masks must be set before Receive Mode is enabled. After Producer Mode is enabled, the MRDY flag in the CAN_MSR register is automatically set until the first transfer command. The software application prepares data to be sent by writing to the CAN_MDHx and the CAN_MDLx registers, then by setting the MTCR bit in the CAN_MCRx register. Data is sent after the reception of a remote frame as soon as it wins the bus arbitration. The MRDY flag remains at zero as long as the message has not been sent or aborted. No access to the mailbox data register can be done while MRDY flag is cleared. An interrupt is pending for the mailbox while the MRDY flag is set. This interrupt can be masked according to the mailbox flag in the CAN_IMR global register. If a remote frame is received while no data are ready to be sent (signal MRDY set in the CAN_MSRx register), then the MMI signal is set in the CAN_MSRx register. This bit is cleared by reading the CAN_MSRx register. The MRTR field in the CAN_MSRx register has no meaning. This field is used only when using Receive and Receive with Overwrite modes. After a remote frame has been received, the mailbox functions like a transmit mailbox. The message with the highest priority is sent first. The transmitted message may be aborted by setting the MACR bit in the CAN_MCR register. Please refer to the section Transmission Handling on page 1362.
1363
(CAN_MDLx CAN_MDHx)
Message 1
Message 2
Consumer Configuration
A mailbox is in Consumer Mode once the MOT field in the CAN_MMRx register has been configured. Message ID and Message Acceptance masks must be set before Receive Mode is enabled. After Consumer Mode is enabled, the MRDY flag in the CAN_MSR register is automatically cleared until the first transfer request command. The software application sends a remote frame by setting the MTCR bit in the CAN_MCRx register or the MBx bit in the global CAN_TCR register. The application is notified of the answer by the MRDY flag set in the CAN_MSRx register. The application can read the data contents in the CAN_MDHx and CAN_MDLx registers. An interrupt is pending for the mailbox while the MRDY flag is set. This interrupt can be masked according to the mailbox flag in the CAN_IMR global register. The MRTR bit in the CAN_MCRx register has no effect. This field is used only when using Transmit Mode. After a remote frame has been sent, the consumer mailbox functions as a reception mailbox. The first message received is stored in the mailbox data registers. If other messages intended for this mailbox have been sent while the MRDY flag is set in the CAN_MSRx register, they will be lost. The application is notified by reading the MMI field in the CAN_MSRx register. The read operation automatically clears the MMI flag. If several messages are answered by the Producer, the CAN controller may have one mailbox in consumer configuration, zero or several mailboxes in Receive Mode and one mailbox in Receive with Overwrite Mode. In this case, the consumer mailbox must have a lower number than the Receive with Overwrite mailbox. The transfer command can be triggered for all mailboxes at the same time by setting several MBx fields in the CAN_TCR register.
Figure 46-18. Consumer Handling
CAN BUS MRDY (CAN_MSRx) MMI (CAN_MSRx) MTCR (CAN_MCRx) Remote Frame Message x Remote Frame Message y
(CAN_MDLx CAN_MDHx)
Message x
Message y
1364
Timestamping Mode: The value of the internal timer is captured at each Start Of Frame or each End Of Frame. Time Triggered Mode: The mailbox transfer operation is triggered when the internal timer reaches the mailbox trigger.
Timestamping Mode is enabled by clearing the TTM bit in the CAN_MR register. Time Triggered Mode is enabled by setting the TTM bit in the CAN_MR register. 46.8.4.1 Timestamping Mode Each mailbox has its own timestamp value. Each time a message is sent or received by a mailbox, the 16-bit value MTIMESTAMP of the CAN_TIMESTP register is transferred to the LSB bits of the CAN_MSRx register. The value read in the CAN_MSRx register corresponds to the internal timer value at the Start Of Frame or the End Of Frame of the message handled by the mailbox.
Figure 46-19. Mailbox Timestamp
Start of Frame End of Frame
Message 1
Message 2
TEOF (CAN_MR) TIMESTAMP (CAN_TSTP) MTIMESTAMP (CAN_MSRx) MTIMESTAMP (CAN_MSRy) Timestamp 1 Timestamp 2
Timestamp 1 Timestamp 2
46.8.4.2 Time Triggered Mode In Time Triggered Mode, basic cycles can be split into several time windows. A basic cycle starts with a reference message. Each time a window is defined from the reference message, a transmit operation should occur within a predefined time window. A mailbox must not win the arbitration in a previous time window, and it must not be retried if the arbitration is lost in the time window.
Figure 46-20. Time Triggered Principle
Time Cycle Reference Message Reference Message
Time Trigger Mode is enabled by setting the TTM field in the CAN_MR register. In Time Triggered Mode, as in Timestamp Mode, the CAN_TIMESTP field captures the values of the internal counter, but the MTIMESTAMP fields in the CAN_MSRx registers are not active and are read at 0.
1365
1366
CAN BUS
Reference Message
CAN_TIM Cleared by software MRDY (CAN_MSRlast_mailbox_number) Timer Event x MRDY (CAN_MSRx) MTIMEMARKy == CAN_TIM MTIMEMARKx == CAN_TIM
End of Frame
Reference Message
Cleared by software MRDY (CAN_MSRlast_mailbox_number) Timer Event x MRDY (CAN_MSRx) Time Window Basic Cycle MTIMEMARKx == CAN_TIM
1367
1368
46.9
Table 46-6. Register Mapping Offset 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028 0x002C - 0x00E0 0x00E4 0x00E8 0x00EC - 0x01FC 0x0200 + MB * 0x20 + 0x00 0x0200 + MB * 0x20 + 0x04 0x0200 + MB * 0x20 + 0x08 0x0200 + MB * 0x20 + 0x0C 0x0200 + MB * 0x20 + 0x10 0x0200 + MB * 0x20 + 0x14 0x0200 + MB * 0x20 + 0x18 0x0200 + MB * 0x20 + 0x1C Register Mode Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Status Register Baudrate Register Timer Register Timestamp Register Error Counter Register Transfer Command Register Abort Command Register Reserved Write Protect Mode Register Write Protect Status Register Reserved Mailbox Mode Register
(1)
Name CAN_MR CAN_IER CAN_IDR CAN_IMR CAN_SR CAN_BR CAN_TIM CAN_TIMESTP CAN_ECR CAN_TCR CAN_ACR CAN_WPMR CAN_WPSR CAN_MMR CAN_MAM CAN_MID CAN_MFID CAN_MSR CAN_MDL CAN_MDH CAN_MCR
Access Read-write Write-only Write-only Read-only Read-only Read-write Read-only Read-only Read-only Write-only Write-only Read-write Read-only Read-write Read-write Read-write Read-only Read-only Read-write Read-write Write-only
Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 -
Mailbox Acceptance Mask Register Mailbox ID Register Mailbox Family ID Register Mailbox Status Register Mailbox Data Low Register Mailbox Data High Register Mailbox Control Register
Note:
1369
This register can only be written if the WPEN bit is cleared in CAN Write Protection Mode Register.
CANEN: CAN Controller Enable 0: The CAN Controller is disabled. 1: The CAN Controller is enabled. LPM: Disable/Enable Low-power Mode 0: Disable low-power Mode 1: Enable low-power Mode CAN controller enters low-power Mode once all pending messages have been transmitted. ABM: Disable/Enable Autobaud/Listen mode 0: Disable Autobaud/listen mode 1: Enable Autobaud/listen mode OVL: Disable/Enable Overload Frame 0: No overload frame is generated. 1: An overload frame is generated after each successful reception for mailboxes configured in Receive with/without overwrite Mode, Producer and Consumer. TEOF: Timestamp Messages at each End of Frame 0: The value of CAN_TIM is captured in the CAN_TIMESTP register at each Start Of Frame. 1: The value of CAN_TIM is captured in the CAN_TIMESTP register at each End Of Frame. TTM: Disable/Enable Time Triggered Mode 0: Time Triggered Mode is disabled 1: Time Triggered Mode is enabled TIMFRZ: Enable Timer Freeze 0: The internal timer continues to be incremented after it reached 0xFFFF. 1: The internal timer stops incrementing after reaching 0xFFFF. It is restarted after a timer reset. See Freezing the Internal Timer Counter on page 1366. DRPT: Disable Repeat 0: When a transmit mailbox loses the bus arbitration, the transfer request remains pending. 1: When a transmit mailbox lose the bus arbitration, the transfer request is automatically aborted. It automatically raises the MABT and MRDT flags in the corresponding CAN_MSRx. SAMA5D3 Series [DATASHEET]
11121BATARM08-Mar-13
1370
1371
1372
1373
1374
1375
1376
1377
TSTP Timestamp
0: No bus activity has been detected. 1: A start of frame or an end of frame has been detected (according to the TEOF field in the CAN_MR register). This flag is automatically cleared by reading the CAN_SR register.
1378
A form error results from violations on one or more of the fixed form of the following bit fields:
CRC delimiter ACK delimiter End of frame Error delimiter Overload delimiter
This flag is automatically cleared by reading CAN_SR register.
1379
This register can only be written if the WPEN bit is cleared in CAN Write Protection Mode Register. Any modification on one of the fields of the CAN_BR register must be done while CAN module is disabled. To compute the different Bit Timings, please refer to the Section 46.7.4.1 CAN Bit Timing Configuration on page 1349.
t PHS2 = t CSC ( PHASE2 + 1 ) Warning: PHASE2 value must be different from 0. PHASE1: Phase 1 segment
This phase is used to compensate for edge phase error.
1380
TIMER: Timer
This field represents the internal CAN controller 16-bit timer value.
1381
MTIMESTAMP: Timestamp
This field carries the value of the internal CAN controller 16-bit timer value at the start or end of frame. If the TEOF bit is cleared in the CAN_MR register, the internal Timer Counter value is captured in the MTIMESTAMP field at each start of frame else the value is captured at each end of frame. When the value is captured, the TSTP flag is set in the CAN_SR register. If the TSTP mask in the CAN_IMR register is set, an interrupt is generated while TSTP flag is set in the CAN_SR register. This flag is cleared by reading the CAN_SR register. Note: The CAN_TIMESTP register is reset when the CAN is disabled then enabled thanks to the CANEN bit in the CAN_MR.
1382
the transmitter is error passive and detects an ACKNOWLEDGMENT ERROR because of not detecting a dominant ACK and does not detect a dominant bit while sending its PASSIVE ERROR FLAG. the transmitter sends an ERROR FLAG because a STUFF ERROR occurred during arbitration and should have been recessive and has been sent as recessive but monitored as dominant.
When a transmitter detects a BIT ERROR while sending an ACTIVE ERROR FLAG or an OVERLOAD FLAG, the TEC will be increased by 8. Any node tolerates up to 7 consecutive dominant bits after sending an ACTIVE ERROR FLAG, PASSIVE ERROR FLAG or OVERLOAD FLAG. After detecting the 14th consecutive dominant bit (in case of an ACTIVE ERROR FLAG or an OVERLOAD FLAG) or after detecting the 8th consecutive dominant bit following a PASSIVE ERROR FLAG, and after each sequence of additional eight consecutive dominant bits every transmitter increases its TEC by 8. After a successful transmission the TEC is decreased by 1 unless it was already 0.
1383
This flag clears the MRDY and MABT flags in the corresponding CAN_MSRx register. When several mailboxes are requested to be transmitted simultaneously, they are transmitted in turn, starting with the mailbox with the highest priority. If several mailboxes have the same priority, then the mailbox with the lowest number is sent first (i.e., MB0 will be transferred before MB1).
1384
It is possible to set MACR field (in the CAN_MCRx register) for each mailbox.
1385
WPKEY
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
1386
23
22
21
20
19
18
17
16
15
14
13
12
11
10
WPVSRC
7 6 5 4 3 2 1 0
WPVS
1387
Read-write
30 22 14 6 29 21 13 5 28 20 12 MTIMEMARK 4 MTIMEMARK 3 2 1 0 27 19 11 26 18 PRIOR 10 9 8 25 MOT 17 24 16
This register can only be written if the WPEN bit is cleared in CAN Write Protection Mode Register.
5 6
MB_PRODUCER
1388
Read-write
30 22 14 6 29 MIDE 21 MIDvA 13 5 12 MIDvB 4 MIDvB 3 2 1 0 11 10 9 28 20 27 19 26 MIDvA 18 25 17 MIDvB 8 24 16
This register can only be written if the WPEN bit is cleared in CAN Write Protection Mode Register. To prevent concurrent access with the internal CAN core, the application must disable the mailbox before writing to CAN_MAMx registers.
1389
Read-write
30 22 14 6 29 MIDE 21 MIDvA 13 5 12 MIDvB 4 MIDvB 3 2 1 0 11 10 9 28 20 27 19 26 MIDvA 18 25 17 MIDvB 8 24 16
This register can only be written if the WPEN bit is cleared in CAN Write Protection Mode Register. To prevent concurrent access with the internal CAN core, the application must disable the mailbox before writing to CAN_MIDx registers.
1390
Read-only
30 22 14 6 29 21 13 5 28 20 MFID 12 MFID 4 MFID 3 2 1 0 11 10 9 8 27 19 26 MFID 18 25 17 24 16
MFID: Family ID
This field contains the concatenation of CAN_MIDx register bits masked by the CAN_MAMx register. This field is useful to speed up message ID decoding. The message acceptance procedure is described below. As an example: CAN_MIDx = 0x305A4321 CAN_MAMx = 0x3FF0F0FF CAN_MFIDx = 0x000000A3
1391
Read-only
30 22 MABT 14 6 29 21 13 5 28 27 20 19 MRTR 12 11 MTIMESTAMP 4 3 MTIMESTAMP 26 18 MDLC 10 2 9 1 8 0 25 17 24 MMI 16
These register fields are updated each time a message transfer is received or aborted. MMI is cleared by reading the CAN_MSRx register. MRDY, MABT are cleared by writing MTCR or MACR in the CAN_MCRx register. Warning: MRTR and MDLC state depends partly on the mailbox object type.
1392
Consumer
1393
1394
Read-write
30 29 28 MDL 27 26 25 24
23
22
21
20 MDL
19
18
17
16
15
14
13
12 MDL
11
10
4 MDL
1395
Read-write
30 29 28 MDH 27 26 25 24
23
22
21
20 MDH
19
18
17
16
15
14
13
12 MDH
11
10
4 MDH
1396
Write-only
30 22 MACR 14 6 29 21 13 5 28 20 MRTR 12 4 27 19 26 18 MDLC 11 3 10 2 9 1 8 0 25 17 24 16
Consumer situations can be handled automatically by setting the mailbox object type in Consumer. This requires only one mailbox. It can also be handled using two mailboxes, one in reception, the other in transmission. The MRTR and the MTCR bits must be set in the same time.
1397
It is possible to set MACR field for several mailboxes in the same time, setting several bits to the CAN_ACR register.
This flag clears the MRDY and MABT flags in the CAN_MSRx register. When several mailboxes are requested to be transmitted simultaneously, they are transmitted in turn. The mailbox with the highest priority is serviced first. If several mailboxes have the same priority, the mailbox with the lowest number is serviced first (i.e., MBx0 will be serviced before MBx 15 if they have the same priority). It is possible to set MTCR for several mailboxes at the same time by writing to the CAN_TCR register.
1398
47.
47.1
Each channel is bidirectional. The data channel is used to transfer digitized signal samples at a constant rate of 16 bits at 16 kHz. The control channel is used to communicate with control registers of the HLSD at a maximum rate of 8 bits at 16 kHz. The SMD performs all protocol-related data conversion for transmission and received data interpretation in both data and control channels of the link. The SMD incorporates both RX and TX FIFOs, available through the DMAC interface. Each FIFO is able to hold eight 32bit words (equivalent to 16 modem data samples).
47.2
Embedded Characteristics
z
z z z z z
Modulations and protocols z V.90 z V.34 z V.32bis, V.32, V.22bis, V.22, V.23, V.21 z V.23 reverse, V.23 half-duplex z Bell 212A/Bell 103 z V.29 FastPOS z V.22bis fast connect z V.80 Synchronous Access Mode Data compression and error correction z V.44 data compression (V.92 model) z V.42bis and MNP 5 data compression z V.42 LAPM and MNP 2-4 error correction z EIA/TIA 578 Class 1 and T.31 Class 1.0 Call Waiting (CW) detection and Type II Caller ID decoding during data mode Type I Caller ID (CID) decoding Sixty-three embedded and upgradable country profiles Embedded AT commands SmartDAA z Extension pick-up detection z Digital line protection z Line reversal detection z Line-in-use detection z Remote hang-up detection z Worldwide compliance
1399
47.3
Block Diagram
Figure 47-1. Software Modem Device Block Diagram
SMD Controller SMD Core
Byte Parallel Interface CPU Interrupt Control Channel Logic Control/Status Registers Ring Detection and Pulse Dialing Machines (masters)
AHB
AHB Wrapper
DIB Pads
X X
1400
48.
48.1
Note:
1.
When Slow Clock is selected for Master Clock (CSS = 0 in PMC Master Clock Register), TIMER_CLOCK5 input is equivalent to Master Clock.
1401
48.2
Embedded Characteristics
z z
Provides six 32-bit Timer Counter channels Wide range of functions including:
z z z z z z z z z
Frequency measurement Event counting Interval measurement Pulse generation Delay timing Pulse Width Modulation Up/down capabilities Quadrature decoder logic 2-bit gray up/down count for stepper motor Three external clock inputs Five Internal clock inputs Two multi-purpose input/output signals acting as trigger event
z z z z
Internal interrupt signal Two global registers that act on all TC channels Read of the Capture registers by the DMAC Configuration registers can be write protected
1402
48.3
Block Diagram
TIMER_CLOCK1
TIMER_CLOCK2 TIMER_CLOCK3
TIOA2 TCLK1
Timer/Counter Channel 0
TIOA
TIOA0
TIOB
TIMER_CLOCK4 TIMER_CLOCK5
TCLK2
TIOB0
SYNC
INT0
Timer/Counter Channel 1
TIOA
TIOA1
TIOB
TIOB1 INT1
TIOA1 TIOB1
Timer/Counter Channel 2
TIOA
TIOA2
TIOB
TIOB2
SYNC
TIOA2 TIOB2
INT2
Table 48-2. Signal Name Description Block/Channel Signal Name XC0, XC1, XC2 TIOA Channel Signal TIOB INT SYNC Description External Clock Inputs Capture Mode: Timer Counter Input Waveform Mode: Timer Counter Output Capture Mode: Timer Counter Input Waveform Mode: Timer Counter Input/Output Interrupt Signal Output (internal signal) Synchronization Input Signal (from configuration register)
1403
48.4
Table 48-3. TC Pin List Pin Name TCLK0-TCLK2 TIOA0-TIOA2 TIOB0-TIOB2 Description External Clock Input I/O Line A I/O Line B Type Input I/O I/O
48.5
Product Dependencies
48.5.3 Interrupt
The TC has an interrupt line connected to the Interrupt Controller (IC). Handling the TC interrupt requires programming the IC before configuring the TC.
1404
48.6
Functional Description
48.6.1 TC Description
The 6 channels of the Timer Counter are independent and identical in operation except when quadrature decoder is enabled. The registers for channel programming are listed in Table 48-5 on page 1424.
Internal clock signals: TIMER_CLOCK1, TIMER_CLOCK2, TIMER_CLOCK3, TIMER_CLOCK4, TIMER_CLOCK5 External clock signals: XC0, XC1 or XC2
This selection is made by the TCCLKS bits in the TC Channel Mode Register. The selected clock can be inverted with the CLKI bit in TC_CMR. This allows counting on the opposite edges of the clock. The burst function allows the clock to be validated when an external signal is high. The BURST parameter in the Mode Register defines this signal (none, XC0, XC1, XC2). See Figure 48-3 Clock Selection Note: In all cases, if an external clock is used, the duration of each of its levels must be longer than the master clock period. The external clock frequency must be at least 2.5 times lower than the master clock
1405
TCLK0
SYNC
TC1XC1S Timer/Counter Channel 1 TCLK1 TIOA0 TIOA2 XC0 = TCLK0 XC1 XC2 = TCLK2 TIOB1 TIOA1
SYNC
TC2XC2S
SYNC
Selected Clock
1406
CLKSTA
CLKEN
CLKDIS
Q Q S R
S R
Counter Clock
Stop Event
Disable Event
Capture Mode provides measurement on signals. Waveform Mode provides wave generation.
The TC Operating Mode is programmed with the WAVE bit in the TC Channel Mode Register. In Capture Mode, TIOA and TIOB are configured as inputs. In Waveform Mode, TIOA is always configured to be an output and TIOB is an output if it is not selected to be the external trigger.
48.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.
1407
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 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 ENETRG in TC_CMR. If an external trigger is used, the duration of the pulses must be longer than the master clock period in order to be detected.
1408
Internal PDC trigger Transfer to System Memory RA T1 T1,T2,T3,T4 = System Bus load dependent (Tmin = 8 MCK)
48.6.10 Trigger Conditions
In addition to the SYNC signal, the software trigger and the RC compare trigger, an external trigger can be defined. The ABETRG bit in the TC_CMR register selects TIOA or TIOB input signal as an external trigger. The ETRGEDG parameter defines the edge (rising, falling or both) detected to generate an external trigger. If ETRGEDG = 0 (none), the external trigger is disabled.
RA T2
RA T3
RA T4
1409
TCCLKS
TIMER_CLOCK1
TIMER_CLOCK2
CLKI
CLKSTA
CLKEN
CLKDIS
TIMER_CLOCK3
TIMER_CLOCK4
Q Q R S R
TIMER_CLOCK5
XC0
XC1 LDBSTOP
XC2
MCK
BURST
LDBDIS
Register C
1 Counter CLK OVF RESET Trig ABETRG ETRGEDG Edge Detector LDRA LDRB CPCTRG
Capture Register A
Capture Register B
Compare RC =
SWTRG
SYNC
MTIOB
TIOB
CPCS
LOVRS
LDRAS
LDRBS
ETRGS
COVFS
TC1_SR
Edge Detector
TC1_IMR
TIOA
11121BATARM08-Mar-13
INT
1410
1411
CLKEN
CLKDIS
TIMER_CLOCK1 CLKI
TIMER_CLOCK2
TIMER_CLOCK3
TIMER_CLOCK4 CPCDIS
Q Q R
CPCSTOP
MCK
S R
ACPA MTIOA
TIMER_CLOCK5
XC0
XC1
1
Counter
CLK RESET OVF
SWTRG
BCPC Trig BCPB WAVSEL EEVT BEEVT EEVTEDG ENETRG Edge Detector CPCS CPAS CPBS ETRGS COVFS TC1_SR MTIOB
SYNC
Output Controller
XC2
AEEVT
TIOA
TIOB TC1_IMR
BSWTRG
Timer/Counter Channel
11121BATARM08-Mar-13
INT
Output Controller
TIOB
1412
48.6.12.1 WAVSEL = 00 When WAVSEL = 00, the value of TC_CV is incremented from 0 to 0xFFFF. Once 0xFFFF has been reached, the value of TC_CV is reset. Incrementation of TC_CV starts again and the cycle continues. See Figure 48-8. 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 48-9. 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).
Figure 48-8. WAVSEL= 00 without trigger
Counter Value 0xFFFF Counter cleared by compare match with 0xFFFF
RC RB
RA
Time
TIOA
RC RB
RA
Time
TIOA
1413
48.6.12.2 WAVSEL = 10 When WAVSEL = 10, the value of TC_CV is incremented from 0 to the value of RC, then automatically reset on a RC Compare. Once the value of TC_CV has been reset, it is then incremented and so on. See Figure 48-10. It is important to note that TC_CV can be reset at any time by an external event or a software trigger if both are programmed correctly. See Figure 48-11. In addition, RC Compare can stop the counter clock (CPCSTOP = 1 in TC_CMR) and/or disable the counter clock (CPCDIS = 1 in TC_CMR).
Figure 48-10. WAVSEL = 10 Without Trigger
Counter Value 0xFFFF Counter cleared by compare match with RC RC RB
RA
Time
TIOA
RA
Time
TIOA
1414
48.6.12.3 WAVSEL = 01 When WAVSEL = 01, the value of TC_CV is incremented from 0 to 0xFFFF. Once 0xFFFF is reached, the value of TC_CV is decremented to 0, then re-incremented to 0xFFFF and so on. See Figure 48-12. A trigger such as an external event or a software trigger can modify TC_CV at any time. If a trigger occurs while TC_CV is incrementing, TC_CV then decrements. If a trigger is received while TC_CV is decrementing, TC_CV then increments. See Figure 48-13. RC Compare cannot be programmed to generate a trigger in this configuration. At the same time, RC Compare can stop the counter clock (CPCSTOP = 1) and/or disable the counter clock (CPCDIS = 1).
Figure 48-12. WAVSEL = 01 Without Trigger
Counter Value 0xFFFF Counter decremented by compare match with 0xFFFF
RC RB
RA
Time
TIOA
RA
Time
TIOA
1415
48.6.12.4 WAVSEL = 11 When WAVSEL = 11, the value of TC_CV is incremented from 0 to RC. Once RC is reached, the value of TC_CV is decremented to 0, then re-incremented to RC and so on. See Figure 48-14. A trigger such as an external event or a software trigger can modify TC_CV at any time. If a trigger occurs while TC_CV is incrementing, TC_CV then decrements. If a trigger is received while TC_CV is decrementing, TC_CV then increments. See Figure 48-15. RC Compare can stop the counter clock (CPCSTOP = 1) and/or disable the counter clock (CPCDIS = 1).
Figure 48-14. WAVSEL = 11 Without Trigger
Counter Value 0xFFFF Counter decremented by compare match with RC RC RB
RA
Time
TIOA
RA
Time
TIOA
1416
1417
Figure 48-16. Predefined Connection of the Quadrature Decoder with Timer Counters
Reset pulse Quadrature Decoder (Filter + Edge Detect + QD) PHEdges TIOB0 PHA QDEN SPEEDEN 1 1 TIOA TIOA0 QDEN 1 TIOB 1 XC0 XC0 Speed/Position Timer/Counter Channel 0
TIOA0
TIOB0
PHB Index
TIOB1
IDX
1 TIOB1
TIOB 1 XC0
XC0
Timer/Counter Channel 1
1418
48.6.15.2 Input Pre-processing Input pre-processing consists of capabilities to take into account rotary sensor factors such as polarities and phase definition followed by configurable digital filtering. Each input can be negated and swapping PHA, PHB is also configurable. By means of the MAXFILT field in TC_BMR, it is possible to configure a minimum duration for which the pulse is stated as valid. When the filter is active, pulses with a duration lower than MAXFILT+1 * tMCK ns are not passed to downstream logic. Filters can be disabled using the FILTER field in the TC_BMR register.
Figure 48-17. Input Stage
Input Pre-Processing
SWAP 1 TIOA0 INVA 1 TIOB0 INVB 1 1 TIOB1 IDXPHB INVIDX IDX PHB PHA
MAXFILT
FILTER
Filter
PHedge
Filter
IDX
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.
1419
MCK
MAXFILT=2
Filter Out
PHB motor shaft stopped in such a position that rotary sensor cell is aligned with an edge of the disk rotation stop PHA PHB Edge area due to system vibration PHB stop mechanical shock on system
PHB
1420
48.6.15.3 Direction Status and Change Detection After filtering, the quadrature signals are analyzed to extract the rotation direction and edges of the 2 quadrature signals detected in order to be counted by timer/counter logic downstream. The direction status can be directly read at anytime on TC_QISR register. The polarity of the direction flag status depends on the configuration written in TC_BMR register. INVA, INVB, INVIDX, SWAP modify the polarity of DIR flag. Any change in rotation direction is reported on TC_QISR register and can generate an interrupt. The direction change condition is reported as soon as 2 consecutive edges on a phase signal have sampled the same value on the other phase signal and there is an edge on the other signal. The 2 consecutive edges of 1 phase signal sampling the same value on other phase signal is not sufficient to declare a direction change, for the reason that particulate contamination may mask one or more reflective bar on the optical or magnetic disk of the sensor. (Refer to Figure 48-19 Rotation Change Detection for waveforms.)
Figure 48-19. Rotation Change Detection
PHA
PHB
DIR
DIRCHG
No direction change due to particulate contamination masking a reflective bar missing pulse PHA same phase PHB DIR spurious change condition (if detected in a simple way) DIRCHG
The direction change detection is disabled when QDTRANS is set to 1 in TC_BMR. In this case the DIR flag report must not be used. A quadrature error is also reported by the quadrature decoder logic. Rather than reporting an error only when 2 edges occur at the same time on PHA and PHB, which is unlikely to occur in real life, there is a report if the time difference between 2 edges on PHA, PHB is lower than a predefined value. This predefined value is configurable and corresponds
1421
to (MAXFILT+1) * tMCK ns. After being filtered there is no reason to have 2 edges closer than (MAXFILT+1) * tMCK ns under normal mode of operation. In the instance an anomaly occurs, a quadrature error is reported on QERR flag on TC_QISR register.
Figure 48-20. Quadrature Error Detection
MCK
MAXFILT = 2
PHB resulting PHA, PHB electrical waveforms PHA Even with an abnorrmaly formatted disk, there is no occurence of PHA, PHB switching at the same time. PHB duration < MAXFILT QERR
MAXFILT must be tuned according to several factors such as the system clock frequency (MCK), type of rotary sensor and rotation speed to be achieved. 48.6.15.4 Position and Rotation Measurement When POSEN is set in TC_BMR register, position is processed on channel 0 (by means of the PHA,PHB edge detections) and motor revolutions are accumulated in channel 1 timer/counter and can be read through TC_CV0 and/or TC_CV1 register if the IDX signal is provided on TIOB1 input. Channel 0 and 1 must be configured in capture mode (WAVE = 0 in TC_CMR0). 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. Depending on the quadrature signals, the direction is decoded and allows to count up or down in timer/counter channels 0 and 1. The direction status is reported on TC_QISR register.
1422
48.6.15.5 Speed Measurement When SPEEDEN is set in TC_BMR register, the speed measure is enabled on channel 0. A time base must be defined on channel 2 by writing the TC_RC2 period register. Channel 2 must be configured in waveform mode (WAVE bit field set) in TC_CMR2 register. WAVSEL bit field must be defined with 0x10 to clear the counter by comparison and matching with TC_RC value. ACPC field must be defined at 0x11 to toggle TIOA output. This time base is automatically fed back to TIOA of channel 0 when QDEN and SPEEDEN are set. Channel 0 must be configured in capture mode (WAVE = 0 in TC_CMR0). ABETRG bit field of TC_CMR0 must be configured at 1 to get TIOA as a trigger for this channel. EDGTRG can be set to 0x01, to clear the counter on a rising edge of the TIOA signal and LDRA field must be set accordingly to 0x01, to load TC_RA0 at the same time as the counter is cleared (LDRB must be set to 0x01). As a consequence, at the end of each time base period the differentiation required for the speed calculation is performed. The process must be started by configuring the TC_CR register with CLKEN and SWTRG. The speed can be read on TC_RA0 register in TC_CMR0. Channel 1 can still be used to count the number of revolutions of the motor.
DOWNx
48.6.17 Write Protection System
In order to bring security to the Timer Counter, a write protection system has been implemented. The write protection mode prevent the write of TC_BMR, TC_CMRx, TC_SMMRx, TC_RAx, TC_RBx, TC_RCx registers. When this mode is enabled and one of the protected registers write, the register write request canceled. Due to the nature of the write protection feature, enabling and disabling the write protection mode requires the use of a security code. Thus when enabling or disabling the write protection mode the WPKEY field of the TC_WPMR register must be filled with the TIM ASCII code (corresponding to 0x54494D) otherwise the register write will be canceled.
1423
48.7
Table 48-5. Register Mapping Register Channel Control Register Channel Mode Register Stepper Motor Mode Register Register AB Counter Value Register A Register B Register C Status Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Block Control Register Block Mode Register QDEC Interrupt Enable Register QDEC Interrupt Disable Register QDEC Interrupt Mask Register QDEC Interrupt Status Register Reserved Write Protect Mode Register Reserved TC_WPMR Read-write 0 Name TC_CCR TC_CMR TC_SMMR TC_RAB TC_CV TC_RA TC_RB TC_RC TC_SR TC_IER TC_IDR TC_IMR TC_BCR TC_BMR TC_QIER TC_QIDR TC_QIMR TC_QISR Access Write-only Read-write Read-write Read-only Read-only Read-write Read-write
(2) (2)
Reset 0 0 0 0 0 0 0 0 0 0 0 0
0x00 + channel * 0x40 + 0x00 0x00 + channel * 0x40 + 0x04 0x00 + channel * 0x40 + 0x08 0x00 + channel * 0x40 + 0x0C 0x00 + channel * 0x40 + 0x10 0x00 + channel * 0x40 + 0x14 0x00 + channel * 0x40 + 0x18 0x00 + channel * 0x40 + 0x1C 0x00 + channel * 0x40 + 0x20 0x00 + channel * 0x40 + 0x24 0x00 + channel * 0x40 + 0x28 0x00 + channel * 0x40 + 0x2C 0xC0 0xC4 0xC8 0xCC 0xD0 0xD4 0xD8 0xE4 0xE8 - 0xFC
Read-write Read-only Write-only Write-only Read-only Write-only Read-write Write-only Write-only Read-only Read-only
1424
TC_CCRx [x=0..2] 0xF0010000 (0)[0], 0xF0010040 (0)[1], 0xF0010080 (0)[2], 0xF8014000 (1)[0], 0xF8014040 (1)[1], 0xF8014080 (1)[2] Write-only
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 SWTRG 25 17 9 1 CLKDIS 24 16 8 0 CLKEN
1425
TC_CMRx [x=0..2] (WAVE = 0) 0xF0010004 (0)[0], 0xF0010044 (0)[1], 0xF0010084 (0)[2], 0xF8014004 (1)[0], 0xF8014044 (1)[1], 0xF8014084 (1)[2] Read-write
30 22 14 CPCTRG 6 LDBSTOP 29 21 13 5 BURST 28 20 12 4 11 3 CLKI 27 19 LDRB 10 ABETRG 2 1 TCCLKS 9 ETRGEDG 0 26 18 25 17 LDRA 8 24 16
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450
1426
1427
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450
1428
Note:
1. If TIOB is chosen as the external event signal, it is configured as an input and no longer generates waveforms and subsequently no IRQs.
1429
1430
1431
TC_SMMRx [x=0..2] 0xF0010008 (0)[0], 0xF0010048 (0)[1], 0xF0010088 (0)[2], 0xF8014008 (1)[0], 0xF8014048 (1)[1], 0xF8014088 (1)[2] Read-write
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 10 2 9 1 DOWN 25 17 8 0 GCEN 24 16
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450
1432
48.7.5 TC Register AB
Name: Address: Access:
31
TC_RABx [x=0..2] 0xF001000C (0)[0], 0xF001004C (0)[1], 0xF001008C (0)[2], 0xF801400C (1)[0], 0xF801404C (1)[1], 0xF801408C (1)[2] Read-only
30 29 28 RAB 23 22 21 20 RAB 15 14 13 12 RAB 7 6 5 4 RAB 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
1433
TC_CVx [x=0..2] 0xF0010010 (0)[0], 0xF0010050 (0)[1], 0xF0010090 (0)[2], 0xF8014010 (1)[0], 0xF8014050 (1)[1], 0xF8014090 (1)[2] Read-only
30 29 28 CV 23 22 21 20 CV 15 14 13 12 CV 7 6 5 4 CV 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
1434
48.7.7 TC Register A
Name: Address: Access:
31
TC_RAx [x=0..2] 0xF0010014 (0)[0], 0xF0010054 (0)[1], 0xF0010094 (0)[2], 0xF8014014 (1)[0], 0xF8014054 (1)[1], 0xF8014094 (1)[2] Read-only if WAVE = 0, Read-write if WAVE = 1
30 29 28 RA 23 22 21 20 RA 15 14 13 12 RA 7 6 5 4 RA 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450
RA: Register A
RA contains the Register A value in real time.
1435
48.7.8 TC Register B
Name: Address: Access:
31
TC_RBx [x=0..2] 0xF0010018 (0)[0], 0xF0010058 (0)[1], 0xF0010098 (0)[2], 0xF8014018 (1)[0], 0xF8014058 (1)[1], 0xF8014098 (1)[2] Read-only if WAVE = 0, Read-write if WAVE = 1
30 29 28 RB 23 22 21 20 RB 15 14 13 12 RB 7 6 5 4 RB 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450
RB: Register B
RB contains the Register B value in real time.
1436
48.7.9 TC Register C
Name: Address: Access:
31
TC_RCx [x=0..2] 0xF001001C (0)[0], 0xF001005C (0)[1], 0xF001009C (0)[2], 0xF801401C (1)[0], 0xF801405C (1)[1], 0xF801409C (1)[2] Read-write
30 29 28 RC 23 22 21 20 RC 15 14 13 12 RC 7 6 5 4 RC 3 2 1 0 11 10 9 8 19 18 17 16 27 26 25 24
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450
RC: Register C
RC contains the Register C value in real time.
1437
TC_SRx [x=0..2] 0xF0010020 (0)[0], 0xF0010060 (0)[1], 0xF00100A0 (0)[2], 0xF8014020 (1)[0], 0xF8014060 (1)[1], 0xF80140A0 (1)[2] Read-only
30 22 14 6 LDRBS 29 21 13 5 LDRAS 28 20 12 4 CPCS 27 19 11 3 CPBS 26 18 MTIOB 10 2 CPAS 25 17 MTIOA 9 1 LOVRS 24 16 CLKSTA 8 0 COVFS
1438
1439
TC_IERx [x=0..2] 0xF0010024 (0)[0], 0xF0010064 (0)[1], 0xF00100A4 (0)[2], 0xF8014024 (1)[0], 0xF8014064 (1)[1], 0xF80140A4 (1)[2] Write-only
30 22 14 6 LDRBS 29 21 13 5 LDRAS 28 20 12 4 CPCS 27 19 11 3 CPBS 26 18 10 2 CPAS 25 17 9 1 LOVRS 24 16 8 0 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.
1440
TC_IDRx [x=0..2] 0xF0010028 (0)[0], 0xF0010068 (0)[1], 0xF00100A8 (0)[2], 0xF8014028 (1)[0], 0xF8014068 (1)[1], 0xF80140A8 (1)[2] Write-only
30 22 14 6 LDRBS 29 21 13 5 LDRAS 28 20 12 4 CPCS 27 19 11 3 CPBS 26 18 10 2 CPAS 25 17 9 1 LOVRS 24 16 8 0 COVFS
CPAS: RA Compare
0 = No effect. 1 = Disables the RA Compare Interrupt (if WAVE = 1).
CPBS: RB Compare
0 = No effect. 1 = Disables the RB Compare Interrupt (if WAVE = 1).
CPCS: RC Compare
0 = No effect. 1 = Disables the RC Compare Interrupt.
LDRAS: RA Loading
0 = No effect. 1 = Disables the RA Load Interrupt (if WAVE = 0).
LDRBS: RB Loading
0 = No effect. 1 = Disables the RB Load Interrupt (if WAVE = 0).
1441
Read-only
30 22 14 6 LDRBS 29 21 13 5 LDRAS 28 20 12 4 CPCS 27 19 11 3 CPBS 26 18 10 2 CPAS 25 17 9 1 LOVRS 24 16 8 0 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.
1442
1443
INVIDX 7
This register can only be written if the WPEN bit is cleared in TC Write Protect Mode Register on page 1450.
1444
FILTER:
0 = IDX,PHA, PHB input pins are not filtered. 1 = IDX,PHA, PHB input pins are filtered using MAXFILT value.
1445
IDX: InDeX
0 = No effect. 1 = Enables the interrupt when a rising edge occurs on IDX input.
1446
IDX: InDeX
0 = No effect. 1 = Disables the interrupt when a rising edge occurs on IDX input.
1447
IDX: InDeX
0 = The interrupt on IDX input is disabled. 1 = The interrupt on IDX input is enabled.
1448
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.
1449
23
22
21
20 WPKEY
19
18
17
16
15
14
13
12 WPKEY
11
10
0 WPEN
1450
49.
49.1
1451
49.2
Embedded Characteristics
z z
A Modulo n Counter Providing Eleven Clocks Two Independent Linear Dividers Working on Modulo n Counter Outputs Independent 16-bit Counter for Each Channel Independent Complementary Outputs with 12-bit Dead-Time Generator (Also Called Dead-Band or NonOverlapping Time) for Each Channel Independent Enable Disable Command for Each Channel Independent Clock Selection for Each Channel Independent Period, Duty-Cycle and Dead-Time for Each Channel Independent Double Buffering of Period, Duty-Cycle and Dead-Times for Each Channel Independent Programmable Selection of The Output Waveform Polarity for Each Channel Independent Programmable Center or Left Aligned Output Waveform for Each Channel Independent Output Override for Each Channel Independent Interrupt for Each Channel, at Each Period for Left-Aligned or Center-Aligned Configuration
Independent Channels
z z z z z z z z z z
z z
Two 2-bit Gray Up/Down Channels for Stepper Motor Control Synchronous Channel Mode
z z
Synchronous Channels Share the Same Counter Mode to Update the Synchronous Channels Registers after a Programmable Number of Periods Programmable delay for Events Lines to delay ADC measurements
z z
8 Comparison Units Intended to Generate Interrupts, Pulses on Event Lines 1 Programmable Fault/Break Inputs Providing an Asynchronous Protection of PWM Outputs
z z z
4 User Driven through PIO inputs PMC Driven when Crystal Oscillator Clock Fails ADC Controller Driven through Configurable Comparison Function
1452
49.3
Block Diagram
Period Comparator OCx SYNCx Duty-Cycle MUX Clock Selector Counter Channel x
PWMHx PWMLx
PIO
Channel 0 Update
PWMH0 PWML0
Counter Channel 0
event line 0 event line 1 Comparison Units PMC MCK CLOCK Generator Events Generator event line x APB Interface Interrupt Generator Interrupt Controller ADC
APB
49.4
1453
49.5
Product Dependencies
1454
Note:
1455
49.6
Functional Description
The PWM macrocell is primarily composed of a clock generator module and 4 channels.
z z z
Clocked by the master clock (MCK), the clock generator module provides 13 clocks. Each channel can independently choose one of the clock generator outputs. Each channel generates an output waveform with attributes that can be defined independently for each channel through the user interface registers.
Divider A
clkA
PREA
DIVA
PWM_MR
Divider B
clkB
PREB
DIVB
PWM_MR
The PWM master clock (MCK) 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 in three blocks:
z z
A modulo n counter which provides 11 clocks: FMCK, FMCK/2, FMCK/4, FMCK/8, FMCK/16, FMCK/32, FMCK/64, FMCK/128, FMCK/256, FMCK/512, FMCK/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. After a reset of the PWM controller, DIVA (DIVB) and PREA (PREB) are set to 0. This implies that after reset clkA (clkB) are turned off.
1456
At reset, all clocks provided by the modulo n counter are turned off except clock MCK. This situation is also true when the PWM master clock is turned off through the Power Management Controller. CAUTION: Before using the PWM macrocell, the programmer must first enable the PWM clock in the Power Management Controller (PMC).
Channel x
Period Comparator x Duty-Cycle MUX From Clock Generator Clock Selector Counter Channel x SYNCx OCx DTOHx Dead-Time Generator DTOLx PWMHx OOOHx Output Fault OOOLx PWMLx Override Protection MUX
Channel y (= x+1)
Comparator y PWMHy OOOHy DTOHy Dead-Time Output Fault Generator DTOLy Override OOOLy Protection PWMLy
A clock selector which selects one of the clocks provided by the clock generator (described in Section 49.6.1 on page 1456). A counter clocked by the output of the clock selector. This counter is incremented or decremented according to the channel configuration and comparators matches. The size of the counter is 16 bits. A comparator used to compute the OCx output waveform according to the counter value and the configuration. The counter value can be the one of the channel counter or the one of the channel 0 counter according to SYNCx bit in the PWM Sync Channels Mode Register on page 1486 (PWM_SCM). A 2-bit configurable gray counter enables the stepper motor driver. One gray counter drives 2 channels. A dead-time generator providing two complementary outputs (DTOHx/DTOLx) which allows to drive external power control switches safely. An output override block that can force the two complementary outputs to a programmed value (OOOHx/OOOLx). An asynchronous fault protection mechanism that has the highest priority to override the two complementary outputs (PWMHx/PWMLx) in case of fault detection (outputs forced to 0, 1).
z z z z
1457
49.6.2.2 Comparator The comparator continuously compares its counter value with the channel period defined by CPRD in the PWM Channel Period Register on page 1518 (PWM_CPRDx) and the duty-cycle defined by CDTY in the PWM Channel Duty Cycle Register on page 1516 (PWM_CDTYx) to generate an output signal OCx accordingly. The different properties of the waveform of the output OCx are:
z
The clock selection. The channel counter is clocked by one of the clocks provided by the clock generator described in the previous section. This channel parameter is defined in the CPRE field of the PWM Channel Mode Register on page 1514 (PWM_CMRx). This field is reset at 0. The waveform period. This channel parameter is defined in the CPRD field of the PWM_CPRDx register. If the waveform is left aligned, then the output waveform period depends on the counter source clock and can be calculated: By using the PWM master clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024), the resulting period formula will be:
( X CPRD ) ------------------------------MCK
By using the PWM master clock (MCK) divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
( CRPD DIVA ) CRPD DIVB ) ------------------------------------------ or ( -----------------------------------------MCK MCK
If the waveform is center aligned then the output waveform period depends on the counter source clock and can be calculated: By using the PWM master clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will be:
( 2 X CPRD ) -----------------------------------------MCK
By using the PWM master clock (MCK) divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
( 2 CPRD DIVA ) 2 CPRD DIVB ) ----------------------------------------------------- or ( ----------------------------------------------------MCK MCK
z
The waveform duty-cycle. This channel parameter is defined in the CDTY field of the PWM_CDTYx register. If the waveform is left aligned then:
The waveform polarity. At the beginning of the period, the signal can be at high or low level. This property is defined in the CPOL field of the PWM_CMRx register. By default the signal starts by a low level. The waveform alignment. The output waveform can be left or center aligned. Center aligned waveforms can be used to generate non overlapped waveforms. This property is defined in the CALG field of the PWM_CMRx register. The default mode is left aligned.
1458
OC0
OC1
Period
Note:
1.
See Figure 49-5 on page 1460 for a detailed description of center aligned waveforms.
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:
z z CDTY = CPRD and CPOL = 0 CDTY = 0 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 on page 1514 while the channel is enabled can lead to an unexpected behavior of the device being driven by PWM. Besides generating output signals OCx, the comparator generates interrupts in function of 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 the PWM_CMRx register 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 49-5 Waveform Properties illustrates the counter interrupts in function of the configuration.
1459
Output Waveform OCx CPOL(PWM_CMRx) = 1 Counter Event CHIDx(PWM_ISR) CES(PWM_CMRx) = 0 Counter Event CHIDx(PWM_ISR) CES(PWM_CMRx) = 1 Left Aligned CALG(PWM_CMRx) = 0
1460
49.6.2.3 2-bit Gray Up/Down Counter for Stepper Motor It is possible to configure a couple of channels to provide a 2-bit gray count waveform on 2 outputs. Dead-Time Generator and other downstream logic can be configured on these channels. Up or down count mode can be configured on-the-fly by means of PWM_SMMR configuration registers. When GCEN0 is set to 1, channels 0 and 1 outputs are driven with gray counter.
Figure 49-6. 2-bit Gray Up/Down Counter
GCEN0 = 1 PWMH0
PWML0
PWMH1
PWML1
DOWNx
1461
49.6.2.4 Dead-time Generator The dead-time generator uses the comparator output OCx to provide the two complementary outputs DTOHx and DTOLx, which allows the PWM macrocell to drive external power control switches safely. When the dead-time generator is enabled by setting the bit DTE to 1 or 0 in the PWM Channel Mode Register (PWM_CMRx), dead-times (also called dead-bands or non-overlapping times) are inserted between the edges of the two complementary outputs DTOHx and DTOLx. Note that enabling or disabling the dead-time generator is allowed only if the channel is disabled. The dead-time is adjustable by the PWM Channel Dead Time Register (PWM_DTx). Both outputs of the dead-time generator can be adjusted separately by DTH and DTL. The dead-time values can be updated synchronously to the PWM period by using the PWM Channel Dead Time Update Register (PWM_DTUPDx). The dead-time is based on a specific counter which uses the same selected clock that feeds the channel counter of the comparator. Depending on the edge and the configuration of the dead-time, DTOHx and DTOLx are delayed until the counter has reached the value defined by DTH or DTL. An inverted configuration bit (DTHI and DTLI bit in the PWM_CMRx register) is provided for each output to invert the dead-time outputs. The following figure shows the waveform of the dead-time generator.
Figure 49-7. Complementary Output Waveforms
Output waveform OCx CPOLx = 0 Output waveform DTOHx DTHIx = 0 Output waveform DTOLx DTLIx = 0 Output waveform DTOHx DTHIx = 1 Output waveform DTOLx DTLIx = 1 DTHx DTLx
Output waveform OCx CPOLx = 1 Output waveform DTOHx DTHIx = 0 Output waveform DTOLx DTLIx = 0 Output waveform DTOHx DTHIx = 1 Output waveform DTOLx DTLIx = 1 DTHx DTLx
1462
49.6.2.5 Output Override The two complementary outputs DTOHx and DTOLx of the dead-time generator can be forced to a value defined by the software.
Figure 49-8. Override Output Selection
DTOHx 0 OOOHx OOVHx 1
OSLx
The OSHx and OSLx fields in the PWM Output Selection Register (PWM_OS) allow the DTOHx and DTOLx outputs of the dead-time generator to be overridden by the value defined in the OOVHx and OOVLx fields in thePWM Output Override Value Register (PWM_OOV). The PWM Output Selection Set Register and PWM Output Selection Set Update Register set registers (PWM_OSS and PWM_OSSUPD) enable the override of the outputs of a channel regardless of other channels. In the same way, the PWM Output Selection Clear Register and PWM Output Selection Clear Update Register clear registers (PWM_OSC and PWM_OSCUPD) disable the override of the outputs of a channel regardless of other channels. By using the PWM_OSSUPD and PWM_OSCUPD buffer registers, the output selection of PWM outputs is done synchronously to the channel counter, at the beginning of the next PWM period. By using the PWM_OSS and PWM_OSC registers, 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.
1463
49.6.2.6 Fault Protection 1 input provides fault protection which can force any of the PWM output pair to a programmable value. This mechanism has priority over output overriding.
Figure 49-9. Fault Protection
0 fault input 0 Glitch Filter 1 FIV0
0 FMOD0
SET CLR OUT
from fault 0
FFIL0
FPOL0
Write FCLR0 at 1
FMOD0
FIV1
0 FMOD1
SET CLR OUT
FFIL1
FPOL1
Write FCLR1 at 1
FMOD1
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, Timer Counter, to name but a few, 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 bit 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. Check the corresponding peripheral documentation for details on handling fault generation. The fault inputs can be glitch filtered or not in function of the FFIL field in the PWM_FMR register. When the filter is activated, glitches on fault inputs with a width inferior to the PWM master clock (MCK) 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 register, the fault remains active as long as the fault input is at this polarity level. If the corresponding FMOD bit is set to 1, the fault remains active until the fault input is not at this polarity level anymore and until it is cleared by writing the corresponding bit FCLR in the PWM Fault Clear Register (PWM_FSCR). By reading the PWM Fault Status Register (PWM_FSR), the user can read the current level of the fault inputs by means of the field FIV, and can know which fault is currently active thanks to the FS field. 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 the synchronous channels (see Section 49.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 master clock (MCK) 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:
z z
To prevent an unexpected activation of the status flag FSy in the PWM_FSR register, the FMODy bit can be set to 1 only if the FPOLy bit has been previously configured to its final value. To prevent an unexpected activation of the Fault Protection on the channel x, the bit FPEx[y] can be set to 1 only if the FPOLy bit has been previously configured to its final value.
1464
If a comparison unit is enabled (see Section 49.6.3 PWM Comparison Units) and if a fault is triggered in the channel 0, in this case the comparison cannot match. As soon as the fault protection is triggered on a channel, an interrupt (different from the interrupt generated at the end of the PWM period) can be generated but only if it is enabled and not masked. The interrupt is reset by reading the interrupt status register, even if the fault which has caused the trigger of the fault protection is kept active. 49.6.2.7 Synchronous Channels Some channels can be linked together as synchronous channels. They have the same source clock, the same period, the same alignment and are started together. In this way, their counters are synchronized together. The synchronous channels are defined by the SYNCx bits in the PWM Sync Channels Mode Register (PWM_SCM). Only one group of synchronous channels is allowed. When a channel is defined as a synchronous channel, the channel 0 is automatically defined as a synchronous channel too, because the channel 0 counter configuration is used by all the synchronous channels. If a channel x is defined as a synchronous channel, it uses the following configuration fields of the channel 0 instead of its own:
z z z
CPRE0 field in PWM_CMR0 register instead of CPREx field in PWM_CMRx register (same source clock) CPRD0 field in PWM_CMR0 register instead of CPRDx field in PWM_CMRx register (same period) CALG0 field in PWM_CMR0 register instead of CALGx field in PWM_CMRx register (same alignment)
Thus writing these fields of a synchronous channel has no effect on the output waveform of this channel (except channel 0 of course). Because counters of synchronous channels must start at the same time, they are all enabled together by enabling the channel 0 (by the CHID0 bit in PWM_ENA register). In the same way, they are all disabled together by disabling channel 0 (by the CHID0 bit in PWM_DIS register). However, a synchronous channel x different from channel 0 can be enabled or disabled independently from others (by the CHIDx bit in PWM_ENA and PWM_DIS registers). Defining a channel as a synchronous channel while it is an asynchronous channel (by writing the bit SYNCx to 1 while it was at 0) is allowed only if the channel is disabled at this time (CHIDx = 0 in PWM_SR register). In the same way, defining a channel as an asynchronous channel while it is a synchronous channel (by writing the SYNCx bit to 0 while it was 1) is allowed only if the channel is disabled at this time. The field UPDM (Update Mode) in the PWM_SCM register allow to select one of the three methods to update the registers of the synchronous channels:
z
Method 1 (UPDM = 0): the period value, the duty-cycle values and the dead-time values must be written by the CPU in their respective update registers (respectively PWM_CPRDUPDx, PWM_CDTYUPDx and PWM_DTUPDx).The update is triggered at the next PWM period as soon as the bit UPDULOCK in the PWM Sync Channels Update Control Register (PWM_SCUC) is set to 1 (see Method 1: Manual write of duty-cycle values and manual trigger of the update on page 1466). Method 2 (UPDM = 1): the period value, the duty-cycle values, the dead-time values and the update period value must be written by the CPU in their respective update registers (respectively PWM_CPRDUPDx, PWM_CDTYUPDx and PWM_DTUPD). The update of the period value and of the dead-time values is triggered at the next PWM period as soon as the bit UPDULOCK in the PWM Sync Channels Update Control Register (PWM_SCUC) is set to 1. The update of the duty-cycle values and the update period value is triggered automatically after an update period defined by the field UPR in the PWM Sync Channels Update Period Register (PWM_SCUP) (see Method 2: Manual write of duty-cycle values and automatic trigger of the update on page 1467).
1465
Table 49-5. Summary of the Update of Registers of Synchronous Channels UPDM=0 Write by the CPU Period Value (PWM_CPRDUPDx) Update is triggered at the next PWM period as soon as the bit UPDULOCK is set to 1 Write by the CPU Dead-Time Values (PWM_DTUPDx) Update is triggered at the next PWM period as soon as the bit UPDULOCK is set to 1 Write by the CPU Duty-Cycle Values (PWM_CDTYUPDx) Update is triggered at the next PWM period as soon as the bit UPDULOCK is set to 1 Not applicable Update Period Value (PWM_SCUPUPD) Not applicable Write by the CPU Update is triggered at the next PWM period as soon as the update period counter has reached the value UPR Write by the CPU Update is triggered at the next PWM period as soon as the update period counter has reached the value UPR UPDM=1
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 CPU (respectively PWM_CPRDUPDx, PWM_CDTYUPDx and PWM_DTUPDx). To trigger the update, the user must use the bit UPDULOCK of the PWM Sync Channels Update Control Register (PWM_SCUC) which allows to update synchronously (at the same PWM period) the synchronous channels:
z z
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. 2. 3. 4. 5. 6. Select the manual write of duty-cycle values and the manual update by setting the UPDM field to 0 in the PWM_SCM register Define the synchronous channels by the SYNCx bits in the PWM_SCM register. Enable the synchronous channels by writing CHID0 in the PWM_ENA register. 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). Set UPDULOCK to 1 in PWM_SCUC. The update of the registers will occur at the beginning of the next PWM period. At this moment the UPDULOCK bit is reset, go to Step 4.) for new values.
1466
CDTYUPD
0x20
0x40
0x60
UPDULOCK
CDTY
0x20
0x40
0x60
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 CPU (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 of the PWM Sync Channels Update Control Register (PWM_SCUC) which allows to update synchronously (at the same PWM period) the synchronous channels: z If the bit UPDULOCK is set to 1, the update is done at the next PWM period of the synchronous channels. z 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 Sync Channels Update Period Register (PWM_SCUP). 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: z 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_IMR2 register, 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 register. 9. Write registers that need to be updated (PWM_CDTYUPDx, PWM_SCUPUPD). 10. The update of these registers will occur at the next PWM period of the synchronous channels when the Update Period is elapsed. Go to Step 8. for new values.
1467
CDTYUPD
0x20
0x40
0x60
UPRUPD
0x1
0x3
UPR
0x1
0x3
UPRCNT
0x0
0x1
0x0
0x1
0x0
0x1
0x0
0x1
0x2
0x3
0x0
0x1
0x2
CDTY
0x20
0x40
0x60
WRDY
CNT [PWM_CCNT0]
=
1 0 1
Comparison x
CTR [PWM_CMPMx]
1468
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 of the channel 0 is center aligned (CALG = 1 in PWM Channel Mode Register ), the bit CVM (in PWM_CMPVx) defines if the comparison is made when the counter is counting up or counting down (in left alignment mode CALG=0, this bit is useless). If a fault is active on the channel 0, the comparison is disabled and cannot match (see Section 49.6.2.6 Fault Protection). The user can define the periodicity of the comparison x by the fields CTR and CPR (in PWM_CMPVx). The comparison is performed periodically once every CPR+1 periods of the counter of the channel 0, when the value of the comparison period counter CPRCNT (in PWM_CMPMx) reaches the value defined by CTR. CPR is the maximum value of the comparison period counter CPRCNT. If CPR=CTR=0, the comparison is performed at each period of the counter of the channel 0. The comparison x configuration can be modified while the channel 0 is enabled by using the PWM Comparison x Mode Update Register (PWM_CMPMUPDx registers for the comparison x). In the same way, the comparison x value can be modified while the channel 0 is enabled by using the PWM Comparison x Value Update Register (PWM_CMPVUPDx registers for the comparison x). The update of the comparison x configuration and the comparison x value is triggered periodically after the comparison x update period. It is defined by the field CUPR in the PWM_CMPMx. The comparison unit has an update period counter independent from the period counter to trigger this update. When the value of the comparison update period counter CUPRCNT (in PWM_CMPMx) reaches the value defined by CUPR, the update is triggered. The comparison x update period CUPR itself can be updated while the channel 0 is enabled by using the PWM_CMPMUPDx register. CAUTION: To be taken into account, the write of the register PWM_CMPVUPDx must be followed by a write of the register PWM_CMPMUPDx.
The comparison match and the comparison update can be source of an interrupt, but only if it is enabled and not masked. These interrupts can be enabled by the PWM Interrupt Enable Register 2 and disabled by the PWM Interrupt Disable Register 2 . The comparison match interrupt and the comparison update interrupt are reset by reading the PWM Interrupt Status Register 2 .
1469
CVUPD CVMVUPD CTRUPD CPRUPD CUPRUPD CV CVM CTR CPR CUPR CUPRCNT CPRCNT Comparison Update CMPU Comparison Match CMPM
0x6
0x2
0x6
0x1 0x1 0x3 0x0 0x0 0x1 0x1 0x2 0x0 0x3 0x1
0x2 0x3 0x2 0x0 0x0 0x1 0x1 0x2 0x2 0x0 0x3 0x1 0x0 0x2 0x1 0x0 0x2 0x1 0x3
1470
1471
If the channel is a synchronous channel and update method 1 or 2 is selected (SYNCx=1 and UPDM=1 or 2 in PWM_SCM register): z registers PWM_CPRDUPDx and PWM_DTUPDx hold the new period and dead-times values until the bit UPDULOCK is written at 1 (in PWM_SCUC register) and the end of the current PWM period, then update the values for the next period. z register PWM_CDTYUPDx holds the new duty-cycle value until the end of the update period of synchronous channels (when UPRCNT is equal to UPR in PWM Sync Channels Update Period Register (PWM_SCUP)) and the end of the current PWM period, then updates the value for the next period. 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.
Note:
PWM_DTUPDx Value
PWM_CPRDUPDx Value
PWM_CDTYUPDx Value
PWM_DTx
PWM_CPRDx
PWM_CDTYx
- 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
1472
49.6.5.4 Changing the Synchronous Channels Update Period It is possible to change the update period of synchronous channels while they are enabled (see Method 2: Manual write of duty-cycle values and automatic trigger of the update on page 1467). To prevent an unexpected update of the synchronous channels registers, the user must use the PWM Sync Channels Update Period Update Register (PWM_SCUPUPD) to change the update period of synchronous channels while they are still enabled. This register holds the new value until the end of the update period of synchronous channels (when UPRCNT is equal to UPR in PWM Sync Channels Update Period Register (PWM_SCUP)) and the end of the current PWM period, then updates the value for the next period.
Notes: 1. If the update register PWM_SCUPUPD is written several times between two updates, only the last written value is taken into account. 2. Changing the update period does make sense only if there is one or more synchronous channels and if the update method 1 or 2 is selected (UPDM = 1 or 2 in PWM Sync Channels Mode Register ).
PWM_SCUPUPD Value
PWM_SCUP
1473
49.6.5.5 Changing the Comparison Value and the Comparison Configuration It is possible to change the comparison values and the comparison configurations while the channel 0 is enabled (see Section 49.6.3 PWM Comparison Units). To prevent unexpected comparison match, the user must use the PWM Comparison x Value Update Register and the PWM Comparison x Mode Update Register (PWM_CMPVUPDx and PWM_CMPMUPDx) to change respectively the comparison values and the comparison configurations while the channel 0 is still enabled. These registers hold the new values until the end of the comparison update period (when CUPRCNT is equal to CUPR in PWM Comparison x Mode Register (PWM_CMPMx) and the end of the current PWM period, then update the values for the next period. CAUTION: Note: To be taken into account, the write of the PWM_CMPVUPDx register must be followed by a write of the PWM_CMPMUPDx register.
If the update registers PWM_CMPVUPDx and PWM_CMPMUPDx are written several times between two updates, only the last written value are taken into account.
PWM_CMPVx
PWM_CMPMx
End of channel0 PWM period and end of Comparison Update Period and and PWM_CMPMx written End of channel0 PWM period and end of Comparison Update Period
49.6.5.6 Interrupts Depending on the interrupt mask in the PWM_IMR1 and PWM_IMR2 registers, an interrupt can be generated at the end of the corresponding channel period (CHIDx in the PWM_ISR1 register), after a fault event (FCHIDx in the PWM_ISR1 register), after a comparison match (CMPMx in the PWM_ISR2 register), after a comparison update (CMPUx in the PWM_ISR2 register) or according to the transfer mode of the synchronous channels (WRDY, ENDTX, TXBUFE and UNRE in the PWM_ISR2 register). If the interrupt is generated by the flags CHIDx or FCHIDx, the interrupt remains active until a read operation in the PWM_ISR1 register 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 register occurs. A channel interrupt is enabled by setting the corresponding bit in the PWM_IER1 and PWM_IER2 registers. A channel interrupt is disabled by setting the corresponding bit in the PWM_IDR1 and PWM_IDR2 registers.
1474
49.6.5.7 Write Protect Registers To prevent any single software error that may corrupt PWM behavior, the registers listed below can be write-protected by writing the field WPCMD in the PWM Write Protect Control Register on page 1507 (PWM_WPCR). They are divided into 6 groups:
z
Register group 0:
z
PWM Clock Register on page 1479 PWM Disable Register on page 1481 PWM Sync Channels Mode Register on page 1486 PWM Channel Mode Register on page 1514 PWM Stepper Motor Mode Register on page 1506 PWM Channel Period Register on page 1518 PWM Channel Period Update Register on page 1519 PWM Channel Dead Time Register on page 1521 PWM Channel Dead Time Update Register on page 1522 PWM Fault Mode Register on page 1500 PWM Fault Protection Value Register on page 1503
Register group 1:
z
Register group 2:
z z z
Register group 3:
z z
Register group 4:
z z
Register group 5:
z z
Write Protect SW, which can be enabled or disabled. Write Protect HW, which can just be enabled, only a hardware reset of the PWM controller can disable it.
Both types of Write Protect can be applied independently to a particular register group by means of the WPCMD and WPRG fields in PWM_WPCR register. If at least one Write Protect is active, the register group is write-protected. The field WPCMD allows to perform the following actions depending on its value:
z z z
0 = Disabling the Write Protect SW of the register groups of which the bit WPRG is at 1. 1 = Enabling the Write Protect SW of the register groups of which the bit WPRG is at 1. 2 = Enabling the Write Protect HW of the register groups of which the bit WPRG is at 1.
At any time, the user can determine which Write Protect is active in which register group by the fields WPSWS and WPHWS in the PWM Write Protect Status Register on page 1509 (PWM_WPSR). If a write access in a write-protected register is detected, then the WPVS flag in the PWM_WPSR register is set and the field WPVSRC indicates in which register the write access has been attempted, through its address offset without the two LSBs. The WPVS and PWM_WPSR fields are automatically reset after reading the PWM_WPSR register.
1475
49.7
Table 49-6. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 0x5C 0x60 0x64 0x68 0x6C 0x70-0x78 0x7C 0x80 0x84-0x9C 0xA0 - 0xAC 0xB0 0xB4-0xBC Register PWM Clock Register PWM Enable Register PWM Disable Register PWM Status Register PWM Interrupt Enable Register 1 PWM Interrupt Disable Register 1 PWM Interrupt Mask Register 1 PWM Interrupt Status Register 1 PWM Sync Channels Mode Register Reserved PWM Sync Channels Update Control Register PWM Sync Channels Update Period Register PWM Sync Channels Update Period Update Register PWM Interrupt Enable Register 2 PWM Interrupt Disable Register 2 PWM Interrupt Mask Register 2 PWM Interrupt Status Register 2 PWM Output Override Value Register PWM Output Selection Register PWM Output Selection Set Register PWM Output Selection Clear Register PWM Output Selection Set Update Register PWM Output Selection Clear Update Register PWM Fault Mode Register PWM Fault Status Register PWM Fault Clear Register PWM Fault Protection Value Register PWM Fault Protection Enable Register Reserved PWM Event Line 0 Mode Register PWM Event Line 1 Mode Register Reserved Reserved PWM Stepper Motor Mode Register Reserved Name PWM_CLK PWM_ENA PWM_DIS PWM_SR PWM_IER1 PWM_IDR1 PWM_IMR1 PWM_ISR1 PWM_SCM PWM_SCUC PWM_SCUP PWM_SCUPUPD PWM_IER2 PWM_IDR2 PWM_IMR2 PWM_ISR2 PWM_OOV PWM_OS PWM_OSS PWM_OSC PWM_OSSUPD PWM_OSCUPD PWM_FMR PWM_FSR PWM_FCR PWM_FPV PWM_FPE PWM_ELMR0 PWM_ELMR1 PWM_SMMR Access Read-write Write-only Write-only Read-only Write-only Write-only Read-only Read-only Read-write Read-write Read-write Write-only Write-only Write-only Read-only Read-only Read-write Read-write Write-only Write-only Write-only Write-only Read-write Read-only Write-only Read-write Read-write Read-write Read-write Read-write Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
1476
Table 49-6. Register Mapping (Continued) Offset 0xC0-E0 0xE4 0xE8 0xEC - 0xFC 0x130 0x134 0x138 0x13C 0x140 0x144 0x148 0x14C 0x150 0x154 0x158 0x15C 0x160 0x164 0x168 0x16C 0x170 0x174 0x178 0x17C 0x180 0x184 0x188 0x18C 0x190 0x194 0x198 0x19C 0x1A0 0x1A4 0x1A8 0x1AC 0x1B0 - 0x1FC Register Reserved PWM Write Protect Control Register PWM Write Protect Status Register Reserved PWM Comparison 0 Value Register PWM Comparison 0 Value Update Register PWM Comparison 0 Mode Register PWM Comparison 0 Mode Update Register PWM Comparison 1 Value Register PWM Comparison 1 Value Update Register PWM Comparison 1 Mode Register PWM Comparison 1 Mode Update Register PWM Comparison 2 Value Register PWM Comparison 2 Value Update Register PWM Comparison 2 Mode Register PWM Comparison 2 Mode Update Register PWM Comparison 3 Value Register PWM Comparison 3 Value Update Register PWM Comparison 3 Mode Register PWM Comparison 3 Mode Update Register PWM Comparison 4 Value Register PWM Comparison 4 Value Update Register PWM Comparison 4 Mode Register PWM Comparison 4 Mode Update Register PWM Comparison 5 Value Register PWM Comparison 5 Value Update Register PWM Comparison 5 Mode Register PWM Comparison 5 Mode Update Register PWM Comparison 6 Value Register PWM Comparison 6 Value Update Register PWM Comparison 6 Mode Register PWM Comparison 6 Mode Update Register PWM Comparison 7 Value Register PWM Comparison 7 Value Update Register PWM Comparison 7 Mode Register PWM Comparison 7 Mode Update Register Reserved Name PWM_WPCR PWM_WPSR PWM_CMPV0 PWM_CMPVUPD0 PWM_CMPM0 PWM_CMPMUPD0 PWM_CMPV1 PWM_CMPVUPD1 PWM_CMPM1 PWM_CMPMUPD1 PWM_CMPV2 PWM_CMPVUPD2 PWM_CMPM2 PWM_CMPMUPD2 PWM_CMPV3 PWM_CMPVUPD3 PWM_CMPM3 PWM_CMPMUPD3 PWM_CMPV4 PWM_CMPVUPD4 PWM_CMPM4 PWM_CMPMUPD4 PWM_CMPV5 PWM_CMPVUPD5 PWM_CMPM5 PWM_CMPMUPD5 PWM_CMPV6 PWM_CMPVUPD6 PWM_CMPM6 PWM_CMPMUPD6 PWM_CMPV7 PWM_CMPVUPD7 PWM_CMPM7 PWM_CMPMUPD7 Access Write-only Read-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Read-write Write-only Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
1477
Table 49-6. Register Mapping (Continued) Offset 0x200 + ch_num * 0x20 + 0x00 0x200 + ch_num * 0x20 + 0x04 0x200 + ch_num * 0x20 + 0x08 0x200 + ch_num * 0x20 + 0x0C 0x200 + ch_num * 0x20 + 0x10 0x200 + ch_num * 0x20 + 0x14 0x200 + ch_num * 0x20 + 0x18 0x200 + ch_num * 0x20 + 0x1C Register PWM Channel Mode Register(1) PWM Channel Duty Cycle Register(1) PWM Channel Duty Cycle Update Register(1) PWM Channel Period Register(1) PWM Channel Period Update Register(1) PWM Channel Counter Register(1) PWM Channel Dead Time Register(1) PWM Channel Dead Time Update Register(1) Name PWM_CMR PWM_CDTY PWM_CDTYUPD PWM_CPRD PWM_CPRDUPD PWM_CCNT PWM_DT PWM_DTUPD Access Read-write Read-write Write-only Read-write Write-only Read-only Read-write Write-only Reset 0x0 0x0 0x0 0x0 0x0
Note:
1478
15 7
14 6
13 5
12 4 DIVA
11
10 PREA
This register can only be written if the bits WPSWS0 and WPHWS0 are cleared in PWM Write Protect Status Register on page 1509.
1479
CHIDx: Channel ID
0 = No effect. 1 = Enables PWM output for channel x.
1480
This register can only be written if the bits WPSWS1 and WPHWS1 are cleared in PWM Write Protect Status Register on page 1509.
CHIDx: Channel ID
0 = No effect. 1 = Disables PWM output for channel x.
1481
CHIDx: Channel ID
0 = PWM output for channel x is disabled. 1 = PWM output for channel x is enabled.
1482
CHIDx: Counter Event on Channel x Interrupt Enable FCHIDx: Fault Protection Trigger on Channel x Interrupt Enable
CHIDx: Counter Event on Channel x Interrupt Disable FCHIDx: Fault Protection Trigger on Channel x Interrupt Disable
1483
CHIDx: Counter Event on Channel x Interrupt Mask FCHIDx: Fault Protection Trigger on Channel x Interrupt Mask
1484
1485
This register can only be written if the bits WPSWS2 and WPHWS2 are cleared in PWM Write Protect Status Register on page 1509.
Notes: 1. The update occurs at the beginning of the next PWM period, when the UPDULOCK bit in PWM Sync Channels Update Control Register is set. 2. The update occurs when the Update Period is elapsed.
1486
1487
1488
This register acts as a double buffer for the UPR value. This prevents an unexpected automatic trigger of the update of synchronous channels.
1489
WRDY: Write Ready for Synchronous Channels Update Interrupt Enable UNRE: Synchronous Channels Update Underrun Error Interrupt Enable CMPMx: Comparison x Match Interrupt Enable CMPUx: Comparison x Update Interrupt Enable
1490
WRDY: Write Ready for Synchronous Channels Update Interrupt Disable UNRE: Synchronous Channels Update Underrun Error Interrupt Disable CMPMx: Comparison x Match Interrupt Disable CMPUx: Comparison x Update Interrupt Disable
1491
WRDY: Write Ready for Synchronous Channels Update Interrupt Mask UNRE: Synchronous Channels Update Underrun Error Interrupt Mask CMPMx: Comparison x Match Interrupt Mask CMPUx: Comparison x Update Interrupt Mask
1492
1493
1494
1495
1496
1497
1498
1499
23
22
21
20 FFIL
19
18
17
16
15
14
13
12 FMOD
11
10
4 FPOL
This register can only be written if the bits WPSWS5 and WPHWS5 are cleared in PWM Write Protect Status Register on page 1509.
0 = The fault y becomes active when the fault input y is at 0. 1 = The fault y becomes active when the fault input y is at 1. FMOD: Fault Activation Mode
For each field bit y (fault input number):
0 = The fault y is active until the Fault condition is removed at the peripheral(1) level. 1 = The fault y stays active until the Fault condition is removed at the peripheral(1) level AND until it is cleared in the PWM Fault Clear Register .
Note: 1. The Peripheral generating the fault.
CAUTION: To prevent an unexpected activation of the status flag FSy in the PWM Fault Status Register on page 1501, the bit FMODy can be set to 1 only if the FPOLy bit has been previously configured to its final value.
1500
23
22
21
20
19
18
17
16
15
14
13
12 FS
11
10
4 FIV
0 = The current sampled value of the fault input y is 0 (after filtering if enabled). 1 = The current sampled value of the fault input y is 1 (after filtering if enabled). FS: Fault Status
For each field bit y (fault input number):
1501
23
22
21
20
19
18
17
16
15
14
13
12
11
10
4 FCLR
0 = No effect. 1 = If bit y of FMOD field is set to 1 and if the fault input y is not at the level defined by the bit y of FPOL field, the fault y is cleared and becomes inactive (FMOD and FPOL fields belong to PWM Fault Mode Register on page 1500), else writing this bit to 1 has no effect.
1502
This register can only be written if the bits WPSWS5 and WPHWS5 are cleared in PWM Write Protect Status Register on page 1509.
1503
23
22
21
20 FPE2
19
18
17
16
15
14
13
12 FPE1
11
10
4 FPE0
This register can only be written if the bits WPSWS5 and WPHWS5 are cleared in PWM Write Protect Status Register on page 1509. Only the first 1 bit (number of fault input pins) of the FPE0, FPE1, FPE2 and FPE3 fields is significant.
CAUTION: To prevent an unexpected activation of the Fault Protection, the bit y of the FPEx field can be set to 1 only if the corresponding FPOL bit has been previously configured to its final value in PWM Fault Mode Register on page 1500.
1504
1505
1506
23
22
21
20 WPKEY
19
18
17
16
15
14
13
12 WPKEY
11
10
7 WPRG5
6 WPRG4
5 WPRG3
4 WPRG2
3 WPRG1
2 WPRG0
1 WPCMD
Moreover, to meet security requirements, in this mode of operation, the PIO lines associated with PWM can not be configured through the PIO interface, not even by the PIO controller.
3 = No effect. Note: Only a hardware reset of the PWM controller can disable the Write Protect HW.
Register group 0:
PWM Clock Register on page 1479
Register group 1:
PWM Disable Register on page 1481
Register group 2:
PWM Sync Channels Mode Register on page 1486 PWM Channel Mode Register on page 1514 PWM Stepper Motor Mode Register on page 1506
Register group 3:
PWM Channel Period Register on page 1518 PWM Channel Period Update Register on page 1519
1507
Register group 4:
PWM Channel Dead Time Register on page 1521 PWM Channel Dead Time Update Register on page 1522
Register group 5:
PWM Fault Mode Register on page 1500 PWM Fault Protection Value Register on page 1503
1508
23
22
21
20 WPVSRC
19
18
17
16
15 7 WPVS
14 6
13 WPHWS5 5 WPSWS5
12 WPHWS4 4 WPSWS4
11 WPHWS3 3 WPSWS3
10 WPHWS2 2 WPSWS2
9 WPHWS1 1 WPSWS1
8 WPHWS0 0 WPSWS0
1509
PWM_CMPVx 0xF002C130 [0], 0xF002C140 [1], 0xF002C150 [2], 0xF002C160 [3], 0xF002C170 [4], 0xF002C180 [5], 0xF002C190 [6], 0xF002C1A0 [7] Read-write
30 22 29 21 28 20 CV 27 19 26 18 25 17 24 CVM 16
15
14
13
12 CV
11
10
4 CV
Only the first 16 bits (channel counter size) of field CV are significant.
1510
PWM_CMPVUPDx 0xF002C134 [0], 0xF002C144 [1], 0xF002C154 [2], 0xF002C164 [3], 0xF002C174 [4], 0xF002C184 [5], 0xF002C194 [6], 0xF002C1A4 [7] Write-only
30 22 29 21 28 20 CVUPD 27 19 26 18 25 17 24 CVMUPD 16
15
14
13
12 CVUPD
11
10
4 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: to be taken into account, the write of the register PWM_CMPVUPDx must be followed by a write of the register PWM_CMPMUPDx.
1511
PWM_CMPMx 0xF002C138 [0], 0xF002C148 [1], 0xF002C158 [2], 0xF002C168 [3], 0xF002C178 [4], 0xF002C188 [5], 0xF002C198 [6], 0xF002C1A8 [7] Read-write
30 22 CUPRCNT 29 21 28 20 27 19 26 18 CUPR 13 CPRCNT 7 6 CTR 5 4 3 2 12 11 10 CPR 1 0 CEN 9 8 25 17 24 16
15
14
1512
PWM_CMPMUPDx 0xF002C13C [0], 0xF002C14C [1], 0xF002C15C [2], 0xF002C16C [3], 0xF002C17C [4], 0xF002C18C [5], 0xF002C19C [6], 0xF002C1AC [7] Write-only
30 22 14 6 CTRUPD 29 21 13 5 28 20 12 4 27 19 26 18 CUPRUPD 11 10 CPRUPD 3 2 1 0 CENUPD 9 8 25 17 24 16
This register acts as a double buffer for the CEN, CTR, CPR and CUPR values. This prevents an unexpected comparison x match.
1513
PWM_CMRx [x=0..3] 0xF002C200 [0], 0xF002C220 [1], 0xF002C240 [2], 0xF002C260 [3] Read-write
30 22 14 6 29 21 13 5 28 20 12 4 27 19 11 3 26 18 DTLI 10 CES 2 CPRE 25 17 DTHI 9 CPOL 1 24 16 DTE 8 CALG 0
This register can only be written if the bits WPSWS2 and WPHWS2 are cleared in PWM Write Protect Status Register on page 1509.
1514
1515
PWM_CDTYx [x=0..3] 0xF002C204 [0], 0xF002C224 [1], 0xF002C244 [2], 0xF002C264 [3] Read-write
30 22 29 21 28 20 CDTY 27 19 26 18 25 17 24 16
15
14
13
12 CDTY
11
10
4 CDTY
1516
PWM_CDTYUPDx [x=0..3] 0xF002C208 [0], 0xF002C228 [1], 0xF002C248 [2], 0xF002C268 [3] Write-only.
30 22 29 21 28 20 CDTYUPD 27 19 26 18 25 17 24 16
15
14
13
12 CDTYUPD
11
10
4 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.
1517
PWM_CPRDx [x=0..3] 0xF002C20C [0], 0xF002C22C [1], 0xF002C24C [2], 0xF002C26C [3] Read-write
30 22 29 21 28 20 CPRD 27 19 26 18 25 17 24 16
15
14
13
12 CPRD
11
10
4 CPRD
This register can only be written if the bits WPSWS3 and WPHWS3 are cleared in PWM Write Protect Status Register on page 1509. Only the first 16 bits (channel counter size) are significant.
By using the PWM master clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will be:
( X CPRD ) ------------------------------MCK
By using the PWM master clock (MCK) divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
( CRPD DIVA ) CRPD DIVB ) ------------------------------------------ or ( -----------------------------------------MCK MCK
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 master clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will be:
( 2 X CPRD ) -----------------------------------------MCK
By using the PWM master clock (MCK) divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
( 2 CPRD DIVA ) 2 CPRD DIVB ) ----------------------------------------------------- or ( ----------------------------------------------------MCK MCK
1518
PWM_CPRDUPDx [x=0..3] 0xF002C210 [0], 0xF002C230 [1], 0xF002C250 [2], 0xF002C270 [3] Write-only
30 22 29 21 28 20 CPRDUPD 27 19 26 18 25 17 24 16
15
14
13
12 CPRDUPD
11
10
4 CPRDUPD
This register can only be written if the bits WPSWS3 and WPHWS3 are cleared in PWM Write Protect Status Register on page 1509. 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.
By using the PWM master clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will be:
( X CPRDUPD ) --------------------------------------------MCK
By using the PWM master clock (MCK) divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
( CRPDUPD DIVA ) ( CRPDUPD DIVB ) -------------------------------------------------------or -------------------------------------------------------MCK MCK
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 master clock (MCK) divided by an X given prescaler value (with X being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). The resulting period formula will be:
( 2 X CPRDUPD ) ------------------------------------------------------MCK
By using the PWM master clock (MCK) divided by one of both DIVA or DIVB divider, the formula becomes, respectively:
( 2 CPRDUPD DIVA ) 2 CPRDUPD DIVB ) ------------------------------------------------------------------ or ( -----------------------------------------------------------------MCK MCK
1519
PWM_CCNTx [x=0..3] 0xF002C214 [0], 0xF002C234 [1], 0xF002C254 [2], 0xF002C274 [3] Read-only
30 22 29 21 28 20 CNT 27 19 26 18 25 17 24 16
15
14
13
12 CNT
11
10
4 CNT
The channel is enabled (writing CHIDx in the PWM_ENA register). The channel counter reaches CPRD value defined in the PWM_CPRDx register if the waveform is left aligned.
1520
PWM_DTx [x=0..3] 0xF002C218 [0], 0xF002C238 [1], 0xF002C258 [2], 0xF002C278 [3] Read-write
30 29 28 DTL 27 26 25 24
23
22
21
20 DTL
19
18
17
16
15
14
13
12 DTH
11
10
4 DTH
This register can only be written if the bits WPSWS4 and WPHWS4 are cleared in PWM Write Protect Status Register on page 1509. Only the first 12 bits (dead-time counter size) of fields DTH and DTL are significant.
1521
PWM_DTUPDx [x=0..3] 0xF002C21C [0], 0xF002C23C [1], 0xF002C25C [2], 0xF002C27C [3] Write-only
30 29 28 DTLUPD 27 26 25 24
23
22
21
20 DTLUPD
19
18
17
16
15
14
13
12 DTHUPD
11
10
4 DTHUPD
This register can only be written if the bits WPSWS4 and WPHWS4 are cleared in PWM Write Protect Status Register on page 1509. 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.
1522
50.
50.1
1523
50.2
Embedded Characteristics
z z z z z z
12-bit Resolution 1 MHz Conversion Rate Wide Range Power Supply Operation Selectable Single Ended or Differential Input Voltage Programmable Gain For Maximum Full Scale Input Range 0 - VDD Resistive 4-wire and 5-wire Touchscreen Controller
z z z
Position and Pressure Measurement for 4-wire screens Position Measurement for 5-wire screens Average of up to 8 measures for noise filtering
z z z z
Programmable Pen Detection sensitivity Integrated Multiplexer Offering Up to 12 Independent Analog Inputs Individual Enable and Disable of Each Channel Hardware or Software Trigger
z z z z z
External Trigger Pin Timer Counter Outputs (Corresponding TIOA Trigger) Internal Trigger Counter Trigger on Pen Contact Detection PWM Event Line
z z z z
Drive of PWM Fault Input DMA Support Possibility of ADC Timings Configuration Two Sleep Modes and Conversion Sequencer
z z
Automatic Wake-up on Trigger and Back to Sleep Mode after Conversions of all Enabled Channels Possibility of Customized Channel Sequence Power Down Capability
z z
1524
50.3
Block Diagram
PMC MCK
ADC Controller
ADTRG
Trigger Selection
ADC Interrupt
ADC cell
Control Logic
Interrupt Controller
VDDANA ADVREF
SOC
AD0/XP/UL
Touchscreen Switches
1 2 3 4
VIN+ VIN- OFFSET S/H
Peripheral Bridge
PGA
APB
AD-
AD-
CHx
GND
50.4
Signal Description
Description Analog power supply Reference voltage Analog input channels External trigger
Table 50-1. ADC Pin Description Pin Name VDDANA ADVREF AD0 - AD11 ADTRG
1525
50.5
Product Dependencies
1526
50.5.6 PWM Event Line PWM Event Lines may or may not be used as hardware triggers depending on user requirements. 50.5.7 Fault Output The ADC Controller has the FAULT output connected to the FAULT input of PWM. Please refer to Section 50.7.11 Fault Output and implementation of the PWM in the product. 50.5.8 Conversion Performances
For performance and electrical characteristics of the ADC, see the product DC Characteristics section.
1527
50.6
Functional Description
ADC_Start
ADC_SEL
CH0
CH1
CH2
LCDR
CH0
CH1
DRDY
Transfer Period
1528
Figure 50-3. Sequence of ADC conversions when Tracking time < Conversion time
Read the ADC_LCDR
ADC_Start
ADC_SEL
CH0
CH1
CH2
CH3
LCDR
CH0
CH1
CH2
DRDY
Transfer Period
Transfer Period
Transfer Period
50.6.3 Conversion Resolution 50.6.4 The ADC supports 12-bit resolutions.Conversion Results
When a conversion is completed, the resulting 12-bit digital value is stored in the Channel Data Register (ADC_CDRx) of the current channel and in the ADC Last Converted Data Register (ADC_LCDR). By setting the TAG option in the ADC_EMR, the ADC_LCDR presents the channel number associated to the last converted data in the CHNB field. The channel EOC bit in the Status Register (ADC_SR) is set and the DRDY is set. In the case of a connected DMA channel, DRDY rising triggers a data request. In any case, either EOC and DRDY can trigger an interrupt. Reading one of the ADC_CDR registers clears the corresponding EOC bit. Reading ADC_LCDR clears the DRDY bit.
1529
DRDY (ADC_SR)
If the ADC_CDR is not read before further incoming data is converted, the corresponding Overrun Error (OVREx) flag is set in the Overrun Status Register (ADC_OVER). Likewise, new data converted when DRDY is high sets the GOVRE bit (General Overrun Error) in ADC_SR. The OVREx flag is automatically cleared when ADC_OVER is read, and GOVRE flag is automatically cleared when ADC_SR is read.
1530
Trigger event CH0 (ADC_CHSR) CH1 (ADC_CHSR) ADC_LCDR ADC_CDR0 ADC_CDR1 Undefined Data Undefined Data Undefined Data Data A Data A Data B Data C
Data C Data B
EOC0 (ADC_SR)
Conversion A
Conversion C
Read ADC_CDR0
EOC1 (ADC_SR)
Conversion B
Read ADC_CDR1
Read ADC_SR
Warning: If the corresponding channel is disabled during a conversion or if it is disabled and then reenabled during a conversion, its associated data and its corresponding EOC and OVRE flags in ADC_SR are unpredictable.
1531
Any edge, either rising or falling or both, detected on the external trigger pin, TSADTRG. The hardware trigger source is selected with the TRGSEL field in the Mode Register (ADC_MR). The selected hardware trigger is enabled if TRGMOD=1,2 or 3 in ADC Trigger Register. The Pen Detect, depending on how the PENDET bit is set in the ADC Touchscreen Mode Register. A continuous trigger, meaning the ADC Controller restarts the next sequence as soon as it finishes the current one A periodic trigger, which is defined by programming the TRGPER field in the ADC Trigger Register.
z z z
The minimum time between 2 consecutive trigger events must be strictly greater than the duration time of the longest conversion sequence according to configuration of registers ADC_MR, ADC_CHSR, ADC_SEQR1, ADC_SEQR2, ADC_TSMR. If a hardware trigger is selected, the start of a conversion is triggered after a delay starting at each rising edge of the selected signal. Due to asynchronous handling, the delay may vary in a range of 2 MCK clock periods to 1 ADC clock period.
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 DMA, only the transfers of converted data from enabled channels are performed and the resulting data buffers should be interpreted accordingly.
1532
The conversion sequencer allows automatic processing with minimum processor intervention and optimized power consumption. Conversion sequences can be performed periodically using the internal timer (ADC_TRGR register) or the PWM event line. The periodic acquisition of several samples can be processed automatically without any intervention of the processor thanks to the DMA. The sequence can be customized by programming the Sequence Channel Registers, ADC_SEQR1 and ADC_SEQR2 and setting to 1 the USEQ bit of the Mode Register (ADC_MR). The user can choose a specific order of channels and can program up to 12 conversions by sequence. The user is totally free to create a personal sequence, by writing channel numbers in ADC_SEQR1 and ADC_SEQR2. Not only can channel numbers be written in any sequence, channel numbers can be repeated several times. Only enabled sequence bitfields are converted, consequently to program a 15-conversion sequence, the user can simply put a disable in ADC_CHSR[15], thus disabling the 16THCH field of ADC_SEQR2. If all ADC channels (i.e. 12) are used on an application board, there is no restriction of usage of the user sequence. But as soon as some ADC channels are not enabled for conversion but rather used as pure digital inputs, the respective indexes of these channels cannot be used in the user sequence fields (ADC_SEQR1, ADC_SEQR2 bitfields). For example, if channel 4 is disabled (ADC_CSR[4] = 0), ADC_SEQR1, ADC_SEQR2 register bitfields USCH1 up to USCH12 must not contain the value 4. Thus the length of the user sequence may be limited by this behavior. As an example, if only 4 channels over 12 (CH0 up to CH3) are selected for ADC conversions, the user sequence length cannot exceed 4 channels. Each trigger event may launch up to 4 successive conversions of any combination of channels 0 up to 3 but no more (i.e. in this case the sequence CH0, CH0, CH1, CH1, CH1 is impossible). A sequence that repeats several times the same channel requires more enabled channels than channels actually used for conversion. For example, a sequence like CH0, CH0, CH1, CH1 requires 4 enabled channels (4 free channels on application boards) whereas only CH0, CH1 are really converted. Note: The reference voltage pins always remain connected in normal mode as in sleep mode.
1533
Table 50-4. Input Pins and Channel Number in Single Ended Mode Input Pins AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 AD8 AD9 AD10 AD11 AD12 AD13 AD14 AD15 Channel Number CH0 CH1 CH2 CH3 CH4 CH5 CH6 CH7 CH8 CH9 CH10 CH11 CH12 CH13 CH14 CH15
Table 50-5. Input Pins and Channel Number In Differential Mode Input Pins AD0-AD1 AD2-AD3 AD4-AD5 AD6-AD7 AD8-AD9 AD10-AD11 AD12-AD13 AD14-AD15 Channel Number CH0 CH2 CH4 CH6 CH8 CH10 CH12 CH14
1534
To allow full range, analog offset of the ADC can be configured by the OFFSET bit of the Channel Offset Register (ADC_COR). The Offset is only available in Single Ended Mode.
Table 50-7. Offset of the Sample and Hold Unit: OFFSET DIFF and Gain (G) OFFSET Bit 0 1 OFFSET (DIFF = 0) 0 0 (G-1)Vrefin/2 OFFSET (DIFF = 1)
1535
Figure 50-6. Analog Full Scale Ranges in Single Ended/Differential Applications Versus Gain and Offset
gain=0.5 (00)
same as gain=1
()vrefin
VIN-
0 vrefin
()vrefin
VIN+
VIN+
()vrefin
gain=1 (01)
VIN()vrefin
0 vrefin
offset=1
offset=0
()vrefin (5/8)vrefin
gain=2 (10)
VIN+ VIN+
VIN+ VIN-
0 vrefin
offset=1
VIN+
offset=0
(5/8)vrefin ()vrefin (3/8)vrefin
same as gain=2
VIN+ VIN-
gain=4 (11)
VIN+
()vrefin (1/8)vrefin
1536
1537
50.7
Touchscreen
YM
YP
XM
XP
VDD
YP
VDD
YP
XP
Volt
GND
GND
1538
VYM / VDD or VYP / VDD. The implementation with on-chip power switches is shown in Figure 50-8. The voltage measurement at the output of the switch compensates for the switches loss. It is possible to correct for switch loss by performing the operation: [VYP - VXM] / [VXP - VXM]. This requires additional measurements, as shown in Figure 50-8.
Figure 50-8. Touchscreen Switches Implementation
XP VDDANA
0
XM GND
1
YP To the ADC VDDANA
2
YM GND
XP
YP
YP
XP
XM Switch Resistor
YM Switch Resistor
1539
Open circuit YP XP
Switch Resistor
XP
YP
XP
YP
Rp
Rp
Rp
XM Switch Resistor
YM Open circuit
XM Switch Resistor
YM Open circuit
YM
GND Z1 Measure(Xp)
1540
UL
Pen Contact
Resistive layer
UR
Sense
LL
Conductive Layer
LR UR
VDDANA for Yp GND for Xp Sense
UL
VDDANA
LL
VDDANA for Xp GND for Yp
LR
GND
1541
Connecting Upper left (UL) and upper right (UR) corners to VDDANA Connecting Lower left (LL) and lower right (LR) corners to ground. The voltage measured is determined by the voltage divider developed at the point of touch (Yposition) and the SENSE input is converted by ADC. Connecting the upper left (UL) and lower left (LL) corners to ground Connecting the upper right and lower right corners to VDDANA. The voltage measured is determined by the voltage divider developed at the point of touch (Xposition) and the SENSE input is converted by ADC.
UL UR
VDDANA
0
GND VDDANA GND
LL
VDDANA
2 3
To the ADC
Sense
LR
GND
UL
VDDANA
UR
Sense
LL
LR
GND
1542
ADC_SEL
C T
C T
C -
C T
C T
T: Touchscreen Sequence
YRDY
1543
X+/UL X-/UR
VDDANA
0
GND VDDANA GND
1 2 3 4
PENDBC Debouncer Pen Interrupt To the ADC
Y+/LL
VDDANA
Y-/SENSE
GND
LR
GND
GND
The Touchscreen Pen Detect can be used to generate an ADC interrupt to wake up the system. The Pen Detect generates two types of status, reported in the ADC Interrupt Status Register: z The PEN bit is set as soon as a contact exceeds the debouncing time as defined by PENDBC and remains set until ADC_SR is read. z The NOPEN bit is set as soon as no current flows for a time over the debouncing time as defined by PENDBC and remains set until ADC_SR is read. Both bits are automatically cleared as soon as the Status Register (ADC_SR) is read, and can generate an interrupt by writing the ADC Interrupt Enable Register. Moreover, the rising of either one of them clears the other, they cannot be set at the same time. The PENS bit of the ADC_SR indicates the current status of the pen contact.
1544
5 6 8 5 6 8
0 0 0 0 0 0
trig.event2
trig.eventN
trig.eventN
5 6 8
0 0 0
1545
50.7.10.2 Touchscreen Channels Only When only touchscreen conversions are required (i.e. TSMODE differs from 0 in ADC_TSMR register and ADC_CHSR equals 0), the structure of data within the buffer is defined by the ADC_TSMR register. When TSMODE = 1 or 3, each trigger event adds 2 half-words in the buffer (assuming TSAV = 0), first half-word being XPOS of ADC_XPOSR register then YPOS of ADC_YPOSR register. If TSAV/TSFREQ differs from 0, the data structure remains unchanged. Not all trigger events add data to the buffer. When TSMODE = 2, each trigger event adds 4 half-words to the buffer (assuming TSAV=0), first half-word being XPOS of ADC_XPOSR register followed by YPOS of ADC_YPOSR register and finally Z1 followed by Z2, both located in ADC_PRESSR register. When TAG is set (ADC_EMR), the CHNB field (4 most significant bit of the ADC_LCDR) register is set to 0 when XPOS is transmitted and set to 1 when YPOS is transmitted, allowing an easier post-processing of the buffer or better checking buffer integrity. In case 4-wire with pressure mode is selected, Z1 value is transmitted to the buffer along with tag set to 2 and Z2 is tagged with value 3. XSCALE and YSCALE (calibration values) are not transmitted to the buffer because they are supposed to be constant and moreover only measured at the very first start up of the controller or upon user request. There is no change in buffer structure whatever the value of PENDET bit configuration in ADC_TSMR register but it is recommended to use the pen detection function for buffer post-processing (refer to Pen Detection Status on page 1550).
1546
Figure 50-15. Buffer Structure when only touchscreen channels are enabled
0 1 0 1
0 0 0 0
trig.eventN
0 1
ADC_XPOSR ADC_YPOSR
BA + [(N-1) * 4]
trig.eventN
0 0
ADC_XPOSR ADC_YPOSR
0
DMA Buffer Structure
0 0 0 0 0 0 0 0
1 2 3 0 1 2 3
trig.event2
trig.eventN
0 1 2 3
trig.eventN BA + [(N-1) * 8] BA + [(N-1) * 8]+ 0x02 BA + [(N-1) * 8]+ 0x04 BA + [(N-1) * 8]+ 0x06
0 0 0 0
1547
50.7.10.3 Interleaved Channels When both classic ADC channels (CH4/CH5 up to CH12 are set in ADC_CHSR) and touchscreen conversions are required (TSMODE differs from 0 in ADC_TSMR register) the structure of the buffer differs according to TSAV and TSFREQ values. If TSFREQ differs from 0, not all events generate touchscreen conversions, therefore buffer structure is based on 2TSFREQ trigger events. Given a TSFREQ value, the location of touchscreen conversion results depends on TSAV value. When TSFREQ = 0, TSAV must equal 0. There is no change in buffer structure whatever the value of PENDET bit configuration in ADC_TSMR register but it is recommended to use the pen detection function for buffer post-processing (refer to Pen Detection Status on page 1550).
1548
Figure 50-16. Buffer Structure when classic ADC and touchscreen channels are interleaved
8
DMA Buffer Structure trig.event2
0
DMA Buffer Structure trig.event2
0 1 8 0 1
0 0 0 0 0
trig.eventN
trig.eventN
8 0 1
0 0 0
8
DMA Buffer Structure trig.event2 trig.event3
DMA Transfer Base Address (BA) BA + 0x02 BA + 0x04 BA + 0x06 BA + 0x08 BA + 0x0A BA + 0x0c BA + 0x0e
8 8 0 1
0 1 8 8 0
trig.event3 trig.event4
8 8 0 1
trig.event4
1 8
trig.eventN
trig.eventN
8 0
trig.eventN+1
BA + [(N-1) * 8]
trig.eventN+1
8 8 0 1
1 8
1549
50.7.10.4 Pen Detection Status If the pen detection measure is enabled (PENDET is set in ADC_TSMR register), the XPOS, YPOS, Z1, Z2 values transmitted to the buffer through ADC_LCDR register are cleared (including the CHNB field), if the PENS flag of ADC_ISR register is 0. When the PENS flag is set, XPOS, YPOS, Z1, Z2 are normally transmitted. Therefore, using pen detection together with tag function eases the post-processing of the buffer, especially to determine which touchscreen converted values correspond to a period of time when the pen was in contact with the screen. When the pen detection is disabled or the tag function is disabled, XPOS, YPOS, Z1, Z2 are normally transmitted without tag and no relationship can be found with pen status, thus post-processing may not be easy.
Figure 50-17. Buffer Structure with and without pen detection enabled
8
DMA buffer Structure trig.event2
0
DMA buffer Structure
0 1 8 0 1
0 0 0 0 0
PENS = 1
trig.eventN
trig.eventN
8 0
trig.eventN+1
PENS = 1
BA + 0x06
0 0 0 0 0 0
0 8 0 0
PENS = 0
PENS = 0
1550
ADC Mode Register on page 1555 ADC Channel Sequence 1 Register on page 1557 ADC Channel Sequence 2 Register on page 1558 ADC Channel Enable Register on page 1559 ADC Channel Disable Register on page 1560 ADC Extended Mode Register on page 1569 ADC Compare Window Register on page 1570 ADC Channel Gain Register on page 1571 ADC Channel Offset Register on page 1572 ADC Analog Control Register on page 1574 ADC Touchscreen Mode Register on page 1575 ADC Trigger Register on page 1580
1551
50.8
Table 50-8. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 ... 0x7C 0x80 - 0x90 0x94 0x98 - 0xAC 0xB0 0xB4 0xB8 0xBC 0xC0 0xC4 - 0xE0 0xE4 Control Register Mode Register Channel Sequence Register 1 Channel Sequence Register 2 Channel Enable Register Channel Disable Register Channel Status Register Reserved Last Converted Data Register Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Interrupt Status Register Reserved Reserved Overrun Status Register Extended Mode Register Compare Window Register Channel Gain Register Channel Offset Register Channel Data Register 0 Channel Data Register 1 ... Channel Data Register 11 Reserved Analog Control Register Reserved Touchscreen Mode Register Touchscreen X Position Register Touchscreen Y Position Register Touchscreen Pressure Register Trigger Register Reserved Write Protect Mode Register Register Name ADC_CR ADC_MR ADC_SEQR1 ADC_SEQR2 ADC_CHER ADC_CHDR ADC_CHSR ADC_LCDR ADC_IER ADC_IDR ADC_IMR ADC_ISR ADC_OVER ADC_EMR ADC_CWR ADC_CGR ADC_COR ADC_CDR0 ADC_CDR1 ... ADC_CDR11 ADC_ACR ADC_TSMR ADC_XPOSR ADC_YPOSR ADC_PRESSR ADC_TRGR ADC_WPMR Access Write-only Read-write Read-write Read-write Write-only Write-only Read-only Read-only Write-only Write-only Read-only Read-only Read-only Read-write Read-write Read-write Read-write Read-only Read-only ... Read-only Read-write Read-write Read-only Read-only Read-only Read-write Read-write Reset 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 ... 0x00000000 0x00000100 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
1552
Table 50-8. Register Mapping (Continued) Offset 0xE8 0xEC - 0xF8 0xFC Register Write Protect Status Register Reserved Reserved Name ADC_WPSR Access Read-only Reset 0x00000000
1553
1554
28
27
26 TRACKTIM
25
24
20
19
18 STARTUP
17
16
11
10
2 TRGSEL
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
Note:
The trigger selection can be performed only if TRGMOD=1,2 or 3 in ADC Trigger Register.
1555
TRACKTIM: Tracking Time Tracking Time = (TRACKTIM + 1) * ADCClock periods. TRANSFER: Transfer Period This field must be programmed with value 2. USEQ: Use Sequence Enable
Value 0 1 Name NUM_ORDER REG_ORDER Description Normal Mode: The controller converts channels in a simple numeric order depending only on the channel index. User Sequence Mode: The sequence respects what is defined in ADC_SEQR1 and ADC_SEQR2 registers and can be used to convert several times the same channel.
1556
23
22
15
14
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1557
23
22
15
14
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1558
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1559
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1560
1561
1562
EOCx: End of Conversion Interrupt Enable x XRDY: Touchscreen Measure XPOS Ready Interrupt Enable
YRDY: Touchscreen Measure YPOS Ready Interrupt Enable PRDY: Touchscreen Measure Pressure Ready Interrupt Enable EOCAL: End of Calibration Sequence DRDY: Data Ready Interrupt Enable GOVRE: General Overrun Error Interrupt Enable COMPE: Comparison Event Interrupt Enable PEN: Pen Contact Interrupt Enable NOPEN: No Pen Contact Interrupt Enable
0 = No effect. 1 = Enables the corresponding interrupt.
1563
EOCx: End of Conversion Interrupt Disable x XRDY: Touchscreen Measure XPOS Ready Interrupt Disable YRDY: Touchscreen Measure YPOS Ready Interrupt Disable PRDY: Touchscreen Measure Pressure Ready Interrupt Disable EOCAL: End of Calibration Sequence DRDY: Data Ready Interrupt Disable GOVRE: General Overrun Error Interrupt Disable COMPE: Comparison Event Interrupt Disable PEN: Pen Contact Interrupt Disable NOPEN: No Pen Contact Interrupt Disable
0 = No effect. 1 = Disables the corresponding interrupt.
1564
EOCx: End of Conversion Interrupt Mask x XRDY: Touchscreen Measure XPOS Ready Interrupt Mask YRDY: Touchscreen Measure YPOS Ready Interrupt Mask PRDY: Touchscreen Measure Pressure Ready Interrupt Mask EOCAL: End of Calibration Sequence DRDY: Data Ready Interrupt Mask GOVRE: General Overrun Error Interrupt Mask COMPE: Comparison Event Interrupt Mask PEN: Pen Contact Interrupt Mask NOPEN: No Pen Contact Interrupt Mask
0 = The corresponding interrupt is disabled. 1 = The corresponding interrupt is enabled.
1565
1566
1567
1568
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1569
15 7
14 6
13 5
12 4 LOWTHRES
11
10 LOWTHRES
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1570
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
The DIFFx mentioned in this table is described in the following register, ADC_COR.
1571
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1572
1573
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
1574
23 15 7
22 NOTSDMA 14 6
21 13 5 TSAV
20 12 4
This register can only be written if the WPEN bit is cleared in ADC Write Protect Mode Register on page 1581.
When TSMOD equals 01 or 10 (i.e. 4-wire mode), channel 0, 1, 2 and 3 must not be used for classic ADC conversions. When TSMOD equals 11 (i.e. 5-wire mode), channel 0, 1, 2, 3, and 4 must not be used.
1575
1576
15 7
14 6
13 5
12 4 XPOS
11
10 XPOS
XPOS: X Position
The Position measured is stored here. if XPOS = 0 or XPOS = XSIZE, the pen is on the border. When pen detection is enabled (PENDET set to 1 in ADC_TSMR register), XPOS is tied to 0 while there is no detection of contact on the touchscreen (i.e. when PENS bitfield is cleared in ADC_ISR register).
1577
15 7
14 6
13 5
12 4 YPOS
11
10 YPOS
YPOS: Y Position
The Position measured is stored here. if YPOS = 0 or YPOS = YSIZE, the pen is on the border. When pen detection is enabled (PENDET set to 1 in ADC_TSMR register), YPOS is tied to 0 while there is no detection of contact on the touchscreen (i.e. when PENS bitfield is cleared in ADC_ISR register).
1578
15 7
14 6
13 5
12 4 Z1
11
10 Z1
1579
TRGPER
23 22 21 20 19 18 17 16
TRGPER
15 14 13 12 11 10 9 8
TRGMOD
1580
1581
1582
51.
51.1
51.2
Embedded Characteristics
z z z z
Software Fuse Programming User Write Access for Fuse Part of Fuse can be Masked After Read 256 FUSE Bits:
z z z
192 Bits are dedicated to Users 3 Bits are dedicated to Special Functions The Fuse Controller can be hidden thanks to a SFR write-once bit. Please refer to the Special Function Registers (SFR) section of this datasheet for details.
1583
51.3
Block Diagram
Figure 51-1. Fuse Controller Block Diagram
Fuse States
Fuse States
Controls
1584
51.4
Functional Description
Clock
FUSE_SRx
outdated
up to date
RRQ
WS
RS
5.
1585
WSEL
XX
00
01
DATA
XX
Fuse[31:0]
Fuse[63:32]
WRQ
WS RS
1586
51.5
Table 51-3. Register Mapping Offset 0x00 0x04 0x08 0x0C 0x10 0x14 ... 0x2C 0x30 - 0xDC 0xE0 - 0xFC Register Fuse Control Register Fuse Mode Register Fuse Index Register Fuse Data Register Fuse Status Register 0 Fuse Status Register 1 ... Fuse Status Register 7 Reserved Reserved Name FUSE_CR FUSE_MR FUSE_IR FUSE_DR FUSE_SR0 FUSE_SR1 ... FUSE_SR7 Access Write-only Write-only Read-write Read-write Read-only Read-only ... Read-only Reset 0x00000000 0x00000000 0x00000000 ... 0x00000000
1587
1588
1589
1590
23
22
21
20 DATA
19
18
17
16
15
14
13
12 DATA
11
10
4 DATA
1591
51.5.5
Name:
Address: Access:
31
1592
52.
52.1
52.2
Embedded Characteristics
z z z z
Compliant with FIPS Publication 197, Advanced Encryption Standard (AES) 128-bit/192-bit/256-bit Cryptographic Key 12/14/16 Clock Cycles Encryption/Decryption Processing Time with a 128-bit/192-bit/256-bit Cryptographic Key Support of the Five Standard Modes of Operation Specified in the NIST Special Publication 800-38A, Recommendation for Block Cipher Modes of Operation - Methods and Techniques:
z z z z z
Electronic Code Book (ECB) Cipher Block Chaining (CBC) including CBC-MAC Cipher Feedback (CFB) Output Feedback (OFB) Counter (CTR)
z z z
8-bit, 16-bit, 32-bit, 64-bit and 128-bit Data Sizes Possible in CFB Mode Last Output Data Mode Allows Optimized Message Authentication Code (MAC) Generation Connection to DMA Optimizes Data Transfers for all Operating Modes
1593
52.3
Product Dependencies
52.3.2 Interrupt
The AES interface has an interrupt line connected to the Interrupt Controller. Handling the AES interrupt requires programming the Interrupt Controller before configuring the AES.
Table 52-1. Peripheral IDs Instance AES ID 43
1594
52.4
Functional Description
The Advanced Encryption Standard (AES) specifies a FIPS-approved cryptographic algorithm that can be used to protect electronic data. The AES algorithm is a symmetric block cipher that can encrypt (encipher) and decrypt (decipher) information. Encryption converts data to an unintelligible form called ciphertext. Decrypting the ciphertext converts the data back into its original form, called plaintext. The CIPHER bit in the AES Mode Register (AES_MR) allows selection between the encryption and the decryption processes. The AES is capable of using cryptographic keys of 128/192/256 bits to encrypt and decrypt data in blocks of 128 bits. This 128-bit/192-bit/256-bit key is defined in the Key Registers (AES_KEYWRx). The input to the encryption processes of the CBC, CFB, and OFB modes includes, in addition to the plaintext, a 128-bit data block called the initialization vector (IV), which must be set in the Initialization Vector Registers (AES_IVRx). The initialization vector is used in an initial step in the encryption of a message and in the corresponding decryption of the message. The Initialization Vector Registers are also used by the CTR mode to set the counter value.
ECB: Electronic Code Book CBC: Cipher Block Chaining OFB: Output Feedback CFB: Cipher Feedback
z z z z z
CFB8 (CFB where the length of the data segment is 8 bits) CFB16 (CFB where the length of the data segment is 16 bits) CFB32 (CFB where the length of the data segment is 32 bits) CFB64 (CFB where the length of the data segment is 64 bits) CFB128 (CFB where the length of the data segment is 128 bits)
CTR: Counter
The data pre-processing, post-processing and data chaining for the concerned modes are automatically performed. Refer to the NIST Special Publication 800-38A Recommendation for more complete information. These modes are selected by setting the OPMOD field in the AES Mode Register (AES_MR). In CFB mode, five data sizes are possible (8, 16, 32, 64 or 128 bits), configurable by means of the CFBS field in the mode register. (Section 52.6.2 AES Mode Register on page 1603). In CTR mode, the size of the block counter embedded in the module is 16 bits. Therefore, there is a rollover after processing 1 megabyte of data. If the file to be processed is greater than 1 megabyte, this file must be split into fragments of 1 megabyte. Prior to loading the first fragment into AES_IDATARx registers, the AES_IVRx registers must be cleared. For any fragment, after the transfer is completed and prior to transferring the next fragment, the AES_IVR0 register must be programmed so that the fragment number (0 for the first fragment, 1 for the second one, and so on) is written in the 16 MSB of the AES_IVR0 register.
1595
Write the Mode Register (AES_MR) with all required fields, including but not limited to SMOD and OPMOD. Write the 128-bit/192-bit/256-bit key in the Key Registers (AES_KEYWRx). Write the initialization vector (or counter) in the Initialization Vector Registers (AES_IVRx). The Initialization Vector Registers concern all modes except ECB. Set the bit DATRDY (Data Ready) in the AES Interrupt Enable register (AES_IER), depending on whether an interrupt is required or not at the end of processing. Write the data to be encrypted/decrypted in the authorized Input Data Registers (See Table 52-2).
Note:
z z
Table 52-2. Authorized Input Data Registers Operation Mode ECB CBC OFB 128-bit CFB 64-bit CFB 32-bit CFB 16-bit CFB 8-bit CFB CTR Input Data Registers to Write All All All All AES_IDATAR0 and AES_IDATAR1 AES_IDATAR0 AES_IDATAR0 AES_IDATAR0 All
Note: Note:
z z z
In 64-bit CFB mode, writing to AES_IDATAR2 and AES_IDATAR3 registers is not allowed and may lead to errors in processing. In 32-, 16- and 8-bit CFB modes, writing to AES_IDATAR1, AES_IDATAR2 and AES_IDATAR3 registers is not allowed and may lead to errors in processing. Set the START bit in the AES Control register AES_CR to begin the encryption or the decryption process. When processing completes, the DATRDY bit in the AES Interrupt Status Register (AES_ISR) raises. If an interrupt has been enabled by setting the DATRDY bit in AES_IER, the interrupt line of the AES is activated. When the software reads one of the Output Data Registers (AES_ODATARx), the DATRDY bit is automatically cleared.
52.4.2.2 Auto Mode The Auto Mode is similar to the manual one, except that in this mode, as soon as the correct number of Input Data registers is written, processing is automatically started without any action in the Control Register.
1596
1597
Write START bit in AES_CR (Manual mode) or Write AES_IDATARx register(s) (Auto mode)
DATRDY
If the user does not want to read the output data registers between each encryption/decryption, the DATRDY flag will not be cleared. If the DATRDY flag is not cleared, the user cannot know the end of the following encryptions/decryptions. 52.4.5.2 If LOD = 1 The DATRDY flag is cleared when at least one Input Data Register is written, so before the start of a new transfer (See Figure 52-2). No more Output Data Register reads are necessary between consecutive encryptions/decryptions.
Figure 52-2. Manual and Auto Modes with LOD = 1
Write START bit in AES_CR (Manual mode) or Write AES_IDATARx register(s) (Auto mode)
DATRDY
1598
Multiple Encryption or Decryption Processes BTC /channel 0 BTC /channel 1 Write accesses into AES_IDATARx Read accesses into AES_ODATARx Message fully processed (cipher or decipher) last block can be read
52.4.6.2 If LOD = 1 This mode is recommended to process AES CBC-MAC operating mode. The user must first wait for the DMA flag (BTC = Buffer Transfer Complete) to rise, then for DATRDY to ensure that the encryption/decryption is completed (see Figure 52-4). In this case, no receive buffers are required. The output data are only available on the Output Data Registers (AES_ODATARx).
Figure 52-4. DMA transfer with LOD = 1
Multiple Encryption or Decryption Processes Write accesses into AES_IDATARx BTC / channel 0 DATRDY Message fully transferred Message fully processed (cipher or decipher) MAC result can be read
Note:
1. Depending on the mode, there are other ways of clearing the DATRDY flag. See: Section 52.6.6 AES Interrupt Status Register.
Warning: In DMA mode, reading to the Output Data registers before the last data transfer may lead to unpredictable results.
1599
52.5
Security Features
Input Data Register written during the data processing when SMOD=IDATAR0_START Output Data Register read during data processing Mode Register written during data processing Output Data Register read during sub-keys generation Mode Register written during sub-keys generation Write-only register read access
The URAD bit and the URAT field can only be reset by the SWRST bit in the AES_CR control register.
1600
52.6
Table 52-5. Register Mapping Offset 0x00 0x04 0x08-0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38 0x3C 0x40 0x44 0x48 0x4C 0x50 0x54 0x58 0x5C 0x60 0x64 0x68 0x6C 0x70 - 0xFC Register Control Register Mode Register Reserved Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Interrupt Status Register Key Word Register 0 Key Word Register 1 Key Word Register 2 Key Word Register 3 Key Word Register 4 Key Word Register 5 Key Word Register 6 Key Word Register 7 Input Data Register 0 Input Data Register 1 Input Data Register 2 Input Data Register 3 Output Data Register 0 Output Data Register 1 Output Data Register 2 Output Data Register 3 Initialization Vector Register 0 Initialization Vector Register 1 Initialization Vector Register 2 Initialization Vector Register 3 Reserved Name AES_CR AES_MR AES_IER AES_IDR AES_IMR AES_ISR AES_KEYWR0 AES_KEYWR1 AES_KEYWR2 AES_KEYWR3 AES_KEYWR4 AES_KEYWR5 AES_KEYWR6 AES_KEYWR7 AES_IDATAR0 AES_IDATAR1 AES_IDATAR2 AES_IDATAR3 AES_ODATAR0 AES_ODATAR1 AES_ODATAR2 AES_ODATAR3 AES_IVR0 AES_IVR1 AES_IVR2 AES_IVR3 Access Write-only Read-write Write-only Write-only Read-only Read-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Read-only Read-only Read-only Read-only Write-only Write-only Write-only Write-only Reset 0x0 0x0 0x0 0x0 0x0 0x0 0x0
1601
23
22
21
20
19
18
17
16
15
14
13
12
11
10
SWRST
0
START
1602
23
22
21
20
19
18
17
16
CKEY
15 14 13 12
11 10
CFBS
9 8
LOD
7 6
OPMOD
5 4 3
KEYSIZE
2 1
SMOD
0
PROCDLY
CIPHER
Values which are not listed in the table must be considered as reserved. If a DMA transfer is used, 0x2 must be configured. Refer to Section 52.4.3 DMA Mode for more details.
Values which are not listed in the table must be considered as reserved.
1603
Values which are not listed in the table must be considered as reserved. For CBC-MAC operating mode, please set OPMOD to CBC and LOD to 1.
CKEY: Key
This field must be written with the value 0xE for the first AES_MR programming. For further programming of the AES_MR register, any value can be written, including that of 0xE. Note: CKEY field is write-only.
1604
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Enable URAD: Unspecified Register Access Detection Interrupt Enable
0: No effect. 1: Enables the corresponding interrupt.
1605
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Disable URAD: Unspecified Register Access Detection Interrupt Disable
0: No effect. 1: Disables the corresponding interrupt.
1606
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Mask URAD: Unspecified Register Access Detection Interrupt Mask
0: The corresponding interrupt is not enabled. 1: The corresponding interrupt is enabled.
1607
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAT
7 6 5 4
URAD
0
DATRDY
Only the last Unspecified Register Access Type is available through the URAT field. URAT field is reset only by the SWRST bit in the AES_CR control register.
1608
KEYW
23 22 21 20 19 18 17 16
KEYW
15 14 13 12 11 10 9 8
KEYW
7 6 5 4 3 2 1 0
KEYW
1609
IDATA
23 22 21 20 19 18 17 16
IDATA
15 14 13 12 11 10 9 8
IDATA
7 6 5 4 3 2 1 0
IDATA
1610
ODATA
23 22 21 20 19 18 17 16
ODATA
15 14 13 12 11 10 9 8
ODATA
7 6 5 4 3 2 1 0
ODATA
1611
IV
23 22 21 20 19 18 17 16
IV
15 14 13 12 11 10 9 8
IV
7 6 5 4 3 2 1 0
IV
1612
53.
53.1
53.2
Embedded Characteristics
z z z z z z z
Supports Single Data Encryption Standard (DES) and Triple Data Encryption Algorithm (TDEA or TDES) Compliant with FIPS Publication 46-3, Data Encryption Standard (DES) 64-bit Cryptographic Key for TDES Two-key or Three-key Algorithms for TDES 18-clock Cycles Encryption/Decryption Processing Time for DES 50-clock Cycles Encryption/Decryption Processing Time for TDES Support the Four Standard Modes of Operation specified in the FIPS Publication 81, DES Modes of Operation
z z z z
Electronic Code Book (ECB) Cipher Block Chaining (CBC) Cipher Feedback (CFB) Output Feedback (OFB)
z z z
8-bit, 16-bit, 32-bit and 64-bit Data Sizes Possible in CFB Mode Last Output Data Mode Allowing Optimized Message (Data) Authentication Code (MAC) Generation Connection to DMA Optimizes Data Transfers for all Operating Modes
1613
53.3
Product Dependencies
53.3.2 Interrupt
The TDES interface has an interrupt line connected to the Advanced Interrupt Controller (AIC). Handling the TDES interrupt requires programming the AIC before configuring the TDES. Peripheral IDs
Instance TDES ID 44
53.4
Functional Description
The Data Encryption Standard (DES) and the Triple Data Encryption Algorithm (TDES) specify FIPS-approved cryptographic algorithms that can be used to protect electronic data. The TDES bit in the TDES Mode Register (TDES_MR) is used to select either the single DES or the Triple DES mode. Encryption (enciphering) converts data to an unintelligible form called ciphertext. Decrypting (deciphering) the ciphertext converts the data back into its original form, called plaintext. The CIPHER bit in the TDES Mode Register is used to choose between encryption and decryption. A DES is capable of using cryptographic keys of 64 bits to encrypt and decrypt data in blocks of 64 bits. This 64-bit key is defined in the Key 1 Word Registers (TDES_KEY1WRx). A TDES key consists of three DES keys, which is also referred to as a key bundle. These three 64-bit keys are defined, respectively, in the Key 1, 2 and 3 Word Registers (TDES_KEY1WRx, TDES_KEY2WRx and TDES_KEY3WRx). In Triple DES mode (TDESMOD set to 1), the KEYMOD bit in the TDES Mode Register is used to choose between a twoand a three-key algorithm:
z z z z
In three-key encryption mode, the data is first encrypted with Key 1, then decrypted using Key 2 and then encrypted with Key 3. In three-key decryption mode, the data is decrypted with Key 3, then encrypted with Key 2 and then decrypted using Key 1. In two-key encryption mode, the data is first encrypted with Key 1, then decrypted using Key 2 and then encrypted with Key 1. In two-key decryption mode, the data is decrypted with Key 1, then encrypted with Key 2 and then decrypted using Key 1.
The input to the encryption processes of the CBC, CFB, and OFB modes includes, in addition to the plaintext, a 64-bit data block called the initialization vector (IV), which must be set in the Initialization Vector Registers (TDES_IVRx). The initialization vector is used in an initial step in the encryption of a message and in the corresponding decryption of the message.
1614
CFB16 (CFB where the length of the data segment is 16 bits) CFB32 (CFB where the length of the data segment is 32 bits) CFB64 (CFB where the length of the data segment is 64 bits)
The data pre-processing, post-processing and data chaining for each mode are automatically performed. Refer to the FIPS Publication 81 for more complete information. These modes are selected by setting the OPMOD field in the TDES Mode Register (TDES_MR). In CFB mode, four data sizes are possible (8, 16, 32 and 64 bits), configurable by means of the CFBS field in the mode register. (See TDES Mode Register on page 1621.). The OFB and CFB modes of operation are only available if 2-key mode is selected (KEYMOD=1 in TDES_MR register).
The Initialization Vector Registers concern all modes except ECB. Set the bit DATRDY (Data Ready) in the TDES Interrupt Enable register (TDES_IER), depending on whether an interrupt is required or not at the end of processing. Write the data to be encrypted/decrypted in the authorized Input Data Registers (See Table 53-1).
Table 53-1. Authorized Input Data Registers Operation Mode ECB CBC OFB CFB 64-bit CFB 32-bit CFB 16-bit CFB 8-bit Input Data Registers to Write All All All All TDES_IDATAR0 TDES_IDATAR0 TDES_IDATAR0
Note:
z z z
In 32-bit, 16-bit and 8-bit CFB mode, writing to TDES_IDATAR1 register is not allowed and may lead to errors in processing. Set the START bit in the TDES Control register TDES_CR to begin the encryption or the decryption process. When the processing completes, the bit DATRDY in the TDES Interrupt Status Register (TDES_ISR) raises. If an interrupt has been enabled by setting the bit DATRDY in TDES_IER, the interrupt line of the TDES is activated. When the software reads one of the Output Data Registers (TDES_ODATARx), the DATRDY bit is automatically cleared.
1615
53.4.2.2 Auto Mode The Auto Mode is similar to Manual Mode, except that, as soon as the correct number of Input Data registers is written, processing is automatically started without any action in the control register. 53.4.2.3 DMA Mode The DMA Controller can be used in association with the TDES to perform an encryption/decryption of a buffer without any action by the software during processing. The SMOD field of TDES_MR must be set to 0x2 and the DMA must be configured with non-incremental addresses. The start address of any transfer descriptor must be set in TDES_IDATAR0 register. The DMA chunk size configuration depends on the TDES mode of operation and is listed in Table 53-2 "DMA Data Transfer Type for the Different Operation Modes". When writing data to TDES with the first DMA channel, data will be fetched from a memory buffer (source data). It is recommended to configure the size of source data to words even for CFB modes. On the contrary, the destination data size depends on the mode of operation. When reading data from the TDES with the second DMA channel, the source data is the data read from TDES and data destination is the memory buffer. In this case, source data size depends on the TDES mode of operation and is listed in Table 53-2.
Table 53-2. DMA Data Transfer Type for the Different Operation Modes Operation Mode ECB CBC OFB CFB 64-bit CFB 32-bit CFB 16-bit CFB 8-bit Chunk Size 1 1 1 1 1 1 1 Destination/Source Data Transfer Type Word Word Word Word Word Half-word Byte
1616
Write START bit in TDES_CR (Manual mode) or Write TDES_IDATARx register(s) (Auto mode)
DATRDY
If the user does not want to read the output data registers between each encryption/decryption, the DATRDY flag will not be cleared. If the DATRDY flag is not cleared, the user will not be informed of the end of the encryptions/decryptions that follow. If LOD = 1: The DATRDY flag is cleared when at least one Input Data Register is written, before the start of a new transfer. See Figure 53-2. No further Output Data Register reads are necessary between consecutive encryptions/decryptions.
Figure 53-2. Manual and Auto Modes with LOD = 1
Write START bit in TDES_CR (Manual mode) or Write TDES_IDATARx register(s) (Auto mode)
DATRDY
If LOD = 0
This mode may be used for all TDES operating modes except CBC-MAC where LOD = 1 mode is recommended. The end of the encryption/decryption is notified by the end of DMA transfer associated to TDES_ODATARx registers (see Figure 53-3). Two DMA channels are required, one for writing message blocks to TDES_IDATARx registers and the other one to get back the processed from TDES_ODATARx registers.
Figure 53-3. DMA transfer with LOD = 0
Multiple Encryption or Decryption Processes Write accesses into TDES_IDATARx BTC /channel 0 Read accesses into TDES_ODATARx BTC /channel 1 Message fully processed (cipher or decipher) last block can be read
1617
If LOD = 1
This mode is recommended to process TDES CBC-MAC operating mode. The user must first wait for the DMA flag (BTC = Buffer Transfer Complete) to rise, then for DATRDY to ensure that the encryption/decryption is completed (see Figure 53-4). In this case, no receive buffers are required. The output data is only available on the Output Data Registers (TDES_ODATARx).
Figure 53-4. DMA transfer with LOD = 1
Multiple Encryption or Decryption Processes Write accesses into TDES_IDATARx BTC / channel 0 DATRDY Message fully transferred Message fully processed (cipher or decipher) MAC result can be read
Note:
Depending on the mode, there are other ways of clearing the DATRDY flag. See: Section 53.5.6 TDES Interrupt Status Register.
Warning: In DMA mode, reading to the Output Data registers before the last data transfer may lead to unpredictable results.
1618
53.5
Table 53-4. Register Mapping Offset 0x00 0x04 0x08-0x0C 0x10 0x14 0x18 0x1C 0x20 0x24 0x28 0x2C 0x30 0x34 0x38-0x3C 0x40 0x44 0x48-0x4C 0x50 0x54 0x58-0x5C 0x60 0x64 0x68 - 0xFC Register Control Register Mode Register Reserved Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Interrupt Status Register Key 1 Word Register 0 Key 1 Word Register 1 Key 2 Word Register 0 Key 2 Word Register 1 Key 3 Word Register 0 Key 3 Word Register 1 Reserved Input Data Register 0 Input Data Register 1 Reserved Output Data Register 0 Output Data Register 1 Reserved Initialization Vector Register 0 Initialization Vector Register 1 Reserved Name TDES_CR TDES_MR TDES_IER TDES_IDR TDES_IMR TDES_ISR TDES_KEY1WR0 TDES_KEY1WR1 TDES_KEY2WR0 TDES_KEY2WR1 TDES_KEY3WR0 TDES_KEY3WR1 TDES_IDATAR0 TDES_IDATAR1 TDES_ODATAR0 TDES_ODATAR1 TDES_IVR0 TDES_IVR1 Access Write-only Read-write Write-only Write-only Read-only Read-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Write-only Read-only Read-only Write-only Write-only Reset 0x2 0x0 0x0000001E 0x0 0x0
1619
23
22
21
20
19
18
17
16
15
14
13
12
11
10
SWRST
0
START
1620
23
22
21
20
19
18
17
16
15
14
13
12
11
10 9
CFBS
8
LOD
7
6 5
OPMOD
4
2 1
SMOD
0
KEYMOD
TDESMOD
CIPHER
Values which are not listed in the table must be considered as reserved. If a DMA transfer is used, 0x2 must be configured. Refer to Section 53.4.3.2 DMA Mode for more details.
For CBC-MAC operating mode, please set OPMOD to CBC and LOD to 1. The OFB and CFB modes of operation are only available if 2-key mode is selected (KEYMOD=1).
1621
1622
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Enable URAD: Unspecified Register Access Detection Interrupt Enable
0: No effect. 1: Enables the corresponding interrupt.
1623
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Disable URAD: Unspecified Register Access Detection Interrupt Disable
0: No effect. 1: Disables the corresponding interrupt.
1624
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Mask URAD: Unspecified Register Access Detection Interrupt Mask
0: The corresponding interrupt is not enabled. 1: The corresponding interrupt is enabled.
1625
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAT
7 6 5 4
URAD
0
DATRDY
Only the last Unspecified Register Access Type is available through the URAT field. URAT field is reset only by the SWRST bit in the TDES_CR control register.
1626
KEY1W
23 22 21 20 19 18 17 16
KEY1W
15 14 13 12 11 10 9 8
KEY1W
7 6 5 4 3 2 1 0
KEY1W
1627
KEY2W
23 22 21 20 19 18 17 16
KEY2W
15 14 13 12 11 10 9 8
KEY2W
7 6 5 4 3 2 1 0
KEY2W
1628
KEY3W
23 22 21 20 19 18 17 16
KEY3W
15 14 13 12 11 10 9 8
KEY3W
7 6 5 4 3 2 1 0
KEY3W
1629
IDATA
23 22 21 20 19 18 17 16
IDATA
15 14 13 12 11 10 9 8
IDATA
7 6 5 4 3 2 1 0
IDATA
1630
ODATA
23 22 21 20 19 18 17 16
ODATA
15 14 13 12 11 10 9 8
ODATA
7 6 5 4 3 2 1 0
ODATA
1631
IV
23 22 21 20 19 18 17 16
IV
15 14 13 12 11 10 9 8
IV
7 6 5 4 3 2 1 0
IV
1632
54.
54.1
54.2
Embedded Characteristics
z z z
Supports Secure Hash Algorithm (SHA1, SHA224, SHA256, SHA384, SHA512) Compliant with FIPS Publication 180-2 Configurable Processing Period:
z z
85 Clock Cycles to get a fast SHA1 runtime, 88 clock cycles for SHA384,SHA512 or 209 Clock Cycles for Maximizing Bandwidth of Other Applications 72 Clock Cycles to get a fast SHA224, SHA256 runtime or 194 Clock Cycles for Maximizing Bandwidth of Other Applications
z z
Connection to DMA Channel Capabilities Optimizes Data Transfers Double Input Buffer Optimizes Runtime
54.3
Product Dependencies
54.3.2 Interrupt
The SHA interface has an interrupt line connected to the Interrupt Controller. Handling the SHA interrupt requires programming the interrupt controller before configuring the SHA.
Table 54-1. Peripheral IDs Instance SHA ID 42
1633
54.4
Functional Description
The Secure Hash Algorithm (SHA) module requires a padded message according to FIPS180-2 specification. The first block of the message must be indicated to the module by a specific command. The SHA module produces a N-bit message digest each time a block is written and processing period ends. N is 160 for SHA1, 224 for SHA224, 256 for SHA256, 384 for SHA384, 512 for SHA512.
Set the bit DATRDY (Data Ready) in the SHA Interrupt Enable Register (SHA_IER), depending on whether an interrupt is required or not at the end of processing. For the first block of a message, the FIRST command must be set by writing a 1 into the corresponding bit of the Control Register (SHA_CR). For the other blocks, there is nothing to write in this Control Register. Write the block to be processed in the Input Data Registers. Set the START bit in the SHA Control Register SHA_CR to begin the processing. When the processing completes, the bit DATRDY in the SHA Interrupt Status Register (SHA_ISR) raises. If an interrupt has been enabled by setting the bit DATRDY in SHA_IER, the interrupt line of the SHA is activated. Repeat the write procedure for each block, start procedure and wait for the interrupt procedure up to the last block of the entire message. Each time the start procedure is complete, the DATRDY flag is cleared. After the last block is processed (DATRDY flag is set, if an interrupt has been enabled by setting the bit DATRDY in SHA_IER, the interrupt line of the SHA is activated), read the message digest in the Output Data Registers. The DATRDY flag is automatically cleared when reading the SHA_IODATARx registers.
1634
54.4.4.2 Auto Mode Auto Mode is similar to Manual Mode, except that in this mode, as soon as the correct number of Input Data Registers is written, processing is automatically started without any action in the control register. 54.4.4.3 DMA Mode The DMA can be used in association with the SHA to perform the algorithm on a complete message without any action by the software during processing. The SMOD field of the SHA_MR must be set to 0x2. The DMA must be configured with non incremental addresses. The start address of any transfer descriptor must be set to point to the SHA_IDATAR0 register. The DMA chunk size must be set to transfer, for each trigger request, 16 words of 32 bits when processing SHA1/SHA256 algorithms or 32 words of 32 bits when SHA384/SHA512 are being used.
Figure 54-1. Enable DMA Channels
Message Processing (Multiple Block) BTC/ channel 0 DATRDY Message fully transferred Message fully processed SHA result can be read Write accesses into SHA_IDATARx
54.4.4.4 SHA Register Endianism In ARM processor based products, the AHB bus and processors manipulate data in Little Endian form. However, following the protocol of FIPS 180-2 specification, data is collected, processed and stored by the SHA module in a Big Endian form. The data presented to the SHA module (written to SHA_IDATAxR) must be in Little Endian form. The data read from the SHA module (read from SHA_IODATAxR) will be in Little Endian form. The SHA interface automatically converts into Big Endian format words that are presented into Little Endian. Likewise, the SHA interface returns hash results into Little Endian format even if the internal processing is Big Endian. Managing how data is presented to the SHA registers should be managed by software. As a clarification of this process consider the following example. If the first 64 bits of a message (according to FIPS180-2, i.e. Big Endian format) to be processed is 0xcafe_dede_0123_4567 then the SHA_IDATA0R and SHA_IDATA1R registers should be written with the following pattern:
z z
In a Little Endian system, the message starting with pattern 0xcafe_dede_0123_4567 will be stored into memories as follows:
z z z z
0xca stored at initial offset (for example 0x00), then 0xfe stored at initial offset + 1 (i.e. 0x01), 0xde stored at initial offset + 2 (i.e. 0x02), 0xde stored at initial offset +3 (i.e. 0x03).
1635
Lets assume the message is received through a serial to parallel communication channel, the first received character is 0xca and stored at first memory location (initial offset), second octet being 0xfe is stored at initial offset + 1. When reading on a 32-bit Little Endian system bus, the first word read back from system memory is 0x_dede_feca. When the SHA_IODATAxR registers are read, the hash result is organized in Little Endian format, allowing system memory storage in the same format as the message. Taking an example from the FIPS 180-2 specification Appendix B.1, the endianism conversion can be observed. For this example, the 512-bit message is: 0x6162638000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000018 and the expected SHA-256 result is: 0xba7816bf_8f01cfea_414140de_5dae2223_b00361a3_96177a9c_b410ff61_f20015ad If the message has not already been stored in the system memory, the first step is to convert the input message to Little Endian before writing to the SHA_IDATAxR registers. This would result in a write of: SHA_IDATA0R = 0x80636261...... SHA_IDATA15R = 0x18000000 The data in the output message digest registers, SHA_IODATAxR, contain SHA_IODATAxR = 0xbf1678ba... SHA_IODATA7R = 0xad1500f2 which is the Little Endian format of 0xba7816bf,..., 0xf20015ad. Reading SHA_IODATA0R to SHA_IODATA1R and storing into a Little Endian memory system forces hash results to be stored in the same format as the message. When the output message is read, the user can convert back to Big Endian for a resulting message value of: 0xba7816bf_8f01cfea_414140de_5dae2223_b00361a3_96177a9c_b410ff61_f20015ad
Input Data Register written during the data processing in DMA mode Input/Output Data Register read during the data processing Mode Register written during the data processing Write-only register read access
The URAD bit and the URAT field can only be reset by the SWRST bit in the SHA_CR control register.
1636
54.5
Table 54-2. Register Mapping Offset 0x00 0x04 0x08-0x0C 0x10 0x14 0x18 0x1C 0x20-0x3C 0x40 ... 0x7C 0x80 ... 0x9C 0xA0 ... 0xBC 0x94-0xFC Register Control Register Mode Register Reserved Interrupt Enable Register Interrupt Disable Register Interrupt Mask Register Interrupt Status Register Reserved Input Data 0 Register ... Input Data 15 Register Input/Output Data 0 Register ... Input/Output Data 7 Register Input/Output Data 8 Register ... Input/Output Data 15 Register Reserved SHA_IDATAR0 ... SHA_IDATAR15 SHA_IODATAR0 ... SHA_IODATAR7 SHA_IODATAR8 ... SHA_IODATAR15 Write-only ... Write-only Read-write ... Read-write Read-write ... Read-write Name SHA_CR SHA_MR SHA_IER SHA_IDR SHA_IMR SHA_ISR Access Write-only Read-write Write-only Write-only Read-only Read-only Reset 0x0000100 0x0 0x0 ... 0x0 ... 0x0 0x0 ... 0x0
1637
23
22
21
20
19
18
17
16
15
14
13
12
11
10
SWRST
0
FIRST
START
1638
23
22
21
20
19
18
17
16
15
14
13
12
11
10
DUALBUFF
8
7 6 5
3 2
ALGO
1 0
PROCDLY
SMOD
Values which are not listed in table must be considered as reserved. If a DMA transfer is used, either 0x1 or 0x2 must be configured. Refer to DMA Mode on page 1635 for more details.
When SHA1 algorithm is processed, runtime period is either 85 or 209 clock cycles. When SHA256 or SHA224 algorithm is processed, runtime period is either 72 or 194 clock cycles. When SHA384 or SHA512 algorithm is processed, runtime period is either 88 or 209 clock cycles.
1639
1640
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Enable URAD: Unspecified Register Access Detection Interrupt Enable
0: No effect. 1: Enables the corresponding interrupt.
1641
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Disable URAD: Unspecified Register Access Detection Interrupt Disable
0: No effect. 1: Disables the corresponding interrupt.
1642
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAD
0
DATRDY
DATRDY: Data Ready Interrupt Mask URAD: Unspecified Register Access Detection Interrupt Mask
0: The corresponding interrupt is not enabled. 1: The corresponding interrupt is enabled.
1643
23
22
21
20
19
18
17
16
15
14
13
12
11
10
URAT
7 6 5 4
URAD
0
DATRDY
Only the last Unspecified Register Access Type is available through the URAT field. URAT field is reset only by the SWRST bit in the SHA_CR control register.
1644
IDATA
23 22 21 20 19 18 17 16
IDATA
15 14 13 12 11 10 9 8
IDATA
7 6 5 4 3 2 1 0
IDATA
1645
IODATA
23 22 21 20 19 18 17 16
IODATA
15 14 13 12 11 10 9 8
IODATA
7 6 5 4 3 2 1 0
IODATA
1646
55.
55.1
Electrical Characteristics
Absolute Maximum Ratings
Table 55-1. Absolute Maximum Ratings* Operating Temperature (Industrial)..............-40 C to + 85 C Junction Temperature..................................................125C Storage Temperature.................................-60C to + 150C Voltage on Input Pins with Respect to Ground.....-0.3V to VDDIO+0.3V(+ 4V max) Maximum Operating Voltage (VDDCORE, VDDPLLA, VDDUTMIC)...........................1.5V (VDDIODDR).................................................................2.0V (VDDIOM, VDDIOPx, VDDUTMII, VDDOSC, VDDANA and VDDBU)..................................................4.0V Total DC Output Current on all I/O lines...................350 mA *NOTICE: Stresses beyond those listed under Absolute Maximum Ratings may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
1647
55.2
DC Characteristics
The following characteristics are applicable to the operating temperature range: TA = -40C to +85C, unless otherwise specified.
Table 55-2. DC Characteristics
Symbol VVDDCORE VVDDCORErip VVDDUTMIC VVDDUTMII VVDDBU VVDDBUrip VVDDPLLA VVDDPLLArip VVDDOSC VVDDOSCrip VVDDIOM VVDDIODDR VVDDIOP0 VVDDIOP1 VVDDANA VIL Parameter DC Supply Core VDDCORE ripple DC Supply UDPHS and UHPHS UTMI+ Core DC Supply UDPHS and UHPHS UTMI+ Interface DC Supply Backup VDDBU ripple DC Supply PLLA VDDPLLA ripple DC Supply Oscillator VDDOSC ripple DC Supply EBI I/Os DC Supply SDRAM I/Os DC Supply Peripheral I/Os DC Supply Peripheral I/Os DC Supply Analog Input Low-level Voltage VVDDIO in 3.3V range VVDDIO in 1.8V range Input High-level Voltage VVDDIO in 3.3V range VVDDIO in 1.8V range All PIO lines VVDDIOx in 3.3V range All PIO lines VVDDIOx in 1.8V range Output Low-level Voltage Output High-level Voltage IO Max IO Max All PIO lines VVDDIOx in 1.8V range All PIO lines NTRST and NRST VVDDIOx in 3.3V range VVDDIO - 0.4 100 160 310 k 45 70 130 DDR2 or LP-DDR usage LP-DDR2 usage 1.65/3.0 1.7 1.14 1.65 1.65 3.0 -0.3 -0.3 2 0.7 x VVDDIO 0.34 V 0.21 0.4 V V 3.3 1.8/3.3 1.8 1.2 1.65 1.08 1.2 1.08 3.0 1.65 1.2 3.3 Conditions Min 1.08 Typ 1.2 Max 1.32 20 1.32 3.6 3.6 30 1.32 10 3.6 30 1.95/3.6 1.95 1.30 3.6 3.6 3.6 0.8 V 0.3 x VVDDIO VVDDIO + 0.3 VVDDIO + 0.3 V Units V mVrms V V V mVrms V mVrms V mVrms V V V V V
VIH
VHYS
VOL VOH
RPULL
1648
5 (LO_DRIVE)
16 (ME_DRIVE)
22 (HI_DRIVE)
30 13
RSERIAL
Serial Resistor
ISC
Static Current
1649
55.3
Power Consumption
z z z z
Typical power consumption of PLLs, Slow Clock and Main Oscillator Power consumption of power supply in four different modes: Active, Idle, Ultra Low-power and Backup Power consumption by peripheral: calculated as the difference in current measurement after having enabled then disabled the corresponding clock Software used for power consumption measurements: DHRYSTONE
VDDIOM = 1.8V VDDIOP0 and 1= 3.3V VDDPLLA = 1.2V VDDCORE = 1.2V VDDBU = 3.3V TA = 25 C There is no consumption on the I/Os of the device
1650
Table 55-3 represents the power consumption estimated on the power supplies.
Table 55-3. Power Consumption in Active Mode Mode Conditions ARM Core clock is 400 MHz. Active MCK is 133 MHz. All peripheral clocks activated. Onto AMP2. ARM Core clock is 498 MHz. MCK is 166 MHz. Active All peripheral clocks activated. VDDCORE = 1.25V. Onto AMP2. ARM Core clock is 536 MHz. MCK is 134 MHz. Active All peripheral clocks activated. VDDCORE = 1.25V. Onto AMP2. 110 mA 106 mA 88 mA Consumption Unit
Table 55-4. Power Consumption by Peripheral in Active Mode Peripheral PIO Controller USART UHPHS UDPHS ADC TWI SPI PWM HSMCI SSC Timer Counter Channels DMA SMD ISI EMAC GEMAC LCDC CAN SHA AES TDES TRNG Consumption 4.5 2.0 22.5 24.5 3.0 1.0 2.5 6.0 13.5 3.0 2.5 27.5 5.0 4.0 10.0 21.5 13.0 4.5 4.0 2.0 1.0 0.5 A/MHz(1) Unit
Note:
1.
Reference frequency is the peripheral frequency. It can be a division (1,2,4,8) of MCK. Please refer to the PMC section for more details.
1651
In order to reduce power consumption, each Peripheral Clock has been timed to an optimum value. The peripheral frequency is programmable with the help of a divider in the PMC_PCR register. Programming a divider giving higher frequency than required will lead to an unpredictable behavior. Table Table 55-5 gives the maximum frequency values for each peripheral.
Table 55-5. Maximum Values for each Peripheral Peripheral name DBGU PIT SMD USART[3..0] UART[1..0] TWI[2..0] HSMCI[2..0] SPI[1..0] TC[1..0] PWM ADC SSC[1..0] CAN[1..0] Description Debug Unit Interrupt Periodic Interval Timer Interrupt SMD Soft Modem USART 0 UART Two-wire Interface High Speed Multimedia Card Interface 0 Serial Peripheral Interface 0 Timer Counter Pulse Width Modulation Controller Touch Screen ADC Controller Synchronous Serial Controller CAN Controller 0 Max Frequency 66 MHz 133 MHz 24 MHz 66 MHz 66 MHz 66 MHz 133 MHz 133 MHz 66 MHz 133 MHz 66 MHz 66 MHz 66 MHz
The system will restart as for a reset event. 55.3.3.2 Idle Mode The purpose of Idle Mode is to optimize power consumption of the device versus response time. In this mode, only the core clock is stopped. The peripheral clocks, including the DDR Controller clock, can be enabled. The current consumption in this mode is application dependent. This mode is entered via the Wait for Interrupt (WFI) instruction and PCK disabling. The processor can be awakened from an interrupt. The system will resume where it was before entering in WFI mode.
1652
55.3.3.3 Ultra Low-power Mode The purpose of Ultra Low-power Mode is to reduce the power consumption of the device to the minimum without disconnecting VDDCORE power supply. It is a combination of very low frequency operations and Idle Mode. This mode is entered via the following steps: 1. 2. Set the DDR in Self Refresh Mode Reduce the system clock (PCK and MCK) to the minimum with the help of the PMC:
z z z z
PCK and MCK configuration is to be defined regarding the expected power consumption and wake-up time. Please refer to Table 55-6 for details PLLs are disabled. CKGR_PLLAR (eventually CKGR_PLLBR) is set to 0x3F00. CKGR_UCKR is set to 0. Main Oscillator is disabled. MOSCXTEN is set to 0 in CKGR_MOR. Eventually 12 MHz RC Oscillator is disabled. MOSCRCEN is set to 0 in CKGR_MOR.
3/ Enter in Wait for Interrupt (WFI) mode and disable the PCK clock. The processor can be awakened from an interrupt. Once revived, the system must reprogram the system clocks (OSC, PLL, PCK, MCK, DDRCK) to recover the previous state. Data is maintained in the external memory. 55.3.3.4 Low-power Mode Summary Table The modes detailed above are the main low-power modes. Each part can be set to on or off separately and wake-up sources can be individually configured. Table 55-6 below shows a summary of the configurations of the low-power modes.
Table 55-6. Low-power Mode Configuration Summary
32K RC, 12 MHz RC, 32 kHz Osc, RTC, Backup Registers, Core POR VDDCORE Memory (Backup Region) Regulator Peripherals OFF Backup ON OFF (Not powered)
Mode
Mode Entry
PIO State Potential while in Wake-Up Core at Low- power PIO State at Sources Wake Up Mode Wake Up Reset Inputs with pull-ups
Idle
ON
ON
Any interrupt
Ultra Lowpower
ON
ON
1780 A @ 12 MHz 3.9 s @ 12 MHz Any interrupt Clocked back at previous one 520 A @ 750 kHz Previous state saved Unchanged 455 A @ 187 kHz 432 A @ 32 kHz 429 A @ 512 Hz 60 s @ 750 kHz 230 s @ 187 kHz 1.4 ms @ 32 kHz 89 ms @ 512 Hz
Notes: 1. When considering wake-up time, the time required to start the PLL is not taken into account. Once started, the device works with the Main Oscillator. The user has to add the PLL start-up time if it is needed in the system. The wake-up time is defined as the time taken for wake up until the first instruction is fetched. 2. The external loads on PIOs are not taken into account in the calculation. 3. Total Current consumption. 4. Depends on MCK frequency.
1653
55.4
Clock Characteristics
Note:
1. For DDR2 usage only, there are no limitations to LP-DDR and LP-DDR2.
Units
166
Note:
1654
55.5
Table 55-9. Main Oscillator Characteristics Symbol Parameter Conditions FREQ = 00, 01(2) Freq Operating Frequency FREQ = 10 FREQ = 11 FREQ = 00, 01 CLOAD(1) CLEXT(1) CPARA Load Capacitance FREQ = 10 FREQ = 11 External Load Capacitance Parasitic Load Capacitance Duty Cycle tST IDDST PON IDD ON Startup Time Standby Current Consumption Standby mode FREQ = 00, 01 Drive Level FREQ = 10 FREQ = 11 Current Dissipation @ 12 MHz 0.5 0.6 40 0.7 0.8 60 2 0.1 150 300 400 1 mA W Min 8 20 44 12.5 4 4 Typ Max 16 24 48 17.5 8 6 pF pF % ms A pF MHz Unit
Note:
1. The external capacitors value can be determined by using the following formula: CLEXT = (2*CLOAD) - CBOARD - CROUTING - CPACKAGE - (CPARA*2), where CLEXT: external capacitor value which must be soldered from XIN to GND and XOUT to GND, CLOAD: crystal targeted load. Please refer to CLOAD parameter in the electrical specification, CBOARD: external calculated (or measured) parasitic value due to board, CROUTING: parasitic capacitance due to internal chip routing, typically 1.5 pF, CPACKAGE: parasitic capacitance due to package and bonding, typically 0.75 pF, CPARA: internal parasitic load due to internal structure. 2. FREQ field defines the input frequency for the UTMI and the Main Oscillator. It is defined in the UTMI Clock Trimming Register (SFR_UTMICKTRIM) located in the SFR section. Take care to select the correct FREQ value, this has a direct influence on the USB frequency.
Figure 55-2. Main Oscillator Schematics
XIN
CLEXT
CLEXT
1655
Min
Typ
Unit
5 1.3 2
9 2 3.2 7 1 1.3 pF fF
FREQ = 10 with ESRmax = 150 FREQ = 11 with ESRmax = 100 FREQ = 00, 01
CS
Shunt Capacitance
Note:
1. FREQ field defines the input frequency for the UTMI and the Main Oscillator. It is defined in UTMI Clock Trimming Register, located in SFR section. Take care to select the correct FREQ value, this has a direct influence on USB frequency.
Conditions
Min
Max 50
Units MHz ns
20 0.4 x tCPXIN 0.4 x tCPXIN 0.6 x tCPXIN 0.6 x tCPXIN 25 500 VDDOSC VDDOSC
ns ns pF k V
Note:
1. These characteristics apply only when the Main Oscillator is in bypass mode (i.e. when MOSCEN = 0 and OSCBYPASS = 1) in the CKGR_MOR register. See PMC Clock Generator Main Oscillator Register in the PMC section.
1656
55.6
Table 55-12. 12 MHz RC Oscillator Characteristics Symbol F0 Duty IDD ON tON IDD STDBY Parameter Nominal Frequency Duty Cycle Power Consumption Oscillation Startup time Standby consumption Conditions Min 11.4 45 Typ 12 50 220 10 22 Max 12.6 55 Units MHz % A s A
55.7
Table 55-13. 32 kHz Oscillator Characteristics Symbol 1/(tCP32KHz) CCRYSTAL32 CLEXT32(2) Parameter Crystal Oscillator Frequency Load Capacitance External Load Capacitance Duty Cycle RS = 50 k(1) tST Startup Time RS = 100 k(1) PON Drive Level CCRYSTAL32 = 6 pF CCRYSTAL32 = 12.5 pF CCRYSTAL32 = 6 pF CCRYSTAL32 = 12.5 pF Crystal @ 32.768 kHz CCRYSTAL32 = 6 pF CCRYSTAL32 = 12.5 pF 40 6 6 19 50 60 400 900 600 1200 0.2 Conditions Min Typ 32 768 12.5 Max Unit kHz pF pF pF % ms ms ms ms W
Notes: 1. RS is the equivalent series resistance. 2. CLEXT32 is determined by taking into account internal, parasitic and package load capacitance.
Figure 55-3. 32 kHz Oscillator Schematics
XIN32
XOUT32
GNDBU
CCRYSTAL32
CLEXT32
CLEXT32
1657
Min
Typ 50
Max 100 3 2
Unit k fF pF A A A A nA
RS = 100 k
(1)
Conditions
Min
Max 44
Units kHz s s s ns ns
22 11 11 400 400 6 4 VDDBU -0.3 0.7 x VVDDBU VDDBU 0.3 x VVDDBU VVDDBU + 0.3
pF M V V V
Note:
1. These characteristics apply only when the 32768 kHz Oscillator is in bypass mode (i.e. when RCEN = 0, OSC32EN = 0, OSCSEL = 1 and OSC32BYP = 1) in the SCKCR register. See Slow Clock Selection in the PMC section.
1658
55.8
Table 55-16. 32 kHz RC Oscillator Characteristics Symbol 1/(tCPRCz) tST IDD ON IDD STDBY
55.9
PLL Characteristics
Parameter Output Frequency Input Frequency Current Consumption Startup Time Active mode @ 800 MHz Standby mode Conditions VDDPLLA[1.08V, 1.32V] VDDPLLA[1.2V, 1.32V] Min 400 400 8 13 1 25 Typ Max 800 1000 50 14 200 100 Unit MHz MHz mA A s
in LS or FS Mode
15
1659
IVDDUTMII
IVDDUTMIC
Note:
Note:
1660
Note:
Use IBCTL = 00 for Sampling Frequency below 500 kHz and IBCTL = 01 between 500 kHz and 1 MHz.
Table 55-23. Channel Conversion Time and ADC Clock Symbol fADC tCP_ADC fS Parameter ADC Clock Frequency ADC Clock Period Sampling Frequency From OFF Mode to Normal Mode: - Voltage Reference OFF - Analog Circuitry OFF tSTART-UP ADC Startup time From Standby Mode to Normal Mode: - Voltage Reference ON - Analog Circuitry OFF tTRACKTIM tCONV tSETTLE Track and Hold Time Conversion Time Settling Time Settling time to change offset and gain 200 See Section 55.11.1.1 Track and Hold Time versus Source Output Impedance for more details 4 8 12 20 30 Conditions Min 1 50 Typ Max 20 1000 1 40 s Units MHz ns MHz
160 20
ns TCP_ADC ns
Table 55-24. External Voltage Reference Input Parameter ADVREF Input Voltage Range, 12-bit ADVREF Current ADVREF Input DC impedance 6 8 Conditions 2.4V < VVDDIN < 3.6V Min 2.4 Typ Max VDDANA 600 10 Units V A k
1661
Gain = 1, LSB = (3.0V / 4096) = 732 uV Gain = 2, LSB = (1.5V / 4096) = 366 uV Gain = 4, LSB = (750mV / 4096) = 183 uV Gain = 0.5, LSB = (6.0V / 4096) = 1465 uV Gain = 1, LSB = (3.0V / 4096) = 732 uV Gain = 4, LSB = (750mV / 4096) = 366 uV
Table 55-25. INL, DNL, 12-bit mode, VDDANA 2.4V to 3.6V supply voltage conditions Parameter Resolution Integral Non-linearity (INL) All mode, all gain Typ=3.0V supply, 27C All mode, all gain Typ=3.0V supply, 27C -4 Conditions Min Typ 12 1 +4 Max Units Bit LSB
-2
0.5
+2
LSB
Table 55-26. Gain Error, 12-bit Mode, VDDANA 2.4V to 3.6V supply voltage conditions Parameter Gain Error, Differential mode, uncalibrated Gain Error, Differential mode, after calibration Gain Error, Single Ended, uncalibrated Conditions Any gain and offset values Gain = 0.5 Gain = 1 Gain = 2 Any gain and offset values Gain = 1 Gain Error, Single Ended, after calibration Gain = 2 Gain = 4 Min -45 -8 -16 -24 -45 -8 -16 -24 Typ Max +45 +8 +16 +24 LSB +45 +8 +16 +24 Units
Table 55-27. Error offset with or without calibration, 12-bit Mode, VDDANA 2.4V to 3.6V supply voltage conditions Parameter Offset Error Conditions Single Ended, Gain = 1 / Differential mode Gain = 0.5 Single Ended, Gain = 2 / Differential mode Gain = 1 Single Ended, Gain = 4 / Differential mode Gain = 2 Min -8 -16 -32 Typ Max +8 +16 +32 LSB Units
1662
Table 55-28. Dynamic Performance Characteristics in Single ended and 12 bits mode (1) Parameter Signal to Noise Ratio - SNR Total Harmonic Distortion - THD Signal to Noise and Distortion - SINAD Effective Number of Bits - ENOB
(1)
Conditions
Min 54
Typ 61 -80
Max
Units dB
-68
dB dB Bits
54 8.7
61 9.8
Note:
1. ADC Clock (FADC) = 20 MHz, Fs=1MHz, Fin = 127 kHz, IBCTL = 01, FFT using 1024 points or more, Frequency band = [1 kHz, 500 kHz] Nyquist conditions fulfilled.
Table 55-29. Dynamic Performance Characteristics in Differential and 12 bits mode(1) Parameter Signal to Noise Ratio - SNR Total Harmonic Distortion - THD Signal to Noise and Distortion - SINAD Effective Number of Bits - ENOB
(1)
Conditions
Min 58
Typ 63 -80
Max
Units dB
-72
dB dB Bits
58 9.3
63 10.2
Note:
1. ADC Clock (FADC)= 20 MHz, Fs=1 MHz, Fin=127 kHz, IBCTL = 01, FFT using 1024 points or more, Frequency band = [1 kHz, 500 kHz] Nyquist conditions fulfilled.
1663
55.11.1.1 Track and Hold Time versus Source Output Impedance The following figure gives a simplified acquisition path.
Figure 55-4. Simplified Acquisition Path
ADC Input Zsource Mux. Sample & Hold 12-bit ADC Core
Ron
Csample
During the tracking phase the ADC needs to track the input signal during the tracking time shown below:
z z
10-bit mode: tTRACK = 0.042 x ZSOURCE + 160 12-bit mode: tTRACK = 0.054 x ZSOURCE + 205
With tTRACK expressed in ns and ZSOURCE expressed in Ohms. Two cases must be considered: 1. The calculated tracking time (tTRACK) is lower than 15 tCP_ADC. Set TRANSFER = 1 and TRACTIM = 0. In this case, the allowed ZSOURCE can be computed versus the ADC frequency with the hypothesis of tTRACK = 15 tCP_ADC: Where tCP_ADC = 1/fADC . See Table 55-30 on page 1664.
Table 55-30. Source Impedance Values fADC = ADC clock (MHz) 20.00 16.00 10.67 8.00 6.40 5.33 4.57 4.00 3.56 3.20 2.91 2.67 2.46 2.29 2.13 2.00 1.00 ZSOURCE (k) for 12 bits 10 14 22 31 40 48 57 66 74 83 92 100 109 118 126 135 274 ZSOURCE (k) for 10 bits 14 19 30 41 52 63 74 85 97 108 119 130 141 152 164 175 353
1664
2.
Set TRANSFER = 1 and TRACTIM = 0. In this case, a timer will trigger the ADC in order to set the correct sampling rate according to the Track time. The maximum possible sampling frequency will be defined by tTRACK in nanoseconds, computed by the previous formula but with minus 15 tCP_ADC and plus TRANSFER time.
z z
10 bit mode: 1/fS = tTRACK - 15 tCP_ADC + 5 tCP_ADC 12 bit mode: 1/fS = tTRACK - 15 tCP_ADC + 5 tCP_ADC CSAMPLE and RON are taken into account in the formulas
Note:
Table 55-31. Analog Inputs Parameter Input Voltage Range Input Leakage Current Input Capacitance Min 0 Typ Max VADVREF 0.5 8 A pF Units
Note:
Input Voltage range can be up to VDDANA without destruction or over-consumption. If VDDIO < VADVREF max input voltage is VDDIO.
55.11.1.2 ADC Application Information For more information on data converter terminology, please refer to the application note: Data Converter Terminology, Atmel lit 6022. http://www.atmel.com/dyn/resources/prod_documents/doc6022.pdf
1665
Static
Dynamic
NRST Tres
When a very slow (versus TRES) supply rising slope is applied on POR VDD pin, the reset time becomes negligible and the reset signal is released when VDD raises upper than Vth+. When a very fast (versus TRES) supply rising slope is applied on POR VDD pin, the voltage threshold becomes negligible and the reset signal is released after TRES time. It is the smallest possible reset time.
1666
NO HOLD SETTINGS (nrd hold = 0) SMC1 SMC2 Data Setup before NRD High Data Hold after NRD High 9.6 0 6.8 0 ns ns
HOLD SETTINGS (nrd hold 0) SMC3 SMC4 Data Setup before NRD High Data Hold after NRD High 9.4 0 6.6 0 ns ns
HOLD or NO HOLD SETTINGS (nrd hold 0, nrd hold =0) SMC5 NBS0/A0, NBS1, NBS2/A1, NBS3, A2 - A25 Valid before NRD High (nrd setup + nrd pulse)* tCPMCK + 2.4 (nrd setup + nrd pulse - ncs rd setup) * tCPMCK + 2 nrd pulse * tCPMCK + 1.8 (nrd setup + nrd pulse)* tCPMCK + 2.1 (nrd setup + nrd pulse - ncs rd setup) * tCPMCK + 1.9 nrd pulse * tCPMCK +1.2 ns
SMC6
ns
SMC7
ns
Table 55-36. SMC Read Signals - NCS Controlled (READ_MODE = 0) Symbol Parameter VDDIOM supply 1.8V Min 3.3V 1.8V Max 3.3V Units
NO HOLD SETTINGS (ncs rd hold = 0) SMC8 SMC9 Data Setup before NCS High Data Hold after NCS High 18.5 0 16.2 0 ns ns
1667
Table 55-36. SMC Read Signals - NCS Controlled (READ_MODE = 0) HOLD SETTINGS (ncs rd hold 0) SMC10 SMC11 Data Setup before NCS High Data Hold after NCS High 17 0 14.7 0 ns ns
HOLD or NO HOLD SETTINGS (ncs rd hold 0, ncs rd hold = 0) NBS0/A0, NBS1, NBS2/A1, NBS3, A2 - A25 valid before NCS High (ncs rd setup + ncs rd pulse)* tCPMCK + 19.1 (ncs rd setup + ncs rd pulse nrd setup)* tCPMCK + 16.8 ncs rd pulse length * tCPMCK +2 (ncs rd setup + ncs rd pulse)* tCPMCK + 18.8 (ncs rd setup + ncs rd pulse - nrd setup)* tCPMCK +16.1 ncs rd pulse length * tCPMCK + 1.5
SMC12
ns
SMC13
ns
SMC14
ns
HOLD or NO HOLD SETTINGS (nwe hold 0, nwe hold = 0) SMC15 SMC16 SMC17 Data Out Valid before NWE High NWE Pulse Width NBS0/A0 NBS1, NBS2/A1, NBS3, A2 - A25 valid before NWE low nwe pulse * tCPMCK + 2.4 nwe pulse * tCPMCK + 1.9 nwe setup * tCPMCK + 2.6 (nwe setup ncs rd setup + nwe pulse) * tCPMCK + 2.2 nwe pulse * tCPMCK + 1.6 nwe pulse * tCPMCK + 1.3 nwe pulse * tCPMCK + 2 (nwe setup ncs rd setup + nwe pulse) * tCPMCK + 1.9 ns ns ns
SMC18
ns
HOLD SETTINGS (nwe hold 0) SMC19 NWE High to Data OUT, NBS0/A0 NBS1, NBS2/A1, NBS3, A2 - A25 change NWE High to NCS Inactive (1) nwe hold * tCPMCK + 2.3 (nwe hold - ncs wr hold)* tCPMCK + 1.9 nwe hold * tCPMCK +1.1 (nwe hold - ncs wr hold)* tCPMCK +1 ns
SMC20
ns
NO HOLD SETTINGS (nwe hold = 0) SMC21 NWE High to Data OUT, NBS0/A0 NBS1, NBS2/A1, NBS3, A2 - A25, NCS change(1) 2 1.6 ns
Notes: 1. hold length = total cycle duration - setup duration - pulse duration. hold length is for ncs wr hold length or NWE hold length.
1668
Table 55-38. SMC Write NCS Controlled (WRITE_MODE = 0) Symbol Parameter 1.8V Supply SMC22 SMC23 SMC24 Data Out Valid before NCS High NCS Pulse Width NBS0/A0 NBS1, NBS2/A1, NBS3, A2 - A25 valid before NCS low ncs wr pulse * tCPMCK + 9.8 ncs wr pulse * tCPMCK + 2 ncs wr setup * tCPMCK + 4.3 (ncs wr setup nwe setup + ncs pulse)* tCPMCK + 2.4 ncs wr hold * tCPMCK + 2.6 (ncs wr hold nwe hold)* tCPMCK + 5.5 Min 3.3V Supply ncs wr pulse * tCPMCK + 9.1 ncs wr pulse * tCPMCK + 1.5 ncs wr setup * tCPMCK + 3.7 (ncs wr setup nwe setup + ncs pulse)* tCPMCK + 2.1 ncs wr hold * tCPMCK + 1.7 (ncs wr hold nwe hold)* tCPMCK + 5.6 1.8V Supply Max 3.3V Supply Units ns ns ns
SMC25
ns
SMC26
NCS High to Data Out, NBS0/A0, NBS1, NBS2/A1, NBS3, A2 - A25, change NCS High to NWE Inactive
ns
SMC27
ns
SMC12
SMC12
SMC24
SMC26
A0/A1/NBS[3:0]/A2-A25
SMC13
SMC13
NRD
NCS
SMC14 SMC9
SMC14
SMC23
SMC8
SMC10
SMC11
SMC22
SMC26
D0 - D15
SMC25 SMC27
NWE
1669
Figure 55-7. SMC Timings - NRD Controlled Read and NWE Controlled Write
SMC5 SMC17 SMC21 SMC5 SMC17 SMC19
A0/A1/NBS[3:0]/A2-A25
SMC6 SMC18 SMC21 SMC6 SMC18 SMC20
NCS
NRD
SMC7
SMC7
SMC1
SMC2
SMC15
SMC21
SMC3
SMC4
SMC15
SMC19
D0 - D31
NWE
SMC16
SMC16
55.13.2.3 FPGA Timings SMC and PCK2 can be used to interface a FPGA. PCK2 is to be programmed to output MCK. READ_MODE and WRITE_MODE are to be configured to 0.
Figure 55-8. FPGA Timings
PCK2 FPGA1 ADD, NCS, NDR, NWE FPGA3 DATA Output FPGA4 FPGA2
FPGA6
Table 55-39. FPGA Timings vs PCK2 Symbol Parameter VDDIOM Supply VDDCORE Supply FPGA1 Address, NCS, NRD, NWE Setup before PCK2 falling edge Address, NCS, NRD, NWE Hold after PCK2 falling edge Data Out Setup before PCK2 falling edge [1.65:1.95] [1.08:1.32] 1.78 Min [3.0:3.6V] [1.08:1.32] 2.07 [3.0:3.6V] [1.2:1.32] 1.78 [1.65:1.95] [1.08:1.32] Max [3.0:3.6V] [1.08:1.32] [3.0:3.6V] [1.2:1.32] Units V V ns
FPGA2
0.29
0.35
1.22
ns
FPGA3
1.46
1.77
1.59
ns
1670
Table 55-39. FPGA Timings vs PCK2 FPGA4 FPGA5 FPGA6 Data Out Hold after PCK2 falling edge Data In Setup before PCK2 falling edge Data In Hold after PCK2 falling edge 0 0.27 1.10 14.15 0 12.08 0 10.39 0 ns ns ns
These values may be product dependant and should be confirmed by the specification.
SPCK
SPI0 MISO
SPI1
SPI2 MOSI
SPCK
SPI3 MISO
SPI4
SPI5 MOSI
1671
NPCS0
SPI12 SPCK
SPI13
SPI6 MISO
SPI7 MOSI
SPI8
NPCS0
SPI13 SPI12
SPCK
SPI9 MISO
SPI10 MOSI
SPI11
SPI14 SPI6 SPCK (CPOL = 0) SPI12 SPCK (CPOL = 1) SPI16 MISO SPI9
SPI15
SPI13
1672
Table 55-41. SPI Timings with 3v3 peripheral supply Symbol Parameter Cond Master Mode SPI0 SPI1 SPI2 SPI3 SPI4 SPI5 MISO Setup time before SPCK rises MISO Hold time after SPCK rises SPCK rising to MOSI MISO Setup time before SPCK falls MISO Hold time after SPCK falls SPCK falling to MOSI Slave Mode SPI6 SPI7 SPI8 SPI9 SPI10 SPI11 SPI12 SPI13 SPI14 SPI15 SPI16 SPCK falling to MISO MOSI Setup time before SPCK rises MOSI Hold time after SPCK rises SPCK rising to MISO MOSI Setup time before SPCK falls MOSI Hold time after SPCK falls NPCS0 setup to SPCK rising NPCS0 hold after SPCK falling NPCS0 setup to SPCK falling NPCS0 hold after SPCK rising NPCS0 falling to MISO valid 5.8(1) 2 0.3 5.8(1) 2 0.3 3.5 19.5 1.9 19.8 8.8 9.4(1) 9.4(1) ns ns ns ns ns ns ns ns ns ns ns 8.7 5.9 0.8(1) 8.7 5.8 0.9(1) 3.8(1) 3.7(1) ns ns ns ns ns ns Min Max Units
Notes: 1. For output signals, Min and Max access time must be extracted. The Min access time is the time between the SPCK rising or falling edge and the signal change. The Max access timing is the time between the SPCK rising or falling edge and the signal stabilizes. Figure 55-13 illustrates Min and Max accesses for SPI2. The same applies for SPI5, SPI6, SPI9.
Table 55-42. SPI Timings with 1v8 Peripheral Supply Symbol Parameter Cond Master Mode SPI0 SPI1 SPI2 SPI3 SPI4 SPI5 MISO Setup time before SPCK rises MISO Hold time after SPCK rises SPCK rising to MOSI MISO Setup time before SPCK falls MISO Hold time after SPCK falls SPCK falling to MOSI Slave Mode SPI6 SPI7 SPCK falling to MISO MOSI Setup time before SPCK rises 3.2(1) 1.7 9.4(1) ns ns 10.9 0 0.8
(1)
Min
Max
Units
ns ns 3.5
(1)
ns ns ns
ns
1673
Table 55-42. SPI Timings with 1v8 Peripheral Supply Symbol SPI8 SPI9 SPI10 SPI11 SPI12 SPI13 SPI14 SPI15 SPI16 Parameter MOSI Hold time after SPCK rises SPCK rising to MISO MOSI Setup time before SPCK falls MOSI Hold time after SPCK falls NPCS0 setup to SPCK rising NPCS0 hold after SPCK falling NPCS0 setup to SPCK falling NPCS0 hold after SPCK rising NPCS0 falling to MISO valid Cond Min 1 2.9
(1)
Max
Units ns
10.9
(1)
ns ns ns ns ns ns ns
ns
Figure 55-14. Min and Max access time for SPI output signal
SPCK
SPI0 MISO
SPI1
SPI2max MOSI
SPI2min
1674
55.15.2 DDR2-SDRAM
Table 55-43. System Clock Waveform Parameters Symbol Parameter Conditions VDDCORE[1.08V,1.32V] T = 85C tDDRCK DDRCK Cycle time VDDCORE[1.2V,1.32V], VDDIODDR[1.75V,1.9V], T = 85C VDDCORE[1.08V,1.32V] T = 85C tSDQS DQS setup time VDDCORE[1.2V,1.32V], VDDIODDR[1.75V,1.9V], T = 85C 0.7 ns 0.6 ns 6.0 8.0 ns Min 7.5 Max 8.0 Units ns
55.15.3 LPDDR1-SDRAM
Table 55-44. System Clock Waveform Parameters Symbol tDDRCK tSDQS Parameter DDRCK Cycle time Conditions VDDCORE[1.08V,1.32V] T = 85C VDDCORE[1.08V,1.32V] T = 85C Min 7.5 Max Units ns
7.3
ns
55.15.4 LPDDR2-SDRAM
Table 55-45. System Clock Waveform Parameters Symbol tDDRCK tSDQS Parameter DDRCK Cycle time Conditions VDDCORE[1.08V,1.32V] T = 85C VDDCORE[1.08V,1.32V] T = 85C Min 7.5 Max Units ns
6.2
ns
1675
tSDQS
DQS
These values may be product dependant and should be confirmed by the specification.
TK (CKI =0)
TK (CKI =1)
SSC0 TF/TD
1676
TK (CKI =0)
TK (CKI =1)
SSC1 TF/TD
TK (CKI=1)
SSC2 TF
SSC3
SSC4 TD
TK (CKI=0)
SSC5 TF SSC7 TD
SSC6
1677
RK (CKI=1)
SSC8 RF/RD
SSC9
RK (CKI=0)
SSC8 RD SSC10 RF
SSC9
RK (CKI=0)
SSC11 RD SSC13 RF
SSC12
RK (CKI=1)
SSC11 RF/RD
SSC12
1678
Table 55-47. SSC Timings with 3.3V Peripheral supply Symbol Parameter Cond Transmitter SSC0 SSC1 SSC2 SSC3 SSC4(1) SSC5 SSC6 SSC7(1) TK edge to TF/TD (TK output, TF output) TK edge to TF/TD (TK input, TF output) TF setup time before TK edge (TK output) TF hold time after TK edge (TK output) TK edge to TF/TD (TK output, TF input) TF setup time before TK edge (TK input) TF hold time after TK edge (TK input) TK edge to TF/TD (TK input, TF input) Receiver SSC8 SSC9 SSC10 SSC11 SSC12 SSC13 RF/RD setup time before RK edge (RK input) RF/RD hold time after RK edge (RK input) RK edge to RF (RK input) RF/RD setup time before RK edge (RK output) RF/RD hold time after RK edge (RK output) RK edge to RF (RK output) 0 tCPMCK 2.5
(2)
Min
Max
Units
1.2(2) 2.3 (2) 7.7 7.3 1.2 (+2*tCPMCK) 0 tCPMCK 2.4 (+3*tCPMCK)
(1)(2) (1)(2)
ns ns ns ns
2.1(+2*tCPMCK)
(1)(2)
ns ns ns
8.8 (+3*tCPMCK)
(1)(2)
ns
ns ns 8.8
(2)
ns ns ns
ns
Notes: 1. Timings SSC4 and SSC7 depend on the start condition. When STTDLY = 0 (Receive start delay) and START = 4, or 5 or 7 (Receive Start Selection), two Periods of the MCK must be added to timings. 2. For output signals (TF, TD, RF), Min and Max access times are defined. The Min access time is the time between the TK (or RK) edge and the signal change. The Max access timing is the time between the TK edge and the signal stabilization. Figure 55-24 illustrates Min and Max accesses for SSC0. The same applies for SSC1, SSC4, and SSC7, SSC10 and SSC13.
1679
Table 55-48. SSC Timing with 1V8 Peripheral supply Symbol Parameter Cond Transmitter SSC0 SSC1 SSC2 SSC3 SSC4(1) SSC5 SSC6 SSC7(1) TK edge to TF/TD (TK output, TF output) TK edge to TF/TD (TK input, TF output) TF setup time before TK edge (TK output) TF hold time after TK edge (TK output) TK edge to TF/TD (TK output, TF input) TF setup time before TK edge (TK input) TF hold time after TK edge (TK input) TK edge to TF/TD (TK input, TF input) Receiver SSC8 SSC9 SSC10 SSC11 SSC12 SSC13 RF/RD setup time before RK edge (RK input) RF/RD hold time after RK edge (RK input) RK edge to RF (RK input) RF/RD setup time before RK edge (RK output) RF/RD hold time after RK edge (RK output) RK edge to RF (RK output) 0 tCPMCK 2.5
(2)
Min
Max
Units
1.2(2) 2.3 (2) 7.7 7.3 1.2 (+2*tCPMCK) 0 tCPMCK 2.4 (+3*tCPMCK)
(1)(2) (1)(2)
ns ns ns ns
2.1(+2*tCPMCK)
(1)(2)
ns ns ns
8.8 (+3*tCPMCK)
(1)(2)
ns
ns ns 8.8
(2)
ns ns ns
ns
TK (CKI =1)
1680
These values may be product dependant and should be confirmed by the specification.
PIXCLK
3
Valid Data
Valid Data
Valid Data
Min 3.1 1
Max
Units ns ns
80
MHz
Table 55-51. ISI Timings with Peripheral Supply 1.8V Symbol ISI1 ISI2 ISI3 Parameter DATA/VSYNC/HSYNC setup time DATA/VSYNC/HSYNC hold time PIXCLK frequency Min 3.4 1.2 80 Max Units ns ns MHz
1681
Table 55-52. MCI Timings Symbol Parameter CLoad C = 25 pF MCI1 CLK frequency at Data transfer Mode C= 100 pF C= 250 pF CLK frequency at Identification Mode CLK Low time CLK High time CLK Rise time CLK Fall time CLK Low time CLK High time CLK Rise time CLK Fall time MCI2 MCI3 MCI4 MCI5 Input hold time Input setup time Output change after CLK rising Output valid before CLK rising C= 100 pF C= 100 pF C= 100 pF C= 100 pF C= 250 pF C= 250 pF C= 250 pF C= 250 pF 3 3 5 5 50 50 50 50 10 10 10 10 Min Max 25 20 20 400 Units MHz MHz MHz kHz ns ns ns ns ns ns ns ns ns ns ns ns
1682
These values may be product dependant and should be confirmed by the specification.
Notes: 1. For EMAC output signals, Min and Max access time are defined. The Min access time is the time between the EDMC rising edge and the signal change. The Max access timing is the time between the EDMC rising edge and the signal stabilizes. Figure 55-27 illustrates Min and Max accesses for EMAC3.
Figure 55-27. Min and Max access time of EMAC output signals
EMDC EMAC1 EMDIO EMAC4 EMAC5 EMAC3 min EMAC2 EMAC3 max
1683
1684
ERXCK EMAC11 ERX[3:0] EMAC13 ERXER EMAC15 ERXDV EMAC16 EMAC14 EMAC12
1685
Table 55-56. RMII Mode Symbol EMAC21 EMAC22 EMAC23 EMAC24 EMAC25 EMAC26 EMAC27 EMAC28 Parameter ETXEN toggling from EREFCK rising ETX toggling from EREFCK rising Setup for ERX from EREFCK rising Hold for ERX from EREFCK rising Setup for ERXER from EREFCK rising Hold for ERXER from EREFCK rising Setup for ECRSDV from EREFCK rising Hold for ECRSDV from EREFCK rising Min (ns) 2
(1)
2(1) 4 2 4 2 4 2
1686
These values may be product dependant and should be confirmed by the specification.
NPCSx SPI3 CPOL=1 SPI0 SPCK=0 CPOL=0 SPI4 MISO MOSI SPI4 MSB SPI1 SPI2 LSB
SPI5
NPCS0
SPI12 SPCK
SPI13
SPI6 MISO
SPI7 MOSI
SPI8
1687
SPI14 SPI6 SPCK (CPOL = 0) SPI12 SPCK (CPOL = 1) SPI16 MISO SPI9
SPI15
SPI13
Table 55-58. UART SPI Timings 3.3V Peripheral Supply Symbol Parameter Cond Master Mode SPI0 SPI1 SPI2 SPI3 SPI4 SPI5 SPCK Period Input Data Setup Time Input Data Hold Time Chip Select Active to Serial Clock Output Data Setup Time Serial Clock to Chip Select Inactive Slave Mode SPI6 SPI7 SPI8 SPI9 SPI10 SPI11 SPI12 SPI13 SPI14 SPI15 SPI16 SPCK falling to MISO MOSI Setup time before SPCK rises MOSI Hold time after SPCK rises SPCK rising to MISO MOSI Setup time before SPCK falls MOSI Hold time after SPCK falls NPCS0 setup to SPCK rising NPCS0 hold after SPCK falling NPCS0 setup to SPCK falling NPCS0 hold after SPCK rising NPCS0 falling to MISO valid 0.1 5.6
(1)
Min
Max
Units
ns ns ns ns ns ns
2.2(1)
8.7(1)
ns ns ns
(1)
ns ns ns ns ns ns ns
ns
Notes: 1. For output signals, Min and Max access time must be extracted. The Min access time is the time between the SPCK rising or falling edge and the signal change. The Max access timing is the time between the SPCK rising or falling edge and the signal stabilizes. Figure 55-13 illustrates Min and Max accesses for SPI2. The same applies for SPI5, SPI6, SPI9.
1688
Condition
Max 0.3 VCC VCC + 0.5 0.4 300 250 10 10 400 1000 ns -------------------Cb 300 ns ----------------Cb 3.45 0.9
Units V V V V ns ns A pF kHz s s s s s s s s s s ns ns s s s s
0.1 VCC < Vi < 0.9 VCC > max(16 fTWCK, 250 kHz)(6)
0 V CC 0,4V ---------------------------3mA V CC 0,4V ---------------------------3mA 4.0 0.6 4.7 1.3 4.0 0.6 4.7 0.6 0 0 250 100 4.0 0.6 4.7 1.3
fTWCK 100 kHz Rp Value of Pull-up resistor fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz fTWCK 100 kHz fTWCK > 100 kHz
Hold Time (repeated) START Condition Low Period of the SCL Clock High period of the SCL clock Set-up time for a repeated START condition Data hold time Data setup time Setup time for STOP condition Bus free time between a STOP and START condition
Notes: 1. This parameter is characterized in Chip Number; it is not 100% tested. 2. Required only for fTWCK > 100 kHz. 3. Cb = capacitance of one bus line in pF. Per I2C Standard, Cb Max = 400pF 4. This requirement applies to all Chip Number 2-wire Serial Interface operation. Other devices connected to the 2-wire Serial Bus need only to satisfy the general fTWCK requirement. 5. fCK = CPU clock frequency 6. This requirement applies to all Chip Number 2-wire Serial Interface operation. Other devices connected to the Twowire Serial Bus need only obey the general fSCL requirement.
1689
tBUF
1690
56.
Mechanical Characteristics
TITLE
324
1691
Table 56-2. Device and 324-ball LFBGA Package Maximum Weight 400 mg
Table 56-3. Package Reference JEDEC Drawing Reference JESD97 Classification MO-275-KAAE-1 e8
Table 56-4. Package Information Ball Land Nominal Ball Diameter Solder Mask Opening Solder Mask Definition Solder 0.350 mm 0.05 0.30 mm 0.275 mm 0.05 SMD SAC105
1692
56.1
Marking
All devices are marked with the Atmel logo and the ordering code. Additional marking may be in one of the following formats:
YYWW V XXXXXXXXX
where
z z z z
ARM
YY: manufactory year WW: manufactory week V: revision XXXXXXXXX: lot number
1693
57.
ATSAMA5D33A-CU
BGA324
Green
ATSAMA5D34A-CU
BGA324
Green
ATSAMA5D35A-CU
BGA324
Green
1694
58.
58.1
58.1.2 Boot ROM: NAND Flash Detection using ONFI Parameters does Not Work
During Nandflash initialization, the ONFI parameter detection may not work correctly. This can lead to incorrect configuration of ECC settings and to reading wrong data from the Nandflash memory, thus making it impossible to boot from this memory. Problem Fix/Workaround When programming the bootable program in the Nandflash, always use the header method, with any Nandflash memory, ONFI compliant or not.
58.2
58.3
58.4
1695
58.5
58.5.1 GMAC: TX Packet Buffer DMA Lockup when Reading Used Status
In the following conditions:
z z z z z
Frame N-1 has completed the transmission on GMII and its post-transmit status has been passed from the MAC to DMA. The descriptor write back for frame N-1 has been requested on AHB and is awaiting completion. Frame N has completed the transmission on GMII and its post-transmit status has been passed from the MAC to DMA. A used bit has been read from the buffer descriptor queue after the descriptors associated with frame N. This means a buffer descriptor with bit [31] set in word 1 of the descriptor pair. Status associated with this used bit is passed from MAC to DMA on the exact AHB clock cycle that the writeback request for frame N-1 completes (either; BREADY high in the case of HREADY or high in the data phase in the case of AHB).
When this precise sequence occurs, the AHB write back request for frame N never actually occurs, but the TX DMA state machine waits in the DMA_MANWR state, awaiting the AHB response for the write. This response never happens since the request was never sent. Problem Fix/Workaround 1. Avoid the issue by sending only one frame at a time.
To send only a single frame at a time, each frame queued in the descriptor buffers must be followed by a buffer descriptor with the used bit set. GEM will send the frame and then halt and update status. Once frame status indicates that the frame has completed, then a new frame may be queued and transmit DMA restarted. 2. Avoid issue by changing used bit status to exhausted mid-frame status. For this workaround the buffer descriptors with used bit set, that mark the end of the queues are replaced with two zero length descriptors with particular bits set or clear. The effect is an exhausted mid-frame status instead of the usual used bit read status. This requires changes to SW for adding new frames to queues. For this discussion, assume that the last descriptor associated with the last valid frame queued is descriptor N, which is at address offset X from the queue base pointer. Currently the end of the queue is marked with descriptor N+1 with its used bit set as follows:
z
descriptor N: X+0x00: FC800000 X+0x04: 0000803C - Last frame queued descriptor N+1: X+0x08: xxxxxxxx +0x0C: 8xxxxxxx - Used bit set (x is a dont care value)
For the workaround buffer descriptor N+1 and also N+2 should be replaced with the following: z descriptor N: X+0x00: FC800000
z
X+0x04: 0000803C - Last frame queued descriptor N+1: X+0x08: 00000000 X+0x0C: 00000000 descriptor N+2: X+0x10: 00000000 X+0x14: 80008000 - last buffer and used bit set
1696
1697
Revision History
In the tables that follow, the most recent version of the document appears first. rfo indicates changes requested during document review and approval loop.
Doc. Rev. Comments 11121B Introduction: Section 8.1 Chip Identification, updated Chip ID: 0x8A5C07C1 --> 0x8A5C07C2. Description, added a cross-reference to Table 1-1 SAMA5D3 Devices in the last paragraph. Replaced Cortex references with Cortex in Description and further on in the entire document. Removed AT91SAM from the document title. Standard Boot Strategies: Section 12.3.4.1 NAND Flash Boot: NAND Flash Detection, added the eccBitReq field description in NAND Flash Specific Header Detection. SFR: Added a row for SFR_UTMICKTRIM register (offset value 0x30) in Table 16-1 Register Mapping and the corresponding Section 16.3.4 UTMI Clock Trimming Register. External Memories: Section 27.1.5 Product Dependencies, updated LPDDR2 Mode data in Table 27-2 DDR2 I/O Lines Usage vs rfo Operating Modes (DDR_WE, DDR_RAS - DDR_CAS, and DDR_A[13..0]). Section 27.1.6.2 2x16-bit LPDDR2, added references on CAx LP-DDR2 signals and Table 27-3 CAx LPDDR2 Signal Connection. USART Added a paragraph on IRDA_FILTER programming criteria in Section 45.7.5.3 IrDA Demodulator and in the corresponding bitfield description in Section 45.8.20 USART IrDA FILTER Register. 8508 8683 8796
Section 45.8.18 USART FI DI RATIO Register, expanded FI_DI_RATIO bitfield to 16 bits in the register table. 8643 FUSE: Section 51.2 Embedded Characteristics, added references on FUSE bits. Added Section 51.2.1 FUSE Bit Mapping and Section 51.2.2 Special Functions. 8785
1698
Doc. Rev. Comments 11121B Electrical Characteristics: Section 55.6 12 MHz RC Oscillator Characteristics, updated the IDDON value in Table 55-12. Section 55.7 32 kHz Oscillator Characteristics, added a row on PON in Table 55-13. Section 55.11 12-Bit ADC Characteristics, updated data in: - Table 55-22 Analog Power Supply Characteristics - Table 55-23 Channel Conversion Time and ADC Clock - Table 55-24 External Voltage Reference Input - Table 55-25 INL, DNL, 12-bit mode, VDDANA 2.4V to 3.6V supply voltage conditions - Table 55-26 Gain Error, 12-bit Mode, VDDANA 2.4V to 3.6V supply voltage conditions - Table 55-27 Error offset with or without calibration, 12-bit Mode, VDDANA 2.4V to 3.6V supply voltage conditions - Table 55-28 Dynamic Performance Characteristics in Single ended and 12 bits mode (1); and - Table 55-29 Dynamic Performance Characteristics in Differential and 12 bits mode(1) Added Section 55.15 MPDDRC Timings.
rfo
rfo
Section 55.16 SSC Timings, updated PIXCLK frequency maximum value and fixed transmitter parameter data rfo for SSC7 in Table 55-47 SSC Timings with 3.3V Peripheral supply and Table 55-48 SSC Timing with 1V8 Peripheral supply. Mechanical Characteristics: Added Nominal Ball Diameter and Solder rows in Table 56-4 Package Information. Errata: Added the introduction paragraph in Section 58. SAMA5D3 Series Errata. Added Section 58.1.2 Boot ROM: NAND Flash Detection using ONFI Parameters does Not Work. rfo 8785 rfo
1699
Table of Contents
5. Power Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.1 5.2 5.3 Power Supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Power-up Consideration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Power-down Consideration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6. Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.1 6.2 Embedded Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 External Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8. System Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8.1 8.2 Chip Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Backup Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
9. Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
9.1 9.2 9.3 9.4 Peripheral Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Peripheral Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Peripheral Signal Multiplexing on I/O Lines . . . . . . . . . . . . . . . . . . . . . . . . . . Peripheral Clock Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 28 30 30
11.7 11.8
The Boundary JTAG ID Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 The Cortex-A5 DP Identification Code Register IDCODE . . . . . . . . . . . . . . . 51
ii
Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Watchdog Timer (WDT) User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
iii
25.4 25.5 25.6 25.7 25.8 25.9 25.10 25.11 25.12 25.13
Processor Clock Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . USB Device and Host Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DDR2/LPDDR/LPDDR2 Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Software Modem Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Peripheral Clock Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programmable Clock Output Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . Main Crystal Clock Failure Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programming Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clock Switching Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Power Management Controller (PMC) User Interface . . . . . . . . . . . . . . . .
196 196 196 196 197 197 198 199 202 205
iv
29.18 Software Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 29.19 Static Memory Controller (HSMC) User Interface . . . . . . . . . . . . . . . . . . . . 402
35.5 35.6
Programming Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959 Ethernet MAC 10/100 (EMAC) User Interface . . . . . . . . . . . . . . . . . . . . . . . 962
vi
Multi-master Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Slave Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Write Protection System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Two-wire Interface (TWI) User Interface . . . . . . . . . . . . . . . . . . . . . . . . . .
vii
viii
57. SAMA5D3 Ordering Information . . . . . . . . . . . . . . . . . . . . . . . . . 1694 58. SAMA5D3 Series Errata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695
58.1 58.2 Standard Boot Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695 Static Memory Controller (HSMC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695
ix
LCD Controller (LCDC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695 PWM Controller (PWM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695 Gigabit Ethernet MAC (GMAC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1696
Atmel Corporation 1600 Technology Drive San Jose, CA 95110 USA Tel: (+1) (408) 441-0311 Fax: (+1) (408) 487-2600 www.atmel.com
Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Millennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369
Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621
Atmel Japan G.K. 16F Shin-Osaki Kangyo Bldg 1-6-4 Osaki, Shinagawa-ku Tokyo 141-0032 JAPAN Tel: (+81) (3) 6417-0300 Fax: (+81) (3) 6417-0370
2013 Atmel Corporation. All rights reserved. / Rev.: 11121BATARM08-Mar-13 Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, QTouch, SAM-BA and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Windows and others, are registered trademarks or trademarks of Microsoft Corporation in the US and/or other countries. ARM, ARMPowered logo, Cortex, Thumb-2 and others are registered trademarks or trademarks of ARM Ltd. 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.