Atmel SAM9X25 Manual

Atmel SAM9X25 Manual

At91sam arm-based embedded mpu

Advertisement

Quick Links

Features
Core
– ARM926EJ-S™ ARM
– 16 Kbytes Data Cache, 16 Kbytes Instruction Cache, Memory Management Unit
Memories
– One 64-Kbyte internal ROM embedding bootstrap routine: Boot on NAND Flash,
SDCard, DataFlash
– One 32-Kbyte internal SRAM, single-cycle access at system speed
– High Bandwidth Multi-port DDR2 Controller
– 32-bit External Bus Interface supporting 8-bank DDR2/LPDDR, SDR/LPSDR, Static
Memories
– MLC/SLC NAND Controller, with up to 24-bit Programmable Multi-bit Error
Correcting Code (PMECC)
System running at up to 133 MHz
– 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 and Fast 12 MHz RC Oscillators
– Selectable 32768 Hz Low-power Oscillator and 12 MHz Oscillator
– One PLL for the system and one PLL at 480 MHz optimized for USB High Speed
– Twelve 32-bit-layer AHB Bus Matrix for large Bandwidth transfers
– Dual Peripheral Bridge with dedicated programmable clock for best performance
– Two dual port 8-channel DMA Controllers
– Advanced Interrupt Controller and Debug Unit
– Two Programmable External Clock Signals
Low Power Mode
– Shut Down Controller with four 32-bit Battery Backup Registers
– Clock Generator and Power Management Controller
– Very Slow Clock Operating Mode, Software Programmable Power Optimization
Capabilities
Peripherals
– USB Device High Speed, USB Host High Speed and USB Host Full Speed with
dedicated On-Chip Transceiver
– Two 10/100 Mbps Ethernet MAC Controllers
– Two High Speed Memory Card Hosts
– Two CAN Controllers
– Two Master/Slave Serial Peripheral Interface
– Two Three-channel 32-bit Timer/Counters
– One Synchronous Serial Controller
– One Four-channel 16-bit PWM Controller
– Three Two-wire Interfaces
– Four USARTs, two UARTs
– One 12-channel 10-bit Analog-to-Digital Converter
– Soft Modem
I/O
– Four 32-bit Parallel Input/Output Controllers
– 105 Programmable I/O Lines Multiplexed with up to Three Peripheral I/Os
– Input Change Interrupt Capability on Each I/O Line, optional Schmitt trigger input
– Individually Programmable Open-drain, Pull-up and pull-down resistor,
Synchronous Output
Package
– 217-ball BGA, pitch 0.8 mm
®
®
Thumb
Processor running at up to 400 MHz @ 1.0V +/- 10%
®
or serial DataFlash. Programmable order.
AT91SAM
ARM-based
Embedded MPU
SAM9X25
11054A–ATARM–27-Jul-11

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the SAM9X25 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Atmel SAM9X25

  • Page 1 – Internal Low Power 32 kHz RC and Fast 12 MHz RC Oscillators – Selectable 32768 Hz Low-power Oscillator and 12 MHz Oscillator SAM9X25 – One PLL for the system and one PLL at 480 MHz optimized for USB High Speed –...
  • Page 2 Device and Host, FS USB Host, two HS SDCard/SDIO/MMC interfaces, USARTs, SPIs, I2S, TWIs and 10-bit ADC. To ensure uninterrupted data transfer with minimum processor overhead, the SAM9X25 offers a 10-layer bus matrix coupled with 2 x 8 central DMA channels and dedicated DMAs for the high- speed connectivity peripherals.
  • Page 3 SAM9X25 2. Block Diagram Figure 2-1. SAM9X25 Block Diagram 11054A–ATARM–27-Jul-11...
  • Page 4 External Interrupt Input Input Fast Interrupt Input Input PIO Controller - PIOA - PIOB - PIOC - PIOD PA0-PA31 Parallel IO Controller A PB0-PB18 Parallel IO Controller B PC0-PC31 Parallel IO Controller C PD0-PD21 Parallel IO Controller D SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 5 SAM9X25 Table 3-1. Signal Description List (Continued) Signal Name Function Type Active Level External Bus Interface - EBI D0-D15 Data Bus D16-D31 Data Bus A0-A25 Address Bus Output NWAIT External Wait Signal Input Static Memory Controller - SMC NCS0-NCS5 Chip Select Lines...
  • Page 6 Serial Peripheral Interface - SPIx SPIx_MISO Master In Slave Out SPIx_MOSI Master Out Slave In SPIx_SPCK SPI Serial Clock SPIx_NPCS0 SPI Peripheral Chip Select 0 SPIx_NPCS1-SPIx_NPCS3 SPI Peripheral Chip Select Output Two-Wire Interface -TWIx TWDx Two-wire Serial Data TWCKx Two-wire Serial Clock SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 7 SAM9X25 Table 3-1. Signal Description List (Continued) Signal Name Function Type Active Level Pulse Width Modulation Controller- PWMC PWM0-PWM3 Pulse Width Modulation Output Output USB Host High Speed Port - UHPHS HFSDPA USB Host Port A Full Speed Data +...
  • Page 8 Analog-to-Digital Converter - ADC AD0-AD11 12 Analog Inputs Analog ADTRG ADC Trigger Input ADVREF ADC Reference Analog CAN Controller - CANx CANRXx CAN input Input CANTXx CAN output Output Soft Modem - SMD DIBN Soft Modem Signal DIBP Soft Modem Signal SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 9 SAM9X25 4. Package and Pinout The SAM9X25 is available in 217-ball BGA package. Overview of the 217-ball BGA Package Figure 4-1 shows the orientation of the 217-ball BGA Package. Figure 4-1. Orientation of the 217-ball BGA Package TOP VIEW A B C D E F G H J...
  • Page 10 When “Reset State” is mentioned, the configuration is defined by the “Reset State” column of the Pin Description table. Table 4-2. SAM9X25 I/O Type Assignment and Frequency I/O Frequency Charge Load Output I/O Type (MHz) (pF) Current Signal Name GPIO...
  • Page 11 SAM9X25 Indicates if Schmitt Trigger is enabled. Example: Note: The PB18 “Reset State” column shows “PIO, I, PU, ST”. That means the line PIO18 is configured as an Input with Pull-Up and Schmitt Trigger enabled. PD14 reset state is “PIO, I, PU”.
  • Page 12 VDDANA GPIO E0_RXDV SPI0_NPCS3 PIO, I, PU, ST VDDANA GPIO_CLK E0_TXCK TWD2 PIO, I, PU, ST VDDANA GPIO E0_MDIO TWCK2 PIO, I, PU, ST VDDANA GPIO_ANA E0_MDC PIO, I, PU, ST VDDANA GPIO_ANA E0_TXEN PIO, I, PU, ST SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 13 SAM9X25 Table 4-3. Pin Description BGA217 (Continued) Primary Alternate PIO Peripheral A PIO Peripheral B PIO Peripheral C Reset State Signal, Dir, PU, Ball Power Rail I/O Type Signal Signal Signal Signal Signal PD, ST VDDANA GPIO_ANA E0_TXER PIO, I, PU, ST...
  • Page 14 H10, GNDIOM GNDIOM VDDIOP0 POWER VDDIOP0 VDDIOP1 POWER VDDIOP1 GNDIOP GNDIOP VDDBU POWER VDDBU GNDBU GNDBU VDDANA POWER VDDANA GNDANA GNDANA VDDPLLA POWER VDDPLLA VDDOSC POWER VDDOSC GNDOSC GNDOSC H14, VDDCORE POWER VDDCORE GNDCORE GNDCORE VDDUTMII POWER VDDUTMII SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 15 SAM9X25 Table 4-3. Pin Description BGA217 (Continued) Primary Alternate PIO Peripheral A PIO Peripheral B PIO Peripheral C Reset State Signal, Dir, PU, Ball Power Rail I/O Type Signal Signal Signal Signal Signal PD, ST VDDUTMIC POWER VDDUTMIC GNDUTMI GNDUTMI...
  • Page 16 I, ST VDDIOP0 RSTJTAG I, ST VDDIOP0 RSTJTAG VDDIOP0 RSTJTAG I, ST VDDIOP0 RSTJTAG RTCK VDDIOP0 RSTJTAG NRST I, PU, ST VDDIOP0 RSTJTAG NTRST I, PU, ST VDDBU CLOCK XIN32 VDDBU CLOCK XOUT32 VDDOSC CLOCK VDDOSC CLOCK XOUT SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 17 SAM9X25 5. Power Considerations Power Supplies The SAM9X25 has several types of power supply pins. Table 5-1. SAM9X25 Power Supplies Associated Name Voltage Range, nominal Powers Ground ARM core, internal memories, internal peripherals and VDDCORE 0.9-1.1V, 1.0V GNDCORE part of the system controller.
  • Page 18 6. Memories Figure 6-1. SAM9X25 Memory Mapping Internal Memory Mapping Address Memory Space 0x0000 0000 0x0000 0000 1 MByte Boot Memory (1) 0x0010 0000 Notes: Internal Memories 256 MBytes 1 MByte (1) Can be ROM, EBI1_NCS0 or SRAM depending on BMS and REMAP...
  • Page 19 Embedded Memories 6.2.1 Internal SRAM The SAM9X25 embeds a total of 32 Kbytes of high-speed SRAM. After reset and until the Remap Command is performed, the SRAM is only accessible at address 0x0030 0000. After Remap, the SRAM also becomes available at address 0x0.
  • Page 20 • SDRAM Power-up Initialization by Software • CAS Latency of 2, 3 Supported • Auto Precharge Command Not Used • SDR-SDRAM with 16-bit Datapath and Eight Columns Not Supported – Clock Frequency Change in Precharge Power-down Mode Not Supported SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 21 SAM9X25 7. 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.
  • Page 22 Figure 7-1. SAM9X25 System Controller Block Diagram System Controller VDDCORE Powered nirq Advanced nfiq Interrupt periph_irq[2..30] Controller ntrst ARM926EJ-S pit_irq por_ntrst wdt_irq dbgu_irq proc_nreset pmc_irq rstc_irq Debug dbgu_irq periph_nreset debug Unit dbgu_txd dbgu_rxd Periodic jtag_nreset Boundary Scan debug pit_irq Interval...
  • Page 23 • Chip ID: 0x819A_05A1 • Chip ID Extension: 4 • JTAG ID: 0x05B2_F03F • ARM926 TAP ID: 0x0792_603F Backup Section The SAM9X25 features a Backup Section that embeds: • RC Oscillator • Slow Clock Oscillator • Real Time Counter (RTC) • Shutdown Controller •...
  • Page 24 Peripheral Identifiers Table 8-1 defines the Peripheral Identifiers of the SAM9X25. A peripheral identifier is required for the control of the peripheral interrupt with the Advanced Interrupt Controller and for the con- trol of the peripheral clock with the Power Management Controller.
  • Page 25 Advanced Interrupt Controller Peripheral Signal Multiplexing on I/O Lines The SAM9X25 features 4 PIO Controllers, PIOA, PIOB, PIOC and PIOD, which multiplex the I/O lines of the peripheral set. Each PIO Controller controls 32 lines, 19 lines, 32 lines and 22 lines respectively for PIOA, PIOB, PIOC and PIOD.
  • Page 26 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 27 SAM9X25 SAM9X25 ™ 9. ARM926EJ-S Description ™ The ARM926EJ-S processor is a member of the ARM9 family of general-purpose microproces- sors. The ARM926EJ-S implements ARM architecture version 5TEJ and is targeted at multi- tasking applications where full memory management, high performance, low die size and low power are all important features.
  • Page 28 – Separate AMBA AHB Buses for Both the 32-bit Data Interface and the 32-bit Instructions Interface • Bus Interface Unit – Arbitrates and Schedules AHB Requests – Enables Multi-layer AHB to be Implemented – Increases Overall Bus Bandwidth – Makes System Architecture Mode Flexible SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 29 SAM9X25 SAM9X25 Block Diagram Figure 9-1. ARM926EJ-S Internal Functional Block Diagram External Coprocessors ETM9 CP15 System External Trace Port Configuration Coprocessor Interface Coprocessor Interface Write Data ARM9EJ-S Processor Core Instruction Fetches Read Data Data Instruction Address Address Instruction DTCM ITCM...
  • Page 30 ARM instructions. The hardware/software split is invisible to the programmer, invisible to the application and invisible to the operating system. All existing ARM registers are re-used in Jazelle state and all registers then have particular functions in this mode. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 31 SAM9X25 SAM9X25 Minimum interrupt latency is maintained across both ARM state and Java state. Since byte codes execution can be restarted, an interrupt automatically triggers the core to switch from Java state to ARM state for the execution of the interrupt handler. This means that no special provision has to be made for handling interrupts while executing byte codes, whether in hard- ware or in software.
  • Page 32 The Thumb state register set is a subset of the ARM state set. The programmer has direct access to: • Eight general-purpose registers r0-r7 • Stack pointer, SP • Link register, LR (ARM r14) • PC • CPSR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 33 SAM9X25 SAM9X25 There are banked registers SPs, LRs and SPSRs for each privileged mode (for more details see the ARM9EJ-S Technical Reference Manual, revision r1p2 page 2-12). 9.4.7.1 Status Registers The ARM9EJ-S core contains one CPSR, and five SPSRs for exception handlers to use. The program status registers: •...
  • Page 34 Execute stage in the pipeline. If the instruction is not executed, for example because a branch occurs while it is in the pipeline, the abort does not take place. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 35 SAM9X25 SAM9X25 The breakpoint (BKPT) instruction is a new feature of ARM9EJ-S that is destined to solve the problem of the Prefetch Abort. A breakpoint instruction operates as though the instruction caused a Prefetch Abort. A breakpoint instruction does not cause the ARM9EJ-S to take the Prefetch Abort exception until the instruction reaches the Execute stage of the pipeline.
  • Page 36 Thumb Instruction Set Overview The Thumb instruction set is a re-encoded subset of the ARM instruction set. The Thumb instruction set is divided into: • Branch instructions • Data processing instructions • Load and Store instructions SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 37 SAM9X25 SAM9X25 • Load and Store multiple instructions • Exception-generating instruction For further details, see the ARM Technical Reference Manual. Table 9-4 gives the Thumb instruction mnemonic list. Table 9-4. Thumb Instruction Mnemonic List Mnemonic Operation Mnemonic Operation Move Move Not...
  • Page 38 1. Register locations 0,5, and 13 each provide access to more than one register. The register accessed depends on the value of the opcode_2 field. 2. Register location 9 provides access to more than one register. The register accessed depends on the value of the CRm field. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 39 SAM9X25 SAM9X25 9.5.1 CP15 Registers Access CP15 registers can only be accessed in privileged mode by: • 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.
  • Page 40 Virtual Address), the access control logic determines if the access is permitted and outputs the appropriate physical address corresponding to the MVA. If access is not permitted, the MMU signals the CPU core to abort. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 41 SAM9X25 SAM9X25 If the TLB does not contain an entry for the MVA, the translation table walk hardware is invoked to retrieve the translation information from the translation table in physical memory. 9.6.3 Translation Table Walk Hardware The translation table walk hardware is a logic that traverses the translation tables located in physical memory, gets the physical address and access permissions and updates the TLB.
  • Page 42 The Write Buffer can hold up to 16 words of data and four separate addresses. DCache and Write Buffer operations are closely connected as their configuration is set in each section by the page descriptor in the MMU translation table. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 43 Any ARM9EJ-S core request that is not 1, 4, 8 words in size is split into packets of these sizes. Note that the Atmel bus is AHB-Lite protocol compliant, hence it does not support split and retry requests.
  • Page 44 AHB. If the ARM9EJ-S is in Thumb state, then two instructions can be fetched at a time. 9.8.3 Address Alignment The ARM926EJ-S BIU performs address alignment checking and aligns AHB addresses to the necessary boundary. 16-bit accesses are aligned to halfword boundaries, and 32-bit accesses are aligned to word boundaries. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 45 10.1 Description The SAM9X25 features a number of complementary debug and test capabilities. A common JTAG/ICE (In-Circuit Emulator) port is used for standard debugging functions, such as down- loading code and single-stepping through programs. The Debug Unit provides a two-pin UART that can be used to upload an application into internal SRAM.
  • Page 46 10.3 Block Diagram Figure 10-1. Debug and Test Block Diagram NTRST ICE/JTAG JTAGSEL Boundary Port RTCK Reset Test ARM9EJ-S ICE-RT ARM926EJ-S DTXD DBGU DRXD TAP: Test Access Port SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 47 SAM9X25 SAM9X25 10.4 Application Examples 10.4.1 Debug Environment Figure 10-2 shows a complete debug environment example. The ICE/JTAG interface is used for standard debugging functions, such as downloading code and single-stepping through the pro- gram. A software debugger running on a personal computer provides the user interface for configuring a Trace Port interface utilizing the ICE/JTAG interface.
  • Page 48 These devices can be connected to form a single scan chain. Figure 10-3. Application Test Environment Example Test Adaptor Tester JTAG Interface ICE/JTAG Chip n Chip 2 Connector SAM9 Chip 1 SAM9-based Application Board In Test SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 49 SAM9X25 SAM9X25 10.5 Debug and Test Pin Description Table 10-1. Debug and Test Pin List Pin Name Function Type Active Level Reset/Test NRST Microcontroller Reset Input/Output Test Mode Select Input High ICE and JTAG NTRST Test Reset Signal Input Test Clock...
  • Page 50 NTRST (optional in IEEE Standard 1149.1) is a Test-ReSeT input which is mandatory in ARM cores and used to reset the debug logic. On Atmel ARM926EJ-S-based cores, NTRST is a Power On Reset output. It is asserted on power on. If necessary, the user can also reset the debug logic with the NTRST pin assertion during 2.5 MCK periods.
  • Page 51 SAM9X25 SAM9X25 10.6.4 Debug Unit The Debug Unit provides a two-pin (DXRD and TXRD) USART that can be used for several debug and trace purposes and offers an ideal means for in-situ programming solutions and debug monitor communication. Moreover, the association with two peripheral data controller channels permits packet handling of these tasks with processor time reduced to a minimum.
  • Page 52 • VERSION[31:28]: Product Version Number Set to 0x0. • PART NUMBER[27:12]: Product Part Number Product part Number is 0x5B2F • MANUFACTURER IDENTITY[11:1] Set to 0x01F. Bit[0] required by IEEE Std. 1149.1. Set to 0x1. JTAG ID Code value is 0x05B2_F03F. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 53 SAM9X25 SAM9X25 11. Boot Strategies The system always boots at address 0x0. To ensure maximum boot possibilities, the memory layout can be changed thanks to the BMS pin. This allows the user to layout the ROM or an external memory to 0x0. The sampling of the BMS pin is done at reset.
  • Page 54 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 55 SAM9X25 SAM9X25 11.4 NVM Boot 11.4.1 NVM Boot Sequence The boot sequence on external memory devices can be controlled using the Boot Sequence Register (BSCR). The 3 LSBs of the BSCR are available to control the sequence. The user can then choose to bypass some steps shown in Figure 11-2 “NVM Bootloader...
  • Page 56 NAND Flash Bootloader NAND Flash to SRAM Y es Copy from SPI0 CS1 Flash Boot SPI Flash Bootloader SPI Flash to SRAM Y es Copy from TWI EEPROM Boot TWI EEPROM Bootloader TWI EEPROM to SRAM SAM-BA Monitor SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 57 SAM9X25 SAM9X25 11.4.2 NVM Bootloader Program Description Figure 11-3. NVM Bootloader Program Diagram Start Initialize NVM Restore the reset values Initialization OK ? for the peripherals and Jump to next boot solution Y es Valid code detection in NVM NVM contains valid code...
  • Page 58 Unconditional instruction: 0xE for bits 31 to 28 Load PC with PC relative addressing instruction: – 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 59 SAM9X25 SAM9X25 The sixth vector, at offset 0x14, contains the size of the image to download. The user must replace this vector with the user’s own vector. This information is described below. Figure 11-7. Structure of the ARM Vector 6 Size of the code to download in bytes The value has to be smaller than 24 kbytes.
  • Page 60 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 Restore the reset values for the peripherals and Jump to next bootable memory SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 61 SAM9X25 SAM9X25 NAND Flash Specific Header Detection This is the first method used to determine NAND Flash parameters. After Initialization and Reset command, the Boot Program reads the first page without ECC check, to determine if the NAND parameter header is present. The header is made of 52 times the same 32-bit word (for redun- dancy reasons) which must contain NAND and PMECC parameters used to correctly perform the read of the rest of the data in the NAND.
  • Page 62 PMECC_status, unsigned int pageBuffer) pPMECC: pointer to the PMECC base address, pPMERRLOC: pointer to the PMERRLOC base address, PMECC_desc: pointer to the PMECC descriptor, PMECC_status: the status returned by the read of PMECCISR register; SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 63 SAM9X25 SAM9X25 pageBuffer: address of the buffer containing the page to be corrected. The PMECC descriptor structure is: typedef struct _PMECC_paramDesc_struct { unsigned int pageSize; unsigned int spareSize; unsigned int sectorSize; // 0 for 512, 1 for 1024 bytes unsigned int errBitNbrCapability;...
  • Page 64 For a full description and an example of how to use the PMECC detection and correction fea- ture, refer to the software package dedicated to this device on Atmel’s web site. 11.4.4.3 SD Card Boot The SD Card bootloader uses MCI0. It looks for a “boot.bin” file in the root directory of a FAT12/16/32 formatted SD Card.
  • Page 65 SAM9X25 SAM9X25 Supported DataFlash Devices The SPI Flash Boot program supports all Atmel DataFlash devices. Table 11-2. DataFlash Device Device Density Page Size (bytes) Number of Pages AT45DB011 1 Mbit AT45DB021 2 Mbits 1024 AT45DB041 4 Mbits 2048 AT45DB081 8 Mbits...
  • Page 66 – Check if USB Device enumeration has occurred – Check if characters have been 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 11-4. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 67 SAM9X25 SAM9X25 Figure 11-10. SAM-BA Monitor Diagram No valid code in NVM Init DBGU and USB USB Enumeration Character(s) received Successful ? on DBGU ? Run monitor Run monitor Wait for command Wait for command on the USB link on the DBGU link 11.5.1...
  • Page 68 – <blk #> = binary number, starts at 01, increments by 1, and wraps 0FFH to 00H (not to 01) – <255-blk #> = 1’s complement of the blk#. – <checksum> = 2 bytes CRC16 Figure 11-11 shows a transmission using this protocol. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 69 ISDN modems and virtual COM ports. The Vendor ID is Atmel’s vendor ID 0x03EB. The product ID is 0x6124. These references are used by the host operating system to mount the correct driver. On Windows systems, the INF files contain the correspondence between vendor ID and product ID.
  • Page 70 BA Boot commands are sent by the host through endpoint 1. If required, the message is split by the host into several data payloads by the host driver. If the command requires a response, the host can send IN transactions to pick up the response. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 71 SAM9X25 SAM9X25 12. Boot Sequence Controller (BSC) 12.1 Description The System Controller embeds a Boot Sequence Configuration Register to save timeout delays on boot. The boot sequence is programmable through the Boot Sequence Configuration Regis- ter (BSCR). This register is powered by VDDBU, the modification is saved and applied after the next reset.
  • Page 72 Factory Value:0x0000_0000 BOOTKEY BOOT BOOT BOOT • BOOTx: Boot media sequence Is defined in the product-dependent ROM code. • BOOTKEY 0xB5 (VALID): valid boot key To avoid spurious writing, this key is necessary for write accesses. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 73 SAM9X25 SAM9X25 13. Advanced Interrupt Controller (AIC) 13.1 Description The Advanced Interrupt Controller (AIC) is an 8-level priority, individually maskable, vectored interrupt controller, providing handling of up to thirty-two interrupt sources. It is designed to sub- stantially reduce the software and real-time overhead in handling internal and external interrupts.
  • Page 74 Advanced Interrupt Controller Processor Fast nFIQ External Interrupt Controller Source Controller Input Stage nIRQ IRQ0-IRQn Interrupt Fast PIOIRQ Processor Priority Forcing Clock Controller Internal Source Power Input Management Stage Embedded Controller Peripherals User Interface Wake Up SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 75 SAM9X25 SAM9X25 13.6 I/O Line Description Table 13-1. I/O Line Description Pin Name Pin Description Type Fast Interrupt Input IRQ0 - IRQn Interrupt 0 - Interrupt n Input 13.7 Product Dependencies 13.7.1 I/O Lines The interrupt signals FIQ and IRQ0 to IRQn are normally multiplexed through the PIO control- lers.
  • Page 76 “Priority Controller” on page 79) and the register AIC_CISR gives an image of the signals nIRQ and nFIQ driven on the processor. Each status referred to above can be used to optimize the interrupt handling of the systems. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 77 SAM9X25 SAM9X25 Figure 13-4. Internal Interrupt Source Input Stage AIC_SMRI (SRCTYPE) Level/ AIC_IPR Source i Edge AIC_IMR Fast Interrupt Controller Priority Controller Edge AIC_IECR Detector Clear AIC_ISCR AIC_ICCR AIC_IDCR Figure 13-5. External Interrupt Source Input Stage AIC_SMRi SRCTYPE High/Low Level/...
  • Page 78 Maximum FIQ Latency = 4 Cycles Figure 13-7. External Interrupt Level Sensitive Source IRQ or FIQ (High Level) IRQ or FIQ (Low Level) nIRQ Maximum IRQ Latency = 3 Cycles nFIQ Maximum FIQ Latency = 3 cycles SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 79 SAM9X25 SAM9X25 Figure 13-8. Internal Interrupt Edge Triggered Source nIRQ Maximum IRQ Latency = 4.5 Cycles Peripheral Interrupt Becomes Active Figure 13-9. Internal Interrupt Level Sensitive Source nIRQ Maximum IRQ Latency = 3.5 Cycles Peripheral Interrupt Becomes Active 13.8.3 Normal Interrupt 13.8.3.1...
  • Page 80 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 espe- cially the processor interrupt modes and the associated status bits. It is assumed that: SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 81 SAM9X25 SAM9X25 1. The Advanced Interrupt Controller has been programmed, AIC_SVR registers are loaded with corresponding interrupt service routine addresses and interrupts are enabled. 2. The instruction at the ARM interrupt exception vector address is required to work with the vectoring LDR PC, [PC, # -&F20]...
  • Page 82 2. The ARM core enters FIQ mode. 3. 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 automati- SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 83 SAM9X25 SAM9X25 cally clearing the fast interrupt, if it has been programmed to be edge triggered. In this case only, it de-asserts the nFIQ line on the processor. 4. The previous step enables branching to the corresponding interrupt service routine. It is not necessary to save the link register R14_fiq and SPSR_fiq if nested fast interrupts are not needed.
  • Page 84 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 85 SAM9X25 SAM9X25 To summarize, in normal operating mode, the read of AIC_IVR performs the following opera- tions within the AIC: 1. Calculates active interrupt (higher than current or spurious). 2. Determines and returns the vector of the active interrupt. 3. Memorizes the interrupt.
  • Page 86 The protected registers are: • “AIC Source Mode Register” on page 88 • “AIC Source Vector Register” on page 89 • “AIC Spurious Interrupt Vector Register” on page 100 • “AIC Debug Control Register” on page 101 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 87: Table Of Contents

    SAM9X25 SAM9X25 13.10 Advanced Interrupt Controller (AIC) User Interface 13.10.1 Base Address The AIC is mapped at the address 0xFFFF F000. It has a total 4-Kbyte addressing space. This permits the vectoring fea- ture, as the PC-relative load/store instructions of the ARM processor support only a ± 4-Kbyte offset.
  • Page 88 Positive edge triggered for internal source INT_EDGE_TRIGGERED Negative edge triggered for external source High level Sensitive for internal source EXT_HIGH_LEVEL High level Sensitive for external source Positive edge triggered for internal source EXT_POSITIVE_EDGE Positive edge triggered for external source SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 89: Name Aic_Smr0

    SAM9X25 SAM9X25 13.10.3 AIC Source Vector Register Name: AIC_SVR0..AIC_SVR31 Address: 0xFFFFF080 Access: Read-write Reset: VECTOR VECTOR VECTOR VECTOR This register can only be written if the WPEN bit is cleared in AIC Write Protect Mode Register • VECTOR: Source Vector The user may store in these registers the addresses of the corresponding handler for each interrupt source.
  • Page 90: Aic_Ivr

    The Source Vector Register is indexed using the current interrupt number when the Interrupt Vector Register is read. When there is no current interrupt, the Interrupt Vector Register reads the value stored in AIC_SPU. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 91: Aic_Fvr

    SAM9X25 SAM9X25 13.10.5 AIC FIQ Vector Register Name: AIC_FVR Address: 0xFFFFF104 Access: Read-only Reset: FIQV FIQV FIQV FIQV • FIQV: FIQ Vector Register The FIQ Vector Register contains the vector programmed by the user in the Source Vector Register 0. When there is no fast interrupt, the FIQ Vector Register reads the value stored in AIC_SPU.
  • Page 92: Aic_Isr

    – – – – – – – – – – – – – – – – – – – – IRQID • IRQID: Current Interrupt Identifier The Interrupt Status Register returns the current interrupt source number. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 93: Aic_Ipr

    SAM9X25 SAM9X25 13.10.7 AIC Interrupt Pending Register Name: AIC_IPR Address: 0xFFFFF10C Access: Read-only Reset: PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24 PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6...
  • Page 94: Aic_Cisr

    – – NIRQ NFIQ • NFIQ: NFIQ Status 0 = nFIQ line is deactivated. 1 = nFIQ line is active. • NIRQ: NIRQ Status 0 = nIRQ line is deactivated. 1 = nIRQ line is active. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 95: Aic_Iecr

    SAM9X25 SAM9X25 13.10.10 AIC Interrupt Enable Command Register Name: AIC_IECR Address: 0xFFFFF120 Access: Write-only PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24 PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6...
  • Page 96: Aic_Idcr

    PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6 PID5 PID4 PID3 PID2 • FIQ, SYS, PID2-PID31: Interrupt Disable 0 = No effect. 1 = Disables corresponding interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 97: Aic_Iccr

    SAM9X25 SAM9X25 13.10.12 AIC Interrupt Clear Command Register Name: AIC_ICCR Address: 0xFFFFF128 Access: Write-only PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24 PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6...
  • Page 98: Aic_Iscr

    PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6 PID5 PID4 PID3 PID2 • FIQ, SYS, PID2-PID31: Interrupt Set 0 = No effect. 1 = Sets corresponding interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 99: Aic_Eoicr

    SAM9X25 SAM9X25 13.10.14 AIC End of Interrupt Command Register Name: AIC_EOICR Address: 0xFFFFF130 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 100: Aic_Spu

    The user may store the address of a spurious interrupt handler in this register. The written value is returned in AIC_IVR in case of a spurious interrupt and in AIC_FVR in case of a spurious fast interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 101: Aic_Dcr

    SAM9X25 SAM9X25 13.10.16 AIC Debug Control Register Name: AIC_DCR Address: 0xFFFFF138 Access: Read-write Reset: – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 102 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6 PID5 PID4 PID3 PID2 – • SYS, PID2-PID31: Fast Forcing Enable 0 = No effect. 1 = Enables the fast forcing feature on the corresponding interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 103 SAM9X25 SAM9X25 13.10.18 AIC Fast Forcing Disable Register Name: AIC_FFDR Address: 0xFFFFF144 Access: Write-only PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24 PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6...
  • Page 104 PID6 PID5 PID4 PID3 PID2 – • SYS, PID2-PID31: Fast Forcing Status 0 = The Fast Forcing feature is disabled on the corresponding interrupt. 1 = The Fast Forcing feature is enabled on the corresponding interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 105 SAM9X25 SAM9X25 13.10.20 AIC Write Protect Mode Register Name: AIC_WPMR Address: 0xFFFFF1E4 Access: Read-write Reset: Table 13-3 WPKEY WPKEY WPKEY — — — — — — — WPEN • WPEN: Write Protect Enable 0 = Disables the Write Protect if WPKEY corresponds to 0x414943 ("AIC" in ASCII).
  • Page 106: Aic_Wpsr

    • WPVSRC: Write Protect Violation Source When WPVS is active, this field indicates the write-protected register (through address offset or code) in which a write access has been attempted. Note: Reading AIC_WPSR automatically clears all fields. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 107 SAM9X25 SAM9X25 14. Reset Controller (RSTC) 14.1 Description The Reset Controller (RSTC), based on power-on reset cells, handles all the resets of the sys- tem without any external components. It reports which reset occurred last. The Reset Controller also drives independently or simultaneously the external reset and the peripheral and processor resets.
  • Page 108 Characteristics in the Electrical Characteristics section of the product documentation. The Reset Controller Mode Register (RSTC_MR), allowing the configuration of the Reset Con- troller, is powered with VDDBU, so that its configuration is saved as long as VDDBU is on. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 109 SAM9X25 SAM9X25 14.4.2 NRST Manager After power-up, NRST is an output during the ERSTL time defined in the RSTC. When ERSTL elapsed, the pin behaves as an input and all the system is held in reset if NRST is tied to GND by an external signal.
  • Page 110 VDDBU only activates the backup_nreset signal. The backup_nreset must be released so that any other reset can be generated by VDDCORE (Main Supply POR output). Figure 14-4 shows how the General Reset affects the reset signals. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 111 SAM9X25 SAM9X25 Figure 14-4. General Reset State SLCK Freq. Backup Supply POR output Startup Time Main Supply POR output backup_nreset Processor Startup proc_nreset RSTTYP 0x0 = General Reset periph_nreset NRST (nrst_out) EXTERNAL RESET LENGTH BMS Sampling = 2 cycles 14.4.5.2 Wake-up Reset The Wake-up Reset occurs when the Main Supply is down.
  • Page 112 EXTERNAL_RESET_LENGTH Slow Clock cycles, as programmed in the field ERSTL. How- ever, 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 113 SAM9X25 SAM9X25 Figure 14-6. User Reset State SLCK Freq. NRST Resynch. Processor Startup 2 cycles proc_nreset RSTTYP 0x4 = User Reset periph_nreset NRST (nrst_out) >= EXTERNAL RESET LENGTH 14.4.5.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 •...
  • Page 114 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 115 SAM9X25 SAM9X25 Figure 14-8. Watchdog Reset SLCK Freq. wd_fault Processor Startup = 3 cycles proc_nreset RSTTYP 0x2 = Watchdog Reset periph_nreset Only if WDRPROC = 0 NRST (nrst_out) EXTERNAL RESET LENGTH 8 cycles (ERSTL=2) 14.4.6 Reset State Priorities The Reset State Manager manages the following priorities between the different reset sources, given in descending order: •...
  • Page 116 14-9). . Reading the RSTC_SR status register resets the URSTS bit . Figure 14-9. Reset Controller Status and Interrupt read Peripheral Access RSTC_SR 2 cycle 2 cycle resynchronization resynchronization NRST NRSTL URSTS rstc_irq if (URSTEN = 0) and (URSTIEN = 1) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 117 SAM9X25 SAM9X25 14.5 Reset Controller (RSTC) User Interface Table 14-1. Register Mapping Offset Register Name Access Reset Back-up Reset 0x00 Control Register RSTC_CR Write-only 0x04 Status Register RSTC_SR Read-only 0x0000_0001 0x0000_0000 0x08 Mode Register RSTC_MR Read-write 0x0000_0000 Note: 1. The reset value of RSTC_SR either reports a General Reset or a Wake-up Reset depending on last rising power supply.
  • Page 118 • EXTRST: External Reset 0 = No effect. 1 = If KEY is correct, asserts the NRST pin. • KEY: Password Should be written at value 0xA5. Writing any other value in this field aborts the write operation. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 119 0 = No software command is being performed by the reset controller. The reset controller is ready for a software command. 1 = A software reset command is being performed by the reset controller. The reset controller is busy. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 120 Slow Clock cycles. This allows assertion duration to be programmed between 60 μs and 2 seconds. • KEY: Password Should be written at value 0xA5. Writing any other value in this field aborts the write operation. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 121 SAM9X25 SAM9X25 15. Real-time Clock (RTC) 15.1 Description The Real-time Clock (RTC) peripheral is designed for very low power consumption. It combines a complete time-of-day clock with alarm and a two-hundred-year Gregorian calen- dar, complemented by a programmable periodic interrupt. The alarm and calendar registers are accessed by a 32-bit data bus.
  • Page 122 Each of these fields can be enabled or disabled to match the alarm condition: • If all the fields are enabled, an alarm flag is generated (the corresponding flag is asserted and an interrupt generated if enabled) at a given month, date, hour/minute/second. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 123 SAM9X25 SAM9X25 • 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.
  • Page 124 Set UPDTIM and/or UPDCAL bit(s) in RTC_CR Read RTC_SR Polling or IRQ (if enabled) ACKUPD = 1 ? Clear ACKUPD bit in RTC_SCCR Update Time and/or Calendar values in RTC_TIMR/RTC_CALR Clear UPDTIM and/or UPDCAL bit in RTC_CR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 125 SAM9X25 SAM9X25 15.6 Real Time Clock (RTC) User Interface Table 15-1. Register Mapping Offset Register Name Access Reset 0x00 Control Register RTC_CR Read-write 0x04 Mode Register RTC_MR Read-write 0x08 Time Register RTC_TIMR Read-write 0x0C Calendar Register RTC_CALR Read-write 0x01210720 0x10...
  • Page 126: Rtc_Cr

    The event that generates the flag CALEV in RTC_SR depends on the value of CALEVSEL Value Name Description WEEK Week change (every Monday at time 00:00:00) MONTH Month change (every 01 of each month at time 00:00:00) YEAR Year change (every January 1 at time 00:00:00) – SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 127: Rtc_Mr

    SAM9X25 SAM9X25 15.6.2 RTC Mode Register Name: RTC_MR Address: 0xFFFFFEB4 Access: Read-write – – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 128: Rtc_Timr

    The range that can be set is 1 - 12 (BCD) in 12-hour mode or 0 - 23 (BCD) in 24-hour mode. • AMPM: Ante Meridiem Post Meridiem Indicator This bit is the AM/PM indicator in 12-hour mode. 0 = AM. 1 = PM. All non-significant bits read zero. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 129: Rtc_Calr

    SAM9X25 SAM9X25 15.6.4 RTC Calendar Register Name: RTC_CALR Address: 0xFFFFFEBC Access: Read-write – – DATE MONTH YEAR – CENT • CENT: Current Century The range that can be set is 19 - 20 (BCD). The lowest four bits encode the units. The higher bits encode the tens.
  • Page 130: Rtc_Timalr

    This field is the alarm field corresponding to the BCD-coded hour counter. • AMPM: AM/PM Indicator This field is the alarm field corresponding to the BCD-coded hour counter. • HOUREN: Hour Alarm Enable 0 = The hour-matching alarm is disabled. 1 = The hour-matching alarm is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 131: Rtc_Calalr

    SAM9X25 SAM9X25 15.6.6 RTC Calendar Alarm Register Name: RTC_CALALR Address: 0xFFFFFEC4 Access: Read-write DATEEN – DATE MTHEN – – MONTH – – – – – – – – – – – – – – – – • MONTH: Month Alarm This field is the alarm field corresponding to the BCD-coded month counter.
  • Page 132: Rtc_Sr

    1 = At least one calendar event has occurred since the last clear. The calendar event is selected in the CALEVSEL field in RTC_CR and can be any one of the following events: week change, month change and year change. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 133: Rtc_Sccr

    SAM9X25 SAM9X25 15.6.8 RTC Status Clear Command Register Name: RTC_SCCR Address: 0xFFFFFECC Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 134: Rtc_Ier

    • TIMEN: Time Event Interrupt Enable 0 = No effect. 1 = The selected time event interrupt is enabled. • CALEN: Calendar Event Interrupt Enable 0 = No effect. • 1 = The selected calendar event interrupt is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 135: Rtc_Idr

    SAM9X25 SAM9X25 15.6.10 RTC Interrupt Disable Register Name: RTC_IDR Address: 0xFFFFFED4 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 136: Rtc_Imr

    0 = The selected time event interrupt is disabled. 1 = The selected time event interrupt is enabled. • CAL: Calendar Event Interrupt Mask 0 = The selected calendar event interrupt is disabled. 1 = The selected calendar event interrupt is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 137: Rtc_Ver

    SAM9X25 SAM9X25 15.6.12 RTC Valid Entry Register Name: RTC_VER Address: 0xFFFFFEDC Access: Read-only – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 138 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 139 SAM9X25 SAM9X25 16. Periodic Interval Timer (PIT) 16.1 Description The Periodic Interval Timer (PIT) provides the operating system’s scheduler interrupt. It is designed to offer maximum accuracy and efficient management, even for systems with long response time. 16.2 Embedded Characteristics •...
  • Page 140 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 141 SAM9X25 SAM9X25 Figure 16-2. Enabling/Disabling PIT with PITEN APB cycle APB cycle restarts MCK Prescaler MCK Prescaler PITEN CPIV PIV - 1 PICNT PITS (PIT_SR) APB Interface read PIT_PIVR 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 142 Table 16-1. Register Mapping Offset Register Name Access Reset 0x00 Mode Register PIT_MR Read-write 0x000F_FFFF 0x04 Status Register PIT_SR Read-only 0x0000_0000 0x08 Periodic Interval Value Register PIT_PIVR Read-only 0x0000_0000 0x0C Periodic Interval Image Register PIT_PIIR Read-only 0x0000_0000 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 143 SAM9X25 SAM9X25 16.5.1 Periodic Interval Timer Mode Register Name: PIT_MR Address: 0xFFFFFE30 Access: Read-write – – – – – – PITIEN PITEN – – – – • PIV: Periodic Interval Value Defines the value compared with the primary 20-bit counter of the Periodic Interval Timer (CPIV). The period is equal to (PIV + 1).
  • Page 144 SAM9X25 SAM9X25 16.5.2 Periodic Interval Timer Status Register Name: PIT_SR Address: 0xFFFFFE34 Access: Read-only – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 145 SAM9X25 SAM9X25 16.5.3 Periodic Interval Timer Value Register Name: PIT_PIVR Address: 0xFFFFFE38 Access: Read-only PICNT PICNT CPIV CPIV CPIV Reading this register clears PITS in PIT_SR. • CPIV: Current Periodic Interval Value Returns the current value of the periodic interval timer.
  • Page 146 CPIV CPIV • CPIV: Current Periodic Interval Value Returns the current value of the periodic interval timer. • PICNT: Periodic Interval Counter Returns the number of occurrences of periodic intervals since the last read of PIT_PIVR. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 147 SAM9X25 SAM9X25 17. Watchdog Timer (WDT) 17.1 Description The Watchdog Timer can be used to prevent system lock-up if the software becomes trapped in a deadlock. It features a 12-bit down counter that allows a watchdog period of up to 16 seconds (slow clock at 32.768 kHz).
  • Page 148 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 149 SAM9X25 SAM9X25 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. Figure 17-2. Watchdog Behavior Watchdog Error Watchdog Underflow...
  • Page 150 17.5 Watchdog Timer (WDT) User Interface Table 17-1. Register Mapping Offset Register Name Access Reset 0x00 Control Register WDT_CR Write-only 0x04 Mode Register WDT_MR Read-write Once 0x3FFF_2FFF 0x08 Status Register WDT_SR Read-only 0x0000_0000 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 151 SAM9X25 SAM9X25 17.5.1 Watchdog Timer Control Register Name: WDT_CR Address: 0xFFFFFE40 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – WDRSTT • WDRSTT: Watchdog Restart 0: No effect.
  • Page 152 1: The Watchdog stops when the processor is in debug state. • WDIDLEHLT: Watchdog Idle Halt 0: The Watchdog runs when the system is in idle mode. 1: The Watchdog stops when the system is in idle state. • WDDIS: Watchdog Disable SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 153 SAM9X25 SAM9X25 0: Enables the Watchdog Timer. 1: Disables the Watchdog Timer. 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 154 1: At least one Watchdog underflow occurred since the last read of WDT_SR. • WDERR: Watchdog Error 0: No Watchdog error occurred since the last read of WDT_SR. 1: At least one Watchdog error occurred since the last read of WDT_SR. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 155 SAM9X25 SAM9X25 18. Shutdown Controller (SHDWC) 18.1 Description The Shutdown Controller controls the power supplies VDDIO and VDDCORE and the wake-up detection on debounced input lines. 18.2 Embedded Characteristics • Shutdown and Wake-up Logic – Software Assertion of the SHDW Output Pin –...
  • Page 156 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 password-protected and so the value written SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 157 SAM9X25 SAM9X25 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).
  • Page 158 18.7 Shutdown Controller (SHDWC) User Interface Table 18-2. Register Mapping Offset Register Name Access Reset 0x00 Shutdown Control Register SHDW_CR Write-only 0x04 Shutdown Mode Register SHDW_MR Read-write 0x0000_0003 0x08 Shutdown Status Register SHDW_SR Read-only 0x0000_0000 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 159 SAM9X25 SAM9X25 18.7.1 Shutdown Control Register Name: SHDW_CR Address: 0xFFFFFE10 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – SHDW • SHDW: Shutdown Command 0 = No effect.
  • Page 160 (CPTWK x 16 + 1) Slow Clock cycles after the event on WKUP. • RTCWKEN: Real-time Clock Wake-up Enable 0 = The RTC Alarm signal has no effect on the Shutdown Controller. 1 = The RTC Alarm signal forces the de-assertion of the SHDN pin. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 161 • RTCWK: Real-time Clock Wake-up 0 = No wake-up alarm from the RTC occurred since the last read of SHDW_SR. 1 = At least one wake-up alarm from the RTC occurred since the last read of SHDW_SR. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 162 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 163 SAM9X25 SAM9X25 19. General Purpose Backup Registers (GPBR) 19.1 Description The System Controller embeds Four general-purpose backup registers. 19.2 Embedded Characteristics • Four 32-bit General Purpose Backup Registers 19.3 General Purpose Backup Registers (GPBR) User Interface Table 19-1. Register Mapping...
  • Page 164 19.3.1 General Purpose Backup Register x Name: SYS_GPBRx Address: 0xFFFFFE60 [0], 0xFFFFFE64 [1], 0xFFFFFE68 [2], 0xFFFFFE6C [3] Access: Read-write GPBR_VALUEx GPBR_VALUEx GPBR_VALUEx GPBR_VALUEx • GPBR_VALUEx: Value of GPBR x SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 165 SAM9X25 SAM9X25 20. Slow Clock Controller (SCKC) 20.1 Description The System Controller embeds a Slow Clock Controller. The slow clock can be generated either by an external 32,768 Hz crystal oscillator or by the on- chip 32 kHz RC oscillator. The 32,768 Hz crystal oscillator can be bypassed by setting the bit OSC32BYP to accept an external slow clock on XIN32.
  • Page 166 • Switch from 32,768 Hz oscillator to internal RC by setting the bit OSCSEL to 0. • Wait 5 slow clock cycles for internal resynchronization. • Disable the 32,768 Hz oscillator by setting the bit OSC32EN to 0. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 167 SAM9X25 SAM9X25 20.4 Slow Clock Configuration (SCKC) User Interface Table 20-1. Register Mapping Offset Register Name Access Reset Slow Clock Configuration Register SCKC_CR Read-write 0x0000_0001 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 168 SAM9X25 SAM9X25 20.4.1 Slow Clock Configuration Register Name: SCKC_CR Address: 0xFFFFFE50 Access: Read-write Reset: 0x0000_0001 – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 169 SAM9X25 SAM9X25 21. Clock Generator (CKGR) 21.1 Description The Clock Generator User Interface is embedded within the Power Management Controller and is described in Section 22.13 ”Power Management Controller (PMC) User Interface”. However, the Clock Generator registers are named CKGR_.
  • Page 170 The internal 32 kHz RC oscillator and the 32,768 Hz oscillator can be enabled by setting to 1, respectively, RCEN bit and OSC32EN bit in the System Controller user interface. The OSCSEL command selects the slow clock source. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 171 SAM9X25 SAM9X25 Figure 21-2. Slow Clock Clock Generator RCEN On Chip RC OSC Slow Clock SLCK Slow Clock XIN32 Oscillator XOUT32 OSCSEL OSC32EN OSC32BYP RCEN, OSC32EN,OSCSEL and OSC32BYP bits are located in the Slow Clock Control Register (SCKCR) located at address 0xFFFFFE50 in the backed up part of the System Controller and so are preserved while VDDBU is present.
  • Page 172 • 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. • Switch the master clock back to the slow clock domain SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 173 SAM9X25 SAM9X25 21.4.4 Slow Clock Configuration Register Name: SCKCR Address: 0xFFFFFE50 Access: Read-write Reset Value: 0x0000_0001 – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 174 12 MHz RC oscillator. This fast RC oscillator allows the processor to start or restart in a few microseconds when 12 MHz internal RC is selected. The 12 MHz crystal oscillator can be bypassed by setting the bit MOSCXTBY to accept an exter- nal main clock on XIN. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 175 SAM9X25 SAM9X25 Figure 21-4. Main Clock Selection MOSCRCEN On Chip 12M RC OSC Main Clock Main Clock Oscillator XOUT MOSCSEL MOSCXTEN MOSCXTBY 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 oscillator is started as Main clock.
  • Page 176 (PMC_IER) can trigger an interrupt to the processor. 21.6.6 3 to 20 MHz Crystal Oscillator After reset, the 3 to 20 MHz Crystal Oscillator is disabled and it is not selected as the source of MAINCK. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 177 SAM9X25 SAM9X25 The user can select the 3 to 20 MHz crystal oscillator to be the source of MAINCK, as it provides a more accurate frequency. The software enables or disables the main oscillator so as to reduce power consumption by clearing the MOSCXTEN bit in the Main Oscillator Register (CKGR_MOR).
  • Page 178 MAINCK, the 12 MHz frequency must also be selected because the UTMI PLL multiplier contains a built-in multiplier of x 40 to obtain the USB High Speed 480 MHz. A 12 MHz crystal is needed to use the USB. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 179 SAM9X25 SAM9X25 Figure 21-7. UTMI PLL Block Diagram UPLLEN MAINCK UTMI PLL UPLLCK UPLLCOUNT UTMI PLL SLCK LOCKU Counter 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.
  • Page 180 • Slow Clock Mode, processor and peripherals running at low frequency • Standby Mode, mix of Idle and Backup Mode, peripheral running at low frequency, processor stopped waiting for an interrupt • Backup Mode, Main Power Supplies off, VDDBU powered by a battery SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 181 SAM9X25 SAM9X25 22.3 Master Clock Controller The Master Clock Controller provides selection and division of the Master Clock (MCK). MCK is the clock provided to all the peripherals and the memory controller. The Master Clock is selected from one of the clocks provided by the Clock Generator. Selecting the Slow Clock provides a Slow Clock signal to the whole device.
  • Page 182 Note: The ARM Wait for Interrupt mode is entered by means of CP15 coprocessor operation. Refer to the Atmel application note, Optimizing Power Consumption for AT91SAM9261-based Systems, http://www.atmel.com/dyn/resources/prod_documents/doc6217.pdf. When the Processor Clock is disabled, the current instruction is finished before the clock is stopped, but this does not prevent data transfers from other masters of the system bus.
  • Page 183 SAM9X25 SAM9X25 22.6 USB Device and Host Clocks The USB Device and Host High Speed ports clocks are controlled by the UDPHS and UHPHS bits in PMC_PCER. To save power on this peripheral when they are is not used, the user can set these bits in PMC_PCDR.
  • Page 184 PMC_SR register to be set. This can be done either by polling the status register or by wait- ing the interrupt line to be raised if the associated interrupt to MOSCS has been enabled in the PMC_IER register. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 185 SAM9X25 SAM9X25 2. Setting PLLA and divider: All parameters needed to configure PLLA and the divider are located in the CKGR_PLLAR register. The DIVA field is used to control the divider itself. A value between 0 and 255 can be pro- grammed.
  • Page 186 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 22.12.2. “Clock Switching Waveforms” on page 189. Code Example: write_register(PMC_MCKR,0x00000001) wait (MCKRDY=1) write_register(PMC_MCKR,0x00000011) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 187 SAM9X25 SAM9X25 wait (MCKRDY=1) The Master Clock is main clock divided by 16. The Processor Clock is the Master Clock. 5. Selection of 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.
  • Page 188 4 x SLCK + PLLACOUNT x SLCK 1.5 x PLLA Clock 3 x UPLL Clock + 2.5 x UPLL Clock + UPLL Clock 4 x SLCK + 4 x SLCK + 1.5 x UPLL Clock UPLLCOUNT x SLCK SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 189 SAM9X25 SAM9X25 22.12.2 Clock Switching Waveforms Figure 22-3. Switch Master Clock from Slow Clock to PLL Clock Slow Clock PLL Clock LOCK MCKRDY Master Clock Write PMC_MCKR Figure 22-4. Switch Master Clock from Main Clock to Slow Clock Slow Clock...
  • Page 190 PLLA Clock LOCKA MCKRDY Master Clock Slow Clock Write CKGR_PLLAR Figure 22-6. Programmable Clock Output Programming PLL Clock PCKRDY PCKx Output Write PMC_PCKx PLL Clock is selected Write PMC_SCER PCKx is enabled Write PMC_SCDR PCKx is disabled SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 191 SAM9X25 SAM9X25 22.13 Power Management Controller (PMC) User Interface Table 22-3. Register Mapping Offset Register Name Access Reset 0x0000 System Clock Enable Register PMC_SCER Write-only N.A. 0x0004 System Clock Disable Register PMC_SCDR Write-only N.A. 0x0008 System Clock Status Register PMC_SCSR...
  • Page 192: Pmc_Scer

    • UDP: USB Device Clock Enable 0 = No effect. 1 = Enables the USB Device clock. • PCKx: Programmable Clock x Output Enable 0 = No effect. 1 = Enables the corresponding Programmable Clock output. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 193: Pmc_Scdr

    SAM9X25 SAM9X25 22.13.2 PMC System Clock Disable Register Name: PMC_SCDR Address: 0xFFFFFC04 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – PCK1 PCK0 – SMDCK –...
  • Page 194: Pmc_Scsr

    0 = The USB Device clock is disabled. 1 = The USB Device clock is enabled. • PCKx: Programmable Clock x Output Status 0 = The corresponding Programmable Clock output is disabled. 1 = The corresponding Programmable Clock output is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 195 SAM9X25 SAM9X25 22.13.4 PMC Peripheral Clock Enable Register Name: PMC_PCER Address: 0xFFFFFC10 Access: Write-only PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24 PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6...
  • Page 196 PID2 • PIDx: Peripheral Clock x Disable 0 = No effect. 1 = Disables the corresponding peripheral clock. Note: PID2 to PID31 refer to identifiers as defined in the section “Peripheral Identifiers” in the product datasheet. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 197 SAM9X25 SAM9X25 22.13.6 PMC Peripheral Clock Status Register Name: PMC_PCSR Address: 0xFFFFFC18 Access: Read-only PID31 PID30 PID29 PID28 PID27 PID26 PID25 PID24 PID23 PID22 PID21 PID20 PID19 PID18 PID17 PID16 PID15 PID14 PID13 PID12 PID11 PID10 PID9 PID8 PID7 PID6...
  • Page 198: Ckgr_Uckr

    • BIASEN: UTMI BIAS Enable 0 = The UTMI BIAS is disabled. 1 = The UTMI BIAS is enabled. • BIASCOUNT: UTMI BIAS Start-up Time Specifies the number of Slow Clock cycles for the UTMI BIAS start-up time. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 199: Ckgr_Mor

    SAM9X25 SAM9X25 22.13.8 PMC Clock Generator Main Oscillator Register Name: CKGR_MOR Address: 0xFFFFFC20 Access: Read-write – – – – – – CFDEN MOSCSEL MOSCXTST – – – – MOSCRCEN – MOSCXTBY MOSCXTEN • KEY: Password Should be written at value 0x37. Writing any other value in this field aborts the write operation.
  • Page 200: Ckgr_Mcfr

    Gives the number of Main Clock cycles within 16 Slow Clock periods. • MAINFRDY: Main Clock Ready 0 = MAINF value is not valid or the Main Oscillator is disabled. 1 = The Main Oscillator has been enabled previously and MAINF value is available. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 201: Ckgr_Pllar

    SAM9X25 SAM9X25 22.13.10 PMC Clock Generator PLLA Register Name: CKGR_PLLAR Address: 0xFFFFFC28 Access: Read-write – – – – MULA MULA OUTA PLLACOUNT DIVA 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.
  • Page 202 SysClk DDR is equal to 2 x MCK. DDRCK is equal to MCK. Master Clock is Prescaler Output Clock divided by 3. PCK_DIV3 SysClk DDR is equal to 2 x MCK. DDRCK is equal to MCK. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 203 SAM9X25 SAM9X25 • PLLADIV2: PLLA divisor by 2 Value Name Description NOT_DIV2 PLLA clock frequency is divided by 1. DIV2 PLLA clock frequency is divided by 2. 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 204 • USBS: USB OHCI Input Clock Selection 0 = USB Clock Input is PLLA 1 = USB Clock Input is UPLL • USBDIV: Divider for USB OHCI Clock. USB Clock is Input clock divided by USBDIV+1 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 205: Pmc_Smd

    SAM9X25 SAM9X25 22.13.13 PMC SMD Clock Register Name: PMC_SMD Address: 0xFFFFFC3C Access: Read-write – – – – – – – – – – – – – – – – – – – SMDDIV – – – – – – –...
  • Page 206 Selected clock divided by 2 CLOCK_DIV4 Selected clock divided by 4 CLOCK_DIV8 Selected clock divided by 8 CLOCK_DIV16 Selected clock divided by 16 CLOCK_DIV32 Selected clock divided by 32 CLOCK_DIV64 Selected clock divided by 64 Reserved Reserved SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 207: Pmc_Ier

    SAM9X25 SAM9X25 22.13.15 PMC Interrupt Enable Register Name: PMC_IER Address: 0xFFFFFC60 Access: Write-only – – – – – – – – – – – – – CFDEV MOSCRCS MOSCSELS – – – – – – PCKRDY1 PCKRDY0 – LOCKU –...
  • Page 208: Pmc_Idr

    • 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 209: Pmc_Sr

    SAM9X25 SAM9X25 22.13.17 PMC Status Register Name: PMC_SR Address: 0xFFFFFC68 Access: Read-only – – – – – – – – – – – CFDS CFDEV MOSCRCS MOSCSELS – – – – – – PCKRDY1 PCKRDY0 OSCSELS LOCKU – – MCKRDY...
  • Page 210 1 = A clock failure of the main on-chip RC oscillator clock is detected. • FOS: Clock Failure Detector Fault Output Status 0 = The fault output of the clock failure detector is inactive. 1 = The fault output of the clock failure detector is active. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 211: Pmc_Imr

    SAM9X25 SAM9X25 22.13.18 PMC Interrupt Mask Register Name: PMC_IMR Address: 0xFFFFFC6C Access: Read-only – – – – – – – – – – – – – CFDEV MOSCRCS MOSCSELS – – – – – – PCKRDY1 PCKRDY0 – – –...
  • Page 212: Pmc_Pllicpr

    – – – – – ICPLLA • ICPLLA: Charge Pump Current To optimize clock performance, this field must be programmed as specified in “PLL A Characteristics” in the Electrical Char- acteristics section of the product datasheet. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 213 SAM9X25 SAM9X25 22.13.20 PMC Write Protect Mode Register Name: PMC_WPMR Address: 0xFFFFFCE4 Access: Read-write Reset: Table 22-3 WPKEY WPKEY WPKEY — — — — — — — WPEN • WPEN: Write Protect Enable 0 = Disables the Write Protect if WPKEY corresponds to 0x504D43 (“PMC” in ASCII).
  • Page 214: Pmc_Wpsr

    WPVSRC. • WPVSRC: Write Protect Violation Source When WPVS is active, this field indicates the write-protected register (through address offset or code) in which a write access has been attempted. Reading PMC_WPSR automatically clears all fields. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 215 SAM9X25 SAM9X25 22.13.22 PMC Peripheral Control Register Name: PMC_PCR Address: 0xFFFFFD0C Access: Read-write — — — — — — — — — — — — — — — — — — — — — — • PID: Peripheral ID Only the following Peripheral IDs can have a DIV value other than 0: PID2, PID3, PID5 to PID11, PID13 to PID19, PID28 to PID30.
  • Page 216 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 217 SAM9X25 SAM9X25 23. Parallel Input/Output Controller (PIO) 23.1 Description The Parallel Input/Output Controller (PIO) manages up to 32 fully programmable input/output lines. Each I/O line may be dedicated as a general-purpose I/O or be assigned to a function of an embedded peripheral. This assures effective optimization of the pins of a product.
  • Page 218 Up to 32 pins Up to 32 peripheral IOs Embedded Peripheral PIN 31 Figure 23-2. Application Block Diagram On-Chip Peripheral Drivers Keyboard Driver Control & Command Driver On-Chip Peripherals PIO Controller Keyboard Driver General Purpose I/Os External Devices SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 219 SAM9X25 SAM9X25 23.4 Product Dependencies 23.4.1 Pin Multiplexing Each pin is configurable, according to product definition as either a general-purpose I/O line only, or as an I/O line multiplexed with one or two peripheral I/Os. As the multiplexing is hard- ware defined and thus product-dependent, the hardware designer and programmer must carefully determine the configuration of the PIO controllers required by their application.
  • Page 220 PIO_ISR[0] (Up to 32 possible inputs) EVENT DETECTOR Programmable PIO Clock Glitch PIO Interrupt Resynchronization Slow Clock Debouncing Stage Clock Filter PIO_IER[0] Divider PIO_SCDR PIO_IMR[0] PIO_IDR[0] PIO_IFER[0] PIO_IFSR[0] PIO_ISR[31] PIO_IFSCER[0] PIO_IFDR[0] PIO_IFSCSR[0] PIO_IER[31] PIO_IFSCDR[0] PIO_IMR[31] PIO_IDR[31] SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 221 SAM9X25 SAM9X25 23.5.1 Pull-up and Pull-down Resistor Control Each I/O line is designed with an embedded pull-up resistor and an embedded pull-down resis- tor. The pull-up resistor can be enabled or disabled by writing respectively PIO_PUER (Pull-up Enable Register) and PIO_PUDR (Pull-up Disable Resistor). Writing in these registers results in setting or clearing the corresponding bit in PIO_PUSR (Pull-up Status Register).
  • Page 222 I/O line which is driven low only by each device. An external pull-up resistor (or enabling of the internal one) is generally required to guar- antee a high level on the line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 223 SAM9X25 SAM9X25 The Multi Drive feature is controlled by PIO_MDER (Multi-driver Enable Register) and PIO_MDDR (Multi-driver Disable Register). The Multi Drive can be selected whether the I/O line is controlled by the PIO controller or assigned to a peripheral function. PIO_MDSR (Multi-driver Status Register) indicates the pins that are configured to support external drivers.
  • Page 224 1.5 cycles Pin Level 1 cycle 1 cycle 1 cycle 1 cycle PIO_PDSR if PIO_IFSR = 0 2 cycles 1 cycle up to 2.5 cycles PIO_PDSR if PIO_IFSR = 1 up to 2 cycles SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 225 SAM9X25 SAM9X25 Figure 23-6. Input Debouncing Filter Timing PIO_IFCSR = 1 Divided Slow Clock Pin Level up to 2 cycles Tmck up to 2 cycles Tmck PIO_PDSR if PIO_IFSR = 0 1 cycle Tdiv_slclk 1 cycle Tdiv_slclk up to 1.5 cycles Tdiv_slclk...
  • Page 226 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 227 SAM9X25 SAM9X25 23.5.10.2 Interrupt Mode Configuration All the interrupt sources are enabled by writing 32’hFFFF_FFFF in PIO_IER. Then the Additional Interrupt Mode is enabled for line 0 to 7 by writing 32’h0000_00FF in PIO_AIMER. 23.5.10.3 Edge or Level Detection Configuration Lines 3, 4 and 5 are configured in Level detection by writing 32’h0000_0038 in PIO_LSR.
  • Page 228 23.5.14 Programmable Schmitt Trigger It is possible to configure each input for the Schmitt Trigger. By default the Schmitt trigger is ™ active. Disabling the Schmitt Trigger is requested when using the QTouch Library. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 229 SAM9X25 SAM9X25 23.5.15 Write Protection Registers To prevent any single software error that may corrupt PIO behavior, certain address spaces can be write-protected by setting the WPEN bit in the “PIO Write Protect Mode Register” (PIO_WPMR). If a write access to the protected registers is detected, then the WPVS flag in the PIO Write Pro- tect Status Register (PIO_WPSR) is set and the field WPVSRC indicates in which register the write access has been attempted.
  • Page 230 0x0000_00FF PIO_ODR 0xFFFF_FF00 PIO_IFER 0x0000_0F00 PIO_IFDR 0xFFFF_F0FF PIO_SODR 0x0000_0000 PIO_CODR 0x0FFF_FFFF PIO_IER 0x0F00_0F00 PIO_IDR 0xF0FF_F0FF PIO_MDER 0x0000_000F PIO_MDDR 0xFFFF_FFF0 PIO_PUDR 0xFFF0_00F0 PIO_PUER 0x000F_FF0F PIO_PPDDR 0xFF0F_FFFF PIO_PPDER 0x00F0_0000 PIO_ABCDSR1 0xF0F0_0000 PIO_ABCDSR2 0xFF00_0000 PIO_OWER 0x0000_000F PIO_OWDR 0x0FFF_ FFF0 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 231 SAM9X25 SAM9X25 23.7 Parallel Input/Output Controller (PIO) User Interface Each I/O line controlled by the PIO Controller is associated with a bit in each of the PIO Control- ler User Interface registers. Each register is 32 bits wide. If a parallel I/O line is not defined, writing to the corresponding bits has no effect.
  • Page 232 Read-only 0x00000000 0x00E4 Write Protect Mode Register PIO_WPMR Read-write 0x00E8 Write Protect Status Register PIO_WPSR Read-only 0x00EC Reserved 0x00F8 0x0100 Schmitt Trigger Register PIO_SCHMITT Read-write 0x00000000 0x0104- Reserved 0x010C 0x0110 IO Delay Register PIO_DELAYR Read-write 0x00000000 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 233 SAM9X25 SAM9X25 Table 23-2. Register Mapping (Continued) Offset Register Name Access Reset 0x0114 I/O Drive Register 1 PIO_DRIVER1 Read-write 0x00000000 0x0118 I/O Drive Register 2 PIO_DRIVER2 Read-write 0x00000000 0x011C Reserved 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.
  • Page 234 This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: PIO Disable 0: No effect. 1: Disables the PIO from controlling the corresponding pin (enables peripheral control of the pin). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 235 SAM9X25 SAM9X25 23.7.3 PIO Status Register Name: PIO_PSR Address: 0xFFFFF408 (PIOA), 0xFFFFF608 (PIOB), 0xFFFFF808 (PIOC), 0xFFFFFA08 (PIOD) Access: Read-only • P0-P31: PIO Status 0: PIO is inactive on the corresponding I/O line (peripheral is active). 1: PIO is active on the corresponding I/O line (peripheral is inactive).
  • Page 236 PIO Output Status Register Name: PIO_OSR Address: 0xFFFFF418 (PIOA), 0xFFFFF618 (PIOB), 0xFFFFF818 (PIOC), 0xFFFFFA18 (PIOD) Access: Read-only • P0-P31: Output Status 0: The I/O line is a pure input. 1: The I/O line is enabled in output. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 237 SAM9X25 SAM9X25 23.7.7 PIO Input Filter Enable Register Name: PIO_IFER Address: 0xFFFFF420 (PIOA), 0xFFFFF620 (PIOB), 0xFFFFF820 (PIOC), 0xFFFFFA20 (PIOD) Access: Write-only This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Input Filter Enable 0: No effect.
  • Page 238 PIO Set Output Data Register Name: PIO_SODR Address: 0xFFFFF430 (PIOA), 0xFFFFF630 (PIOB), 0xFFFFF830 (PIOC), 0xFFFFFA30 (PIOD) Access: Write-only • P0-P31: Set Output Data 0: No effect. 1: Sets the data to be driven on the I/O line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 239 SAM9X25 SAM9X25 23.7.11 PIO Clear Output Data Register Name: PIO_CODR Address: 0xFFFFF434 (PIOA), 0xFFFFF634 (PIOB), 0xFFFFF834 (PIOC), 0xFFFFFA34 (PIOD) Access: Write-only • P0-P31: Clear Output Data 0: No effect. 1: Clears the data to be driven on the I/O line.
  • Page 240 PIO Interrupt Enable Register Name: PIO_IER Address: 0xFFFFF440 (PIOA), 0xFFFFF640 (PIOB), 0xFFFFF840 (PIOC), 0xFFFFFA40 (PIOD) Access: Write-only • P0-P31: Input Change Interrupt Enable 0: No effect. 1: Enables the Input Change Interrupt on the I/O line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 241 SAM9X25 SAM9X25 23.7.15 PIO Interrupt Disable Register Name: PIO_IDR Address: 0xFFFFF444 (PIOA), 0xFFFFF644 (PIOB), 0xFFFFF844 (PIOC), 0xFFFFFA44 (PIOD) Access: Write-only • P0-P31: Input Change Interrupt Disable 0: No effect. 1: Disables the Input Change Interrupt on the I/O line. 23.7.16...
  • Page 242 Access: Write-only This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Multi Drive Enable. 0: No effect. 1: Enables Multi Drive on the I/O line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 243 SAM9X25 SAM9X25 23.7.19 PIO Multi-driver Disable Register Name: PIO_MDDR Address: 0xFFFFF454 (PIOA), 0xFFFFF654 (PIOB), 0xFFFFF854 (PIOC), 0xFFFFFA54 (PIOD) Access: Write-only This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Multi Drive Disable.
  • Page 244 This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Pull Up Enable. 0: No effect. 1: Enables the pull up resistor on the I/O line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 245 SAM9X25 SAM9X25 23.7.23 PIO Pull Up Status Register Name: PIO_PUSR Address: 0xFFFFF468 (PIOA), 0xFFFFF668 (PIOB), 0xFFFFF868 (PIOC), 0xFFFFFA68 (PIOD) Access: Read-only • P0-P31: Pull Up Status. 0: Pull Up resistor is enabled on the I/O line. 1: Pull Up resistor is disabled on the I/O line.
  • Page 246 1: Assigns the I/O line to the Peripheral B function. If the same bit is set to 1 in PIO_ABCDSR2: 0: Assigns the I/O line to the Peripheral C function. 1: Assigns the I/O line to the Peripheral D function. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 247 SAM9X25 SAM9X25 23.7.25 PIO Peripheral ABCD Select Register 2 Name: PIO_ABCDSR2 Access: Read-write This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Peripheral Select. If the same bit is set to 0 in PIO_ABCDSR1: 0: Assigns the I/O line to the Peripheral A function.
  • Page 248 PIO Input Filter Slow Clock Enable Register Name: PIO_IFSCER Address: 0xFFFFF484 (PIOA), 0xFFFFF684 (PIOB), 0xFFFFF884 (PIOC), 0xFFFFFA84 (PIOD) Access: Write-only • P0-P31: Debouncing Filtering Select. 0: No Effect. 1: The Debouncing Filter is able to filter pulses with a duration < Tdiv_slclk/2. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 249 SAM9X25 SAM9X25 23.7.28 PIO Input Filter Slow Clock Status Register Name: PIO_IFSCSR Address: 0xFFFFF488 (PIOA), 0xFFFFF688 (PIOB), 0xFFFFF888 (PIOC), 0xFFFFFA88 (PIOD) Access: Read-only • P0-P31: Glitch or Debouncing Filter Selection Status 0: The Glitch Filter is able to filter glitches with a duration < Tmck2.
  • Page 250 This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Pull Down Enable. 0: No effect. 1: Enables the pull down resistor on the I/O line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 251 SAM9X25 SAM9X25 23.7.32 PIO Pad Pull Down Status Register Name: PIO_PPDSR Address: 0xFFFFF498 (PIOA), 0xFFFFF698 (PIOB), 0xFFFFF898 (PIOC), 0xFFFFFA98 (PIOD) Access: Read-only This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register”...
  • Page 252 Access: Write-only This register can only be written if the WPEN bit is cleared in “PIO Write Protect Mode Register” • P0-P31: Output Write Disable. 0: No effect. 1: Disables writing PIO_ODSR for the I/O line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 253 SAM9X25 SAM9X25 23.7.35 PIO Output Write Status Register Name: PIO_OWSR Address: 0xFFFFF4A8 (PIOA), 0xFFFFF6A8 (PIOB), 0xFFFFF8A8 (PIOC), 0xFFFFFAA8 (PIOD) Access: Read-only • P0-P31: Output Write Status. 0: Writing PIO_ODSR does not affect the I/O line. 1: Writing PIO_ODSR affects the I/O line.
  • Page 254 0xFFFFF4B8 (PIOA), 0xFFFFF6B8 (PIOB), 0xFFFFF8B8 (PIOC), 0xFFFFFAB8 (PIOD) Access: Read-only • P0-P31: Peripheral CD Status. 0: The interrupt source is a Both Edge detection event 1: The interrupt source is described by the registers PIO_ELSR and PIO_FRLHSR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 255 SAM9X25 SAM9X25 23.7.39 PIO Edge Select Register Name: PIO_ESR Address: 0xFFFFF4C0 (PIOA), 0xFFFFF6C0 (PIOB), 0xFFFFF8C0 (PIOC), 0xFFFFFAC0 (PIOD) Access: Write-only • P0-P31: Edge Interrupt Selection. 0: No effect. 1: The interrupt source is an Edge detection event. 23.7.40 PIO Level Select Register...
  • Page 256 0xFFFFF4D0 (PIOA), 0xFFFFF6D0 (PIOB), 0xFFFFF8D0 (PIOC), 0xFFFFFAD0 (PIOD) Access: Write-only • P0-P31: Falling Edge/Low Level Interrupt Selection. 0: No effect. 1: The interrupt source is set to a Falling Edge detection or Low Level detection event, depending on PIO_ELSR. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 257 SAM9X25 SAM9X25 23.7.43 PIO Rising Edge/High Level Select Register Name: PIO_REHLSR Address: 0xFFFFF4D4 (PIOA), 0xFFFFF6D4 (PIOB), 0xFFFFF8D4 (PIOC), 0xFFFFFAD4 (PIOD) Access: Write-only • P0-P31: Rising Edge /High Level Interrupt Selection. 0: No effect. 1: The interrupt source is set to a Rising Edge detection or High Level detection event, depending on PIO_ELSR.
  • Page 258 23.7.45 PIO Lock Status Register Name: PIO_LOCKSR Address: 0xFFFFF4E0 (PIOA), 0xFFFFF6E0 (PIOB), 0xFFFFF8E0 (PIOC), 0xFFFFFAE0 (PIOD) Access: Read-only • P0-P31: Lock Status. 0: The I/O line is not locked. 1: The I/O line is locked. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 259 SAM9X25 SAM9X25 23.7.46 PIO Write Protect Mode Register Name: PIO_WPMR Address: 0xFFFFF4E4 (PIOA), 0xFFFFF6E4 (PIOB), 0xFFFFF8E4 (PIOC), 0xFFFFFAE4 (PIOD) Access: Read-write Reset: Table 23-2 WPKEY WPKEY WPKEY WPEN – – – – – – – For more information on Write Protection Registers, refer to Section 23.7 ”Parallel Input/Output Controller (PIO) User...
  • Page 260 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 261 SAM9X25 SAM9X25 23.7.47 PIO Write Protect Status Register Name: PIO_WPSR Address: 0xFFFFF4E8 (PIOA), 0xFFFFF6E8 (PIOB), 0xFFFFF8E8 (PIOC), 0xFFFFFAE8 (PIOD) Access: Read-only Reset: Table 23-2 – – – – – – – – WPVSRC WPVSRC WPVS – – – – –...
  • Page 262 SCHMITT22 SCHMITT21 SCHMITT20 SCHMITT19 SCHMITT18 SCHMITT17 SCHMITT16 SCHMITT15 SCHMITT14 SCHMITT13 SCHMITT12 SCHMITT11 SCHMITT10 SCHMITT9 SCHMITT8 SCHMITT7 SCHMITT6 SCHMITT5 SCHMITT4 SCHMITT3 SCHMITT2 SCHMITT1 SCHMITT0 • SCHMITTx [x=0..31]: 0: Schmitt Trigger is enabled. 1= Schmitt Trigger is disabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 263 SAM9X25 SAM9X25 23.7.49 PIO I/O Delay Register Name: PIO_DELAYR Address: 0xFFFFF510 (PIOA), 0xFFFFF710 (PIOB), 0xFFFFF910 (PIOC), 0xFFFFFB10 (PIOD) Access: Read-write Reset: Figure 23-2 Delay7 Delay6 Delay5 Delay4 Delay3 Delay2 Delay1 Delay0 • Delay x: Gives the number of elements in the delay line associated to pad x.
  • Page 264 LINE14 LINE13 LINE12 LINE11 LINE10 LINE9 LINE8 LINE7 LINE6 LINE5 LINE4 LINE3 LINE2 LINE1 LINE0 • LINEx [x=0..15]: Drive of PIO line x Value Name Description HI_DRIVE High drive ME_DRIVE Medium drive LO_DRIVE Low drive Reserved SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 265 SAM9X25 SAM9X25 23.7.51 PIO I/O Drive Register 2 Name: PIO_DRIVER2 Address: 0xFFFFF518 (PIOA), 0xFFFFF718 (PIOB), 0xFFFFF918 (PIOC), 0xFFFFFB18 (PIOD) Access: Read-write Reset: LINE31 LINE30 LINE29 LINE28 LINE27 LINE26 LINE25 LINE24 LINE23 LINE22 LINE21 LINE20 LINE19 LINE18 LINE17 LINE16 • LINEx [x=16..31]: Drive of PIO line x...
  • Page 266 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 267 – Two-pin UART – Debug Communication Channel (DCC) support • Two-pin UART – Implemented features are 100% compatible with the standard Atmel USART – Independent receiver and transmitter with a common programmable Baud Rate Generator – Even, Odd, Mark or Space Parity Generation –...
  • Page 268 Pin Name Description Type DRXD Debug Receive Data Input DTXD Debug Transmit Data Output Figure 24-2. Debug Unit Application Example Boot Program Debug Monitor Trace Manager Debug Unit RS232 Drivers Programming Tool Debug Console Trace Console SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 269 SAM9X25 SAM9X25 24.4 Product Dependencies 24.4.1 I/O Lines Depending on product integration, the Debug Unit pins may be multiplexed with PIO lines. In this case, the programmer must first configure the corresponding PIO Controller to enable I/O lines operations of the Debug Unit.
  • Page 270 (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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 271 SAM9X25 SAM9X25 Figure 24-4. Start Bit Detection Sampling Clock DRXD True Start Detection Baud Rate Clock Figure 24-5. Character Reception Example: 8-bit, parity enabled 1 stop 0.5 bit 1 bit period period DRXD Sampling Stop Bit True Start Detection Parity Bit 24.5.2.3...
  • Page 272 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 273 SAM9X25 SAM9X25 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.
  • Page 274 The Debug Communication Channel contains two registers that are accessible through the ICE Breaker on the JTAG side and through the coprocessor 0 on the ARM Processor side. As a reminder, the following instructions are used to read and write the Debug Communication Channel: SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 275 SAM9X25 SAM9X25 p14, 0, Rd, c1, c0, 0 Returns the debug communication data read register into Rd p14, 0, Rd, c1, c0, 0 Writes the value in Rd to the debug communication data write register. The bits COMMRX and COMMTX, which indicate, respectively, that the read register has been...
  • Page 276 Read-write 0x0024 - 0x003C Reserved – – – 0x0040 Chip ID Register DBGU_CIDR Read-only – 0x0044 Chip ID Extension Register DBGU_EXID Read-only – 0x0048 Force NTRST Register DBGU_FNR Read-write 0x004C - 0x00FC Reserved – – – SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 277: Dbgu_Cr

    SAM9X25 SAM9X25 24.6.1 Debug Unit Control Register Name: DBGU_CR Address: 0xFFFFF200 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – RSTSTA – – TXDIS...
  • Page 278: Dbgu_Mr

    Space: Parity forced to 0 0b011 MARK Mark: Parity forced to 1 0b1xx NONE No Parity • CHMODE: Channel Mode Value Name Description 0b00 NORM Normal Mode 0b01 AUTO Automatic Echo 0b10 LOCLOOP Local Loopback 0b11 REMLOOP Remote Loopback SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 279: Dbgu_Ier

    SAM9X25 SAM9X25 24.6.3 Debug Unit Interrupt Enable Register Name: DBGU_IER Address: 0xFFFFF208 Access: Write-only – – – – – – COMMRX COMMTX – – – – – – – – – – – – – – TXEMPTY – – –...
  • Page 280: Dbgu_Idr

    • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 281: Dbgu_Imr

    SAM9X25 SAM9X25 24.6.5 Debug Unit Interrupt Mask Register Name: DBGU_IMR Address: 0xFFFFF210 Access: Read-only – – – – – – COMMRX COMMTX – – – – – – – – – – – – – – TXEMPTY – – –...
  • Page 282: Dbgu_Sr

    0 = COMMTX from the ARM processor is inactive. 1 = COMMTX from the ARM processor is active. • COMMRX: Debug Communication Channel Read Status 0 = COMMRX from the ARM processor is inactive. 1 = COMMRX from the ARM processor is active. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 283 SAM9X25 SAM9X25 24.6.7 Debug Unit Receiver Holding Register Name: DBGU_RHR Address: 0xFFFFF218 Access: Read-only – – – – – – – – – – – – – – – – – – – – – – – – RXCHR • RXCHR: Received Character Last received character if RXRDY is set.
  • Page 284: Dbgu_Brgr

    Read-write – – – – – – – – – – – – – – – – • CD: Clock Divisor Value Name Description DISABLED DBGU Disabled 2 to 65535 – MCK / (CD x 16) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 285: Dbgu_Cidr

    SAM9X25 SAM9X25 24.6.10 Debug Unit Chip ID Register Name: DBGU_CIDR Address: 0xFFFFF240 Access: Read-only NVPTYP ARCH ARCH SRAMSIZ NVPSIZ2 NVPSIZ EPROC VERSION • VERSION: Version of the Device Values depend upon the version of the device. • EPROC: Embedded Processor...
  • Page 286 • SRAMSIZ: Internal SRAM Size Value Name Description – Reserved 1K bytes 2K bytes 6K bytes 112K 112K bytes 4K bytes 80K bytes 160K 160K bytes 8K bytes 16K bytes 32K bytes 64K bytes 128K 128K bytes SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 287 SAM9X25 SAM9X25 Value Name Description 256K 256K bytes 96K bytes 512K 512K bytes • ARCH: Architecture Identifier Value Name Description 0x19 AT91SAM9xx AT91SAM9xx Series 0x29 AT91SAM9XExx AT91SAM9XExx Series 0x34 AT91x34 AT91x34 Series 0x37 CAP7 CAP7 Series 0x39 CAP9 CAP9 Series...
  • Page 288 ROM and Embedded Flash Memory ROM_FLASH NVPSIZ is ROM size NVPSIZ2 is Flash size • EXT: Extension Flag 0 = Chip ID has a single register definition without extension 1 = An extended Chip ID exists. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 289: Dbgu_Exid

    SAM9X25 SAM9X25 24.6.11 Debug Unit Chip ID Extension Register Name: DBGU_EXID Address: 0xFFFFF244 Access: Read-only EXID EXID EXID EXID • EXID: Chip ID Extension Reads 0 if the bit EXT in DBGU_CIDR is 0. 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 290: Dbgu_Fnr

    – – – – FNTRST • FNTRST: Force NTRST 0 = NTRST of the ARM processor’s TAP controller is driven by the power_on_reset signal. 1 = NTRST of the ARM processor’s TAP controller is held low. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 291 SAM9X25 25. Bus Matrix (MATRIX) 25.1 Description The Bus Matrix implements a multi-layer AHB, based on the AHB-Lite protocol, that enables par- allel access paths between multiple AHB masters and slaves in a system, thus increasing the overall bandwidth. The Bus Matrix interconnects up to 16 AHB masters to up to 16 AHB slaves.
  • Page 292 USB Host EHCI registers USB Host OHCI registers Slave 4 External Bus Interface Slave 5 DDR2 port 1 Slave 6 DDR2 port 2 Slave 7 DDR2 port 3 Slave 8 Peripheral Bridge 0 Slave 9 Peripheral Bridge 1 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 293 SAM9X25 25.2.3 Master to Slave Access All the Masters can normally access all the Slaves. However, some paths do not make sense, such as allowing access from the USB Device High speed DMA to the Internal Peripherals. Thus, these paths are forbidden or simply not wired, and shown as “-” in the following table.
  • Page 294 Other non-privileged masters still get one latency clock cycle if they want to access the same slave. This technique is useful for masters that mainly perform single accesses or short bursts with some Idle cycles in between. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 295 SAM9X25 This configuration provides no benefit on access latency or bandwidth when reaching maximum slave bus throughput irregardless of the number of requesting masters. 25.4.3 Fixed Default Master After the end of the current access, if no other request is pending, the slave connects to its fixed default master.
  • Page 296 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. However, the Slot Cycle Limit should not be disabled in the particular case of a master capable...
  • Page 297 SAM9X25 Warning: This feature cannot prevent any slave from locking its access indefinitely. 25.5.2 Arbitration Priority Scheme The bus Matrix arbitration scheme is organized in priority pools. Round-robin priority is used in the highest and lowest priority pools, whereas fixed level priority is used between priority pools and in the intermediate priority pools.
  • Page 298 WPVS flag in the MATRIX Write Protect Status Register (MATRIX_WPSR) is set and the field WPVSRC indicates in which register the write access has been attempted. The WPVS flag is reset by writing the MATRIX Write Protect Mode Register (MATRIX_WPMR) with the appropriate access key WPKEY. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 299 SAM9X25 25.7 Bus Matrix (MATRIX) User Interface Table 25-4. Register Mapping Offset Register Name Access Reset 0x0000 Master Configuration Register 0 MATRIX_MCFG0 Read-write 0x00000001 0x0004 Master Configuration Register 1 MATRIX_MCFG1 Read-write 0x00000000 0x0008 Master Configuration Register 2 MATRIX_MCFG2 Read-write 0x00000000...
  • Page 300 Master Remap Control Register MATRIX_MRCR Read-write 0x00000000 0x0104 - 0x010C Reserved – – – 0x0110 - 0x01E0 Chip Configuration Registers – – – 0x01E4 Write Protect Mode Register MATRIX_WPMR Read-write 0x00000000 0x01E8 Write Protect Status Register MATRIX_WPSR Read-only 0x00000000 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 301 SAM9X25 25.7.1 Bus Matrix Master Configuration Registers Name: MATRIX_MCFG0...MATRIX_MCFG11 Address: 0xFFFFDE00 [0], 0xFFFFDE04 [1], 0xFFFFDE08 [2], 0xFFFFDDEC [3], 0xFFFFDE10 [4], 0xFFFFDE14 [5], 0xFFFFDE18 [6], 0xFFFFDE1C [7], 0xFFFFDE20 [8], 0xFFFFDE28 [10], 0xFFFFDE2C [11] Access: Read-write – – – – – –...
  • Page 302 This is the number of the Default Master for this slave. Only used if DEFMSTR_TYPE is 2. Specifying the number of a mas- ter which is not connected to the selected slave is equivalent to setting DEFMSTR_TYPE to 0. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 303 SAM9X25 25.7.3 Bus Matrix Priority Registers A For Slaves Name: MATRIX_PRAS0...MATRIX_PRAS8 Address: 0xFFFFDE80 [0], 0xFFFFDE88 [1], 0xFFFFDE90 [2], 0xFFFFDE98 [3], 0xFFFFDEA0 [4], 0xFFFFDEA8 [5], 0xFFFFDEB0 [6], 0xFFFFDEB8 [7], 0xFFFFDEC0 [8], 0xFFFFDEC8 [9] Access: Read-write – – M7PR – – M6PR –...
  • Page 304 Round-robin arbitration is used in the lowest (MxPR = 0) and highest (MxPR = 3) priority pools. Fixed priority is used in intermediate priority pools (MxPR = 1) and (MxPR = 2). “Arbitration Priority Scheme” on page 297 for details. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 305 SAM9X25 25.7.5 Bus Matrix Master Remap Control Register Name: MATRIX_MRCR Address: 0xFFFFDF00 Access: Read-write – – – – – – – – – – – – – – – – – – – – RCB11 RCB10 – RCB8 RCB7 RCB6...
  • Page 306 Chip Configuration User Interface Table 25-5. Chip Configuration User Interface Offset Register Name Access Reset Value 0x0110 - 0x011C Reserved – – – 0x0120 EBI Chip Select Assignment Register CCFG_EBICSA Read-write 0x00000000 0x0124 - 0x01FC Reserved – – – SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 307 SAM9X25 25.7.6.1 EBI Chip Select Assignment Register Name: CCFG_EBICSA Access: Read-write Reset: 0x0000_0000 – – – – – – DDR_MP_EN NFD0_ON_D16 – – – – – – EBI_DRIVE – – – – – – – EBI_DBPDC EBI_DBPUC – – –...
  • Page 308 1 = DDR Multi-port is enabled, performance is increased. Warning! Use only with NFDO0_ON_D16 = 0. The system behavior is unpredictable if ND0_ON_D16 is set to 1 at the same time. DDR_MP_EN External Memory Default DDR2 or LP-DDR + 8-bit NAND Flash Note: EBI Chip Select 1 is to be assigned to the DDR2SDR Controller. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 309 SAM9X25 25.7.7 Write Protect Mode Register Name: MATRIX_WPMR Address: 0xFFFFDFE4 Access: Read-write WPKEY WPKEY WPKEY – – – – – – – WPEN For more details on MATRIX_WPMR, refer to Section 25.6 “Write Protect Registers” on page 298. • WPEN: Write Protect ENable 0 = Disables the Write Protect if WPKEY corresponds to 0x4D4154 (“MAT”...
  • Page 310 1: At least one Write Protect Violation has occurred since the last write of the MATRIX_WPMR. • WPVSRC: Write Protect Violation Source When WPVS is active, this field indicates the register address offset in which a write access has been attempted. Otherwise it reads as 0. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 311 SAM9X25 SAM9X25 26. External Bus Interface (EBI) 26.1 Description The External Bus Interface (EBI) is designed to ensure the successful data transfer between several external devices and the embedded Memory Controller of an ARM-based device. The Static Memory, DDR, SDRAM and ECC Controllers are all featured external Memory Con- trollers on the EBI.
  • Page 312 NWR0/NWE NWR1/NBS1 NWR3/NBS3/DQM3 SDCK, SDCK#, SDCKE DQM[1:0] DQS[1:0] RAS, CAS SDWE, SDA10 NAND Flash Logic NCS3/NANDCS PMECC NANDOE PMERRLOC Controllers NANDWE A21/NANDALE A22/NANDCLE Chip Select Address Decoders D[31:16] Assignor A[25:20] NCS5 NCS4 User Interface NCS2 NWAIT SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 313 SAM9X25 SAM9X25 26.4 I/O Lines Description Table 26-1. EBI I/O Lines Description Name Function Type Active Level EBI_D0 - EBI_D31 Data Bus EBI_A0 - EBI_A25 Address Bus Output EBI_NWAIT External Wait Signal Input EBI_NCS0 - EBI_NCS5 Chip Select Lines Output...
  • Page 314 3. NBS0 and NBS1 enable respectively lower and upper bytes of the lower 16-bit word. 4. NBS2 and NBS3 enable respectively lower and upper bytes of the upper 16-bit word. 5. D24-31 and A20, A23-A25, NCS2, NCS4, NCS5 are multiplexed on PD15-PD31. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 315 SAM9X25 SAM9X25 Table 26-4. EBI Pins and External Device Connections Power supply Pins of the Interfaced Device Signals: EBI_ DDR2/LPDDR SDR/LPSDR NAND Flash Controller DDRC SDRAMC D0 - D15 VDDIOM D0 - D15 D0 - D15 NFD0-NFD15 D16 - D31 VDDNF –...
  • Page 316 The EBI_CSA registers in the Chip Configuration User Interface enable on-chip pull-up and pull- down resistors on data bus lines not multiplexed with the PIO Controller lines. The pull-down resistors are enabled after reset. The bits, EBIx_DBPUC and EBI_DBPDC, control the pull-up SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 317 SAM9X25 SAM9X25 and pull-down resistors on the D0 - D15 lines. Pull-up or pull-down resistors on the D16 - D31 lines can be performed by programming the appropriate PIO controller. 26.5.3.3 Drive Level and Delay Control The EBI I/Os accept two drive levels, HIGH and LOW. This allows to avoid overshoots and give the best performance according to the bus load and external memories.
  • Page 318 SDR) are in the same power supply range, (NFD0_ON_D16 = default). DDR2 or LP-DDR or 16-bit LP-SDR (1.8V) D[15:0] D[15:0] NAND Flash (1.8V) D[15:0] A[22:21] 32bit SDRAM (3.3V) D[15:0] D[15:0] D[31:16] D[31:16] NAND Flash (3.3V) D[15:0] A[22:21] SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 319 SAM9X25 SAM9X25 In the following example the NAND Flash and the external RAM (DDR2 or LP-DDR or 16bit LP- SDR) are NOT in the same power supply range (NFD0_ON_D16 = 1). DDR2 or LP-DDR or 16-bit LP-SDR (1.8V) D[15:0] D[15:0] NAND Flash (3.3V)
  • Page 320 NCSx address space. The chip enable (CE) signal of the device and the ready/busy (R/B) signals are connected to PIO lines. The CE signal then remains asserted even when NCSx is not selected, preventing the device from returning to standby mode. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 321 SAM9X25 SAM9X25 Figure 26-4. NAND Flash Application Example D[7:0] AD[7:0] A[22:21] NCSx/NANDCS Not Connected NAND Flash NANDOE NANDWE 26.5.4 Implementation Examples The following hardware configurations are given for illustration only. The user should refer to the memory manufacturer web site to check current device availability.
  • Page 322 The DDR2 initialization sequence is described in the sub-section “DDR2 Device Initialization” of the DDRSDRC section. In this case VDDNF can be different from VDDIOM. NAND Flash device can be 3.3V or 1.8V and wired on D16-D31 data bus. NFD0_ON_D16 is to be set to 1. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 323 SAM9X25 SAM9X25 26.5.4.2 16-bit LPDDR on EBI Hardware Configuration Software Configuration The following configuration has to be performed: • Assign EBI_CS1 to the DDR2 controller by setting the bit EBI_CS1A in the EBI Chip Select Register located in the bus matrix memory space.
  • Page 324 The SDRAM initialization sequence is described in the section “SDRAM Device Initialization” in “SDRAM Controller (SDRAMC)”. In this case VDDNF can be different from VDDIOM. NAND Flash device can be 3.3V or 1.8V and wired on D16-D31 data bus. NFD0_ON_D16 is to be set to 1. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 325 SAM9X25 SAM9X25 26.5.4.4 2x16-bit SDRAM on EBI Hardware Configuration A[1..14] D[0..31] SDRAM MT48LC16M16A2 MT48LC16M16A2 MT48LC16M16A2 MT48LC16M16A2 SDA10 SDA10 DQ10 DQ10 DQ11 DQ11 DQ12 DQ12 DQ13 DQ13 DQ14 DQ14 DQ15 DQ15 VDDIOM VDDIOM N.C1 N.C1 VDDQ VDDQ VDDQ VDDQ VDDQ VDDQ...
  • Page 326 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 327 SAM9X25 SAM9X25 26.5.4.6 16-bit NAND Flash with NFD0_ON_D16 = 0 Hardware Configuration D[0..15] MT29F2G16AABWP-ET MT29F2G16AABWP-ET I/O0 I/O1 NANDOE I/O2 NANDWE I/O3 (ANY PIO) I/O4 I/O5 (ANY PIO) I/O6 I/O7 I/O8 I/O9 I/O10 I/O11 I/O12 I/O13 I/O14 I/O15 100NF 100NF 100NF...
  • Page 328 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 329 SAM9X25 SAM9X25 26.5.4.8 16-bit NAND Flash with NFD0_ON_D16 = 1 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.
  • Page 330 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 331 SAM9X25 SAM9X25 27. Programmable Multibit ECC Error Location Controller (PMERRLOC) 27.1 Description The PMECC Error Location Controller provides hardware acceleration for determining roots of polynomials over two finite fields: GF(2^13) and GF(2^14). It integrates 24 fully programmable coefficients. These coefficients belong to GF(2^13) or GF(2^14). The coefficient programmed in the PMERRLOC_SIGMAx register is the coefficient of degree x in the polynomial.
  • Page 332 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 indicates the number of errors. The error posi- tion can be read in the PMERRLOCx registers. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 333 SAM9X25 SAM9X25 27.5 Programmable Multibit ECC Error Location (PMERRLOC) User Interface Table 27-3. Register Mapping Offset Register Name Access Reset 0x000 Error Location Configuration Register PMERRLOC_ELCFG Read-write 0x00000000 0x004 Error Location Primitive Register PMERRLOC_ELPRIM Read-only 0x00000000 0x008 Error Location Enable Register...
  • Page 334 – – – – – – SECTORSZ • ERRNUM: Number of Errors • SECTORSZ: Sector Size 0: The ECC computation is based on a 512-byte sector. 1: The ECC computation is based on a 1024-byte sector. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 335 SAM9X25 SAM9X25 27.5.2 Error Location Primitive Register Name: PMERRLOC_ELPRIM Address: 0xFFFFE604 Access: Read-only Reset: 0x00000000 – – – – – – – – – – – – – – – – PRIMITIV PRIMITIV • PRIMITIV: Primitive Polynomial 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 336 PMERRLOC_ELEN Address: 0xFFFFE608 Access: Read-write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – ENINIT ENINIT • ENINIT: Initial Number of Bits in the Codeword SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 337 SAM9X25 SAM9X25 27.5.4 Error Location Disable Register Name: PMERRLOC_ELDIS Address: 0xFFFFE60C Access: Read-write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 338 – – – – – – – – – – – – – – – – – – – – – – – – – – – – – BUSY • BUSY: Error Location Engine Busy SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 339 SAM9X25 SAM9X25 27.5.6 Error Location Interrupt Enable Register Name: PMERRLOC_ELIER Address: 0xFFFFE614 Access: Read-only Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 340 – – – – – – – – – – – – – – – – – – – – – – – – – – – – – DONE • DONE: Computation Terminated Interrupt Disable SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 341 SAM9X25 SAM9X25 27.5.8 Error Location Interrupt Mask Register Name: PMERRLOC_ELIMR Address: 0xFFFFE61C Access: Read-only Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 342 – – – – – – – – – – – – – – – – ERR_CNT – – – – – – – DONE • DONE: Computation Terminated Interrupt Status • ERR_CNT: Error Counter value SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 343 SAM9X25 SAM9X25 27.5.10 Error Location SIGMAx Register Name: PMERRLOC_SIGMAx [x=0..24] Address: 0xFFFFE628 Access: Read-Write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – SIGMAN SIGMAN • SIGMAx: Coefficient of degree x in the SIGMA polynomial.
  • Page 344 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 345 SAM9X25 28. Programmable Multibit ECC Controller (PMECC) 28.1 Description The PMECC Controller is a programmable binary BCH (Bose, Chaudhuri and Hocquenghem) encoder/decoder. This controller can be used to generate redundancy information for both Sin- gle-Level Cell (SLC) and Multi-level Cell (MLC) NAND Flash devices. It supports redundancy for correction of 2, 4, 8, 12 or 24 bits of error per sector of data.
  • Page 346 28.3 Block Diagram Figure 28-1. Block Diagram MLC/SLC Static Memory NAND Flash device Controller 8-Bit Control Bus Data Bus PMECC Controller Programmable BCH Algorithm User Interface SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 347 SAM9X25 28.4 Functional Description The NAND Flash sector size is programmable and can be set to 512 bytes or 1024 bytes. The PMECC module generates redundancy at encoding time, when a NAND write page operation is performed. The redundancy is appended to the page and written in the spare area. This opera- tion is performed by the processor.
  • Page 348 Find the error positions This step can finding the roots of the be hardware assisted error location polynomial. using the PMERRLOC And correct the bits. module. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 349 SAM9X25 28.4.1 MLC/SLC Write Page Operation using PMECC When an MLC write page operation is performed, the PMECC controller is configured with the NANDWR field of the PMECCFG register set to one. When the NAND spare area contains file system information and redundancy (PMECCx), the spare area is error protected, then the SPA- REEN bit of the PMECCFG register is set to one.
  • Page 350 This mode is entered by writing one to the DATA field of the PMECC_CTRL register. Figure 28-4. NAND Write Operation Write NAND operation with SPAREEN set to zero pagesize = n * sectorsize Sector 0 Sector 1 Sector 2 Sector 3 512 or 1024 bytes ECC computation enable signal SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 351 SAM9X25 28.4.2 MLC/SLC Read Page Operation using PMECC Table 28-3. Relevant Remainders Registers BCH_ERR field Sector size set to 512 bytes Sector size set to 1024 bytes PMECC_REM0 PMECC_REM0 PMECC_REM0, PMECC_REM1 PMECC_REM0, PMECC_REM1 PMECC_REM0, PMECC_REM1, PMECC_REM0, PMECC_REM1, PMECC_REM2, PMECC_REM3, PMECC_REM2, PMECC_REM3...
  • Page 352 This mode allows a manual retrieve of the ECC. This mode is entered writing one in the USER field of the PMECC_CTRL register. Figure 28-7. User Read Mode ecc_area_size ecc_area end_addr addr = 0 Partial Syndrome computation enable signal SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 353 SAM9X25 28.5 Software Implementation 28.5.1 Remainder Substitution Procedure The substitute function evaluates the polynomial remainder, with different values of the field primitive elements. The finite field arithmetic addition operation is performed with the Exclusive or. The finite field arithmetic multiplication operation is performed through the gf_log, gf_antilog lookup tables.
  • Page 354 = 0; /* delta set to -1 */ delta[0] = (mu[0] * 2 - lmu[0]) >> 1; Second Row /* Mu */ mu[1] = 0; /* Sigma(x) set to 1 */ for (i = 0; i < (2*NB_ERROR_MAX+1); i++) SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 355 SAM9X25 smu[1][i] = 0; smu[1][0] = 1; /* discrepancy set to Syndrome 1 */ dmu[1] = si[1]; /* polynom order set to 0 */ lmu[1] = 0; /* delta set to 0 */ delta[1] = (mu[1] * 2 - lmu[1]) >> 1;...
  • Page 356 /* 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]) SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 357 SAM9X25 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; 28.5.3 Find the Error Position The output of the get_sigma() procedure is a polynomial stored in the smu[NB_ERROR+1][] table. The error position is the roots of that polynomial. The degree of this polynomial is very important information, as it gives the number of errors.
  • Page 358 PMECC REM 5 Register PMECC_REM5 Read-only 0x00000000 0x240+sec_num*(0x40)+0x18 PMECC REM 6 Register PMECC_REM6 Read-only 0x00000000 0x240+sec_num*(0x40)+0x1C PMECC REM 7 Register PMECC_REM7 Read-only 0x00000000 0x240+sec_num*(0x40)+0x20 PMECC REM 8 Register PMECC_REM8 Read-only 0x00000000 0x240+sec_num*(0x40)+0x24 PMECC REM 9 Register PMECC_REM9 Read-only 0x00000000 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 359 SAM9X25 Table 28-4. Register Mapping (Continued) Offset Register Name Access Reset 0x240+sec_num*(0x40)+0x28 PMECC REM 10 Register PMECC_REM10 Read-only 0x00000000 0x240+sec_num*(0x40)+0x2C PMECC REM 11 Register PMECC_REM11 Read-only 0x00000000 0x440 - 0x5FC Reserved – – – 11054A–ATARM–27-Jul-11...
  • Page 360 • SPAREEN: Spare Enable – for NAND write access: 0: the spare area is skipped 1: the spare area is protected with the last sector of data. – for NAND read access: 0: the spare area is skipped. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 361 SAM9X25 1: the spare area contains protected data or only redundancy information. • AUTO: Automatic Mode Enable This bit is only relevant in NAND Read Mode, when spare enable is activated. 0: Indicates that the spare area is not protected. In that case the ECC computation takes into account the ECC area located in the spare area.
  • Page 362 – – – – – – – – – – – – – – – – – – – – – – SPARESIZE SPARESIZE • SPARESIZE: Spare Area Size The spare area size is equal to (SPARESIZE+1) bytes. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 363 SAM9X25 28.6.3 PMECC Start Address Register Name: PMECC_SADDR Address: 0xFFFFE008 Access: Read-write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – STARTADDR STARTADDR • STARTADDR: ECC Area Start Address (byte oriented address) This field indicates the first byte address of the ECC area.
  • Page 364 – – – – – – – – – – – – – – – – ENDADDR ENDADDR • ENDADDR: ECC Area End Address (byte oriented address) This field indicates the last byte address of the ECC area. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 365 SAM9X25 28.6.5 PMECC Clock Control Register Name: PMECC_CLK Address: 0xFFFFE010 Access: Read-write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 366 • DATA: Start a Data Phase • USER: Start a User Mode Phase • ENABLE: PMECC Module Enable PMECC module must always be configured before being activated. • DISABLE: PMECC Module Disable PMECC module must always be configured after being deactivated. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 367 SAM9X25 28.6.7 PMECC Status Register Name: PMECC_SR Address: 0xFFFFE018 Access: Read-only Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 368 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – ERRIE • ERRIE: Error Interrupt Enable SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 369 SAM9X25 28.6.9 PMECC Interrupt Disable Register Name: PMECC_IDR Address: 0xFFFFE020 Access: Write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 370 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – ERRIM • ERRIM: Error Interrupt Enable SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 371 SAM9X25 28.6.11 PMECC Interrupt Status Register Name: PMECC_ISR Address: 0xFFFFE028 Access: Read-only Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – ERRIS • ERRIS: Error Interrupt Status Register When set to one, bit i of the PMECCISR register indicates that sector i is corrupted.
  • Page 372 0xFFFFE180 [0][5] .. 0xFFFFE1A8 [10][5] 0xFFFFE1C0 [0][6] .. 0xFFFFE1E8 [10][6] 0xFFFFE200 [0][7] .. 0xFFFFE228 [10][7] Access: Read-only Reset: 0x00000000 • ECC: BCH Redundancy This register contains the remainder of the division of the codeword by the generator polynomial. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 373 SAM9X25 28.6.13 PMECC Remainder x Register Name: PMECC_REMx [x=0..11] [sec_num=0..7] Address: 0xFFFFE240 [0][0] .. 0xFFFFE26C [11][0] 0xFFFFE280 [0][1] .. 0xFFFFE2AC [11][1] 0xFFFFE2C0 [0][2] .. 0xFFFFE2EC [11][2] 0xFFFFE300 [0][3] .. 0xFFFFE32C [11][3] 0xFFFFE340 [0][4] .. 0xFFFFE36C [11][4] 0xFFFFE380 [0][5] .. 0xFFFFE3AC [11][5] 0xFFFFE3C0 [0][6] ..
  • Page 374 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 375 SAM9X25 SAM9X25 29. Static Memory Controller (SMC) 29.1 Description The Static Memory Controller (SMC) generates the signals that control the access to the exter- nal memory devices or peripheral devices. It has 6 Chip Selects and a 26-bit address bus. The 32-bit data bus can be configured to interface with 8-, 16-, or 32-bit external devices.
  • Page 376 “Data Bus Width” on page 378. NWR2 NBS2 Byte-write or byte-select access, see “Byte Write or Byte Select Access” on page 378 NWR3 NBS3 Byte-write or byte-select access see “Byte Write or Byte Select Access” on page 378 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 377 SAM9X25 SAM9X25 29.5 Application Example 29.5.1 Hardware Interface Figure 29-1. SMC Connections to Static Memory Devices D0-D31 A0/NBS0 128K x 8 128K x 8 NWR0/NWE SRAM SRAM NWR1/NBS1 D8-D15 D0 - D7 A1/NWR2/NBS2 D0-D7 D0 - D7 NWR3/NBS3 A2 - A18...
  • Page 378 Each chip select with a 16-bit or 32-bit data bus can operate with one of two different types of write access: byte write or byte select access. This is controlled by the BAT field of the SMC_MODE register for the corresponding chip select. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 379 SAM9X25 SAM9X25 Figure 29-3. Memory Connection for an 8-bit Data Bus D[7:0] D[7:0] A[18:2] A[18:2] Write Enable Output Enable NCS[2] Memory Enable Figure 29-4. Memory Connection for a 16-bit Data Bus D[15:0] D[15:0] A[19:2] A[18:1] A[0] NBS0 Low Byte Enable...
  • Page 380 3 (upper byte) respectively. Byte Select Access is used to connect two 16-bit devices. Figure 29-7 shows how to connect two 16-bit devices on a 32-bit data bus in Byte Select Access mode, on NCS3 (BAT = Byte Select Access). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 381 SAM9X25 SAM9X25 Figure 29-6. Connection of 2 x 8-bit Devices on a 16-bit Bus: Byte Write Option D[7:0] D[7:0] D[15:8] A[24:2] A[23:1] A[0] NWR0 Write Enable NWR1 Read Enable NCS[3] Memory Enable D[15:8] A[23:1] A[0] Write Enable Read Enable Memory Enable 29.8.2.3...
  • Page 382 1 x 8-bit Byte Access Type (BAT) Byte Select Byte Select Byte Write Byte Select Byte Write NBS0_A0 NBS0 NBS0 NBS0 NWE_NWR0 NWR0 NWR0 NBS1_NWR1 NBS1 NBS1 NWR1 NBS1 NWR1 NBS2_NWR2_A1 NBS2 NBS2 NWR2 NBS3_NWR3 NBS3 NBS3 NWR3 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 383 SAM9X25 SAM9X25 29.9 Standard Read and Write Protocols In the following sections, the byte access type is not considered. Byte select lines (NBS0 to NBS3) always have the same timing as the A address bus. NWE represents either the NWE sig- nal in byte select access type or one of the byte write lines (NWR0 to NWR3) in byte write access type.
  • Page 384 Null Delay Setup and Hold If null setup and hold parameters are programmed for NRD and/or NCS, NRD and NCS remain active continuously in case of consecutive read cycles in the same memory (see Figure 29-9). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 385 SAM9X25 SAM9X25 Figure 29-9. No Setup, No Hold On NRD and NCS Read Signals A[25:2] NBS0,NBS1, NBS2,NBS3, A0, A1 D[31:0] NRD_PULSE NRD_PULSE NRD_PULSE NCS_RD_PULSE NCS_RD_PULSE NCS_RD_PULSE NRD_CYCLE NRD_CYCLE NRD_CYCLE 29.9.1.5 Null Pulse Programming null pulse is not permitted. Pulse must be at least set to 1. A null value leads to unpredictable behavior.
  • Page 386 NCS, whatever the programmed waveform of NRD may be. Figure 29-11. READ_MODE = 0: Data is sampled by SMC before the rising edge of NCS A[25:2] NBS0,NBS1, NBS2,NBS3, A0, A1 PACC D[31:0] Data Sampling SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 387 SAM9X25 SAM9X25 29.9.3 Write Waveforms The write protocol is similar to the read protocol. It is depicted in Figure 29-12. The write cycle starts with the address setting on the memory address bus. 29.9.3.1 NWE Waveforms The NWE signal is characterized by a setup timing, a pulse width and a hold timing.
  • Page 388 NWR2, NWR3 D[31:0] NWE_PULSE NWE_PULSE NWE_PULSE NCS_WR_PULSE NCS_WR_PULSE NCS_WR_PULSE NWE_CYCLE NWE_CYCLE NWE_CYCLE 29.9.3.5 Null Pulse Programming null pulse is not permitted. Pulse must be at least set to 1. A null value leads to unpredictable behavior. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 389 SAM9X25 SAM9X25 29.9.4 Write Mode The WRITE_MODE parameter in the SMC_MODE register of the corresponding chip select indi- cates which signal controls the write operation. 29.9.4.1 Write is Controlled by NWE (WRITE_MODE = 1): Figure 29-14 shows the waveforms of a write operation with WRITE_MODE set to 1. The data is put on the bus during the pulse and hold steps of the NWE signal.
  • Page 390 The SMC_SETUP register groups the definition of all setup parameters: • NRD_SETUP, NCS_RD_SETUP, NWE_SETUP, NCS_WR_SETUP The SMC_PULSE register groups the definition of all pulse parameters: • NRD_PULSE, NCS_RD_PULSE, NWE_PULSE, NCS_WR_PULSE The SMC_CYCLE register groups the definition of all cycle parameters: • NRD_CYCLE, NWE_CYCLE SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 391 SAM9X25 SAM9X25 Table 29-4 shows how the timing parameters are coded and their permitted range. Table 29-4. Coding and Range of Timing Parameters Permitted Range Coded Value Number of Bits Effective Value Coded Value Effective Value 0 ≤ ≤ 31 0 ≤...
  • Page 392 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-19. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 393 SAM9X25 SAM9X25 Figure 29-17. Early Read Wait State: Write with No Hold Followed by Read with No Setup A[25:2] NBS0, NBS1, NBS2, NBS3, A0, A1 no hold no setup D[31:0] write cycle read cycle Early Read wait state Figure 29-18. Early Read Wait State: NCS Controlled Write with No Hold Followed by a Read with No NCS Setup...
  • Page 394 The user must not change the configuration parameters of an SMC Chip Select (Setup, Pulse, Cycle, Mode) if accesses are performed on this CS during the modification. Any change of the Chip Select parameters, while fetching the code from a memory connected on this CS, may lead SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 395 SAM9X25 SAM9X25 to unpredictable behavior. The instructions used to modify the parameters of an SMC Chip Select can be executed from the internal RAM or from a memory connected to another CS. 29.10.3.2 Slow Clock Mode Transition A Reload Configuration Wait State is also inserted when the Slow Clock Mode is entered or exited, after the end of the current transfer (see “Slow Clock Mode”...
  • Page 396 TDF = 2 clock cycles NRD controlled read operation Figure 29-21. TDF Period in NCS Controlled Read Operation (TDF = 3) A[25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 tpacc D[31:0] TDF = 3 clock cycles NCS controlled read operation SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 397 SAM9X25 SAM9X25 29.11.2 TDF Optimization Enabled (TDF_MODE = 1) When the TDF_MODE of the SMC_MODE register is set to 1 (TDF optimization is enabled), the SMC takes advantage of the setup period of the next access to optimize the number of wait states cycle to insert.
  • Page 398 = 1 write2 controlling signal TDF_CYCLES = 4 (NWE) D[31:0] 2 TDF WAIT STATES read1 cycle write2 cycle TDF_CYCLES = 4 TDF_MODE = 0 Read to Write Chip Select (optimization disabled) Wait State Wait State SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 399 SAM9X25 SAM9X25 Figure 29-25. TDF Mode = 0: TDF wait states between read and write accesses on the same chip select A[25:2] NBS0, NBS1, NBS2, NBS3, A0, A1 read1 controlling signal (NRD) write2 setup = 1 read1 hold = 1...
  • Page 400 Figure 29-26. Write Access with NWAIT Assertion in Frozen Mode (EXNW_MODE = 10) [25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 FROZEN STATE D[31:0] NWAIT internally synchronized NWAIT signal Write cycle EXNW_MODE = 10 (Frozen) WRITE_MODE = 1 (NWE_controlled) NWE_PULSE = 5 NCS_WR_PULSE = 7 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 401 SAM9X25 SAM9X25 Figure 29-27. Read Access with NWAIT Assertion in Frozen Mode (EXNW_MODE = 10) [25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 FROZEN STATE NWAIT internally synchronized NWAIT signal Read cycle EXNW_MODE = 10 (Frozen) READ_MODE = 0 (NCS_controlled) Assertion is ignored...
  • Page 402 Figure 29-28. NWAIT Assertion in Write Access: Ready Mode (EXNW_MODE = 11) [25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 Wait STATE D[31:0] NWAIT internally synchronized NWAIT signal Write cycle EXNW_MODE = 11 (Ready mode) WRITE_MODE = 1 (NWE_controlled) NWE_PULSE = 5 NCS_WR_PULSE = 7 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 403 SAM9X25 SAM9X25 Figure 29-29. NWAIT Assertion in Read Access: Ready Mode (EXNW_MODE = 11) A[25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 Wait STATE NWAIT internally synchronized NWAIT signal Read cycle EXNW_MODE = 11(Ready mode) READ_MODE = 0 (NCS_controlled) Assertion is ignored...
  • Page 404 Figure 29-30. NWAIT Latency [25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 WAIT STATE minimal pulse length NWAIT intenally synchronized NWAIT latency 2 cycle resynchronization NWAIT signal Read cycle EXNW_MODE = 10 or 11 READ_MODE = 1 (NRD_controlled) NRD_PULSE = 5 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 405 SAM9X25 SAM9X25 29.13 Slow Clock Mode The SMC is able to automatically apply a set of “slow clock mode” read/write waveforms when an internal signal driven by the Power Management Controller is asserted because MCK has been turned to a very slow clock rate (typically 32kHz clock rate). In this mode, the user-pro- grammed waveforms are ignored and the slow clock mode waveforms are applied.
  • Page 406 SLOW CLOCK MODE WRITE SLOW CLOCK MODE WRITE NORMAL MODE WRITE This write cycle finishes with the slow clock mode set Slow clock mode transition is detected: of parameters after the clock rate transition Reload Configuration Wait State SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 407 SAM9X25 SAM9X25 Figure 29-33. 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 A[25:2] NBS0, NBS1, NBS2, NBS3, A0,A1 SLOW CLOCK MODE WRITE...
  • Page 408 NCS_RD_PULSE NRD_PULSE The NRD and NCS signals are held low during all read transfers, whatever the programmed val- ues of the setup and hold timings in the User Interface may be. Moreover, the NRD and NCS SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 409 SAM9X25 SAM9X25 timings are identical. The pulse length of the first access to the page is defined with the NCS_RD_PULSE field of the SMC_PULSE register. The pulse length of subsequent accesses within the page are defined using the NRD_PULSE parameter.
  • Page 410 Figure 29-35. Access to Non-sequential Data within the Same Page Page address A[25:3] A[2], A1, A0 D[7:0] NRD_PULSE NCS_RD_PULSE NRD_PULSE SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 411 SAM9X25 SAM9X25 29.15 Programmable IO Delays The external bus interface consists of a data bus, an address bus and control signals. The simul- taneous switching outputs on these busses may lead to a peak of current in the internal and external power supply lines.
  • Page 412 0xD8 SMC Delay on I/O SMC_DELAY7 Read-write 0x00000000 0xDC SMC Delay on I/O SMC_DELAY8 Read-write 0x00000000 SMC Write Protect Mode 0xE4 SMC_WPMR Read-write 0x00000000 Register SMC Write Protect Status 0xE8 SMC_WPSR Read-only 0x00000000 Register 0xEC-0xFC Reserved SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 413 SAM9X25 SAM9X25 29.16.1 SMC Setup Register Name: SMC_SETUP[0..5] Address: 0xFFFFEA00 [0], 0xFFFFEA10 [1], 0xFFFFEA20 [2], 0xFFFFEA30 [3], 0xFFFFEA40 [4], 0xFFFFEA50 [5] Access: Read-write – – NCS_RD_SETUP – – NRD_SETUP – – NCS_WR_SETUP – – NWE_SETUP • NWE_SETUP: NWE Setup Length...
  • Page 414 NCS pulse length = (256* NCS_RD_PULSE[6] + NCS_RD_PULSE[5:0]) clock cycles The NCS pulse length must be at least 1 clock cycle. In page mode read access, the NCS_RD_PULSE parameter defines the duration of the first access to one page. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 415 SAM9X25 SAM9X25 29.16.3 SMC Cycle Register Name: SMC_CYCLE[0..5] Address: 0xFFFFEA08 [0], 0xFFFFEA18 [1], 0xFFFFEA28 [2], 0xFFFFEA38 [3], 0xFFFFEA48 [4], 0xFFFFEA58 [5] Access: Read-write – – – – – – – NRD_CYCLE NRD_CYCLE – – – – – – – NWE_CYCLE NWE_CYCLE •...
  • Page 416 • Disabled Mode: The NWAIT input signal is ignored on the corresponding Chip Select. • Frozen Mode: If asserted, the NWAIT signal freezes the current read or write cycle. After deassertion, the read/write cycle is resumed from the point where it was stopped. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 417 SAM9X25 SAM9X25 • 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.
  • Page 418 0xFFFFEAC0 [1], 0xFFFFEAC4 [2], 0xFFFFEAC8 [3], 0xFFFFEACC [4], 0xFFFFEAD0 [5], 0xFFFFEAD4 [6], 0xFFFFEAD8 [7], 0xFFFFEADC [8] Access: Read-write Reset Value: Table 29-8 Delay8 Delay7 Delay6 Delay5 Delay4 Delay3 Delay2 Delay1 • Delay x: Gives the number of elements in the delay line. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 419 SAM9X25 SAM9X25 29.16.6 SMC Write Protect Mode Register Name: SMC_WPMR Address: 0xFFFFEAE4 Access: Read-write Reset Value: Table 29-8 WPKEY WPKEY WPKEY — — — — — — — WPEN • WPEN: Write Protect Enable 0 = Disables the Write Protect if WPKEY corresponds to 0x534D43 (“SMC” in ASCII).
  • Page 420 • WPVSRC: Write Protect Violation Source When WPVS is active, this field indicates the write-protected register (through address offset or code) in which a write access has been attempted. Note: Reading SMC_WPSR automatically clears all fields. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 421 SAM9X25 SAM9X25 30. DDR SDR SDRAM Controller (DDRSDRC) 30.1 Description The DDR SDR SDRAM Controller (DDRSDRC) is a multiport memory controller. It comprises four slave AHB interfaces. All simultaneous accesses (four independent AHB ports) are inter- leaved to maximize memory bandwidth and minimize transaction latency due to SDRAM protocol.
  • Page 422 • DDR2-SDRAM with Eight Internal Banks Supported • Linear and Interleaved Decoding Supported • SDR-SDRAM or Low-power DDR1-SDRAM with 2 Internal Banks Not Supported • Clock Frequency Change in Precharge Power-down Mode Not Supported • OCD (Off-chip Driver) Mode Not Supported SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 423 SAM9X25 SAM9X25 30.3 DDRSDRC Module Diagram Figure 30-1. DDRSDRC Module Diagram DDR-SDR Controller AHB Slave Interface 0 Input Power Management Stage clk/nclk ras,cas,we AHB Slave Interface 1 Input Stage Addr, DQM Memory Controller Output Finite State Machine DDR-SDR Stage SDRAM Signal Management...
  • Page 424 9. The application must go into Normal Mode, setting Mode to 0 in the Mode Register (see Section 30.7.1 on page 452) and perform a write access at any location in the SDRAM to acknowledge this command. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 425 SAM9X25 SAM9X25 10. Write the refresh rate into the count field in the DDRSDRC Refresh Timer register (see page 453). (Refresh rate = delay between refresh cycles). The SDR-SDRAM device requires a refresh every 15.625 μs or 7.81 μs. With a 100 MHz frequency, the refresh timer count register must to be set with (15.625*100 MHz) = 1562 i.e.
  • Page 426 The write address must be chosen so that BA[1] is set to 1 and BA[0] is set to 1. For example, with a 16-bit 128 MB DDR2-SDRAM (12 rows, 9 columns, 4 banks) bank address, the DDR2-SDRAM write access should be done at the address 0x20C00000. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 427 SAM9X25 SAM9X25 8. An Extended Mode Register set (EMRS1) cycle is issued to enable DLL. The applica- tion must set Mode to 5 in the Mode Register (see Section 30.7.1 on page 452) 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.
  • Page 428 15.625 μs or 7.81 μs. With a 133 MHz frequency, the refresh timer count register must to 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 429 SAM9X25 SAM9X25 30.5 Functional Description 30.5.1 SDRAM Controller Write Cycle The DDRSDRC allows burst access or single access in normal mode (mode = 000). Whatever the access type, the DDRSDRC keeps track of the active row in each bank, thus maximizing performance.
  • Page 430 DM[1:0] D[15:0] Trp = 2 Trcd = 2 Figure 30-3. Single Write Access, Row Closed, DDR2-SDRAM Device SDCLK A[12:0] Row a col a COMMAND PRCHG WRITE BA[1:0] DQS[1:0] DM[1:0] D[15:0] Trp = 2 Trcd = 2 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 431 SAM9X25 SAM9X25 Figure 30-4. Single Write Access, Row Closed, SDR-SDRAM Device SDCLK A[12:0] Row a Col a COMMAND PRCHG WRITE BA[1:0] DM[1:0] D[31:0] DaDb Trp = 2 Trcd = 2 Figure 30-5. Burst Write Access, Row Closed, Low-power DDR1-SDRAM Device...
  • Page 432 Dg Dhs Trcd 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 30-8 on page 433. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 433 SAM9X25 SAM9X25 Figure 30-8. Write Command Followed By a Read Command without Burst Write Interrupt, Low-power DDR1-SDRAM Device SDCLK A[12:0] col a col a COMMAND WRITE READ BA[1:0] DQS[1:0] DM[1:0] D[15:0] Dd De Df Dg Dh Da Db Twrd = BL/2 +2 = 8/2 +2 = 6...
  • Page 434 In the case where the page access is already open, a read command is generated. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 435 SAM9X25 SAM9X25 To comply with SDRAM timing parameters, additional clock cycles are inserted between pre- charge/active (Trp) commands and active/read (Trcd) commands. The DDRSDRC supports a cas latency of two, two and half, and three (2 or 3 clocks delay). During this delay, the controller uses internal signals to anticipate the next access and improve the performance of the control- ler.
  • Page 436 DM[1:0] D[15:0] Latency = 2 Trcd Figure 30-12. Single Read Access, Row Close, Latency = 3, DDR2-SDRAM Device SDCLK A[12:0] Row a Col a COMMAND PRCHG READ BA[1:0] DQS[1] DQS[0] DM[1:0] D[15:0] Latency = 2 Trcd SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 437 SAM9X25 SAM9X25 Figure 30-13. Single Read Access, Row Close, Latency = 2, SDR-SDRAM Device SDCLK A[12:0] Row a col a COMMAND PRCHG READ BA[1:0] DM[3:0] D[31:0] DaDb Trcd Latency = 2 Figure 30-14. Burst Read Access, Latency = 2, Low-power DDR1-SDRAM Devices...
  • Page 438 When the DDRSDRC initiates a refresh of an SDRAM device, internal memory accesses are not delayed. However, if the CPU tries to access the SDRAM device, the slave indicates that the device is busy. A request of refresh does not interrupt a burst transfer in progress. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 439 SAM9X25 SAM9X25 30.5.4 Power Management 30.5.4.1 Self Refresh Mode This mode is activated by setting low-power command bits [LPCB] to ‘01’ in the DDRSDRC_LPR Register Self refresh mode is used to reduce power consumption, i.e., when no access to the SDRAM device is possible.
  • Page 440 Enter Self refresh Mode Figure 30-18. Self Refresh Mode Entry, Timeout = 1 or 2 SDCLK A[12:0] COMMAND NOP READ PRCHG ARFSH NOP BA[1:0] DQS[1:0] DM[1:0] D[15:0] Enter Self refresh 64 or 128 Mode wait states SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 441 SAM9X25 SAM9X25 Figure 30-19. Self Refresh Mode Exit SDCLK A[12:0] COMMAND VALID BA[1:0] DQS[1:0] DM[1:0] D[15:0] DaDb Exit Self Refresh mode clock must be stable TXNRD/TXSRD (DDR device) before exiting self refresh mode TXSR (Low-power DDR1 device) TXSR (Low-power SDR, SDR-SDRAM device) Figure 30-20.
  • Page 442 • 00 = Power-down mode is enabled as soon as the 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 443 SAM9X25 SAM9X25 Figure 30-22. Power-down Entry/Exit, Timeout = 0 SDCLK A[12:0] COMMAND READ READ BA[1:0] DQS[1:0] DM[1:0] D[15:0] Exit power down mode Entry power down mode 30.5.4.3 Deep Power-down Mode The deep power-down mode is a new feature of the Low-power SDRAM. When this mode is activated, all internal voltage generators inside the device are stopped and all data is lost.
  • Page 444 X during current access in bank Y. This allows Trp and Trcd timings to be masked (see Figure 30-25). 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 445 SAM9X25 SAM9X25 the case of four simultaneous read accesses, when the four banks and associated rows are open, the controller reads with a continuous flow and masks the cas latency for each different access. To allow a continuous flow, the read command must be set at 2 or 3 cycles (cas latency) before the end of current access.
  • Page 446 “DDRSDRC Timing Parameter 0 Register” on page 457 • “DDRSDRC Timing Parameter 1 Register” on page 459 • “DDRSDRC Timing Parameter 2 Register” on page 460 • “DDRSDRC Memory Device Register” on page 463 • “DDRSDRC High Speed Register” on page 465 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 447 SAM9X25 SAM9X25 30.6 Software Interface/SDRAM Organization, Address Mapping The SDRAM address space is organized into banks, rows and columns. The DDRSDRC maps different memory types depending on the values set in the DDRSDRC Configuration Register. Section 30.7.3 “DDRSDRC Configuration Register” on page 454.
  • Page 448 Column[8:0] Row[11:0] Bk[1:0] Column[9:0] Row[11:0] Bk[1:0] Column[10:0] Row[11:0] Bk[1:0] Column[11:0] Table 30-7. Interleaved Mapping for SDRAM Configuration: 8K Rows, 512/1024/2048/4096 Columns CPU Address Line Row[12:0] Bk[1:0] Column[8:0] Row[12:0] Bk[1:0] Column[9:0] Row[12:0] Bk[1:0] Column[10:0] Row[12:0] Bk[1:0] Column[11:0] SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 449 SAM9X25 SAM9X25 Table 30-8. Interleaved Mapping for SDRAM Configuration: 16K Rows, 512/1024/2048 Columns CPU Address Line Row[13:0] Bk[1:0] Column[8:0] Row[13:0] Bk[1:0] Column[9:0] Row[13:0] Bk[1:0] Column[10:0] 30.6.2 SDRAM Address Mapping for 16-bit Memory Data Bus Width and Eight Banks Table 30-9.
  • Page 450 CPU Address Line Bk[1:0] Row[12:0] Column[7:0] M[1:0] Bk[1:0] Row[12:0] Column[8:0] M[1:0] Bk[1:0] Row[12:0] Column[9:0] M[1:0] Bk[1:0] Row[12:0] Column[10:0] M[1:0] Notes: 1. M[1:0] is the byte address inside a 32-bit word. 2. Bk[1] = BA1, Bk[0] = BA0 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 451 SAM9X25 SAM9X25 30.7 DDR SDR SDRAM Controller (DDRSDRC) User Interface The User Interface is connected to the APB bus. The DDRSDRC is programmed using the registers listed in Table 30-16 Table 30-16. Register Mapping Offset Register Name Access Reset 0x00...
  • Page 452 To activate this mode, the “Extended Load Mode Register” command must be followed by a write to the SDRAM. The write in the SDRAM must be done in the appropriate bank. Deep power mode: Access to deep power-down mode Reserved SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 453 SAM9X25 SAM9X25 30.7.2 DDRSDRC Refresh Timer Register Name: DDRSDRC_RTR Address: 0xFFFFE804 Access: Read-write Reset: Table 30-16 – – – – – – – – – – – – – – – – – – – – COUNT COUNT This register can only be written if the bit WPEN is cleared in “DDRSDRC Write Protect Mode Register”...
  • Page 454 The reset value is 9 column bits. SDR-SDRAM devices with eight columns in 16-bit mode are not supported. DDR - Column bits SDR - Column bits • NR: Number of Row Bits The reset value is 12 row bits. Row bits SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 455 SAM9X25 SAM9X25 • CAS: CAS Latency The reset value is 2 cycles. DDR2 CAS Latency SDR CAS Latency Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved • DLL: Reset DLL Reset value is 0. This field defines the value of Reset DLL.
  • Page 456 The reset value is four banks. Number of banks Note: Only DDR-SDRAM 2 devices support eight internal banks. • DECOD: Type of Decoding The reset value is 0: sequential decoding. 0 = Sequential Decoding. 1 = Interleaved Decoding. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 457 SAM9X25 SAM9X25 30.7.4 DDRSDRC Timing Parameter 0 Register Name: DDRSDRC_TPR0 Address: 0xFFFFE80C Access: Read-write Reset: Table 30-16 TMRD REDUCE_WRRD TWTR TRRD TRCD TRAS This register can only be written if the bit WPEN is cleared in “DDRSDRC Write Protect Mode Register” on page 466.
  • Page 458 • TMRD: Load Mode Register Command to Active or Refresh Command Reset Value is 2 cycles. This field defines the delay between a Load mode register command and an active or refresh command in number of cycles. Number of cycles is between 0 and 15. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 459 SAM9X25 SAM9X25 30.7.5 DDRSDRC Timing Parameter 1 Register Name: DDRSDRC_TPR1 Address: 0xFFFFE810 Access: Read-write Reset: Table 30-16 – – – – TXSRD TXSNR – – – TRFC This register can only be written if the bit WPEN is cleared in “DDRSDRC Write Protect Mode Register”...
  • Page 460 . This requires that no more than four ACTIVATE commands may be issued in any given t (MIN) period. Number of cycles is between 0 and 15. Note: This field is found only in DDR-SDRAM 2 devices with eight internal banks SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 461 SAM9X25 SAM9X25 30.7.7 DDRSDRC Low-power Register Name: DDRSDRC_LPR Address: 0xFFFFE81C Access: Read-write Reset: Table 30-16 – – – – – – – – – – UPD_MR – – – APDE – – TIMEOUT – – PASR CLK_FR LPCB • LPCB: Low-power Command Bit Reset value is “00”.
  • Page 462 DDRSDRC shares external bus. Automatic update is done during a refresh command and a pending read or write access in SDRAM device. DDRSDRC does not share external bus. Automatic update is done before entering in self refresh mode. Reserved SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 463 SAM9X25 SAM9X25 30.7.8 DDRSDRC Memory Device Register Name: DDRSDRC_MD Address: 0xFFFFE820 Access: Read-write Reset: Table 30-16 – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 464 Master lock. If this flag is set, it means the DDRSDRC clock frequency is too low compared to Master delay line number of elements. • MDVAL DLL Master Delay Value Value of the Master delay counter. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 465 SAM9X25 SAM9X25 30.7.10 DDRSDRC High Speed Register Name: DDRSDRC_HS Address: 0xFFFFE82C Access: Read-write Reset: Table 30-16 – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 466 “DDRSDRC High Speed Register” on page 465 • WPKEY: Write Protect KEY Should be written at value 0x444452 (“DDR” in ASCII). Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 467 SAM9X25 SAM9X25 30.7.12 DDRSDRC Write Protect Status Register Name: DDRSDRC_WPSR Address: 0xFFFFE8E8 Access: Read-only Reset: Table 30-16 – – – – – – – – WPVSRC WPVSRC – – – – – – – WPVS • WPVS: Write Protect Violation Status 0 = No Write Protect Violation has occurred since the last read of the DDRSDRC_WPSR register.
  • Page 468 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 469 SAM9X25 SAM9X25 31. DMA Controller (DMAC) 31.1 Description The DMA Controller (DMAC) is an AHB-central DMA controller core that transfers data from a source peripheral to a destination peripheral over one or more AMBA buses. One channel is required for each source/destination pair. In the most basic configuration, the DMAC has one master interface and one channel.
  • Page 470 The hardware interface numbers are also given in Table 31-1. Table 31-1. DMA Channel Definition DMA Channel HW Instance Name interface Number HSMCI0 RX/TX SPI0 SPI0 USART0 USART0 USART1 USART1 TWI0 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 471 SAM9X25 SAM9X25 Table 31-1. DMA Channel Definition (Continued) DMA Channel HW Instance Name interface Number TWI0 TWI2 TWI2 UART0 UART0 31.2.2 DMA Controller 1 • Two Masters • Embeds 8 channels • 16-bytes FIFO per Channel • features: – Linked List support with Status Write Back operation at End of Transfer –...
  • Page 472 DMA Global DMA Global Control Request Arbiter and Data Mux DMA Destination DMA Write Requests Pool Datapath Bundles DMA Channel n Atmel APB rev2 Interface DMA Destination Atmel DMA Channel 2 Status Interface DMA Channel 1 Registers DMA Channel 0...
  • Page 473 SAM9X25 SAM9X25 31.4 Functional Description 31.4.1 Basic Definitions Source peripheral: Device on an AMBA layer from where the DMAC reads data, which is then stored in the channel FIFO. The source peripheral teams up with a destination peripheral to form a channel.
  • Page 474 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 475 SAM9X25 SAM9X25 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. Multi-buffer DMAC transfer: A DMAC transfer may consist of multiple DMAC buffers. Multi-buf- fer DMAC transfers are supported through buffer chaining (linked list pointers), auto-reloading of channel registers, and contiguous buffers.
  • Page 476 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]. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 477 SAM9X25 SAM9X25 31.4.3.3 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.
  • Page 478 = DSCRx(0) + 0x8 DADDRx DADDRx = DSCRx(1) + 0x4 = DSCRx(0) + 0x4 SADDRx SADDRx = DSCRx(1) + 0x0 = DSCRx(0) + 0x0 DSCRx(0) DSCRx(2) DSCRx(1) (points to 0 if LLI(1) is the last transfer descriptor SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 479 SAM9X25 SAM9X25 31.4.4.2 Programming DMAC for Multiple Buffer Transfers Table 31-3. Multiple Buffers Transfer Management Table Transfer Type AUTO SRC_REP DST_REP SRC_DSCR DST_DSCR BTSIZE DSCR SADDR DADDR Other Fields 1) Single Buffer or Last buffer of a multiple buffer –...
  • Page 480 L L I . D M A C _ C T R L B x . S R C _ D S C R a n d LLI.DMAC_CTRLBx.DST_DSCR are one and LLI.DMAC_DSCRx is set to 0. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 481 SAM9X25 SAM9X25 31.4.5 Programming a Channel Four registers, the DMAC_DSCRx, the DMAC_CTRLAx, the DMAC_CTRLBx and DMAC_CFGx, need to be programmed to set up whether single or multi-buffer transfers take place, and which type of multi-buffer transfer is used. The different transfer types are shown in Table 31-3 on page 479.
  • Page 482 This requires programming the SRC_PER and DST_PER bits, respectively. 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 31-3 on page 479. The SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 483 SAM9X25 SAM9X25 LLI.DMAC_CTRLBx register of the last Linked List Item must be set as described in Row 1 of Table 31-3. Figure 31-5 on page 478 shows a Linked List example with two list items. 5. 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.
  • Page 484 DMAC_CTRLAx.BTSIZE, then this can be achieved using the type of multi-buffer transfer as shown in Figure 31-7 on page 485. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 485 SAM9X25 SAM9X25 Figure 31-7. Multi-buffer with Linked Address for Source and Destination Buffers are Contiguous Address of Address of Source Layer Destination Layer Buffer 2 DADDR(3) Buffer 2 Buffer 2 SADDR(3) DADDR(2) Buffer 2 Buffer 1 SADDR(2) DADDR(1) Buffer 1...
  • Page 486 1. Read the Channel Enable register to choose an available (disabled) channel. 2. Clear any pending interrupts on the channel from the previous DMAC transfer by read- ing the interrupt status register. Program the following channel registers: SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 487 SAM9X25 SAM9X25 a. Write the starting source address in the DMAC_SADDRx register for channel x. b. Write the starting destination address in the DMAC_DADDRx register for channel x. c. Program DMAC_CTRLAx, DMAC_CTRLBx and DMAC_CFGx according to Row 10 as shown in Table 31-3 on page 479.
  • Page 488 488. The DMAC transfer flow is shown in Figure 31-10 on page 489. Figure 31-9. Multi-buffer DMAC Transfer with Source and Destination Address Auto-reloaded Address of Address of Source Layer Destination Layer Block0 Block1 Block2 SADDR DADDR BlockN Destination Buffers Source Buffers SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 489 SAM9X25 SAM9X25 Figure 31-10. DMAC Transfer Flow for Source and Destination Address Auto-reloaded Channel Enabled by software Buffer Transfer Replay mode for SADDRx, DADDRx, CTRLAx, CTRLBx Buffer Complete interrupt generated here HDMA Transfer Complete Interrupt generated here Is HDMA in Row1 of...
  • Page 490 (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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 491 SAM9X25 SAM9X25 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, 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.
  • Page 492 DMAC_CTRLAx register for channel x. For example, in this register, you can pro- gram 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 493 SAM9X25 SAM9X25 – ii. Set up the transfer characteristics, such as: – 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.
  • Page 494 Figure 31-14 on page 495. Figure 31-13. Multi-buffer Transfer with Source Address Auto-reloaded and Contiguous Destination Address Address of Address of Destination Layer Source Layer Buffer2 DADDR(2) Buffer1 DADDR(1) Buffer0 SADDR DADDR(0) Source Buffers Destination Buffers SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 495 SAM9X25 SAM9X25 Figure 31-14. 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 Complete interrupt generated here Buffer Transfer Complete...
  • Page 496 17. Once the buffer of data is transferred, the DMAC_CTRLAx register is written out to sys- tem 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 497 SAM9X25 SAM9X25 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.
  • Page 498 DMAC_CHSR.ENABLE[n] register bit. The recommended way for software to disable a channel without losing data is to use the SUS- PEND[n] bit in conjunction with the EMPTY[n] bit in the Channel Handler Status Register. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 499 SAM9X25 SAM9X25 1. If software wishes to disable a channel n prior to the DMAC transfer completion, then it can set the DMAC_CHER.SUSPEND[n] bit to tell the DMAC to halt all transfers from the source peripheral. Therefore, the channel FIFO receives no new data.
  • Page 500 BTSIZE must be initialized to a non zero value if the first transfer is initiated with AUTO field set to TRUE even if LLI mode is enabled because the LLI fetch operation will not update this field. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 501 SAM9X25 SAM9X25 31.6 Write Protection Registers To prevent any single software error that may corrupt DMAC behavior, the DMAC address space can be write-protected by setting the WPEN bit in the “DMAC Write Protect Mode Regis- ter” (DMAC_WPMR). If a write access to anywhere in the DMAC address space is detected, then the WPVS flag in the DMAC Write Protect Status Register (MCI_WPSR) is set and the field WPVSRC indicates in which register the write access has been attempted.
  • Page 502 DMAC Channel Destination Picture in Picture Configuration 0x03C+ch_num*(0x28)+(0x1C) DMAC_DPIP Read-write Register 0x03C+ch_num*(0x28)+(0x20) Reserved – – – 0x03C+ch_num*(0x28)+(0x24) Reserved – – – 0x1E4 Write Protect Mode Register DMAC_WPMR Read-write 0x1E8 Write Protect Status Register DMAC_WPSR Read-only 0x01EC- 0x1FC Reserved – – – SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 503 SAM9X25 SAM9X25 31.7.1 DMAC Global Configuration Register Name: DMAC_GCFG Address: 0xFFFFEC00 (0), 0xFFFFEE00 (1) Access: Read-write Reset: 0x00000010 – – – – – – – – – – – – – – – – – – – – – –...
  • Page 504 DSREQ7 SSREQ7 DSREQ6 SSREQ6 DSREQ5 SSREQ5 DSREQ4 SSREQ4 DSREQ3 SSREQ3 DSREQ2 SSREQ2 DSREQ1 SSREQ1 DSREQ0 SSREQ0 • DSREQx Request a destination single transfer on channel i. • SSREQx Request a source single transfer on channel i. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 505 SAM9X25 SAM9X25 31.7.4 DMAC Software Chunk Transfer Request Register Name: DMAC_CREQ Address: 0xFFFFEC0C (0), 0xFFFFEE0C (1) Access: Read-write Reset: 0x00000000 – – – – – – – – – – – – – – – – DCREQ7 SCREQ7 DCREQ6 SCREQ6...
  • Page 506 Writing one to DLASTx prior to writing one to DSREQx or DCREQx indicates that this destination request is the last transfer of the buffer. • SLASTx Writing one to SLASTx prior to writing one to SSREQx or SCREQx indicates that this source request is the last transfer of the buffer. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 507 SAM9X25 SAM9X25 31.7.6 DMAC Error, Buffer Transfer and Chained Buffer Transfer Interrupt Enable Register Name: DMAC_EBCIER Address: 0xFFFFEC18 (0), 0xFFFFEE18 (1) Access: Write-only Reset: 0x00000000 – – – – – – – – ERR7 ERR6 ERR5 ERR4 ERR3 ERR2 ERR1...
  • Page 508 Chained Buffer transfer completed Disable Register. When set, a bit of the CBTC field disables the interrupt from the rele- vant DMAC channel. • ERRx: Access Error [7:0] Access Error Interrupt Disable Register. When set, a bit of the ERR field disables the interrupt from the relevant DMAC channel. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 509 SAM9X25 SAM9X25 31.7.8 DMAC Error, Buffer Transfer and Chained Buffer Transfer Interrupt Mask Register Name: DMAC_EBCIMR Address: 0xFFFFEC20 (0), 0xFFFFEE20 (1) Access: Read-only Reset: 0x00000000 – – – – – – – – ERR7 ERR6 ERR5 ERR4 ERR3 ERR2 ERR1...
  • Page 510 • CBTCx: Chained Buffer Transfer Completed [7:0] When CBTC[i] is set, Channel i Chained buffer has terminated. LLI Fetch operation is disabled. • ERRx: Access Error [7:0] When ERR[i] is set, Channel i has detected an AHB Read or Write Error Access. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 511 SAM9X25 SAM9X25 31.7.10 DMAC Channel Handler Enable Register Name: DMAC_CHER Address: 0xFFFFEC28 (0), 0xFFFFEE28 (1) Access: Write-only Reset: 0x00000000 KEEP7 KEEP6 KEEP5 KEEP4 KEEP3 KEEP2 KEEP1 KEEP0 – – – – – – – – SUSP7 SUSP6 SUSP5 SUSP4 SUSP3...
  • Page 512 Write one to this field to disable the relevant DMAC Channel. The content of the FIFO is lost and the current AHB access is terminated. Software must poll DIS[7:0] field in the DMAC_CHSR register to be sure that the channel is disabled. • RESx: [7:0] Write one to this field to resume the channel transfer restoring its context. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 513 SAM9X25 SAM9X25 31.7.12 DMAC Channel Handler Status Register Name: DMAC_CHSR Address: 0xFFFFEC30 (0), 0xFFFFEE30 (1) Access: Read-only Reset: 0x00FF0000 STAL7 STAL6 STAL5 STAL4 STAL3 STAL2 STAL1 STAL0 EMPT7 EMPT6 EMPT5 EMPT4 EMPT3 EMPT2 EMPT1 EMPT0 SUSP7 SUSP6 SUSP5 SUSP4 SUSP3...
  • Page 514 SADDR SADDR This register can only be written if the WPEN bit is cleared in “DMAC Write Protect Mode Register”. • SADDR: Channel x source address. This register must be aligned with the source transfer width. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 515 SAM9X25 SAM9X25 31.7.14 DMAC Channel x [x = 0..7] Destination Address Register Name: DMAC_DADDRx [x = 0..7] Address: 0xFFFFEC40 (0)[0], 0xFFFFEC68 (0)[1], 0xFFFFEC90 (0)[2], 0xFFFFECB8 (0)[3], 0xFFFFECE0 (0)[4], 0xFFFFED08 (0)[5], 0xFFFFED30 (0)[6], 0xFFFFED58 (0)[7], 0xFFFFEE40 (1)[0], 0xFFFFEE68 (1)[1], 0xFFFFEE90 (1)[2], 0xFFFFEEB8 (1)[3], 0xFFFFEEE0 (1)[4], 0xFFFFEF08 (1)[5], 0xFFFFEF30 (1)[6],...
  • Page 516 Value Name Description AHB_IF0 The buffer transfer descriptor is fetched via AHB-Lite Interface 0 AHB_IF1 The buffer transfer descriptor is fetched via AHB-Lite Interface 1 • DSCR: Buffer Transfer descriptor address. This address is word aligned. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 517 SAM9X25 SAM9X25 31.7.16 DMAC Channel x [x = 0..7] Control A Register Name: DMAC_CTRLAx [x = 0..7] Address: 0xFFFFEC48 (0)[0], 0xFFFFEC70 (0)[1], 0xFFFFEC98 (0)[2], 0xFFFFECC0 (0)[3], 0xFFFFECE8 (0)[4], 0xFFFFED10 (0)[5], 0xFFFFED38 (0)[6], 0xFFFFED60 (0)[7], 0xFFFFEE48 (1)[0], 0xFFFFEE70 (1)[1], 0xFFFFEE98 (1)[2], 0xFFFFEEC0 (1)[3], 0xFFFFEEE8 (1)[4], 0xFFFFEF10 (1)[5], 0xFFFFEF38 (1)[6],...
  • Page 518 1: If SOD field of DMAC_CFG register is set to true, then the DMAC is automatically disabled when an LLI updates the con- tent of this register. The DONE field is written back to memory at the end of the transfer. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 519 SAM9X25 SAM9X25 31.7.17 DMAC Channel x [x = 0..7] Control B Register Name: DMAC_CTRLBx [x = 0..7] Address: 0xFFFFEC4C (0)[0], 0xFFFFEC74 (0)[1], 0xFFFFEC9C (0)[2], 0xFFFFECC4 (0)[3], 0xFFFFECEC (0)[4], 0xFFFFED14 (0)[5], 0xFFFFED3C (0)[6], 0xFFFFED64 (0)[7], 0xFFFFEE4C (1)[0], 0xFFFFEE74 (1)[1], 0xFFFFEE9C (1)[2], 0xFFFFEEC4 (1)[3], 0xFFFFEEEC (1)[4], 0xFFFFEF14 (1)[5], 0xFFFFEF3C (1)[6],...
  • Page 520 • AUTO: Automatic Multiple Buffer Transfer 0 (DISABLE): Automatic multiple buffer transfer is disabled. 1 (ENABLE): Automatic multiple buffer transfer is enabled. This bit enables replay mode or contiguous mode when several buffers are transferred. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 521 SAM9X25 SAM9X25 31.7.18 DMAC Channel x [x = 0..7] Configuration Register Name: DMAC_CFGx [x = 0..7] Address: 0xFFFFEC50 (0)[0], 0xFFFFEC78 (0)[1], 0xFFFFECA0 (0)[2], 0xFFFFECC8 (0)[3], 0xFFFFECF0 (0)[4], 0xFFFFED18 (0)[5], 0xFFFFED40 (0)[6], 0xFFFFED68 (0)[7], 0xFFFFEE50 (1)[0], 0xFFFFEE78 (1)[1], 0xFFFFEEA0 (1)[2], 0xFFFFEEC8 (1)[3], 0xFFFFEEF0 (1)[4], 0xFFFFEF18 (1)[5], 0xFFFFEF40 (1)[6],...
  • Page 522 The largest defined length AHB burst is performed on the destination AHB interface. HALF_CFG When half FIFO size is available/filled, a source/destination request is serviced. When there is enough space/data available to perform a single AHB access, then the ASAP_CFG request is serviced. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 523 SAM9X25 SAM9X25 31.7.19 DMAC Channel x [x = 0..7] Source Picture in Picture Configuration Register Name: DMAC_SPIPx [x = 0..7] Address: 0xFFFFEC54 (0)[0], 0xFFFFEC7C (0)[1], 0xFFFFECA4 (0)[2], 0xFFFFECCC (0)[3], 0xFFFFECF4 (0)[4], 0xFFFFED1C (0)[5], 0xFFFFED44 (0)[6], 0xFFFFED6C (0)[7], 0xFFFFEE54 (1)[0], 0xFFFFEE7C (1)[1],...
  • Page 524 • DPIP_HOLE This field indicates the value to add to the address when the programmable boundary has been reached. • DPIP_BOUNDARY This field indicates the number of source transfers to perform before the automatic address increment operation. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 525 SAM9X25 SAM9X25 31.7.21 DMAC Write Protect Mode Register Name: DMAC_WPMR Address: 0xFFFFEDE4 (0), 0xFFFFEFE4 (1) Access: Read-write Reset: Table 31-4 WPKEY WPKEY WPKEY — — — — — — — WPEN • WPEN: Write Protect Enable 0 = Disables the Write Protect if WPKEY corresponds to 0x444D4143 (“DMAC” in ASCII).
  • Page 526 • WPVSRC: Write Protect Violation Source When WPVS is active, this field indicates the write-protected register (through address offset or code) in which a write access has been attempted. Note: Reading DMAC_WPSR automatically clears all fields. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 527 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 Atmel’s architecture in the same way all existing class drivers run, without hardware specialization.
  • Page 528 The standard OHCI USB stack driver can be easily ported to Atmel’s 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 user’s application.
  • Page 529 USB physical transceivers are integrated in the product and driven by the root hub’s ports. Over current protection on ports can be activated by the USB host controller. Atmel’s standard product does not dedicate pads to external over current protection.
  • Page 530 EHCI Master 30 MHz Interface Port USB 2.0 EHCI UTMI transceiver Router Host Controller EHCI User FS transceiver Interface OHCI Master Interface Root Hub USB 1.1 OHCI Host Controller Host SIE OHCI User Interface OHCI clocks SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 531 SAM9X25 SAM9X25 32.4.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. 32.5 Typical Connection Figure 32-4. Board Schematic to Interface UHP High-speed Device Controller PIO (VBUS DETECT) "A"...
  • Page 532 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 533 SAM9X25 SAM9X25 33. USB High Speed Device Port (UDPHS) 33.1 Description The USB High Speed Device Port (UDPHS) is compliant with the Universal Serial Bus (USB), rev 2.0 High Speed device specification. Each endpoint can be configured in one of several USB transfer types. It can be associated with one, two or three banks of a Dual-port RAM used to store the current data payload.
  • Page 534 1. In Isochronous Mode (Iso), it is preferable that High Band Width capability is available. The size of internal DPRAM is 4 KB. Suspend and resume are automatically detected by the UDPHS device, which notifies the pro- cessor by raising an interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 535 SAM9X25 SAM9X25 33.3 Block Diagram Figure 33-2. Block Diagram APB bus Interface ctrl DHSDP status DHSDM AHB1 Rd/Wr/Ready UTMI DFSDP USB2.0 AHB bus CORE DFSDM AHB0 Master APB bus Multiplexeur Slave Local Slave interface Alloc 32 bits 16/8 bits DPRAM...
  • Page 536 The USB V2.0 High Speed Device Port provides communication services between host and attached USB devices. Each device is offered with a collection of communication flows (pipes) associated with each endpoint. Software on the host communicates with a USB Device through a set of communication flows. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 537 SAM9X25 SAM9X25 33.6.2 USB V2.0 High Speed Transfer Types A communication flow is carried over one of four transfer types defined by the USB device. A device provides several logical communication pipes with the host. To each logical pipe is associated an endpoint.
  • Page 538 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 Register” on page 584. Control endpoints can generate interrupts and use only 1 bank. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 539 SAM9X25 SAM9X25 All endpoints (except endpoint 0) can be configured either as Bulk, Interrupt or Isochronous. See Table 33-1. UDPHS Endpoint Description. The maximum packet size they can accept corresponds to the maximum endpoint size. Note: The endpoint size of 1024 is reserved for isochronous endpoints.
  • Page 540 – AUTO_VALID: Automatically validate the packet and switch to the next bank. – EPT_ENABL: Enable endpoint. • Without DMA – RX_BK_RDY: An interrupt is sent after a new packet has been stored in the endpoint FIFO. – EPT_ENABL: Enable endpoint. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 541 SAM9X25 SAM9X25 33.6.6 DPRAM Management Endpoints can only be allocated in ascending order, from the endpoint 0 to the last endpoint to be allocated. The user shall therefore configure them in the same order. The allocation of an endpoint x starts when the Number of Banks field in the UDPHS Endpoint Configuration Register (UDPHS_EPTCFGx.BK_NUMBER) is different from zero.
  • Page 542 The UDPHS DMA Channel Transfer Descriptor is described in “UDPHS DMA Channel Transfer Descriptor” on page 595. Note: In case of debug, be careful to address the DMA to an SRAM address even if a remap is done. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 543 SAM9X25 SAM9X25 Figure 33-7. Example of DMA Chained List Transfer Descriptor UDPHS Registers (Current Transfer Descriptor) Next Descriptor Address Transfer Descriptor DMA Channel Address UDPHS Next Descriptor Next Descriptor Address DMA Channel Control DMA Channel Address DMA Channel Address Transfer Descriptor...
  • Page 544 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 545 SAM9X25 SAM9X25 Figure 33-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...
  • Page 546 Each buffer to be transferred must be described by a DMA Transfer descriptor (see “UDPHS DMA Channel Transfer Descriptor” on page 595). Transfer descriptors are chained. Before exe- cuting transfer of the buffer, the UDPHS may fetch a new transfer descriptor from the memory SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 547 SAM9X25 SAM9X25 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 TX_BK_RDY may be set in the UDPHS_EPTCTLENBx register.
  • Page 548 Data OUT (ZLP) Data OUT (ZLP) Packets Interrupt Pending RX_BK_RDY Set by Hardware (UDPHS_EPTSTAx) Cleared by Firmware TX_COMPLT (UDPHS_EPTSTAx) Set by Hardware Cleared by Firmware Note: A NAK handshake is always generated at the first status stage token. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 549 SAM9X25 SAM9X25 Figure 33-12. Data OUT Followed by Status IN Transfer Host Sends the Last Device Sends a Status IN Data Payload to the Device to the Host USB Bus Token OUT Data OUT Token IN Data IN Packets Interrupt Pending...
  • Page 550 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) • ERR_FL_ISO: There was no data to transmit inside a microframe, so a ZLP is answered by default. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 551 SAM9X25 SAM9X25 • 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 (TX_BK_RDY) 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.
  • Page 552 Interrupt Pending RX_BK_RDY (UDPHS_EPTSTAx) Set by Hardware Cleared by Firmware, Data Payload Written in FIFO FIFO (DPR) Data OUT 1 Data OUT 1 Data OUT 2 Content Written by UDPHS Device Microcontroller Read Written by UDPHS Device SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 553 SAM9X25 SAM9X25 Figure 33-15. Data OUT Transfer for an Endpoint with Two Banks Microcontroller reads Data 1 in bank 0, Microcontroller reads Data 2 in bank 1, Host sends first data payload Host sends second data payload Host sends third data payload...
  • Page 554 RX_BK_RDY 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 RX_BK_RDY interrupt is generated and the BYTE_COUNT in UDPHS_EPTSTAx register is updated. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 555 SAM9X25 SAM9X25 33.6.9.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.
  • Page 556 STALL_SNT/ERR_CRISO/ERR_NB_TRA Error Interrupt RX_SETUP/ERR_FL_ISO Received SETUP/Error Flow Interrupt TX_PK_RD /ERR_TRANS TX Packet Read/Transaction Error Interrupt TX_COMPLT Transmitted IN Data Complete Interrupt RX_BK_RDY Received OUT Data Interrupt ERR_OVFLW Overflow Error Interrupt MDATA_RX MDATA Interrupt DATAX_RX DATAx Interrupt SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 557 SAM9X25 SAM9X25 Figure 33-19. UDPHS Interrupt Control Interface (UDPHS_IEN) Global IT mask Global IT sources DET_SUSPD MICRO_SOF INT_SOF USB Global ENDRESET IT Sources WAKE_UP ENDOFRSM UPSTR_RES (UDPHS_EPTCTLENBx) SHRT_PCKT EP mask (UDPHS_IEN) BUSY_BANK EPT_0 EP sources NAK_OUT husb2dev NAK_IN/ERR_FLUSH interrupt STALL_SNT/ERR_CRISO/ERR_NBTRA...
  • Page 558 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 559 SAM9X25 SAM9X25 33.6.13.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. Dis- abling the transceiver is automatically done. HSDM, HSDP, FSDP and FSDP lines are tied to GND pull-downs integrated in the hub downstream ports.
  • Page 560 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 561 SAM9X25 SAM9X25 33.6.14 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: • Test_J • Test_K • Test_Packet • Test_SEO_NAK (See Section 33.7.7 “UDPHS Test Register” on page 572 for definitions of each test mode.)
  • Page 562 3. The DMA channel index refers to the corresponding EP number. When no DMA channel is assigned to one EP, the associ- ated registers are reserved. This is the case for EP0, so DMA Channel 0 registers are reserved. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 563 SAM9X25 SAM9X25 33.7.1 UDPHS Control Register Name: UDPHS_CTRL Address: 0xF803C000 Access: Read-write – – – – – – – – – – – – – – – – – – – – PULLD_DIS REWAKEUP DETACH EN_UDPHS FADDR_EN DEV_ADDR • DEV_ADDR: UDPHS Address This field contains the default address (0) after power-up or UDPHS bus reset (read), or it is written with the value set by a SET_ADDRESS request received by the device firmware (write).
  • Page 564 (See DETACH description above.) DETACH PULLD_DIS Condition Pull up Pull down not recommended High impedance Pull up VBUS present state Pull down Pull down No VBUS High impedance High impedance VBUS present & state state software disconnect SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 565 SAM9X25 SAM9X25 33.7.2 UDPHS Frame Number Register Name: UDPHS_FNUM Address: 0xF803C004 Access: Read-only FNUM_ERR – – – – – – – – – – – – – – – – – FRAME_NUMBER FRAME_NUMBER MICRO_FRAME_NUM • MICRO_FRAME_NUM: Microframe Number Number of the received microframe (0 to 7) in one frame.This field is reset at the beginning of each new frame (1 ms).
  • Page 566 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 567 SAM9X25 SAM9X25 • 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.
  • Page 568 0 = cleared by setting the ENDRESET bit in UDPHS_CLRINT. 1 = set by hardware when an End Of Reset has been detected by the UDPHS controller. This triggers a UDPHS interrupt when the ENDRESET bit is set in UDPHS_IEN. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 569 SAM9X25 SAM9X25 • WAKE_UP: Wake Up CPU Interrupt 0 = cleared by setting the WAKE_UP bit in UDPHS_CLRINT. 1 = set by hardware when the UDPHS controller is in SUSPEND state and is re-activated by a filtered non-idle signal from the UDPHS line (not by an upstream resume).
  • Page 570 • ENDOFRSM: End Of Resume Interrupt Clear 0 = no effect. 1 = clear the ENDOFRSM bit in UDPHS_INTSTA. • UPSTR_RES: Upstream Resume Interrupt Clear 0 = no effect. 1 = clear the UPSTR_RES bit in UDPHS_INTSTA. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 571 SAM9X25 SAM9X25 33.7.6 UDPHS Endpoints Reset Register Name: UDPHS_EPTRST Address: 0xF803C01C Access: Write only – – – – – – – – – – – – – – – – – – – – – – – – – EPT_6...
  • Page 572 1 = set to repetitively transmit the packet stored in the current bank. This enables the testing of rise and fall times, eye pat- terns, jitter, and any other dynamic waveform specifications. • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 573 SAM9X25 SAM9X25 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.
  • Page 574 33.7.8 UDPHS Name1 Register Name: UDPHS_IPNAME1 Address: 0xF803C0F0 Access: Read-only IP_NAME1 IP_NAME1 IP_NAME1 IP_NAME1 • IP_NAME1 ASCII string “HUSB” SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 575 SAM9X25 SAM9X25 33.7.9 UDPHS Name2 Register Name: UDPHS_IPNAME2 Address: 0xF803C0F4 Access: Read-only IP_NAME2 IP_NAME2 IP_NAME2 IP_NAME2 • IP_NAME2 ASCII string “2DEV” 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 576 • DMA_FIFO_WORD_DEPTH: DMA FIFO Depth in Words 0 = if FIFO is 16 words deep. 1 = if FIFO is 1 word deep. 2 = if FIFO is 2 words deep. 15 = if FIFO is 15 words deep. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 577 SAM9X25 SAM9X25 • FIFO_MAX_SIZE: DPRAM Size 0 = if DPRAM is 128 bytes deep. 1 = if DPRAM is 256 bytes deep. 2 = if DPRAM is 512 bytes deep. 3 = if DPRAM is 1024 bytes deep. 4 = if DPRAM is 2048 bytes deep.
  • Page 578 For Control endpoints this bit has no effect and should be left at zero. • EPT_TYPE: Endpoint Type Set this field according to the endpoint type (see Section 33.6.5 ”Endpoint Configuration”). (Endpoint 0 should always be configured as control) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 579 SAM9X25 SAM9X25 Endpoint Type Value Name Description CTRL8 Control endpoint Isochronous endpoint BULK Bulk endpoint Interrupt endpoint • BK_NUMBER: Number of Banks Set this field according to the endpoint’s number of banks (see Section 33.6.5 ”Endpoint Configuration”). Number of Banks...
  • Page 580 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 581 SAM9X25 SAM9X25 • ERR_OVFLW: Overflow Error Interrupt Enable 0 = no effect. 1 = enable Overflow Error Interrupt. • RX_BK_RDY: Received OUT Data Interrupt Enable 0 = no effect. 1 = enable Received OUT Data Interrupt. • TX_COMPLT: Transmitted IN Data Complete Interrupt Enable 0 = no effect.
  • Page 582 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 583 SAM9X25 SAM9X25 • ERR_OVFLW: Overflow Error Interrupt Disable 0 = no effect. 1 = disable Overflow Error Interrupt. • RX_BK_RDY: Received OUT Data Interrupt Disable 0 = no effect. 1 = disable Received OUT Data Interrupt. • TX_COMPLT: Transmitted IN Data Complete Interrupt Disable 0 = no effect.
  • Page 584 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 585 SAM9X25 SAM9X25 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, ERR_FL_ISO...), then the request cancellation may happen at any time and may immediately stop the current DMA transfer.
  • Page 586 For IN endpoints: a Short Packet transmission is guaranteed upon end of the DMA Transfer, thus signaling a BULK or INTERRUPT end of transfer or 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 587 SAM9X25 SAM9X25 33.7.15 UDPHS Endpoint Set Status Register Name: UDPHS_EPTSETSTAx [x=0..6] Address: 0xF803C114 [0], 0xF803C134 [1], 0xF803C154 [2], 0xF803C174 [3], 0xF803C194 [4], 0xF803C1B4 [5], 0xF803C1D4 [6] Access: Write-only – – – – – – – – – – – –...
  • Page 588 • RX_SETUP/ERR_FL_ISO: Received SETUP/Error Flow Clear 0 = no effect. 1 = clear the RX_SETUP/ERR_FL_ISO flags of UDPHS_EPTSTAx. • STALL_SNT/ERR_NBTRA: Stall Sent/Number of Transaction Error Clear 0 = no effect. 1 = clear the STALL_SNT/ERR_NBTRA flags of UDPHS_EPTSTAx. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 589 SAM9X25 SAM9X25 • NAK_IN/ERR_FLUSH: NAKIN/Bank Flush Error Clear 0 = no effect. 1 = clear the NAK_IN/ERR_FLUSH flags of UDPHS_EPTSTAx. • NAK_OUT: NAKOUT Clear 0 = no effect. 1 = clear the NAK_OUT flag of UDPHS_EPTSTAx. 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 590 3. For High Bandwidth Isochronous Out endpoint, it is recommended to check the UDPHS_EPTSTAx/ERR_TRANS 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). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 591 SAM9X25 SAM9X25 • ERR_OVFLW: Overflow Error This bit is set by hardware when a new too-long packet is received. Example: If the user programs an endpoint 64 bytes wide and the host sends 128 bytes in an OUT transfer, then the Over- flow Error bit is set.
  • Page 592 – ERR_FLUSH: (for High Bandwidth Isochronous IN endpoints) This bit is set when flushing unsent banks at the end of a microframe. This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by EPT_CTL_DISx (disable endpoint). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 593 SAM9X25 SAM9X25 • NAK_OUT: NAK OUT This bit is set by hardware when a NAK handshake has been sent in response to an OUT or PING request from the Host. This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by EPT_CTL_DISx (disable endpoint).
  • Page 594 An OUT Short Packet is detected when the receive byte count is less than the configured UDPHS_EPTCFGx register EPT_Size. This bit is updated at the same time as the BYTE_COUNT field. This bit is reset by UDPHS_EPTRST register EPT_x (reset endpoint) and by UDPHS_EPTCTLDISx (disable endpoint). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 595 SAM9X25 SAM9X25 33.7.18 UDPHS DMA Channel Transfer Descriptor The DMA channel transfer descriptor is loaded from the memory. Be careful with the alignment of this buffer. The structure of the DMA channel transfer descriptor is defined by three parameters as...
  • Page 596 Channel 0 is not used. • NXT_DSC_ADD This field points to the next channel descriptor to be processed. This channel descriptor must be aligned, so bits 0 to 3 of the address must be equal to zero. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 597 SAM9X25 SAM9X25 33.7.20 UDPHS DMA Channel Address Register Name: UDPHS_DMAADDRESSx [x = 0..5] Address: 0xF803C304 [0], 0xF803C314 [1], 0xF803C324 [2], 0xF803C334 [3], 0xF803C344 [4], 0xF803C354 [5] Access: Read-write BUFF_ADD BUFF_ADD BUFF_ADD BUFF_ADD Note: Channel 0 is not used. • BUFF_ADD This field determines the AHB bus starting address of a DMA channel transfer.
  • Page 598 1 = the channel controller loads the next descriptor after the end of the current transfer, i.e. when the UDPHS_DMASTATUS/CHANN_ENB bit is reset. If the UDPHS_DMA CONTROL/CHANN_ENB bit is cleared, the next descriptor is immediately loaded upon transfer request. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 599 SAM9X25 SAM9X25 DMA Channel Control Command Summary LDNXT_DSC CHANN_ENB Description Stop now Run and stop at end of buffer Load next descriptor now Run and link at end of buffer • END_TR_EN: End of Transfer Enable (Control) Used for OUT transfers only.
  • Page 600 1. Bits [31:2] are only writable when issuing a channel Control Command other than “Stop Now”. 2. For reliability it is highly recommended to wait for both UDPHS_DMASTATUSx register CHAN_ACT and CHAN_ENB flags are at 0, thus ensuring the channel has been stopped before issuing a command other than “Stop Now”. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 601 SAM9X25 SAM9X25 33.7.22 UDPHS DMA Channel Status Register Name: UDPHS_DMASTATUSx [x = 0..5] Address: 0xF803C30C [0], 0xF803C31C [1], 0xF803C32C [2], 0xF803C33C [3], 0xF803C34C [4], 0xF803C35C [5] Access: Read-write BUFF_COUNT BUFF_COUNT – – – – – – – – – DESC_LDST...
  • Page 602 NT_DIS_DMA bit is used to disable the channel request) and the channel is no longer active CHANN_ACT flag is 0. Note: For OUT endpoints, if the receive buffer byte length (BUFF_LENGTH) has been defaulted to zero because the USB transfer length is unknown, the actual buffer byte length received will be 0x10000-BUFF_COUNT. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 603 SAM9X25 34. High Speed MultiMediaCard Interface (HSMCI) 34.1 Description The High Speed MultiMediaCard Interface (HSMCI) supports the MultiMedia Card (MMC) Spec- ification V4.3, the SD Memory Card Specification V2.0, the SDIO V2.0 specification and CE-ATA V1.1. The HSMCI includes a command register, response registers, data registers, timeout counters and error detection logic that automatically handle the transmission of commands and, when required, the reception of the associated responses and data with a limited processor overhead.
  • Page 604 34.3 Block Diagram Figure 34-1. Block Diagram APB Bridge DMAC MCCK MCCDA MCDA0 HSMCI Interface MCDA1 MCDA2 MCDA3 Interrupt Control HSMCI Interrupt SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 605 SAM9X25 34.4 Application Block Diagram Figure 34-2. Application Block Diagram Application Layer ex: File System, Audio, Security, etc. Physical Layer HSMCI Interface 2 3 4 5 6 2 3 4 5 6 9 1011 1213 8 SDCard 34.5 Pin Name List Table 34-1.
  • Page 606 PMC to enable the HSMCI clock. 34.6.3 Interrupt The HSMCI interface has an interrupt line connected to the Advanced Interrupt Controller (AIC). Handling the HSMCI interrupt requires programming the AIC before configuring the HSMCI. Table 34-3. Peripheral IDs Instance HSMCI0 HSMCI1 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 607 SAM9X25 34.7 Bus Topology Figure 34-3. High Speed MultiMedia Memory Card Bus Topology 2 3 4 5 6 9 1011 1213 8 The High Speed MultiMedia Card communication is based on a 13-pin serial bus interface. It has three communication lines and four supply lines.
  • Page 608 Data line Bit 2 MCDz2 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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 609 SAM9X25 Figure 34-6. SD Card Bus Connections with One Slot MCDA0 - MCDA3 MCCK SD CARD MCCDA 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.
  • Page 610 CMDNB (command number) 2 (CMD2) RSPTYP (response type) 2 (R2: 136 bits response) SPCMD (special command) 0 (not a special command) OPCMD (open drain command) MAXLAT (max latency for command to response) 0 (NID cycles ==> 5 cycles) SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 611 SAM9X25 Table 34-7. Fields and Values for HSMCI_CMDR Command Register Field Value TRCMD (transfer command) 0 (No transfer) TRDIR (transfer direction) X (available only in transfer command) TRTYP (transfer type) X (available only in transfer command) IOSPCMD (SDIO special command) 0 (not a special command) The HSMCI_ARGR contains the argument field of the command.
  • Page 612 Does the command involve a busy indication? RETURN OK Read HSMCI_SR NOTBUSY 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 MultiMe- dia Card specification). SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 613 SAM9X25 34.8.2 Data Transfer Operation The High Speed MultiMedia Card allows several read/write operations (single block, multiple blocks, stream, etc.). These kinds of transfer can be selected setting the Transfer Type (TRTYP) field in the HSMCI Command Register (HSMCI_CMDR). These operations can be done using the features of the DMA Controller.
  • Page 614 Number of words to read = Number of words to read -1 RETURN Notes: 1. It is assumed that this command has been correctly sent (see Figure 34-7). 2. This field is also accessible in the HSMCI Block Register (HSMCI_BLKR). SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 615 SAM9X25 34.8.4 Write Operation In write operation, the HSMCI Mode Register (HSMCI_MR) is used to define the padding value when writing non-multiple block size. If the bit PADV is 0, then 0x00 value is used when padding data, otherwise 0xFF is used.
  • Page 616 Number of words to write = Number of words to write -1 RETURN Note: 1. It is assumed that this command has been correctly sent (see Figure 34-7). 2. This field is also accessible in the HSMCI Block Register (HSMCI_BLKR). SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 617 SAM9X25 The following flowchart (Figure 34-10) shows how to manage read multiple block and write mul- tiple 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).
  • Page 618 Program DMAC_CFGx register for channel x with the following field’s 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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 619 SAM9X25 Enable Channel x, writing one to DMAC_CHER[x]. The DMAC is ready and waiting for request. 7. Wait for XFRDONE in HSMCI_SR register. 34.8.6 READ_SINGLE_BLOCK Operation using DMA Controller 34.8.6.1 Block Length is Multiple of 4 1. Wait until the current command execution has successfully completed.
  • Page 620 –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. 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 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 621 SAM9X25 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. 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.
  • Page 622 – DMAEN is set to true to enable DMAC hardware handshaking in the HSMCI. This bit was previously set to false. 5. Issue a WRITE_MULTIPLE_BLOCK command. 6. 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). SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 623 SAM9X25 a. Read the channel Register to choose an available (disabled) channel. b. Clear any pending interrupts on the channel from the previous DMAC transfer by reading the DMAC_EBCISR register. c. Program a List of descriptors. d. The LLI(n).DMAC_SADDRx memory location for channel x must be set to the loca- tion of the source data.
  • Page 624 –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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 625 SAM9X25 h. Program LLI_W(n).DMAC_CFGx register for channel x with the following field’s 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.
  • Page 626 DMA Controller is able to prefetch data and write HSMCI simultaneously. p. Program LLI_B(n).DMAC_CFGx memory location for channel x with the following field’s values: – FIFOCFG defines the watermark of the DMAC channel FIFO. – SRC_H2SEL is set to true to enable hardware handshaking on the destination. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 627 SAM9X25 – SRC_PER is programmed with the hardware handshaking ID of the targeted HSMCI Host Controller q. 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. Program DMAC_CTRLBx register for channel x with 0, its content is updated with the LLI Fetch operation.
  • Page 628 The SD/SDIO Card communication is based on a 9-pin interface (Clock, Command, 4 x Data and 3 x Power lines). The communication protocol is defined as a part of this specification. The main difference between the SD/SDIO Card and the High Speed MultiMedia Card is the initial- ization process. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 629 SAM9X25 The SD/SDIO Card Register (HSMCI_SDCR) allows selection of the Card Slot and the data bus width. The SD/SDIO Card bus allows dynamic configuration of the number of data lines. After power up, by default, the SD/SDIO Card uses only DAT0 for data transfer. After initialization, the host can change the bus width (number of active data lines).
  • Page 630 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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 631 SAM9X25 34.11 HSMCI Boot Operation Mode 34.11.1 In boot operation mode, the processor can read boot data from the slave (MMC device) by keeping the CMD line low after power-on before issuing CMD1. The data can be read from either the boot area or user area, depending on register setting.
  • Page 632 The CMDRDY flag is released 8 tbit after the end of the card response. CMDRDY flag D0 is tied by the card D0 is released 1st Block Last Block Data bus - D0 1st Block Last Block Not busy flag XFRDONE flag SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 633 SAM9X25 34.13 Write Protection Registers To prevent any single software error that may corrupt HSMCI behavior, the entire HSMCI address space from address offset 0x000 to 0x00FC can be write-protected by setting the WPEN bit in the “HSMCI Write Protect Mode Register”...
  • Page 634 HSMCI_FIFO0 Read-write 0x5FC FIFO Memory Aperture255 HSMCI_FIFO255 Read-write 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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 635 SAM9X25 34.14.1 HSMCI Control Register Name: HSMCI_CR Address: 0xF0008000 (0), 0xF000C000 (1) Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – – SWRST –...
  • Page 636 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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 637 SAM9X25 • 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.
  • Page 638 DTOCYC x 1024 4096 DTOCYC x 4096 65536 DTOCYC x 65536 1048576 DTOCYC x 1048576 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) raises. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 639 SAM9X25 34.14.4 HSMCI SDCard/SDIO Register Name: HSMCI_SDCR Address: 0xF000800C (0), 0xF000C00C (1) Access: Read-write – – – – – – – – – – – – – – – – – – – – – – – – SDCBUS –...
  • Page 640 34.14.5 HSMCI Argument Register Name: HSMCI_ARGR Address: 0xF0008010 (0), 0xF000C010 (1) Access: Read-write • ARG: Command Argument SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 641 SAM9X25 34.14.6 HSMCI Command Register Name: HSMCI_CMDR Address: 0xF0008014 (0), 0xF000C014 (1) Access: Write-only – – – – BOOT_ACK ATACS IOSPCMD – – TRTYP TRDIR TRCMD – – – MAXLAT OPDCMD SPCMD RSPTYP CMDNB This register is write-protected while CMDRDY is 0 in HSMCI_SR. If an Interrupt command is sent, this register is only writeable by an interrupt response (field SPCMD).
  • Page 642 SINGLE MMC/SDCard Single Block MULTIPLE MMC/SDCard Multiple Block STREAM MMC Stream BYTE SDIO Byte BLOCK SDIO Block • IOSPCMD: SDIO Special Command Value Name Description Not an SDIO Special Command SUSPEND SDIO Suspend Command RESUME SDIO Resume Command SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 643 SAM9X25 • ATACS: ATA with Command Completion Signal 0 (NORMAL) = Normal operation mode. 1 (COMPLETION) = This bit indicates that a completion signal is expected within a programmed amount of time (HSMCI_CSTOR). • BOOT_ACK: Boot Operation Acknowledge. The master can choose to receive the boot acknowledge from the slave when a Boot Request command is issued. When set to one this field indicates that a Boot acknowledge is expected within a programmable amount of time defined with DTOMUL and DTOCYC fields located in the HSMCI_DTOR register.
  • Page 644 This field determines the size of the data block. This field is also accessible in the HSMCI Mode Register (HSMCI_MR). Bits 16 and 17 must be set to 0 if FBYTE is disabled. Note: In SDIO Byte mode, BLKLEN field is not used. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 645 SAM9X25 34.14.8 HSMCI Completion Signal Timeout Register Name: HSMCI_CSTOR Address: 0xF000801C (0), 0xF000C01C (1) Access: Read-write – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 646 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. 34.14.10 HSMCI Receive Data Register Name: HSMCI_RDR Address: 0xF0008030 (0), 0xF000C030 (1) Access: Read-only DATA DATA DATA DATA • DATA: Data to Read SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 647 SAM9X25 34.14.11 HSMCI Transmit Data Register Name: HSMCI_TDR Address: 0xF0008034 (0), 0xF000C034 (1) Access: Write-only DATA DATA DATA DATA • DATA: Data to Write 11054A–ATARM–27-Jul-11...
  • Page 648 (DAT0) to LOW. The card stops pulling down the data line as soon as at least one receive buffer for the defined data transfer block length becomes free. The NOTBUSY flag allows to deal with these different states. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 649 SAM9X25 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.
  • Page 650 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. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 651 SAM9X25 • 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.
  • Page 652 • 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 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 653 SAM9X25 • DMADONE: DMA Transfer completed Interrupt Enable • 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.
  • Page 654 • 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 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 655 SAM9X25 • 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.
  • Page 656 • 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 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 657 SAM9X25 • 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.
  • Page 658 0: BLKLEN bytes are moved from the Memory Card to the system memory, two DMA descriptors are used when the trans- fer size is not a multiple of 4. 1: Ceiling(BLKLEN/4) * 4 bytes are moved from the Memory Card to the system memory, only one DMA descriptor is used. SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 659 SAM9X25 34.14.17 HSMCI Configuration Register Name: HSMCI_CFG Address: 0xF0008054 (0), 0xF000C054 (1) Access: Read-write – – – – – – – – – – – – – – – – – LSYNC – – – HSMODE – – – FERRCTRL –...
  • Page 660 “HSMCI Data Timeout Register” on page 638 • “HSMCI SDCard/SDIO Register” on page 639 • “HSMCI Completion Signal Timeout Register” on page 645 • “HSMCI DMA Configuration Register” on page 658 • “HSMCI Configuration Register” on page 659 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 661 SAM9X25 34.14.19 HSMCI Write Protect Status Register Name: HSMCI_WPSR Address: 0xF00080E8 (0), 0xF000C0E8 (1) Access: Read-only – – – – – – – – WP_VSRC WP_VSRC – – – – WP_VS • WP_VS: Write Protection Violation Status Value Name Description...
  • Page 662 34.14.20 HSMCI FIFOx Memory Aperture Name: HSMCI_FIFOx[x=0..255] Address: 0xF0008200 (0), 0xF000C200 (1) Access: Read-write DATA DATA DATA DATA • DATA: Data to Read or Data to Write SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 663 SAM9X25 SAM9X25 35. Serial Peripheral Interface (SPI) 35.1 Description The Serial Peripheral Interface (SPI) circuit is a synchronous serial data link that provides com- munication with external devices in Master or Slave Mode. It also enables communication between processors if an external processor is connected to the system.
  • Page 664 35.3 Block Diagram Figure 35-1. Block Diagram DMA Ch. AHB Matrix Peripheral Bridge SPCK MISO MOSI SPI Interface NPCS0/NSS NPCS1 NPCS2 Interrupt Control NPCS3 SPI Interrupt SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 665 SAM9X25 SAM9X25 35.4 Application Block Diagram Figure 35-2. Application Block Diagram: Single Master/Multiple Slave Implementation SPCK SPCK MISO MISO Slave 0 MOSI MOSI SPI Master NPCS0 SPCK NPCS1 MISO NPCS2 Slave 1 MOSI NPCS3 SPCK MISO Slave 2 MOSI 35.5 Signal Description Table 35-1.
  • Page 666 SPI Bus Protocol Mode SPI Mode CPOL NCPHA Shift SPCK Edge Capture SPCK Edge SPCK Inactive Level Falling Rising Rising Falling Rising Falling High Falling Rising High Figure 35-3 Figure 35-4 show examples of data transfers. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 667 SAM9X25 SAM9X25 Figure 35-3. SPI Transfer Format (NCPHA = 1, 8 bits per transfer) SPCK cycle (for reference) SPCK (CPOL = 0) SPCK (CPOL = 1) MOSI (from master) MISO (from slave) (to slave) * Not defined, but normally MSB of previous character received.
  • Page 668 SPI_RDR. The user has to read the status register to clear the OVRES bit. Figure 35-5, shows a block diagram of the SPI when operating in Master Mode. Figure 35-6 on page 670 shows a flow chart describing how transfers are handled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 669 SAM9X25 SAM9X25 35.7.3.1 Master Mode Block Diagram Figure 35-5. Master Mode Block Diagram SPI_CSR0..3 SCBR Baud Rate Generator SPCK Clock SPI_CSR0..3 SPI_RDR RDRF BITS OVRES NCPHA CPOL Shift Register MOSI MISO SPI_TDR TDRE SPI_CSR0..3 SPI_RDR CSAAT NPCS3 PCSDEC SPI_MR Current...
  • Page 670 Delay DLYBCS NPCS = SPI_MR(PCS), NPCS = SPI_TDR(PCS) SPI_TDR(PCS) Delay DLYBS Serializer = SPI_TDR(TD) TDRE = 1 Data Transfer SPI_RDR(RD) = Serializer RDRF = 1 Delay DLYBCT TDRE ? CSAAT ? NPCS = 0xF Delay DLYBCS SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 671 SAM9X25 SAM9X25 Figure 35-7 shows Transmit Data Register Empty (TDRE), Receive Data Register (RDRF) and Transmission Register Empty (TXEMPTY) status flags behavior within the SPI_SR (Status Reg- ister) during an 8-bit data transfer in fixed mode and no Peripheral Data Controller involved.
  • Page 672 TXEMPTY flag, then write SPIDIS into the SPI_CR register (this will not change the configu- ration 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 673 SAM9X25 SAM9X25 35.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.
  • Page 674 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 675 SAM9X25 SAM9X25 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.
  • Page 676 SPI when operating in Slave Mode. Figure 35-11. Slave Mode Functional Bloc Diagram SPCK Clock SPIEN SPIENS SPIDIS SPI_CSR0 SPI_RDR RDRF BITS OVRES NCPHA CPOL Shift Register MISO MOSI SPI_TDR TDRE SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 677 SAM9X25 SAM9X25 35.7.5 Write Protected Registers To prevent any single software error that may corrupt SPI behavior, the registers listed below can be write-protected by setting the SPIWPEN bit in the SPI Write Protection Mode Register (SPI_WPMR). If a write access in a write-protected register is detected, then the SPIWPVS flag in the SPI Write Protection Status Register (SPI_WPSR) is set and the field SPIWPVSRC indicates in which register the write access has been attempted.
  • Page 678 Chip Select Register 3 SPI_CSR3 Read-write 0x4C - 0xE0 Reserved – – – 0xE4 Write Protection Control Register SPI_WPMR Read-write 0xE8 Write Protection Status Register SPI_WPSR Read-only 0x00E8 - 0x00F8 Reserved – – – 0x00FC Reserved – – – SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 679 SAM9X25 SAM9X25 35.8.1 SPI Control Register Name: SPI_CR Address: 0xF0000000 (0), 0xF0004000 (1) Access: Write-only – – – – – – – LASTXFER – – – – – – – – – – – – – – – – SWRST –...
  • Page 680 1 = In Master Mode, a transfer can start only if the Receive Data Register is empty, i.e. does not contain any unread data. This mode prevents overrun error in reception. • LLB: Local Loopback Enable 0 = Local loopback path disabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 681 SAM9X25 SAM9X25 1 = Local loopback path enabled LLB controls the local loopback on the data serializer for testing in Master Mode only. (MISO is internally connected on MOSI.) • PCS: Peripheral Chip Select This field is only used if Fixed Peripheral Select is active (PS = 0).
  • Page 682 In Master Mode only, these bits indicate the value on the NPCS pins at the end of a transfer. Otherwise, these bits read zero. Note: When using variable peripheral select mode (PS = 1 in SPI_MR) it is mandatory to also set the WDRBT field to 1 if the SPI_RDR PCS field is to be processed. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 683 SAM9X25 SAM9X25 35.8.4 SPI Transmit Data Register Name: SPI_TDR Address: 0xF000000C (0), 0xF000400C (1) Access: Write-only – – – – – – – LASTXFER – – – – • TD: Transmit Data Data to be transmitted by the SPI Interface is stored in this register. Information to be transmitted must be written to the transmit data register in a right-justified format.
  • Page 684 1 = SPI_TDR and internal shifter are empty. If a transfer delay has been defined, TXEMPTY is set after the completion of such delay. • SPIENS: SPI Enable Status 0 = SPI is disabled. 1 = SPI is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 685 SAM9X25 SAM9X25 35.8.6 SPI Interrupt Enable Register Name: SPI_IER Address: 0xF0000014 (0), 0xF0004014 (1) Access: Write-only – – – – – – – – – – – – – – – – – – – – – – TXEMPTY NSSR –...
  • Page 686 • 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 687 SAM9X25 SAM9X25 35.8.8 SPI Interrupt Mask Register Name: SPI_IMR Address: 0xF000001C (0), 0xF000401C (1) Access: Read-only – – – – – – – – – – – – – – – – – – – – – – TXEMPTY NSSR –...
  • Page 688 Description 8_BIT 8 bits for transfer 9_BIT 9 bits for transfer 10_BIT 10 bits for transfer 11_BIT 11 bits for transfer 12_BIT 12 bits for transfer 13_BIT 13 bits for transfer 14_BIT 14 bits for transfer SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 689 SAM9X25 SAM9X25 Value Name Description 15_BIT 15 bits for transfer 16_BIT 16 bits for transfer – Reserved – Reserved – Reserved – Reserved – Reserved – Reserved – Reserved • SCBR: Serial Clock Baud Rate In Master Mode, the SPI Interface uses a modulus counter to derive the SPCK baud rate from the Master Clock MCK. The Baud rate is selected by writing a value from 1 to 255 in the SCBR field.
  • Page 690 • SPIWPKEY: SPI Write Protection Key Password If a value is written in SPIWPEN, the value is taken into account only if SPIWPKEY is written with “SPI” (SPI written in ASCII Code, ie 0x535049 in hexadecimal). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 691 SAM9X25 SAM9X25 35.8.11 SPI Write Protection Status Register Name: SPI_WPSR Address: 0xF00000E8 (0), 0xF00040E8 (1) Access: Read-only – – – – – – – – – – – – – – – – SPIWPVSRC – – – – – SPIWPVS •...
  • Page 692 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 693 SAM9X25 SAM9X25 36. Timer Counter (TC) 36.1 Embedded Characteristics • Three 32-bit Timer Counter Channels • A Wide Range of Functions Including: – Frequency Measurement – Event Counting – Interval Measurement – Pulse Generation – Delay Timing – Pulse Width Modulation –...
  • Page 694 XC0, XC1, XC2 External Clock Inputs Capture Mode: Timer Counter Input TIOA Waveform Mode: Timer Counter Output Channel Signal Capture Mode: Timer Counter Input TIOB Waveform Mode: Timer Counter Input/Output Interrupt Signal Output SYNC Synchronization Input Signal SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 695 SAM9X25 SAM9X25 36.4 Pin Name List Table 36-3. TC pin list Pin Name Description Type TCLK0-TCLK2 External Clock Input Input TIOA0-TIOA2 I/O Line A TIOB0-TIOB2 I/O Line B 36.5 Product Dependencies 36.5.1 I/O Lines The pins used for interfacing the compliant external devices may be multiplexed with PIO lines.
  • Page 696 XC2 = TCLK2 TIOB0 SYNC TC1XC1S Timer/Counter Channel 1 TIOA1 TCLK1 XC0 = TCLK0 TIOA0 TIOA2 XC2 = TCLK2 TIOB1 SYNC Timer/Counter TC2XC2S Channel 2 XC0 = TCLK0 TIOA2 TCLK2 XC1 = TCLK1 TIOA0 TIOB2 TIOA1 SYNC SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 697 SAM9X25 SAM9X25 Figure 36-3. Clock Selection TCCLKS CLKI TIMER_CLOCK1 Synchronous Edge Detection TIMER_CLOCK2 TIMER_CLOCK3 Selected TIMER_CLOCK4 Clock TIMER_CLOCK5 BURST 36.6.4 Clock Control The clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. See Figure 36-4.
  • Page 698 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 699 SAM9X25 SAM9X25 If an external trigger is used, the duration of the pulses must be longer than the master clock period in order to be detected. 36.6.7 Capture Operating Mode This mode is entered by clearing the WAVE parameter in TC_CMR (Channel Mode Register).
  • Page 700 Figure 36-5. Capture Mode CPCS LOVRS COVFS LDRBS LDRAS ETRGS TC1_SR TC1_IMR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 701 SAM9X25 SAM9X25 36.6.10 Waveform Operating Mode Waveform operating mode is entered by setting the WAVE parameter in TC_CMR (Channel Mode Register). In Waveform Operating Mode the TC channel generates 1 or 2 PWM signals with the same fre- quency and independently programmable duty cycles, or generates different types of one-shot or repetitive pulses.
  • Page 702 Figure 36-6. Waveform Mode CPCS CPBS CPAS COVFS ETRGS TC1_SR TC1_IMR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 703 SAM9X25 SAM9X25 36.6.11.1 WAVSEL = 00 When WAVSEL = 00, the value of TC_CV is incremented from 0 to 0xFFFF. Once 0xFFFF has been reached, the value of TC_CV is reset. Incrementation of TC_CV starts again and the cycle continues. See Figure 36-7.
  • Page 704 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 36-9. WAVSEL = 10 Without Trigger Counter Value 0xFFFF Counter cleared by compare match with RC Time Waveform Examples TIOB TIOA SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 705 SAM9X25 SAM9X25 Figure 36-10. WAVSEL = 10 With Trigger Counter Value 0xFFFF Counter cleared by compare match with RC Counter cleared by trigger Time Waveform Examples TIOB TIOA 36.6.11.3 WAVSEL = 01 When WAVSEL = 01, the value of TC_CV is incremented from 0 to 0xFFFF. Once 0xFFFF is reached, the value of TC_CV is decremented to 0, then re-incremented to 0xFFFF and so on.
  • Page 706 TC_CV is incrementing, TC_CV then decrements. If a trigger is received while TC_CV is decrementing, TC_CV then increments. See Figure 36-14. RC Compare can stop the counter clock (CPCSTOP = 1) and/or disable the counter clock (CPCDIS = 1). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 707 SAM9X25 SAM9X25 Figure 36-13. WAVSEL = 11 Without Trigger Counter Value 0xFFFF Counter decremented by compare match with RC Time Waveform Examples TIOB TIOA Figure 36-14. WAVSEL = 11 With Trigger Counter Value 0xFFFF Counter decremented by compare match with RC...
  • Page 708 The following events control TIOA and TIOB: software trigger, external event and RC compare. RA compare controls TIOA and RB compare controls TIOB. Each of these events can be pro- grammed to set, clear or toggle the output as defined in the corresponding parameter in TC_CMR. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 709 SAM9X25 SAM9X25 36.7 Timer Counter (TC) User Interface Table 36-4. Register Mapping Offset Register Name Access Reset 0x00 + channel * 0x40 + 0x00 Channel Control Register TC_CCR Write-only – 0x00 + channel * 0x40 + 0x04 Channel Mode Register...
  • Page 710 – – – – – – – – – – SYNC • SYNC: Synchro Command 0 = no effect. 1 = asserts the SYNC signal which generates a software trigger simultaneously for each of the channels. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 711 SAM9X25 SAM9X25 36.7.2 TC Block Mode Register Name: TC_BMR Address: 0xF80080C4 (0), 0xF800C0C4 (1) Access: Read-write – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 712 • CLKDIS: Counter Clock Disable Command 0 = no effect. 1 = disables the clock. • SWTRG: Software Trigger Command 0 = no effect. 1 = a software trigger is performed: the counter is reset and the clock is started. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 713 SAM9X25 SAM9X25 36.7.4 TC Channel Mode Register: Capture Mode Name: TC_CMRx [x=0..2] (WAVE = 0) Address: 0xF8008004 (0)[0], 0xF8008044 (0)[1], 0xF8008084 (0)[2], 0xF800C004 (1)[0], 0xF800C044 (1)[1], 0xF800C084 (1)[2] Access: Read-write – – – – – – – – – –...
  • Page 714 Rising edge of TIOA FALLING Falling edge of TIOA EDGE Each edge of TIOA • LDRB: RB Loading Selection Value Name Description NONE None RISING Rising edge of TIOA FALLING Falling edge of TIOA EDGE Each edge of TIOA SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 715 SAM9X25 SAM9X25 36.7.5 TC Channel Mode Register: Waveform Mode Name: TC_CMRx [x=0..2] (WAVE = 1) Address: 0xF8008004 (0)[0], 0xF8008044 (0)[1], 0xF8008084 (0)[2], 0xF800C004 (1)[0], 0xF800C044 (1)[1], 0xF800C084 (1)[2] Access: Read-write BSWTRG BEEVT BCPC BCPB ASWTRG AEEVT ACPC ACPA WAVE WAVSEL...
  • Page 716 UP_RC UP mode with automatic trigger on RC Compare UPDOWN_RC UPDOWN mode with automatic trigger on RC Compare • WAVE 0 = Waveform Mode is disabled (Capture Mode is enabled). 1 = Waveform Mode is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 717 SAM9X25 SAM9X25 • ACPA: RA Compare Effect on TIOA Value Name Description NONE None CLEAR Clear TOGGLE Toggle • ACPC: RC Compare Effect on TIOA Value Name Description NONE None CLEAR Clear TOGGLE Toggle • AEEVT: External Event Effect on TIOA...
  • Page 718 CLEAR Clear TOGGLE Toggle • BEEVT: External Event Effect on TIOB Value Name Description NONE None CLEAR Clear TOGGLE Toggle • BSWTRG: Software Trigger Effect on TIOB Value Name Description NONE None CLEAR Clear TOGGLE Toggle SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 719 SAM9X25 SAM9X25 36.7.6 TC Counter Value Register Name: TC_CVx [x=0..2] Address: 0xF8008010 (0)[0], 0xF8008050 (0)[1], 0xF8008090 (0)[2], 0xF800C010 (1)[0], 0xF800C050 (1)[1], 0xF800C090 (1)[2] Access: Read-only • CV: Counter Value CV contains the counter value in real time. 36.7.7 TC Register A Name: TC_RAx [x=0..2]...
  • Page 720 RB contains the Register B value in real time. 36.7.9 TC Register C Name: TC_RCx [x=0..2] Address: 0xF800801C (0)[0], 0xF800805C (0)[1], 0xF800809C (0)[2], 0xF800C01C (1)[0], 0xF800C05C (1)[1], 0xF800C09C (1)[2] Access: Read-write • RC: Register C RC contains the Register C value in real time. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 721 SAM9X25 SAM9X25 36.7.10 TC Status Register Name: TC_SRx [x=0..2] Address: 0xF8008020 (0)[0], 0xF8008060 (0)[1], 0xF80080A0 (0)[2], 0xF800C020 (1)[0], 0xF800C060 (1)[1], 0xF800C0A0 (1)[2] Access: Read-only – – – – – – – – – – – – – MTIOB MTIOA CLKSTA –...
  • Page 722 0 = TIOB is low. If WAVE = 0, this means that TIOB pin is low. If WAVE = 1, this means that TIOB is driven low. 1 = TIOB is high. If WAVE = 0, this means that TIOB pin is high. If WAVE = 1, this means that TIOB is driven high. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 723 SAM9X25 SAM9X25 36.7.11 TC Interrupt Enable Register Name: TC_IERx [x=0..2] Address: 0xF8008024 (0)[0], 0xF8008064 (0)[1], 0xF80080A4 (0)[2], 0xF800C024 (1)[0], 0xF800C064 (1)[1], 0xF800C0A4 (1)[2] Access: Write-only – – – – – – – – – – – – – – –...
  • Page 724 • 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). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 725 SAM9X25 SAM9X25 • ETRGS: External Trigger 0 = no effect. 1 = disables the External Trigger Interrupt. 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 726 0 = the Load RB Interrupt is disabled. 1 = the Load RB Interrupt is enabled. • ETRGS: External Trigger 0 = the External Trigger Interrupt is disabled. 1 = the External Trigger Interrupt is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 727 SAM9X25 SAM9X25 37. Pulse Width Modulation Controller (PWM) 37.1 Description The PWM macrocell controls several channels independently. Each channel controls one square output waveform. Characteristics of the output waveform such as period, duty-cycle and polarity are configurable through the user interface. Each channel selects and uses one of the clocks provided by the clock generator.
  • Page 728 APB Interface Interrupt Generator Interrupt Controller 37.4 I/O Lines Description Each channel outputs one waveform on one external I/O line. Table 37-1. I/O Line Description Name Description Type PWMx PWM Waveform Output for channel x Output SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 729 SAM9X25 SAM9X25 37.5 Product Dependencies 37.5.1 I/O Lines The pins used for interfacing the PWM may be multiplexed with PIO lines. The programmer must first program the PIO controller to assign the desired PWM pins to their peripheral function. If I/O lines of the PWM are not used by the application, they can be used for other purposes by the PIO controller.
  • Page 730 The PWM macrocell master clock, MCK, is divided in the clock generator module to provide dif- ferent clocks available for all channels. Each channel can independently select one of the divided clocks. The clock generator is divided in three blocks: SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 731 SAM9X25 SAM9X25 – a modulo n counter which provides 11 clocks: F /2, F /4, F /16, F /32, F /64, F /128, F /256, F /512, F /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.
  • Page 732 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 733 SAM9X25 SAM9X25 Figure 37-4. Non Overlapped Center Aligned Waveforms No overlap PWM0 PWM1 Period Note: 1. See Figure 37-5 on page 734 for a detailed description of center aligned waveforms. When center aligned, the internal channel counter increases up to CPRD and.decreases down to 0.
  • Page 734 Period Output Waveform PWMx CPOL(PWM_CMRx) = 0 Output Waveform PWMx CPOL(PWM_CMRx) = 1 CHIDx(PWM_ISR) Left Aligned CALG(PWM_CMRx) = 0 PWM_CCNTx CPRD(PWM_CPRDx) CDTY(PWM_CDTYx) Period Output Waveform PWMx CPOL(PWM_CMRx) = 0 Output Waveform PWMx CPOL(PWM_CMRx) = 1 CHIDx(PWM_ISR) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 735 SAM9X25 SAM9X25 37.6.3 PWM Controller Operations 37.6.3.1 Initialization Before enabling the output channel, this channel must have been configured by the software application: • Configuration of the clock generator if DIVA and DIVB are required • Selection of the clock for each channel (CPRE field in the PWM_CMRx register) •...
  • Page 736 Writing in CPD field Update of the Period or Duty Cycle CHIDx = 1 Writing in PWM_CUPDx The last write has been taken into account Note: Polarity and alignment can be modified only when the channel is disabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 737 SAM9X25 SAM9X25 37.6.3.4 Interrupts Depending on the interrupt mask in the PWM_IMR register, an interrupt is generated at the end of the corresponding channel period. The interrupt remains active until a read operation in the PWM_ISR register occurs. A channel interrupt is enabled by setting the corresponding bit in the PWM_IER register. A chan- nel interrupt is disabled by setting the corresponding bit in the PWM_IDR register.
  • Page 738 0x200 + ch_num * 0x20 + 0x0C PWM Channel Counter Register PWM_CCNT Read-only 0x200 + ch_num * 0x20 + 0x10 PWM Channel Update Register PWM_CUPD Write-only Notes: 1. Some registers are indexed with “ch_num” index ranging from 0 to 3. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 739 SAM9X25 SAM9X25 37.7.1 PWM Mode Register Name: PWM_MR Address: 0xF8034000 Access: Read-write – – – – PREB DIVB – – – – PREA DIVA • DIVA, DIVB: CLKA, CLKB Divide Factor Value Name Description CLK_OFF CLKA, CLKB clock is turned off...
  • Page 740 – – – – – – – – – – – – – – – – CHID3 CHID2 CHID1 CHID0 • CHIDx: Channel ID 0 = No effect. 1 = Disable PWM output for channel x. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 741 SAM9X25 SAM9X25 37.7.4 PWM Status Register Name: PWM_SR Address: 0xF803400C Access: Read-only – – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 742 – – – – – – – – – – – – – – – – CHID3 CHID2 CHID1 CHID0 • CHIDx: Channel ID. 0 = No effect. 1 = Disable interrupt for PWM channel x. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 743 SAM9X25 SAM9X25 37.7.7 PWM Interrupt Mask Register Name: PWM_IMR Address: 0xF8034018 Access: Read-only – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 744 0 = No new channel period has been achieved since the last read of the PWM_ISR register. 1 = At least one new channel period has been achieved since the last read of the PWM_ISR register. Note: Reading PWM_ISR automatically clears CHIDx flags. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 745 SAM9X25 SAM9X25 37.7.9 PWM Channel Mode Register Name: PWM_CMR[0..3] Address: 0xF8034200 [0], 0xF8034220 [1], 0xF8034240 [2], 0xF8034260 [3] Access: Read-write – – – – – – – – – – – – – – – – – – – –...
  • Page 746 • CPD: Channel Update Period 0 = Writing to the PWM_CUPDx will modify the duty cycle at the next period start event. 1 = Writing to the PWM_CUPDx will modify the period at the next period start event. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 747 SAM9X25 SAM9X25 37.7.10 PWM Channel Duty Cycle Register Name: PWM_CDTY[0..3] Address: 0xF8034204 [0], 0xF8034224 [1], 0xF8034244 [2], 0xF8034264 [3] Access: Read-write CDTY CDTY CDTY CDTY Only the first 16 bits (internal channel counter size) are significant. • CDTY: Channel Duty Cycle Defines the waveform duty cycle.
  • Page 748 × × CPRD ------------------------------------------ - – By using a Master Clock divided by one of both DIVA or DIVB divider, the formula becomes, respectively: × × × × CPRD DIVA CPRD DIVB ----------------------------------------------------- - ----------------------------------------------------- - SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 749 Internal counter value. This register is reset when: • the channel is enabled (writing CHIDx in the PWM_ENA register). • the counter reaches CPRD value defined in the PWM_CPRDx register if the waveform is left aligned. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 750 When CPD field of PWM_CMRx register = 0, the duty-cycle (CDTY of PWM_CDTYx register) is updated with the CUPD value at the beginning of the next period. When CPD field of PWM_CMRx register = 1, the period (CPRD of PWM_CPRDx register) is updated with the CUPD value at the beginning of the next period. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 751 400 Kbits per second, based on a byte-oriented transfer format. It can be used with any Atmel Two-wire Interface bus Serial EEPROM and I²C compatible device such as Real Time Clock (RTC), Dot Matrix/Graphic LCD Controllers and Temperature Sensor, to name but a few.
  • Page 752 Table 38-2. Abbreviations Abbreviation Description Two-wire Interface Acknowledge Non Acknowledge Stop Start Repeated Start SADR Slave Address Any address except SADR Read Write 38.4 Block Diagram Figure 38-1. Block Diagram APB Bridge TWCK Two-wire Interface Interrupt SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 753 SAM9X25 SAM9X25 38.5 Application Block Diagram Figure 38-2. Application Block Diagram Host with TWCK Interface Atmel TWI I²C LCD I²C Temp. I²C RTC Serial EEPROM Controller Sensor Slave 1 Slave 2 Slave 3 Slave 4 Rp: Pull up value as given by the I²C Standard 38.5.1...
  • Page 754 • A high-to-low transition on the TWD line while TWCK is high defines the START condition. • A low-to-high transition on the TWD line while TWCK is high defines a STOP condition. Figure 38-3. START and STOP Conditions TWCK Start Stop Figure 38-4. Transfer Format TWCK Start Address Data Data Stop SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 755 SAM9X25 SAM9X25 38.7.2 Modes of Operation The TWI has six modes of operations: • Master transmitter mode • Master receiver mode • Multi-master transmitter mode • Multi-master receiver mode • Slave transmitter mode • Slave receiver mode These modes are described in the following chapters.
  • Page 756 TWI_THR or until a STOP command is performed. Figure 38-6, Figure 38-7, and Figure 38-8. Figure 38-6. Master Write with One Data Byte STOP Command sent (write in TWI_CR) DADR DATA TXCOMP TXRDY Write THR (DATA) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 757 SAM9X25 SAM9X25 Figure 38-7. Master Write with Multiple Data Bytes STOP command performed (by writing in the TWI_CR) 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 38-8.
  • Page 758 “repeated start” (Sr) in I2C fully-compatible devices. See Figure 38-12. See Figure 38-11 Figure 38-13 for Master Write operation with internal address. The three internal address bytes are configurable through the Master Mode register (TWI_MMR). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 759 SAM9X25 SAM9X25 If the slave device supports only a 7-bit address, i.e. no internal address, IADRSZ must be set to In the figures below the following abbreviations are used: • S Start • Sr Repeated Start • P Stop • W Write •...
  • Page 760 3. Program TWI_IADR with b3 b4 b5 b6 b7 b8 b9 b10 (b10 is the LSB of the 10-bit address) Figure 38-13 below shows a byte write to an Atmel AT24LC512 EEPROM. This demonstrates the use of internal addresses to access the device. Figure 38-13. Internal Address Usage...
  • Page 761 SAM9X25 SAM9X25 Figure 38-15. TWI Write Operation with Single Data Byte without Internal Address BEGIN Set TWI clock (CLDIV, CHDIV, CKDIV) in TWI_CWGR (Needed only once) Set the Control register: - Master enable TWI_CR = MSEN + SVDIS Set the Master Mode register:...
  • Page 762 Write ==> bit MREAD = 0 Set the internal address TWI_IADR = address Load transmit register TWI_THR = Data to send Write STOP command TWI_CR = STOP Read Status register TXRDY = 1? Read Status register TXCOMP = 1? Transfer finished SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 763 SAM9X25 SAM9X25 Figure 38-17. 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 Control register: - Master enable TWI_CR = MSEN + SVDIS...
  • Page 764 - Device slave address - Transfer direction bit Read ==> bit MREAD = 1 Start the transfer TWI_CR = START | STOP Read status register RXRDY = 1? Read Receive Holding Register Read Status register TXCOMP = 1? SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 765 SAM9X25 SAM9X25 Figure 38-19. 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 Control register: - Master enable TWI_CR = MSEN + SVDIS Set the Master Mode register:...
  • Page 766 RXRDY = 1? Read Receive Holding register (TWI_RHR) Last data to read but one? Stop the transfer TWI_CR = STOP Read Status register RXRDY = 1? Read Receive Holding register (TWI_RHR) Read status register TXCOMP = 1? SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 767 SAM9X25 SAM9X25 38.9 Multi-master Mode 38.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.
  • Page 768 (DADR + W + START + Write THR) (DADR + W + START + Write THR) The flowchart shown in Figure 38-23 on page 769 gives an example of read and write operations in Multi-master mode. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 769 SAM9X25 SAM9X25 Figure 38-23. Multi-master Flowchart START Programm the SLAVE mode: SADR + MSDIS + SVEN Read Status Register SVACC = 1 ? GACC = 1 ? SVREAD = 0 ? EOSACC = 1 ? TXRDY= 1 ? Write in TWI_THR...
  • Page 770 As soon as data is written in the TWI_THR, TXRDY (Transmit Holding Register Ready) flag is reset, and it is set when the shift register is empty and the sent data acknowledged or not. If the data is not acknowledged, the NACK flag is set. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 771 SAM9X25 SAM9X25 Note that a STOP or a repeated START always follows a NACK. Figure 38-25 on page 772. 38.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).
  • Page 772 EOSVACC 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 773 SAM9X25 SAM9X25 38.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.
  • Page 774 DATA1 DATA2 DATA0 is not read in the RHR SCLWS SCL is stretched on the last bit of DATA1 RXRDY Rd DATA0 Rd DATA1 Rd DATA2 SVACC SVREAD As soon as a START is detected TXCOMP SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 775 SAM9X25 SAM9X25 Notes: 1. At the end of the read sequence, TXCOMP is set after a STOP or after a REPEATED_START + an address different from SADR. 2. SCLWS is automatically set when the clock synchronization mechanism is started and automatically reset when the mecha- nism is finished.
  • Page 776 SVREAD = 0 ? TXRDY= 1 ? EOSACC = 1 ? Write in TWI_THR TXCOMP = 1 ? RXRDY= 0 ? Read TWI_RHR GENERAL CALL TREATMENT Decoding of the programming sequence Prog seq OK ? Change SADR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 777 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 778 Read-only 0x00000000 0x30 Receive Holding Register TWI_RHR Read-only 0x00000000 0x34 Transmit Holding Register TWI_THR Write-only 0x00000000 0xEC - 0xFC Reserved – – – – – – Note: 1. All unlisted offset values are considered as “reserved”. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 779 SAM9X25 SAM9X25 38.11.1 TWI Control Register Name: TWI_CR Address: 0xF8010000 (0), 0xF8014000 (1), 0xF8018000 (2) Access: Write-only Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – –...
  • Page 780 • QUICK: SMBUS Quick Command 0 = No effect. 1 = If Master mode is enabled, a SMBUS Quick Command is sent. • SWRST: Software Reset 0 = No effect. 1 = Equivalent to a system reset. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 781 SAM9X25 SAM9X25 38.11.2 TWI Master Mode Register Name: TWI_MMR Address: 0xF8010004 (0), 0xF8014004 (1), 0xF8018004 (2) Access: Read-write Reset: 0x00000000 – – – – – – – – – DADR – – – MREAD – – IADRSZ – – –...
  • Page 782 The slave device address is used in Slave mode in order to be accessed by master devices in read or write mode. SADR must be programmed before enabling the Slave mode or after a general call. Writes at other times have no effect. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 783 SAM9X25 SAM9X25 38.11.4 TWI Internal Address Register Name: TWI_IADR Address: 0xF801000C (0), 0xF801400C (1), 0xF801800C (2) Access: Read-write Reset: 0x00000000 – – – – – – – – IADR IADR IADR • IADR: Internal Address 0, 1, 2 or 3 bytes depending on IADRSZ.
  • Page 784 × CLDIV • CHDIV: Clock High Divider The SCL high period is defined as follows: CKDIV × × CHDIV high • CKDIV: Clock Divider The CKDIV is used to increase both SCL high and low periods. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 785 SAM9X25 SAM9X25 38.11.6 TWI Status Register Name: TWI_SR Address: 0xF8010020 (0), 0xF8014020 (1), 0xF8018020 (2) Access: Read-only Reset: 0x0000F009 – – – – – – – – – – – – – – – – EOSACC SCLWS ARBLST NACK –...
  • Page 786 NACK used in Master mode: 0 = Each data byte has been correctly received by the far-end side TWI slave component. 1 = A data byte has not been acknowledged by the slave component. Set at the same time as TXCOMP. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 787 SAM9X25 SAM9X25 NACK used in Slave Read mode: 0 = Each data byte has been correctly received by the Master. 1 = In read mode, a data byte has not been acknowledged by the Master. When NACK is set the programmer must not fill TWI_THR even if TXRDY is set, because it means that the Master will stop the data transfer or re initiate it.
  • Page 788 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 789 SAM9X25 SAM9X25 38.11.8 TWI Interrupt Disable Register Name: TWI_IDR Address: 0xF8010028 (0), 0xF8014028 (1), 0xF8018028 (2) Access: Write-only Reset: 0x00000000 – – – – – – – – – – – – – – – – EOSACC SCL_WS ARBLST NACK –...
  • Page 790 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 791 SAM9X25 SAM9X25 38.11.10 TWI Receive Holding Register Name: TWI_RHR Address: 0xF8010030 (0), 0xF8014030 (1), 0xF8018030 (2) Access: Read-only Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – –...
  • Page 792 Read-write Reset: 0x00000000 – – – – – – – – – – – – – – – – – – – – – – – – TXDATA • TXDATA: Master or Slave Transmit Holding Data SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 793 SAM9X25 SAM9X25 39. Universal Synchronous Asynchronous Receiver Transceiver (USART) 39.1 Description The Universal Synchronous Asynchronous Receiver Transceiver (USART) provides one full duplex universal synchronous asynchronous serial link. Data frame format is widely programma- ble (data length, parity, number of stop bits) to support a maximum of standards. The receiver implements parity error, framing error and overrun error detection.
  • Page 794 – Frame Slot Mode: the Master allocates slots to the scheduled frames automatically. – Generation of the Wakeup signal • Test Modes – Remote Loopback, Local Loopback, Automatic Echo • Supports Connection of Two DMA Controller Channels (DMAC) – Offers Buffer Transfer without Processor Intervention SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 795 SAM9X25 SAM9X25 39.3 Block Diagram Figure 39-1. USART Block Diagram (Peripheral) DMA Controller Channel Channel USART Controller Receiver Interrupt USART Controller Interrupt Transmitter Baud Rate Generator MCK/DIV User Interface SLCK Table 39-1. SPI Operating Mode USART SPI Slave SPI Master...
  • Page 796 39.4 Application Block Diagram Figure 39-2. Application Block Diagram IrLAP Field Bus IrDA Serial Driver Driver Driver Driver Driver Driver USART RS485 Smart IrDA RS232 Drivers Card Transceivers Drivers Transceiver Slot Differential Serial Port SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 797 SAM9X25 SAM9X25 39.5 I/O Lines Description Table 39-2. I/O Line Description Name Description Type Active Level Serial Clock Transmit Serial Data or Master Out Slave In (MOSI) in SPI Master Mode or Master In Slave Out (MISO) in SPI Slave Mode...
  • Page 798 USART operations, the USART clock can be stopped when not needed and be restarted later. In this case, the USART will resume its operations where it left off. Configuring the USART does not require the USART clock to be enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 799 SAM9X25 SAM9X25 39.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. Table 39-4. Peripheral IDs Instance USART0 USART1 USART2 USART3 Note that it is not recommended to use the USART interrupt line in edge sensitive mode.
  • Page 800 – The “Synch Break” is detected even if it is partially superimposed with a data byte – Automatic Identifier parity calculation/sending and verification – Parity sending and verification can be disabled – Automatic Checksum calculation/sending and verification – Checksum sending and verification can be disabled SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 801 SAM9X25 SAM9X25 – Support both “Classic” and “Enhanced” checksum types – Full LIN error checking and reporting – Frame Slot Mode: the Master allocates slots to the scheduled frames automatically. – Generation of the Wakeup signal • Test modes – Remote loopback, local loopback, automatic echo 11054A–ATARM–27-Jul-11...
  • Page 802 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 803 SAM9X25 SAM9X25 SelectedClock Baudrate -------------------------------------------- 8 2 Over – This gives a maximum baud rate of MCK divided by 8, assuming that MCK is the highest possi- ble clock and that OVER is programmed to 1. Baud Rate Calculation Example...
  • Page 804 In synchronous mode, if the external clock is selected (USCLKS = 3), the clock is provided directly by the signal on the USART SCK pin. No division is active. The value written in US_BRGR has no effect. The external clock frequency must be at least 4.5 times lower than the SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 805 SAM9X25 SAM9X25 system clock. In synchronous mode master (USCLKS = 0 or 1, CLK0 set to 1), the receive part limits the SCK maximum frequency to MCK/4.5 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.
  • Page 806 USART waits the end of transmission of both the current character and character being stored in the Transmit Holding Register (US_THR). If a timeguard is programmed, it is handled normally. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 807 SAM9X25 SAM9X25 39.7.3 Synchronous and Asynchronous Modes 39.7.3.1 Transmitter Operations The transmitter performs the same in both synchronous and asynchronous operating modes (SYNC = 0 or SYNC = 1). One start bit, up to 9 data bits, one optional parity bit and up to two stop bits are successively shifted out on the TXD pin at each falling edge of the programmed serial clock.
  • Page 808 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 809 SAM9X25 SAM9X25 Figure 39-9. Preamble Patterns, Default Polarity Assumed Manchester encoded DATA data 8 bit width "ALL_ONE" Preamble Manchester encoded DATA data 8 bit width "ALL_ZERO" Preamble Manchester encoded DATA data 8 bit width "ZERO_ONE" Preamble Manchester encoded DATA data 8 bit width "ONE_ZERO"...
  • Page 810 If the USART is programmed in asynchronous operating mode (SYNC = 0), the receiver over- samples the RXD input line. The oversampling is either 16 or 8 times the Baud Rate clock, depending on the OVER bit in the Mode Register (US_MR). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 811 SAM9X25 SAM9X25 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.
  • Page 812 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 39-16 for an exam- ple of Manchester error detection during data phase. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 813 SAM9X25 SAM9X25 Figure 39-15. Preamble Pattern Mismatch Preamble Mismatch Preamble Mismatch Manchester coding error invalid pattern Manchester encoded DATA data Preamble Length is set to 8 Figure 39-16. Manchester Error Flag Preamble Length is set to 4 Elementary character bit time...
  • Page 814 The Manchester preamble length is to be defined in accordance with the RF IC configuration. Figure 39-18. ASK Modulator Output NRZ stream Manchester encoded data default polarity unipolar output ASK Modulator Output Uptstream Frequency F0 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 815 SAM9X25 SAM9X25 Figure 39-19. FSK Modulator Output NRZ stream Manchester encoded data default polarity unipolar output FSK Modulator Output Uptstream Frequencies [F0, F0+offset] 39.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.
  • Page 816 Figure 39-21. Receiver Status Baud Rate Clock Start Parity Stop Start Parity Stop RSTSTA = 1 Write US_CR Read US_RHR RXRDY OVRE SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 817 SAM9X25 SAM9X25 39.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 818. Even and odd parity bit generation and error detection are supported.
  • Page 818 0 during the timeguard transmission if a character has been written in US_THR. TXEMPTY remains low until the timeguard transmission is completed as the time- guard is part of the current character being transmitted. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 819 SAM9X25 SAM9X25 Figure 39-23. Timeguard Operations TG = 4 TG = 4 Baud Rate Clock Start Parity Stop Start Parity Stop Write US_THR TXRDY TXEMPTY Table 39-10 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the function of the Baud Rate.
  • Page 820 Bit Time Time-out bit/sec μs 1 667 109 225 1 200 54 613 2 400 27 306 4 800 13 653 9 600 6 827 14400 4 551 19200 3 413 28800 2 276 33400 1 962 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 821 SAM9X25 SAM9X25 Table 39-11. Maximum Time-out Period (Continued) Baud Rate Bit Time Time-out 56000 1 170 57600 1 138 200000 39.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.
  • Page 822 RXBRK bit. 39.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 39-27. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 823 SAM9X25 SAM9X25 Figure 39-27. Connection with a Remote Device for Hardware Handshaking USART Remote Device 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...
  • Page 824 Receive Holding Register (US_RHR). It appropriately sets the PARE bit in the Status Reg- ister (US_SR) so that the software can handle the error. Figure 39-30. T = 0 Protocol without Parity Error Baud Rate Clock Start Parity Guard Guard Next Time 1 Time 2 Start SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 825 SAM9X25 SAM9X25 Figure 39-31. T = 0 Protocol with Parity Error Baud Rate Clock Error Start Parity Guard Guard Start Time 1 Time 2 Repetition Receive Error Counter The USART receiver also records the total number of errors. This can be read in the Number of Error (US_NER) register.
  • Page 826 Table 39-12. Table 39-12. IrDA Pulse Duration Baud Rate Pulse Duration (3/16) 2.4 Kb/s 78.13 μs 9.6 Kb/s 19.53 μs 19.2 Kb/s 9.77 μs 38.4 Kb/s 4.88 μs 57.6 Kb/s 3.26 μs 115.2 Kb/s 1.63 μs SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 827 SAM9X25 SAM9X25 Figure 39-33 shows an example of character transmission. Figure 39-33. IrDA Modulation Stop Start Data Bits Transmitter Output Bit Period Bit Period 39.7.5.2 IrDA Baud Rate Table 39-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.
  • Page 828 Input As the IrDA mode uses the same logic as the ISO7816, note that the FI_DI_RATIO field in US_FIDI must be set to a value higher than 0 in order to assure IrDA communications operate correctly. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 829 SAM9X25 SAM9X25 39.7.6 RS485 Mode The USART features the RS485 mode to enable line driver control. While operating in RS485 mode, the USART behaves as though in asynchronous or synchronous mode and configuration of all the parameters is possible. The difference is that the RTS pin is driven high when the transmitter is operating.
  • Page 830 In order to avoid unpredicted behavior, any change of the SPI Mode must be followed by a soft- ware reset of the transmitter and of the receiver (except the initial configuration after a hardware reset). (See Section 39.7.8.3). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 831 SAM9X25 SAM9X25 39.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 804. However, there are some restrictions: In SPI Master Mode: •...
  • Page 832 SCK cycle (for reference) (CPOL = 0) (CPOL = 1) MOSI SPI Master -> TXD SPI Slave -> RXD MISO SPI Master -> RXD SPI Slave -> TXD SPI Master -> RTS SPI Slave -> CTS SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 833 SAM9X25 SAM9X25 39.7.7.4 Receiver and Transmitter Control See “Receiver and Transmitter Control” on page 806. 39.7.7.5 Character Transmission 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.
  • Page 834 All the LIN Frames start with a header which is sent by the master node and consists of a Synch Break Field, Synch Field and Identifier Field. So in Master node configuration, the frame handling starts with the sending of the header. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 835 SAM9X25 SAM9X25 The header is transmitted as soon as the identifier is written in the LIN Identifier register (US_LINIR). At this moment the flag TXRDY falls. The Break Field, the Synch Field and the Identifier Field are sent automatically one after the other.
  • Page 836 Start Stop Start Stop Break Field ID0 ID1 ID2 ID3 ID4 ID5 ID6 ID7 Delimiter Synch Byte = 0x55 13 dominant bits (at 0) 1 recessive bit (at 1) LINBK LINID US_LINIR te RSTSTA=1 in US_CR SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 837 SAM9X25 SAM9X25 39.7.8.8 Slave Node Synchronization The synchronization is done only in Slave node configuration. The procedure is based on time measurement between falling edges of the Synch Field. The falling edges are available in dis- tances of 2, 4, 6 and 8 bit times.
  • Page 838 • Baudrate = 20 kbit/s, Over=1 (Oversampling 8X) => F (min) = 1.47 MHz • Baudrate = 1 kbit/s, Over=0 (Oversampling 16X) => F (min) = 132 kHz • Baudrate = 1 kbit/s, Over=1 (Oversampling 8X) => F (min) = 74 kHz SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 839 SAM9X25 SAM9X25 39.7.8.9 Identifier Parity A protected identifier consists of two sub-fields; the identifier and the identifier parity. Bits 0 to 5 are assigned to the identifier and bits 6 and 7 are assigned to the parity. The USART interface can generate/check these parity bits, but this feature can also be disabled.
  • Page 840 • Data transfer from the Slave 1 to the Master: NACT(Master)=SUBSCRIBE NACT(Slave1)=PUBLISH NACT(Slave2)=IGNORE • Data transfer from the Slave1 to the Slave2: NACT(Master)=IGNORE NACT(Slave1)=PUBLISH NACT(Slave2)=SUBSCRIBE • Data transfer from the Slave2 to the Master and to the Slave1: NACT(Master)=SUBSCRIBE NACT(Slave1)=SUBSCRIBE NACT(Slave2)=PUBLISH SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 841 SAM9X25 SAM9X25 39.7.8.11 Response Data Length The LIN response data length is the number of data fields (bytes) of the response excluding the checksum. The response data length can either be configured by the user or be defined automatically by bits 4 and 5 of the Identifier (compatibility to LIN Specification 1.1).
  • Page 842 If the checksum feature is disabled, the user can send it manually all the same, by considering the checksum as a normal data byte and by adding 1 to the response data length (see Section 39.7.8.11). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 843 SAM9X25 SAM9X25 39.7.8.13 Frame Slot Mode This mode is useful only for Master nodes. It respects the following rule: each frame slot shall be longer than or equal to TFrame_Maximum. If the Frame Slot Mode is enabled (FSDIS = 0) and a frame transfer has been completed, the TXRDY flag is set again only after TFrame_Maximum delay, from the start of frame.
  • Page 844 • Write IDCHR in US_LINIR to send the header What comes next depends on the NACT configuration: • Case 1: NACT = PUBLISH, the USART sends the response – Wait until TXRDY in US_CSR rises – Write TCHR in US_THR to send a byte SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 845 SAM9X25 SAM9X25 – If all the data have not been written, redo the two previous steps – Wait until LINTC in US_CSR rises – Check the LIN errors • Case 2: NACT = SUBSCRIBE, the USART receives the response – Wait until RXRDY in US_CSR rises –...
  • Page 846 IMPORTANT: if the NACT configuration for this frame is PUBLISH, the US_LINMR register, must be write with NACT = PUBLISH even if this field is already correctly configured, in order to set the TXREADY flag and the corresponding write transfer request. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 847 SAM9X25 SAM9X25 What comes next depends on the NACT configuration: • Case 1: NACT = PUBLISH, the LIN controller sends the response – Wait until TXRDY in US_CSR rises – Write TCHR in US_THR to send a byte – If all the data have not been written, redo the two previous steps –...
  • Page 848 DMAC always writes in the Transmit Holding register (US_THR) and it always reads in the Receive Holding register (US_RHR). The size of the data written or read by the DMAC in the USART is always a byte. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 849 SAM9X25 SAM9X25 Master Node Configuration The user can choose between two DMAC modes by the PDCM bit in the LIN Mode register (US_LINMR): • PDCM = 1: the LIN configuration is stored in the WRITE buffer and it is written by the DMAC in the Transmit Holding register US_THR (instead of the LIN Mode register US_LINMR).
  • Page 850 • Baud rate max = 20 kbit/s -> Tbi t= 50 μs -> 5 Tbits = 250 μs In the LIN 1.3 specification, the wakeup request should be generated with the character 0x80 in order to impose 8 successive dominant bits. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 851 SAM9X25 SAM9X25 The user can choose by the WKUPTYP bit in the LIN Mode register (US_LINMR) either to send a LIN 2.0 wakeup request (WKUPTYP=0) or to send a LIN 1.3 wakeup request (WKUPTYP=1). A wake-up request is transmitted by writing the Control Register (US_CR) with the LINWKUP bit to 1.
  • Page 852 Remote Loopback Mode Remote loopback mode directly connects the RXD pin to the TXD pin, as shown in Figure 39-57. The transmitter and the receiver are disabled and have no effect. This mode allows bit-by-bit retransmission. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 853 SAM9X25 SAM9X25 Figure 39-57. Remote Loopback Mode Configuration Receiver Transmitter 39.7.10 Write Protection Registers To prevent any single software error that may corrupt USART behavior, certain address spaces can be write-protected by setting the WPEN bit in the USART Write Protect Mode Register (US_WPMR).
  • Page 854 LIN Identifier Register US_LINIR Read-write 0xE4 Write Protect Mode Register US_WPMR Read-write 0xE8 Write Protect Status Register US_WPSR Read-only 0x5C - 0xFC Reserved – – – Notes: 1. Write is possible only in LIN Master node configuration. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 855 SAM9X25 SAM9X25 39.8.1 USART Control Register Name: US_CR Address: 0xF801C000 (0), 0xF8020000 (1), 0xF8024000 (2) Access: Write-only – – – – – – – – – – LINWKUP LINABT RTSDIS/RCS RTSEN/FCS – – RETTO RSTNACK RSTIT SENDA STTTO STPBRK STTBRK...
  • Page 856 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). • RTSDIS: Request to Send Disable 0: No effect. 1: Drives the pin RTS to 1. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 857 SAM9X25 SAM9X25 • 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). • LINABT: Abort LIN Transmission 0: No effect.
  • Page 858 LIN_MASTER LIN Master LIN_SLAVE LIN Slave SPI_MASTER SPI Master SPI_SLAVE SPI Slave • USCLKS: Clock Selection Value Name Description Master Clock MCK is selected Internal Clock Divided MCK/DIV (DIV=8) is selected Serial Clock SLK is selected SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 859 SAM9X25 SAM9X25 • CHRL: Character Length. Value Name Description 5_BIT Character length is 5 bits 6_BIT Character length is 6 bits 7_BIT Character length is 7 bits 8_BIT Character length is 8 bits • SYNC: Synchronous Mode Select 0: USART operates in Asynchronous Mode.
  • Page 860 Defines the maximum number of iterations in mode ISO7816, protocol T= 0. • FILTER: Infrared Receive Line Filter 0: The USART does not filter the receive line. 1: The USART filters the receive line using a three-sample filter (1/16-bit clock) (2 over 3 majority). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 861 SAM9X25 SAM9X25 • MAN: Manchester Encoder/Decoder Enable 0: Manchester Encoder/Decoder are disabled. 1: Manchester Encoder/Decoder are enabled. • MODSYNC: Manchester Synchronization Mode 0:The Manchester Start bit is a 0 to 1 transition 1: The Manchester Start bit is a 1 to 0 transition.
  • Page 862 • LINTC: LIN Transfer Completed Interrupt Enable • CTSIC: Clear to Send Input Change Interrupt Enable • MANE: Manchester Error Interrupt Enable • LINBE: LIN Bus Error Interrupt Enable • LINISFE: LIN Inconsistent Synch Field Error Interrupt Enable SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 863 SAM9X25 SAM9X25 • LINIPE: LIN Identifier Parity Interrupt Enable • LINCE: LIN Checksum Error Interrupt Enable • LINSNRE: LIN Slave Not Responding Error Interrupt Enable 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 864 • LINTC: LIN Transfer Completed Interrupt Disable • CTSIC: Clear to Send Input Change Interrupt Disable • MANE: Manchester Error Interrupt Disable • LINBE: LIN Bus Error Interrupt Disable • LINISFE: LIN Inconsistent Synch Field Error Interrupt Disable SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 865 SAM9X25 SAM9X25 • LINIPE: LIN Identifier Parity Interrupt Disable • LINCE: LIN Checksum Error Interrupt Disable • LINSNRE: LIN Slave Not Responding Error Interrupt Disable 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 866 • LINTC: LIN Transfer Completed Interrupt Mask • CTSIC: Clear to Send Input Change Interrupt Mask • MANE: Manchester Error Interrupt Mask • LINBE: LIN Bus Error Interrupt Mask • LINISFE: LIN Inconsistent Synch Field Error Interrupt Mask SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 867 SAM9X25 SAM9X25 • LINIPE: LIN Identifier Parity Interrupt Mask • LINCE: LIN Checksum Error Interrupt Mask • LINSNRE: LIN Slave Not Responding Error Interrupt Mask 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 868 0: There has not been a time-out since the last Start Time-out command (STTTO in US_CR) or the Time-out Register is 0. 1: There has been a time-out since the last Start Time-out command (STTTO in US_CR). • TXEMPTY: Transmitter Empty SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 869 SAM9X25 SAM9X25 0: There are characters in either US_THR or the Transmit Shift Register, or the transmitter is disabled. 1: There are no characters in US_THR, nor in the Transmit Shift Register. • ITER: Max number of Repetitions Reached 0: Maximum number of repetitions has not been reached since the last RSTSTA.
  • Page 870 1: A LIN Checksum Error has been detected since the last RSTSTA. • LINSNRE: LIN Slave Not Responding Error 0: No LIN Slave Not Responding Error has been detected since the last RSTSTA. 1: A LIN Slave Not Responding Error has been detected since the last RSTSTA. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 871 SAM9X25 SAM9X25 39.8.7 USART Receive Holding Register Name: US_RHR Address: 0xF801C018 (0), 0xF8020018 (1), 0xF8024018 (2) Access: Read-only – – – – – – – – – – – – – – – – RXSYNH – – – – –...
  • Page 872 • TXSYNH: Sync Field to be transmitted 0: The next character sent is encoded as a data. Start Frame Delimiter is DATA SYNC. 1: The next character sent is encoded as a command. Start Frame Delimiter is COMMAND SYNC. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 873 SAM9X25 SAM9X25 39.8.9 USART Baud Rate Generator Register Name: US_BRGR Address: 0xF801C020 (0), 0xF8020020 (1), 0xF8024020 (2) Access: Read-write – – – – – – – – – – – – – This register can only be written if the WPEN bit is cleared in “USART Write Protect Mode Register”...
  • Page 874 This register can only be written if the WPEN bit is cleared in “USART Write Protect Mode Register” on page 884. • TO: Time-out Value 0: The Receiver Time-out is disabled. 1 - 131071: The Receiver Time-out is enabled and the Time-out delay is TO x Bit Period. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 875 SAM9X25 SAM9X25 39.8.11 USART Transmitter Timeguard Register Name: US_TTGR Address: 0xF801C028 (0), 0xF8020028 (1), 0xF8024028 (2) Access: Read-write – – – – – – – – – – – – – – – – – – – – – –...
  • Page 876 • FI_DI_RATIO: FI Over DI Ratio Value 0: If ISO7816 mode is selected, the Baud Rate Generator generates no signal. 1 - 2047: If ISO7816 mode is selected, the Baud Rate is the clock provided on SCK divided by FI_DI_RATIO. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 877 SAM9X25 SAM9X25 39.8.13 USART Number of Errors Register Name: US_NER Address: 0xF801C044 (0), 0xF8020044 (1), 0xF8024044 (2) Access: Read-only – – – – – – – – – – – – – – – – – – – – –...
  • Page 878 – – – IRDA_FILTER This register can only be written if the WPEN bit is cleared in “USART Write Protect Mode Register” on page 884. • IRDA_FILTER: IrDA Filter Sets the filter of the IrDA demodulator. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 879 SAM9X25 SAM9X25 39.8.15 USART Manchester Configuration Register Name: US_MAN Address: 0xF801C050 (0), 0xF8020050 (1), 0xF8024050 (2) Access: Read-write – DRIFT RX_MPOL – – RX_PP – – – – RX_PL – – – TX_MPOL – – TX_PP – – – –...
  • Page 880 1: Logic Zero is coded as a one-to-zero transition, Logic One is coded as a zero-to-one transition. • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 881 SAM9X25 SAM9X25 39.8.16 USART LIN Mode Register Name: US_LINMR Address: 0xF801C054 (0), 0xF8020054 (1), 0xF8024054 (2) Access: Read-write – – – – – – – – – – – – – – – PDCM WKUPTYP FSDIS CHKTYP CHKDIS PARDIS NACT •...
  • Page 882 0 - 255: Defines the response data length if DLM=0,in that case the response data length is equal to DLC+1 bytes. • PDCM: DMAC Mode 0: The LIN mode register US_LINMR is not written by the DMAC. 1: The LIN mode register US_LINMR (excepting that flag) is written by the DMAC. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 883 SAM9X25 SAM9X25 39.8.17 USART LIN Identifier Register Name: US_LINIR Address: 0xF801C058 (0), 0xF8020058 (1), 0xF8024058 (2) Access: Read-write or Read-only – – – – – – – – – – – – – – – – – – – –...
  • Page 884 “USART Manchester Configuration Register” on page 879 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 885 SAM9X25 SAM9X25 39.8.19 USART Write Protect Status Register Name: US_WPSR Address: 0xF801C0E8 (0), 0xF80200E8 (1), 0xF80240E8 (2) Access: Read-only Reset: Table 39-17 — — — — — — — — WPVSRC WPVSRC — — — — — — — WPVS •...
  • Page 886 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 887 SAM9X25 SAM9X25 40. Universal Asynchronous Receiver Transceiver (UART) 40.1 Description The Universal Asynchronous Receiver Transmitter features a two-pin UART that can be used for communication and trace purposes and offers an ideal medium for in-situ programming solu- tions. Moreover, the association with two DMA controller channels permits packet handling for these tasks with processor time reduced to a minimum.
  • Page 888 The UART clock is controllable through the Power Management Controller. In this case, the pro- grammer must first configure the PMC to enable the UART clock. Usually, the peripheral identifier used for this purpose is 1. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 889 SAM9X25 SAM9X25 40.4.3 Interrupt Source The UART interrupt line is connected to one of the interrupt sources of the Nested Vectored Interrupt Controller (NVIC). Interrupt handling requires programming of the NVIC before config- uring the UART. 40.5 UART Operations The UART operates in asynchronous mode only and supports only 8-bit character handling (with parity).
  • Page 890 When a complete character is received, it is transferred to the UART_RHR and the RXRDY sta- tus bit in UART_SR (Status Register) is set. The bit RXRDY is automatically cleared when the receive holding register UART_RHR is read. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 891 SAM9X25 SAM9X25 Figure 40-5. Receiver Ready URXD RXRDY Read UART_RHR 40.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.
  • Page 892 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 Regis- ter (UART_THR), and after the written character is transferred from UART_THR to the Shift SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 893 SAM9X25 SAM9X25 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.
  • Page 894 Figure 40-11. Test Modes Automatic Echo Receiver Disabled Transmitter Local Loopback Disabled Receiver Disabled Transmitter Remote Loopback Disabled Receiver Disabled Transmitter SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 895 SAM9X25 SAM9X25 40.6 Universal Asynchronous Receiver Transmitter (UART) User Interface Table 40-3. Register Mapping Offset Register Name Access Reset 0x0000 Control Register UART_CR Write-only – 0x0004 Mode Register UART_MR Read-write 0x0008 Interrupt Enable Register UART_IER Write-only – 0x000C Interrupt Disable Register...
  • Page 896 1 = The transmitter is disabled. If a character is being processed and a character has been written in the UART_THR and RSTTX is not set, both characters are completed before the transmitter is stopped. • RSTSTA: Reset Status Bits 0 = No effect. 1 = Resets the status bits PARE, FRAME and OVRE in the UART_SR. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 897 SAM9X25 SAM9X25 40.6.2 UART Mode Register Name: UART_MR Address: 0xF8040004 (0), 0xF8044004 (1) Access: Read-write – – – – – – – – – – – – – – – – CHMODE – – – – – – – –...
  • Page 898 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 899 SAM9X25 SAM9X25 40.6.4 UART Interrupt Disable Register Name: UART_IDR Address: 0xF804000C (0), 0xF804400C (1) Access: Write-only – – – – – – – – – – – – – – – – – – – – – – TXEMPTY –...
  • Page 900 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 901 SAM9X25 SAM9X25 40.6.6 UART Status Register Name: UART_SR Address: 0xF8040014 (0), 0xF8044014 (1) Access: Read-only – – – – – – – – – – – – – – – – – – – – – – TXEMPTY – –...
  • Page 902 – – – – – – – – – – – – – – – – – – – – – – – – RXCHR • RXCHR: Received Character Last received character if RXRDY is set. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 903 SAM9X25 SAM9X25 40.6.8 UART Transmit Holding Register Name: UART_THR Address: 0xF804001C (0), 0xF804401C (1) Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 904 Access: Read-write – – – – – – – – – – – – – – – – • CD: Clock Divisor Baud Rate Clock is disabled 1 to 65,535 = MCK / (CD x 16) SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 905 SAM9X25 SAM9X25 41. Controller Area Network (CAN) 41.1 Description The CAN controller provides all the features required to implement the serial communication protocol CAN defined by Robert Bosch GmbH, the CAN specification as referred to by ISO/11898A (2.0 Part A and 2.0 Part B) for high speeds and ISO/11519-2 for low speeds. The CAN Controller is able to handle all types of frames (Data, Remote, Error and Overload) and achieves a bitrate of 1 Mbit/sec.
  • Page 906 Block Diagram Figure 41-1. CAN Block Diagram Controller Area Network CANRX CAN Protocol Controller CANTX Mailbox Error Counter Priority Encoder Control & Status (x = number of mailboxes - 1) CAN Interrupt User Interface Internal Bus SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 907 SAM9X25 SAM9X25 41.4 Application Block Diagram Figure 41-2. Application Block Diagram Layers Implementation CAN-based Profiles Software Software CAN-based Application Layer CAN Controller CAN Data Link Layer Transceiver CAN Physical Layer 41.5 I/O Lines Description Table 41-1. I/O Lines Description Name...
  • Page 908 • Overload frames: They provide an extra delay between the preceding and the successive data frames or remote frames. 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.
  • Page 909 SAM9X25 SAM9X25 Figure 41-3. Message Acceptance Procedure CAN_MAMx CAN_MIDx Message Received & & Message Refused Message Accepted 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.
  • Page 910 Transmit The application is notified that the message has been sent or aborted. The message prepared in the mailbox data registers will be sent after receiving the next remote Producer frame. This extends transmit mailbox features. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 911 SAM9X25 SAM9X25 41.7.3 Time Management Unit The CAN Controller integrates a free-running 16-bit internal timer. The counter is driven by the bit clock of the CAN bus line. It is enabled when the CAN controller is enabled (CANEN set in the CAN_MR register).
  • Page 912 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 seg- ment in the bit time, PHASE SEG2 shall not be less than the IPT.
  • Page 913 SAM9X25 SAM9X25 • 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. • SJW: ReSynchronization Jump Width.
  • Page 914 • 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 915 SAM9X25 SAM9X25 Figure 41-6. CAN Resynchronization THE PHASE ERROR IS POSITIVE Nominal Sample point (the transmitter is slower than the receiver) Sample point after resynchronization Received data bit Nominal bit time SYNC_ SYNC_ PROP_SEG PHASE_SEG1 PHASE_SEG2 (before resynchronization) Phase error (max Tsjw)
  • Page 916 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 917 SAM9X25 SAM9X25 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 cor- responding interrupt is pending while the interrupt is set in the CAN_IMR register.
  • Page 918 – 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 919 SAM9X25 SAM9X25 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.
  • Page 920 – 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 921 SAM9X25 SAM9X25 – 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.
  • Page 922 (CAN_MSRx) (CAN_MDLx Message 3 Message 1 CAN_MDHx) MTCR (CAN_MCRx) Reading CAN_MSRx Reading CAN_MDHx & CAN_MDLx Writing CAN_MCRx Note: In the case of ARM architecture, CAN_MSRx, CAN_MDLx, CAN_MDHx can be read using an optimized ldm assembler instruction. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 923 SAM9X25 SAM9X25 Receive with Overwrite Mailbox A mailbox is in Receive with Overwrite 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 Receive Mode is enabled, the MRDY flag in the CAN_MSR register is automatically cleared until the first message is received.
  • Page 924 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 buf- fer split (see Figure 41-14). SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 925 SAM9X25 SAM9X25 Figure 41-14. Chaining Three Mailboxes to Receive a Buffer Split into Four Messages Buffer split in 4 messages CAN BUS Message s1 Message s2 Message s3 Message s4 MRDY (CAN_MSRx) (CAN_MSRx) MRDY (CAN_MSRy) (CAN_MSRy) MRDY (CAN_MSRz) (CAN_MSRz) Reading CAN_MSRx, CAN_MSRy and CAN_MSRz Reading CAN_MDH &...
  • Page 926 Writing CAN_MDHx & CAN_MDLx 41.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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 927 SAM9X25 SAM9X25 Figure 41-16. Producer / Consumer Model PUSH MODEL Producer Consumer Indication(s) Request CAN Data Frame PULL MODEL Producer Consumer Indications CAN Remote Frame Request(s) Response CAN Data Frame Confirmation(s) 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.
  • Page 928 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 929 SAM9X25 SAM9X25 Figure 41-18. Consumer Handling Message x Message y Remote Frame Remote Frame CAN BUS MRDY (CAN_MSRx) (CAN_MSRx) MTCR (CAN_MCRx) (CAN_MDLx Message x Message y CAN_MDHx) 41.8.4 CAN Controller Timing Modes Using the free running 16-bit internal timer, the CAN controller can be set in one of the two fol- lowing timing modes: •...
  • Page 930 FFFFh. When this occurs, it automatically freezes until a new reset is issued, either due to a message received in the last mailbox or any other reset counter operations. The TOVF bit in the CAN_SR register is set when the counter is SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 931 SAM9X25 SAM9X25 frozen. The 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 gener- ated when TOVF is set. Figure 41-21. Time Triggered Operations...
  • Page 932 Mailbox Data Low Register CAN_MDL Read-write 0x0200 + mb_num * 0x20 + 0x18 Mailbox Data High Register CAN_MDH Read-write 0x0200 + mb_num * 0x20 + 0x1C Mailbox Control Register CAN_MCR Write-only 2. Mailbox number ranges from 0 to 7. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 933 SAM9X25 SAM9X25 41.9.1 CAN Mode Register Name: CAN_MR Address: 0xF8000000 (0), 0xF8004000 (1) Access: Read-write – – – – – – – – – – – – – – – – – – – – – DRPT TIMFRZ TEOF CANEN •...
  • Page 934 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 935 SAM9X25 SAM9X25 41.9.2 CAN Interrupt Enable Register Name: CAN_IER Address: 0xF8000004 (0), 0xF8004004 (1) Access: Write-only – – – BERR FERR AERR SERR CERR TSTP TOVF WAKEUP SLEEP BOFF ERRP WARN ERRA – – – – – – – –...
  • Page 936 1 = Enable Acknowledgment Error interrupt. • FERR: Form Error Interrupt Enable 0 = No effect. 1 = Enable Form Error interrupt. • BERR: Bit Error Interrupt Enable 0 = No effect. 1 = Enable Bit Error interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 937 SAM9X25 SAM9X25 41.9.3 CAN Interrupt Disable Register Name: CAN_IDR Address: 0xF8000008 (0), 0xF8004008 (1) Access: Write-only – – – BERR FERR AERR SERR CERR TSTP TOVF WAKEUP SLEEP BOFF ERRP WARN ERRA – – – – – – – –...
  • Page 938 1 = Disable Acknowledgment Error interrupt. • FERR: Form Error Interrupt Disable 0 = No effect. 1 = Disable Form Error interrupt. • BERR: Bit Error Interrupt Disable 0 = No effect. 1 = Disable Bit Error interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 939 SAM9X25 SAM9X25 41.9.4 CAN Interrupt Mask Register Name: CAN_IMR Address: 0xF800000C (0), 0xF800400C (1) Access: Read-only – – – BERR FERR AERR SERR CERR TSTP TOVF WAKEUP SLEEP BOFF ERRP WARN ERRA – – – – – – – –...
  • Page 940 • FERR: Form Error Interrupt Mask 0 = Form Error interrupt is disabled. 1 = Form Error interrupt is enabled. • BERR: Bit Error Interrupt Mask 0 = Bit Error interrupt is disabled. 1 = Bit Error interrupt is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 941 SAM9X25 SAM9X25 41.9.5 CAN Status Register Name: CAN_SR Address: 0xF8000010 (0), 0xF8004010 (1) Access: Read-only OVLSY TBSY RBSY BERR FERR AERR SERR CERR TSTP TOVF WAKEUP SLEEP BOFF ERRP WARN ERRA – – – – – – – – • MBx: Mailbox x Event 0 = No event occurred on Mailbox x.
  • Page 942 1 = A stuffing error occurred during a previous transfer. A form error results from the detection of more than five consecutive bit with the same polarity. This flag is automatically cleared by reading CAN_SR register. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 943 SAM9X25 SAM9X25 • AERR: Acknowledgment Error 0 = No acknowledgment error occurred during a previous transfer. 1 = An acknowledgment error occurred during a previous transfer. An acknowledgment error is detected when no detection of the dominant bit in the acknowledge slot occurs.
  • Page 944 0 = The incoming bit stream is sampled once at sample point. 1 = The incoming bit stream is sampled three times with a period of a MCK clock period, centered on sample point. SMP Sampling Mode is automatically disabled if BRP = 0. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 945 SAM9X25 SAM9X25 41.9.7 CAN Timer Register Name: CAN_TIM Address: 0xF8000018 (0), 0xF8004018 (1) Access: Read-only – – – – – – – – – – – – – – – – TIMER15 TIMER14 TIMER13 TIMER12 TIMER11 TIMER10 TIMER9 TIMER8 TIMER7...
  • Page 946 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 947 SAM9X25 SAM9X25 41.9.9 CAN Error Counter Register Name: CAN_ECR Address: 0xF8000020 (0), 0xF8004020 (1) Access: Read-only – – – – – – – – – – – – – – – • REC: Receive Error Counter When a receiver detects an error, REC will be increased by one, except when the detected error is a BIT ERROR while sending an ACTIVE ERROR FLAG or an OVERLOAD FLAG.
  • Page 948 (i.e., MB0 will be transferred before MB1). • TIMRST: Timer Reset Resets the internal timer counter. If the internal timer counter is frozen, this command automatically re-enables it. This command is useful in Time Triggered mode. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 949 SAM9X25 SAM9X25 41.9.11 CAN Abort Command Register Name: CAN_ACR Address: 0xF8000028 (0), 0xF8004028 (1) Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 950 Reception mailbox with overwrite. Mailbox is configured for reception. If a message is received while the mailbox is full, it overwrites the previous message. Transmit mailbox. Mailbox is configured for transmission. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 951 SAM9X25 SAM9X25 Consumer Mailbox. Mailbox is configured in reception but behaves as a Transmit Mailbox, i.e., it sends a remote frame and waits for an answer. Producer Mailbox. Mailbox is configured in transmission but also behaves like a reception mailbox, i.e., it waits to receive a Remote Frame before sending its contents.
  • Page 952 • MIDE: Identifier Version 0= Compares IDvA from the received frame with the CAN_MIDx register masked with CAN_MAMx register. 1= Compares IDvA and IDvB from the received frame with the CAN_MIDx register masked with CAN_MAMx register. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 953 SAM9X25 SAM9X25 41.9.14 CAN Message ID Register Name: CAN_MIDx [x=0..7] Address: 0xF8000208 (0)[0], 0xF8000228 (0)[1], 0xF8000248 (0)[2], 0xF8000268 (0)[3], 0xF8000288 (0)[4], 0xF80002A8 (0)[5], 0xF80002C8 (0)[6], 0xF80002E8 (0)[7], 0xF8004208 (1)[0], 0xF8004228 (1)[1], 0xF8004248 (1)[2], 0xF8004268 (1)[3], 0xF8004288 (1)[4], 0xF80042A8 (1)[5], 0xF80042C8 (1)[6],...
  • Page 954 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 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 955 SAM9X25 SAM9X25 41.9.16 CAN Message Status Register Name: CAN_MSRx [x=0..7] Address: 0xF8000210 (0)[0], 0xF8000230 (0)[1], 0xF8000250 (0)[2], 0xF8000270 (0)[3], 0xF8000290 (0)[4], 0xF80002B0 (0)[5], 0xF80002D0 (0)[6], 0xF80002F0 (0)[7], 0xF8004210 (1)[0], 0xF8004230 (1)[1], 0xF8004250 (1)[2], 0xF8004270 (1)[3], 0xF8004290 (1)[4], 0xF80042B0 (1)[5], 0xF80042D0 (1)[6],...
  • Page 956 After setting the MOT field in the CAN_MMR, MRDY is reset to 0. A remote frame has been received, mailbox data have been transmitted. Producer After setting the MOT field in the CAN_MMR, MRDY is reset to 1. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 957 SAM9X25 SAM9X25 • MMI: Mailbox Message Ignored 0 = No message has been ignored during the previous transfer 1 = At least one message has been ignored during the previous transfer Cleared by reading the CAN_MSRx register. Mailbox Object Type Description Set when at least two messages intended for the mailbox have been sent.
  • Page 958 CAN_MSRx register. In this mode, the software application must re-read CAN_MDH and CAN_MDL, while the MMI bit in the CAN_MSRx register is set. Bytes are received/sent on the bus in the following order: 1. CAN_MDL[7:0] 2. CAN_MDL[15:8] 3. CAN_MDL[23:16] 4. CAN_MDL[31:24] 5. CAN_MDH[7:0] 6. CAN_MDH[15:8] 7. CAN_MDH[23:16] 8. CAN_MDH[31:24] SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 959 SAM9X25 SAM9X25 41.9.18 CAN Message Data High Register Name: CAN_MDHx [x=0..7] Address: 0xF8000218 (0)[0], 0xF8000238 (0)[1], 0xF8000258 (0)[2], 0xF8000278 (0)[3], 0xF8000298 (0)[4], 0xF80002B8 (0)[5], 0xF80002D8 (0)[6], 0xF80002F8 (0)[7], 0xF8004218 (1)[0], 0xF8004238 (1)[1], 0xF8004258 (1)[2], 0xF8004278 (1)[3], 0xF8004298 (1)[4], 0xF80042B8 (1)[5], 0xF80042D8 (1)[6],...
  • Page 960 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 961 SAM9X25 SAM9X25 • MACR: Abort Request for Mailbox x Mailbox Object Type Description Receive No action Receive with overwrite No action Cancels transfer request if the message has not been transmitted to the Transmit CAN transceiver. Consumer Cancels the current transfer before the remote frame has been sent.
  • Page 962 SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 963 SAM9X25 SAM9X25 42. Analog-to-digital Converter (ADC) 42.1 Description The ADC is based on a 10-bit Analog-to-Digital Converter (ADC) managed by an ADC Control- ler. Refer to the Block Diagram: Figure 42-1. It also integrates a 12-to-1 analog multiplexer, making possible the analog-to-digital conversions of 12 analog lines. The conversions extend from 0V to ADVREF.
  • Page 964 1. DMA is sometimes referenced as PDC (Peripheral DMA Controller). 42.4 Signal Description Table 42-1. ADC Pin Description Pin Name Description VDDANA Analog power supply ADVREF Reference voltage AD0 - AD11 Analog input channels ADTRG External trigger SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 965 SAM9X25 SAM9X25 42.5 Product Dependencies 42.5.1 Power Management The ADC Controller is not continuously clocked. The programmer must first enable the ADC Controller MCK in the Power Management Controller (PMC) before using the ADC Controller. However, if the application does not require ADC operations, the ADC Controller clock can be stopped when not needed and restarted when necessary.
  • Page 966 DMA channel, DRDY rising triggers a data transfer request. In any case, either EOC and DRDY can trigger an interrupt. Reading one of the ADC_CDR registers clears the corresponding EOC bit. Reading ADC_LCDR clears the DRDY bit and EOC bit corresponding to the last converted channel. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 967 SAM9X25 SAM9X25 Figure 42-3. EOCx and DRDY Flag Behavior Write the ADC_CR Write the ADC_CR Read the ADC_CDRx Read the ADC_LCDR with START = 1 with START = 1 (ADC_CHSR) EOCx (ADC_SR) DRDY (ADC_SR) If the ADC_CDR is not read before further incoming data is converted, the corresponding Over- run Error (OVREx) flag is set in the Overrun Status Register (ADC_OVER).
  • Page 968 (ADC_OVER) 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. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 969 SAM9X25 SAM9X25 42.6.5 Conversion Triggers Conversions of the active analog channels are started with a software or hardware trigger. The software trigger is provided by writing the Control Register (ADC_CR) with the START bit at 1. The hardware trigger can be selected by the TRGMOD field in the “ADC Trigger Register”...
  • Page 970 Mode Register, ADC_MR. Warning: No input buffer amplifier to isolate the source is included in the ADC. This must be taken into consideration to program a precise value in the TRACKTIM field. See the product ADC Characteristics section. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 971 SAM9X25 SAM9X25 42.6.9 Buffer Structure The DMA read channel is triggered each time a new data is stored in ADC_LCDR register. The same structure of data is repeatedly stored in ADC_LCDR register each time a trigger event occurs. Depending on user mode of operation (ADC_MR, ADC_CHSR, ADC_SEQR1, ADC_SEQR2) the structure differs.
  • Page 972 0xE8 Write Protect Status Register ADC_WPSR Read-only 0x00000000 0xEC - 0xF8 Reserved – – – 0xFC Reserved – – – Note: If an offset is not listed in the table it must be considered as “reserved”. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 973 SAM9X25 SAM9X25 42.7.1 ADC Control Register Name: ADC_CR Address: 0xF804C000 Access: Write-only – – – – – – – – – – – – – – – – – – – – – – – – – – – –...
  • Page 974 ADCClock = MCK / ( (PRESCAL+1) * 2 ) • STARTUP: Start Up Time Value Name Description SUT0 0 periods of ADCClock SUT8 8 periods of ADCClock SUT16 16 periods of ADCClock SUT24 24 periods of ADCClock SUT64 64 periods of ADCClock SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 975 SAM9X25 SAM9X25 Value Name Description SUT80 80 periods of ADCClock SUT96 96 periods of ADCClock SUT112 112 periods of ADCClock SUT512 512 periods of ADCClock SUT576 576 periods of ADCClock SUT640 640 periods of ADCClock SUT704 704 periods of ADCClock...
  • Page 976 USCHx does not add the corresponding channel in the conversion sequence. Configuring the same value in different fields leads to multiple samples of the same channel during the conversion sequence. This can be done consecutively, or not, according to user needs. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 977 SAM9X25 SAM9X25 42.7.4 ADC Channel Sequence 2 Register Name: ADC_SEQR2 Address: 0xF804C00C Access: Read-write USCH16 USCH15 USCH14 USCH13 USCH12 USCH11 USCH10 USCH9 This register can only be written if the WPEN bit is cleared in “ADC Write Protect Mode Register” on page 991.
  • Page 978 • CHx: Channel x Enable 0 = No effect. 1 = Enables the corresponding channel. Note: if USEQ = 1 in ADC_MR register, CHx corresponds to the xth channel of the sequence described in ADC_SEQR1 and ADC_SEQR2. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 979 SAM9X25 SAM9X25 42.7.6 ADC Channel Disable Register Name: ADC_CHDR Address: 0xF804C014 Access: Write-only – – – – – – – – – – – – – – – – – – – – CH11 CH10 This register can only be written if the WPEN bit is cleared in “ADC Write Protect Mode Register”...
  • Page 980 – – – – – – – – – – – – – – – – – CH11 CH10 • CHx: Channel x Status 0 = Corresponding channel is disabled. 1 = Corresponding channel is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 981 SAM9X25 SAM9X25 42.7.8 ADC Last Converted Data Register Name: ADC_LCDR Address: 0xF804C020 Access: Read-only – – – – – – – – – – – – – – – – CHNB LDATA LDATA • LDATA: Last Data Converted The analog-to-digital conversion data is placed into this register at the end of a conversion and remains until a new conver- sion is completed.
  • Page 982 • EOCx: End of Conversion Interrupt Enable x • DRDY: Data Ready Interrupt Enable • GOVRE: General Overrun Error Interrupt Enable • COMPE: Comparison Event Interrupt Enable 0 = No effect. 1 = Enables the corresponding interrupt. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 983 SAM9X25 SAM9X25 42.7.10 ADC Interrupt Disable Register Name: ADC_IDR Address: 0xF804C028 Access: Write-only – – – COMPE GOVRE DRDY – – – – – – – – – EOC11 EOC10 EOC9 EOC8 EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0 •...
  • Page 984 • EOCx: End of Conversion Interrupt Mask x • DRDY: Data Ready Interrupt Mask • GOVRE: General Overrun Error Interrupt Mask • COMPE: Comparison Event Interrupt Mask 0 = The corresponding interrupt is disabled. 1 = The corresponding interrupt is enabled. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 985 SAM9X25 SAM9X25 42.7.12 ADC Interrupt Status Register Name: ADC_ISR Address: 0xF804C030 Access: Read-only – – COMPE GOVRE DRDY – – – – – – – – – EOC11 EOC10 EOC9 EOC8 EOC7 EOC6 EOC5 EOC4 EOC3 EOC2 EOC1 EOC0 • EOCx: End of Conversion x 0 = Corresponding analog channel is disabled, or the conversion is not finished.
  • Page 986 • OVREx: Overrun Error x 0 = No overrun error on the corresponding channel since the last read of ADC_OVER. 1 = There has been an overrun error on the corresponding channel since the last read of ADC_OVER. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 987 SAM9X25 SAM9X25 42.7.14 ADC Extended Mode Register Name: ADC_EMR Address: 0xF804C040 Access: Read-write – – – – – – – – – – – – – – – – – – – – – CMPALL – CMPSEL – – CMPMODE This register can only be written if the WPEN bit is cleared in “ADC Write Protect Mode Register”...
  • Page 988 This register can only be written if the WPEN bit is cleared in “ADC Write Protect Mode Register” on page 991. • LOWTHRES: Low Threshold Low threshold associated to compare settings of ADC_EMR register. • HIGHTHRES: High Threshold High threshold associated to compare settings of ADC_EMR register. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 989 SAM9X25 SAM9X25 42.7.16 ADC Channel Data Register Name: ADC_CDRx [x=0..11] Address: 0xF804C050, 0xF804C054, 0xF804C058, 0xF804C05C, 0xF804C060, 0xF804C064, 0xF804C068, 0xF804C06C, 0xF804C070, 0xF804C074, 0xF804C078 Access: Read-only – – – – – – – – – – – – – – – –...
  • Page 990 Trigger Period = (TRGPER+1) /ADCCLK The minimum time between 2 consecutive trigger events must be strictly greater than the duration time of the longest con- version sequence according to configuration of registers ADC_MR, ADC_CHSR, ADC_SEQR1, ADC_SEQR2. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 991 SAM9X25 SAM9X25 42.7.18 ADC Write Protect Mode Register Name: ADC_WPMR Address: 0xF804C0E4 Access: Read-write WPKEY WPKEY WPKEY — — — — — — — WPEN • WPEN: Write Protect Enable 0 = Disables the Write Protect if WPKEY corresponds to 0x414443 (“ADC” in ASCII).
  • Page 992 WPVSRC. • WPVSRC: Write Protect Violation Source When WPVS is active, this field indicates the write-protected register (through address offset or code) in which a write access has been attempted. Reading ADC_WPSR automatically clears all fields. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 993 SAM9X25 43. Software Modem Device (SMD) 43.1 Description The Software Modem Device (SMD) is a block for communication via a modem's Digital Isolation Barrier (DIB) with a complementary Line Side Device (HLSD). SMD and HLSD are two parts of the "Transformer only" solution. The transformer is the only component connecting SMD and HLSD.
  • Page 994 Figure 43-1. Software Modem Device Block Diagram SMD Controller SMD Core Byte Parallel Control Ring Interface Channel Logic Detection and Pulse Interrupt Dialing Control/Status Machines Registers (masters) Interface Pads Circuitry FIFO 2x16 DMA Channel FIFO Logic Interface Parallel Wrapper FIFO 2x16 8x32 (2) Interface SAM9X25 11054A–ATARM–27-Jul-11...
  • Page 995 44.1 Description The Atmel Synchronous Serial Controller (SSC) provides a synchronous communication link with external devices. It supports many serial synchronous communication protocols generally used in audio and telecom applications such as I2S, Short Frame Sync, Long Frame Sync, etc.
  • Page 996 Peripheral SSC Interface Interrupt Control SSC Interrupt 44.4 Application Block Diagram Figure 44-2. Application Block Diagram Power Interrupt Test OS or RTOS Driver Management Management Management Time Slot Frame Serial AUDIO Codec Line Interface Management Management SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 997 SAM9X25 SAM9X25 44.5 Pin Name List Table 44-1. I/O Lines Description Pin Name Pin Description Type Receiver Frame Synchro Input/Output Receiver Clock Input/Output Receiver Data Input Transmitter Frame Synchro Input/Output Transmitter Clock Input/Output Transmitter Data Output 44.6 Product Dependencies 44.6.1 I/O Lines The pins used for interfacing the compliant external devices may be multiplexed with PIO lines.
  • Page 998 All SSC interrupts can be enabled/disabled configuring the SSC Interrupt mask register. Each Table 44-3. Peripheral IDs Instance pending and unmasked SSC interrupt will assert the SSC interrupt line. The SSC interrupt ser- vice routine can get the interrupt origin by reading the SSC interrupt status register. SAM9X25 SAM9X25 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...
  • Page 999 SAM9X25 SAM9X25 44.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 pro- gramming the receiver to use the transmit clock and/or to start a data transfer when transmission starts.
  • Page 1000 DIV value is even or odd. Figure 44-5. Divided Clock Generation Master Clock Divided Clock DIV = 1 Divided Clock Frequency = MCK/2 Master Clock Divided Clock DIV = 3 Divided Clock Frequency = MCK/6 SAM9X25 SAM9X25 1000 1000 11054A–ATARM–27-Jul-11 11054A–ATARM–27-Jul-11...

Table of Contents