The CC2540 and CC2541 are cost-effective, low-power, and true system-on-chip (SoC) solutions for
Bluetooth low energy applications. They enable robust BLE master or slave nodes to be built with very low
total bill-of-material costs. The CC2540 and CC2541 combine the excellent performance of a leading RF
transceiver with an industry-standard enhanced 8051 MCU, in-system programmable flash memory, 8-KB
RAM, and many other powerful supporting features and peripherals. The CC2540 and CC2541 are suited
for systems where very low power consumption is required. Very low-power sleep modes are available.
Short transition times between operating modes further enable low power consumption.
The CC2540 comes in two different versions: CC2540F128 and CC2540F256, with 128 KB and 256 KB of
flash memory, respectively.
The CC2541 comes in two different versions: CC2541F128 and CC2541F256, with 128 KB and 256 KB of
flash memory, respectively.
The CC2541F128/F256 comes in two different versions: CC2541F128/F256, with 128 and 256 KB of flash
memory, respectively.
Combined with the Bluetooth low-energy protocol stack from Texas Instruments, the
CC2540F128/CC2540F256 and CC2541F128/CC2541F256 constitute the market’s most comprehensive
single-mode Bluetooth low energy solution.
The CC253x System-on-Chip solution for 2.4 GHz is suitable for a wide range of applications. These can
easily be built on top of the IEEE 802.15.4 based standard protocols (RemoTI™ network protocol, TIMAC
software, and Z-Stack™ software for ZigBee®compliant solutions) or on top of the proprietary SimpliciTI™
network protocol. The usage is, however, not limited to these protocols alone. The CC253x family is, for
example, also suitable for 6LoWPAN and Wireless HART implementations.
Each chapter of this manual describes details of a module or peripheral; however, not all features are
present on all devices. To see the differences regarding features, see Table 0-1 in the Devices section.
For detailed technical numbers, such as power consumption and RF performance, see the device-specific
data sheet (Appendix C).
Preface
SWRU191F–April 2009–Revised April 2014
Read This First
Related Documentation and Software From Texas Instruments
Related documentation (for example, the CC2530 data sheet http://www-s.ti.com/sc/techlit/swrs081 and
CC2540 data sheet http://www-s.ti.com/sc/techlit/swrs084) can be found in Appendix C.
For more information regarding software that can be used with the CC253x, CC2540, or CC2541 Systemon-Chip solution (for example, SmartRF™ software for radio performance and functionality evaluation),
see Chapter 27, which also contains more information regarding the RemoTI network protocol, the
SimpliciTI network protocol, the TIMAC software, the Z-Stack software, and the BLE stack software.
SmartRF, RemoTI, SimpliciTI, Z-Stack are trademarks of Texas Instruments.
Bluetooth is a registered trademark of Bluetooth SIG, Inc.
Microsoft, Windows are trademarks of Microsoft Corporation.
ZigBee is a registered trademark of ZigBee Alliance.
14
Read This FirstSWRU191F–April 2009–Revised April 2014
This equipment generates, uses, and can radiate radio frequency energy and has not been tested for
compliance with the limits of computing devices pursuant to subpart J of part 15 of FCC rules, which are
designed to provide reasonable protection against radio frequency interference. Operation of this
equipment in other environments may cause interference with radio communications, in which case the
user at his own expense will be required to take whatever measures may be required to correct this
interference.
If You Need Assistance
All technical support is channeled through the TI Product Information Centers (PIC) - www.ti.com/support.
To send an E-mail request, please enter your contact information, along with your request at the following
link – PIC request form.
Also visit the Low Power RF, ZigBee, and Bluetooth low energy sections of the TI E2E Community
(www.ti.com/lprf-forum), where you can easily get in touch with other CC253x, CC2540, and CC2541
users and find FAQs, Design Notes, Application Notes, Videos, and so forth.
Glossary
Abbreviations used in this user guide can be found in Appendix A.
Devices
The CC253x System-on-Chip solution family consists of several devices. The following table provides a
device overview and points out the differences regarding memory sizes and peripherals. For a complete
feature list of any of the devices, see the corresponding data sheet (Appendix C).
Each SFR and XREG register is described in a separate table, where each table title contains the
following information in the format indicated:
For SFR registers: REGISTER NAME (SFR address) – register description
For XREG registers: REGISTER NAME (XDATA address) – register description
Each table has five columns to describe the different register fields as described in the following:
Column 1 – Bit: Denotes which bits of the register are described and addressed in the specific row
Column 2 – Name: Specific name of the register field
Column 3 – Reset: Reset or initial value of the register field
Column 4 – R/W: Key indicating the accessibility of the bits in the field (see Table 0-2 for more details)
Column 5 – Description: More details about the register field, and often a description of the functions of
the different values
In the register descriptions, each register field is shown with a symbol (R/W) indicating the access mode of
the register field. The register values are always given in binary notation unless prefixed by 0x, which
indicates hexadecimal notation.
www.ti.com
Table 0-2. Register Bit Conventions
SYMBOLACCESS MODE
R/WRead and write
RRead-only
R0Read as 0
R1Read as 1
WWrite-only
W0Write as 0
W1Write as 1
H0Hardware clear
H1Hardware set
16
Read This FirstSWRU191F–April 2009–Revised April 2014
As mentioned in the preface, the CC253x, CC2540, and CC2541 device family provides solutions for a
wide range of applications. In order to help the user to develop these applications, this user's guide
focuses on the usage of the different building blocks of the CC253x, CC2540, and CC2541 device family.
For detailed device descriptions, complete feature lists, and performance numbers, see the device-specific
data sheet (Appendix C).
In order to provide easy access to relevant information, the following subsections guide the reader to the
different chapters in this guide.
The block diagrams in Figure 1-1, Figure 1-2, and Figure 1-3 show the different building blocks of the
CC253x and, CC2540, and CC2541 devices. Not all features and functions of all modules or peripherals
are present on all devices of the CC253x, CC2540, and CC2541; hence, see the device-specific data
sheet for a device-specific block diagram.
www.ti.com
18
IntroductionSWRU191F–April 2009–Revised April 2014
The 8051 CPU core is a single-cycle 8051-compatible core. It has three different memory access buses
(SFR, DATA, and CODE/XDATA) with single-cycle access to SFR, DATA, and the main SRAM. It also
includes a debug interface and an 18-input extended interrupt unit. The detailed functionality of the CPU
and the memory is addressed in Chapter 2.
The interrupt controller services a total of 18 interrupt sources, divided into six interrupt groups, each of
which is associated with one of four interrupt priorities. Any interrupt service request is serviced also when
the device is in idle mode by going back to active mode. Some interrupts can also wake up the device
from sleep mode (when in sleep mode, the device is in one of the three low-power modes PM1, PM2, or
PM3); see Chapter 4 for more details.
The memory arbiter is at the heart of the system, as it connects the CPU and DMA controller with the
physical memories and all peripherals through the SFR bus. The memory arbiter has four memory access
points, access of which can map to one of three physical memories: SRAM, flash memory, and
XREG/SFR registers. The memory arbiter is responsible for performing arbitration and sequencing
between simultaneous memory accesses to the same physical memory.
The 4-, 6-, or 8-KB SRAM maps to the DATA memory space and to parts of the XDATA memory spaces.
The SRAM is an ultralow-power SRAM that retains its contents in all power modes. This is an important
feature for low-power applications.
The 32-, 64-, 96-, 128-, or 256-KB flash block provides in-circuit programmable non-volatile program
memory for the device, and maps into the CODE and XDATA memory spaces. In addition to holding
program code and constants, the non-volatile memory allows the application to save data that must be
preserved such that it is available after restarting the device. Using this feature one can, for example, use
saved network-specific data to avoid the need for a full start-up and network find-and-join process.
Overview
1.1.2 Clocks and Power Management
The digital core and peripherals are powered by a 1.8-V low-dropout voltage regulator (Chapter 26).
Additionally, the CC253x, CC2540, and CC2541 contain a power-management functionality that allows the
use of different low-power modes (PM1, PM2, and PM3) for low-power applications with a long battery life
(see Chapter 4 for more details). Five different reset sources exist to reset the device; see Chapter 5 for
more details.
1.1.3 Peripherals
The CC253x, CC2540, and CC2541 include many different peripherals that allow the application designer
to develop advanced applications. Not all peripherals are present on all devices. See Table 0-1 for a listing
of which peripherals are present on each device.
The debug interface (Chapter 3) implements a proprietary two-wire serial interface that is used for incircuit debugging. Through this debug interface, it is possible to perform an erasure of the entire flash
memory, control which oscillators are enabled, stop and start execution of the user program, execute
supplied instructions on the 8051 core, set code breakpoints, and single-step through instructions in the
code. Using these techniques, it is possible to perform in-circuit debugging and external flash
programming elegantly.
The device contains flash memory for storage of program code. The flash memory is programmable from
the user software and through the debug interface (as mentioned previously). The flash controller
(Chapter 6) handles writing and erasing the embedded flash memory. The flash controller allows pagewise erasure and 4-bytewise programming.
The I/O controller (Chapter 7) is responsible for all general-purpose I/O pins. The CPU can configure
whether peripheral modules control certain pins or whether they are under software control, and if so,
whether each pin is configured as an input or output and if a pullup or pulldown resistor in the pad is
connected. CPU interrupts can be enabled on each pin individually. Each peripheral that connects to the
I/O pins can choose between two different I/O pin locations to ensure flexibility in various applications.
SWRU191F–April 2009–Revised April 2014Introduction
A versatile five-channel DMA controller (Chapter 8) is available in the system, accesses memory using
the XDATA memory space, and thus has access to all physical memories. Each channel (trigger, priority,
transfer mode, addressing mode, source and destination pointers, and transfer count) is configured with
DMA descriptors anywhere in memory. Many of the hardware peripherals (AES core, flash controller,
USARTs, timers, ADC interface) achieve highly efficient operation by using the DMA controller for data
transfers between SFR or XREG addresses and flash or SRAM.
Timer 1 (Chapter 9) is a 16-bit timer with timer, counter, and PWM functionality. Timer 1 has a
programmable prescaler, a 16-bit period value, and five individually programmable counter or capture
channels, each with a 16-bit compare value. Each of the counter or capture channels can be used as a
PWM output or to capture the timing of edges on input signals. Timer 1 can also be configured in IR
generation mode, where it counts Timer 3 periods and the output is ANDed with the output of Timer 3 to
generate modulated consumer IR signals with minimal CPU interaction (see Section 9.9).
Timer 2 (MAC Timer) (Chapter 22) is specially designed for supporting an IEEE 802.15.4 MAC or other
time-slotted protocol in software. The timer has a configurable timer period and a 24-bit overflow counter
that can be used to keep track of the number of periods that have transpired. A 40-bit capture register is
also used to record the exact time at which a start-of-frame delimiter is received or transmitted, or the
exact time at which transmission ends, as well as two 16-bit output compare registers and two 24-bit
overflow compare registers that can send various command strobes (start RX, start TX, etc.) at specific
times to the radio modules.
Timer 3 and Timer 4 (Chapter 10) are 8-bit timers with timer, counter, and PWM functionality. They have
a programmable prescaler, an 8-bit period value, and one programmable counter channel with an 8-bit
compare value. Each of the counter channels can be used as a PWM output.
The Sleep Timer (Chapter 11) is an ultralow-power timer that counts 32-kHz crystal oscillator or 32-kHz
RC oscillator periods. The Sleep Timer runs continuously in all operating modes except power mode 3
(PM3). Typical applications of this timer are as a real-time counter or as a wake-up timer for coming out of
power mode 1 (PM1) or power mode 2 (PM2).
The ADC (Chapter 12) supports 7 bits (30-kHz bandwidth) to 12 bits (4-kHz bandwidth) of resolution. DC
and audio conversions with up to eight input channels (Port 0) are possible. The inputs can be selected as
single-ended or differential. The reference voltage can be internal, AVDD, or a single-ended or differential
external signal. The ADC also has a temperature-sensor input channel. The ADC can automate the
process of periodic sampling or conversion over a sequence of channels.
The battery monitor (Chapter 13) (CC2533 only) enables simple voltage monitoring in devices that do
not include an ADC. It is designed such that it is accurate in the voltage areas around 2 V, with lower
resolution at higher voltages.
The random-number generator (Chapter 14) uses a 16-bit LFSR to generate pseudorandom numbers,
which can be read by the CPU or used directly by the command strobe processor. The random-number
generator can be seeded with random data from noise in the radio ADC.
The AES coprocessor (Chapter 15) allows the user to encrypt and decrypt data using the AES algorithm
with 128-bit keys. The core is able to support the security operations required by IEEE 802.15.4 MAC
security, the ZigBee network layer, and the application layer.
A built-in Watchdog Timer (Chapter 16) allows the device to reset itself in case the firmware hangs.
When enabled by software, the Watchdog Timer must be cleared periodically; otherwise, it resets the
device when it times out. It can alternatively be configured for use as a general 32-kHz timer.
USART 0 and USART 1 (Chapter 18) are each configurable as either a SPI master or slave or as a
UART. They provide double buffering on both RX and TX and hardware flow control, and are thus well
suited to high-throughput full-duplex applications. Each has its own high-precision baud-rate generator,
thus leaving the ordinary timers free for other uses.
The I2C module (Chapter 20) (CC2533 and CC2541) provides a digital peripheral connection with two pins
and supports both master and slave operation.
The USB 2.0 controller (Chapter 21) (CC2531 and CC2540) operates at Full-Speed, 12 Mbps transfer
rate. The controller has five bidirectional endpoints in addition to control endpoint 0. The endpoints support
bulk, Interrupt, and Isochronous operation for implementation of a wide range of applications. The 1024
bytes of dedicated, flexible FIFO memory combined with DMA access ensures that a minimum of CPU
involvement is needed for USB communication.
22
IntroductionSWRU191F–April 2009–Revised April 2014
The operational amplifier (Chapter 18) (CC2530, CC2531, and CC2540) is intended to provide front-end
buffering and gain for the ADC. Both the inputs as well as the output are available on pins, so the
feedback network is fully customizable. A chopper-stabilized mode is available for applications that need
good accuracy with high gain.
The ultralow-power analog comparator (Chapter 19) (CC2530, CC2531, CC2540, and CC2541) enables
applications to wake up from PM2 or PM3 based on an analog signal. Both inputs are brought out to pins;
the reference voltage must be provided externally. The comparator output is mapped into the digital I/O
port and can be treated by the MCU as a regular digital input.
1.1.4 Radio
The CC2540 and CC2541 provide a Bluetooth low energy-compliant radio transceiver. The RF core which
controls the analog and digital radio modules is only indirectly accessible through API commands to the
BLE stack. More details about the CC2540 or CC2541 BLE radio can be found in Chapter 24. The
CC2541 can also be run in proprietary modes; more details can be found in Chapter 25.
The CC253x device family provides an IEEE 802.15.4-compliant radio transceiver. The RF core
controls the analog radio modules. In addition, it provides an interface between the MCU and the radio
which makes it possible to issue commands, read status, and automate and sequence radio events. The
radio also includes a packet-filtering and address-recognition module. More details about the CC253x
radio can be found in Chapter 23.
1.2Applications
As shown in the overview (Section 1.1), this user's guide focuses on the functionality of the different
modules that are available to build different types of applications based on the CC253x,CC2540, and
CC2541 device family. When looking at the complete application development process, additional
information is useful. However, as this information and help is not device-specific (that is, not unique for
the CC253x, CC2540, and 41 device family), see the additional information sources in the following
paragraphs.
The first step is to set up the development environment (hardware, tools, and so forth) by purchasing a
development kit (see the device-specific product Web site to find links to the relevant development kits).
The development kits come with an out-of-the-box demonstration and information on how to set up the
development environment; install required drivers (done easily by installing the SmartRF software,
Section 27.1), set up the compiler tool chain, and so forth. As soon as one has installed the development
environment, one is ready to start the application development.
The easiest way to write the application software is to base the application on one of the available
standard protocols (RemoTI network protocol, Section 27.2; TIMAC software, Section 27.4; Z-Stack
software for ZigBee-compliant solutions, Section 27.5); BLE stack software for Bluetooth low energycompliant solutions Section 27.6; or the proprietary SimpliciTI network protocol, Section 27.3. They all
come with several sample applications.
For the hardware layout design of the user-specific hardware, the designer can find reference designs on
the different product pages (Section B.1). By copying these designs, the designer achieves optimal
performance. The developed hardware can then be tested easily using the SmartRF Studio software
(Section 27.1).
In case the final system should not have the expected performance, it is recommended to try out the
developed software on the development kit hardware and see how it works there. To check the userspecific hardware, it is a good first step to use SmartRF Studio software to compare the development kit
performance versus the user-specific hardware using the same settings.
The user can also find additional information and help by joining the Low-Power RF Online Community
(Section B.2) and by subscribing to the Low-Power RF eNewsletter (Section B.4).
To contact a third-party to help with development or to use modules, check out the Texas Instruments
Low-Power RF Developer Network (Section B.3).
Overview
SWRU191F–April 2009–Revised April 2014Introduction
The System-on-Chip solution is based on an enhanced 8051 core. More details regarding the core,
memory map, instruction set, and interrupts are described in the following subsections.
The enhanced 8051 core uses the standard 8051 instruction set. Instructions execute faster than the
standard 8051 due to the following:
•One clock per instruction cycle is used as opposed to 12 clocks per instruction cycle in the standard
8051.
•Wasted bus states are eliminated.
Because an instruction cycle is aligned with memory fetch when possible, most of the single-byte
instructions are performed in a single clock cycle. In addition to the speed improvement, the enhanced
8051 core also includes architectural enhancements:
•A second data pointer
•An extended 18-source interrupt unit
The 8051 core is object-code-compatible with the industry-standard 8051 microcontroller. That is, object
code compiled with an industry-standard 8051 compiler or assembler executes on the 8051 core and is
functionally equivalent. However, because the 8051 core uses a different instruction timing than many
other 8051 variants, existing code with timing loops may require modification. Also, because the peripheral
units such as timers and serial ports differ from those on other 8051 cores, code which includes
instructions using the peripheral-unit SFRs does not work correctly.
Flash prefetching is not enabled by default, but improves CPU performance by up to 33%. This is at the
expense of slightly increased power consumption, but in most cases improves energy consumption as it is
faster. Flash prefetching can be enabled in the FCTL register.
8051 CPU Introduction
2.2Memory
The 8051 CPU architecture has four different memory spaces. The 8051 has separate memory spaces for
program memory and data memory. The 8051 memory spaces are the following (see Section 2.2.1 and
Section 2.2.2 for details):
CODE. A read-only memory space for program memory. This memory space addresses 64 KB.
DATA. A read-or-write data memory space that can be directly or indirectly accessed by a single-cycle
CPU instruction. This memory space addresses 256 bytes. The lower 128 bytes of the DATA memory
space can be addressed either directly or indirectly, the upper 128 bytes only indirectly.
XDATA. A read-and-write data memory space, access to which usually requires 4–5 CPU instruction
cycles. This memory space addresses 64 KB. Access to XDATA memory is also slower than DATA
access, as the CODE and XDATA memory spaces share a common bus on the CPU core, and instruction
prefetch from CODE thus cannot be performed in parallel with XDATA accesses.
SFR. A read-or-write register memory space which can be directly accessed by a single CPU instruction.
This memory space consists of 128 bytes. For SFR registers whose address is divisible by eight, each bit
is also individually addressable.
The four different memory spaces are distinct in the 8051 architecture, but are partly overlapping in the
device to ease DMA transfers and hardware debugger operation.
How the different memory spaces are mapped onto the three physical memories (flash program memory,
SRAM, and memory-mapped registers) is described in Section 2.2.1 and Section 2.2.2.
2.2.1 Memory Map
The memory map differs from the standard 8051 memory map in two important aspects, as described in
the following paragraphs.
First, in order to allow the DMA controller access to all physical memory and thus allow DMA transfers
between the different 8051 memory spaces, parts of SFR and the DATA memory space are mapped into
the XDATA memory space (see Figure 2-1).
Second, two alternative schemes for CODE memory space mapping can be used. The first scheme is the
standard 8051 mapping where only the program memory (that is, flash memory) is mapped to CODE
memory space. This mapping is the default after a device reset and is shown in Figure 2-2.
The second scheme is used for executing code from SRAM. In this mode, the SRAM is mapped into the
region of 0x8000 through (0x8000 + SRAM_SIZE – 1). The map is shown in Figure 2-3. Executing code
from SRAM improves performance and reduces power consumption.
The upper 32 KB of XDATA is a read-only area called XBANK (see Figure 2-1). Any of the available 32
KB flash banks can be mapped in here. This gives software access to the whole flash memory. This area
is typically used to store additional constant data.
Details about mapping of all 8051 memory spaces are given in Section 2.2.2.
The memory map showing how the different physical memories are mapped into the CPU memory spaces
is given in Figure 2-1 through Figure 2-3. The number of available flash banks depends on the flash size
option.
26
Figure 2-1. XDATA Memory Space (Showing SFR and DATA Mapping)
Figure 2-2. CODE Memory SpaceFigure 2-3. CODE Memory Space for Running Code
From SRAM
XDATA memory space. The XDATA memory map is given in Figure 2-1.
The SRAM is mapped into address range of 0x0000 through (SRAM_SIZE – 1).
The XREG area is mapped into the 1 KB address range (0x6000–0x63FF). These registers are additional
registers, effectively extending the SFR register space. Some peripheral registers and most of the radio
control and data registers are mapped in here.
The SFR registers are mapped into address range (0x7080–0x70FF).
The flash information page (2 KB) is mapped into the address range (0x7800–0x7FFF). This is a read-only
area and contains various information about the device.
The upper 32 KB of the XDATA memory space (0x8000–0xFFFF) is a read-only flash code bank (XBANK)
and can be mapped to any of the available flash banks using the MEMCTR.XBANK[2:0] bits.
The mapping of flash memory, SRAM, and registers to XDATA allows the DMA controller and the CPU
access to all the physical memories in a single unified address space.
Writing to unimplemented areas in the memory map (shaded in the figure) has no effect. Reading from
unimplemented areas returns 0x00. Writes to read-only regions, that is, flash areas, are ignored.
CODE memory space. The CODE memory space is 64 KB and is divided into a common area
(0x0000–0x7FFF) and a bank area (0x8000–0xFFFF) as shown in Figure 2-2. The common area is
always mapped to the lower 32 KB of the physical flash memory (bank 0). The bank area can be mapped
to any of the available 32-KB flash banks (from 0 to 7). The number of available flash banks depends on
the flash size option. Use the flash-bank-select register, FMAP, to select the flash bank. On 32-KB
devices, no flash memory can be mapped into the bank area. Reads from this region return 0x00 on these
devices.
To allow program execution from SRAM, it is possible to map the available SRAM into the lower range of
the bank area from 0x8000 through (0x8000 + SRAM_SIZE – 1). The rest of of the currently selected bank
is still mapped into the address range from (0x8000 + SRAM_SIZE) through 0xFFFF). Set the
MEMCTR.XMAP bit to enable this feature.
DATA memory space. The 8-bit address range of DATA memory is mapped into the upper 256 bytes of
the SRAM, that is, the address range from (SRAM_SIZE – 256) through (SRAM_SIZE – 1).
SFR memory space. The 128-entry hardware register area is accessed through this memory space. The
SFR registers are also accessible through the XDATA address space at the address range
(0x7080–0x70FF). Some CPU-specific SFR registers reside inside the CPU core and can only be
accessed using the SFR memory space and not through the duplicate mapping into XDATA memory
space. These specific SFR registers are listed in SFR Registers.
2.2.3 Physical Memory
RAM. All devices contain static RAM. At power on, the content of RAM is undefined. RAM content is
retained in all power modes.
Flash Memory. The on-chip flash memory is primarily intended to hold program code and constant data.
The flash memory has the following features:
•Page size: 1 KB or 2 KB (details are given in the data sheet of the device.)
•Flash-page erase time: 20 ms
•Flash-chip (mass) erase time: 20 ms
•Flash write time (4 bytes): 20 μs
•Data retention (at room temperature): 100 years
•Program and erase endurance: 20,000 cycles
The flash memory is organized as a set of 1 or 2 KB pages. The 16 bytes of the upper available page
contain page-lock bits and the debug-lock bit. There is one lock bit for each page, except the lock-bit page
which is implicitly locked when not in debug mode. When the lock bit for a page is 0, it is impossible to
erase or write that page. When the debug lock bit is 0, most of the commands on the debug interface are
ignored. The primary purpose of the debug lock bit is to protect the contents of the flash against read-out.
The Flash Controller is used to write and erase the contents of the flash memory.
When the CPU reads instructions and constants from flash memory, it fetches the instructions through a
cache. Four bytes of instructions and four bytes of constant data are cached, at 4-byte boundaries. That
is, when the CPU reads from address 0x00F1 for example, bytes 0x00F0–0x00F3 are cached. A separate
prefetch unit is capable of prefetching 4 additional bytes of instructions. The cache is provided mainly to
reduce power consumption by reducing the amount of time the flash memory is accessed. The cache may
be disabled with the FCTL.CM[1:0] register bits. Doing so increases power consuption and is not
recommended. The execution time from flash is not cycle-accurate when using the default cache mode
and the cache mode with prefetch; that is, one cannot determine exactly the number of clock cycles a set
of instructions takes. To obtain cycle-accurate execution, enable the real-time cache mode and ensure all
DMA transfers have low priority. The prefetch mode improves performance by up to 33%, at the expense
of increased power consumption due to wasted flash reads. Typically, performance improves by
15%–20%. Total energy, however, may decrease (depending on the application) due to fewer wasted
clock cycles waiting for the flash to return instructions and/or data. Prefetching is very applicationdependent and requires the use of power modes to be effective.
The Information Page is a 2 KB read-only region that stores various device information. Among other
things, it contains for IEEE 802.15.4 or Bluetooth low energy compliant devices a unique IEEE address
from the TI range of addresses. For CC253x, this is a 64-bit IEEE address stored with least-significant
byte first at XDATA address 0x780C. For CC2540 and CC2541, this is a 48-bit IEEE address stored with
least-significant byte first at XDATA address 0x780E.
SFR Registers. The special function registers (SFRs) control several of the features of the 8051 CPU
core and/or peripherals. Many of the 8051 core SFRs are identical to the standard 8051 SFRs. However,
there are additional SFRs that control features that are not available in the standard 8051. The additional
SFRs are used to interface with the peripheral units and RF transceiver.
Table 2-1 shows the addresses of all SFRs in the device. The 8051 internal SFRs are shown with gray
background, whereas the other SFRs are the SFRs specific to the device.
www.ti.com
28
NOTE: All internal SFRs (shown with gray background in Table 2-1), can only be accessed through
SFR space, as these registers are not mapped into XDATA space. One exception is the port
registers (P0, P1, and P2) which are readable from XDATA.
ADCCON10xB4ADCADC control 1
ADCCON20xB5ADCADC control 2
ADCCON30xB6ADCADC control 3
ADCL0xBAADCADC data low
ADCH0xBBADCADC data high
RNDL0xBCADCRandom number generator data low
RNDH0xBDADCRandom number generator data high
ENCDI0xB1AESEncryption or decryption input data
ENCDO0xB2AESEncryption or decryption output data
ENCCS0xB3AESEncryption or decryption control and status
P00x80CPUPort 0. Readable from XDATA (0x7080)
SP0x81CPUStack pointer
DPL00x82CPUData pointer 0 low byte
DPH00x83CPUData pointer 0 high byte
DPL10x84CPUData pointer 1 low byte
DPH10x85CPUData pointer 0 high byte
PCON0x87CPUPower mode control
TCON0x88CPUInterrupt flags
P10x90CPUPort 1. Readable from XDATA (0x7090)
DPS0x92CPUData pointer select
S0CON0x98CPUInterrupt flags 2
IEN20x9ACPUInterrupt enable 2
S1CON0x9BCPUInterrupt flags 3
P20xA0CPUPort 2. Readable from XDATA (0x70A0)
IEN00xA8CPUInterrupt enable 0
IP00xA9CPUInterrupt priority 0
IEN10xB8CPUInterrupt enable 1
IP10xB9CPUInterrupt priority 1
IRCON0xC0CPUInterrupt flags 4
PSW0xD0CPUProgram status Word
ACC0xE0CPUAccumulator
IRCON20xE8CPUInterrupt flags 5
B0xF0CPUB register
DMAIRQ0xD1DMADMA interrupt flag
DMA1CFGL0xD2DMADMA channel 1–4 configuration address low
DMA1CFGH0xD3DMADMA channel 1–4 configuration address high
DMA0CFGL0xD4DMADMA channel 0 configuration address low
DMA0CFGH0xD5DMADMA channel 0 configuration address high
DMAARM0xD6DMADMA channel armed
DMAREQ0xD7DMADMA channel start request and status
—0xAA—Reserved
—0x8E—Reserved
—0x99—Reserved
—0xB0—Reserved
—0xB7—Reserved
—0xC8—Reserved
P0IFG0x89IOCPort 0 interrupt status flag
P1IFG0x8AIOCPort 1 interrupt status flag
P2IFG0x8BIOCPort 2 interrupt status flag
PICTL0x8CIOCPort pins interrupt mask and edge
P0IEN0xABIOCPort 0 interrupt mask
P1IEN0x8DIOCPort 1 interrupt mask
P2IEN0xACIOCPort 2 interrupt mask
P0INP0x8FIOCPort 0 input mode
PERCFG0xF1IOCPeripheral I/O control
APCFG0xF2IOCAnalog peripheral I/O configuration
P0SEL0xF3IOCPort 0 function select
P1SEL0xF4IOCPort 1 function select
P2SEL0xF5IOCPort 2 function select
P1INP0xF6IOCPort 1 input mode
P2INP0xF7IOCPort 2 input mode
P0DIR0xFDIOCPort 0 direction
P1DIR0xFEIOCPort 1 direction
P2DIR0xFFIOCPort 2 direction
PMUX0xAEIOCPower-down signal mux
MPAGE0x93MEMORY Memory page select
MEMCTR0xC7MEMORYMemory system control
FMAP0x9FMEMORYFlash-memory bank mapping
RFIRQF10x91RFRF interrupt flags MSB
RFD0xD9RFRF data
RFST0xE1RFRF command strobe
RFIRQF00xE9RFRF interrupt flags LSB
RFERRF0xBFRFRF error interrupt flags
ST00x95STSleep Timer 0
ST10x96STSleep Timer 1
ST20x97STSleep Timer 2
STLOAD0xADSTSleep-timer load status
SLEEPCMD0xBEPMCSleep-mode control command
SLEEPSTA0x9DPMCSleep-mode control status
CLKCONCMD 0xC6PMCClock control command
CLKCONSTA0x9EPMCClock control status
T1CC0L0xDATimer 1Timer 1 channel 0 capture or compare value low
T1CC0H0xDBTimer 1Timer 1 channel 0 capture or compare value high
T1CC1L0xDCTimer 1Timer 1 channel 1 capture or compare value low
T1CC1H0xDDTimer 1Timer 1 channel 1 capture or compare value high
T1CC2L0xDETimer 1Timer 1 channel 2 capture or compare value low
T1CC2H0xDFTimer 1Timer 1 channel 2 capture or compare value high
T1CNTL0xE2Timer 1Timer 1 counter low
T1CNTH0xE3Timer 1Timer 1 counter high
T1CTL0xE4Timer 1Timer 1 control and status
T1CCTL00xE5Timer 1Timer 1 channel 0 capture or compare control
T1CCTL10xE6Timer 1Timer 1 channel 1 capture or compare control
T1CCTL20xE7Timer 1Timer 1 channel 2 capture or compare control
T1STAT0xAFTimer 1Timer 1 status
XREG Registers. The XREG registers are additional registers in the XDATA memory space. These
registers are mainly used for radio configuration and control. For more details regarding each register, see
the corresponding module or peripheral chapter. Table 2-2 gives a descriptive overview of the register
address space.
Table 2-2. Overview of XREG Registers
XDATA AddressRegister NameDescription
0x6000–0x61FF—Radio Section 24.1 or CC2541 Radio Section 25.12 for
0x61A6
0x61ADOPAMPMCOperational amplifier mode control (CC2540)
0x6200–0x622B—USB registers (see Section 21.12 for complete list)
0x6230I2CCFGI2C control
0x6231I2CSTATI2C status
0x6232I2CDATAI2C data
0x6233I2CADDRI2C own slave address
0x6234I2CWCWrapper control
0x6235I2CIOGPIO
0x6243OBSSEL0Observation output control register 0
0x6244OBSSEL1Observation output control register 1
0x6245OBSSEL2Observation output control register 2
0x6246OBSSEL3Observation output control register 3
0x6247OBSSEL4Observation output control register 4
0x6248OBSSEL5Observation output control register 5
0x6249CHVERChip version
0x624ACHIPIDChip identification
0x624BTR0Test register 0
0x6260DBGDATADebug interface write data
0x6262SRCRCSleep reset CRC
0x6264BATTMONBattery monitor
0x6265IVCTRLAnalog control register
0x6270FCTLFlash control
0x6271FADDRLFlash address low
0x6272FADDRHFlash address high
0x6273FWDATAFlash write data
0x6276CHIPINFO0Chip information byte 0
0x6277CHIPINFO1Chip information byte 1
0x6281IRCTLTimer 1 IR generation control
0x6290CLDClock-loss detection
0x62A0T1CCTL0
0x62A1T1CCTL1
0x62A2T1CCTL2
0x62A3T1CCTL3Timer 1 channel 3 capture or compare control
0x62A4T1CCTL4Timer 1 channel 4 capture or compare control
0x62A6T1CC0L
0x62A7T1CC0H
MONMUXBattery monitor MUX (CC2533)
OPAMPMCOperational amplifier mode control (CC2530, CC2531)
Radio registers (see CC253x Radio Section 23.15 or CC2540
complete list)
Timer 1 channel 0 capture or compare control (additional XREG
mapping of SFR register)
Timer 1 channel 1 capture or compare control (additional XREG
mapping of SFR register)
Timer 1 channel 2 capture or compare control (additional XREG
mapping of SFR register)
Timer 1 channel 0 capture or compare value low (additional
XREG mapping of SFR register)
Timer 1 channel 0 capture or compare value high (additional
XREG mapping of SFR register)
0x62ABT1CC2H
0x62ACT1CC3LTimer 1 channel 3 capture or compare value low
0x62ADT1CC3HTimer 1 channel 3 capture or compare value high
0x62AET1CC4LTimer 1 channel 4 capture or compare value low
0x62AFT1CC4HTimer 1 channel 4 capture or compare value high
0x62B0STCCSleep Timer capture control
0x62B1STCSSleep Timer capture status
0x62B2STCV0Sleep Timer capture value byte 0
0x62B3STCV1Sleep Timer capture value byte 1
0x62B4STCV2Sleep Timer capture value byte 2
0x62C0OPAMPCOperational amplifier control
0x62C1OPAMPSOperational amplifier status
0x62D0CMPCTLAnalog comparator control and status
Timer 1 channel 1 capture or compare value low (additional
XREG mapping of SFR register)
Timer 1 channel 1 capture or compare value high (additional
XREG mapping of SFR register)
Timer 1 channel 2 capture or compare value low (additional
XREG mapping of SFR register)
Timer 1 channel 2 capture or compare value high (additional
XREG mapping of SFR register)
Memory
2.2.4 XDATA Memory Access
The MPAGE register is used during instructions MOVX A,@Ri and MOVX @Ri,A. MPAGE gives the 8 mostsignificant address bits, whereas the register Ri gives the 8 least-significant bits.
In some 8051 implementations, this type of XDATA access is performed using P2 to give the mostsignificant address bits. Existing software may therefore have to be adapted to make use of MPAGE
instead of P2.
MPAGE (0x93) – Memory Page Select
BitNameResetR/WDescription
MPAGE[7:0]
7:0
0x00R/W Memory page, high-order bits of address in MOVX instruction
2.2.5 Memory Arbiter
The memory arbiter handles CPU and DMA access to all physical memory except the CPU internal
registers. When an access conflict between the CPU and DMA occurs, the memory arbiter stalls one of
the bus masters so that the conflict is resolved.
The control registers MEMCTR and FMAP are used to control various aspects of the memory subsystem.
The MEMCTR and FMAP registers are described as follows.
MEMCTR.XMAP must be set to enable program execution from RAM.
The flash-bank map register, FMAP, controls mapping of physical 32-KB code banks to the program
address region 0x8000–0xFFFF in CODE memory space.
0R/W XDATA map to code. When this bit is set, the SRAM XDATA region, from 0x0000
through (SRAM_SIZE – 1), is mapped into the CODE region from 0x8000 through
(0x8000 + SRAM_SIZE – 1). This enables execution of program code from RAM.
0: SRAM map into CODE feature disabled
1: SRAM map into CODE feature enabled
000R/WXDATA bank select. Controls which code bank of the physical flash memory is
mapped into the XDATA region (0x8000–0xFFFF). When set to 0, the root bank is
mapped in.
Valid settings depend on the flash size for the device. Writing an invalid setting is
ignored, that is, no update to XBANK[2:0] is performed.
32-KB version: 0 only (that is, the root bank is always mapped in.)
64-KB version: 0–1
96-KB version: 0–2
128-KB version: 0–3
256-KB version: 0–7
001R/WFlash bank map. Controls which bank is mapped into the bank area of the CODE
memory space (0x8000–0xFFFF). When set to 0, the root bank is mapped in. Valid
settings depend on the flash size for the device. Writing an invalid setting is ignored,
that is, no update to MAP[2:0] is performed.
32-KB version: No value can be written. Bank area is only used for running program
code from SRAM. See MEMCTR.XMAP.
64-KB version: 0–1
96-KB version: 0–2
128-KB version: 0–3
256-KB version: 0–7
www.ti.com
2.3CPU Registers
This section describes the internal registers found in the CPU.
2.3.1 Data Pointers
Two data pointers, DPTR0 and DPTR1, exist to accelerate the movement of data blocks to and from
memory. The data pointers are generally used to access CODE or XDATA space. For example:
MOVC A,@A+DPTR
MOV A,@DPTR.
The data pointer select bit, bit 0 in the data pointer select register DPS, chooses which data pointer is the
active one during execution of an instruction that uses the data pointer, for example, in one of the
preceding instructions.
The data pointers are two bytes wide, consisting of the following SFRs:
0R/W Data pointer select. Selects active data pointer.
0: DPTR0
1: DPTR1
2.3.2 Registers R0–R7
There are four register banks (not to be confused with CODE memory space banks that only apply to flash
memory organization) of eight registers each. These register banks are mapped in the DATA memory
space at addresses 0x00–0x07, 0x08–0x0F, 0x10–0x17, and 0x18–0x1F. Each register bank contains the
eight 8-bit registers R0–R7. The register bank to be used is selected through the program status word
PSW.RS[1:0]. Register bank 0 uses flip-flops internally for storing the values (SRAM is bypassed or
unused), whereas banks 1–3 use SRAM for storage. This is done to save power. Typically, the current
consumption goes down by approximately 200 μA by using register bank 0 instead of register banks 1–3.
CPU Registers
2.3.3 Program Status Word
The program status word (PSW) contains several bits that show the current state of the CPU. The PSW is
accessible as an SFR, and it is bit-addressable. The PSW is shown as follows and contains the carry flag,
auxiliary carry flag for BCD operations, register-select bits, overflow flag, and parity flag. Two bits in the
PSW are uncommitted and can be used as user-defined status flags.
PSW (0xD0) – Program Status Word
BitNameResetR/WDescription
CY
7
6
5
4:3
2
1
0
AC
F0
RS[1:0]
OV
F1
P
0R/W Carry flag. Set to 1 when the last arithmetic operation resulted in a carry (during
addition) or borrow (during subtraction); otherwise, cleared to 0 by all arithmetic
operations.
0R/W Auxiliary carry flag for BCD operations. Set to 1 when the last arithmetic operation
resulted in a carry into (during addition) or borrow from (during subtraction) the highorder nibble, otherwise cleared to 0 by all arithmetic operations.
0R/W User-defined, bit-addressable
00R/WRegister bank select bits. Selects which set of R7–R0 registers to use from four
possible banks in DATA space.
00: Register bank 0, 0x00–0x07
01: Register bank 1, 0x08–0x0F
10: Register bank 2, 0x10–0x17
11: Register bank 3, 0x18–0x1F
0R/W Overflow flag, set by arithmetic operations. Set to 1 when the last arithmetic
operation is a carry (addition), borrow (subtraction), or overflow (multiply or divide).
Otherwise, the bit is cleared to 0 by all arithmetic operations.
0R/W User-defined, bit-addressable
0R/W Parity flag, parity of accumulator set by hardware to 1 if it contains an odd number of
ACC is the accumulator. This is the source and destination of most arithmetic instructions, data transfers,
and other instructions. The mnemonic for the accumulator (in instructions involving the accumulator) is A
instead of ACC.
ACC (0xE0) – Accumulator
BitNameResetR/WDescription
ACC[7:0]
7:0
0x00R/W Accumulator
2.3.5 B Register
The B register is used as the second 8-bit argument during execution of multiply and divide instructions.
When not used for these purposes, it may be used as a scratchpad register to hold temporary data.
B (0xF0) – B Register
BitNameResetR/WDescription
B[7:0]
7:0
0x00R/W B register. Used in MUL and DIV instructions
2.3.6 Stack Pointer
The stack resides in DATA memory space and grows upwards. The PUSH instruction first increments the
stack pointer (SP) and then copies the byte into the stack. The SP is initialized to 0x07 after a reset, and it
is incremented once to start from location 0x08, which is the first register (R0) of the second register bank.
Thus, in order to use more than one register bank, the SP should be initialized to a different location not
used for data storage.
1980.
The following conventions are used in the instruction set summary:
•Rn – Register R7–R0 of the currently selected register bank
•Direct – 8-bit internal data-location address. This can be DATA area (0x00–0x7F) or SFR area
(0x80–0xFF).
•@Ri – 8-bit internal data location, DATA area (0x00–0xFF) addressed indirectly through register R1 or
R0
•#data – 8-bit constant included in instruction
•#data16 – 16-bit constant included in instruction
•addr16 – 16-bit destination address. Used by LCALL and LJMP. A branch can be anywhere within the
64 KB CODE memory space.
•addr11 – 11-bit destination address. Used by ACALL and AJMP. The branch is within the same 2 KB
page of program memory as the first byte of the following instruction.
•rel – Signed (2s-complement) 8-bit offset byte. Used by SJMP and all conditional jumps. Range is –128
to 127 bytes relative to first byte of the following instruction.
The instructions that affect CPU flag settings located in PSW are listed in Table 2-4. Note that operations
on the PSW register or bits in PSW also affect the flag settings. Also note that the cycle count for many
instructions assumes single-cycle access to the memory element being accessed, that is, the best-case
situation. This is not always the case. Reads from flash may take 1–3 cycles, for example.
ADD A,RnAdd register to accumulator28–2F11
ADD A,directAdd direct byte to accumulator2522
ADD A,@RiAdd indirect RAM to accumulator26–2712
ADD A,#dataAdd immediate data to accumulator2422
ADDC A,RnAdd register to accumulator with carry flag38–3F11
ADDC A,directAdd direct byte to A with carry flag3522
ADDC A,@RiAdd indirect RAM to A with carry flag36–3712
ADDC A,#dataAdd immediate data to A with carry flag3422
SUBB A,RnSubtract register from A with borrow98–9F11
SUBB A,directSubtract direct byte from A with borrow9522
SUBB A,@RiSubtract indirect RAM from A with borrow96–9712
SUBB A,#dataSubtract immediate data from A with borrow9422
INC AIncrement accumulator0411
INC RnIncrement register08–0F12
INC directIncrement direct byte0523
INC @RiIncrement indirect RAM06–0713
INC DPTRIncrement data pointerA311
DEC ADecrement accumulator1411
DEC RnDecrement register18–1F12
DEC directDecrement direct byte1523
DEC @RiDecrement indirect RAM16–1713
MUL ABMultiply A and BA415
DIV ADivide A by B8415
DA ADecimal adjust accumulatorD411
ANL A,RnAND register to accumulator58–5F11
ANL A,directAND direct byte to accumulator5522
ANL A,@RiAND indirect RAM to accumulator56–5712
ANL A,#dataAND immediate data to accumulator5422
ANL direct,AAND accumulator to direct byte5223
ANL direct,#dataAND immediate data to direct byte5334
ORL A,RnOR register to accumulator48–4F11
ORL A,directOR direct byte to accumulator4522
ORL A,@RiOR indirect RAM to accumulator46–4712
ORL A,#dataOR immediate data to accumulator4422
ORL direct,AOR accumulator to direct byte4223
ORL direct,#dataOR immediate data to direct byte4334
XRL A,RnExclusive OR register to accumulator68–6F11
XRL A,directExclusive OR direct byte to accumulator6522
XRL A,@RiExclusive OR indirect RAM to accumulator66–6712
XRL A,#dataExclusive OR immediate data to accumulator6422
XRL direct,AExclusive OR accumulator to direct byte6223
XRL direct,#dataExclusive OR immediate data to direct byte6334
CLR AClear accumulatorE411
CPL AComplement accumulatorF411
RL ARotate accumulator left2311
RLC ARotate accumulator left through carry3311
RR ARotate accumulator right0311
RRC ARotate accumulator right through carry1311
SWAP ASwap nibbles within the accumulatorC411
MOV A,RnMove register to accumulatorE8–EF11
MOV A,directMove direct byte to accumulatorE522
MOV A,@RiMove indirect RAM to accumulatorE6–E712
MOV A,#dataMove immediate data to accumulator7422
MOV Rn,AMove accumulator to registerF8–FF12
MOV Rn,directMove direct byte to registerA8–AF24
MOV Rn,#dataMove immediate data to register78–7F22
MOV direct,AMove accumulator to direct byteF523
MOV direct,RnMove register to direct byte88–8F23
MOV direct1,direct2 Move direct byte to direct byte8534
MOV direct,@RiMove indirect RAM to direct byte86–8724
MOV direct,#dataMove immediate data to direct byte7533
MOV @Ri,AMove accumulator to indirect RAMF6–F713
MOV @Ri,directMove direct byte to indirect RAMA6–A725
MOV @Ri,#dataMove immediate data to indirect RAM76–7723
MOV DPTR,#data16 Load data pointer with a 16-bit constant9033
MOVC A,@A+DPTR Move code byte relative to DPTR to accumulator9313
MOVC A,@A+PCMove code byte relative to PC to accumulator8313
MOVX A,@RiMove external RAM (8-bit address) to AE2–E313
MOVX A,@DPTRMove external RAM (16-bit address) to AE013
MOVX @Ri,AMove A to external RAM (8-bit address)F2–F314
MOVX @DPTR,AMove A to external RAM (16-bit address)F014
PUSH directPush direct byte onto stackC024
POP directPop direct byte from stackD023
XCH A,RnExchange register with accumulatorC8–CF12
XCH A,directExchange direct byte with accumulatorC523
XCH A,@RiExchange indirect RAM with accumulatorC6–C713
XCHD A,@RiExchange low-order nibble indirect. RAM with AD6–D713
ACALL addr11Absolute subroutine callxxx1126
LCALL addr16Long subroutine call1236
RETReturn from subroutine2214
RETIReturn from interrupt3214
AJMP addr11Absolute jumpxxx0123
LJMP addr16Long jump0234
SJMP relShort jump (relative address)8023
JMP @A+DPTRJump indirect relative to the DPTR7312
JZ relJump if accumulator is zero6023
JNZ relJump if accumulator is not zero7023
JC relJump if carry flag is set4023
JNCJump if carry flag is not set5023
JB bit,relJump if direct bit is set2034
JNB bit,relJump if direct bit is not set3034
JBC bit,direct relJump if direct bit is set and clear bit1034
CJNE A,direct relCompare direct byte to A and jump if not equalB534
CJNE A,#data relCompare immediate to A and jump if not equalB434
CJNE Rn,#data relCompare immediate to reg. and jump if not equalB8–BF34
CJNE @Ri,#data rel Compare immediate to indirect and jump if not equalB6–B734
DJNZ Rn,relDecrement register and jump if not zeroD8–DF13
DJNZ direct,relDecrement direct byte and jump if not zeroD534
NOPNo operation0011
CLR CClear carry flagC311
CLR bitClear direct bitC223
SETB CSet carry flagD311
SETB bitSet direct bitD223
CPL CComplement carry flagB311
CPL bitComplement direct bitB223
ANL C,bitAND direct bit to carry flag8222
ANL C,/bitAND complement of direct bit to carryB022
ORL C,bitOR direct bit to carry flag7222
ORL C,/bitOR complement of direct bit to carryA022
MOV C,bitMove direct bit to carry flagA222
MOV bit,CMove carry flag to direct bit9223
0 = set to 0, 1 = set to 1, x = set to 0 or 1, – = not affected
www.ti.com
(1)
2.5Interrupts
The CPU has 18 interrupt sources. Each source has its own request flag located in a set of interrupt-flag
SFR registers. Each interrupt requested by the corresponding flag can be individually enabled or disabled.
The definitions of the interrupt sources and the interrupt vectors are given in Table 2-5.
The interrupts are grouped into a set of priority-level groups with selectable priority levels.
The interrupt-enable registers are described in Section 2.5.1 and the interrupt priority settings are
Each interrupt can be individually enabled or disabled by the interrupt-enable bits in the interrupt-enable
SFRs IEN0, IEN1, and IEN2. The CPU interrupt-enable SFRs are described as follows and summarized
in Table 2-5.
Note that some peripherals have several events that can generate the interrupt request associated with
that peripheral. This applies to Port 0, Port 1, Port 2, Timer 1, Timer 2, Timer 3, Timer 4, DMA controller,
and Radio. These peripherals have interrupt mask bits for each internal interrupt source in the
corresponding SFR or XREG register.
In order to enable any of the interrupts, the following steps must be taken:
1. Clear interrupt flags.
2. Set individual interrupt-enable bit in the peripherals SFR register, if any.
3. Set the corresponding individual interrupt-enable bit in the IEN0, IEN1, or IEN2 register to 1.
4. Enable global interrupt by setting the EA bit in IEN0 to 1.
5. Begin the interrupt service routine at the corresponding vector address of that interrupt. See Table 2-5
for addresses.
Figure 2-4 gives a complete overview of all interrupt sources and associated control and state registers.
Shaded boxes in Figure 2-4 are interrupt flags that are automatically cleared by hardware when the
interrupt service routine is called.indicates a one-shot, either due to the level source or due to edge
shaping. Interrupts missing this are to be treated as level-triggered (apply to ports P0, P1, and P2). The
switch boxes are shown in the default state, andorindicates rising- or falling-edge detection, that
is, at what time instance the interrupt is generated. As a general rule for pulsed or edge-shaped interrupt
sources, one should clear CPU interrupt flag registers prior to clearing the source flag bit, if available, for
flags that are not automatically cleared. For level sources, one must clear the source prior to clearing the
CPU flag.
Note that when clearing source interrupt flags in a register that contains several flags, interrupts may be
lost if a read-modify-write operation is done (even in a single assembly instruction), as it also clears
interrupt flags that became active between the read and write operation. The source interrupt flags (with
the exception of the USB controller interrupt flags) have the access mode R/W0. This means that writing 1
to a bit has no effect, so 1 should be written to an interrupt flag that is not to be cleared. For instance, to
clear the TIMER2_OVF_PERF bit (bit 3) of T2IRQF in C code, one should do:
Interrupts
T2IRQF = ~(1 <<3);
and not:
T2IRQF &= ~(1 << 3); //wrong!
Table 2-5. Interrupts Overview
InterruptInterruptInterruptInterrupt Mask,
NumberNameVectorCPU
0RF core-error situationRFERR0x03
1ADC end of conversionADC0x0B
2USART 0 RX completeURX00x13
3USART 1 RX completeURX10x1B
4AES encryption or decryption completeENC0x23
5Sleep Timer compareST0x2B
6Port-2 inputs, USB, or I2CP2INT0x33
7USART 0 TX completeUTX00x3B
8DMA transfer completeDMA0x43
9Timer 1 (16-bit) capture, compare, overflowT10x4B
10Timer 2T20x53
(1)
Hardware-cleared when interrupt service routine is called
When an interrupt occurs, the CPU vectors to the interrupt-vector address as shown in Table 2-5. Once an
interrupt service has begun, it can be interrupted only by a higher-priority interrupt. The interrupt service is
terminated by an RETI (return-from-interrupt instruction). When an RETI is performed, the CPU returns to
the instruction that would have been next when the interrupt occurred.
When the interrupt condition occurs, the CPU also indicates this by setting an interrupt flag bit in the
interrupt flag registers. This bit is set regardless of whether the interrupt is enabled or disabled. If the
interrupt is enabled when an interrupt flag is set, then on the next instruction cycle, the interrupt is
acknowledged by hardware, forcing an LCALL to the appropriate vector address.
Interrupts
Interrupt response requires a varying amount of time, depending on the state of the CPU when the
interrupt occurs. If the CPU is performing an interrupt service with equal or greater priority, the new
interrupt is pending until it becomes the interrupt with highest priority. In other cases, the response time
depends on current instruction. The fastest possible response to an interrupt is seven machine cycles.
This includes one machine cycle for detecting the interrupt and six cycles to perform the LCALL.
NOTE:If an interrupt is disabled and the interrupt flag is polled, the 8051 assembly instruction JBC
must not be used to poll the interrupt flag and clear it when set. If the JBC instruction is
used, the interrupt flag may be re-asserted immediately.
NOTE:If the assembly instruction XCH A, IEN0 is used to clear the global interrupt enable flag
EA, the CPU may enter the interrupt routine on the cycle following this instruction. If that
happens, the interrupt routine is executed with EA set to 0, which may delay the service of
higher-priority interrupts.
6–0R/W Must be written 0. Writing a 1 always enables the interrupt source.
P0IF
5
T4IF
4
T3IF
3
T2IF
2
T1IF
1
DMAIF
0
0R/W Sleep Timer interrupt flag
0: Interrupt not pending
1: Interrupt pending
0R/W Port 0 interrupt flag
0: Interrupt not pending
1: Interrupt pending
0R/W Timer 4 interrupt flag. Set to 1 when Timer 4 interrupt occurs and cleared when CPU
H0vectors to the interrupt service routine.
0: Interrupt not pending
1: Interrupt pending
0R/W Timer 3 interrupt flag. Set to 1 when Timer 3 interrupt occurs and cleared when CPU
H0vectors to the interrupt service routine.
0: Interrupt not pending
1: Interrupt pending
0R/W Timer 2 interrupt flag. Set to 1 when Timer 2 interrupt occurs and cleared when CPU
H0vectors to the interrupt service routine.
0: Interrupt not pending
1: Interrupt pending
0R/W Timer 1 interrupt flag. Set to 1 when Timer 1 interrupt occurs and cleared when CPU
H0vectors to the interrupt service routine.
0: Interrupt not pending
1: Interrupt pending
0R/W DMA-complete interrupt flag
0: Interrupt not pending
1: Interrupt pending
Interrupts
IRCON2 (0xE8) – Interrupt Flags 5
BitNameResetR/WDescription
7:5 –000R/WReserved
WDTIF
4
3
2
1
0
P1IF
UTX1IF
UTX0IF
P2IF
0R/W Watchdog Timer interrupt flag
0: Interrupt not pending
1: Interrupt pending
0R/W Port 1 interrupt flag
0: Interrupt not pending
1: Interrupt pending
0R/W USART 1 TX interrupt flag
0: Interrupt not pending
1: Interrupt pending
0R/W USART 0 TX interrupt flag
0: Interrupt not pending
1: Interrupt pending
0R/W Port 2 interrupt flag
0: Interrupt not pending
1: Interrupt pending
2.5.3 Interrupt Priority
The interrupts are grouped into six interrupt priority groups, and the priority for each group is set by
registers IP0 and IP1. In order to assign a higher priority to an interrupt, that is, to its interrupt group, the
corresponding bits in IP0 and IP1 must be set as shown in Table 2-6.
The interrupt priority groups with assigned interrupt sources are shown in Table 2-7. Each group is
assigned one of four priority levels. While an interrupt service request is in progress, it cannot be
interrupted by a lower- or same-level interrupt.
In the case when interrupt requests of the same priority level are received simultaneously, the polling
sequence shown in Table 2-8 is used to resolve the priority of each request. Note that the polling
sequence in Figure 2-4 is the algorithm found in Table 2-8, not that polling is among the IP bits as listed in
the figure.
IP1 (0xB9) – Interrupt Priority 1
BitNameResetR/WDescription
7:6 –00R/W Reserved
IP1_IPG5
5
IP1_IPG4
4
IP1_IPG3
3
IP1_IPG2
2
IP1_IPG1
1
IP1_IPG0
0
IP0 (0xA9) – Interrupt Priority 0
BitNameResetR/WDescription
7:6 –00R/W Reserved
IP0_IPG5
5
IP0_IPG4
4
IP0_IPG3
3
IP0_IPG2
2
IP0_IPG1
1
IP0_IPG0
0
0R/W Interrupt group 5, priority control bit 1, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 4, priority control bit 1, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 3, priority control bit 1, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 2, priority control bit 1, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 1, priority control bit 1, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 0, priority control bit 1, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 5, priority control bit 0, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 4, priority control bit 0, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 3, priority control bit 0, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 2, priority control bit 0, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 1, priority control bit 0, see Table 2-7: Interrupt Priority Groups
0R/W Interrupt group 0, priority control bit 0, see Table 2-7: Interrupt Priority Groups
The two-wire debug interface allows programming of the on-chip flash, and it provides access to memory
and register contents and debug features such as breakpoints, single-stepping, and register modification.
The debug interface uses I/O pins P2.1 and P2.2 as debug data and debug clock, respectively, during
debug mode. These I/O pins can be used as general-purpose I/O only while the device is not in debug
mode. Thus, the debug interface does not interfere with any peripheral I/O pins.
Debug mode is entered by forcing two falling-edge transitions on pin P2.2 (debug clock) while the
RESET_N input is held low. When RESET_N is set high, the device is in debug mode.
On entering debug mode, the CPU is in the halted state with the program counter reset to address
0x0000.
While in debug mode, pin P2.1 is the debug-data bidirectional pin, and P2.2 is the debug-clock input pin.
NOTE: Note that the debugger cannot be used with a divided system clock. When running the
debugger, the value of CLKCONCMD.CLKSPD should be set to 000 when CLKCONCMD.OSC = 0 or
to 001 when CLKCONCMD.OSC = 1.
3.2Debug Communication
The debug interface uses a SPI-like two-wire interface consisting of the P2.1 (debug data) and P2.2
(debug clock) pins. Data is driven on the bidirectional debug-data pin at the positive edge of the debug
clock, and data is sampled on the negative edge of this clock.
The direction of the debug-data pin depends on the command being issued. Data is driven on the positive
edge of the debug clock and sampled on the negative edge. Figure 3-1 shows how data is sampled.
Debug Mode
Figure 3-1. External Debug Interface Timing
The data is byte-oriented and is transmitted MSB-first. A sequence of one byte is shown in Figure 3-2.
SWRU191F–April 2009–Revised April 2014Debug Interface
A debug command sequence always starts with the host transmitting a command through the serial
interface. This command encodes the number of bytes containing further parameters to follow, and
whether a response is required. Based on this command, the debug module controls the direction of the
debug data pad. A typical command sequence is shown in Figure 3-3. Note that the debug-data signal is
simplified for the clarity of the figure, not showing each individual bit change. The direction is not explicitly
indicated to the outside world, but must be derived by the host from the command protocol.
www.ti.com
Figure 3-3. Typical Command Sequence—No Extra Wait for Response
For commands that require a response, there must be a small idle period between the command and the
response to allow the pad to change direction. After the minimum waiting time (t
indicates whether it is ready to deliver the response data by pulling the data pad low. The external
debugger, which is sampling the data pad, detects this and begins to clock out the response data. If the
data pad is high after the waiting time, it is an indication to the debugger that the chip is not ready yet.
Figure 3-4 shows how the wait works.
) of 83 ns, the chip
dir_change
52
Debug InterfaceSWRU191F–April 2009–Revised April 2014
Figure 3-4. Typical Command Sequence. Wait for Response
If the debug interface indicates by pulling the data line high that it is not ready to return data, the external
device must issue exactly eight clock pulses before it samples the ready level again. This must be
repeated until the level is low. The wait cycle is equivalent to reading a byte from the debug interface, but
ignoring the result. Note that the pad starts to change direction on the falling edge of the debug clock.
Thus, the pad driver drives against the driver in the programmer until the programmer changes pad
direction. This duration should be minimized in a programmer implementation.
3.3Debug Commands
The debug commands are shown in Table 3-1. Some of the debug commands are described in further
detail in the following subsections.
The 3 least-significant bits (the Xs) are don't care values.
Table 3-1. Debug Commands
Additi Output
CommandDescription
InstructiononalBytes
ByteInput
Bytes
CHIP_ERASE0001 0XXX01Perform flash chip erase (mass erase) and clear lock bits. If any other
command except READ_STATUS is issued, then the use of CHIP_ERASE
is disabled.
Input byte: none
Output byte: Debug status byte. See Table 3-3.
Input byte: See Table 3-2 for details.
Output byte: Debug status byte. See Table 3-3.
Input byte: none.
Output byte: Returns value set by WR_CONFIG command. See Table 3-2.
53
Debug Commands
CommandDescription
GET_PC0010 1XXX02Return value of 16-bit program counter.
READ_STATUS0011 0XXX01Read status byte.
SET_HW_BRKPNT 0011 1XXX31Set hardware breakpoint.
HALT0100 0XXX01Halt CPU operation
RESUME0100 1XXX01Resume CPU operation. The CPU must be in the halted state for this
DEBUG_INSTR0101 0Xyy1–31Run debug instruction. The supplied instruction is executed by the CPU
STEP_INSTR0101 1XXX01Step CPU instruction. The CPU executes the next instruction from
GET_BM0110 0XXX01This command does the same thing as GET_PC, except that it returns the
GET_CHIP_ID0110 1XXX02Return value of 16-bit chip ID and version number.
BURST_WRITE1000 0kkk2–20491
www.ti.com
Table 3-1. Debug Commands (continued)
Additi Output
InstructiononalBytes
ByteInput
Bytes
Input byte: none
Output bytes: Returns 2 bytes.
Input byte: none
Output byte: Debug status byte. See Table 3-3.
Input bytes: See Section 3.3.3 for details.
Output byte: Debug status byte. See Table 3-3.
Input byte: none
Output byte: Debug status byte. See Table 3-3. If the CPU was already
halted, the output is undefined.
command to be run.
Input byte: none
Output byte: Debug status byte. See Table 3-3.
without incrementing the program counter. The CPU must be in halted
state for this command to be run. Note that yy is number of bytes following
the command byte, i.e., how many bytes the CPU instruction has (see
Table 2-3).
Input byte(s): CPU instruction
Output byte: The resulting accumulator register value after the instruction
has been executed
program memory and increments the program counter after execution. The
CPU must be in the halted state for this command to be run.
Input byte: none
Output byte: The resulting accumulator register value after the instruction
has been executed
memory bank. It returns one byte, where the 3 least-significant bits are the
currently used memory bank.
Input byte: none
Output byte: Memory bank (current value of FMAP.MAP)
Input byte: none.
Output bytes: The CHIPID and CHVER register values
This command writes a sequence of 1–2048 bytes to the DBGDATA
register. Each time the register is updated, a DBG_BW DMA trigger is
generated.
The number of parameters to the BURST_WRITE command is variable.
The number of data bytes in the burst is indicated using the 3 last bits of
the command byte (kkk), and the whole next byte. The command
sequence is shown in Figure 3-5. The burst length is indicated by an 11-bit
value (b10–b0). After these two bytes, the given number of data bytes
must be appended. The value 0 means 2048 data bytes; thus, the smallest
number of bytes to transfer is 1.
Input bytes: Command sequence
Output byte: Debug status byte. See Table 3-3.
54
Debug InterfaceSWRU191F–April 2009–Revised April 2014
The commands WR_CONFIG and RD_CONFIG are used to access the debug-configuration data byte.
The format and description of this configuration data are shown in Table 3-2.
BitNameResetDescription
7:6 –00Reserved
SOFT_POWER_MODE
5
4 –0Reserved
TIMERS_OFF
3
DMA_PAUSE
2
TIMER_SUSPEND
1
0–0Reserved. Always write 0.
Debug Commands
Figure 3-5. Burst Write Command (First 2 Bytes)
Table 3-2. Debug Configuration
1When set, the digital voltage regulator is not turned off during PM2 and PM3. If this bit
is cleared, the debug interface is reset during PM2 and PM3.
Disable timers. Disable timer operation. This overrides the TIMER_SUSPEND bit and its
0
function.
0: Do not disable timers
1: Disable timers
1DMA pause. The DMA registers must not be accessed while this bit is set.
0: Enable DMA transfers
1: Pause all DMA transfers
1Suspend timers.
Suspend timers when the chip is halted. The timers are also suspended during debug
instructions. When executing a STEP, the timers receive exactly (or as close as
possible) as many ticks as they would if the program were free-running.
0: Do not suspend timers
1: Suspend timers
3.3.2 Debug Status
A debug-status byte is read using the READ_STATUS command. The format and description of this
debug status is shown in Table 3-3.
The READ_STATUS command is, for example, used for:
•Polling the status of the chip erase (CHIP_ERASE_BUSY) after a CHIP_ERASE command.
•Checking whether the oscillator is stable (OSCILLATOR_STABLE); required for debug commands
HALT, RESUME, DEBUG_INSTR, STEP_REPLACE, and STEP_INSTR.
Table 3-3. Debug Status
BitNameResetDescription
CHIP_ERASE_BUSY
7
SWRU191F–April 2009–Revised April 2014Debug Interface
Submit Documentation Feedback
0Flash chip erase busy
The signal is only high when a chip erase is in progress. It goes high immediately after a
CHIP_ERASE command is received and returns to low when the flash is fully erased.
0: CPU is running. Chip in operational mode controlled by debugger.
CPU is not running. Chip is in power mode defined by SLEEPCMD.MODE register
1:
setting. See Section 4.1–Section 4.3 for details.
0CPU was halted
0: CPU is running.
1: CPU was halted from a breakpoint or from a HALT debug command.
0Chip is active. Note that PM0 and PM1 are not supported in debug mode. See also
Table 3-4.
0: Chip is in normal operation with CPU running (if not halted).
1: Chip is out of normal operation (active mode) and either in transition up or down from
power mode or stable in the power mode defined by the SLEEPCMD.MODE register
setting. See Section 4.1–Section 4.3 for details.
0Halt status. Returns cause of last CPU halt
0: CPU was halted by HALT debug command.
1: CPU was halted by hardware breakpoint.
Debug interface is locked. Returns value of DBGLOCK bit. See Section 3.4.1.
0
0: Debug interface is not locked.
1: Debug interface is locked.
0System clock oscillator stable
0: Oscillators not stable
1: Oscillators stable
0Stack overflow. This bit indicates when the CPU writes to DATA memory space at
address 0xFF, which is possibly a stack overflow.
0: No stack overflow
1: Stack overflow
PCON_IDLEPM_ACTIVE
00Chip in normal operation with CPU running (if not halted)
01Chip in transition to start-up from power mode
10Chip in transition to enter power mode
11Chip stable in power mode
3.3.3 Hardware Breakpoints
The debug command SET_HW_BRKPNT is used to set one of the four available hardware breakpoints.
When a hardware breakpoint is enabled, it compares the CPU address bus with the breakpoint. When a
match occurs, the CPU is halted.
When issuing the SET_HW_BRKPNT, the external host must supply three data bytes that define the
hardware breakpoint. The hardware breakpoint itself consists of 19 bits, whereas three bits are used for
control purposes. The format of the three data bytes for the SET_HW_BRKPNT command is as follows.
The first data byte consists of the following:
•Bits 7–6: Unused
•Bits 5–4: Breakpoint number, 0–3
•Bit 3: 1 = enable, 0 = disable
•Bits 2–0: Memory bank bits. Bits 18–16 of hardware breakpoint.
The second data byte consists of bits 15–8 of the hardware breakpoint.
Table 3-4. Relation Between PCON_IDLE and PM_ACTIVE
Description
56
Debug InterfaceSWRU191F–April 2009–Revised April 2014
The third data byte consists of bits 7–0 of the hardware breakpoint. Thus, the second and third data bytes
set the CPU CODE address at which to stop execution.
3.4Flash Programming
Programming of the on-chip flash is performed via the debug interface. The external host must initially
send instructions using the DEBUG_INSTR debug command to perform the flash programming with the
flash controller.
3.4.1 Lock Bits
For software and/or access protection, a set of lock bits can be written to the upper available flash
page—the lock-bit page. The lock-bit structure consists of 128 bits where the first (FLASH_PAGES-1)
each corresponds to the first flash pages available in the device. The last bit (at the highest address) is
the debug lock bit (see Table 3-5). The structure starts at address 0x7FF0 (address 0xFFF0 in XDATA)
when the upper flash bank is mapped in, and occupies 16 bytes. The rest of the lock-bit page can be used
to store code or constants, but cannot be changed without entering debug mode.
The PAGELOCK[FLASH_PAGES-2:0] lock-protect bits are used to enable erase and write protection for
individual flash memory pages (2 KB; 1 KB on CC2533). There is one bit for each available page.
When the debug-lock bit, DBGLOCK, is set to 0 (see Table 3-5), all debug commands except
CHIP_ERASE, READ_STATUS, and GET_CHIP_ID are disabled. The status of the debug-lock bit can be
read using the READ_STATUS command (see Section 3.3.2).
Note that after the debug-lock bit has changed due to a write to the lock-bit page or a CHIP_ERASE
command, the device must be reset to lock or unlock the debug interface.
Issuing a CHIP_ERASE command is the only way to clear the debug-lock bit, thereby unlocking the debug
interface.
Flash Programming
Table 3-5 defines the 16-byte structure containing the flash lock-protection bits. Bit 0 of the first byte
contains the lock bit for page 0, bit 1 of the first byte contains the lock bit for page 1, and so on. Bit 7 of
the last byte in the flash is the DBGLOCK bit (bit 127 in the structure).
Table 3-5. Flash Lock-Protection Bit Structure Definition
BitNameDescription
127
126:FLASH_PAGES-1 FREE SPACEOn devices with less than 256 KB memory: Code space available for
FLASH_PAGES-2:0
NOTE: It is recommended to lock all pages that are not to be in-system programmed. This is to
prevent erroneous code from unintentionally altering code or constants. This can only be
changed while in debug mode.
DBGLOCK
PAGELOCK[FLASH_PAGES-2:0]
3.5Debug Interface and Power Modes
Power modes PM2 and PM3 may be handled in two different ways when the chip is in debug mode. The
default behavior is never to turn off the digital voltage regulator. This emulates power modes while
maintaining debug mode operation. The clock sources are turned off as in ordinary power modes. The
other option is to turn off the 1.8-V internal digital power. This leads to a complete shutdown of the digital
part, which disables debug mode. When the chip is in debug mode, the two options are controlled by
configuration bit 5 (SOFT_POWER_MODE).
Debug-lock bit
0: Disable debug commands
1: Enable debug commands
storing code or constants.
Page-lock bits. There is one bit for each of the up to 128 pages.
Page-lock bits for unavailable pages are not used.
0: Page locked
1: Page not locked
SWRU191F–April 2009–Revised April 2014Debug Interface
The debug interface still responds to a reduced set of commands while in one of the power modes. The
chip can be woken up from sleep mode by issuing a HALT command to the debug interface. The HALT
command brings the chip up from sleep mode in the halted state. The RESUME command must be issued
to resume software execution.
The debug status may be read when in power modes. The status must be checked when leaving a power
mode by issuing a HALT command. The time needed to power up depends on which power mode the
chip is in, and must be checked in the debug status. The debug interface only accepts commands that are
available in sleep mode before the chip is operational.
NOTE: Debugging in Idle mode and PM1 is not supported. It is recommended to use active mode or
another power mode when debugging.
www.ti.com
58
Debug InterfaceSWRU191F–April 2009–Revised April 2014
This register is updated each time a new byte has been transferred to the debug
interface using the BURST_WRITE command. A DBG_BW DMA trigger is
generated when this byte is updated. This allows the DMA controller to fetch the
data.
Low-power operation is enabled through different operating modes (power modes). The various operating
modes are referred to as active mode, idle mode, and power modes 1, 2, and 3 (PM1–PM3).
Different operating modes, or power modes, are used to allow low-power operation. Ultralow-power
operation is obtained by turning off the power supply to modules to avoid static (leakage) power
consumption and also by using clock gating and turning off oscillators to reduce dynamic power
consumption.
The five various operating modes (power modes) are called active mode, idle mode, PM1, PM2, and PM3
(PM1, PM2, and PM3 are also referred to as sleep modes). Active mode is the normal operating mode,
whereas PM3 has the lowest power consumption. The impact of the different power modes on system
operation is shown in Table 4-1, together with voltage regulator and oscillator options.
Power Management Introduction
Table 4-1. Power Modes
Power ModeHigh-Frequency OscillatorLow-Frequency Oscillator
Active mode: The fully functional mode. The voltage regulator to the digital core is on, and either the 16-
MHz RC oscillator or the 32-MHz crystal oscillator or both are running. Either the 32-kHz RCOSC or the
32-kHz XOSC is running.
Idle mode: Identical to active mode, except that the CPU core stops operating (is idle).
PM1: The voltage regulator to the digital part is on. Neither the 32-MHz XOSC nor the 16-MHz RCOSC is
running. Either the 32-kHz RCOSC or the 32-kHz XOSC is running. The system goes to active mode on
reset, an external interrupt, or when the Sleep Timer expires.
PM2: The voltage regulator to the digital core is turned off. Neither the 32-MHz XOSC nor the 16-MHz
RCOSC is running. Either the 32-kHz RCOSC or the 32-kHz XOSC is running. The system goes to active
mode on reset, an external interrupt, or when the Sleep Timer expires.
PM3: The voltage regulator to the digital core is turned off. None of the oscillators is running. The system
goes to active mode on reset or an external interrupt.
The POR is active in PM2 and PM3, but the BOD is powered down, which gives limited voltage
supervision. If the supply voltage is lowered to below 1.4 V during PM2 or PM3, at temperatures of 70°C
or higher, and then brought back up to good operating voltage before active mode is re-entered, registers
and RAM contents that are saved in PM2 or PM3 may become altered. Hence, care should be taken in
the design of the system power supply to ensure that this does not occur. The voltage can be periodically
supervised accurately by entering active mode, as a BOD reset is triggered if the supply voltage is below
approximately 1.7 V.
The CC2533 and CC2541 have functionality to perform automatically a CRC check of the retained
configuration register values in PM2 and PM3 to check that the device state was not altered during sleep.
The bits in SRCRC.CRC_RESULT indicate whether there were any changes, and by enabling
SRCRC.CRC_RESET_EN, the device immediately resets itself with a watchdog reset if
SRCRC.CRC_RESULT is not 00 (= CRC of retained registers passed) after wakeup from PM2 or PM3. The
SRCRC register also contains the SRCRC.FORCE_RESET bit that can be used by software to trigger a
watchdog reset immediately to reboot the device.
For CC2533 and CC2541, additional analog reset architecture adds another brownout detector (the
3VBOD) that senses on the unregulated voltage. The purpose of this 3VBOD is to reduce the current
consumption of the device when supplied with voltages well below the operating voltage.
SWRU191F–April 2009–Revised April 2014Power Management and Clocks
Active mode is the fully functional mode of operation where the CPU, peripherals, and RF transceiver are
active. The digital voltage regulator is turned on.
Active mode is used for normal operation. By enabling the PCON.IDLE bit while in active mode
(SLEEPCMD.MODE = 0x00), the CPU core stops operating and the idle mode is entered. All other
peripherals function normally, and any enabled interrupt wakes up the CPU core (to transition back from
idle mode to active mode).
4.1.2 PM1
In PM1, the high-frequency oscillators are powered down (32-MHz XOSC and 16-MHz RCOSC). The
voltage regulator and the enabled 32-kHz oscillator are on. When PM1 is entered, a power-down
sequence is run.
PM1 is used when the expected time until a wakeup event is relatively short (less than 3 ms), because
PM1 uses a fast power-down and power-up sequence.
4.1.3 PM2
PM2 has the second-lowest power consumption. In PM2, the power-on reset, external interrupts, selected
32-kHz oscillator, and Sleep Timer peripherals are active. I/O pins retain the I/O mode and output value
set before entering PM2. All other internal circuits are powered down. The voltage regulator is also turned
off. When PM2 is entered, a power-down sequence is run.
PM2 is typically entered when using the Sleep Timer as the wakeup event, and also combined with
external interrupts. PM2 should typically be choosen, compared to PM1, when expected sleep time
exceeds 3 ms. Using less sleep time does not reduce system power consumption compared to using
PM1.
www.ti.com
4.1.4 PM3
PM3 is used to achieve the operating mode with the lowest power consumption. In PM3, all internal
circuits that are powered from the voltage regulator are turned off (basically all digital modules; the only
exceptions are interrupt detection and POR level sensing). The internal voltage regulator and all oscillators
are also turned off.
Reset (POR or external) and external I/O port interrupts are the only functions that operate in this mode.
I/O pins retain the I/O mode and output value set before entering PM3. A reset condition or an enabled
external I/O interrupt event wakes the device up and places it into active mode (an external interrupt starts
from where it entered PM3, whereas a reset returns to start-of-program execution). The content of RAM
and registers is partially preserved in this mode (see Section 4.6). PM3 uses the same power-down and
power-up sequence as PM2.
PM3 is used to achieve ultralow-power consumption when waiting for an external event. It should be used
when expected sleep time exceeds 3 ms.
4.2Power-Management Control
The required power mode is selected by the MODE bits in the SLEEPCMD control register and the
PCON.IDLE bit. Setting the SFR register PCON.IDLE bit enters the mode selected by SLEEPCMD.MODE.
An enabled interrupt from port pins or Sleep Timer or a power-on reset wakes the device from other power
modes and brings it into active mode.
When PM1, PM2, or PM3 is entered, a power-down sequence is run. When the device is taken out of
PM1, PM2, or PM3, it starts at 16 MHz and automatically changes to 32 MHz if CLKCONCMD.OSC was 0
when entering the power mode (setting PCON.IDLE). If CLKCONCMD.OSC was 1 when PCON.IDLE was
set, when entering the power mode, it continues to run at 16 MHz.
62
Power Management and ClocksSWRU191F–April 2009–Revised April 2014
The instruction that sets the PCON.IDLE bit must be aligned in a certain way for correct operation. The
first byte of the assembly instruction immediately following this instruction must not be placed on a 4-byte
boundary. Furthermore, cache must not be disabled (see CM in the FCTL register description in
Chapter 6). Failure to comply with this requirement may cause higher current consumption. Provided this
requirement is fulfilled, the first assembly instruction after the instruction that sets the PCON.IDLE bit is
performed before the ISR of the interrupt that caused the system to wake up, but after the system woke
up. If this instruction is a global interrupt disable, it is possible to have it followed by code for execution
after wakeup, but before the ISR is serviced.
An example of how this can be done in the IAR compiler is shown as follows. The command for setting
PCON to 1 is placed in a function written in assembly code. In a C file calling this function, a declaration
such as extern void
EnterSleepModeDisableInterruptsOnWakeup(void); is used. The
RSEG NEAR_CODE:CODE:NOROOT(2) statement ensures that the MOV PCON,#1 instruction is placed on
a 2-byte boundary. It is a 3-byte instruction, so the following instruction is not placed on a 4-byte
boundary, as required. In the following example, this instruction is CLR EA, which disables all interrupts.
That means that the ISR of the interrupt that woke up the system is not executed until after the IEN0.EA
bit has been set again later in the code. If this functionality is not wanted, the CLR EA instruction can be
replaced by a NOP.
PUBLIC EnterSleepModeDisableInterruptsOnWakeup FUNCTION
EnterSleepModeDisableInterruptsOnWakeup,0201H RSEG NEAR_CODE:CODE:NOROOT(2)
EnterSleepModeDisableInterruptsOnWakeup: MOV PCON,#1 CLR EA RET
4.3Power-Management Registers
This section describes the power-management registers. All register bits retain their previous values when
entering PM2 or PM3.
Power-Management Registers
SRCRC (0x6262) – Sleep Reset CRC (CC2533 and CC2541 only)
BitNameResetR/WDescription
XOSC_AMP_DET_EN
7
6–0R0Reserved. Always read 0.
FORCE_RESET
5
4–0RReserved
CRC_RESULT
3:2
1–0RReserved
CRC_RESET_EN
0
PCON (0x87) – Power Mode Control
BitNameResetR/WDescription
7:1 –0000 000R/W Reserved, always write as 0000 000.
IDLE
0
0R/W 0: Disable
1: Enable the amplitude detector for the 32-MHz XOSC, CC2533 only
0R/W 0: No action
1: Force watchdog reset.
00R/W0 00: CRC of retained registers passed
01: Low CRC value failed
10: High CRC value failed
11: Both CRC values failed
0R/W 0: Disable reset of chip due to CRC.
1: Enable reset of chip if CRC_RESULT != 00 after wakeup from PM2 or PM3.
0R0/W Power mode control. Writing 1 to this bit forces the device to enter the power mode
set by SLEEPCMD.MODE (note that MODE = 0x00 AND IDLE = 1 stops the CPU core
H0
activity). This bit is always read as 0.
All enabled interrupts clear this bit when active, and the device re-enters active
mode.
SWRU191F–April 2009–Revised April 2014Power Management and Clocks
0: 32-kHz RC oscillator calibration is enabled.
1: 32-kHz RC oscillator calibration is disabled.
This setting can be written at any time, but does not take effect before the chip has
been running on the 16-MHz high-frequency RC oscillator.
00R/WPower-mode setting
00: Active or Idle mode
01: Power mode 1 (PM1)
10: Power mode 2 (PM2)
11: Power mode 3 (PM3)
0R32-kHz RC oscillator calibration status
SLEEPSTA.OSC32K_CALDIS shows the current status of disabling of the 32-kHz
RC calibration. The bit is not set to the same value as
SLEEPCMD.OSC32K_CALDIS before the chip has been run on the 32-kHz RC
oscillator.
XXRStatus bit indicating the cause of the last reset. If there are multiple resets, the
register only contains the last event.
00: Power-on reset and brownout detection
01: External reset
10: Watchdog Timer reset
11: Clock loss reset
0RThe 32-kHz clock signal (synchronized to the system clock)
www.ti.com
64
Power Management and ClocksSWRU191F–April 2009–Revised April 2014
The device has one internal system clock, or main clock. The source for the system clock can be either
the 16-MHz RC oscillator or the 32-MHz crystal oscillator. Clock control is performed using the
CLKCONCMD SFR register.
There is also one 32-kHz clock source that can either be an RC oscillator or a crystal oscillator, also
controlled by the CLKCONCMD register.
The CLKCONSTA register is a read-only register used for getting the current clock status.
The choice of oscillator allows a trade-off between high accuracy in the case of the crystal oscillator and
low power consumption when the RC oscillator is used. Note that operation of the RF transceiver requires
that the 32-MHz crystal oscillator is used.
In the CC2533, CC2540 and CC2541, an additional module for detection of 32-MHz XOSC stability is
available. This amplitude detector can be useful in environments with significant noise on the power
supply, to ensure that the clock source is not used until the clock signal is stable. In the CC2533, this
module can be enabled by setting the SRCRC.XOSC_AMP_DET_EN bit, and this adds around 20 μs to the
32-MHz XOSC startup time. In the CC2540 and CC2541, the module is always enabled.
4.4.1 Oscillators
Figure 4-1 gives an overview of the clock system with available clock sources.
Two high-frequency oscillators are present in the device:
•32-MHz crystal oscillator
•16-MHz RC oscillator
The 32-MHz crystal-oscillator start-up time may be too long for some applications; therefore, the device
can run on the 16-MHz RC oscillator until the crystal oscillator is stable. The 16-MHz RC oscillator
consumes less power than the crystal oscillator, but because it is not as accurate as the crystal oscillator it
cannot be used for RF transceiver operation.
Two low-frequency oscillators are present in the device:
•32-kHz crystal oscillator
•32-kHz RC oscillator.
The 32-kHz XOSC is designed to operate at 32.768 kHz and provide a stable clock signal for systems
requiring time accuracy. The 32-kHz RCOSC runs at 32.753 kHz when calibrated. The calibration can only
take place when the 32-MHz XOSC is enabled, and this calibration can be disabled by enabling the
SLEEPCMD.OSC32K_CALDIS bit. The 32-kHz RCOSC should be used to reduce cost and power
consumption compared to the 32-kHz XOSC solution. The two 32-kHz oscillators cannot be operated
simultaneously.
www.ti.com
4.4.2 System Clock
The system clock is derived from the selected system clock source, which is the 32-MHz XOSC or the 16MHz RCOSC. The CLKCONCMD.OSC bit selects the source of the system clock. Note that to use the RF
transceiver, the 32-MHz crystal oscillator must be selected and stable.
Note that changing the CLKCONCMD.OSC bit does not cause the system clock to change instantly. The
clock source change first takes effect when CLKCONSTA.OSC = CLKCONCMD.OSC. This is due to the
requirement to have stable clocks prior to actually changing the clock source. Also note that the
CLKCONCMD.CLKSPD bit reflects the frequency of the system clock and thus is a mirror of the
CLKCONCMD.OSC bit.
The 16 MHz RC oscillator is calibrated once after the 32-MHz XOSC has been selected and is stable, that
is, when the CLKCONSTA.OSC bit switches from 1 to 0.
66
Power Management and ClocksSWRU191F–April 2009–Revised April 2014
NOTE: The change from the 16-MHz clock source to the 32-MHz clock source (and vice versa)
aligns with the CLKCONCMD.TICKSPD setting. A slow CLKCONCMD.TICKSPD setting
when CLKCONCMD.OSC is changed results in a longer time before the actual source
change takes effect. The fastest switching is obtained when CLKCONCMD.TICKSPD equals
000.
NOTE: After coming up from PM1, PM2, or PM3, the CPU must wait for CLKCONSTA.OSC to be 0
before operations requiring the system to run on the 32-MHz XOSC (such as the radio) are
started.
4.4.3 32-kHz Oscillators
Two 32-kHz oscillators are present in the device as clock sources for the 32-kHz clock:
•32-kHz XOSC
•32-kHz RCOSC
By default, after a reset, the 32-kHz RCOSC is enabled and selected as the 32-kHz clock source. The
RCOSC consumes less power, but is less accurate compared to the 32-kHz XOSC. The chosen 32-kHz
clock source drives the Sleep Timer, generates the tick for the Watchdog Timer, and is used as a strobe in
Timer 2 to calculate the Sleep Timer sleep time. The CLKCONCMD.OSC32K register bit selects the
oscillator to be used as the 32-kHz clock source. This bit does not give an indication of the stability of the
32-kHz XOSC.
The CLKCONCMD.OSC32K register bit can be written at any time, but does not take effect before the 16MHz RCOSC is the active system clock source. When system clock is changed from the 16-MHz RCOSC
to the 32-MHz XOSC (CLKCONCMD.OSC from 1 to 0), calibration of the 32-kHz RCOSC starts up and is
performed once if the 32-kHz RCOSC is selected. During calibration, a divided version of the 32-MHz
XOSC is used. The result of the calibration is that the 32-kHz RSOSC is running at 32.753 kHz. The 32kHz RCOSC calibration may take up to 2 ms to complete. Calibration can be disabled by setting
SLEEPCMD.OSC32K_CALDIS to 1. At the end of the calibration, an extra pulse may occur on the 32-kHz
clock source, which causes the sleep timer to be incremented by 1.
Note that after having switched to the 32-kHz XOSC and when coming up from PM3 with the 32-kHz
XOSC enabled, the oscillator requires up to 500 ms to stabilize on the correct frequency. The Sleep
Timer, Watchdog Timer and clock-loss detector should not be used before the 32-kHz XOSC is stable.
Oscillators and Clocks
4.4.4 Oscillator and Clock Registers
This section describes the oscillator and clock registers. All register bits retain their previous values when
entering PM2 or PM3.
SWRU191F–April 2009–Revised April 2014Power Management and Clocks
1R/W 32-kHz clock-source select. Setting this bit initiates a clock-source change only.
CLKCONSTA.OSC32K reflects the current setting. The 16-MHz RCOSC must be
selected as system clock when this bit is to be changed. This bit does not give an
indication of the stability of the 32-kHz XOSC.
0: 32 kHz XOSC
1: 32 kHz RCOSC
1R/W System clock-source select. Setting this bit initiates a clock-source change only.
CLKCONSTA.OSC reflects the current setting.
0: 32 MHz XOSC
1: 16 MHz RCOSC
001R/WTimer ticks output setting. Cannot be higher than system clock setting given by OSC
Note that CLKCONCMD.CLKSPD can be set to any value, but the effect is
limited by theCLKCONCMD.OSC setting; that is, if
CLKCONCMD.OSC = 1 and CLKCONCMD.CLKSPD = 000,
CLKCONSTA.CLKSPD reads 001, and the real CLKSPD is 16 MHz.
Note also that the debugger cannot be used with a divided system clock. When
running the debugger, the value of CLKCONCMD.CLKSPD should be set to 000 when
CLKCONCMD.OSC = 0 or to 001 when CLKCONCMD.OSC = 1.
www.ti.com
68
Power Management and ClocksSWRU191F–April 2009–Revised April 2014
The value of the CLKCONCMD.TICKSPD register controls a global prescaler for Timer 1, Timer 3, and
Timer 4. The prescaler value can be set to a value from 0.25 MHz to 32 MHz. It should be noted that if
CLKCONCMD.TICKSPD indicates a higher frequency than the system clock, the actual prescaler value
indicated in CLKCONSTA.TICKSPD is the same as the system clock.
4.6Data Retention
In power modes PM2 and PM3, power is removed from most of the internal circuitry. However, SRAM
retains its contents, and the content of internal registers is also retained in PM2 and PM3.
All CPU, RF, and peripheral registers retain their contents in PM2 and PM3, except the AES, I2C, and
USB registers, OBSSEL0–OBSSEL5, TR0, and in the CC2541, LLECTRL.
Switching to the PM2 or PM3 low-power modes appears transparent to software. Note that the value of
the Sleep Timer is not preserved in PM3.
All registers retain their values in PM1.
SWRU191F–April 2009–Revised April 2014Power Management and Clocks
The device has five reset sources. The following events generate a reset:
•Forcing the RESET_N input pin low
•A power-on reset condition
•A brownout reset condition
•Watchdog Timer reset condition
•Clock-loss reset condition
The initial conditions after a reset are as follows:
•I/O pins are configured as inputs with pullups (P1.0 and P1.1 are inputs, but do not have a pullup or
pulldown)
•CPU program counter is loaded with 0x0000 and program execution starts at this address
•All peripheral registers are initialized to their reset values (see register descriptions)
•Watchdog Timer is disabled
•Clock-loss detetector is disabled
During reset, the I/O pins are configured as inputs with pullups (P1.0 and P1.1 are inputs, but do not have
a pullup or pulldown). The RESET_N input is always configured as an input with pullup.
In the CC2533 and CC2541, a watchdog reset can be generated immediately in software by writing the
SRCRC.FORCE_RESET bit to 1 (see Section 4.3 for the register description). In the other devices in the
family, a watchdog reset can be triggered from software by enabling the watchdog timer with the shortest
time-out and waiting for it to trigger.
The device includes a power-on reset (POR), providing correct initialization during device power on. It also
includes a brownout detector (BOD) operating on the regulated 1.8-V digital power supply only. The BOD
protects the memory contents during supply voltage variations which cause the regulated 1.8-V power to
drop below the minimum level required by digital logic, flash memory, and SRAM.
When power is initially applied, the POR and BOD hold the device in the reset state until the supply
voltage rises above the power-on-reset and brownout voltages.
The cause of the last reset can be read from the register bits SLEEPSTA.RST. It should be noted that a
BOD reset is read as a POR reset.
5.2Clock-Loss Detector
The clock-loss detector can be used in safety-critical systems to detect that one of the XOSC clock
sources (32-MHz XOSC or 32-kHz XOSC) has stopped. This can typically happen due to damage to the
external crystal or supporting components. When the clock-loss detector is enabled, the two clocks
monitor each other continously. If one of the clocks stops toggling, a clock-loss detector reset is generated
within a certain maximum time-out period. The time-out depends on which clock stops. If the 32-kHz clock
stops, the time-out period is 0.5 ms. If the 32-MHz clock stops, the time-out period is 0.25 ms. When the
system comes up again from reset, software can detect the cause of the reset by reading
SLEEPSTA.RST[1:0]. After a reset, the internal RC oscillators are used. Thus, the system is able to start
up again and can then be powered down gracefully. The clock-loss detector is enabled or disabled with
the CLD.EN bit. It is assumed that the 32-MHz XOSC is selected as system clock source when using the
clock-loss detector. The 32-kHz clock can be 32-kHz RCOSC (should be calibrated for accurate reset
timeout) or 32-kHz XOSC.
In power modes 1 and 2, the clock-loss detector is automatically stopped and restarted when the clocks
start up again.
Before entering power mode 3, switch to the 16-MHz RCOSC and disable the clock-loss detector. When
entering active mode again, turn on the clock-loss detector and then switch back to the 32-MHz XOSC.
The device contains flash memory for storage of program code. The flash memory is programmable from
the user software and through the debug interface.
The flash controller handles writing and erasing the embedded flash memory. The embedded flash
memory consists of up to 128 pages of 2048 bytes (CC2530, CC2531, CC2540, and CC2541) or 1024
bytes (CC2533) each.
The flash memory is divided into 2048-byte or 1024-byte flash pages. A flash page is the smallest
erasable unit in the memory, whereas a 32-bit word is the smallest writable unit that can be written to the
flash.
When performing write operations, the flash memory is word-addressable using a 16-bit address written to
the address registers FADDRH:FADDRL.
When performing page-erase operations, the flash memory page to be erased is addressed through the
register bits FADDRH[7:1] (CC2530, CC2531, CC2540, and CC2541) or FADDRH[6:0] (CC2533).
Note the difference in addressing the flash memory; when accessed by the CPU to read code or data, the
flash memory is byte-addressable. When accessed by the flash controller, the flash memory is wordaddressable, where a word consists of 32 bits.
The following sections describe the procedures for flash write and flash page-erase in detail.
6.2Flash Write
The flash is programmed serially with a sequence of one or more 32-bit words (4 bytes), starting at the
start address (set by FADDRH:FADDRL). In general, a page must be erased before writing can begin. The
page-erase operation sets all bits in the page to 1. The chip-erase command (through the debug interface)
erases all pages in the flash. This is the only way to set bits in the flash to 1. When writing a word to the
flash, the 0-bits are programmed to 0 and the 1-bits are ignored (leaves the bit in the flash unchanged).
Thus, bits are erased to 1 and can be written to 0. It is possible to write multiple times to a word. This is
described in Section 6.2.2.
Flash Memory Organization
6.2.1 Flash-Write Procedure
The flash-write sequence algorithm is as follows:
1. Set FADDRH:FADDRL to the start address. (This is the 16 MSBs of the 18-bit byte address).
2. Set FCTL.WRITE to 1. This starts the write-sequence state machine.
3. Write four times to FWDATA within 20 μs (since the last time FCTL.FULL became 0, if not first
iteration). LSB is written first. (FCTL.FULL goes high after the last byte.)
4. Wait until FCTL.FULL goes low. (The flash controller has started programming the 4 bytes written in
step 3 and is ready to buffer the next 4 bytes).
5. Optional status check step:
•If the 4 bytes were not written fast enough in step 3, the operation has timed out and FCTL.BUSY
(and FCTL.WRITE) are 0 at this stage.
•If the 4 bytes could not be written to the flash due to the page being locked, FCTL.BUSY (and
FCTL.WRITE) are 0 and FCTL.ABORT is 1.
6. If this was the last 4 bytes then quit, otherwise go to step 3.
The write operation is performed using one of two methods:
•Using DMA transfer (preferred method)
•Using CPU, running code from SRAM
The CPU cannot access the flash, for example, to read program code while a flash-write operation is in
progress. Therefore, the program code executing the flash write must be executed from RAM. See
Section 2.2.1 for a description of how to run code from RAM.
When a flash-write operation is executed from RAM, the CPU continues to execute code from the next
instruction after initiation of the flash-write operation (FCTL.WRITE = 1).
Power mode 1, 2, or 3 must not be entered while writing to the flash. Also, the system clock source
(XOSC/RCOSC) must not be changed while writing. Note that setting CLKCONSTA.CLKSPD to a high
value makes it impossible to meet the timing requirement of 20-μs write timing. With CLKCONSTA.CLKSPD
= 111, the clock period is only 4 μs. It is therefore recommended to keep CLKCONSTA.CLKSPD at 000 or
001 while writing to the flash.
SWRU191F–April 2009–Revised April 2014Flash Controller
The following rules apply when writing multiple times to a 32-bit word between erase:
•Writing 0 to a bit within a 32-bit flash word, which has been set to 1 by the last erase operation,
changes the state of the bit to 0, subject to the last bullet below.
•It is possible to write 0 to a bit within a 32-bit word repeatedly (subject to the last bullet below) once the
bit has been written with 0. This does not change the state of the bit.
•Writing 1 to a bit does not change the state of the bit, subject to the last bullet below.
•The following limitations apply to writes subsequent to the last page erase:
– A 0 must not be written more than two times to a single bit.
– A 32-bit word shall not be written more than 8 times.
– A page must not be written more than 1024 times.
The state of any bit of a 32-bit flash word is nondeterministic if these limitations are violated.
This makes it possible to write up to 4 new bits to a 32-bit word 8 times. One example write sequence to a
word is shown in Table 6-1. Here bnrepresents the 4 new bits written to the word for each update. This
technique is useful to maximize the lifetime of the flash for data-logging applications.
Table 6-1. Example Write Sequence
StepValue WrittenFLASH Contents After WritingComment
1(page erase)0xFFFFFFFFThe erase sets all bits to 1.
20xFFFFFFFb
30xFFFFFFb1F0xFFFFFFb1b
40xFFFFFb2FF0xFFFFFb2b1b
50xFFFFb3FFF0xFFFFb3b2b1b
60xFFFb4FFFF0xFFFb4b3b2b1b
70xFFb5FFFFF0xFFb5b4b3b2b1b
80xFb6FFFFFF0xFb6b5b4b3b2b1b
90xb7FFFFFFF0xb7b6b5b4b3b2b1b
0
0xFFFFFFFb
www.ti.com
0
0
0
0
0
0
0
0
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
Only the bits written 0 are set to 0, whereas all bits
written 1 are ignored.
6.2.3 DMA Flash Write
When using DMA write operations, the data to be written into flash is stored in the XDATA memory space
(RAM or registers). A DMA channel is configured to read the data to be written from the memory source
address and write this data to the flash write-data register (FWDATA) fixed destination address, with the
DMA trigger event FLASH (TRIG[4:0] = 1 0010 in DMA configuration) enabled. Thus, the flash controller
triggers a DMA transfer when the flash write-data register, FWDATA, is ready to receive new data. The
DMA channel should be configured to perform single-mode, byte-size transfers with the source address
set to start-of-data block and destination address to fixed FWDATA (note that the block size, LEN in
configuration data, must be divisible by 4; otherwise, the last word is not written to the flash). High priority
should also be ensured for the DMA channel, so it is not interrupted in the write process. If interrupted for
more than 20 μs, the write operation may time out, and the write bit, FCTL.WRITE, is set to 0.
When the DMA channel is armed, starting a flash write by setting FCTL.WRITE to 1 triggers the first DMA
transfer (DMA and flash controller handle the reset of the transfer).
Figure 6-1 shows an example of how a DMA channel is configured and how a DMA transfer is initiated to
write a block of data from a location in XDATA to flash memory.
74
Flash ControllerSWRU191F–April 2009–Revised April 2014
To write to the flash using the CPU, a program executing from SRAM must implement the steps outlined
in the procedure described in Section 6.2.1. Disable interrupts to ensure the operation does not time out.
6.3Flash Page Erase
The flash page-erase operation sets all bits in the page to 1.
A page erase is initiated by setting FCTL.ERASE to 1. The page addressed by FADDRH[7:1] (CC2530,
CC2531, CC2540, and CC2541) or FADDRH[6:0] (CC2533) is erased when a page erase is initiated.
Note that if a page erase is initiated simultaneously with a page write, that is, FCTL.WRITE is set to 1, the
page erase is performed before the page-write operation starts. The FCTL.BUSY bit can be polled to see
when the page erase has completed.
Power mode 1, 2, or 3 must not be entered while erasing a page. Also, the system clock source
(XOSC/RCOSC) must not be changed while erasing.
NOTE: If a flash page-erase operation is performed from within flash memory and the Watchdog
Timer is enabled, a Watchdog Timer interval must be selected that is longer than 20 ms, the
duration of the flash page-erase operation, so that the CPU can clear the Watchdog Timer.
Figure 6-1. Flash Write Using DMA
SWRU191F–April 2009–Revised April 2014Flash Controller
Note that while executing program code from within flash memory, when a flash erase or write operation is
initiated the CPU stalls, and program execution resumes from the next instruction when the flash controller
has completed the operation.
The following code example of how to erase one flash page in the CC2530 is given for use with the IAR
compiler:
#include <ioCC2530.h>
unsigned char erase_page_num = 3;/* page number to erase, here: flash page #3 */
/* Erase one flash page */
EA = 0;/* disable interrupts */
while (FCTL & 0x80);/* poll FCTL.BUSY and wait until flash controller is ready */
FADDRH = erase_page_num << 1;/* select the flash page via FADDRH[7:1] bits */
FCTL |= 0x01;/* set FCTL.ERASE bit to start page erase */
while (FCTL & 0x80);/* optional: wait until flash write has completed (~20 ms) */
EA = 1;/* enable interrupts */
6.3.2 Different Flash Page Size on CC2533
The flash page size has been reduced from 2 KB (2048 bytes) on CC2530, CC2531, CC2540, and
CC2541 to 1 KB (1024 bytes) on CC2533. When performing page-erase operations on the flash memory,
the page to be erased is addressed with the register bits FADDRH[6:0] on CC2533 as opposed to
FADDRH[7:1] on CC2530, CC2531, CC2540, and CC2541. The page-lock bits are still placed in the
upper 16 bytes of the last accessible flash page.
www.ti.com
6.4Flash DMA Trigger
The flash DMA trigger is activated when flash data written to the FWDATA register has been written to the
specified location in the flash memory, thus indicating that the flash controller is ready to accept new data
to be written to FWDATA. Four trigger pulses are generated. In order to start the first transfer, one must set
the FCTL.WRITE bit to 1. The DMA and the flash controller then handle all transfers automatically for the
defined block of data (LEN in DMA configuration). It is further important that the DMA is armed prior to
setting the FCTL.WRITE bit, that the trigger source is set to FLASH (TRIG[4:0] = 1 0010), and that
the DMA has high priority so the transfer is not interrupted. If interrupted for more than 20 μs, the write
operation times out and FCTL.WRITE bit is cleared.
6.5Flash Controller Registers
The flash controller registers are described in this section.
76
Flash ControllerSWRU191F–April 2009–Revised April 2014
0RIndicates that write or erase is in operation. This flag is set when the WRITE or
0R/H0 Abort status. This bit is set when a write operation or page erase is aborted. An
01R/WCache mode
0R/W1/
0R/W1/
ERASE bit is set.
0: No write or erase operation active
1: Write or erase operation activated
Write buffer-full status. This flag is set when 4 bytes have been written to FWDATA
R/H0
during flash write. The write buffer is then full and does not accept more data; that
is, writes to FWDATA are ignored when the FULL flag is set. The FULL flag is cleared
when the write buffer again is ready to receive 4 more bytes. This flag is only
needed when the CPU is used to write to the flash.
0: Write buffer can accept more data.
1: Write buffer full
operation is aborted when the page accessed is locked. The abort bit is cleared
when a write or page erase is started.
00: Cache disabled
01: Cache enabled
10: Cache enabled, prefetch mode
11: Cache enabled, real-time mode
Cache mode. Disabling the cache increases the power consumption and reduces
performance. Prefetching, for most applications, improves performance by up to
33% at the expense of potentially increased power consumption. Real-time mode
provides predictable flash-read access time; the execution time is equal to that in
cache-disabled mode, but the power consumption is lower.
Note: The value read always represents the current cache mode. Writing a new
cache mode starts a cache mode-change request that may take several clock cycles
to complete. Writing to this register is ignored if there is a current cache-change
request in progress.
Write. Start writing word at location given by FADDRH:FADDRL. The WRITE bit stays
H0at 1 until the write completes. The clearing of this bit indicates that the erase has
completed, that is, it has timed out or aborted.
If ERASE is also set to 1, a page erase of the whole page addressed by
FADDRH[7:1] is performed before the write. Setting WRITE to 1 when ERASE is 1
has no effect.
Page erase. Erase the page that is given by FADDRH[7:1] (CC2530, CC2531,
H0
CC2540, and CC2541) or FADDRH[6:0] (CC2533). The ERASE bit stays at 1
until the erase completes. The clearing of this bit indicates that the erase has
completed successfully or aborted.
Setting ERASE to 1 when WRITE is 1 has no effect.
Flash Controller Registers
FWDATA (0x6273) – Flash Write Data
BitNameResetR/WDescription
FWDATA[7:0]
7:0
FADDRH (0x6272) – Flash-Address High Byte
BitNameResetR/WDescription
FADDRH[7:0]
7:0
FADDRL (0x6271) – Flash-Address Low Byte
BitNameResetR/WDescription
FADDRL[7:0]
7:0
SWRU191F–April 2009–Revised April 2014Flash Controller
Submit Documentation Feedback
0x00R0/W
0x00R/W Page address and high byte of flash word address
Flash write data. This register can only be written to when FCTL.WRITE is 1.
Bits [7:1] (CC2530, CC2531, CC2540, and CC2541) or bits [6:0] (CC2533)
select which page to access.
77
Chapter 7
SWRU191F–April 2009–Revised April 2014
I/O Ports
There are 21 digital input/output pins that can be configured as general-purpose digital I/O or as peripheral
I/O signals connected to the ADC, timers, or USART peripherals. The use of the I/O ports is fully
configurable from user software through a set of configuration registers.
The I/O ports have the following key features:
•21 digital input/output pins
•General-purpose I/O or peripheral I/O
•Pullup or pulldown capability on inputs
•External interrupt capability
The external interrupt capability is available on all 21 I/O pins. Thus, external devices may generate
interrupts if required. The external interrupt feature can also be used to wake the device up from sleep
mode (power modes PM1, PM2, and PM3).
Unused I/O pins should have a defined level and not be left floating. One way to do this is to leave the pin
unconnected and configure the pin as a general-purpose I/O input with pullup resistor. This is also the
state of all pins during and after reset (except P1.0 and P1.1, which do not have pullup or pulldown
capability). Alternatively, the pin can be configured as a general-purpose I/O output. In either case, the pin
should not be connected directly to VDD or GND, in order to avoid excessive power consumption.
7.2Low I/O Supply Voltage
In applications where the digital I/O power supply voltage pins, DVDD1 and DVDD2, are below 2.6 V, the
register bit PICTL.PADSC should be set to 1 in order to obtain the output dc characteristics specified in
the DC Characteristics table in the device data sheet (Appendix C).
7.3General-Purpose I/O
When used as general-purpose I/O, the pins are organized as three 8-bit ports, Port 0, Port 1, and Port 2;
denoted P0, P1, and P2. P0 and P1 are complete 8-bit-wide ports, whereas P2 has only five usable bits.
All ports are both bit- and byte-addressable through the SFR registers P0, P1, and P2. Each port pin can
individually be set to operate as a general-purpose I/O or as a peripheral I/O.
The output drive strength is 4 mA on all outputs, except for the two high-drive outputs, P1.0 and P1.1,
which each have 20-mA output drive strength.
The registers PxSEL, where x is the port number 0–2, are used to configure each pin in a port as either a
general-purpose I/O pin or as a peripheral I/O signal. By default, after a reset, all digital input/output pins
are configured as general-purpose input pins.
To change the direction of a port pin, the registers PxDIR are used to set each port pin to be either an
input or an output. Thus, by setting the appropriate bit within PxDIR to 1, the corresponding pin becomes
an output.
When reading the port registers P0, P1, and P2, the logic values on the input pins are returned regardless
of the pin configuration. This does not apply during the execution of read-modify-write instructions. The
read-modify-write instructions are: ANL, ORL, XRL, JBC, CPL, INC, DEC, DJNZ, MOV, CLR, and SETB.
Operating on a port register, the following is true: When the destination is an individual bit in port register
P0, P1, or P2, the value of the register, not the value on the pin, is read, modified, and written back to the
port register.
When used as an input, the general-purpose I/O port pins can be configured to have a pullup, pulldown or
three-state mode of operation. By default, after a reset, inputs are configured as inputs with pullup. To
deselect the pullup or pulldown function on an input, the appropriate bit within the PxINP must be set to 1.
The I/O port pins P1.0 and P1.1 do not have pullup or pulldown capability. Note that pins configured as
peripheral I/O signals do not have pullup or pulldown capability, even if the peripheral function is an input.
In power modes PM1, PM2, and PM3, the I/O pins retain the I/O mode and output value (if applicable) that
was set when PM1, PM2, or PM3 was entered.
Unused I/O Pins
7.4General-Purpose I/O Interrupts
General-purpose I/O pins configured as inputs can be used to generate interrupts. The interrupts can be
configured to trigger on either a rising or falling edge of the external signal. Each of the P0, P1, and P2
ports has port interrupt-enable bits common for all bits within the port located in the IEN1–IEN2 registers
as follows:
•IEN1.P0IE: P0 interrupt enable
•IEN2.P1IE: P1 interrupt enable
•IEN2.P2IE: P2 interrupt enable
In addition to these common interrupt enables, the bits within each port have individual interrupt enables
located in SFR registers P0IEN, P1IEN, and P2IEN. Even I/O pins configured as peripheral I/O or
general-purpose outputs have interupts generated when enabled.
When an interrupt condition occurs on one of the I/O pins, the interrupt status flag in the corresponding
P0–P2 interrupt flag register, P0IFG, P1IFG, or P2IFG, is set to 1. The interrupt status flag is set
regardless of whether the pin has its interrupt enable set. When an interrupt is serviced, the interrupt
status flag is cleared by writing a 0 to that flag. This flag must be cleared prior to clearing the CPU port
interrupt flag (PxIF). This is illustrated in Figure 2-4: There is an edge detect between the input line and
PxIFG, but no edge detect or one-shot between PxIFG and PxINT. The practical impact of this is what is
written in Section 2.5.1
The SFR registers used for interrupts are described later in this section. The registers are summarized as
follows:
•P0IEN: P0 interrupt enables
•P1IEN: P1 interrupt enables
•P2IEN: P2 interrupt enables
•PICTL: P0, P1, and P2 edge configuration
•P0IFG: P0 interrupt flags
•P1IFG: P1 interrupt flags
•P2IFG: P2 interrupt flags
7.5General-Purpose I/O DMA
When used as general-purpose I/O pins, the P0 and P1 ports are each associated with one DMA trigger.
These DMA triggers are IOC_0 for P0 and IOC_1 for P1, as shown in Table 8-1.
The IOC_0 trigger is activated when an interrupt occurs on the P0 pins. The IOC_1 trigger is activated
when an interrupt occurs on the P1 pins.
www.ti.com
7.6Peripheral I/O
This section describes how the digital I/O pins are configured as peripheral I/Os. For each peripheral unit
that can interface with an external system through the digital input/output pins, a description of how
peripheral I/Os are configured is given in the following subsections.
For USART and timer I/O, setting the appropriate PxSEL bits to 1 is required for the output signals on a
digital I/O pin to be controlled by the peripheral. For peripheral inputs from digital I/O pins, this is optional.
PxSEL = 1 overrides the pullup or pulldown setting of a pin, so to be able to control pullup and pulldown
with the PxINP bits, the PxSEL bit should be set to 0 for that pin.
Note that peripheral units have two alternative locations for their I/O pins; see Table 7-1. Priority can be
set between peripherals if conflicting settings regarding I/O mapping are present (using the
P2SEL.PRIxP1 and P2DIR.PRIP0 bits). All combinations not causing conflicts can be used.
Note that a peripheral normally is present at the selected location even if it is not used, and another
peripheral that is to use the pins must be given higher priority. The exception is the RTS and CTS pins of
a USART in UART mode with flow control disabled and the SSN pin of a USART configured in SPI master
mode.
Note also that peripheral units that have input pins receive an input from the pin regardless of the PxINP
setting, and this may influence on the state of the peripheral unit. For instance, a UART should be flushed
before use if there may have been activity on the RX pin prior to taking it in use as a UART pin.
PERCFG.T1CFG selects whether to use alternative 1 or alternative 2 locations.
In Table 7-1, the Timer 1 signals are shown as the following:
•0: Channel 0 capture or compare pin
•1: Channel 1 capture or compare pin
•2: Channel 2 capture or compare pin
•3: Channel 3 capture or compare pin
•4: Channel 4 capture or compare pin
P2DIR.PRIP0 selects the order of precedence when assigning several peripherals to Port 0. When set to
10, Timer 1 channels 0–1 have precedence, and when set to 11, Timer 1 channels 2–3 have precedence.
To have all Timer 1 channels visible in the alternative 1 location, move both USART 0 and USART 1 to
the alternative 2 location.
P2SEL.PRI1P1 and P2SEL.PRI0P1 select the order of precedence when assigning several peripherals
to Port 1. The Timer 1 channels have precedence when the former is set low and the latter is set high.
7.6.2 Timer 3
PERCFG.T3CFG selects whether to use alternative 1 or alternative 2 locations.
In Table 7-1, the Timer 3 signals are shown as the following:
P2SEL.PRI2P1 and P2SEL.PRI3P1 select the order of precedence when assigning several peripherals
to Port 1. The Timer 3 channels have precedence when both bits are set high. If P2SEL.PRI2P1 is set
high and P2SEL.PRI3P1 is set low, the Timer 3 channels have precedence over USART 1, but USART 0
has precedence over the Timer 3 channels as well as over USART 1.
7.6.3 Timer 4
PERCFG.T4CFG selects whether to use alternative 1 or alternative 2 locations.
In Table 7-1, the Timer 4 signals are shown as the following:
•0: Channel 0 capture or compare pin
•1: Channel 1 capture or compare pin
P2SEL.PRI1P1 selects the order of precedence when assigning several peripherals to Port 1. The Timer
4 channels have precedence when the bit is set.
7.6.4 USART 0
The SFR register bit PERCFG.U0CFG selects whether to use alternative 1 or alternative 2 locations.
In Table 7-1, the USART 0 signals are shown as follows:
UART:
•RX: RXDATA
•TX: TXDATA
•RT: RTS
•CT: CTS
SPI:
•MI: MISO
•MO: MOSI
•C: SCK
•SS: SSN
P2DIR.PRIP0 selects the order of precedence when assigning several peripherals to Port 0. When set to
00, USART 0 has precedence. Note that if UART mode is selected and hardware flow control is disabled,
USART 1 or Timer 1 has precedence to use ports P0.4 and P0.5.
P2SEL.PRI3P1 and P2SEL.PRI0P1 select the order of precedence when assigning several peripherals
to Port 1. USART 0 has precedence when both are set to 0. Note that if UART mode is selected and
hardware flow control is disabled, Timer 1 or Timer 3 has precedence to use ports P1.2 and P1.3.
www.ti.com
7.6.5 USART 1
The SFR register bit PERCFG.U1CFG selects whether to use alternative 1 or alternative 2 locations.
In Table 7-1, the USART 1 signals are shown as follows:
UART:
P2DIR.PRIP0 selects the order of precedence when assigning several peripherals to Port 0. When set to
01, USART 1 has precedence. Note that if UART mode is selected and hardware flow control is disabled,
USART 0 or Timer 1 has precedence to use ports P0.2 and P0.3.
P2SEL.PRI3P1 and P2SEL.PRI2P1 select the order of precedence when assigning several peripherals
to Port 1. USART 1 has precedence when the former is set to 1 and the latter is set to 0. Note that if
UART mode is selected and hardware flow control is disabled, USART 0 or Timer 3 has precedence to
use ports P1.4 and P1.5.
7.6.6 ADC
In Table 7-1, the ADC signals are shown as follows:
•A0: ADC input 0
•A1: ADC input 1
•A2: ADC input 2
•A3: ADC input 3
•A4: ADC input 4
•A5: ADC input 5
•A6: ADC input 6
•A7: ADC input 7
•T: ADC external trigger pin
When using the ADC, Port 0 pins must be configured as ADC inputs. Up to eight ADC inputs can be used.
To configure a Port 0 pin to be used as an ADC input, the corresponding bit in the APCFG register must be
set to 1. The default values in this register select the Port 0 pins as non-ADC input, i.e., digital
input/outputs.
The settings in the APCFG register override the settings in P0SEL.
Peripheral I/O
The ADC can be configured to use the general-purpose I/O pin P2.0 as an external trigger to start
conversions. P2.0 must be configured as a general-purpose I/O in input mode when being used for ADC
external trigger.
7.6.7 Operational Amplifier and Analog Comparator
When using the operational amplifier and analog comparator, the corresponding Port 0 pins must be
configured as ADC inputs (see Table 7-1). To configure a Port 0 pin to be used as an ADC input, the
corresponding bit in the APCFG register must be set to 1. The default values in this register select the Port
0 pins as non-ADC input, that is, digital input/outputs.
The settings in the APCFG register override the settings in P0SEL.
7.7Debug Interface
Ports P2.1 and P2.2 are used for debug data and clock signals, respectively. These are shown as DD
(debug data) and DC (debug clock) in Table 7-1. When in debug mode, the debug interface controls the
direction of these pins. Pullup and pulldown are disabled on these pins while in debug mode.
7.832-kHz XOSC Input
Ports P2.3 and P2.4 can be used to connect an external 32-kHz crystal. These port pins are used by the
32-kHz XOSC when CLKCONCMD.OSC32K is low, regardless of register settings. The port pins are set in
analog mode when CLKCONCMD.OSC32K is low.
By using the OBSSELx registers (OBSSEL0–OBSSEL5) the user can output different signals from the RF
Core to GPIO pins. These signals can be useful for debugging of low-level protocols or control of external
PA, LNA, or switches. The control registers OBSSEL0–OBSSEL5 can be used to override the standard
GPIO behavior and output RF Core signals (rfc_obs_sig0, rfc_obs_sig1, and rfc_obs_sig2) on
the pins P1[0:5]. For a list of available signals, see the respective RFC_OBS_CTRLx registers in
Section 23.15.3 for CC253x or Section 24.1 for CC2540 or Chapter 25 for CC2541.
7.10 Power-Down Signal MUX (PMUX)
The PMUX register can be used to output the 32-kHz clock and/or the digital voltage regulator status.
The selected 32-kHz clock source can be output on one of the P0 pins. The enable bit CKOEN enables the
output on P0, and the pin of P0 is selected using the CKOPIN (see the PMUX register description for
details). When CKOEN is set, all other configurations for the selected pin are overridden. The clock is
output in all power modes; however, in PM3 the clock stops (see PM3 in Chapter 4).
Furthermore, the digital voltage regulator status can be output on one of the P1 pins. When the DREGSTA
bit is set, the status of the digital voltage regulator is output. DREGSTAPIN selects the P1 pin (see the
PMUX register description for details). When DREGSTA is set, all other configurations for the selected pin
are overridden. The selected pin outputs 1 when the 1.8-V on-chip digital voltage regulator is powered up
(chip has regulated power). The selected pin outputs 0 when the 1.8-V on-chip digital voltage regulator is
powered down, that is, in PM2 and PM3.
7.11 I/O Registers
The registers for the I/O ports are described in this section. The registers are:
P1SEL (0xF4) – Port 1-Function Select
Bit NameResetR/WDescription
SELP1_[7:0]
7:0
P2SEL (0xF5) – Port 2 Function Select and Port 1 Peripheral Priority Control
BitNameResetR/WDescription
7–0R0Reserved
PRI3P1
6
PRI2P1
5
PRI1P1
4
PRI0P1
3
SELP2_4
2
SELP2_3
1
SELP2_0
0
0x00R/WP1.7 to P1.0 function select
0: General-purpose I/O
1: Peripheral function
0R/WPort 1 peripheral priority control. This bit determines which module has priority in the case when
0R/W
0R/W
0R/W
0R/WP2.4 function select
0R/WP2.3 function select
0R/WP2.0 function select
modules are assigned to the same pins.
0:USART 0 has priority.
1:USART 1 has priority.
Port 1 peripheral priority control. This bit determines the order of priority in the case when PERCFG
assigns USART 1 and Timer 3 to the same pins.
0:USART 1 has priority.
1:Timer 3 has priority.
Port 1 peripheral priority control. This bit determines the order of priority in the case when PERCFG
assigns Timer 1 and Timer 4 to the same pins.
0:Timer 1 has priority.
1:Timer 4 has priority.
Port 1 peripheral priority control. This bit determines the order of priority in the case when PERCFG
assigns USART 0 and Timer 1 to the same pins.
0:USART 0 has priority.
1:Timer 1 has priority.
0:General-purpose I/O
1:Peripheral function
0:General-purpose I/O
1:Peripheral function
0:General-purpose I/O
1:Peripheral function
www.ti.com
P0DIR (0xFD) – Port 0 Direction
Bit NameReset R/WDescription
DIRP0_[7:0]
7:0
P1DIR (0xFE) – Port 1 Direction
Bit NameReset R/WDescription
PICTL (0x8C) – Port Interrupt Control
Bit NameResetR/WDescription
PADSC
7
6:4 –000R0Reserved
P2ICON
3
P1ICONH
2
P1ICONL
1
P0ICON
0
0R/WDrive strength control for I/O pins in output mode. Selects output drive strength enhancement to
account for low I/O supply voltage on pin DVDD (this to ensure the same drive strength at lower
voltages as at higher).
0:Minimum drive strength enhancement. DVDD1 and DVDD2 equal to or greater than 2.6 V
1:Maximum drive strength enhancement. DVDD1 and DVDD2 less than 2.6 V
0R/WPort 2, inputs 4 to 0 interrupt configuration. This bit selects the interrupt request condition for Port 2
inputs 4 to 0.
0:Rising edge on input gives interrupt.
1:Falling edge on input gives interrupt.
0R/WPort 1, inputs 7 to 4 interrupt configuration. This bit selects the interrupt request condition for the high
nibble of Port 1 inputs.
0:Rising edge on input gives interrupt.
1:Falling edge on input gives interrupt
0R/WPort 1, inputs 3 to 0 interrupt configuration. This bit selects the interrupt request condition for the low
nibble of Port 1 inputs.
0:Rising edge on input gives interrupt.
1:Falling edge on input gives interrupt.
0R/WPort 0, inputs 7 to 0 interrupt configuration. This bit selects the interrupt request condition for all Port
0 inputs.
0:Rising edge on input gives interrupt.
1:Falling edge on input gives interrupt.
I/O Registers
P0IEN (0xAB) – Port 0 Interrupt Mask
Bit NameReset R/WDescription
P0_[7:0]IEN
7:0
P1IEN (0x8D) – Port 1 Interrupt Mask
Bit NameReset R/WDescription
P1_[7:0]IEN
7:0
P2IEN (0xAC) – Port 2 Interrupt Mask
Bit NameReset R/WDescription
7:6 –00R0Reserved
DPIEN
5
P2_[4:0]IEN
4:0
0x00R/WPort P0.7 to P0.0 interrupt enable
0:Interrupts are disabled.
1:Interrupts are enabled.
0x00R/WPort P1.7 to P1.0 interrupt enable
0:Interrupts are disabled.
1:Interrupts are enabled.
PMUX (0xAE) – Power-Down Signal Mux
Bit NameReset R/W Description
CKOEN
7
CKOPIN[2:0]
6:4
DREGSTA
3
DREGSTAPIN[2:0]
2:0
0R/W Clock Out Enable. When this bit is set, the selected 32-kHz clock is output on one of the P0
pins. CKOPIN selects the pin to use. This overrides all other configurations for the selected
pin. The clock is output in all power modes; however, in PM3 the clock stops (see PM3 in
Chapter 4).
000R/W Clock Out Pin. Selects which P0 pin is to be used to output the selected 32-kHz clock.
0R/W Digital Voltage Regulator Status. When this bit is set, the status of the digital voltage regulator
is output on one of the P1 pins. DREGSTAPIN selects the pin. When DREGSTA is set, all other
configurations for the selected pin are overridden. The selected pin outputs 1 when the 1.8-V
on-chip digital voltage regulator is powered up (chip has regulated power). The selected pin
outputs 0 when the 1.8-V on-chip digital voltage regulator is powered down.
000R/W Digital Voltage Regulator Status Pin. Selects which P1 pin is to be used to output
the DREGSTA signal.
Note that registers OBSSEL0 through OBSSEL5 do not retain data in states PM2 and PM3.
OBSSEL0 (0x6243) – Observation Output Control Register 0
Bit NameResetR/WDescription
EN
7
6:0
SEL[6:0]
0R/WBit controlling the observation output 0 on P1[0].
0 – Observation output disabled
1 – Observation output enabled
Note: If enabled, this overwrites the standard GPIO behavior of P1.0.
000 0000 R/WSelect output signal on observation output 0
The Direct Memory Access (DMA) Controller can be used to relieve the 8051 CPU core of handling data
movement operations, thus achieving high overall performance with good power efficiency. The DMA
controller can move data from a peripheral unit such as ADC or RF transceiver to memory with minimum
CPU intervention.
The DMA controller coordinates all DMA transfers, ensuring that DMA requests are prioritized
appropriately relative to each other and to CPU memory access. The DMA controller contains a number of
programmable DMA channels for memory-memory data movement.
The DMA controller controls data transfers over the entire address range in XDATA memory space.
Because most of the SFR registers are mapped into the DMA memory space, these flexible DMA
channels can be used to unburden the CPU in innovative ways, for example, to feed a USART with data
from memory or periodically to transfer samples between ADC and memory, and so forth. Use of the DMA
can also reduce system power consumption by keeping the CPU in a low-power mode without having to
wake up to move data to or from a peripheral unit (see Section 4.1.1 for CPU low-power mode). Note that
Section 2.2.3 describes the SFR registers that are not mapped into XDATA memory space.
The main features of the DMA controller are as follows:
•Five independent DMA channels
•Three configurable levels of DMA channel priority
•32 configurable transfer trigger events
•Independent control of source and destination address
•Single, block and repeated transfer modes
•Supports length field in transfer data, setting variable transfer length
•Can operate in either word-size or byte-size mode
There are five DMA channels available in the DMA controller, numbered channel 0 through channel 4.
Each DMA channel can move data from one place within the DMA memory space to another, that is,
between XDATA locations.
In order to use a DMA channel, it must first be configured as described in Section 8.2 and Section 8.3.
Figure 8-1 shows the DMA state diagram.
Once a DMA channel has been configured, it must be armed before any transfers are allowed to be
initiated. A DMA channel is armed by setting the appropriate bit in the DMA channel-arm register DMAARM.
When a DMA channel is armed, a transfer begins when the configured DMA trigger event occurs. Note
that the time to arm one channel (that is, get configuration data) takes nine system clocks; thus, if the
corresponding DMAARM bit is set and a trigger appears within the time it takes to configure the channel, the
wanted trigger is lost. If two or more DMA channels are armed simultaneously, the time for all channels to
be configured is longer (sequential read from memory). If all five are armed, it takes 45 system clocks, and
channel 1 is ready first, then channel 2, and lastly channel 0 (all within the last eight system clocks). There
are 32 possible DMA trigger events (see Table 8-1), for example, UART transfer, timer overflow. The
trigger event to be used by a DMA channel is set by the DMA channel configuration; thus, no knowledge
of this is available until after the configuration has been read. The DMA trigger events are listed in
Table 8-1.
In addition to starting a DMA transfer through the DMA trigger events, the user software may force a DMA
transfer to begin by setting the corresponding DMAREQ bit.
It should be noted that if the previously configured trigger source generates trigger events while DMA is
being configured, these are counted as missed events, and as soon as the DMA channel is ready, the
transfer is started. This occurs even though the new trigger source is not the same as the previous one. In
some situations, this leads to errors in the transfer. In order to account for this, trigger source 0 should be
the source between reconfigurations. This is achieved by setting up dummy source and destination
addresses, using fixed length of one byte, block transfer, and trigger source 0. Enabling a software trigger
(DMAREQ) clears missed-trigger counting, and no new triggers are generated while a new configuration is
fetched from memory (unless software writes to DMAREQ for this channel).
A DMAREQ bit is cleared only when the corresponding DMA transfer occurs. The DMAREQ bit is not cleared
when the channel is disarmed.
DMA Operation
SWRU191F–April 2009–Revised April 2014DMA Controller
Setup and control of the DMA operation is performed by the user software. This section describes the
parameters which must be configured before a DMA channel can be used. Section 8.3 describes how the
parameters are set up in software and passed to the DMA controller.
The behavior of each of the five DMA channels is configured with the following parameters:
Source address: The first address from which the DMA channel should read data.
Destination address: The first address to which the DMA channel should write the data read from the
source address. The user must ensure that the destination is writable.
Transfer count: The number of transfers to perform before rearming or disarming the DMA channel
and alerting the CPU with an interrupt request. The length can be defined in the configuration or it can
be defined as described next for the VLEN setting.
VLEN setting: The DMA channel is capable of variable-length transfers, using the first byte or word to
set the transfer length. When doing this, various options are available regarding how to count the
number of bytes to transfer.
Priority: The priority of the DMA transfers for the DMA channel with respect to the CPU and other
DMA channels and access ports.
Trigger event: All DMA transfers are initiated by so-called DMA trigger events. This trigger either
starts a DMA block transfer or a single DMA transfer. In addition to the configured trigger, a DMA
channel can always be triggered by setting its designated DMAREQ.DMAREQx flag. The DMA trigger
sources are described in Table 8-1.
Source and destination increment: The source and destination addresses can be controlled to
increment or decrement or not change.
Transfer mode: The transfer mode determines whether the transfer should be a single transfer or a
block transfer, or repeated versions of these.
Byte or word transfers: Determines whether each DMA transfer should be 8-bit (byte) or 16-bit
(word).
Interrupt mask: An interrupt request is generated on completion of the DMA transfer. The interrupt
mask bit controls whether the interrupt generation is enabled or disabled.
M8: Decide whether to use seven or eight bits per byte byte for transfer length. This is only applicable
when doing byte transfers.
A detailed description of all configuration parameters is given in Section 8.2.1 through Section 8.2.11.
DMA Configuration Parameters
8.2.1 Source Address
The address in XDATA memory where the DMA channel starts to read data. This can be any XDATA
address – in RAM, in the mapped flash bank (see MEMCTR.XBANK), XREG, or XDATA addressed SFR.
8.2.2 Destination Address
The first address to which the DMA channel should write the data read from the source address. The user
must ensure that the destination is writable. This can be any XDATA address – in RAM, XREG, or XDATA
addressed SFR.
8.2.3 Transfer Count
The number of bytes/words that must be transferred for the DMA transfer to be complete. When the
transfer count is reached, the DMA controller rearms or disarms the DMA channel and alerts the CPU with
an interrupt request. The transfer count can be defined in the configuration or it can be defined as
variable-length, as described in Section 8.2.4.
SWRU191F–April 2009–Revised April 2014DMA Controller
The DMA channel is capable of using the first byte or word (for word, bits 12:0 are used) in source data as
the transfer length. This allows variable-length transfers. When using variable-length transfer, various
options regarding how to count number of bytes to transfer are given. In any case, the transfer-count
(LEN) setting is used as a maximum transfer count. If the transfer length specified by the first byte or word
is greater than LEN, then LEN bytes or words are transferred. When using variable-length transfers, then
LEN should be set to the largest allowed transfer length plus one.
Note that the M8 bit (Section 8.2.11) is only used when byte-size transfers are chosen.
Options which can be set with VLEN are the following:
1. Transfer number of bytes or words commanded by first byte/word + 1 (transfers the length byte/word,
and then as many bytes/words as dictated by the length byte/word)
2. Transfer number of bytes or words commanded by first byte/word
3. Transfer number of bytes or words commanded by first byte/word + 2 (transfers the length byte/word,
and then as many bytes/words as dictated by the length byte/word + 1)
4. Transfer number of bytes or words commanded by first byte/word + 3 (transfers the length byte/word,
and then as many bytes/words as dictated by the length byte/word + 2)
Figure 8-2 shows the VLEN options.
www.ti.com
Figure 8-2. Variable Length (VLEN) Transfer Options
8.2.5 Trigger Event
Each DMA channel can be set up to sense on a single trigger. This field determines which trigger the
DMA channel senses.
8.2.6 Source and Destination Increment
When the DMA channel is armed or rearmed, the source and destination addresses are transferred to
internal address pointers. The possibilities for address increment are:
96
•Increment by zero. The address pointer remains fixed after each transfer.
•Increment by one. The address pointer increments one count after each transfer.
•Increment by two. The address pointer increments two counts after each transfer.
•Decrement by one. The address pointer decrements one count after each transfer.
where a count equals 1 byte in byte mode and 2 bytes in word mode.
DMA ControllerSWRU191F–April 2009–Revised April 2014
The transfer mode determines how the DMA channel behaves when it starts transferring data. There are
four transfer modes described as follows:
Single: On a trigger, a single DMA transfer occurs, and the DMA channel awaits the next trigger. After
the number of transfers specified by the transfer count is completed, the CPU is notified, and the DMA
channel is disarmed.
Block: On a trigger, the number of DMA transfers specified by the transfer count is performed as
quickly as possible, after which the CPU is notified and the DMA channel is disarmed.
Repeated single: On a trigger, a single DMA transfer occurs, and the DMA channel awaits the next
trigger. After the number of transfers specified by the transfer count is completed, the CPU is notified,
and the DMA channel is rearmed.
Repeated block: On a trigger, the number of DMA transfers specified by the transfer count is
performed as quickly as possible, after which the CPU is notified and the DMA channel is rearmed.
8.2.8 DMA Priority
A DMA priority is configurable for each DMA channel. The DMA priority is used to determine the winner in
the case of multiple simultaneous internal memory requests, and whether the DMA memory access should
have priority or not over a simultaneous CPU memory access. In case of an internal tie, a round-robin
scheme is used to ensure access for all. There are three levels of DMA priority:
High: Highest internal priority. DMA access always prevails over CPU access.
Normal: Second-highest internal priority. DMA access prevails over the CPU on at least every second
try.
Low: Lowest internal priority. DMA access always defers to a CPU access.
DMA Configuration Parameters
8.2.9 Byte or Word Transfers
Determines whether 8-bit (byte) or 16-bit (word) transfers are done.
8.2.10 Interrupt Mask
On completing a DMA transfer, the channel can generate an interrupt to the processor. This bit masks the
interrupt.
8.2.11 Mode 8 Setting
This field determines whether to use 7 or 8 bits per byte for transfer length. Only applicable when doing
byte transfers.
8.3DMA Configuration Setup
The DMA channel parameters such as address mode, transfer mode, and priority, described in the
previous section, must be configured before a DMA channel can be armed and activated. The parameters
are not configured directly through SFR registers, but instead they are written in a special DMA
configuration-data structure in memory. Each DMA channel in use requires its own DMA configurationdata structure. The DMA configuration-data structure consists of eight bytes and is described in
Section 8.6. A DMA configuration-data structure may reside at any location decided on by the user
software, and the address location is passed to the DMA controller through a set of SFRs,
DMAxCFGH:DMAxCFGL. Once a channel has been armed, the DMA controller reads the configuration data
structure for that channel, given by the address in DMAxCFGH:DMAxCFGL.
It is important to note that the method for specifying the start address for the DMA configuration data
structure differs between DMA channel 0 and DMA channels 1–4 as follows:
DMA0CFGH:DMA0CFGL gives the start address for the DMA channel 0 configuration data structure.
DMA1CFGH:DMA1CFGL gives the start address for the DMA channel 1 configuration data structure,
followed by the channel 2–4 configuration-data structures.
SWRU191F–April 2009–Revised April 2014DMA Controller
Thus, the DMA controller expects the DMA configuration data structures for DMA channels 1–4 to lie in a
contiguous area in memory starting at the address held in DMA1CFGH:DMA1CFGL and consisting of 32
bytes.
8.4Stopping DMA Transfers
Ongoing DMA transfers or armed DMA channels are aborted using the DMAARM register to disarm the
DMA channel.
One or more DMA channels are aborted by writing a 1 to the DMAARM.ABORT register bit, and at the same
time selecting which DMA channels to abort by setting the corresponding DMAARM.DMAARMx bits to 1.
When setting DMAARM.ABORT to 1, the DMAARM.DMAARMx bits for nonaborted channels must be written
as 0.
No DMA interrupt is generated when aborting an ongoing DMA transfer (disarming a DMA channel).
8.5DMA Interrupts
Each DMA channel can be configured to generate an interrupt to the CPU on completing a DMA transfer.
This is accomplished with the IRQMASK bit in the channel configuration. The corresponding interrupt flag
in the DMAIRQ SFR register is set when the interrupt is generated.
Regardless of the IRQMASK bit in the channel configuration, the corresponding interrupt flag in the
DMAIRQ register is set on DMA channel completion. Thus, software should always check (and clear) this
register when rearming a channel with a changed IRQMASK setting. Failure to do so could generate an
interrupt based on the stored interrupt flag.
If a DMA transfer is aborted prior to its completion, the corresponding bit in the DMAIRQ register is not set,
and an interrupt is not generated.
www.ti.com
8.6DMA Configuration-Data Structure
For each DMA channel, the DMA configuration-data structure consists of eight bytes. The configurationdata structure is described in Table 8-2.
8.7DMA Memory Access
The DMA data transfer is affected by endian convention. Note that the DMA descriptors follow big-endian
convention while the other registers follow little-endian convention. This must be accounted for in
compilers.
20ADC_CHALL ADCADC end of a conversion in a sequence, sample ready
21ADC_CH11ADCADC end of conversion channel 0 in sequence, sample ready
22ADC_CH21ADCADC end of conversion channel 1 in sequence, sample ready
23ADC_CH32ADCADC end of conversion channel 2 in sequence, sample ready
24ADC_CH42ADCADC end of conversion channel 3 in sequence, sample ready
25ADC_CH53ADCADC end of conversion channel 4 in sequence, sample ready
26ADC_CH63ADCADC end of conversion channel 5 in sequence, sample ready
27ADC_CH74ADCADC end of conversion channel 6 in sequence, sample ready
28ADC_CH84ADCADC end of conversion channel 7 in sequence, sample ready
29ENC_DWAESAES encryption processor requests download of input data
30ENC_UPAESAES encryption processor requests upload of output data
31DBG_BWDebug interfaceDebug interface burst write
(1)
DMA Memory Access
Table 8-1. DMA Trigger Sources (continued)
DMA Trigger
NumberName
Using this trigger source must be aligned with port interrupt-enable bits. Note that all interrupt-enabled port pins generate a
trigger.
DMA channel source address, high
DMA channel source address, low
DMA channel destination address, high. Note that flash memory is not directly writable.
DMA channel destination address, low. Note that flash memory is not directly writable.
Variable-length transfer mode. In word mode, bits 12:0 of the first word are considered as
the transfer length.
000:Use LEN for transfer count
001:Transfer the number of bytes or words specified by the first byte or word + 1 (up to
a maximum specified by LEN). Thus, the transfer count excludes the length byte or
word.
010:Transfer the number of bytes or words specified by the first byte or word (up to a
maximum specified by LEN). Thus, the transfer count includes the length byte or
word.
011:Transfer the number of bytes/words specified by the first byte/word + 2 (up to a
maximum specified by LEN).
100:Transfer the number of bytes/words specified by the first byte/word + 3 (up to a
maximum specified by LEN).
101:Reserved
110:Reserved
111:Alternative for using LEN as the transfer count
The DMA channel transfer count
SWRU191F–April 2009–Revised April 2014DMA Controller
Used as the maximum allowable length when VLEN differs from 000 and 111. The DMA
channel counts in words when in WORDSIZE mode, and in bytes otherwise.
The DMA channel transfer count
Used as the maximum allowable length when VLEN differs from 000 and 111. The DMA
channel counts in words when in WORDSIZE mode, and in bytes otherwise.
Selects whether each DMA transfer is 8-bit (0) or 16-bit (1).
The DMA channel transfer mode
00:Single
01:Block
10:Repeated single
11:Repeated block
Selects one of the triggers shown in Table 8-1
Source address increment mode (after each transfer):
00:0 bytes or words
01:1 byte or word
10:2 bytes or word
11:–1 byte or word
Destination address increment mode (after each transfer):
00:0 bytes or words
01:1 byte or word
10:2 bytes or words
11:–1 byte or word
Interrupt mask for this channel.
0:Disable interrupt generation
1:Enable interrupt generation on DMA channel done
Mode of 8th bit for VLEN transfer length; only applicable when WORDSIZE = 0 and VLEN
differs from 000 and 111.
0:Use all 8 bits for transfer count
1:Use 7 LSB for transfer count
The DMA channel priority:
00:Low, CPU has priority.
01:Assured, DMA at least every second try
10:High, DMA has priority
11:Reserved
100
DMA ControllerSWRU191F–April 2009–Revised April 2014