CP3UB17 Reprogrammable Connectivity Processor
with USB Interface
1.0General Description
The CP3UB17 connectivity processor combines a powerful
RISC core with on-chip SRAM and Flash memory for high
computing bandwidth, hardware communications peripherals for high I/O bandwidth, and an external bus for system
expandability.
On-chip communications peripherals include: USB controller, ACCESS.bus, Microwire/Plus, SPI, UART, and Advanced Audio Interface (AAI). Additional on-chip peripherals
include DMA controller, PCM/CSVD conversion module,
Timing and Watchdog Unit, Versatile Timer Unit, MultiFunction Timer, and Multi-Input Wakeup.
The CP3UB17 is backed up by the software resources designers need for rapid time-to-market, including an operating system, peripheral drivers, reference designs, and an
integrated development environment.
National Semiconductor offers a complete and industryproven application development environment for CP3UB17
applications, including the IAR Embedded Workbench,
iSYSTEM winIDEA and iC3000 Active Emulator, Development Board, and Application Software.
CP3UB17 Connectivity Processor with USB Interface
PRELIMINARY
Sept. 2003
Block Diagram
12 MHz and 32 kHz
Oscillator
CR16C
CPU Core
Bus
Interface
Unit
Clock Generator
PLL and Clock
Generator
DMA
Controller
GPIOUSB
256K Bytes
Flash
Program
Memory
Peripheral
Controller
Audio
Interface
Power-on-Reset
Bus
Microwire/
SPI
8K Bytes
Flash
Data
CPU Core Bus
Interrupt
Control
Unit
Peripheral Bus
UART
CVSD/PCM
ACCESS
.bus
10K Bytes
Static
RAM
Versatile
Timer Unit
Powe r
Manage-
ment
Muti-Func-
tion Timer
Serial
Debug
Interface
Timing and
Watchdog
Unit
Multi-Input
Wake-Up
DS131
TRI-STATE is a registered trademark of National Semiconductor Corporation.
Fully static RISC processor core, capable of operating
from 0 to 24 MHz with zero wait/hold states
Minimum 41.7 ns instruction cycle time with a 24-MHz in-
ternal clock frequency, based on a 12-MHz external input
30 independently vectored peripheral interrupts
On-Chip Memory
256K bytes reprogrammable Flash program memory
8K bytes Flash data memory
10K bytes of static RAM data memory
Addresses up to 8 Mbytes of external memory
Broad Range of Hardware Communications Peripherals
Full-speed USB node including seven Endpoint-FIFOs
conforming to USB 1.1 specification
ACCESS.bus serial bus (compatible with Philips I
8/16-bit SPI, Microwire/Plus serial interface
Universal Asynchronous Receiver/Transmitter (UART)
Advanced Audio Interface (AAI) to connect to external 8/
13-bit PCM Codecs as well as to ISDN-Controllers
through the IOM-2 interface (slave only)
PCM/CVSD converter supporting one bidirectional audio
connection
General-Purpose Hardware Peripherals
Dual 16-bit Multi-Function Timer
Versatile Timer Unit with four subsystems (VTU)
Four channel DMA controller
Timing and Watchdog Unit
2
C bus)
CP3UB17
Flexible I/O
Up to 37 general-purpose I/O pins (shared with on-chip
The CP3UB17 connectivity processor is a complete microcomputers with all system timing, interrupt logic, program
CP3UB17
memory, data memory, I/O ports included on-chip, making
them well-suited to a wide range of embedded applications.
The block diagram on page 1 shows the major on-chip components of the CP3UB17.
3.1CR16C CPU CORE
The CP3UB17 implements the CR16C CPU core module.
The high performance of the CPU core results from the implementation of a pipelined architecture with a two-bytesper-cycle pipelined system bus. As a result, the CPU can
support a peak execution rate of one instruction per clock
cycle.
For more information, please refer to the CR16C Programmer’s Reference Manual (document number 424521772101, which may be downloaded from National’s web site at
http://www.national.com).
The I/O pin characteristics are fully programmable. Each pin
can be configured to operate as a TRI-STATE output, pushpull output, weak pull-up input, or high-impedance input.
3.4BUS INTERFACE UNIT
The Bus Interface Unit (BIU) controls access to internal/external memory and I/O. It determines the configured parameters for bus access (such as the number of wait states for
memory access) and issues the appropriate bus signals for
each requested access.
The BIU uses a set of control registers to determine how
many wait states and hold states are used when accessing
Flash program memory, and the I/O area (Port B and Port
C). At start-up, the configuration registers are set for slowest
possible memory access. To achieve fastest possible program execution, appropriate values must be programmed.
These settings vary with the clock frequency and the type of
off-chip device being accessed.
3.2MEMORY
The CP3UB17 supports a uniform linear address space of
up to 16 megabytes. Three types of on-chip memory occupy
specific regions within this address space:
256K bytes of Flash program memory
8K bytes of Flash data memory
10K bytes of static RAM
Up to 8M bytes of external memory (100-pin devices )
The 256K bytes of Flash program memory are used to store
the application program and real-time operating system.
The Flash memory has security features to prevent unintentional programming and to prevent unauthorized access to
the program code. This memory can be programmed with
an external programming unit or with the device installed in
the application system (in-system programming).
The 8K bytes of Flash data memory are used for non-volatile storage of data entered by the end-user, such as configuration settings.
The 10K bytes of static RAM are used for temporary storage
of data and for the program stack and interrupt stack. Read
and write operations can be byte-wide or word-wide, depending on the instruction executed by the CPU.
Up to 8M bytes of external memory can be added on an external bus. The external bus is only available on devices in
100-pin packages.
For Flash program and data memory, the device internally
generates the necessary voltages for programming. No additional power supply is required.
3.3INPUT/OUTPUT PORTS
The device has up to 37 software-configurable I/O pins, organized into five ports called Port B, Port C, Port G, Port H,
and Port I. Each pin can be configured to operate as a general-purpose input or general-purpose output. In addition,
many I/O pins can be configured to operate as inputs or outputs for on-chip peripheral modules such as the UART, timers, or Microwire/SPI interface.
3.5INTERRUPT CONTROL UNIT (ICU)
The ICU receives interrupt requests from internal and external sources and generates interrupts to the CPU. An interrupt is an event that temporarily stops the normal flow of
program execution and causes a separate interrupt handler
to be executed. After the interrupt is serviced, CPU execution continues with the next instruction in the program following the point of interruption.
Interrupts from the timers, UART, Microwire/SPI interface,
and Multi-Input Wake-Up, are all maskable interrupts; they
can be enabled or disabled by software. There are 32 of
these maskable interrupts, assigned to 32 linear priority levels.
The highest-priority interrupt is the Non-Maskable Interrupt
), which is generated by a signal received on the NMI
(NMI
input pin.
3.6USB
The USB node is a Universal Serial Bus (USB) Node controller compatible with USB Specification, 1.0 and 1.1. It integrates the required USB transceiver, the Serial Interface
Engine (SIE), and USB endpoint FIFOs. A total of seven
endpoint pipes are supported: one bidirectional pipe for the
mandatory control EP0 and an additional six pipes for unidirectional endpoints to support USB interrupt, bulk, and isochronous data transfers.
3.7MULTI-INPUT WAKE-UP
The Multi-Input Wake-Up (MIWU) module can be used for
either of two purposes: to provide inputs for waking up (exiting) from the Halt, Idle, or Power Save mode; or to provide
general-purpose edge-triggered maskable interrupts from
external sources. This 16-channel module generates four
programmable interrupts to the CPU based on the signals
received on its 16 input channels. Channels can be individually enabled or disabled, and programmed to respond to
positive or negative edges.
www.national.com4
3.8TRIPLE CLOCK AND RESET
The Triple Clock and Reset module generates a high-speed
main System Clock from an external crystal network. It also
provides the main system reset signal and a power-on reset
function.
This module generates a slow System Clock (32.768 kHz)
from an optional external crystal network. The Slow Clock is
used for operating the device in power-save mode. The
32.768 kHz external crystal network is optional, because
the low speed System Clock can be derived from the highspeed clock by a prescaler.
Also, two independent clocks divided down from the high
speed clock are available on output pins.
The Triple Clock and Reset module provides the clock signals required for the operation of the various CP3UB17 onchip modules. From external crystal networks, it generates
the Main Clock, which can be scaled up to 24 MHz from an
external 12 MHz input clock, and a 32.768 kHz secondary
System Clock. The 12 MHz external clock is primarily used
as the reference frequency for the on-chip PLL. Also the
clock for modules which require a fixed clock rate (e.g. the
PCM/CVSD transcoder) is generated through prescalers
from the 12 MHz clock. The PLL generates the input clock
for the USB node and may be used to drive the high-speed
System Clock through a prescaler. Alternatively, the high
speed System Clock can be derived directly from the 12
MHz Main Clock.
In addition, this module generates the device reset by using
reset input signals coming from an external reset and various on-chip modules.
3.9POWER MANAGEMENT
The Power Management Module (PMM) improves the efficiency of the device by changing the operating mode and
power consumption to match the required level of activity.
The device can operate in any of four power modes:
Active—The device operates at full speed using the high-
frequency clock. All device functions are fully operational.
Power Save —The device operates at reduced speed us-
ing the Slow Clock. The CPU and some modules can
continue to operate at this low speed.
Idle—The device is inactive except for the Power Man-
agement Module and Timing and Watchdog Module,
which continue to operate using the Slow Clock.
Halt—The device is inactive but still retains its internal
state (RAM and register contents).
3.10MULTI-FUNCTION TIMER
The Multi-Function Timer (MFT) module contains a pair of
16-bit timer/counter registers. Each timer/counter unit can
be configured to operate in any of the following modes:
mode—Generates pulses of a specified width and duty
cycle and provides a general-purpose timer/counter.
Dual Input Capture mode—Measures the elapsed time
between occurrences of external event and provides a
general-purpose timer/counter.
Dual Independent Timer mode—Generates system tim-
ing signals or counts occurrences of external events.
Single Input Capture and Single Timer mode—Provides
one external event counter and one system timer.
3.11VERSATILE TIMER UNIT
The Versatile Timer Unit (VTU) module contains four independent timer subsystems, each operating in either dual 8bit PWM configuration, as a single 16-bit PWM timer, or a
16-bit counter with two input capture channels. Each of the
four timer subsystems offer an 8-bit clock prescaler to accommodate a wide range of frequencies.
3.12TIMING AND WATCHDOG MODULE
The Timing and Watchdog Module (TWM) contains a RealTime timer and a Watchdog unit. The Real-Time Clock Timing function can be used to generate periodic real-time
based system interrupts. The timer output is one of 16 inputs to the Multi-Input-Wake-Up module which can be used
to exit from a power-saving mode. The Watchdog unit is designed to detect the application program getting stuck in an
infinite loop resulting in loss of program control or “runaway”
programs. When the watchdog triggers, it resets the device.
The TWM is clocked by the low-speed System Clock.
3.13UART
The UART supports a wide range of programmable baud
rates and data formats, parity generation, and several error
detection schemes. The baud rate is generated on-chip, under software control.
The UART offers a wake-up condition from the power-save
mode using the Multi-Input Wake-Up module.
3.14MICROWIRE/SPI
The Microwire/SPI (MWSPI) interface module supports synchronous serial communications with other devices that
conform to Microwire or Serial Peripheral Interface (SPI)
specifications. It supports 8-bit and 16-bit data transfers.
The Microwire interface allows several devices to communicate over a single system consisting of four wires: serial in,
serial out, shift clock, and slave enable. At any given time,
the Microwire interface operates as the master or a slave.
The Microwire interface supports the full set of slave select
for multi-slave implementation.
In master mode, the shift clock is generated on chip under
software control. In slave mode, a wake-up out of powersave mode is triggered using the Multi-Input Wake-Up module.
3.15ACCESS.BUS INTERFACE
The ACCESS.bus interface module (ACB) is a two-wire serial interface with the ACCESS.bus physical layer. It is also
compatible with Intel’s System Management Bus (SMBus)
and Philips’ I
a bus master or slave, and can maintain bidirectional communications with both multiple master and slave devices.
The ACCESS.bus receiver can trigger a wake-up condition
out of the low-power modes using the Multi-Input Wake-Up
module.
2
C bus. The ACB module can be configured as
CP3UB17
5www.national.com
3.16DMA CONTROLLER
The Direct Memory Access Controller (DMAC) can speed
up data transfer between memory and I/O devices or be-
CP3UB17
tween two memories, relative to data transfers performed
directly by the CPU. A method called cycle-stealing allows
the CPU and the DMAC to use the core bus in parallel.
The DMAC implements four independent DMA channels.
DMA requests from a primary and a secondary source
are recognized for each DMA channel, as well as a software DMA request issued directly by the CPU. Table 1
shows the DMA channel assignment on the CP3UB17 architecture. The following on-chip modules can assert a
DMA request to the DMAC:
Table 1 shows how the four DMA channels are assigned
to the modules listed above.
Table 1 DMA Channel Assignment
Channel
0
1
Primary/
Secondary
PrimaryUSBRead/Write
SecondaryUARTRead
PrimaryUARTWrite
SecondaryUnusedN/A
PeripheralTransaction
3.18CVSD/PCM CONVERSION MODULE
The CVSD/PCM module performs conversion between
CVSD data and PCM data, in which the PCM data can be
8-bit µ-Law, 8-bit A-Law, or 13-bit to 16-bit Linear.
3.19SERIAL DEBUG INTERFACE
The Serial Debug Interface module (SDI module)provides a
JTAG-based serial link to an external debugger, for example
running on a PC. In addition, the SDI module integrates an
on-chip debug module, which allows the user to set up to
four hardware breakpoints on instruction execution and data
transfer. The SDI module can act as a CPU bus master to
access all memory mapped resources, such as RAM and
peripherals. Therefore it also allows for fast program code
download into the on-chip Flash program memory using the
JTAG interface.
3.20DEVELOPMENT SUPPORT
The CP3UB17 is backed up by the software resources designers need for rapid time-to-market, including an operating system, peripheral drivers, reference designs, and an
integrated development environment.
National Semiconductor offers a complete and industryproven application development environment for CP3UB17
applications, including the IAR Embedded Workbench,
iSYSTEM winIDEA and iC3000 Active Emulator, Development Board, and Application Software. See your National
Semiconductor sales representative for current information
on availability and features of emulation equipment and
evaluation boards.
2
3
PrimaryAAIRead
SecondaryCVSD/PCMRead
PrimaryAAIWrite
SecondaryCVSD/PCMWrite
3.17ADVANCED AUDIO INTERFACE
The audio interface provides a serial synchronous, full-duplex interface to CODECs and similar serial devices. Transmit and receive paths operate asynchronously with respect
to each other. Each path uses three signals for communication: shift clock, frame synchronization, and data.
In case receive and transmit use separate shift clocks and
frame sync signals, the interface operates in its asynchronous mode. Alternatively, the transmit and receive path can
share the same shift clock and frame sync signals for synchronous mode operation.
The interface can handle data words of either 8- or 16-bit
length and data frames can consist of up to four slots.
In the normal mode of operation, the interface only transfers
one word at a periodic rate. In the network mode, the interface transfers multiple words at a periodic rate. The periodic
rate is also called a data frame and each word within one
frame is called a slot. The beginning of each new data frame
is marked by the frame sync signal.
Note 1: The ENV0, ENV1, ENV2, TCK, TDI, and TMS pins each have a weak pull-up to keep the input from floating.
Note 2: The RESET
Note 3: These functions are always enabled, due to the direct low-impedance path to these pins.
input has a weak pulldown.
Table 3 Pin Assignments for 48-Pin Package
Pin NameAlternate Function(s) Pin NumberType
PH6STD/TIO7
PH7SRD/TIO8
ENV1
VCC
X2CKI
X2CKO
GND
AVC C
AGND
IOVCC
X1CKO
X1CKI
GND
PI0
PI1
PI2SRCLK
PI3
PI4
PI5
PI6WUI9
PI7TA
PG0RXD/WUI10
PG1TXD/WUI11
PG2RTS
PG3CTS
/WUI12
/WUI13
PG5SRFS/NMI
TMS
TCK
TDI
GND
IOVCC
TDO
D-
D+
UVCC
UGND
10
11
12
13
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
1
2
3
4
5
6
7
8
9
GPIO
GPIO
I/O
PWR
I
O
PWR
PWR
PWR
PWR
O
I
PWR
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
I
I
I
PWR
PWR
O, GPIO
O, GPIO
I/O
PWR, I/O
PWR, O
www.national.com10
Pin NameAlternate Function(s) Pin NumberType
RDY
PH0MSK/TIO1
PH1MDIDO/TIO2
PH2MDODI/TIO3
PH3MWCS
/TIO4
ENV0
VCC
GND
RESET
PH4SCK/TIO5
PH5SFS/TIO6
Note 1: The ENV0 and ENV1, TCK, TDI and TMS pins each have a weak pull-up to keep the input from floating.
Note 2: The RESET
Note 3: These functions are always enabled, due to the direct low-impedance path to these pins.
input has a weak pulldown.
38
39
40
41
42
43
44
45
46
47
48
CP3UB17
O
GPIO
GPIO
GPIO
GPIO
I/O
PWR
PWR
I
GPIO
GPIO
11www.national.com
4.1PIN DESCRIPTION
Some pins may be enabled as general-purpose I/O-port
pins or as alternate functions associated with specific peripherals or interfaces. These pins may be individually con-
CP3UB17
Table 4 CP3UB17 Pin Description for the 100-Pin LQFP Package
figured as port pins, even when the associated peripheral or
interface is enabled. Table 4 lists the device pins.
NamePinsI/OPrimary Function
X1CKI1Input12 MHz Oscillator InputNoneNone
X1CKO1Output12 MHz Oscillator OutputNoneNone
X2CKI1Input32 kHz Oscillator InputNoneNone
X2CKO1Output32 kHz Oscillator OutputNoneNone
AVCC1InputPLL Analog Power SupplyNoneNone
IOVCC4Input2.5V - 3.3V I/O Power SupplyNoneNone
VCC2Input
GND6InputReference GroundNoneNone
AGND1InputPLL Analog GroundNoneNone
RESET
TMS1Input
TDI1Input
TDO1OutputJTAG Test Data OutputNoneNone
TCK1Input
RDY
1InputChip general resetNoneNone
1OutputNEXUS Ready OutputNoneNone
2.5V Core Logic
Power Supply
JTAG Test Mode Select
(with internal weak pull-up)
JTAG Test Data Input
(with internal weak pull-up)
JTAG Test Clock Input
(with internal weak pull-up)
Special mode select input with internal pull-up during reset
Special mode select input with internal pull-up during reset
PLLCLKPLL Clock Output
CPUCLKCPU Clock Output
15www.national.com
5.0CPU Architecture
The CP3UB17 uses the CR16C third-generation 16-bit
CompactRISC processor core. The CPU implements a Re-
CP3UB17
duced Instruction Set Computer (RISC) architecture that allows an effective execution rate of up to one instruction per
clock cycle. For a detailed description of the CPU16C architecture, see the CompactRISC CR16C Programmer’s Ref-erence Manual which is available on the National
Semiconductor web site (http://www.nsc.com).
The CR16C CPU core includes these internal registers:
General-purpose registers (R0-R13, RA, and SP)
Dedicated address registers (PC, ISP, USP, and INT-
BASE)
Processor Status Register (PSR)
Configuration Register (CFG)
The R0-R11, PSR, and CFG registers are 16 bits wide. The
R12, R13, RA, SP, ISP and USP registers are 32 bits wide.
The PC register is 24 bits wide. Figure 1 shows the CPU
registers.
Dedicated Address Registers
31
ISPH
USPH
INTBASEH
15
23
PC
ISPL
USPL
INTBASEL
Processor Status Register
15
PSR
Configuration Register
15
CFG
0
0
0
31
Figure 1. CPU Registers
Some register bits are designated as “reserved.” Software
must write a zero to these bit locations when it writes to the
register. Read operations from reserved bit locations return
undefined values.
5.1GENERAL-PURPOSE REGISTERS
The CompactRISC CPU features 16 general-purpose registers. These registers are used individually as 16-bit operands or as register pairs for operations on addresses
greater than 16 bits.
General-purpose registers are defined as R0 through
R13, RA, and SP.
Registers are grouped into pairs based on the setting of
the Short Register bit in the Configuration Register
(CFG.SR). When the CFG.SR bit is set, the grouping of
register pairs is upward-compatible with the architecture
of the earlier CR16A/B CPU cores: (R1,R0), (R2,R1) ...
(R11,R10), (R12_L, R11), (R13_L, R12_L), (R14_L,
R13_L) and SP. (R14_L, R13_L) is the same as
(RA,ERA).
General-Purpose Registers
150
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13
RA
SP
DS004
When the CFG.SR bit is clear, register pairs are grouped
in the manner used by native CR16C software: (R1,R0),
(R2,R1) ... (R11,R10), (R12_L, R11), R12, R13, RA, SP.
R12, R13, RA, and SP are 32-bit registers for holding addresses greater than 16 bits.
With the recommended calling convention for the architecture, some of these registers are assigned special hardware
and software functions. Registers R0 to R13 are for generalpurpose use, such as holding variables, addresses, or index
values. The SP register holds a pointer to the program runtime stack. The RA register holds a subroutine return address. The R12 and R13 registers are available to hold base
addresses used in the index addressing mode.
If a general-purpose register is specified by an operation
that is 8 bits long, only the lower byte of the register is used;
the upper part is not referenced or modified. Similarly, for
word operations on register pairs, only the lower word is
used. The upper word is not referenced or modified.
5.2DEDICATED ADDRESS REGISTERS
The CR16C has four dedicated address registers to implement specific functions: the PC, ISP, USP, and INTBASE
registers.
5.2.1Program Counter (PC) Register
The 24-bit value in the PC register points to the first byte of
the instruction currently being executed. CR16C instructions are aligned to even addresses, therefore the least significant bit of the PC is always 0. At reset, the PC is
initialized to 0 or an optional predetermined value. When a
warm reset occurs, value of the PC prior to reset is saved in
the (R1,R0) general-purpose register pair.
5.2.2Interrupt Stack Pointer (ISP)
The 32-bit ISP register points to the top of the interrupt
stack. This stack is used by hardware to service exceptions
(interrupts and traps). The stack pointer may be accessed
as the ISP register for initialization. The interrupt stack can
be located anywhere in the CPU address space. The ISP
cannot be used for any purpose other than the interrupt
stack, which is used for automatic storage of the CPU registers when an exception occurs and restoration of these
registers when the exception handler returns. The interrupt
stack grows downward in memory. The least significant bit
and the 8 most significant bits of the ISP register are always
0.
5.2.3User Stack Pointer (USP)
The USP register points to the top of the user-mode program stack. Separate stacks are available for user and supervisor modes, to support protection mechanisms for
multitasking software. The processor mode is controlled by
the U bit in the PSR register (which is called PSR.U in the
shorthand convention). Stack grow downward in memory. If
the USP register points to an illegal address (any address
greater than 0x00FF_FFFF) and the USP is used for stack
access, an IAD trap is taken.
www.national.com16
5.2.4Interrupt Base Register (INTBASE)
The INTBASE register holds the address of the dispatch table for exceptions. The dispatch table can be located anywhere in the CPU address space. When loading the
INTBASE register, bits 31 to 24 and bit 0 must written with 0.
5.3PROCESSOR STATUS REGISTER (PSR)
The PSR provides state information and controls operating
modes for the CPU. The format of the PSR is shown below.
1512 11 10 9 87 6 54 3 21 0
ReservedIP E 0 N Z F 0 U L T C
CThe Carry bit indicates whether a carry or bor-
row occurred after addition or subtraction.
0 – No carry or borrow occurred.
1 – Carry or borrow occurred.
TThe Trace bit enables execution tracing, in
which a Trace trap (TRC) is taken after every
instruction. Tracing is automatically disabled
during the execution of an exception handler.
– Tracing disabled.
0
1 – Tracing enabled.
LThe Low bit indicates the result of the last
comparison operation, with the operands interpreted as unsigned integers.
– Second operand greater than or equal to
0
first operand.
1 – Second operand less than first operand.
UThe User Mode bit controls whether the CPU
is in user or supervisor mode. In supervisor
mode, the SP register is used for stack operations. In user mode, the USP register is used
instead. User mode is entered by executing
the Jump USR instruction. When an exception
is taken, the exception handler automatically
begins execution in supervisor mode. The
USP register is accessible using the Load
Processor Register (LPR/LPRD) instruction in
supervisor mode. In user mode, an attempt to
access the USP register generates a UND
trap.
– CPU is executing in supervisor mode.
0
– CPU is executing in user mode.
1
FThe Flag bit is a general condition flag for sig-
nalling exception conditions or distinguishing
the results of an instruction, among other
thing uses. For example, integer arithmetic instructions use the F bit to indicate an overflow
condition after an addition or subtraction operation.
ZThe Zero bit is used by comparison opera-
tions. In a comparison of integers, the Z bit is
set if the two operands are equal. If the operands are unequal, the Z bit is cleared.
– Source and destination operands un-
0
equal.
1 – Source and destination operands equal.
NThe Negative bit indicates the result of the last
comparison operation, with the operands interpreted as signed integers.
– Second operand greater than or equal to
0
first operand.
1 – Second operand less than first operand.
EThe Local Maskable Interrupt Enable bit en-
ables or disables maskable interrupts. If this
bit and the Global Maskable Interrupt Enable
(I) bit are both set, all interrupts are enabled.
If either of these bits is clear, only the nonmaskable interrupt is enabled. The E bit is set
by the Enable Interrupts (EI) instruction and
cleared by the Disable Interrupts (DI) instruction.
– Maskable interrupts disabled.
0
1 – Maskable interrupts enabled.
PThe Trace Trap Pending bit is used together
with the Trace (T) bit to prevent a Trace (TRC)
trap from occurring more than once for one instruction. At the beginning of the execution of
an instruction, the state of the T bit is copied
into the P bit. If the P bit remains set at the end
of the instruction execution, the TRC trap is
taken.
– No trace trap pending.
0
– Trace trap pending.
1
IThe Global Maskable Interrupt Enable bit is
used to enable or disable maskable interrupts.
If this bit and the Local Maskable Interrupt Enable (E) bit are both set, all maskable interrupts are taken. If either bit is clear, only the
non-maskable interrupt is taken. Unlike the E
bit, the I bit is automatically cleared when an
interrupt occurs and automatically set upon
completion of an interrupt handler.
– Maskable interrupts disabled.
0
1 – Maskable interrupts enabled.
Bits Z, C, L, N, and F of the PSR are referenced from assembly language by the condition code in conditional
branch instructions. A conditional branch instruction may
cause a branch in program execution, based on the value of
one or more of these PSR bits. For example, one of the
Bcond instructions, BEQ (Branch EQual), causes a branch
if the PSR.Z bit is set.
On reset, bits 0 through 11 of the PSR are cleared, except
for the PSR.E bit, which is set. On warm reset, the values of
each bit before reset are copied into the R2 general-purpose register. Bits 4 and 8 of the PSR have a constant value
of 0. Bits 12 through 15 are reserved. In general, status bits
are modified only by specific instructions. Otherwise, status
bits maintain their values throughout instructions which do
not implicitly affect them.
CP3UB17
17www.national.com
5.4CONFIGURATION REGISTER (CFG)
The CFG register is used to enable or disable various operating modes and to control optional on-chip caches. Because the CP3UB17 does not have cache memory, the
CP3UB17
cache control bits in the CFG register are reserved. All CFG
bits are cleared on reset.
1510 987 652 10
ReservedSR ED 0 0Reserved00
EDThe Extended Dispatch bit selects whether
the size of an entry in the interrupt dispatch table (IDT) is 16 or 32 bits. Each entry holds the
address of the appropriate exception handler.
When the IDT has 16-bit entries, and all exception handlers must reside in the first 128K
of the address space. The location of the IDT
is held in the INTBASE register, which is not
affected by the state of the ED bit.
– Interrupt dispatch table has 16-bit entries.
0
1 – Interrupt dispatch table has 32-bit entries.
SRThe Short Register bit enables a compatibility
mode for the CR16B large model. In the
CR16C core, registers R12, R13, and RA are
extended to 32 bits. In the CR16B large model, only the lower 16 bits of these registers are
used, and these “short registers” are paired
together for 32-bit operations. In this mode,
the (RA, R13) register pair is used as the extended RA register, and address displacements relative to a single register are
supported with offsets of 0 and 14 bits in place
of the index addressing with these displacements.
– 32-bit registers are used.
0
1 – 16-bit registers are used (CR16B mode).
www.national.com18
5.5ADDRESSING MODES
The CR16C CPU core implements a load/store architecture, in which arithmetic and logical instructions operate on
register operands. Memory operands are made accessible
in registers using load and store instructions. For efficient
implementation of I/O-intensive embedded applications, the
architecture also provides a set of bit operations that operate on memory operands.
The load and store instructions support these addressing
modes: register/pair, immediate, relative, absolute, and index addressing. When register pairs are used, the lower bits
are in the lower index register and the upper bits are in the
higher index register. When the CFG.SR bit is clear, the 32bit registers R12, R13, RA, and SP are also treated as register pairs.
References to register pairs in assembly language use parentheses. With a register pair, the lower numbered register
pair must be on the right. For example,
jump (r5, r4)
load $4(r4,r3), (r6,r5)
load $5(r12), (r13)
The instruction set supports the following addressing
modes:
Register/Pair
Mode
Immediate
Mode
Relative Mode In relative mode, the operand is ad-
In register/pair mode, the operand is held
in a general-purpose register, or in a general-purpose register pair. For example,
the following instruction adds the contents of the low byte of register r1 to the
contents of the low byte of r2, and places
the result in the low byte register r2. The
high byte of register r2 is not modified.
ADDB R1, R2
In immediate mode, the operand is a con-
stant value which is encoded in the instruction. For example, the following
instruction multiplies the value of r4 by 4
and places the result in r4.
MULW $4, R4
dressed using a relative value (displacement) encoded in the instruction. This
displacement is relative to the current
Program Counter (PC), a general-purpose register, or a register pair.
In branch instructions, the displacement
is always relative to the current value of
the PC Register. For example, the following instruction causes an unconditional
branch to an address 10 ahead of the
current PC.
BR *+10
CP3UB17
In another example, the operand resides
in memory. Its address is obtained by
adding a displacement encoded in the instruction to the contents of register r5.
The address calculation does not modify
the contents of register r5.
LOADW 12(R5), R6
The following example calculates the ad-
dress of a source operand by adding a
displacement of 4 to the contents of a
register pair (r5, r4) and loads this operand into the register pair (r7, r6). r7 receives the high word of the operand, and
r6 receives the low word.
LOADD 4(r5, r4), (r7, r6)
Index ModeIn index mode, the operand address is
calculated with a base address held in either R12 or R13. The CFG.SR bit must
be clear to use this mode.
For relative mode operands, the mem-
ory address is calculated by adding
the value of a register pair and a displacement to the base address. The
displacement can be a 14 or 20-bit unsigned value, which is encoded in the
instruction.
For absolute mode operands, the
memory address is calculated by adding a 20-bit absolute address encoded
in the instruction to the base address.
In the following example, the operand address is the sum of the displacement 4,
the contents of the register pair (r5,r4),
and the base address held in register r12.
The word at this address is loaded into
register r6.
LOADW [r12]4(r5, r4), r6
Absolute Mode In absolute mode, the operand is located
in memory, and its address is encoded in
the instruction (normally 20 or 24 bits).
For example, the following instruction
loads the byte at address 4000 into the
lower 8 bits of register r6.
LOADB 4000, r6
For additional information on the addressing modes, see the
CompactRISC CR16C Programmer's Reference Manual.
19www.national.com
5.6STACKS
A stack is a last-in, first-out data structure for dynamic storage of data and addresses. A stack consists of a block of
memory used to hold the data and a pointer to the top of the
CP3UB17
stack. As more data is pushed onto a stack, the stack grows
downward in memory. The CR16C supports two types of
stacks: the interrupt stack and program stacks.
5.6.1Interrupt Stack
The processor uses the interrupt stack to save and restore
the program state during the exception handling. Hardware
automatically pushes this data onto the interrupt stack before entering an exception handler. When the exception
handler returns, hardware restores the processor state with
data popped from the interrupt stack. The interrupt stack
pointer is held in the ISP register.
5.6.2Program Stack
The program stack is normally used by software to save and
restore register values on subroutine entry and exit, hold local and temporary variables, and hold parameters passed
between the calling routine and the subroutine. The only
hardware mechanisms which operate on the program stack
are the PUSH, POP, and POPRET instructions.
5.6.3User and Supervisor Stack Pointers
To support multitasking operating systems, support is provided for two program stack pointers: a user stack pointer
and a supervisor stack pointer. When the PSR.U bit is clear,
the SP register is used for all program stack operations. This
is the default mode when the user/supervisor protection
mechanism is not used, and it is the supervisor mode when
protection is used.
When the PSR.U bit is set, the processor is in user mode,
and the USP register is used as the program stack pointer.
User mode can only be entered using the JUSR instruction,
which performs a jump and sets the PSR.U bit. User mode
is exited when an exception is taken and re-entered when
the exception handler returns. In user mode, the LPRD instruction cannot be used to change the state of processor
registers (such as the PSR).
5.7INSTRUCTION SET
Table 6 lists the operand specifiers for the instruction set,
and Table 7 is a summary of all instructions. For each instruction, the table shows the mnemonic and a brief description of the operation performed.
In the mnemonic column, the lower-case letter “i” is used to
indicate the type of integer that the instruction operates on,
either “B” for byte or “W” for word. For example, the notation
ADDi for the “add” instruction means that there are two
forms of this instruction, ADDB and ADDW, which operate
on bytes and words, respectively.
Similarly, the lower-case string “cond” is used to indicate the
type of condition tested by the instruction. For example, the
notation Jcond represents a class of conditional jump instructions: JEQ for Jump on Equal, JNE for Jump on Not
Equal, etc. For detailed information on all instructions, see
the CompactRISC CR16C Programmer's Reference Manu-al.
Table 6 Key to Operand Specifiers
Operand SpecifierDescription
absAbsolute address
disp
imm
IpositionBit position in memory
RbaseBase register (relative mode)
RdestDestination register
RindexIndex register
RPbase, RPbasexBase register pair (relative mode)
RPdestDestination register pair
RPlinkLink register pair
RpositionBit position in register
Displacement (numeric suffix
indicates number of bits)
Immediate operand (numeric suf-
fix indicates number of bits)
www.national.com20
Rproc16-bit processor register
Rprocd32-bit processor register
RPsrcSource register pair
RPtargetTarget register pair
Rsrc, Rsrc1, Rsrc2Source register
Table 7 Instruction Set Summary
MnemonicOperandsDescription
MOViRsrc/imm, RdestMove
MOVXBRsrc, RdestMove with sign extension
MOVZBRsrc, RdestMove with zero extension
MOVXWRsrc, RPdestMove with sign extension
MOVZWRsrc, RPdestMove with zero extension
MOVDimm, RPdestMove immediate to register-pair
RPsrc, RPdestMove between register-pairs
ADD[U]iRsrc/imm, RdestAdd
ADDCiRsrc/imm, RdestAdd with carry
ADDDRPsrc/imm, RPdestAdd with RP or immediate.
MACQWaRsrc1, Rsrc2, RPdestMultiply signed Q15:
RPdest := RPdest + (Rsrc1 × Rsrc2)
MACSWaRsrc1, Rsrc2, RPdestMultiply signed and add result:
RPdest := RPdest + (Rsrc1 × Rsrc2)
CP3UB17
MACUWaRsrc1, Rsrc2, RPdestMultiply unsigned and add result:
RPsrc, (Rindex)disp(RPbasex)Store (register pair index relative)
RPsrc, (Rindex)absStore (absolute index relative)
STOR IMMimm4, disp(Rbase)Store unsigned 4-bit immediate value extended to operand
imm4, disp(RPbase)
imm4, (Rindex)disp(RPbasex)
imm4, abs
imm4, (Rindex)abs
length in memory
LOADMimm3Load 1 to 8 registers (R2-R5, R8-R11) from memory
starting at (R0)
LOADMPimm3Load 1 to 8 registers (R2-R5, R8-R11) from memory
starting at (R1, R0)
STORMSTORM imm3Store 1 to 8 registers (R2-R5, R8-R11) to memory starting
at (R2)
23www.national.com
Table 7 Instruction Set Summary
MnemonicOperandsDescription
CP3UB17
STORMPimm3Store 1 to 8 registers (R2-R5, R8-R11) to memory starting
at (R7,R6)
DIDisable maskable interrupts
EIEnable maskable interrupts
EIWAITEnable maskable interrupts and wait for interrupt
NOPNo operation
WAITWait for interrupt
www.national.com24
6.0Memory
The CP3UB17 supports a uniform 16M-byte linear address
space. Table 8 lists the types of memory and peripherals
that occupy this memory space. Unlisted address ranges
Table 8 CP3UB17 Memory Map
CP3UB17
are reserved and must not be read or written. The BIU
zones are regions of the address space that share the same
control bits in the Bus Interface Unit (BIU).
Start
Address
00 0000h03 FFFFh256K
04 0000h0D FFFFh640KReserved
0E 0000h0E 1FFFh8KOn-chip Flash Data Memory
0E 2000h0E 7FFFh24KReserved
0E 8000h0E 91FFh4.5KReservedN/A
0E 9200h0E BFFFh11.5KReserved
0E C000h0E E7FFh10KSystem RAM
0E E800h0E EBFFh1KReserved
0E EC00h0E EFFFh1KReserved
0E F000h0E F13Fh320Reserved
0E F140h0E F17Fh64Reserved
0E F180h0E F1FFh128Reserved
0E F200h0F FFFFh67.5KReserved
10 0000h3F FFFFh3072KReserved
End
Address
Size in
Bytes
DescriptionBIU Zone
On-chip Flash Program Memory, including Boot
Memory
Static Zone 0
(mapped internally
in IRE and ERE
mode; mapped to
the external bus in
DEV mode)
40 0000h7F FFFFh4096KExternal Memory Zone 1Static Zone 1
80 0000hFE FFFFh8128KExternal Memory Zone 2Static Zone 2
FF 0000hFF FAFFh64256BIU Peripherals
FF FB00hFF FBFFh256I/O ExpansionI/O Zone
FF FC00hFF FFFFh1KPeripherals and Other I/O PortsN/A
6.1OPERATING ENVIRONMENT
The operating environment controls whether external memory is supported and whether the reset vector jumps to a
code space intended to support In-System Programming
(ISP). Up to 8M of external memory space is available.
The operating mode of the device is controlled by the states
on the ENV2:0 pins at reset, as shown in Table 9.
Table 9 Operating Environment Selection
ENV2:0Operating Environment
When ENV2:0 = 111, IRE mode is selected unless the
EMPTY bits in the Protection word indicate that the program
flash memory is empty (unprogrammed), in which case ISP
mode is selected. See Section 8.4.2 for more details. The
ENV2 pin is only available on the 100-pin packages, therefore it is not possible to enter the ERE or DEV environments
on the 48-pin versions of the CP3UB17.
In the DEV environment, the on-chip flash memory is disabled, and the corresponding region of the address space
is mapped to external memory.
6.2BUS INTERFACE UNIT (BIU)
x10In-System-Programming (ISP) mode
111Internal ROM enabled (IRE) or ISP mode
011External ROM enabled (ERE) mode
000Development (DEV) mode
Internal pullups on the ENV2:0 pins select IRE mode or ISP
mode if these pins are allowed to float.
The BIU controls the interface between the CPU core bus
and those on-chip modules which are mapped into BIU
zones. These on-chip modules are the flash program memory and the I/O zone. The BIU controls the configured parameters for bus access (such as the number of wait states
for memory access) and issues the appropriate bus signals
for the requested access.
25www.national.com
6.3BUS CYCLES
There are four types of data transfer bus cycles:
Normal read
CP3UB17
Fast read
Early write
Late write
The type of data cycle used in a particular transaction depends on the type of CPU operation (a write or a read), the
type of memory or I/O being accessed, and the access type
programmed into the BIU control registers (early/late write
or normal/fast read).
For read operations, a basic normal read takes two clock cycles, and a fast-read bus cycle takes one clock cycle. Normal read bus cycles are enabled by default after reset.
For write operations, a basic late-write bus cycle takes two
clock cycles, and a basic early-write bus cycle takes three
clock cycles. Early-write bus cycles are enabled by default
after reset. However, late-write bus cycles are needed for
ordinary write operations, so this configuration must be
changed by software (see Section 6.4.1).
In certain cases, one or more additional clock cycles are
added to a bus access cycle. There are two types of additional clock cycles for ordinary memory accesses, called internal wait cycles (TIW) and hold (T
A wait cycle is inserted in a bus cycle just after the memory
address has been placed on the address bus. This gives the
accessed memory more time to respond to the transaction
request.
A hold cycle is inserted at the end of a bus cycle. This holds
the data on the data bus for an extended number of clock cycles.
hold
) cycles.
6.4BIU CONTROL REGISTERS
The BIU has a set of control registers that determine how
many wait cycles and hold cycles are to be used for accessing memory. During initialization of the system, these registers should be programmed with appropriate values so that
the minimum allowable number of cycles is used. This number varies with the clock frequency.
There are five BIU control registers, as listed in Table 10.
These registers control the bus cycle configuration used for
accessing the various on-chip memory types.
Table 10 Bus Control Registers
NameAddressDescription
BCFGFF F900hBIU Configuration Register
IOCFGFF F902h
SZCFG0FF F904h
SZCFG1FF F906h
SZCFG2FF F908h
I/O Zone Configuration
Register
Static Zone 0
Configuration Register
Static Zone 1
Configuration Register
Static Zone 2
Configuration Register
6.4.1BIU Configuration Register (BCFG)
The BCFG register is a byte-wide, read/write register that
selects early-write or late-write bus cycles. At reset, the register is initialized to 07h. The register format is shown below.
73210
Reserved11EWR
EWRThe Early Write bit controls write cycle timing.
– Late-write operation (2 clock cycles to
0
write).
– Early-write operation.
1
At reset, the BCFG register is initialized to 07h, which selects early-write operation. However, late-write operation is
required for normal device operation, so software must
change the register value to 06h. Bits 1 and 2 of this register
must always be set when writing to this register.
6.4.2I/O Zone Configuration Register (IOCFG)
The IOCFG register is a word-wide, read/write register that
controls the timing and bus characteristics of accesses to
the 256-byte I/O Zone memory space (FF FB00h to FF
FBFFh). The registers associated with Port B and Port C reside in the I/O memory array. At reset, the register is initialized to 069Fh. The register format is shown below.
7654320
BWReservedHOLDWAIT
151098
ReservedIPSTRes.
WAITThe Memory Wait Cycles field specifies the
number of TIW (internal wait state) clock cycles added for each memory access, ranging
from 000 binary for no additional TIW wait cycles to 111 binary for seven additional TIW
wait cycles.
HOLDThe Memory Hold Cycles field specifies the
number of T
memory access, ranging from 00b for no
T
cycles to 11b for three T
hold
cles.
BWThe Bus Width bit defines the bus width of the
IO Zone.
– 8-bit bus width.
0
– 16-bit bus width (default)
1
IPSTThe Post Idle bit controls whether an idle cycle
follows the current bus cycle, when the next
bus cycle accesses a different zone. No idle
cycles are required for on-chip accesses.
– No idle cycle (recommended).
0
– Idle cycle.
1
clock cycles used for each
hold
hold
clock cy-
www.national.com26
6.4.3Static Zone 0 Configuration Register (SZCFG0)
The SZCFG0 register is a word-wide, read/write register
that controls the timing and bus characteristics of Zone 0
memory accesses. Zone 0 is used for the on-chip flash
memory (including the boot area, program memory, and
data memory).
At reset, the register is initialized to 069Fh. The register format is shown below.
7654320
BWWBR RBEHOLDWAIT
1512111098
ReservedFRE IPRE IPST Res.
WAITThe Memory Wait field specifies the number
of TIW (internal wait state) clock cycles added
for each memory access, ranging from 000b
for no additional TIW wait cycles to 111b for
seven additional TIW wait cycles. These bits
are ignored if the SZCFG0.FRE bit is set.
HOLDThe Memory Hold field specifies the number
of T
access, ranging from 00b for no T
to 11b for three T
are ignored if the SZCFG0.FRE bit is set.
RBEThe Read Burst Enable enables burst cycles
on 16-bit reads from 8-bit bus width regions of
the address space. Because the flash program memory is required to be 16-bit bus
width, the RBE bit is a don’t care bit. This bit
is ignored when the SZCFG0.FRE bit is set.
0
1 – Burst read enabled.
WBRThe Wait on Burst Read bit controls if a wait
state is added on burst read transaction. This
bit is ignored, when SZCFG0.FRE bit is set or
when SZCFG0.RBE is clear.
0
1 – One TBW on burst read cycles.
BWThe Bus Width bit controls the bus width of the
zone. The flash program memory must be
configured for 16-bit bus width.
0
1
FREThe Fast Read Enable bit controls whether
fast read bus cycles are used. A fast read operation takes one clock cycle. A normal read
operation takes at least two clock cycles.
0
1
IPSTThe Post Idle bit controls whether an idle cycle
follows the current bus cycle, when the next
bus cycle accesses a different zone. No idle
cycles are required for on-chip accesses.
0
1
clock cycles used for each memory
hold
clock cycles. These bits
hold
– Burst read disabled.
– No TBW on burst read cycles.
– 8-bit bus width.
– 16-bit bus width (required).
– Normal read cycles.
– Fast read cycles.
– No idle cycle (recommended).
– Idle cycle inserted.
hold
cycles
IPREThe Preliminary Idle bit controls whether an
idle cycle is inserted prior to the current bus
cycle, when the new bus cycle accesses a different zone. No idle cycles are required for onchip accesses.
– No idle cycle (recommended).
0
– Idle cycle inserted.
1
6.4.4Static Zone 1 Configuration Register (SZCFG1)
The SZCFG1 register is a word-wide, read/write register
that controls the timing and bus characteristics for off-chip
accesses selected with the SEL1
At reset, the register is initialized to 069Fh. The register format is shown below.
7654320
BWWBR RBEHOLDWAIT
1512111098
ReservedFRE IPRE IPSTRes.
WAITThe Memory Wait field specifies the number
of TIW (internal wait state) clock cycles added
for each memory access, ranging from 000b
for no additional TIW wait cycles to 111b for
seven additional TIW wait cycles. These bits
are ignored if the SZCFG1.FRE bit is set.
HOLDThe Memory Hold field specifies the number
of T
access, ranging from 00b for no T
to 11b for three T
are ignored if the SZCFG1.FRE bit is set.
RBEThe Read Burst Enable enables burst cycles
on 16-bit reads from 8-bit bus width regions of
the address space. This bit is ignored when
the SZCFG1.FRE bit is set or the
SZCFG1.BW is clear.
0
1
WBRThe Wait on Burst Read bit controls if a wait
state is added on burst read transaction. This
bit is ignored, when SZCFG1.FRE bit is set or
when SZCFG1.RBE is clear.
0
1
BWThe Bus Width bit controls the bus width of the
zone.
0
1
FREThe Fast Read Enable bit controls whether
fast read bus cycles are used. A fast read operation takes one clock cycle. A normal read
operation takes at least two clock cycles.
0
1
clock cycles used for each memory
hold
– Burst read disabled.
– Burst read enabled.
– No TBW on burst read cycles.
– One TBW on burst read cycles.
– 8-bit bus width.
– 16-bit bus width.
– Normal read cycles.
– Fast read cycles.
output signal.
clock cycles. These bits
hold
hold
cycles
CP3UB17
27www.national.com
IPSTThe Post Idle bit controls whether an idle cycle
follows the current bus cycle, when the next
bus cycle accesses a different zone.
– No idle cycle.
CP3UB17
IPREThe Preliminary Idle bit controls whether an
6.4.5Static Zone 2 Configuration Register (SZCFG2)
The SZCFG2 register is a word-wide, read/write register
that controls the timing and bus characteristics for off-chip
accesses selected with the SEL2 output signal.
At reset, the register is initialized to 069Fh. The register format is shown below.
7654320
BWWBRRBEHOLDWAIT
0
1 – Idle cycle inserted.
idle cycle is inserted prior to the current bus
cycle, when the new bus cycle accesses a different zone.
– No idle cycle.
0
1
– Idle cycle inserted.
FREThe Fast Read Enable bit controls whether
fast read bus cycles are used. A fast read operation takes one clock cycle. A normal read
operation takes at least two clock cycles.
– Normal read cycles.
0
1 – Fast read cycles.
IPSTThe Post Idle bit controls whether an idle cycle
follows the current bus cycle, when the next
bus cycle accesses a different zone.
– No idle cycle.
0
1
– Idle cycle inserted.
IPREThe Preliminary Idle bit controls whether an
idle cycle is inserted prior to the current bus
cycle, when the new bus cycle accesses a different zone.
– No idle cycle.
0
1 – Idle cycle inserted.
6.5WAIT AND HOLD STATES
The number of wait cycles and hold cycles inserted into a
bus cycle depends on whether it is a read or write operation,
the type of memory or I/O being accessed, and the control
register settings.
1512111098
ReservedFREIPRE IPSTRes.
WAITThe Memory Wait field specifies the number
of TIW (internal wait state) clock cycles added
for each memory access, ranging from 000b
for no additional TIW wait cycles to 111b for
seven additional TIW wait cycles. These bits
are ignored if the SZCFG2.FRE bit is set.
HOLDThe Memory Hold field specifies the number
of T
access, ranging from 00b for no T
to 11b for three T
are ignored if the SZCFG2.FRE bit is set.
RBEThe Read Burst Enable enables burst cycles
on 16-bit reads from 8-bit bus width regions of
the address space. This bit is ignored when
the SZCFG2.FRE bit is set or the
SZCFG2.BW is clear.
0
1
WBRThe Wait on Burst Read bit controls if a wait
state is added on burst read transaction. This
bit is ignored, when SZCFG2.FRE bit is set or
when SZCFG2.RBE is clear.
0
1
BWThe Bus Width bit controls the bus width of the
zone.
0
1
clock cycles used for each memory
hold
clock cycles. These bits
hold
– Burst read disabled.
– Burst read enabled.
– No TBW on burst read cycles.
– One TBW on burst read cycles.
– 8-bit bus width.
– 16-bit bus width.
hold
cycles
6.5.1Flash Program/Data Memory
When the CPU accesses the Flash program and data memory (address ranges 000000h
0E1FFFh), the number of added wait and hold cycles depends on the type of access and the BIU register settings.
In fast-read mode (SZCFG0.FRE=1), a read operation is a
single cycle access. This limits the maximum CPU operating frequency to 24 MHz.
For a read operation in normal-read mode
(SZCFG0.FRE=0), the number of inserted wait cycles is
specified in the SZCFG0.WAIT field. The total number of
wait cycles is the value in the WAIT field plus 1, so it can
range from 1 to 8. The number of inserted hold cycles is
specified in the SCCFG0.HOLD field, which can range from
0 to 3.
For a write operation in fast read mode (SZCFG0.FRE=1),
the number of inserted wait cycles is 1. No hold cycles are
used.
For a write operation normal read mode (SZCFG0.FRE=0),
the number of wait cycles is equal to the value written to the
SZCFG0.WAIT field plus 1 (in the late write mode) or 2 (in
the early write mode). The number of inserted hold cycles is
equal to the value written to the SCCFG0.HOLD field, which
can range from 0 to 3.
6.5.2RAM Memory
Read and write accesses to on-chip RAM is performed within a single cycle, without regard to the BIU settings. The
RAM address is in the range of 0E 8000h
C000h–0E EBFFh.
6.5.3Access to Peripherals
When the CPU accesses on-chip peripherals in the range of
0E F000h–0E F1FFh and FF 0000h–FF FBFFh, one wait
cycle and one preliminary idle cycle is used. No hold cycles
are used. The IOCFG register determines the access timing
for the address range FF FB00h
–03FFFFh and 0E0000h–
–0E 91FFh and 0E
–FF FBFFh.
www.national.com28
7.0System Configuration Registers
The system configuration registers control and provide status for certain aspects of device setup and operation, such
as indicating the states sampled from the ENV[2:0] inputs.
The system configuration registers are listed in Table 11.
Table 11 System Configuration Registers
NameAddressDescription
MCFGFF F910h
MSTATFF F914h
7.1MODULE CONFIGURATION REGISTER
(MCFG)
The MCFG register is a byte-wide, read/write register that
selects the clock output features of the device.
The register must be written in active mode only, not in power save, HALT, or IDLE mode. However, the register contents are preserved during all power modes.
The MCFG register format is shown below.
Module Configuration
Register
Module Status
Register
MISC_IO_SPEED
MEM_IO_SPEED
The MISC_IO_SPEED bit controls the slew
rate of the output drivers for the ENV[2:0],
, RFDATA, and TDO pins. To minimize
RDY
noise, the slow slew rate is recommended.
– Fast slew rate.
0
1 – Slow slew rate.
The MEM_IO_SPEED bit controls the slew
rate of the output drivers for the A[21:0], RD
SEL[2:1]
for the CP3UB17 are characterized with fast
slew rate. Slow slew rate reduces the available memory access time by 5 ns.
0
1 – Slow slew rate.
, and WR[1:0] pins. Memory speeds
– Fast slew rate.
7.2MODULE STATUS REGISTER (MSTAT)
The MSTAT register is a byte-wide, read-only register that
indicates the general status of the device. The MSTAT register format is shown below.
7543210
Reserved DPGMBUSY
PGMBUSY
OENV2 OENV1 OENV0
CP3UB17
,
76543210
MEM_IO
Res.
_SPEED
EXIOEThe EXIOE bit controls whether the external
PLLCLKOE
MCLKOEThe MCLKOE bit controls whether the Main
SCLKOEThe SCLKOE bit controls whether the Slow
USB_ENABLE
MISC_IO
_SPEED
bus is enabled in the IRE environment for implementing the I/O Zone (FF FB00h
FBFFh).
– External bus disabled.
0
1 – External bus enabled.
The PLLCLKOE bit controls whether the PLL
clock is driven on the ENV0/PLLCLK pin.
0 – ENV0/PLLCLK pin is high impedance.
– PLL clock driven on ENV0/PLLCLK.
1
Clock is driven on the ENV1/CPUCLK pin.
– ENV1/CPUCLK pin is high impedance.
0
1 – Main Clock is driven on ENV1/CPUCLK.
Clock is driven on the ENV2/SLOWCLK pin.
– ENV2/SLOWCLK pin is high impedance.
0
– Slow Clock driven on ENV2/SLOWCLK.
1
The USB_ENABLE bit can be used to force
an external USB transceiver into its low-power
mode. The power mode is dependent on the
USB controller status, the USB_ENABLE bit
in the Function Word (see Section 8.4.1), and
the USB_ENABLE bit in the MCFG register.
– External USB transceiver forced into low-
0
power mode.
– Transceiver power mode dependent on
1
USB controller status and programming
of the Function Word. (This is the state of
the USB_ENABLE bit after reset.)
USB
_ENABLE
SCLKOEMCLKOEPLLCLKOEEXI
OE
–FF
OENV[2:0]The Operating Environment bits hold the
states sampled from the ENV[2:0] input pins
at reset. These states are controlled by external hardware at reset and are held constant in
the register until the next reset.
PGMBUSY The Flash Programming Busy bit is automati-
cally set when either the program memory or
the data memory is being programmed or
erased. It is clear when neither of the memories is busy. When this bit is set, software must
not attempt to program or erase either of
these two memories. This bit is a copy of the
FMBUSY bit in the FMSTAT register.
– Flash memory is not busy.
0
– Flash memory is busy.
1
DPGMBUSY
The Data Flash Programming Busy indicates
that the flash data memory is being erased or
a pipelined programming sequence is currently ongoing. Software must not attempt to perform any write access to the flash program
memory at this time, without also polling the
FSMSTAT.FMFULL bit in the flash memory interface. The DPGMBUSY bit is a copy of the
FMBUSY bit in the FSMSTAT register.
– Flash data memory is not busy.
0
1
– Flash data memory is busy.
29www.national.com
8.0Flash Memory
The flash memory consists of the flash program memory
and the flash data memory. The flash program memory is
CP3UB17
further divided into the Boot Area and the Code Area.
A special protection scheme is applied to the lower portion
of the flash program memory, called the Boot Area. The
Boot Area always starts at address 0 and ranges up to a
programmable end address. The maximum boot area address which can be selected is 00 1BFFh. The intended use
of this area is to hold In-System-Programming (ISP) routines or essential application routines. The Boot Area is always protected against CPU write access, to avoid
unintended modifications.
The Code Area is intended to hold the application code and
constant data. The Code Area begins with the next byte after the Boot Area. Table 12 summarizes the properties of
the regions of flash memory mapped into the CPU address
space.
Table 12 Flash Memory Areas
AreaAddress Range
Boot
Area
Code
Area
Data
Area
–BOOTAREA - 1YesNo
0
BOOTAREA
FFFFh
0E 0000h
–03
–0E 1FFFhYes
8.1FLASH MEMORY PROTECTION
The memory protection mechanisms provide both global
and section-level protection. Section-level protection
against CPU writes is applied to individual 8K-byte sections
of the flash program memory and 512-byte sections of the
flash data memory. Section-level protection is controlled
through read/write registers mapped into the CPU address
space. Global write protection is applied at the device level,
to disable flash memory writes by the CPU. Global write protection is controlled by the encoding of bits stored in the
flash memory array.
8.1.1Section-Level Protection
Each bit in the Flash Memory Write Enable (FM0WER and
FM1WER) registers enables or disables write access to a
corresponding section of flash program memory. Write access to the flash data memory is controlled by the bits in the
Flash Slave Memory Write Enable (FSM0WER) register. By
Read
Access
Ye s
Write Access
Write access
only if section
write enable
bit is set and
global write
protection is
disabled.
Write access
only if section
write enable
bit is set and
global write
protection is
disabled.
default (after reset) all bits in the FM0WER, FM1WER, and
FSM0WER registers are cleared, which disables write access by the CPU to all sections. Write access to a section is
enabled by setting the corresponding write enable bit. After
completing a programming or erase operation, software
should clear all write enable bits to protect the flash program
memory against any unintended writes.
8.1.2Global Protection
The WRPROT field in the Protection Word controls global
write protection. The Protection Word is located in a special
flash memory outside of the CPU address space. If a majority of the bits in the 3-bit WRPROT field are clear, write protection is enabled. Enabling this mode prevents the CPU
from writing to flash memory.
The RDPROT field in the Protection Word controls global
read protection. If a majority of the bits in the 3-bit RDPROT
field are clear, read protection is enabled. Enabling this
mode prevents reading by an external debugger through the
serial debug interface or by an external flash programmer.
CPU read access is not affected by the RDPROT bits.
8.2FLASH MEMORY ORGANIZATION
Each of the flash memories are divided into main blocks and
information blocks. The main blocks hold the code or data
used by application software. The information blocks hold
factory parameters, protection settings, and other devicespecific data. The main blocks are mapped into the CPU address space. The information blocks are accessed indirectly
through a register-based interface. Separate sets of registers are provided for accessing flash program memory (FM
registers) and flash data memory (FSM registers). The flash
program memory consists of two main blocks and two data
blocks, as shown in Table 13. The flash data memory consists of one main block and one information block.
Table 13 Flash Memory Blocks
NameAddress RangeFunction
Main Block 0
Information
Block 0
Main Block 1
Information
Block 1
Main Block 2
Information
Block 2
8.2.1Main Block 0 and 1
Main Block 0 and Main Block 1 hold the 256K-byte program
space, which consists of the Boot Area and Code Area.
00 0000h
(CPU address space)
(address register)
02 0000h
(CPU address space)
(address register)
0E 0000h
(CPU address space)
(address register)
000h
080h
000h
–01 FFFFh
–07Fh
–03 FFFFh
–0FFh
–0E 1FFFh
–07Fh
Flash Program
Memory
Function Word,
Factory
Parameters
Flash Program
Memory
Protection Word,
User Data
Flash Data
Memory
User Data
www.national.com30
Loading...
+ 170 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.