ADVANCE INFORMATION concerns new products in the sampling or preproduction phase of development. Characteristic data and other specications
are subject to change without notice.
Please be aware that an important notice concerning availability, standard warranty, and use in critical applications of Texas Instruments semiconductor
products and disclaimers thereto appears at the end of this data sheet.
– Modified General-Purpose Mode Read and Write Timing figure.
– Modified values for tDVand tDIparameters, and deleted tODparameter from EPI General-Purpose
Interface Characteristics figure.
– Major changes to ADC Characteristics tables, including adding additonal tables and diagram.
■ Corrected ordering part numbers.
■ Additional minor data sheet clarifications and corrections.
Texas Instruments-Advance Information
February 09, 201024
Table 1. Revision History (continued)
DescriptionRevisionDate
6458October 2009
■ Released new 1000, 3000, 5000 and 9000 series Stellaris®devices.
■ The IDCODE value was corrected to be 0x4BA0.0477.
■ Clarified that the NMISET bit in the ICSR register in the NVIC is also a source for NMI.
■ Clarified the use of the LDO.
■ To clarify clock operation, reorganized clocking section, changed the USEFRACT bit to the DIV400
bit and the FRACT bit to the SYSDIV2LSB bit in the RCC2 register, added tables, and rewrote
descriptions.
■ Corrected bit description of the DSDIVORIDE field in the DSLPCLKCFG register.
■ Removed the DSFLASHCFG register at System Control offset 0x14C as it does not function correctly.
■ Removed the MAXADC1SPD and MAXADC0SPD fields from the DCGC0 as they have no function in
deep-sleep mode.
■ Corrected address offsets for the Flash Write Buffer (FWBn) registers.
■ Added Flash Control (FCTL) register at Internal memory offset 0x0F8 to help control frequent
power cycling when hibernation is not used.
Stellaris® LM3S1R21 Microcontroller
■ Changed the name of the EPI channels for clarification: EPI0_TX became EPI0_WFIFO and EPI0_RX
became EPI0_NBRFIFO. This change was also made in the DC7 bit descriptions.
■ Removed the DMACHIS register at DMA module offset 0x504 as it does not function correctly.
■ Corrected alternate channel assignments for the µDMA controller.
■ Major improvements to the EPI chapter.
■ EPISDRAMCFG2 register was deleted as its function is not needed.
■ Clarified PWM source for ADC triggering
■ Changed SSI set up and hold times to be expressed in system clocks, not ns.
■ Updated Electrical Characteristics chapter with latest data. Changes were made to Hibernation,
ADC and EPI content.
■ Additional minor data sheet clarifications and corrections.
Texas Instruments-Advance Information
25February 09, 2010
Revision History
Table 1. Revision History (continued)
DescriptionRevisionDate
6790February 2010
■ Added 108-ball BGA package.
■ In "System Control" chapter:
– Clarified functional description for external reset and brown-out reset.
– Clarified Debug Access Port operation after Sleep modes.
– Corrected the reset value of the Run-Mode Clock Configuration 2 (RCC2) register.
■ In "Internal Memory" chapter, clarified wording on Flash memory access errors and added a section
on interrupts to the Flash memory description.
■ In "External Peripheral Interface" chapter:
– Added clarification about byte selects and dual chip selects.
– Added timing diagrams for continuous-read mode (formerly SRAM mode).
– Corrected reset values of EPI Write FIFO Count (EPIWFIFOCNT) and EPI Raw Interrupt
Status (EPIRIS) registers.
■ Added clarification about timer operating modes and added register descriptions for the GPTMTimer n Prescale Match (GPTMTnPMR) registers.
■ Clarified register descriptions for GPTM Timer A Value (GPTMTAV) and GPTM Timer B Value(GPTMTBV) registers.
■ Corrected the reset value of the ADC Sample Sequence Result FIFO n (ADCSSFIFOn) registers.
■ Added ADC Sample Phase Control (ADCSPC) register at offset 0x24.
■ Added caution note to the I2C Master Timer Period (I2CMTPR) register description and changed
field width to 7 bits.
■ Added Session Disconnect (DISCON) bit to the USB General Interrupt Status (USBIS) and
USB Interrupt Enable (USBIE) registers.
■ Made these changes to the Operating Characteristics chapter:
– Added storage temperature ratings to "Temperature Characteristics" table
– Added "ESD Absolute Maximum Ratings" table
■ Made these changes to the Electrical Characteristics chapter:
– In "Flash Memory Characteristics" table, corrected Mass erase time
– Added sleep and deep-sleep wake-up times ("Sleep Modes AC Characteristics" table)
– In "Reset Characteristics" table, corrected units for supply voltage (VDD) rise time
– Added table entry for VDD3ON power consumption to Table 22-7 on page 770.
■ Added additional DriverLib functions to appendix.
Texas Instruments-Advance Information
February 09, 201026
About This Document
This data sheet provides reference information for the LM3S1R21 microcontroller, describing the
functional blocks of the system-on-chip (SoC) device designed around the ARM® Cortex™-M3
core.
Audience
This manual is intended for system software developers, hardware designers, and application
developers.
About This Manual
This document is organized into sections that correspond to each major feature.
Related Documents
The following documents are referenced by the data sheet, and available on the documentation CD
or from the Stellaris®web site at www.ti.com/stellaris:
The following related documents are also referenced:
■
IEEE Standard 1149.1-Test Access Port and Boundary-Scan Architecture
This documentation list was current as of publication date. Please check the web site for additional
documentation, including application notes and white papers.
Documentation Conventions
This document uses the conventions shown in Table 2 on page 27.
Table 2. Documentation Conventions
MeaningNotation
General Register Notation
REGISTER
offset 0xnnn
APB registers are indicated in uppercase bold. For example, PBORCTL is the Power-On and
Brown-Out Reset Control register. If a register name contains a lowercase n, it represents more
than one register. For example, SRCRn represents any (or all) of the three Software Reset Control
registers: SRCR0, SRCR1 , and SRCR2.
A single bit in a register.bit
Two or more consecutive and related bits.bit field
A hexadecimal increment to a register's address, relative to that module's base address as specified
in “Memory Map” on page 63.
Texas Instruments-Advance Information
27February 09, 2010
About This Document
Table 2. Documentation Conventions (continued)
Register N
reserved
yy:xx
Register Bit/Field
Types
R/W1C
R/W1S
W1C
Reset Value
Pin/Signal Notation
assert a signal
SIGNAL
SIGNAL
Numbers
X
MeaningNotation
Registers are numbered consecutively throughout the document to aid in referencing them. The
register number has no meaning to software.
Register bits marked reserved are reserved for future use. In most cases, reserved bits are set to
0; however, user software should not rely on the value of a reserved bit. To provide software
compatibility with future products, the value of a reserved bit should be preserved across a
read-modify-write operation.
The range of register bits inclusive from xx to yy. For example, 31:15 means bits 15 through 31 in
that register.
This value in the register bit diagram indicates whether software running on the controller can
change the value of the bit field.
Software can read this field. The bit or field is cleared by hardware after reading the bit/field.RC
Software can read this field. Always write the chip reset value.RO
Software can read or write this field.R/W
Software can read or write this field. A write of a 0 to a W1C bit does not affect the bit value in the
register. A write of a 1 clears the value of the bit in the register; the remaining bits remain unchanged.
This register type is primarily used for clearing interrupt status bits where the read operation
provides the interrupt status and the write of the read value clears only the interrupts being reported
at the time the register was read.
Software can read or write a 1 to this field. A write of a 0 to a R/W1S bit does not affect the bit
value in the register.
Software can write this field. A write of a 0 to a W1C bit does not affect the bit value in the register.
A write of a 1 clears the value of the bit in the register; the remaining bits remain unchanged. A
read of the register returns no meaningful data.
This register is typically used to clear the corresponding bit in an interrupt register.
Only a write by software is valid; a read of the register returns no meaningful data.WO
This value in the register bit diagram shows the bit/field value after any reset, unless noted.Register Bit/Field
Bit cleared to 0 on chip reset.0
Bit set to 1 on chip reset.1
Nondeterministic.-
Pin alternate function; a pin defaults to the signal without the brackets.[ ]
Refers to the physical connection on the package.pin
Refers to the electrical signal encoding of a pin.signal
Change the value of the signal from the logically False state to the logically True state. For active
High signals, the asserted signal value is 1 (High); for active Low signals, the asserted signal value
is 0 (Low). The active polarity (High or Low) is defined by the signal name (see SIGNALand SIGNAL
below).
Change the value of the signal from the logically True state to the logically False state.deassert a signal
Signal names are in uppercase and in the Courier font. An overbar on a signal name indicates that
it is active Low. To assert SIGNAL is to drive it Low; to deassert SIGNAL is to drive it High.
Signal names are in uppercase and in the Courier font. An active High signal has no overbar. To
assert SIGNAL is to drive it High; to deassert SIGNAL is to drive it Low.
An uppercase X indicates any of several values is allowed, where X can be any legal pattern. For
example, a binary value of 0X00 can be either 0100 or 0000, a hex value of 0xX is 0x0 or 0x1, and
so on.
Texas Instruments-Advance Information
February 09, 201028
Table 2. Documentation Conventions (continued)
MeaningNotation
0x
Hexadecimal numbers have a prefix of 0x. For example, 0x00FF is the hexadecimal number FF.
All other numbers within register tables are assumed to be binary. Within conceptual information,
binary numbers are indicated with a b suffix, for example, 1011b, and decimal numbers are written
without a prefix or suffix.
Stellaris® LM3S1R21 Microcontroller
Texas Instruments-Advance Information
29February 09, 2010
Architectural Overview
1Architectural Overview
Texas Instruments is the industry leader in bringing 32-bit capabilities and the full benefits of ARM®
Cortex-M3™-based microcontrollers to the broadest reach of the microcontroller market. For current
users of 8- and 16-bit MCUs, Stellaris®with Cortex-M3 offers a direct path to the strongest ecosystem
of development tools, software and knowledge in the industry. Designers who migrate to Stellaris
benefit from great tools, small code footprint and outstanding performance. Even more important,
designers can enter the ARM ecosystem with full confidence in a compatible roadmap from $1 to
1 GHz. For users of current 32-bit MCUs, the Stellaris®family offers the industry’s first implementation
of Cortex-M3 and the Thumb-2 instruction set. With blazingly-fast responsiveness, Thumb-2
technology combines both 16-bit and 32-bit instructions to deliver the best balance of code density
and performance. Thumb-2 uses 26 percent less memory than pure 32-bit code to reduce system
cost while delivering 25 percent better performance. The Texas Instruments Stellaris®family of
microcontrollers—the first ARM® Cortex™-M3 based controllers—brings high-performance 32-bit
computing to cost-sensitive embedded microcontroller applications. These pioneering parts deliver
customers 32-bit performance at a cost equivalent to legacy 8- and 16-bit devices, all in a package
with a small footprint.
The LM3S1R21 microcontroller has the following features:
®
■ ARM® Cortex™-M3 Processor Core
– 80-MHz operation; 100 DMIPS performance
– ARM Cortex SysTick Timer
– Nested Vectored Interrupt Controller (NVIC)
■ On-Chip Memory
– 256 KB single-cycle Flash memory up to 50 MHz; a prefetch buffer improves performance
above 50 MHz
– 48 KB single-cycle SRAM
– Internal ROM loaded with StellarisWare®software:
•Stellaris®Peripheral Driver Library
•Stellaris®Boot Loader
■ External Peripheral Interface (EPI)
– 8/16/32-bit dedicated parallel bus for external peripherals
– Supports SDRAM, SRAM/Flash memory, FPGAs, CPLDs
■ Advanced Serial Integration
– Three UARTs with IrDA and ISO 7816 support (one UART with full modem controls)
– Two I2C modules
– Two Synchronous Serial Interface modules (SSI)
February 09, 201030
Texas Instruments-Advance Information
Stellaris® LM3S1R21 Microcontroller
■ System Integration
– Direct Memory Access Controller (DMA)
– System control and clocks including on-chip precision 16-MHz oscillator
– Four 32-bit timers (up to eight 16-bit)
– Eight Capture Compare PWM pins (CCP)
– Lower-power battery-backed hibernation module
– Real-Time Clock
– Two Watchdog Timers
•One timer runs off the main oscillator
•One timer runs off the precision internal oscillator
– Up to 67 GPIOs, depending on configuration
•Highly flexible pin muxing allows use as GPIO or one of several peripheral functions
•Independently configurable to 2, 4 or 8 mA drive capability
•Up to 4 GPIOs can have 18 mA drive capability
■ Analog
– 10-bit Analog-to-Digital Converter (ADC) with eight analog input channels and sample rate
of one million samples/second
– Two analog comparators
– Eight digital comparators
– On-chip voltage regulator
■ JTAG and ARM Serial Wire Debug (SWD)
■ 100-pin LQFP and 108-ball BGA package
■ Industrial (-40°C to 85°C) Temperature Range
The Stellaris®LM3S5000 series, designed for Controller Area Network (CAN) applications, extends
the Stellaris®family with Bosch CAN networking technology combined with USB 2.0 Full or Low
Speed On-The-Go (OTG) or Host/Device capabilities. The LM3S5000 microcontrollers are perfect
for cost-effective embedded control applications requiring industrial connectivity.
The LM3S1R21 microcontroller is targeted for industrial applications, including remote monitoring,
electronic point-of-sale machines, test and measurement equipment, network appliances and
switches, factory automation, HVAC and building control, gaming equipment, motion control, medical
instrumentation, and fire and security.
For applications requiring extreme conservation of power, the LM3S1R21 microcontroller features
a battery-backed Hibernation module to efficiently power down the LM3S1R21 to a low-power state
31February 09, 2010
Texas Instruments-Advance Information
Architectural Overview
during extended periods of inactivity. With a power-up/power-down sequencer, a continuous time
counter (RTC), a pair of match registers, an APB interface to the system bus, and dedicated
non-volatile memory, the Hibernation module positions the LM3S1R21 microcontroller perfectly for
battery applications.
In addition, the LM3S1R21 microcontroller offers the advantages of ARM's widely available
development tools, System-on-Chip (SoC) infrastructure IP applications, and a large user community.
Additionally, the microcontroller uses ARM's Thumb®-compatible Thumb-2 instruction set to reduce
memory requirements and, thereby, cost. Finally, the LM3S1R21 microcontroller is code-compatible
to all members of the extensive Stellaris®family; providing flexibility to fit our customers' precise
needs.
Texas Instruments offers a complete solution to get to market quickly, with evaluation and
development boards, white papers and application notes, an easy-to-use peripheral driver library,
and a strong support, sales, and distributor network. See “Ordering and Contact Information” on page
850 for ordering information for Stellaris®family devices.
1.1Functional Overview
The following sections provide an overview of the features of the LM3S1R21 microcontroller. The
page number in parentheses indicates where that feature is discussed in detail. Ordering and support
information can be found in “Ordering and Contact Information” on page 850.
1.1.1ARM Cortex™-M3
The following sections provide an overview of the ARM Cortex™-M3 processor core and instruction
set, the integrated System Timer (SysTick) and the Nested Vectored Interrupt Controller.
1.1.1.1Processor Core (see page 50)
All members of the Stellaris®product family, including the LM3S1R21 microcontroller, are designed
around an ARM Cortex™-M3 processor core. The ARM Cortex-M3 processor provides the core for
a high-performance, low-cost platform that meets the needs of minimal memory implementation,
reduced pin count, and low power consumption, while delivering outstanding computational
performance and exceptional system response to interrupts.
■ Outstanding processing performance combined with fast interrupt handling
■ Thumb-2 mixed 16-/32-bit instruction set, delivers the high performance expected of a 32-bit
ARM core in a compact memory size usually associated with 8- and 16-bit devices; typically in
the range of a few kilobytes of memory for microcontroller-class applications
– Single-cycle multiply instruction and hardware divide
– Atomic bit manipulation (bit-banding), delivering maximum memory utilization and streamlined
peripheral control
– Unaligned data access, enabling data to be efficiently packed into memory
■ Fast code execution permits slower processor clock or increases sleep mode time
■ Harvard architecture characterized by separate buses for instruction and data
■ Efficient processor core, system and memories
February 09, 201032
Texas Instruments-Advance Information
Stellaris® LM3S1R21 Microcontroller
■ Hardware division and fast multiplier
■ Deterministic, high-performance interrupt handling for time-critical applications
■ Memory protection unit (MPU) to provide a privileged mode for protected operating system
functionality
■ Enhanced system debug with extensive breakpoint and trace capabilities
■ Serial Wire Debug and Serial Wire Trace reduce the number of pins required for debugging and
tracing
■ Migration from the ARM7™ processor family for better performance and power efficiency
■ Optimized for single-cycle Flash memory usage
■ Ultra-low power consumption with integrated sleep modes
■ 80-MHz operation
■ 1.25 DMIPS/MHz
“ARM Cortex-M3 Processor Core” on page 50 provides an overview of the ARM core; the core is
detailed in the ARM® Cortex™-M3 Technical Reference Manual.
1.1.1.2System Timer (SysTick) (see page 60)
ARM Cortex-M3 includes an integrated system timer, SysTick. SysTick provides a simple, 24-bit,
clear-on-write, decrementing, wrap-on-zero counter with a flexible control mechanism. The counter
can be used in several different ways, for example:
■ An RTOS tick timer that fires at a programmable rate (for example, 100 Hz) and invokes a SysTick
routine
■ A high-speed alarm timer using the system clock
■ A variable rate alarm or signal timer—the duration is range-dependent on the reference clock
used and the dynamic range of the counter
■ A simple counter used to measure time to completion and time used
■ An internal clock-source control based on missing/meeting durations. The COUNTFLAG field in
the SysTick Control and Status register can be used to determine if an action completed within
a set duration, as part of a dynamic clock management control loop
1.1.1.3Nested Vectored Interrupt Controller (NVIC) (see page 66)
The LM3S1R21 controller includes the ARM Nested Vectored Interrupt Controller (NVIC). The NVIC
and Cortex-M3 prioritize and handle all exceptions in Handler Mode. The processor state is
automatically stored to the stack on an exception and automatically restored from the stack at the
end of the Interrupt Service Routine (ISR). The interrupt vector is fetched in parallel to the state
saving, enabling efficient interrupt entry. The processor supports tail-chaining, meaning that
back-to-back interrupts can be performed without the overhead of state saving and restoration.
Software can set eight priority levels on 7 exceptions (system handlers) and 37 interrupts.
■ Deterministic, fast interrupt processing: always 12 cycles, or just 6 cycles with tail-chaining
Texas Instruments-Advance Information
33February 09, 2010
Architectural Overview
■ External non-maskable interrupt signal (NMI) available for immediate execution of NMI handler
for safety critical applications
■ Dynamically reprioritizable interrupts
■ Exceptional interrupt handling via hardware implementation of required register manipulations
“Interrupts” on page 66 provides an overview of the NVIC controller and the interrupt map. Exceptions
and interrupts are detailed in the ARM® Cortex™-M3 Technical Reference Manual.
1.1.2On-Chip Memory
The following sections describe the on-chip memory modules.
1.1.2.1SRAM (see page 200)
The LM3S1R21 microcontroller provides 48 KB of single-cycle on-chip SRAM. The internal SRAM
of the Stellaris®devices is located at offset 0x2000.0000 of the device memory map.
Because read-modify-write (RMW) operations are very time consuming, ARM has introduced
bit-banding technology in the new Cortex-M3 processor. With a bit-band-enabled processor, certain
regions in the memory map (SRAM and peripheral space) can use address aliases to access
individual bits in a single, atomic operation.
Data can be transferred to and from the SRAM using the Micro Direct Memory Access Controller
(µDMA).
1.1.2.2Flash Memory (see page 200)
The LM3S1R21 microcontroller provides 256 KB of single-cycle on-chip Flash memory (above 50
MHz, the Flash memory can be accessed in a single cycle as long as the code is linear; branches
incur a one-cycle stall). The Flash memory is organized as a set of 2-KB blocks that can be
individually erased. Erasing a block causes the entire contents of the block to be reset to all 1s.
These blocks are paired into a set of 2-KB blocks that can be individually protected. The blocks can
be marked as read-only or execute-only, providing different levels of code protection. Read-only
blocks cannot be erased or programmed, protecting the contents of those blocks from being modified.
Execute-only blocks cannot be erased or programmed, and can only be read by the controller
instruction fetch mechanism, protecting the contents of those blocks from being read by either the
controller or by a debugger.
1.1.2.3ROM (see page 794)
The LM3S1R21 ROM is preprogrammed with the following software and programs:
■ Stellaris®Peripheral Driver Library
■ Stellaris®Boot Loader
The Stellaris®Peripheral Driver Library is a royalty-free software library for controlling on-chip
peripherals with a boot-loader capability. The library performs both peripheral initialization and
control functions, with a choice of polled or interrupt-driven peripheral support. In addition, the library
is designed to take full advantage of the stellar interrupt performance of the ARM® Cortex™-M3
core. No special pragmas or custom assembly code prologue/epilogue functions are required. For
applications that require in-field programmability, the royalty-free Stellaris®Boot Loader can act as
an application loader and support in-field firmware updates.
Texas Instruments-Advance Information
February 09, 201034
1.1.3External Peripheral Interface (see page 347)
The External Peripheral Interface (EPI) provides access to external devices using a parallel path.
Unlike communications peripherals such as SSI, UART, and I2C, the EPI is designed to act like a
bus to external peripherals and memory.
The EPI has the following features:
■ 8/16/32-bit dedicated parallel bus for external peripherals and memory
■ Memory interface supports contiguous memory access independent of data bus width, thus
enabling code execution directly from SDRAM, SRAM and Flash memory
■ Blocking and non-blocking reads
■ Separates processor from timing details through use of an internal write FIFO
■ Efficient transfers using Micro Direct Memory Access Controller (µDMA)
– Separate channels for read and write
– Read channel request asserted by programmable levels on the internal non-blocking read
FIFO (NBRFIFO)
Stellaris® LM3S1R21 Microcontroller
– Write channel request asserted by empty on the internal write FIFO (WFIFO)
The EPI supports three primary functional modes: Synchronous Dynamic Random Access Memory
(SDRAM) mode, Traditional Host-Bus mode, and General-Purpose mode. The EPI module also
provides custom GPIOs; however, unlike regular GPIOs, the EPI module uses a FIFO in the same
way as a communication mechanism and is speed-controlled using clocking.
■ Synchronous Dynamic Random Access Memory (SDRAM)
– Supports x16 (single data rate) SDRAM at up to 50 MHz
– Supports low-cost SDRAMs up to 64 MB (512 megabits)
– Includes automatic refresh and access to all banks/rows
– Includes a Sleep/Standby mode to keep contents active with minimal power draw
– Multiplexed address/data interface for reduced pin count
■ Host-bus
– Traditional x8 and x16 MCU bus interface capabilities
– Similar device compatibility options as PIC, ATmega, 8051, and others
– Access to SRAM, NOR Flash memory, and other devices, with up to 1 MB of addressing in
unmultiplexed mode and 256 MB in multiplexed mode (512 MB in Host-Bus 16 mode with
no byte selects)
– Support of both muxed and de-muxed address and data
– Access to a range of devices supporting the non-address FIFO x8 and x16 interface variant,
with support for external FIFO (XFIFO) EMPTY and FULL signals
35February 09, 2010
Texas Instruments-Advance Information
Architectural Overview
– Speed controlled, with read and write data wait-state counters
– Chip select modes include ALE, CSn, Dual CSn and ALE with dual CSn
– Manual chip-enable (or use extra address pins)
■ General Purpose
– Wide parallel interfaces for fast communications with CPLDs and FPGAs
– Useful for custom peripherals or for digital data acquisition and actuator controls
1.1.4Serial Communications Peripherals
The LM3S1R21 controller supports both asynchronous and synchronous serial communications
with:
■ Three UARTs with IrDA and ISO 7816 support (one UART with full modem controls)
■ Two I2C modules
■ Two Synchronous Serial Interface Modules (SSI)
The following sections provide more detail on each of these communications functions.
1.1.4.1UART (see page 565)
A Universal Asynchronous Receiver/Transmitter (UART) is an integrated circuit used for RS-232C
serial communications, containing a transmitter (parallel-to-serial converter) and a receiver
(serial-to-parallel converter), each clocked separately.
The LM3S1R21 controller includes three fully programmable 16C550-type UARTs. Although the
functionality is similar to a 16C550 UART, this UART design is not register compatible. The UART
can generate individually masked interrupts from the Rx, Tx, modem status, and error conditions.
The module generates a single combined interrupt when any of the interrupts are asserted and are
unmasked.
The three UARTs have the following features:
■ Programmable baud-rate generator allowing speeds up to 5 Mbps for regular speed (divide by
16) and 10 Mbps for high speed (divide by 8)
■ Separate 16x8 transmit (TX) and receive (RX) FIFOs to reduce CPU interrupt service loading
February 09, 201036
Texas Instruments-Advance Information
Stellaris® LM3S1R21 Microcontroller
■ Programmable FIFO length, including 1-byte deep operation providing conventional
double-buffered interface
■ FIFO trigger levels of 1/8, 1/4, 1/2, 3/4, and 7/8
■ Standard asynchronous communication bits for start, stop, and parity
■ False-start bit detection
■ Line-break generation and detection
■ Fully programmable serial interface characteristics
– 5, 6, 7, or 8 data bits
– Even, odd, stick, or no-parity bit generation/detection
– 1 or 2 stop bit generation
■ IrDA serial-IR (SIR) encoder/decoder providing
– Programmable use of IrDA Serial Infrared (SIR) or UART input/output
– Support of IrDA SIR encoder/decoder functions for data rates up to 115.2 Kbps half-duplex
– Support of normal 3/16 and low-power (1.41-2.23 μs) bit durations
– Programmable internal clock generator enabling division of reference clock by 1 to 256 for
low-power mode bit duration
■ Support for communication with ISO 7816 smart cards
■ Full modem handshake support (on UART1)
■ LIN protocol support
■ Standard FIFO-level and End-of-Transmission interrupts
■ Efficient transfers using Micro Direct Memory Access Controller (µDMA)
– Separate channels for transmit and receive
– Receive single request asserted when data is in the FIFO; burst request asserted at
programmed FIFO level
– Transmit single request asserted when there is space in the FIFO; burst request asserted at
programmed FIFO level
1.1.4.2I2C (see page 669)
The Inter-Integrated Circuit (I2C) bus provides bi-directional data transfer through a two-wire design
(a serial data line SDA and a serial clock line SCL). The I2C bus interfaces to external I2C devices
such as serial memory (RAMs and ROMs), networking devices, LCDs, tone generators, and so on.
The I2C bus may also be used for system testing and diagnostic purposes in product development
and manufacture.
37February 09, 2010
Texas Instruments-Advance Information
Architectural Overview
Each device on the I2C bus can be designated as either a master or a slave. Each I2C module
supports both sending and receiving data as either a master or a slave and can operate
simultaneously as both a master and a slave. Both the I2C master and slave can generate interrupts.
The LM3S1R21 controller includes two I2C modules with the following features:
■ Devices on the I2C bus can be designated as either a master or a slave
– Supports both transmitting and receiving data as either a master or a slave
– Supports simultaneous master and slave operation
■ Four I2C modes
– Master transmit
– Master receive
– Slave transmit
– Slave receive
■ Two transmission speeds: Standard (100 Kbps) and Fast (400 Kbps)
■ Master and slave interrupt generation
– Master generates interrupts when a transmit or receive operation completes (or aborts due
to an error)
– Slave generates interrupts when data has been transferred or requested by a master or when
a START or STOP condition is detected
■ Master with arbitration and clock synchronization, multimaster support, and 7-bit addressing
mode
1.1.4.3SSI (see page 627)
Synchronous Serial Interface (SSI) is a four-wire bi-directional communications interface that converts
data between parallel and serial. The SSI module performs serial-to-parallel conversion on data
received from a peripheral device, and parallel-to-serial conversion on data transmitted to a peripheral
device. The SSI module can be configured as either a master or slave device. As a slave device,
the SSI module can also be configured to disable its output, which allows a master device to be
coupled with multiple slave devices. The TX and RX paths are buffered with separate internal FIFOs.
The SSI module also includes a programmable bit rate clock divider and prescaler to generate the
output serial clock derived from the SSI module's input clock. Bit rates are generated based on the
input clock and the maximum bit rate is determined by the connected peripheral.
The LM3S1R21 controller includes two SSI modules with the following features:
■ Programmable interface operation for Freescale SPI, MICROWIRE, or Texas Instruments
synchronous serial interfaces
■ Master or slave operation
■ Programmable clock bit rate and prescaler
February 09, 201038
Texas Instruments-Advance Information
■ Separate transmit and receive FIFOs, each 16 bits wide and 8 locations deep
■ Programmable data frame size from 4 to 16 bits
■ Internal loopback test mode for diagnostic/debug testing
■ Standard FIFO-based interrupts and End-of-Transmission interrupt
■ Efficient transfers using Micro Direct Memory Access Controller (µDMA)
– Separate channels for transmit and receive
– Receive single request asserted when data is in the FIFO; burst request asserted when FIFO
contains 4 entries
– Transmit single request asserted when there is space in the FIFO; burst request asserted
when FIFO contains 4 entries
1.1.5System Integration
The LM3S1R21 controller provides a variety of standard system functions integrated into the device,
including:
Stellaris® LM3S1R21 Microcontroller
■ Micro Direct Memory Access Controller (µDMA)
■ System control and clocks including on-chip precision 16-MHz oscillator
■ ARM Cortex SysTick Timer
■ Four 32-bit timers (up to eight 16-bit)
■ Eight Capture Compare PWM pins (CCP)
■ Lower-power battery-backed hibernation module
■ Real-Time Clock
■ Two Watchdog Timers
■ Up to 67 GPIOs, depending on configuration
– Highly flexible pin muxing allows use as GPIO or one of several peripheral functions
– Independently configurable to 2, 4 or 8 mA drive capability
– Up to 4 GPIOs can have 18 mA drive capability
The following sections provide more detail on each of these functions.
1.1.5.1Direct Memory Access (see page 233)
The LM3S1R21 microcontroller includes a Direct Memory Access (DMA) controller, known as
micro-DMA (μDMA). The μDMA controller provides a way to offload data transfer tasks from the
Cortex-M3 processor, allowing for more efficient use of the processor and the available bus
bandwidth. The μDMA controller can perform transfers between memory and peripherals. It has
dedicated channels for each supported on-chip module and can be programmed to automatically
Texas Instruments-Advance Information
39February 09, 2010
Architectural Overview
perform transfers between peripherals and memory as the peripheral is ready to transfer more data.
The μDMA controller provides the following features:
■ ARM PrimeCell® 32-channel configurable µDMA controller
■ Support for memory-to-memory, memory-to-peripheral, and peripheral-to-memory in multiple
transfer modes
– Basic for simple transfer scenarios
– Ping-pong for continuous data flow
– Scatter-gather for a programmable list of arbitrary transfers initiated from a single request
■ Highly flexible and configurable channel operation
– Independently configured and operated channels
– Dedicated channels for supported on-chip modules: GP Timer, UART, ADC, EPI, SSI
– Alternate channel assignments
– One channel each for receive and transmit path for bidirectional modules
– Dedicated channel for software-initiated transfers
– Per-channel configurable bus arbitration scheme
– Optional software-initiated requests for any channel
■ Two levels of priority
■ Design optimizations for improved bus access performance between µDMA controller and the
processor core
– µDMA controller access is subordinate to core access
– RAM striping
– Peripheral bus segmentation
■ Data sizes of 8, 16, and 32 bits
■ Transfer size is programmable in binary steps from 1 to 1024
■ Source and destination address increment size of byte, half-word, word, or no increment
■ Maskable peripheral requests
■ Interrupt on transfer completion, with a separate interrupt per channel
1.1.5.2System Control and Clocks (see page 81)
System control determines the overall operation of the device. It provides information about the
device, controls power-saving features, controls the clocking of the device and individual peripherals,
and handles reset detection and reporting.
Texas Instruments-Advance Information
February 09, 201040
Stellaris® LM3S1R21 Microcontroller
■ Device identification information: version, part number, SRAM size, Flash memory size, and so
on
■ Power control
– On-chip fixed Low Drop-Out (LDO) voltage regulator
– Hibernation module handles the power-up/down 3.3 V sequencing and control for the core
digital logic and analog circuits
– Low-power options for microcontroller: Sleep and Deep-sleep modes with clock gating
– Low-power options for on-chip modules: software controls shutdown of individual peripherals
and memory
– 3.3-V supply brown-out detection and reporting via interrupt or reset
■ Multiple clock sources for microcontroller system clock
– Precision Oscillator (PIOSC): on-chip resource providing a 16 MHz ±1% frequency at room
temperature
•16 MHz ±3% across temperature
•Can be recalibrated with 7-bit trim resolution
•Software power down control for low power modes
– Main Oscillator (MOSC): a frequency-accurate clock source by one of two means: an external
single-ended clock source is connected to the OSC0 input pin, or an external crystal is
connected across the OSC0 input and OSC1 output pins.
•External oscillator used with or without on-chip PLL: select supported frequencies from 1
MHz to 16.384 MHz.
•External crystal: from DC to maximum device speed
– Internal 30-kHz Oscillator: on chip resource providing a 30 kHz ± 50% frequency, used during
power-saving modes
– Hibernation Module clock source: eliminates need for additional crystal for main clock source
•32.768-kHz external oscillator
•4.194304-MHz external crystal
■ Flexible reset sources
– Power-on reset (POR)
– Reset pin assertion
– Brown-out reset (BOR) detector alerts to system power drops
– Software reset
Texas Instruments-Advance Information
41February 09, 2010
Architectural Overview
– Watchdog timer reset
– MOSC failure
1.1.5.3Four Programmable Timers (see page 419)
Programmable timers can be used to count or time external events that drive the Timer input pins.
Each GPTM block provides two 16-bit timers/counters that can be configured to operate independently
as timers or event counters, or configured to operate as one 32-bit timer or one 32-bit Real-Time
Clock (RTC). Timers can also be used to trigger analog-to-digital (ADC) conversions.
The General-Purpose Timer Module (GPTM) contains four GPTM blocks with the following functional
options:
■ Count up or down
■ 16- or 32-bit programmable one-shot timer
■ 16- or 32-bit programmable periodic timer
■ 16-bit general-purpose timer with an 8-bit prescaler
■ 32-bit Real-Time Clock (RTC) when using an external 32.768-KHz clock as the input
■ Eight Capture Compare PWM pins (CCP)
■ Daisy chaining of timer modules to allow a single timer to initiate multiple timing events
■ ADC event trigger
■ User-enabled stalling when the controller asserts CPU Halt flag during debug (excluding RTC
mode)
■ 16-bit input-edge count- or time-capture modes
■ 16-bit PWM mode with software-programmable output inversion of the PWM signal
■ Ability to determine the elapsed time between the assertion of the timer interrupt and entry into
the interrupt service routine.
■ Efficient transfers using Micro Direct Memory Access Controller (µDMA)
– Dedicated channel for each timer
– Burst request generated on timer interrupt
1.1.5.4CCP Pins (see page 426)
Capture Compare PWM pins (CCP) can be used by the General-Purpose Timer Module to time/count
external events using the CCP pin as an input. Alternatively, the GPTM can generate a simple PWM
output on the CCP pin.
The LM3S1R21 microcontroller includes eight Capture Compare PWM pins (CCP) that can be
programmed to operate in the following modes:
■ Capture: The GP Timer is incremented/decremented by programmed events on the CCP input.
The GP Timer captures and stores the current timer value when a programmed event occurs.
February 09, 201042
Texas Instruments-Advance Information
■ Compare: The GP Timer is incremented/decremented by programmed events on the CCP input.
The GP Timer compares the current value with a stored value and generates an interrupt when
a match occurs.
■ PWM: The GP Timer is incremented/decremented by the system clock. A PWM signal is generated
based on a match between the counter value and a value stored in a match register and is output
on the CCP pin.
1.1.5.5Hibernation Module (see page 172)
The Hibernation module provides logic to switch power off to the main processor and peripherals
and to wake on external or time-based events. The Hibernation module includes power-sequencing
logic and has the following features:
■ Two mechanisms for power control
– System power control using discrete external regulator
– On-chip power control using internal switches under register control
■ Dedicated pin for waking using an external signal
Stellaris® LM3S1R21 Microcontroller
■ Low-battery detection, signaling, and interrupt generation
■ 32-bit real-time counter (RTC)
– Two 32-bit RTC match registers for timed wake-up and interrupt generation
– RTC predivider trim for making fine adjustments to the clock rate
■ Clock source from a 32.768-kHz external oscillator or a 4.194304-MHz crystal; source can be
used for main controller clock
■ 64 32-bit words of non-volatile memory to save state during hibernation
■ Programmable interrupts for RTC match, external wake, and low battery events
1.1.5.6Watchdog Timers (see page 466)
A watchdog timer is used to regain control when a system has failed due to a software error or to
the failure of an external device to respond in the expected way. The Stellaris®Watchdog Timer
can generate an interrupt or a reset when a time-out value is reached. In addition, the Watchdog
Timer is ARM FiRM-compliant and can be configured to generate an interrupt to the controller on
its first time-out, and to generate a reset signal on its second time-out. Once the Watchdog Timer
has been configured, the lock register can be written to prevent the timer configuration from being
inadvertently altered.
The LM3S1R21 microcontroller has two Watchdog Timer modules: Watchdog Timer 0 uses the
system clock for its timer clock; Watchdog Timer 1 uses the PIOSC as its timer clock. The Stellaris
Watchdog Timer module has the following features:
®
■ 32-bit down counter with a programmable load register
■ Separate watchdog clock with an enable
■ Programmable interrupt generation logic with interrupt masking
Texas Instruments-Advance Information
43February 09, 2010
Architectural Overview
■ Lock register protection from runaway software
■ Reset generation logic with an enable/disable
■ User-enabled stalling when the microcontroller asserts the CPU Halt flag during debug
1.1.5.7Programmable GPIOs (see page 291)
General-purpose input/output (GPIO) pins offer flexibility for a variety of connections. The Stellaris
GPIO module is comprised of nine physical GPIO blocks, each corresponding to an individual GPIO
port. The GPIO module is FiRM-compliant (compliant to the ARM Foundation IP for Real-Time
Microcontrollers specification) and supports 0-67 programmable input/output pins. The number of
GPIOs available depends on the peripherals being used (see “Signal Tables” on page 720 for the
signals available to each GPIO pin).
■ Up to 67 GPIOs, depending on configuration
■ Highly flexible pin muxing allows use as GPIO or one of several peripheral functions
■ 5-V-tolerant input/outputs
■ Fast toggle capable of a change every two clock cycles
®
■ Two means of port access: either Advanced High-Performance Bus (AHB) with better back-to-back
access performance, or the legacy Advanced Peripheral Bus (APB) for backwards-compatibility
with existing code
■ Programmable control for GPIO interrupts
– Interrupt generation masking
– Edge-triggered on rising, falling, or both
– Level-sensitive on High or Low values
■ Bit masking in both read and write operations through address lines
■ Can be used to initiate an ADC sample sequence
■ Pins configured as digital inputs are Schmitt-triggered
■ Programmable control for GPIO pad configuration
– Weak pull-up or pull-down resistors
– 2-mA, 4-mA, and 8-mA pad drive for digital communication; up to four pads can be configured
with an 18-mA pad drive for high-current applications
– Slew rate control for the 8-mA drive
– Open drain enables
– Digital input enables
1.1.6Analog
The LM3S1R21 controller provides analog functions integrated into the device, including:
February 09, 201044
Texas Instruments-Advance Information
■ 10-bit Analog-to-Digital Converter (ADC) with eight analog input channels and sample rate of
one million samples/second
■ Two analog comparators
■ Eight digital comparators
■ On-chip voltage regulator
The following provides more detail on these analog functions.
1.1.6.1ADC (see page 491)
An analog-to-digital converter (ADC) is a peripheral that converts a continuous analog voltage to a
discrete digital number. The Stellaris®ADC module features 10-bit conversion resolution and supports
eight input channels plus an internal temperature sensor. Four buffered sample sequencers allow
rapid sampling of up to eight analog input sources without controller intervention. Each sample
sequencer provides flexible programming with fully configurable input source, trigger events, interrupt
generation, and sequencer priority. A digital comparator function is included that allows the conversion
value to be diverted to a comparison unit that provides eight digital comparators.
with the following features:
Stellaris® LM3S1R21 Microcontroller
■ Eight analog input channels
■ Single-ended and differential-input configurations
■ On-chip internal temperature sensor
■ Sample rate of one million samples/second
■ Optional phase shift in sample time programmable from 22.5º to 337.5º
■ Four programmable sample conversion sequencers from one to eight entries long, with
corresponding conversion result FIFOs
■ Flexible trigger control
– Controller (software)
– Timers
– Analog Comparators
– GPIO
■ Hardware averaging of up to 64 samples for improved accuracy
■ Digital comparison unit providing eight digital comparators
■ Converter uses an internal 3-V reference or an external reference
■ Power and ground for the analog circuitry is separate from the digital power and ground
■ Efficient transfers using Micro Direct Memory Access Controller (µDMA)
– Dedicated channel for each sample sequencer
Texas Instruments-Advance Information
45February 09, 2010
Architectural Overview
– Burst request asserted when interrupt is triggered
1.1.6.2Analog Comparators (see page 706)
An analog comparator is a peripheral that compares two analog voltages and provides a logical
output that signals the comparison result. The LM3S1R21 microcontroller provides two independent
integrated analog comparators that can be configured to drive an output or generate an interrupt or
ADC event.
The comparator can provide its output to a device pin, acting as a replacement for an analog
comparator on the board, or it can be used to signal the application via interrupts or triggers to the
ADC to cause it to start capturing a sample sequence. The interrupt generation and ADC triggering
logic is separate. This means, for example, that an interrupt can be generated on a rising edge and
the ADC triggered on a falling edge.
The LM3S1R21 microcontroller provides two independent integrated analog comparators with the
following functions:
■ Compare external pin input to external pin input or to internal programmable voltage reference
■ Compare a test voltage against any one of the following voltages:
– An individual external reference voltage
– A shared single external reference voltage
– A shared internal reference voltage
1.1.7JTAG and ARM Serial Wire Debug (see page 69)
The Joint Test Action Group (JTAG) port is an IEEE standard that defines a Test Access Port and
Boundary Scan Architecture for digital integrated circuits and provides a standardized serial interface
for controlling the associated test logic. The TAP, Instruction Register (IR), and Data Registers (DR)
can be used to test the interconnections of assembled printed circuit boards and obtain manufacturing
information on the components. The JTAG Port also provides a means of accessing and controlling
design-for-test features such as I/O pin observation and control, scan testing, and debugging. Texas
Instruments replaces the ARM SW-DP and JTAG-DP with the ARM CoreSight™-compliant Serial
Wire JTAG Debug Port (SWJ-DP) interface. The SWJ-DP interface combines the SWD and JTAG
debug ports into one module providing all the normal JTAG debug and test functionality plus real-time
access to system memory without halting the core or requiring any target resident code. See the
CoreSight™ Design Kit Technical Reference Manual for details on SWJ-DP. The SWJ-DP interface
has the following features:
■ IEEE 1149.1-1990 compatible Test Access Port (TAP) controller
■ Four-bit Instruction Register (IR) chain for storing JTAG instructions
■ IEEE standard instructions: BYPASS, IDCODE, SAMPLE/PRELOAD, EXTEST and INTEST
■ ARM additional instructions: APACC, DPACC and ABORT
■ Integrated ARM Serial Wire Debug (SWD)
– Serial Wire JTAG Debug Port (SWJ-DP)
– Flash Patch and Breakpoint (FPB) unit for implementing breakpoints
Texas Instruments-Advance Information
February 09, 201046
– Data Watchpoint and Trigger (DWT) unit for implementing watchpoints, trigger resources,
and system profiling
– Instrumentation Trace Macrocell (ITM) for support of printf style debugging
– Trace Port Interface Unit (TPIU) for bridging to a Trace Port Analyzer
The Stellaris®family is positioned for cost-conscious applications requiring significant control
processing and connectivity capabilities such as:
■ Remote monitoring
■ Electronic point-of-sale (POS) machines
Stellaris® LM3S1R21 Microcontroller
■ Test and measurement equipment
■ Network appliances and switches
■ Factory automation
■ HVAC and building control
■ Gaming equipment
■ Motion control
■ Medical instrumentation
■ Fire and security
■ Power and energy
■ Transportation
1.3High-Level Block Diagram
Figure 1-1 depicts the features on the Stellaris®LM3S1R21 microcontroller. Note that there are two
on-chip buses that connect the core to the peripherals. The Advanced Peripheral Bus (APB) bus is
the legacy bus. The Advanced High-Performance Bus (AHB) bus provides better back-to-back
access performance than the APB bus.
A memory map lists the location of instructions and data in memory. The memory map for the
LM3S1R21 controller can be found in “Memory Map” on page 63. Register addresses are given as
a hexadecimal increment, relative to the module's base address as shown in the memory map. The
ARM® Cortex™-M3 Technical Reference Manual provides further information on the memory map.
1.4.2Hardware Details
Details on the pins and package can be found in the following sections:
■ “Pin Diagram” on page 718
■ “Signal Tables” on page 720
■ “Operating Characteristics” on page 767
■ “Electrical Characteristics” on page 768
■ “Package Information” on page 852
Stellaris® LM3S1R21 Microcontroller
Texas Instruments-Advance Information
49February 09, 2010
ARM Cortex-M3 Processor Core
2ARM Cortex-M3 Processor Core
The ARM Cortex-M3 processor provides a high-performance, low-cost platform that meets the
system requirements of minimal memory implementation, reduced pin count, and low power
consumption, while delivering outstanding computational performance and exceptional system
response to interrupts. Features include:
■ Outstanding processing performance combined with fast interrupt handling
■ Thumb-2 mixed 16-/32-bit instruction set, delivers the high performance expected of a 32-bit
ARM core in a compact memory size usually associated with 8- and 16-bit devices; typically in
the range of a few kilobytes of memory for microcontroller-class applications
– Single-cycle multiply instruction and hardware divide
– Atomic bit manipulation (bit-banding), delivering maximum memory utilization and streamlined
peripheral control
– Unaligned data access, enabling data to be efficiently packed into memory
■ Fast code execution permits slower processor clock or increases sleep mode time
■ Harvard architecture characterized by separate buses for instruction and data
■ Efficient processor core, system and memories
■ Hardware division and fast multiplier
■ Deterministic, high-performance interrupt handling for time-critical applications
■ Memory protection unit (MPU) to provide a privileged mode for protected operating system
functionality
■ Enhanced system debug with extensive breakpoint and trace capabilities
■ Serial Wire Debug and Serial Wire Trace reduce the number of pins required for debugging and
tracing
■ Migration from the ARM7™ processor family for better performance and power efficiency
■ Optimized for single-cycle Flash memory usage
■ Ultra-low power consumption with integrated sleep modes
■ 80-MHz operation
■ 1.25 DMIPS/MHz
The Stellaris®family of microcontrollers builds on this core to bring high-performance 32-bit computing
to cost-sensitive embedded microcontroller applications, such as factory automation and control,
industrial control power devices, building and home automation, and stepper motors.
February 09, 201050
Texas Instruments-Advance Information
For more information on the ARM Cortex-M3 processor core, see the ARM® Cortex™-M3 Technical
Private Peripheral
Bus
(internal)
Data
Watchpoint
and Trace
Interrupts
Debug
Sleep
Instrumentation
Trace Macrocell
Trace
Port
Interface
Unit
CM3 Core
InstructionsData
Flash
Patch and
Breakpoint
Memory
Protection
Unit
Debug
Access Port
Nested
Vectored
Interrupt
Controller
Serial Wire JTAG
Debug Port
Bus
Matrix
Adv. Peripheral
Bus
I-code bus
D-code bus
System bus
ROM
Table
Serial
Wire
Output
Trace
Port
(SWO)
ARM
Cortex-M3
Reference Manual. For information on SWJ-DP, see the ARM® CoreSight Technical Reference
Manual.
2.1Block Diagram
Figure 2-1. CPU Block Diagram
Stellaris® LM3S1R21 Microcontroller
2.2Functional Description
Important:
Texas Instruments implements the ARM Cortex-M3 core as shown in Figure 2-1 on page 51. The
Cortex-M3 uses the entire 16-bit Thumb instruction set and the base Thumb-2 32-bit instruction set.
In addition, as noted in the ARM® Cortex™-M3 Technical Reference Manual, several Cortex-M3
components are flexible in their implementation: SW/JTAG-DP, ETM, TPIU, the ROM table, the
MPU, and the Nested Vectored Interrupt Controller (NVIC). Each of these is addressed in the
sections that follow.
2.2.1Programming Model
This section provides a brief overview of the programming model for the Cortex-M3 core. More
detailed information can be found in the ARM® Cortex™-M3 Technical Reference Manual.
■ Privileged access and user access - Code can execute as privileged or unprivileged. Unprivileged
execution limits or excludes access to some resources. Privileged execution has access to all
resources. Handler mode is always privileged. Thread mode can be privileged or unprivileged.
The ARM® Cortex™-M3 Technical Reference Manual describes all the features of an
ARM Cortex-M3 in detail. However, these features differ based on the implementation.
This section describes the Stellaris®implementation.
Texas Instruments-Advance Information
51February 09, 2010
ARM Cortex-M3 Processor Core
Thread mode is privileged out of reset, but you can change it to user or unprivileged by setting
the CONTROL[0] bit using the MSR instruction. User access prevents:
– Use of some instructions such as CPS to set FAULTMASK and PRIMASK
– Access to most registers in System Control Space (SCS)
When Thread mode has been changed from privileged to user, it cannot change itself back to
privileged. Only a Handler can change the privilege of Thread mode. Handler mode is always
privileged.
■ Register set - The processor has the following 32-bit registers:
– 13 general-purpose registers, r0-r12
– Stack point alias of banked registers, SP_process and SP_main
– Link register, r14
– Program counter, r15
– One program status register, xPSR.
■ Data types - The processor supports the following data types:
– 32-bit words
– 16-bit halfwords
– 8-bit bytes
■ Memory formats - The processor views memory as a linear collection of bytes numbered in
ascending order from 0. For example, bytes 0-3 hold the first stored word and bytes 4-7 hold the
second stored word. The processor accesses code and data in little-endian format, which means
that the byte with the lowest address in a word is the least-significant byte of the word. The byte
with the highest address in a word is the most significant. The byte at address 0 of the memory
system connects to data lines 7-0.
■ Instruction set - The Cortex-M3 instruction set contains both 16 and 32-bit instructions. These
instructions are summarized in Table 2-1 on page 52 and Table 2-2 on page 54, respectively.
Table 2-1. 16-Bit Cortex-M3 Instruction Set Summary
AssemblerOperation
ADC <Rd>, <Rm>Add register value and C flag to register value
ADD <Rd>, <Rn>, #<immed_3>Add immediate 3-bit value to register
ADD <Rd>, #<immed_8>Add immediate 8-bit value to register
ADD <Rd>, <Rn>, <Rm>Add low register value to low register value
ADD <Rd>, <Rm>Add high register value to low or high register value
ADD <Rd>, PC, #<immed_8> * 4Add 4* (immediate 8-bit value) with PC to register
ADD <Rd>, SP, #<immed_8> * 4Add 4* (immediate 8-bit value) with SP to register
LDREX<c> <Rt>,[<Rn>{,#<imm>}]Load register exclusive calculates an address from a base register value and
an immediate offset, loads a word from memory, writes it to a register
LDREXH<c> <Rt>,[<Rn>{,#<imm>}]Load register exclusive halfword calculates an address from a base register
value and an immediate offset, loads a halfword from memory, writes it to a
register
LDREXB<c> <Rt>,[<Rn>{,#<imm>}]Load register exclusive byte calculates an address from a base register value
and an immediate offset, loads a byte from memory, writes it to a register
LDRH.W <Rxf>, [<Rn>, #<offset_12>]Memory halfword [15:0] from base register address + immediate 12-bit offset
LDRH.W <Rxf>, [<Rn>, #<+/–<offset_8>]!Memory halfword [15:0] from base register address immediate 8-bit offset,
preindexed
LDRH.W <Rxf>. [<Rn>], #+/-<offset_8>Memory halfword [15:0] from base register address immediate 8-bit offset,
postindexed
LDRH.W <Rxf>, [<Rn>, <Rm>{, LSL #<shift>}]Memory halfword [15:0] from register address shifted left by 0, 1, 2, or 3 places
LDRH.W <Rxf>, [PC, #+/–<offset_12>]Memory halfword from PC address immediate 12-bit offset
LDRSB.W <Rxf>, [<Rn>, #<offset_12>]Memory signed byte [7:0] from base register address + immediate 12-bit offset
LDRSB.W <Rxf>. [<Rn>], #+/-<offset_8>Memory signed byte [7:0] from base register address immediate 8-bit offset,
postindexed
LDRSB.W <Rxf>, [<Rn>, #<+/–<offset_8>]!Memory signed byte [7:0] from base register address immediate 8-bit offset,
preindexed
LDRSB.W <Rxf>, [<Rn>, <Rm>{, LSL #<shift>}]Memory signed byte [7:0] from register address shifted left by 0, 1, 2, or 3
places
LDRSB.W <Rxf>, [PC, #+/–<offset_12>]Memory signed byte from PC address immediate 12-bit offset
LDRSH.W <Rxf>, [<Rn>, #<offset_12>]Memory signed halfword [15:0] from base register address + immediate 12-bit
offset
LDRSH.W <Rxf>. [<Rn>], #+/-<offset_8>Memory signed halfword [15:0] from base register address immediate 8-bit
offset, postindexed
LDRSH.W <Rxf>, [<Rn>, #<+/–<offset_8>]!Memory signed halfword [15:0] from base register address immediate 8-bit
offset, preindexed
LDRSH.W <Rxf>, [<Rn>, <Rm>{, LSL #<shift>}]Memory signed halfword [15:0] from register address shifted left by 0, 1, 2,
or 3 places
LDRSH.W <Rxf>, [PC, #+/–<offset_12>]Memory signed halfword from PC address immediate 12-bit offset
LSL{S}.W <Rd>, <Rn>, <Rm>Logical shift left register value by number in register
LSR{S}.W <Rd>, <Rn>, <Rm>Logical shift right register value by number in register
MLA.W <Rd>, <Rn>, <Rm>, <Racc>Multiply two signed or unsigned register values and add the low 32 bits to a
register value
MLS.W <Rd>, <Rn>, <Rm>, <Racc>Multiply two signed or unsigned register values and subtract the low 32 bits
from a register value
MOV{S}.W <Rd>, #<modify_constant(immed_12)>Move immediate 12-bit value to register
MOV{S}.W <Rd>, <Rm>{, <shift>}Move shifted register value to register
MOVT.W <Rd>, #<immed_16>Move immediate 16-bit value to top halfword [31:16] of register
MOVW.W <Rd>, #<immed_16>Move immediate 16-bit value to bottom halfword [15:0] of register and clear
top halfword [31:16]
MRS<c> <Rd>, <psr>Move to register from status
MSR<c> <psr>_<fields>,<Rn>Move to status register
MUL.W <Rd>, <Rn>, <Rm>Multiply two signed or unsigned register values
NOP.WNo operation
Texas Instruments-Advance Information
February 09, 201056
Table 2-2. 32-Bit Cortex-M3 Instruction Set Summary (continued)
AssemblerOperation
ORN{S}.W <Rd>, <Rn>, #<modify_constant(immed_12)>Logical OR NOT register value with immediate 12-bit value
ORN[S}.W <Rd>, <Rn>, <Rm>{, <shift>}Logical OR NOT register value with shifted register value
ORR{S}.W <Rd>, <Rn>, #<modify_constant(immed_12)>Logical OR register value with immediate 12-bit value
ORR{S}.W <Rd>, <Rn>, <Rm>{, <shift>}Logical OR register value with shifted register value
RBIT.W <Rd>, <Rm>Reverse bit order
REV.W <Rd>, <Rm>Reverse bytes in word
REV16.W <Rd>, <Rn>Reverse bytes in each halfword
REVSH.W <Rd>, <Rn>Reverse bytes in bottom halfword and sign-extend
ROR{S}.W <Rd>, <Rn>, <Rm>Rotate right by number in register
RRX{S}.W <Rd>, <Rm>Rotate right with extend
RSB{S}.W <Rd>, <Rn>, #<modify_constant(immed_12)>Subtract a register value from an immediate 12-bit value
RSB{S}.W <Rd>, <Rn>, <Rm>{, <shift>}Subtract a register value from a shifted register value
SBC{S}.W <Rd>, <Rn>, #<modify_constant(immed_12)>Subtract immediate 12-bit value and C bit from register value
SBC{S}.W <Rd>, <Rn>, <Rm>{, <shift>}Subtract shifted register value and C bit from register value
SBFX.W <Rd>, <Rn>, #<lsb>, #<width>Copy selected bits to register and sign-extend
SDIV<c> <Rd>,<Rn>,<Rm>Signed divide
SEV<c>Send event
SMLAL.W <RdLo>, <RdHi>, <Rn>, <Rm>Multiply signed words and add signed-extended value to 2-register value
SMULL.W <RdLo>, <RdHi>, <Rn>, <Rm>Multiply two signed register values
UXTB.W <Rd>, <Rm>{, <rotation>}Copy unsigned byte to register and zero-extend to 32 bits
UXTH.W <Rd>, <Rm>{, <rotation>}Copy unsigned halfword to register and zero-extend to 32 bits
WFE.WWait for event
WFI.WWait for interrupt
2.2.2Serial Wire and JTAG Debug
Texas Instruments replaces the ARM SW-DP and JTAG-DP with the ARM CoreSight™-compliant
Serial Wire JTAG Debug Port (SWJ-DP) interface. As a result, Chapter 12, “Debug Port,” of the
ARM® Cortex™-M3 Technical Reference Manual does not apply to Stellaris®devices.
The SWJ-DP interface combines the SWD and JTAG debug ports into one module. See the
CoreSight™ Design Kit Technical Reference Manual for details on SWJ-DP.
2.2.3Embedded Trace Macrocell (ETM)
ETM is not implemented in the Stellaris®devices. As a result, Chapters 15 and 16 of the ARM®
Cortex™-M3 Technical Reference Manual can be ignored.
2.2.4Trace Port Interface Unit (TPIU)
The TPIU acts as a bridge between the Cortex-M3 trace data from the ITM, and an off-chip Trace
Port Analyzer. Stellaris®devices implement the TPIU as shown in Figure 2-2. This implementation
is similar to the non-ETM version described in the ARM® Cortex™-M3 Technical Reference Manual,
however, SWJ-DP only provides the Serial Wire Viewer (SWV) output format for the TPIU.
Texas Instruments-Advance Information
February 09, 201058
Figure 2-2. TPIU Block Diagram
ATB
Interface
Asynchronous FIFO
APB
Interface
Trace Out
(serializer)
Debug
ATB
Slave
Port
APB
Slave
Port
Serial Wire
Trace Port
(SWO)
Stellaris® LM3S1R21 Microcontroller
2.2.5ROM Table
The default ROM table is implemented as described in the ARM® Cortex™-M3 Technical Reference
Manual.
2.2.6Memory Protection Unit (MPU)
The Memory Protection Unit (MPU) is included on the LM3S1R21 controller and supports the
standard ARMv7 Protected Memory System Architecture (PMSA) model. The MPU provides full
support for protection regions, overlapping protection regions, access permissions, and exporting
memory attributes to the system.
2.2.7Nested Vectored Interrupt Controller (NVIC)
The Nested Vectored Interrupt Controller (NVIC):
■ Facilitates low-latency exception and interrupt handling
■ Controls power management
■ Implements system control registers
The NVIC and the processor core interface are closely coupled, which enables low latency interrupt
processing and efficient processing of late arriving interrupts. The NVIC maintains knowledge of
the stacked (nested) interrupts to enable tail-chaining of interrupts.
You can only fully access the NVIC from privileged mode, but you can pend interrupts in user-mode
by enabling the Configuration Control Register (see the ARM® Cortex™-M3 Technical Reference
Manual). Any other user-mode access causes a bus fault.
All NVIC registers are accessible using byte, halfword, and word unless otherwise stated.
59February 09, 2010
Texas Instruments-Advance Information
ARM Cortex-M3 Processor Core
2.2.7.1Interrupts
The ARM® Cortex™-M3 Technical Reference Manual describes the maximum number of interrupts
and interrupt priorities. The LM3S1R21 microcontroller supports 37 interrupts with eight priority
levels.
In addition to the peripheral interrupts, the system also provides for a non-maskable interrupt (NMI).
The NMI is generally used in safety critical applications where the immediate execution of an interrupt
handler is required. The NMI signal is available as an external signal so that it may be generated
by external circuitry. The NMI is also used internally as part of the main oscillator verification circuitry.
More information on the non-maskable interrupt is located in “Non-Maskable Interrupt” on page 86.
2.2.8System Timer (SysTick)
Cortex-M3 includes an integrated system timer, SysTick. SysTick provides a simple, 24-bit
clear-on-write, decrementing, wrap-on-zero counter with a flexible control mechanism. The counter
can be used in several different ways, for example:
■ An RTOS tick timer which fires at a programmable rate (for example, 100 Hz) and invokes a
SysTick routine
■ A high-speed alarm timer using the system clock
■ A variable rate alarm or signal timer—the duration is range-dependent on the reference clock
used and the dynamic range of the counter.
■ A simple counter used to measure time to completion and time used
■ An internal clock source control based on missing/meeting durations. The COUNTFLAG bit-field
in the control and status register can be used to determine if an action completed within a set
duration, as part of a dynamic clock management control loop.
2.2.8.1Functional Description
The timer consists of three registers:
■ SysTick Control and Status Register - a control and status counter to configure its clock, enable
the counter, enable the SysTick interrupt, and determine counter status
■ SysTick Reload Value Register - the reload value for the counter, used to provide the counter's
wrap value
■ SysTick Current Value Register - the current value of the counter
A fourth register, the SysTick Calibration Value Register, is not implemented in the Stellaris®devices.
When enabled, the timer counts down on each clock from the reload value to zero, reloads (wraps)
to the value in the SysTick Reload Value register on the next clock edge, then decrements on
subsequent clocks. Clearing the SysTick Reload Value register disables the counter on the next
wrap. When the counter reaches zero, the COUNTFLAG status bit is set. The COUNTFLAG bit
clears on reads.
Writing to the SysTick Current Value register clears the register and the COUNTFLAG status bit.
The write does not trigger the SysTick exception logic. On a read, the current value is the value of
the register at the time the register is accessed.
February 09, 201060
Texas Instruments-Advance Information
If the core is in debug state (halted), the counter does not decrement. The timer is clocked with
respect to a reference clock, which can be either the core clock or an external clock source.
2.2.8.2SysTick Control and Status Register
Use the SysTick Control and Status Register to enable the SysTick features. The reset is
0x0000.0000.
DescriptionResetTypeNameBit/Field
Software should not rely on the value of a reserved bit. To provide
0x000ROreserved31:17
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
Count Flag
0R/WCOUNTFLAG16
When set, this bit indicates that the timer has counted to 0 since the last time
this register was read.
This bit is cleared by a read of the register.
If read by the debugger using the DAP, this bit is cleared only if the
MasterType bit in the AHB-AP Control Register is clear. Otherwise, the
COUNTFLAG bit is not changed by the debugger read.
Software should not rely on the value of a reserved bit. To provide
0x000ROreserved15:3
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
Clock Source
0R/WCLKSOURCE2
Stellaris® LM3S1R21 Microcontroller
0R/WTICKINT1
0R/WENABLE0
2.2.8.3SysTick Reload Value Register
The SysTick Reload Value Register specifies the start value to load into the SysTick Current Value
Register when the counter reaches 0. The start value can be between 1 and 0x00FF.FFFF. A start
value of 0 is possible but has no effect because the SysTick interrupt and COUNTFLAG are activated
when counting from 1 to 0.
DescriptionValue
External reference clock. (Not implemented for Stellaris
0
microcontrollers.)
Core clock1
Because an external reference clock is not supported, this bit must be set
in order for SysTick to operate.
Tick Interrupt
When set, this bit causes an interrupt to be generated to the NVIC when
SysTick counts to 0.
When clear, interrupt generation is disabled. Software can use the
COUNTFLAG to determine if the counter has ever reached 0.
Enable
When set, this bit enables SysTick to operate in a multi-shot way. That is,
the counter loads the Reload value and begins counting down. On reaching
0, the COUNTFLAG bit is set and an interrupt is generated if enabled by
TICKINT. The counter then loads the Reload value again and begins counting.
When this bit is clear, the counter is disabled.
®
SysTick can be configured as a multi-shot timer, repeated over and over, firing every N+1 clock
pulses, where N is any value from 1 to 0x00FF.FFFF. For example, if a tick interrupt is required
every 100 clock pulses, 99 must be written into the RELOAD field.
Texas Instruments-Advance Information
61February 09, 2010
ARM Cortex-M3 Processor Core
When configuring SysTick as a single-shot timer, a new value is written on each tick interrupt, and
the actual count down value must be written. For example, if a tick is next required after 400 clock
pulses, 400 must be written into the RELOAD field.
2.2.8.4SysTick Current Value Register
The SysTick Current Value Register contains the current value of the counter.
0x00ROreserved31:24
DescriptionResetTypeNameBit/Field
0x00ROreserved31:24
-W1CCURRENT23:0
Software should not rely on the value of a reserved bit. To
provide compatibility with future products, the value of a
reserved bit should be preserved across a read-modify-write
operation.
Reload Value
-R/WRELOAD23:0
Value to load into the SysTick Current Value Register when
the counter reaches 0.
DescriptionResetTypeNameBit/Field
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
Current Value
This field contains the current value at the time the register is accessed.
No read-modify-write protection is provided, so change with care.
This register is write-clear. Writing to it with any value clears the register
to 0. Clearing this register also clears the COUNTFLAG bit of the
SysTick Control and Status Register.
2.2.8.5SysTick Calibration Value Register
The SysTick Calibration Value register is not implemented.
Texas Instruments-Advance Information
February 09, 201062
3Memory Map
The memory map for the LM3S1R21 controller is provided in Table 3-1.
In this manual, register addresses are given as a hexadecimal increment, relative to the module’s
base address as shown in the memory map. See also Chapter 4, “Memory Map” in the ARM®Cortex™-M3 Technical Reference Manual.
Note that within the memory map, all reserved space returns a bus fault when read or written.
Table 3-1. Memory Map
Stellaris® LM3S1R21 Microcontroller
Memory
FiRM Peripherals
Peripherals
DescriptionEndStart
Reserved0x3FFF.FFFF0x0000.0001
Reserved0x4001.FFFF0x4000.F000
For details,
see page ...
200On-chip Flash0x0003.FFFF0x0000.0000
-Reserved0x00FF.FFFF0x0004.0000
200Reserved for ROM0x1FFF.FFFF0x0100.0000
200Bit-banded on-chip SRAM0x2000.0000
-Reserved0x21FF.FFFF0x0000.0001
200Bit-band alias of 0x2000.0000 through 0x200F.FFFF0x2200.0000
Trace Port Interface Unit (TPIU)0xE004.0FFF0xE004.0000
Reserved0xFFFF.FFFF0xE004.1000
For details,
see page ...
ARM®
Cortex™-M3
Technical
Reference
Manual
-Reserved0xE000.DFFF0xE000.3000
ARM®
Cortex™-M3
Technical
Reference
Manual
-Reserved0xE003.FFFF0xE000.F000
ARM®
Cortex™-M3
Technical
Reference
Manual
-
Texas Instruments-Advance Information
65February 09, 2010
Interrupts
4Interrupts
The ARM Cortex-M3 processor and the Nested Vectored Interrupt Controller (NVIC) prioritize and
handle all exceptions in Handler Mode. The processor state is automatically stored to the stack on
an exception and automatically restored from the stack at the end of the Interrupt Service Routine
(ISR). The vector is fetched in parallel to the state saving, enabling efficient interrupt entry. The
processor supports tail-chaining, which enables back-to-back interrupts to be performed without the
overhead of state saving and restoration.
Table 4-1 on page 66 lists all exception types. Software can set eight priority levels on seven of
these exceptions (system handlers) as well as on 37 interrupts (listed in Table 4-2 on page 67).
Priorities on the system handlers are set with the NVIC System Handler Priority registers. Interrupts
are enabled through the NVIC Interrupt Set Enable register and prioritized with the NVIC Interrupt
Priority registers. Priorities can be grouped by splitting priority levels into pre-emption priorities and
subpriorities. All of the interrupt registers are described in Chapter 8, “Nested Vectored Interrupt
Controller” in the ARM® Cortex™-M3 Technical Reference Manual.
Internally, the highest user-programmable priority (0) is treated as fourth priority, after a Reset,
Non-Maskable Interrupt (NMI), and a Hard Fault, in that order. Note that 0 is the default priority for
all the programmable priorities.
If you assign the same priority level to two or more interrupts, their hardware priority (the lower
position number) determines the order in which the processor activates them. For example, if both
GPIO Port A and GPIO Port B are priority level 1, then GPIO Port A has higher priority.
Important: It may take several processor cycles after a write to clear an interrupt source for the
NVIC to see the interrupt source de-assert. Thus if the interrupt clear is done as the
last action in an interrupt handler, it is possible for the interrupt handler to complete
while the NVIC sees the interrupt as still asserted, causing the interrupt handler to be
re-entered errantly. This situation can be avoided by either clearing the interrupt source
at the beginning of the interrupt handler or by performing a read or write after the write
to clear the interrupt source (and flush the write buffer).
See Chapter 5, “Exceptions” and Chapter 8, “Nested Vectored Interrupt Controller” in the ARM®Cortex™-M3 Technical Reference Manual for more information on exceptions and interrupts.
Table 4-1. Exception Types
a
Exception Type
Interrupt (NMI)
Management
Vector
Number
-3 (highest)1Reset
-22Non-Maskable
-13Hard Fault
programmable4Memory
DescriptionPriority
Stack top is loaded from the first entry of the vector table on reset.-0-
This exception is invoked on power up and warm reset. On the first
instruction, Reset drops to the lowest priority (and then is called the
base level of activation). This exception is asynchronous.
This exception is caused by the assertion of the NMI signal or by using
the NVIC Interrupt Control State register and cannot be stopped or
preempted by any exception but Reset. This exception is asynchronous.
This exception is caused by all classes of Fault, when the fault cannot
activate due to priority or the configurable fault handler has been
disabled. This exception is synchronous.
This exception is caused by an MPU mismatch, including access
violation and no match. This exception is synchronous.
Texas Instruments-Advance Information
February 09, 201066
Table 4-1. Exception Types (continued)
a
Exception Type
Interrupts
a. 0 is the default priority for all the programmable priorities.
Vector
Number
programmable5Bus Fault
programmable6Usage Fault
programmable11SVCall
programmable12Debug Monitor
programmable14PendSV
programmable15SysTick
programmable16 and
above
DescriptionPriority
This exception is caused by a pre-fetch fault, memory access fault, and
other address/memory related faults. This exception is synchronous
when precise and asynchronous when imprecise.
This fault can be enabled or disabled.
This exception is caused by a usage fault, such as undefined instruction
executed or illegal state transition attempt. This exception is
synchronous.
Reserved.-7-10-
This exception is caused by a system service call with an SVC
instruction. This exception is synchronous.
This exception is caused by the debug monitor (when not halting). This
exception is synchronous, but only active when enabled. This exception
does not activate if it is a lower priority than the current activation.
Reserved.-13-
This exception is caused by a pendable request for system service. This
exception is asynchronous and only pended by software.
This exception is caused by the SysTick timer reaching 0, when it is
enabled to generate an interrupt. This exception is asynchronous.
This exception is caused by interrupts asserted from outside the ARM
Cortex-M3 core and fed through the NVIC (prioritized). These exceptions
are all asynchronous. Table 4-2 on page 67 lists the interrupts on the
LM3S1R21 controller.
Stellaris® LM3S1R21 Microcontroller
Table 4-2. Interrupts
Vector Number
DescriptionInterrupt Number (Bit in
Interrupt Registers)
Processor exceptions-0-15
GPIO Port A016
GPIO Port B117
GPIO Port C218
GPIO Port D319
GPIO Port E420
UART0521
UART1622
SSI0723
I2C0824
Reserved9-1325-29
ADC0 Sequence 01430
ADC0 Sequence 11531
ADC0 Sequence 21632
ADC0 Sequence 31733
Watchdog Timers 0 and 11834
Timer 0A1935
Timer 0B2036
Texas Instruments-Advance Information
67February 09, 2010
Interrupts
Table 4-2. Interrupts (continued)
Vector Number
DescriptionInterrupt Number (Bit in
Interrupt Registers)
Timer 1A2137
Timer 1B2238
Timer 2A2339
Timer 2B2440
Analog Comparator 02541
Analog Comparator 12642
Reserved2743
System Control2844
Flash Memory Control2945
GPIO Port F3046
GPIO Port G3147
GPIO Port H3248
UART23349
SSI13450
Timer 3A3551
Timer 3B3652
I2C13753
Reserved38-4254-58
Hibernation Module4359
Reserved44-4560-61
µDMA Software4662
µDMA Error4763
Reserved48-5264-68
EPI5369
GPIO Port J5470
Reserved5571
Texas Instruments-Advance Information
February 09, 201068
5JTAG Interface
The Joint Test Action Group (JTAG) port is an IEEE standard that defines a Test Access Port and
Boundary Scan Architecture for digital integrated circuits and provides a standardized serial interface
for controlling the associated test logic. The TAP, Instruction Register (IR), and Data Registers (DR)
can be used to test the interconnections of assembled printed circuit boards and obtain manufacturing
information on the components. The JTAG Port also provides a means of accessing and controlling
design-for-test features such as I/O pin observation and control, scan testing, and debugging.
The JTAG port is comprised of four pins: TCK, TMS, TDI, and TDO. Data is transmitted serially into
the controller on TDI and out of the controller on TDO. The interpretation of this data is dependent
on the current state of the TAP controller. For detailed information on the operation of the JTAG
port and TAP controller, please refer to the IEEE Standard 1149.1-Test Access Port andBoundary-Scan Architecture.
The Stellaris®JTAG controller works with the ARM JTAG controller built into the Cortex-M3 core
by multiplexing the TDO outputs from both JTAG controllers. ARM JTAG instructions select the ARM
TDO output while Stellaris®JTAG instructions select the Stellaris®TDO output. The multiplexer is
controlled by the Stellaris®JTAG controller, which has comprehensive programming for the ARM,
Stellaris®, and unimplemented JTAG instructions.
Stellaris® LM3S1R21 Microcontroller
The Stellaris®JTAG module has the following features:
■ IEEE 1149.1-1990 compatible Test Access Port (TAP) controller
■ Four-bit Instruction Register (IR) chain for storing JTAG instructions
■ IEEE standard instructions: BYPASS, IDCODE, SAMPLE/PRELOAD, EXTEST and INTEST
■ ARM additional instructions: APACC, DPACC and ABORT
■ Integrated ARM Serial Wire Debug (SWD)
– Serial Wire JTAG Debug Port (SWJ-DP)
– Flash Patch and Breakpoint (FPB) unit for implementing breakpoints
– Data Watchpoint and Trigger (DWT) unit for implementing watchpoints, trigger resources,
and system profiling
– Instrumentation Trace Macrocell (ITM) for support of printf style debugging
– Trace Port Interface Unit (TPIU) for bridging to a Trace Port Analyzer
See the ARM® Cortex™-M3 Technical Reference Manual for more information on the ARM JTAG
controller.
Texas Instruments-Advance Information
69February 09, 2010
Instruction Register (IR)
TAP Controller
BYPASS Data Register
Boundary Scan Data Register
IDCODE Data Register
ABORT Data Register
DPACC Data Register
APACC Data Register
TCK
TMS
TDI
TDO
Cortex-M3
Debug
Port
JTAG Interface
5.1Block Diagram
Figure 5-1. JTAG Module Block Diagram
5.2Signal Description
Table 5-1 on page 70 and Table 5-2 on page 71 list the external signals of the JTAG/SWD controller
and describe the function of each. The JTAG/SWD controller signals are alternate functions for
some GPIO signals, however note that the reset state of the pins is for the JTAG/SWD function.
The JTAG/SWD controller signals are under commit protection and require a special process to be
configured as GPIOs, see “Commit Control” on page 299. The column in the table below titled "Pin
Mux/Pin Assignment" lists the GPIO pin placement for the JTAG/SWD controller signals. The AFSEL
bit in the GPIO Alternate Function Select (GPIOAFSEL) register (page 315) is set to choose the
JTAG/SWD function.The number in parentheses is the encoding that must be programmed into the
PMCn field in the GPIO Port Control (GPIOPCTL) register (page 333) to assign the JTAG/SWD
controller signals to the specified GPIO port pin. For more information on configuring GPIOs, see
“General-Purpose Input/Outputs (GPIOs)” on page 291.
Table 5-1. Signals for JTAG_SWD_SWO (100LQFP)
Pin NumberPin Name
Assignment
Pin TypePin Mux / Pin
a
DescriptionBuffer Type
JTAG/SWD CLK.TTLIPC0 (3)80SWCLK
JTAG TMS and SWDIO.TTLI/OPC1 (3)79SWDIO
JTAG TDO and SWO.TTLOPC3 (3)77SWO
JTAG/SWD CLK.TTLIPC0 (3)80TCK
JTAG TDI.TTLIPC2 (3)78TDI
JTAG TDO and SWO.TTLOPC3 (3)77TDO
Texas Instruments-Advance Information
February 09, 201070
Table 5-1. Signals for JTAG_SWD_SWO (100LQFP) (continued)
Pin NumberPin Name
Assignment
a. The TTL designation indicates the pin has TTL-compatible voltage levels.
Pin TypePin Mux / Pin
Table 5-2. Signals for JTAG_SWD_SWO (108BGA)
Pin NumberPin Name
Assignment
a. The TTL designation indicates the pin has TTL-compatible voltage levels.
Pin TypePin Mux / Pin
Stellaris® LM3S1R21 Microcontroller
a
DescriptionBuffer Type
JTAG TMS and SWDIO.TTLIPC1 (3)79TMS
a
DescriptionBuffer Type
JTAG/SWD CLK.TTLIPC0 (3)A9SWCLK
JTAG TMS and SWDIO.TTLI/OPC1 (3)B9SWDIO
JTAG TDO and SWO.TTLOPC3 (3)A10SWO
JTAG/SWD CLK.TTLIPC0 (3)A9TCK
JTAG TDI.TTLIPC2 (3)B8TDI
JTAG TDO and SWO.TTLOPC3 (3)A10TDO
JTAG TMS and SWDIO.TTLIPC1 (3)B9TMS
5.3Functional Description
A high-level conceptual drawing of the JTAG module is shown in Figure 5-1 on page 70. The JTAG
module is composed of the Test Access Port (TAP) controller and serial shift chains with parallel
update registers. The TAP controller is a simple state machine controlled by the TCK and TMS inputs.
The current state of the TAP controller depends on the sequence of values captured on TMS at the
rising edge of TCK. The TAP controller determines when the serial shift chains capture new data,
shift data from TDI towards TDO, and update the parallel load registers. The current state of the
TAP controller also determines whether the Instruction Register (IR) chain or one of the Data Register
(DR) chains is being accessed.
The serial shift chains with parallel load registers are comprised of a single Instruction Register (IR)
chain and multiple Data Register (DR) chains. The current instruction loaded in the parallel load
register determines which DR chain is captured, shifted, or updated during the sequencing of the
TAP controller.
Some instructions, like EXTEST and INTEST, operate on data currently in a DR chain and do not
capture, shift, or update any of the chains. Instructions that are not implemented decode to the
BYPASS instruction to ensure that the serial path between TDI and TDO is always connected (see
Table 5-4 on page 77 for a list of implemented instructions).
See “JTAG and Boundary Scan” on page 774 for JTAG timing diagrams.
Note:Of all the possible reset sources, only Power-On reset (POR) and the assertion of the RST
input have any effect on the JTAG module. The pin configurations are reset by both the
RST input and POR, whereas the internal JTAG logic is only reset with POR. See “Reset
Sources” on page 82 for more information on reset.
5.3.1JTAG Interface Pins
The JTAG interface consists of four standard pins: TCK, TMS, TDI, and TDO. These pins and their
associated state after a power-on reset or reset caused by the RST input are given in Table 5-3.
Detailed information on each pin follows. Refer to “General-Purpose Input/Outputs (GPIOs)” on page
291 for information on how to reprogram the configuration of these pins.
Texas Instruments-Advance Information
71February 09, 2010
JTAG Interface
Table 5-3. JTAG Port Pins State after Power-On Reset or RST assertion
5.3.1.1Test Clock Input (TCK)
The TCK pin is the clock for the JTAG module. This clock is provided so the test logic can operate
independently of any other system clocks and to ensure that multiple JTAG TAP controllers that
are daisy-chained together can synchronously communicate serial test data between components.
During normal operation, TCK is driven by a free-running clock with a nominal 50% duty cycle. When
necessary, TCK can be stopped at 0 or 1 for extended periods of time. While TCK is stopped at 0
or 1, the state of the TAP controller does not change and data in the JTAG Instruction and Data
Registers is not lost.
By default, the internal pull-up resistor on the TCK pin is enabled after reset, assuring that no clocking
occurs if the pin is not driven from an external source. The internal pull-up and pull-down resistors
can be turned off to save internal power as long as the TCK pin is constantly being driven by an
external source (see page 321 and page 323).
Drive ValueDrive StrengthInternal Pull-DownInternal Pull-UpData DirectionPin Name
The TMS pin selects the next state of the JTAG TAP controller. TMS is sampled on the rising edge
of TCK. Depending on the current TAP state and the sampled value of TMS, the next state may be
entered. Because the TMS pin is sampled on the rising edge of TCK, the IEEE Standard 1149.1
expects the value on TMS to change on the falling edge of TCK.
Holding TMS high for five consecutive TCK cycles drives the TAP controller state machine to the
Test-Logic-Reset state. When the TAP controller enters the Test-Logic-Reset state, the JTAG
module and associated registers are reset to their default values. This procedure should be performed
to initialize the JTAG controller. The JTAG Test Access Port state machine can be seen in its entirety
in Figure 5-2 on page 73.
By default, the internal pull-up resistor on the TMS pin is enabled after reset. Changes to the pull-up
resistor settings on GPIO Port C should ensure that the internal pull-up resistor remains enabled
on PC1/TMS; otherwise JTAG communication could be lost (see page 321).
5.3.1.3Test Data Input (TDI)
The TDI pin provides a stream of serial information to the IR chain and the DR chains. TDI is
sampled on the rising edge of TCK and, depending on the current TAP state and the current
instruction, may present this data to the proper shift register chain. Because the TDI pin is sampled
on the rising edge of TCK, the IEEE Standard 1149.1 expects the value on TDI to change on the
falling edge of TCK.
By default, the internal pull-up resistor on the TDI pin is enabled after reset. Changes to the pull-up
resistor settings on GPIO Port C should ensure that the internal pull-up resistor remains enabled
on PC2/TDI; otherwise JTAG communication could be lost (see page 321).
5.3.1.4Test Data Output (TDO)
The TDO pin provides an output stream of serial information from the IR chain or the DR chains.
The value of TDO depends on the current TAP state, the current instruction, and the data in the
Texas Instruments-Advance Information
February 09, 201072
chain being accessed. In order to save power when the JTAG port is not being used, the TDO pin
Test Logic Reset
Run Test IdleSelect DR ScanSelect IR Scan
Capture DRCapture IR
Shift DRShift IR
Exit 1 DRExit 1 IR
Exit 2 DRExit 2 IR
Pause DRPause IR
Update DRUpdate IR
111
11
1
11
11
11
11
1100
00
00
00
00
00
00
0
0
is placed in an inactive drive state when not actively shifting out data. Because TDO can be connected
to the TDI of another controller in a daisy-chain configuration, the IEEE Standard 1149.1 expects
the value on TDO to change on the falling edge of TCK.
By default, the internal pull-up resistor on the TDO pin is enabled after reset, assuring that the pin
remains at a constant logic level when the JTAG port is not being used. The internal pull-up and
pull-down resistors can be turned off to save internal power if a High-Z output value is acceptable
during certain TAP controller states (see page 321 and page 323).
5.3.2JTAG TAP Controller
The JTAG TAP controller state machine is shown in Figure 5-2. The TAP controller state machine
is reset to the Test-Logic-Reset state on the assertion of a Power-On-Reset (POR). In order to reset
the JTAG module after the microcontroller has been powered on, the TMS input must be held HIGH
for five TCK clock cycles, resetting the TAP controller and all associated JTAG chains. Asserting
the correct sequence on the TMS pin allows the JTAG module to shift in new instructions, shift in
data, or idle during extended testing sequences. For detailed information on the function of the TAP
controller and the operations that occur in each state, please refer to IEEE Standard 1149.1.
Figure 5-2. Test Access Port State Machine
Stellaris® LM3S1R21 Microcontroller
5.3.3Shift Registers
The Shift Registers consist of a serial shift register chain and a parallel load register. The serial shift
register chain samples specific information during the TAP controller’s CAPTURE states and allows
Texas Instruments-Advance Information
73February 09, 2010
JTAG Interface
this information to be shifted out on TDOduring the TAP controller’s SHIFT states. While the sampled
data is being shifted out of the chain on TDO, new data is being shifted into the serial shift register
on TDI. This new data is stored in the parallel load register during the TAP controller’s UPDATE
states. Each of the shift registers is discussed in detail in “Register Descriptions” on page 77.
5.3.4Operational Considerations
Certain operational parameters must be considered when using the JTAG module. Because the
JTAG pins can be programmed to be GPIOs, board configuration and reset conditions on these
pins must be considered. In addition, because the JTAG module has integrated ARM Serial Wire
Debug, the method for switching between these two operational modes is described below.
5.3.4.1GPIO Functionality
When the microcontroller is reset with either a POR or RST, the JTAG/SWD port pins default to their
JTAG/SWD configurations. The default configuration includes enabling digital functionality (DEN[3:0]
set in the Port C GPIO Digital Enable (GPIODEN) register), enabling the pull-up resistors (PUE[3:0]
set in the Port C GPIO Pull-Up Select (GPIOPUR) register), disabling the pull-down resistors
(PDE[3:0] cleared in the Port C GPIO Pull-Down Select (GPIOPDR) register) and enabling the
alternate hardware function (AFSEL[3:0] set in the Port C GPIO Alternate Function Select(GPIOAFSEL) register) on the JTAG/SWD pins. See page 315, page 321, page 323, and page 326.
It is possible for software to configure these pins as GPIOs after reset by clearing AFSEL[3:0] in
the Port C GPIOAFSEL register. If the user does not require the JTAG/SWD port for debugging or
board-level testing, this provides four more GPIOs for use in the design.
Caution – It is possible to create a software sequence that prevents the debugger from connecting to
the Stellaris®microcontroller. If the program code loaded into ash immediately changes the JTAG
pins to their GPIO functionality, the debugger may not have enough time to connect and halt the
controller before the JTAG pin functionality switches. As a result, the debugger may be locked out of
the part. This issue can be avoided with a software routine that restores JTAG functionality based on
an external or software trigger.
The GPIO commit control registers provide a layer of protection against accidental programming of
critical hardware peripherals. Protection is currently provided for the NMI pin (PB7) and the four
JTAG/SWD pins (PC[3:0]). Writes to protected bits of the GPIO Alternate Function Select
(GPIOAFSEL) register (see page 315), GPIO Pull Up Select (GPIOPUR) register (see page 321),
GPIO Pull-Down Select (GPIOPDR) register (see page 323), and GPIO Digital Enable (GPIODEN)
register (see page 326) are not committed to storage unless the GPIO Lock (GPIOLOCK) register
(see page 328) has been unlocked and the appropriate bits of the GPIO Commit (GPIOCR) register
(see page 329) have been set.
5.3.4.2Communication with JTAG/SWD
Because the debug clock and the system clock can be running at different frequencies, care must
be taken to maintain reliable communication with the JTAG/SWD interface. In the Capture-DR state,
the result of the previous transaction, if any, is returned, together with a 3-bit ACK response. Software
should check the ACK response to see if the previous operation has completed before initiating a
new transaction. Alternatively, if the system clock is at least 8 times faster than the debug clock
(TCK or SWCLK), the previous operation has enough time to complete and the ACK bits do not have
to be checked.
Texas Instruments-Advance Information
February 09, 201074
5.3.4.3Recovering a "Locked" Microcontroller
Note:Performing the sequence below restores the nonvolatile registers discussed in “Nonvolatile
Register Programming” on page 204 to their factory default values. The mass erase of the
Flash memory caused by the sequence below occurs prior to the nonvolatile registers being
restored.
If software configures any of the JTAG/SWD pins as GPIO and loses the ability to communicate
with the debugger, there is a debug sequence that can be used to recover the microcontroller.
Performing a total of ten JTAG-to-SWD and SWD-to-JTAG switch sequences while holding the
microcontroller in reset mass erases the Flash memory. The sequence to recover the microcontroller
is:
1. Assert and hold the RST signal.
2. Perform steps 1 and 2 of the JTAG-to-SWD switch sequence on the section called “JTAG-to-SWD
Switching” on page 76.
3. Perform steps 1 and 2 of the SWD-to-JTAG switch sequence on the section called “SWD-to-JTAG
Switching” on page 76.
4. Perform steps 1 and 2 of the JTAG-to-SWD switch sequence.
Stellaris® LM3S1R21 Microcontroller
5. Perform steps 1 and 2 of the SWD-to-JTAG switch sequence.
6. Perform steps 1 and 2 of the JTAG-to-SWD switch sequence.
7. Perform steps 1 and 2 of the SWD-to-JTAG switch sequence.
8. Perform steps 1 and 2 of the JTAG-to-SWD switch sequence.
9. Perform steps 1 and 2 of the SWD-to-JTAG switch sequence.
10. Perform steps 1 and 2 of the JTAG-to-SWD switch sequence.
11. Perform steps 1 and 2 of the SWD-to-JTAG switch sequence.
12. Release the RST signal.
13. Wait 400 ms.
14. Power-cycle the microcontroller.
5.3.4.4ARM Serial Wire Debug (SWD)
In order to seamlessly integrate the ARM Serial Wire Debug (SWD) functionality, a serial-wire
debugger must be able to connect to the Cortex-M3 core without having to perform, or have any
knowledge of, JTAG cycles. This integration is accomplished with a SWD preamble that is issued
before the SWD session begins.
The switching preamble used to enable the SWD interface of the SWJ-DP module starts with the
TAP controller in the Test-Logic-Reset state. From here, the preamble sequences the TAP controller
through the following states: Run Test Idle, Select DR, Select IR, Test Logic Reset, Test Logic
Reset, Run Test Idle, Run Test Idle, Select DR, Select IR, Test Logic Reset, Test Logic Reset, Run
Test Idle, Run Test Idle, Select DR, Select IR, and Test Logic Reset states.
75February 09, 2010
Texas Instruments-Advance Information
JTAG Interface
Stepping through this sequence of the TAP state machine enables the SWD interface and disables
the JTAG interface. For more information on this operation and the SWD interface, see the ARM®Cortex™-M3 Technical Reference Manual and the ARM® CoreSight Technical Reference Manual.
Because this sequence is a valid series of JTAG operations that could be issued, the ARM JTAG
TAP controller is not fully compliant to the IEEE Standard 1149.1. This instance is the only one
where the ARM JTAG TAP controller does not meet full compliance with the specification. Due to
the low probability of this sequence occurring during normal operation of the TAP controller, it should
not affect normal performance of the JTAG interface.
JTAG-to-SWD Switching
To switch the operating mode of the Debug Access Port (DAP) from JTAG to SWD mode, the
external debug hardware must send the switching preamble to the microcontroller. The 16-bit TMS
command for switching to SWD mode is defined as b1110.0111.1001.1110, transmitted LSB first.
This command can also be represented as 0xE79E when transmitted LSB first. The complete switch
sequence should consist of the following transactions on the TCK/SWCLK and TMS/SWDIO signals:
1. Send at least 50 TCK/SWCLK cycles with TMS/SWDIO High to ensure that both JTAG and SWD
2. Send the 16-bit JTAG-to-SWD switch command, 0xE79E, on TMS.
are in their reset/idle states.
3. Send at least 50 TCK/SWCLKcycles with TMS/SWDIOHigh to ensure that if SWJ-DP was already
in SWD mode, the SWD goes into the line reset state before sending the switch sequence.
SWD-to-JTAG Switching
To switch the operating mode of the Debug Access Port (DAP) from SWD to JTAG mode, the
external debug hardware must send a switch command to the microcontroller. The 16-bit TMS
command for switching to JTAG mode is defined as b1110.0111.0011.1100, transmitted LSB first.
This command can also be represented as 0xE73C when transmitted LSB first. The complete switch
sequence should consist of the following transactions on the TCK/SWCLK and TMS/SWDIO signals:
1. Send at least 50 TCK/SWCLK cycles with TMS/SWDIO High to ensure that both JTAG and SWD
are in their reset/idle states.
2. Send the 16-bit SWD-to-JTAG switch command, 0xE73C, on TMS.
3. Send at least 50 TCK/SWCLKcycles with TMS/SWDIOHigh to ensure that if SWJ-DP was already
in JTAG mode, the JTAG goes into the Test Logic Reset state before sending the switch
sequence.
5.4Initialization and Configuration
After a Power-On-Reset or an external reset (RST), the JTAG pins are automatically configured for
JTAG communication. No user-defined initialization or configuration is needed. However, if the user
application changes these pins to their GPIO function, they must be configured back to their JTAG
functionality before JTAG communication can be restored. To return the pins to their JTAG functions,
enable the four JTAG pins (PC[3:0]) for their alternate function using the GPIOAFSEL register.
In addition to enabling the alternate functions, any other changes to the GPIO pad configurations
on the four JTAG pins (PC[3:0]) should be returned to their default settings.
Texas Instruments-Advance Information
February 09, 201076
5.5Register Descriptions
The registers in the JTAG TAP Controller or Shift Register chains are not memory mapped and are
not accessible through the on-chip Advanced Peripheral Bus (APB). Instead, the registers within
the JTAG controller are all accessed serially through the TAP Controller. These registers include
the Instruction Register and the six Data Registers.
5.5.1Instruction Register (IR)
The JTAG TAP Instruction Register (IR) is a four-bit serial scan chain connected between the JTAG
TDI and TDO pins with a parallel load register. When the TAP Controller is placed in the correct
states, bits can be shifted into the IR. Once these bits have been shifted into the chain and updated,
they are interpreted as the current instruction. The decode of the IR bits is shown in Table 5-4. A
detailed explanation of each instruction, along with its associated Data Register, follows.
Table 5-4. JTAG Instruction Register Commands
EXTEST0x0
INTEST0x1
SAMPLE / PRELOAD0x2
IDCODE0xE
ReservedAll Others
Stellaris® LM3S1R21 Microcontroller
DescriptionInstructionIR[3:0]
Drives the values preloaded into the Boundary Scan Chain by the
SAMPLE/PRELOAD instruction onto the pads.
Drives the values preloaded into the Boundary Scan Chain by the
SAMPLE/PRELOAD instruction into the controller.
Captures the current I/O values and shifts the sampled values out of the
Boundary Scan Chain while new preload data is shifted in.
Shifts data into the ARM Debug Port Abort Register.ABORT0x8
Shifts data into and out of the ARM DP Access Register.DPACC0xA
Shifts data into and out of the ARM AC Access Register.APACC0xB
Loads manufacturing information defined by the IEEE Standard 1149.1 into
the IDCODE chain and shifts it out.
Connects TDI to TDO through a single Shift Register chain.BYPASS0xF
Defaults to the BYPASS instruction to ensure that TDI is always connected
to TDO.
5.5.1.1EXTEST Instruction
The EXTEST instruction is not associated with its own Data Register chain. Instead, the EXTEST
instruction uses the data that has been preloaded into the Boundary Scan Data Register using the
SAMPLE/PRELOAD instruction. When the EXTEST instruction is present in the Instruction Register,
the preloaded data in the Boundary Scan Data Register associated with the outputs and output
enables are used to drive the GPIO pads rather than the signals coming from the core. With tests
that drive known values out of the controller, this instruction can be used to verify connectivity. While
the EXTEST instruction is present in the Instruction Register, the Boundary Scan Data Register can
be accessed to sample and shift out the current data and load new data into the Boundary Scan
Data Register.
5.5.1.2INTEST Instruction
The INTEST instruction is not associated with its own Data Register chain. Instead, the INTEST
instruction uses the data that has been preloaded into the Boundary Scan Data Register using the
SAMPLE/PRELOAD instruction. When the INTEST instruction is present in the Instruction Register,
the preloaded data in the Boundary Scan Data Register associated with the inputs are used to drive
the signals going into the core rather than the signals coming from the GPIO pads. With tests that
drive known values into the controller, this instruction can be used for testing. It is important to note
that although the RST input pin is on the Boundary Scan Data Register chain, it is only observable.
77February 09, 2010
Texas Instruments-Advance Information
JTAG Interface
While the INTEST instruction is present in the Instruction Register, the Boundary Scan Data Register
can be accessed to sample and shift out the current data and load new data into the Boundary Scan
Data Register.
5.5.1.3SAMPLE/PRELOAD Instruction
The SAMPLE/PRELOAD instruction connects the Boundary Scan Data Register chain between
TDI and TDO. This instruction samples the current state of the pad pins for observation and preloads
new test data. Each GPIO pad has an associated input, output, and output enable signal. When the
TAP controller enters the Capture DR state during this instruction, the input, output, and output-enable
signals to each of the GPIO pads are captured. These samples are serially shifted out on TDO while
the TAP controller is in the Shift DR state and can be used for observation or comparison in various
tests.
While these samples of the inputs, outputs, and output enables are being shifted out of the Boundary
Scan Data Register, new data is being shifted into the Boundary Scan Data Register from TDI.
Once the new data has been shifted into the Boundary Scan Data Register, the data is saved in the
parallel load registers when the TAP controller enters the Update DR state. This update of the
parallel load register preloads data into the Boundary Scan Data Register that is associated with
each input, output, and output enable. This preloaded data can be used with the EXTEST and
INTEST instructions to drive data into or out of the controller. See “Boundary Scan Data
Register” on page 79 for more information.
5.5.1.4ABORT Instruction
The ABORT instruction connects the associated ABORT Data Register chain between TDI and
TDO. This instruction provides read and write access to the ABORT Register of the ARM Debug
Access Port (DAP). Shifting the proper data into this Data Register clears various error bits or initiates
a DAP abort of a previous request. See the “ABORT Data Register” on page 80 for more information.
5.5.1.5DPACC Instruction
The DPACC instruction connects the associated DPACC Data Register chain between TDI and
TDO. This instruction provides read and write access to the DPACC Register of the ARM Debug
Access Port (DAP). Shifting the proper data into this register and reading the data output from this
register allows read and write access to the ARM debug and status registers. See “DPACC Data
Register” on page 80 for more information.
5.5.1.6APACC Instruction
The APACC instruction connects the associated APACC Data Register chain between TDI and
TDO. This instruction provides read and write access to the APACC Register of the ARM Debug
Access Port (DAP). Shifting the proper data into this register and reading the data output from this
register allows read and write access to internal components and buses through the Debug Port.
See “APACC Data Register” on page 80 for more information.
5.5.1.7IDCODE Instruction
The IDCODE instruction connects the associated IDCODE Data Register chain between TDI and
TDO. This instruction provides information on the manufacturer, part number, and version of the
ARM core. This information can be used by testing equipment and debuggers to automatically
configure input and output data streams. IDCODE is the default instruction loaded into the JTAG
Instruction Register when a Power-On-Reset (POR) is asserted, or the Test-Logic-Reset state is
entered. See “IDCODE Data Register” on page 79 for more information.
Texas Instruments-Advance Information
February 09, 201078
5.5.1.8BYPASS Instruction
VersionPart NumberManufacturer ID1
3128 2712 111 0
TDOTDI
0
TDO
TDI
0
The BYPASS instruction connects the associated BYPASS Data Register chain between TDI and
TDO. This instruction is used to create a minimum length serial path between the TDI and TDO ports.
The BYPASS Data Register is a single-bit shift register. This instruction improves test efficiency by
allowing components that are not needed for a specific test to be bypassed in the JTAG scan chain
by loading them with the BYPASS instruction. See “BYPASS Data Register” on page 79 for more
information.
5.5.2Data Registers
The JTAG module contains six Data Registers. These serial Data Register chains include: IDCODE,
BYPASS, Boundary Scan, APACC, DPACC, and ABORT and are discussed in the following sections.
5.5.2.1IDCODE Data Register
The format for the 32-bit IDCODE Data Register defined by the IEEE Standard 1149.1 is shown in
Figure 5-3. The standard requires that every JTAG-compliant microcontroller implement either the
IDCODE instruction or the BYPASS instruction as the default instruction. The LSB of the IDCODE
Data Register is defined to be a 1 to distinguish it from the BYPASS instruction, which has an LSB
of 0. This definition allows auto-configuration test tools to determine which instruction is the default
instruction.
Stellaris® LM3S1R21 Microcontroller
The major uses of the JTAG port are for manufacturer testing of component assembly and program
development and debug. To facilitate the use of auto-configuration debug tools, the IDCODE
instruction outputs a value of 0x4BA0.0477. This value allows the debuggers to automatically
configure themselves to work correctly with the Cortex-M3 during debug.
Figure 5-3. IDCODE Register Format
5.5.2.2BYPASS Data Register
The format for the 1-bit BYPASS Data Register defined by the IEEE Standard 1149.1 is shown in
Figure 5-4. The standard requires that every JTAG-compliant microcontroller implement either the
BYPASS instruction or the IDCODE instruction as the default instruction. The LSB of the BYPASS
Data Register is defined to be a 0 to distinguish it from the IDCODE instruction, which has an LSB
of 1. This definition allows auto-configuration test tools to determine which instruction is the default
instruction.
Figure 5-4. BYPASS Register Format
5.5.2.3Boundary Scan Data Register
The format of the Boundary Scan Data Register is shown in Figure 5-5. Each GPIO pin, starting
with a GPIO pin next to the JTAG port pins, is included in the Boundary Scan Data Register. Each
Texas Instruments-Advance Information
79February 09, 2010
I
N
TDI
1
st
GPIO
TDO
...
O
U
T
O
E
I
N
m
th
GPIO
O
U
T
O
E
I
N
(m+1)
th
GPIO
O
U
T
O
E
...
I
N
GPIO n
th
O
U
T
O
E
JTAG Interface
GPIO pin has three associated digital signals that are included in the chain. These signals are input,
output, and output enable, and are arranged in that order as shown in the figure.
When the Boundary Scan Data Register is accessed with the SAMPLE/PRELOAD instruction, the
input, output, and output enable from each digital pad are sampled and then shifted out of the chain
to be verified. The sampling of these values occurs on the rising edge of TCK in the Capture DR
state of the TAP controller. While the sampled data is being shifted out of the Boundary Scan chain
in the Shift DR state of the TAP controller, new data can be preloaded into the chain for use with
the EXTEST and INTEST instructions. The EXTEST instruction forces data out of the controller,
and the INTEST instruction forces data into the controller.
Figure 5-5. Boundary Scan Register Format
5.5.2.4APACC Data Register
The format for the 35-bit APACC Data Register defined by ARM is described in the ARM®
Cortex™-M3 Technical Reference Manual.
5.5.2.5DPACC Data Register
The format for the 35-bit DPACC Data Register defined by ARM is described in the ARM®
Cortex™-M3 Technical Reference Manual.
5.5.2.6ABORT Data Register
The format for the 35-bit ABORT Data Register defined by ARM is described in the ARM®
Cortex™-M3 Technical Reference Manual.
Texas Instruments-Advance Information
February 09, 201080
6System Control
System control configures the overall operation of the device and provides information about the
device. Configurable features include reset control, NMI operation, power control, clock control, and
low-power modes.
6.1Signal Description
Table 6-1 on page 81 and Table 6-2 on page 81 list the external signals of the System Control
module and describe the function of each. The NMI signal is the alternate function for the GPIO PB7
signal and functions as a GPIO after reset. PB7 is under commit protection and requires a special
process to be configured as the NMI signal or to subsequently return to the GPIO function, see
“Commit Control” on page 299. The column in the table below titled "Pin Mux/Pin Assignment" lists
the GPIO pin placement for the NMI signal. The AFSEL bit in the GPIO Alternate Function Select(GPIOAFSEL) register (page 315) should be set to choose the NMI function. The number in
parentheses is the encoding that must be programmed into the PMCn field in the GPIO Port Control(GPIOPCTL) register (page 333) to assign the NMI signal to the specified GPIO port pin. For more
information on configuring GPIOs, see “General-Purpose Input/Outputs (GPIOs)” on page 291. The
remaining signals (with the word "fixed" in the Pin Mux/Pin Assignment column) have a fixed pin
assignment and function.
Stellaris® LM3S1R21 Microcontroller
Table 6-1. Signals for System Control & Clocks (100LQFP)
Pin NumberPin Name
Assignment
a. The TTL designation indicates the pin has TTL-compatible voltage levels.
Pin TypePin Mux / Pin
Table 6-2. Signals for System Control & Clocks (108BGA)
Pin NumberPin Name
Assignment
a. The TTL designation indicates the pin has TTL-compatible voltage levels.
Pin TypePin Mux / Pin
6.2Functional Description
The System Control module provides the following capabilities:
a
DescriptionBuffer Type
Non-maskable interrupt.TTLIPB7 (4)89NMI
AnalogIfixed48OSC0
AnalogIfixedL11OSC0
Main oscillator crystal input or an external clock
reference input.
Main oscillator crystal output.AnalogOfixed49OSC1
System reset input.TTLIfixed64RST
a
DescriptionBuffer Type
Non-maskable interrupt.TTLIPB7 (4)A8NMI
Main oscillator crystal input or an external clock
reference input.
Main oscillator crystal output.AnalogOfixedM11OSC1
System reset input.TTLIfixedH11RST
■ Device identification, see “Device Identification” on page 82
■ Local control, such as reset (see “Reset Control” on page 82), power (see “Power
Control” on page 86) and clock control (see “Clock Control” on page 87)
Texas Instruments-Advance Information
81February 09, 2010
System Control
■ System control (Run, Sleep, and Deep-Sleep modes), see “System Control” on page 93
6.2.1Device Identification
Several read-only registers provide software with information on the microcontroller, such as version,
part number, SRAM size, Flash memory size, and other features. See the DID0 (page 97), DID1
(page 124), DC0-DC9 (page 126) and NVMSTAT (page 143) registers.
6.2.2Reset Control
This section discusses aspects of hardware functions during reset as well as system software
requirements following the reset sequence.
6.2.2.1Reset Sources
The LM3S1R21 microcontroller has six sources of reset:
1. Power-on reset (POR) (see page 82).
2. External reset input pin (RST) assertion (see page 83).
3. Internal brown-out (BOR) detector (see page 84).
4. Software-initiated reset (with the software reset registers) (see page 85).
5. A watchdog timer reset condition violation (see page 85).
6. MOSC failure (see page 86).
Table 6-3 provides a summary of results of the various reset operations.
a. By using the SYSRESETREQ bit in the ARM Cortex-M3 Application Interrupt and Reset Control register
b. Programmable on a module-by-module basis using the Software Reset Control Registers.
a
NoNoSoftware Peripheral Reset
YesNoYes
Yes
YesNoYesWatchdog Reset
YesNoYesMOSC Failure Reset
b
After a reset, the Reset Cause (RESC) register is set with the reset cause. The bits in this register
are sticky and maintain their state across multiple reset sequences, except when an internal POR
is the cause, in which case, all the bits in the RESC register are cleared except for the POR indicator.
A bit in the RESC register can be cleared by writing a 0.
6.2.2.2Power-On Reset (POR)
Note:The power-on reset also resets the JTAG controller. An external reset does not.
Texas Instruments-Advance Information
February 09, 201082
The internal Power-On Reset (POR) circuit monitors the power supply voltage (VDD) and generates
PU
RST
Stellaris®
R
VDD
a reset signal to all of the internal logic including JTAG when the power supply ramp reaches a
threshold value (VTH). The microcontroller must be operating within the specified operating parameters
when the on-chip power-on reset pulse is complete. The 3.3-V power supply to the microcontroller
must reach 3.0 V within 10 msec of VDDcrossing 2.0 V to guarantee proper operation. For applications
that require the use of an external reset signal to hold the microcontroller in reset longer than the
internal POR, the RST input may be used as discussed in “External RST Pin” on page 83.
The Power-On Reset sequence is as follows:
1. The microcontroller waits for internal POR to go inactive.
2. The internal reset is released and the core loads from memory the initial stack pointer, the initial
program counter, and the first instruction designated by the program counter, and then begins
execution.
The internal POR is only active on the initial power-up of the microcontroller. The Power-On Reset
timing is shown in Figure 22-5 on page 776.
6.2.2.3External RST Pin
Note:It is recommended that the trace for the RST signal must be kept as short as possible. Be
sure to place any components connected to the RST signal as close to the microcontroller
as possible.
Stellaris® LM3S1R21 Microcontroller
If the application only uses the internal POR circuit, the RST input must be connected to the power
supply (VDD) through an optional pull-up resistor (0 to 100K Ω) as shown in Figure 6-1 on page 83.
Figure 6-1. Basic RST Configuration
RPU= 0 to 100 kΩ
The external reset pin (RST) resets the microcontroller including the core and all the on-chip
peripherals except the JTAG TAP controller (see “JTAG Interface” on page 69). The external reset
sequence is as follows:
1. The external reset pin (RST) is asserted for the duration specified by T
and then de-asserted
MIN
(see “Reset” on page 775).
2. The internal reset is released and the core loads from memory the initial stack pointer, the initial
program counter, and the first instruction designated by the program counter, and then begins
execution.
To improve noise immunity and/or to delay reset at power up, the RST input may be connected to
an RC network as shown in Figure 6-2 on page 84.
Texas Instruments-Advance Information
83February 09, 2010
PU
C
1
RST
Stellaris®
R
VDD
PU
C
1
R
S
RST
Stellaris®
R
VDD
System Control
Figure 6-2. External Circuitry to Extend Power-On Reset
RPU= 1 kΩ to 100 kΩ
C1= 1 nF to 10 µF
If the application requires the use of an external reset switch, Figure 6-3 on page 84 shows the
proper circuitry to use.
Figure 6-3. Reset Circuit Controlled by Switch
Typical RPU= 10 kΩ
Typical RS= 470 Ω
C1= 10 nF
The RPUand C1components define the power-on delay.
The external reset timing is shown in Figure 22-4 on page 775.
6.2.2.4Brown-Out Reset (BOR)
The microcontroller provides a brown-out detection circuit that triggers if the power supply (VDD)
drops below a brown-out threshold voltage (V
may generate an interrupt or a system reset. The default condition is to generate an interrupt, so
BOR must be enabled. Brown-out resets are controlled with the Power-On and Brown-Out ResetControl (PBORCTL) register. The BORIOR bit in the PBORCTL register must be set for a brown-out
condition to trigger a reset; if BORIOR is clear, an interrupt is generated. When a Brown-out condition
occurs during a Flash PROGRAM or ERASE operation, a full system reset is always triggered
without regard to the setting in the PBORCTL register.
The brown-out reset sequence is as follows:
1. When VDDdrops below V
Texas Instruments-Advance Information
). If a brown-out condition is detected, the system
BTH
, an internal BOR condition is set.
BTH
February 09, 201084
2. If the BOR condition exists, an internal reset is asserted.
3. The internal reset is released and the microcontroller fetches and loads the initial stack pointer,
the initial program counter, the first instruction designated by the program counter, and begins
execution.
4. The internal BOR condition is reset after 500 µs to prevent another BOR condition from being
set before software has a chance to investigate the original cause.
The result of a brown-out reset is equivalent to that of an assertion of the external RST input, and
the reset is held active until the proper VDDlevel is restored. The RESC register can be examined
in the reset interrupt handler to determine if a Brown-Out condition was the cause of the reset, thus
allowing software to determine what actions are required to recover.
The internal Brown-Out Reset timing is shown in Figure 22-6 on page 776.
6.2.2.5Software Reset
Software can reset a specific peripheral or generate a reset to the entire microcontroller.
Peripherals can be individually reset by software via three registers that control reset signals to each
on-chip peripheral (see the SRCRn registers, page 165). If the bit position corresponding to a
peripheral is set and subsequently cleared, the peripheral is reset. The encoding of the reset registers
is consistent with the encoding of the clock gating control for peripherals and on-chip functions (see
“System Control” on page 93).
Stellaris® LM3S1R21 Microcontroller
The entire microcontroller including the core can be reset by software by setting the SYSRESETREQ
bit in the Cortex-M3 Application Interrupt and Reset Control register. The software-initiated system
reset sequence is as follows:
1. A software microcontroller reset is initiated by setting the SYSRESETREQ bit in the ARM
Cortex-M3 Application Interrupt and Reset Control register.
2. An internal reset is asserted.
3. The internal reset is deasserted and the microcontroller loads from memory the initial stack
pointer, the initial program counter, and the first instruction designated by the program counter,
and then begins execution.
The software-initiated system reset timing is shown in Figure 22-7 on page 776.
6.2.2.6Watchdog Timer Reset
The Watchdog Timer module's function is to prevent system hangs. The LM3S1R21 microcontroller
has two Watchdog Timer modules in case one watchdog clock source fails. One watchdog is run
off the system clock and the other is run off the Precision Internal Oscillator (PIOSC). Each module
operates in the same manner except that because the PIOSC watchdog timer module is in a different
clock domain, register accesses must have a time delay between them. The watchdog timer can
be configured to generate an interrupt to the microcontroller on its first time-out and to generate a
reset on its second time-out.
After the watchdog's first time-out event, the 32-bit watchdog counter is reloaded with the value of
the Watchdog Timer Load (WDTLOAD) register and resumes counting down from that value. If
the timer counts down to zero again before the first time-out interrupt is cleared, and the reset signal
has been enabled, the watchdog timer asserts its reset signal to the microcontroller. The watchdog
timer reset sequence is as follows:
Texas Instruments-Advance Information
85February 09, 2010
System Control
1. The watchdog timer times out for the second time without being serviced.
2. An internal reset is asserted.
3. The internal reset is released and the microcontroller loads from memory the initial stack pointer,
the initial program counter, and the first instruction designated by the program counter, and
then begins execution.
For more information on the Watchdog Timer module, see “Watchdog Timers” on page 466.
The watchdog reset timing is shown in Figure 22-8 on page 776.
6.2.3Non-Maskable Interrupt
The microcontroller has three sources of non-maskable interrupt (NMI):
■ The assertion of the NMI signal
■ A main oscillator verification error
■ The NMISET bit in the Interrupt Control and Status (ICSR) register in the Cortex-M3.
Software must check the cause of the interrupt in order to distinguish among the sources.
6.2.3.1NMI Pin
The alternate function to GPIO port pin B7 is an NMI signal. The alternate function must be enabled
in the GPIO for the signal to be used as an interrupt, as described in “General-Purpose Input/Outputs
(GPIOs)” on page 291. Note that enabling the NMI alternate function requires the use of the GPIO
lock and commit function just like the GPIO port pins associated with JTAG/SWD functionality, see
page 329. The active sense of the NMI signal is High; asserting the enabled NMI signal above V
initiates the NMI interrupt sequence.
6.2.3.2Main Oscillator Verification Failure
The LM3S1R21 microcontroller provides a main oscillator verification circuit that generates an error
condition if the oscillator is running too fast or two slow. The main oscillator verification circuit can
be programmed to generate a reset event, at which time a Power-on Reset is generated and control
is transferred to the NMI handler. The NMI handler is used to address the main oscillator verification
failure because the necessary code can be removed from the general reset handler, speeding up
reset processing. The detection circuit is enabled by setting the CVAL bit in the Main OscillatorControl (MOSCCTL) register. The main oscillator verification error is indicated in the main oscillator
fail status (MOSCFAIL) bit in the Reset Cause (RESC) register. The main oscillator verification circuit
action is described in more detail in “Main Oscillator Verification Circuit” on page 93.
6.2.4Power Control
The Stellaris®microcontroller provides an integrated LDO regulator that is used to provide power
to the majority of the microcontroller's internal logic. For power reduction, a non-programmable LDO
may be used to scale the microcontroller’s 3.3 V input voltage to 1.2V. The voltage output has a
minimum voltage of 1.08 V and a maximum of 1.35 V. The LDO delivers up to 60 ma.
IH
Figure 6-4 shows the power architecture.
Note:On the printed circuit board, use the LDO output as the source of VDDC input. In addition,
the LDO requires decoupling capacitors. See “On-Chip Low Drop-Out (LDO) Regulator
Characteristics” on page 769.
February 09, 201086
Texas Instruments-Advance Information
Figure 6-4. Power Architecture
Analog Circuits
(ADC, Analog
Comparators)
I/O Buffers
Low-Noise
LDO
Internal
Logic and PLL
GND
GNDA
GNDA
VDDA
VDDA
VDDC
VDDC
LDO
+3.3V
GND
GND
GND
VDD
VDD
Stellaris® LM3S1R21 Microcontroller
6.2.5Clock Control
System control determines the control of clocks in this part.
6.2.5.1Fundamental Clock Sources
There are multiple clock sources for use in the microcontroller:
■ Precision Internal Oscillator (PIOSC). The precision internal oscillator is an on-chip clock
source that is the clock source the microcontroller uses during and following POR. It does not
require the use of any external components and provides a clock that is 16 MHz ±1% at room
temperature and ±3% across temperature. The PIOSC allows for a reduced system cost in
applications that require an accurate clock source. If the main oscillator is required, software
must enable the main oscillator following reset and allow the main oscillator to stabilize before
changing the clock reference. If the Hibernation Module clock source is a 32.768-kHz oscillator,
the precision internal oscillator can be trimmed by software based on a reference clock for
increased accuracy.
■ Main Oscillator (MOSC). The main oscillator provides a frequency-accurate clock source by
one of two means: an external single-ended clock source is connected to the OSC0 input pin, or
an external crystal is connected across the OSC0 input and OSC1 output pins. If the PLL is being
used, the crystal value must be one of the supported frequencies between 3.579545 MHz through
Texas Instruments-Advance Information
87February 09, 2010
System Control
■ Internal 30-kHz Oscillator. The internal 30-kHz oscillator provides an operational frequency of
■ Hibernation Module Clock Source. The Hibernation module can be clocked in one of two ways.
The internal system clock (SysClk), is derived from any of the above sources plus two others: the
output of the main internal PLL and the precision internal oscillator divided by four (4 MHz ± 1%).
The frequency of the PLL clock reference must be in the range of 3.579545 MHz to 16.384 MHz
(inclusive). Table 6-4 on page 88 shows how the various clock sources can be used in a system.
16.384 MHz (inclusive). If the PLL is not being used, the crystal may be any one of the supported
frequencies between 1 MHz and 16.384 MHz. The single-ended clock source range is from DC
through the specified speed of the microcontroller. The supported crystals are listed in the XTAL
bit field in the RCC register (see page 108).
30 kHz ± 50%. It is intended for use during Deep-Sleep power-saving modes. This power-savings
mode benefits from reduced internal switching and also allows the MOSC and PIOSC to be
powered down.
The first way is a 4.194304-MHz crystal connected to the XOSC0 and XOSC1 pins. This clock
signal is divided by 128 internally to produce the 32.768-kHz clock reference. The second way
is a 32.768-kHz oscillator connected to the XOSC0 pin. The clock source for the Hibernation
module can be used for the system clock, thus eliminating the need for an additional crystal or
oscillator. In addition, a 4.194304-MHz crystal can also be a source for the PLL. The Hibernation
module clock source is intended to provide the system with a real-time clock source and may
also provide an accurate source of Deep-Sleep or Hibernate mode power savings.
Table 6-4. Clock Source Options
by 4 (4 MHz ± 1%)
Crystal
Oscillator
6.2.5.2Clock Configuration
The Run-Mode Clock Configuration (RCC) and Run-Mode Clock Configuration 2 (RCC2)
registers provide control for the system clock. The RCC2 register is provided to extend fields that
offer additional encodings over the RCC register. When used, the RCC2 register field values are
used by the logic over the corresponding field in the RCC register. In particular, RCC2 provides for
a larger assortment of clock configuration options. These registers control the following clock
functionality:
■ System clock derived from PLL or other clock source
■ Enabling/disabling of oscillators and PLL
Texas Instruments-Advance Information
February 09, 201088
■ Clock divisors
Main OSC
Precision
Internal OSC
(16 MHz)
Internal OSC
(30 kHz)
÷ 4
÷ 25
PWRDN
ADC Clock
System Clock
MOSCDIS
a
IOSCDIS
a
SYSDIV
e
USESYSDIV
a,d
PWMDW
a
USEPWMDIV
a
PWM Clock
Hibernation
OSC
OSCSRC
b,d
BYPASS
b,d
XTAL
a
PWRDN
b
÷ 2
f
USB PLL
(240 MHz)
÷ 4
USB Clock
XTAL
a
USBPWRDN
c
RXINT
RXFRAC
I
2
S Receive MCLK
I
2
S Transmit MCLK
PLL
(400 MHz)
TXINT
TXFRAC
a. Control provided by RCC register bit/field.
b. Control provided by RCC register bit/field or RCC2 register bit/field, if overridden with RCC2 register bit USERCC2.
c. Control provided by RCC2 register bit/field.
d. Also may be controlled by DSLPCLKCFG when in deep sleep mode.
e. Control provided by RCC register SYSDIV field, RCC2 register SYSDIV2 field if overridden with USERCC2 bit, or
[SYSDIV2,SYSDIV2LSB] if both USERCC2 and DIV400 bits are set.
f. Only a 4.194304-Mhz crystal can be used to drive the PLL.
DIV400
c
■ Crystal input selection
Figure 6-5 shows the logic for the main clock tree. The peripheral blocks are driven by the system
clock signal and can be individually enabled/disabled. The ADC clock signal is automatically divided
down to 16 MHz for proper ADC operation.
Note:When the ADC module is in operation, the system clock must be at least 16 MHz.
Figure 6-5. Main Clock Tree
Stellaris® LM3S1R21 Microcontroller
Note:The figure above shows all features available on all Stellaris® Tempest-class microcontrollers.
Texas Instruments-Advance Information
89February 09, 2010
System Control
In the RCC register, the SYSDIV field specifies which divisor is used to generate the system clock
from either the PLL output or the oscillator source (depending on how the BYPASS bit in this register
is configured). When using the PLL, the VCO frequency of 400 MHz is predivided by 2 before the
divisor is applied. Table 6-5 shows how the SYSDIV encoding affects the system clock frequency,
depending on whether the PLL is used (BYPASS=0) or another clock source is used (BYPASS=1).
The divisor is equivalent to the SYSDIV encoding plus 1. For a list of possible clock sources, see
Table 6-4 on page 88.
Table 6-5. Possible System Clock Frequencies Using the SYSDIV Field
a. This parameter is used in functions such as SysCtlClockSet() in the Stellaris Peripheral Driver Library.
Frequency (BYPASS=1)Frequency (BYPASS=0)DivisorSYSDIV
The SYSDIV2 field in the RCC2 register is 2 bits wider than the SYSDIV field in the RCC register
so that additional larger divisors up to /64 are possible, allowing a lower system clock frequency for
improved Deep Sleep power consumption. When using the PLL, the VCO frequency of 400 MHz is
predivided by 2 before the divisor is applied. The divisor is equivalent to the SYSDIV2 encoding
plus 1. Table 6-6 shows how the SYSDIV2 encoding affects the system clock frequency, depending
on whether the PLL is used (BYPASS2=0) or another clock source is used (BYPASS2=1). For a list
of possible clock sources, see Table 6-4 on page 88.
Table 6-6. Examples of Possible System Clock Frequencies Using the SYSDIV2 Field
To allow for additional frequency choices when using the PLL, the DIV400 bit is provided along
with the SYSDIV2LSB bit. When the DIV400 bit is set, bit 22 becomes the LSB for SYSDIV2. In
this situation, the divisor is equivalent to the (SYSDIV2 encoding with SYSDIV2LSB appended) plus
one. When the DIV400 bit is clear, SYSDIV2LSB is ignored, and the system clock frequency is
determined as shown in Table 6-6 on page 90. Care must be taken when using these frequency
choices with StellarisWare DriverLib API functions. see Table 6-7.
Table 6-7. Examples of Possible System Clock Frequencies with DIV400=1
a
DivisorSYSDIV2LSBSYSDIV2
a. Note that DIV400 and SYSDIV2LSB are only valid when BYPASS2=0.
b. This parameter is used in functions such as SysCtlClockSet() in the Stellaris Peripheral Driver Library.
The microcontroller powers up with the PIOSC running. If another clock source is desired, the PIOSC
can be powered down by setting the IOSCDIS bit in the RCC register.
The PIOSC generates a 16 MHz clock with a ±1% accuracy at room temperatures. Across the
extended temperature range, the accuracy is ±3%. At the factory, the PIOSC is set to 16 MHz at
room temperature, however, the frequency can be trimmed for other voltage or temperature conditions
using software in one of three ways:
■ Default calibration: clear the UTENbit and set the UPDATE bit in the Precision Internal OscillatorCalibration (PIOSCCAL) register.
■ User-defined calibration: The user can program the UT value to adjust the PIOSC frequency. As
the UT value increases, the generated period increases. To commit a new UT value, first set the
UTEN bit, then program the UT field, and then set the UPDATE bit. The adjustment finishes within
a few clock periods and is glitch free.
Texas Instruments-Advance Information
91February 09, 2010
System Control
■ Automatic calibration using the enable 32.768-kHz oscillator from the Hibernation module: set
the CAL bit; the results of the calibration are shown in the RESULT field in the Precision InternalOscillator Statistic (PIOSCSTAT) register. After calibration is complete, the PIOSC is trimmed
using trimmed value returned in the CT field.
6.2.5.4Crystal Configuration for the Main Oscillator (MOSC)
The main oscillator supports the use of a select number of crystals. If the main oscillator is used by
the PLL as a reference clock, the supported range of crystals is 3.579545 to 16.384 MHz, otherwise,
the range of supported crystals is 1 to 16.384 MHz.
The XTALbit in the RCC register (see page 108) describes the available crystal choices and default
programming values.
Software configures the RCC register XTAL field with the crystal number. If the PLL is used in the
design, the XTAL field value is internally translated to the PLL settings.
6.2.5.5Main PLL Frequency Configuration
The main PLL is disabled by default during power-on reset and is enabled later by software if
required. Software specifies the output divisor to set the system clock frequency and enables the
main PLL to drive the output. The PLL operates at 400 MHz, but is divided by two prior to the
application of the output divisor.
To configure the PIOSC to be the clock source for the main PLL, program the OSCRC2 field in the
Run-Mode Clock Configuration 2 (RCC2) register to be 0x1.
If the main oscillator provides the clock reference to the main PLL, the translation provided by
hardware and used to program the PLL is available for software in the XTAL to PLL Translation(PLLCFG) register (see page 112). The internal translation provides a translation within ± 1% of the
targeted PLL VCO frequency. Table 22-9 on page 772 shows the actual PLL frequency and error for
a given crystal choice.
To configure the Hibernation module 4.194304-MHz crystal as the PLL input reference, program
the OSCSRC2 field in the Run-Mode Clock Configuration 2 (RCC2) register to be 0x6.
The Crystal Value field (XTAL) in the Run-Mode Clock Configuration (RCC) register (see page 108)
describes the available crystal choices and default programming of the PLLCFG register. Any time
the XTAL field changes, the new settings are translated and the internal PLL settings are updated.
6.2.5.6PLL Modes
two modes of operation: Normal and Power-Down
■ Normal: The PLL multiplies the input clock reference and drives the output.
■ Power-Down: Most of the PLL internal circuitry is disabled and the PLL does not drive the output.
The modes are programmed using the RCC/RCC2 register fields (see page 108 and page 115).
6.2.5.7PLL Operation
If a PLL configuration is changed, the PLL output frequency is unstable until it reconverges (relocks)
to the new setting. The time between the configuration change and relock is T
READY
(see Table
22-8 on page 771). During the relock time, the affected PLL is not usable as a clock reference.
PLL is changed by one of the following:
■ Change to the XTAL value in the RCC register—writes of the same value do not cause a relock.
February 09, 201092
Texas Instruments-Advance Information
■ Change in the PLL from Power-Down to Normal mode.
Stellaris® LM3S1R21 Microcontroller
A counter is defined to measure the T
READY
oscillator. The range of the main oscillator has been taken into account and the down counter is set
to 0x1200 (that is, ~600 μs at an 8.192 MHz external oscillator clock). When the XTAL value is
greater than 0x0F, the down counter is set to 0x2400 to maintain the required lock time on higher
frequency crystal inputs. Hardware is provided to keep the PLL from being used as a system clock
until the T
condition is met after one of the two changes above. It is the user's responsibility
READY
to have a stable clock source (like the main oscillator) before the RCC/RCC2 register is switched
to use the PLL.
If the main PLL is enabled and the system clock is switched to use the PLL in one step, the system
control hardware continues to clock the microcontroller from the oscillator selected by the RCC/RCC2
register until the main PLL is stable (T
READY
can use many methods to ensure that the system is clocked from the main PLL, including periodically
polling the PLLLRIS bit in the Raw Interrupt Status (RIS) register, and enabling the PLL Lock
interrupt.
6.2.5.8Main Oscillator Verification Circuit
The clock control includes circuitry to ensure that the main oscillator is running at the appropriate
frequency. The circuit monitors the main oscillator frequency and signals if the frequency is outside
of the allowable band of attached crystals.
The detection circuit is enabled using the CVAL bit in the Main Oscillator Control (MOSCCTL)
register. If this circuit is enabled and detects an error, the following sequence is performed by the
hardware:
requirement. The counter is clocked by the main
time met), after which it changes to the PLL. Software
1. The MOSCFAIL bit in the Reset Cause (RESC) register is set.
2. If the internal oscillator (PIOSC) is disabled, it is enabled.
3. The system clock is switched from the main oscillator to the PIOSC.
4. An internal power-on reset is initiated that lasts for 32 PIOSC periods.
5. Reset is de-asserted and the processor is directed to the NMI handler during the reset sequence.
6.2.6System Control
For power-savings purposes, the RCGCn, SCGCn, and DCGCn registers control the clock gating
logic for each peripheral or block in the system while the microcontroller is in Run, Sleep, and
Deep-Sleep mode, respectively. The DC1 , DC2 and DC4 registers act as a write mask for the
RCGCn , SCGCn, and DCGCn registers.
There are four levels of operation for the microcontroller defined as:
■ Run Mode. In Run mode, the microcontroller actively executes code. Run mode provides normal
operation of the processor and all of the peripherals that are currently enabled by the RCGCn
registers. The system clock can be any of the available clock sources including the PLL.
■ Sleep Mode. In Sleep mode, the clock frequency of the active peripherals is unchanged, but the
processor and the memory subsystem are not clocked and therefore no longer execute code.
Sleep mode is entered by the Cortex-M3 core executing a WFI (Wait for Interrupt) instruction.
Any properly configured interrupt event in the system brings the processor back into Run mode.
Texas Instruments-Advance Information
93February 09, 2010
System Control
■ Deep-Sleep Mode. In Deep-Sleep mode, the clock frequency of the active peripherals may
See the system control NVIC section of the ARM® Cortex™-M3 Technical Reference Manual
for more details.
Peripherals are clocked that are enabled in the SCGCn register when auto-clock gating is enabled
(see the RCC register) or the RCGCn register when the auto-clock gating is disabled. The system
clock has the same source and frequency as that during Run mode.
change (depending on the Run mode clock configuration) in addition to the processor clock being
stopped. An interrupt returns the microcontroller to Run mode from one of the sleep modes; the
sleep modes are entered on request from the code. Deep-Sleep mode is entered by first writing
the Deep Sleep Enable bit in the ARM Cortex-M3 NVIC system control register and then executing
a WFI instruction. Any properly configured interrupt event in the system brings the processor
back into Run mode. See the system control NVIC section of the ARM® Cortex™-M3 TechnicalReference Manual for more details.
The Cortex-M3 processor core and the memory subsystem are not clocked. Peripherals are
clocked that are enabled in the DCGCn register when auto-clock gating is enabled (see the RCC
register) or the RCGCn register when auto-clock gating is disabled. The system clock source is
specified in the DSLPCLKCFG register. When the DSLPCLKCFG register is used, the internal
oscillator source is powered up, if necessary, and other clocks are powered down. If the PLL is
running at the time of the WFI instruction, hardware powers the PLL down and overrides the
SYSDIV field of the active RCC/RCC2 register, to be determined by the DSDIVORIDE setting in
the DSLPCLKCFG register, up to /16 or /64 respectively. When the Deep-Sleep exit event
occurs, hardware brings the system clock back to the source and frequency it had at the onset
of Deep-Sleep mode before enabling the clocks that had been stopped during the Deep-Sleep
duration. If the PIOSC or the 4.194304-MHz Hibernation module clock source is used as the
PLL reference clock source, it may continue to provide the clock during Deep-Sleep. See page 119.
■ Hibernate Mode. In this mode, the power supplies are turned off to the main part of the
microcontroller and only the Hibernation module's circuitry is active. An external wake event or
RTC event is required to bring the microcontroller back to Run mode. The Cortex-M3 processor
and peripherals outside of the Hibernation module see a normal "power on" sequence and the
processor starts running code. Software can determine if the microcontroller has been restarted
from Hibernate mode by inspecting the Hibernation module registers.
Caution – If the Cortex-M3 Debug Access Port (DAP) has been enabled, and the device wakes from a
low power sleep or deep-sleep mode, the core may start executing code before all clocks to peripherals
have been restored to their run mode conguration. The DAP is usually enabled by software tools
accessing the JTAG or SWD interface when debugging or ash programming. If this condition occurs,
a Hard Fault is triggered when software accesses a peripheral with an invalid clock.
A software delay loop can be used at the beginning of the interrupt routine that is used to wake up a
system from a WFI (Wait For Interrupt) instruction. This stalls the execution of any code that accesses
a peripheral register that might cause a fault. This loop can be removed for production software as the
DAP is most likely not enabled during normal execution.
Because the DAP is disabled by default (power on reset), the user can also power cycle the device. The
DAP is not enabled unless it is enabled through the JTAG or SWD interface.
Texas Instruments-Advance Information
February 09, 201094
6.3Initialization and Configuration
The PLL is configured using direct register writes to the RCC/RCC2 register. If the RCC2 register
is being used, the USERCC2 bit must be set and the appropriate RCC2 bit/field is used. The steps
required to successfully change the PLL-based system clock are:
1. Bypass the PLL and system clock divider by setting the BYPASS bit and clearing the USESYS
bit in the RCC register, thereby configuring the microcontroller to run off a “raw” clock source
and allowing for the new PLL configuration to be validated before switching the system clock
to the PLL.
2. Select the crystal value (XTAL) and oscillator source (OSCSRC), and clear the PWRDN bit in
RCC/RCC2. Setting the XTAL field automatically pulls valid PLL configuration data for the
appropriate crystal, and clearing the PWRDN bit powers and enables the PLL and its output.
3. Select the desired system divider (SYSDIV) in RCC/RCC2 and set the USESYS bit in RCC. The
SYSDIV field determines the system frequency for the microcontroller.
4. Wait for the PLL to lock by polling the PLLLRIS bit in the Raw Interrupt Status (RIS) register.
5. Enable use of the PLL by clearing the BYPASS bit in RCC/RCC2.
Stellaris® LM3S1R21 Microcontroller
6.4Register Map
Table 6-8 on page 95 lists the System Control registers, grouped by function. The offset listed is a
hexadecimal increment to the register’s address, relative to the System Control base address of
0x400F.E000.
Note:Spaces in the System Control register space that are not used are reserved for future or
internal use. Software should not modify any reserved memory address.
Additional Flash and ROM registers defined in the System Control register space are
described in the “Internal Memory” on page 199.
This register identifies the version of the microcontroller.
Device Identification 0 (DID0)
Base 0x400F.E000
Offset 0x000
Type RO, reset -
reserved
Stellaris® LM3S1R21 Microcontroller
16171819202122232425262728293031
CLASSreservedVER
ROROROROROROROROROROROROROROROROType
0010000000001000Reset
0123456789101112131415
MINORMAJOR
ROROROROROROROROROROROROROROROROType
----------------Reset
DescriptionResetTypeNameBit/Field
0ROreserved31
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
0x1ROVER30:28
DID0 Version
This field defines the DID0 register format version. The version number
is numeric. The value of the VER field is encoded as follows (all other
encodings are reserved):
DescriptionValue
Second version of the DID0 register format.0x1
0x0ROreserved27:24
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
0x04ROCLASS23:16
Device Class
The CLASS field value identifies the internal design from which all mask
sets are generated for all microcontrollers in a particular product line.
The CLASS field value is changed for new product lines, for changes in
fab process (for example, a remap or shrink), or any case where the
MAJOR or MINORfields require differentiation from prior microcontrollers.
The value of the CLASS field is encoded as follows (all other encodings
are reserved):
DescriptionValue
Stellaris® Tempest-class microcontrollers0x04
Texas Instruments-Advance Information
97February 09, 2010
System Control
DescriptionResetTypeNameBit/Field
-ROMAJOR15:8
-ROMINOR7:0
Major Revision
This field specifies the major revision number of the microcontroller.
The major revision reflects changes to base layers of the design. The
major revision number is indicated in the part number as a letter (A for
first revision, B for second, and so on). This field is encoded as follows:
DescriptionValue
Revision A (initial device)0x0
Revision B (first base layer revision)0x1
Revision C (second base layer revision)0x2
and so on.
Minor Revision
This field specifies the minor revision number of the microcontroller.
The minor revision reflects changes to the metal layers of the design.
The MINOR field value is reset when the MAJOR field is changed. This
field is numeric and is encoded as follows:
DescriptionValue
Initial device, or a major revision update.0x0
First metal layer change.0x1
Second metal layer change.0x2
and so on.
Texas Instruments-Advance Information
February 09, 201098
Register 2: Brown-Out Reset Control (PBORCTL), offset 0x030
This register is responsible for controlling reset conditions after initial power-on reset.
Brown-Out Reset Control (PBORCTL)
Base 0x400F.E000
Offset 0x030
Type R/W, reset 0x0000.7FFD
reserved
DescriptionResetTypeNameBit/Field
Stellaris® LM3S1R21 Microcontroller
16171819202122232425262728293031
ROROROROROROROROROROROROROROROROType
0000000000000000Reset
0123456789101112131415
BORIORreserved
reserved
ROR/WROROROROROROROROROROROROROROType
0000000000000000Reset
0x0000.000ROreserved31:2
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
0R/WBORIOR1
BOR Interrupt or Reset
DescriptionValue
A Brown Out Event causes an interrupt to be generated to the
0
interrupt controller.
A Brown Out Event causes a reset of the microcontroller.1
0ROreserved0
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
Texas Instruments-Advance Information
99February 09, 2010
System Control
Register 3: Raw Interrupt Status (RIS), offset 0x050
This register indicates the status for system control raw interrupts. An interrupt is sent to the interrupt
controller if the corresponding bit in the Interrupt Mask Control (IMC) register is set. Writing a 1
to the corresponding bit in the Masked Interrupt Status and Clear (MISC) register clears an interrupt
status bit.
Raw Interrupt Status (RIS)
Base 0x400F.E000
Offset 0x050
Type RO, reset 0x0000.0000
reserved
reserved
MOSCPUPRIS
DescriptionResetTypeNameBit/Field
reserved
16171819202122232425262728293031
ROROROROROROROROROROROROROROROROType
0000000000000000Reset
0123456789101112131415
BORRISreservedPLLLRIS
reserved
ROROROROROROROROROROROROROROROROType
0000000000000000Reset
0x0000.00ROreserved31:9
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
0ROMOSCPUPRIS8
MOSC Power Up Raw Interrupt Status
DescriptionValue
Sufficient time has passed for the MOSC to reach the expected
1
frequency. The value for this power-up time is indicated by
T
MOSC_SETTLE
Sufficient time has not passed for the MOSC to reach the
0
.
expected frequency.
This bit is cleared by writing a 1 to the MOSCPUPMIS bit in the MISC
register.
0ROreserved7
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
0ROPLLLRIS6
PLL Lock Raw Interrupt Status
DescriptionValue
The PLL timer has reached T
1
indicating that sufficient time
READY
has passed for the PLL to lock.
The PLL timer has not reached T
READY
.0
This bit is cleared by writing a 1 to the PLLLMIS bit in the MISC register.
0x0ROreserved5:2
Software should not rely on the value of a reserved bit. To provide
compatibility with future products, the value of a reserved bit should be
preserved across a read-modify-write operation.
Texas Instruments-Advance Information
February 09, 2010100
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.