Cirrus Logic Reference Manual PSoC 3 PSoC 5 Architecture TRM
Cirrus Logic Reference Manual PSoC 3 PSoC 5 Architecture TRM
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone (USA): 800.858.1810
Phone (Intnl): 408.943.2600
http://www.cypress.com
Copyrights
Copyrights
PSoC and CapSense are registered trademarks of Cypress Semiconductor Corporation. PSoC Designer is a trademark of
Cypress Semiconductor Corporation. All other trademarks or registered trademarks referenced herein are the property of
their respective owners.
Purchase of I2C components from Cypress or one of its sublicensed Associated Companies conveys a license under the Phil-
ips I2C Patent Rights to use these components in an I2C system, provided that the system conforms to the I2C Standard
Specification as defined by Philips. As from October 1st, 2006 Philips Semiconductors has a new trade name, NXP Semicon-
ductors.
The information in this document is subject to change without notice and should not be construed as a commitment by
Cypress. While reasonable precautions have been taken, Cypress assumes no responsibility for any errors that may appear
in this document. No part of this document may be copied, or reproduced for commercial use, in any form or by any means
without the prior written consent of Cypress. Made in the U.S.A.
Disclaimer
CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PAR-
TICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein.
Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress
does not authorize its products for use as critical components in life-support systems where a malfunction or failure may rea-
sonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems appli-
cation implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Cypress products meet the specifications contained in their particular Cypress PSoC Datasheets. Cypress believes that its
family of PSoC products is one of the most secure families of its kind on the market today, regardless of how they are used.
There may be methods, unknown to Cypress, that can breach the code protection features. Any of these methods, to our
knowledge, would be dishonest and possibly illegal. Neither Cypress nor any other semiconductor manufacturer can guaran-
tee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Cypress is willing to work with the customer who is concerned about the integrity of their code. Code protection is constantly
evolving. We at Cypress are committed to continuously improving the code protection features of our products.
Section A: Overview 21
1. Introduction ........................................................................................................... 23
2. Getting Started ...................................................................................................... 29
3. Document Construction ......................................................................................... 31
Glossary 479
Index 495
Section A: Overview 21
Document Revision History ..............................................................................................................21
1. Introduction 23
1.1 Top Level Architecture............................................................................................................23
1.2 Features..................................................................................................................................26
1.3 CPU System ...........................................................................................................................26
1.3.1 Processor...............................................................................................................26
1.3.2 Interrupt Controller .................................................................................................26
1.3.3 DMA Controller ......................................................................................................26
1.3.4 Cache Controller ....................................................................................................26
1.4 Memory...................................................................................................................................26
1.5 System Wide Resources ........................................................................................................27
1.5.1 I/O Interfaces .........................................................................................................27
1.5.2 Internal Clock Generators ......................................................................................27
1.5.3 Power Supply.........................................................................................................27
1.5.3.1 Boost Converter .....................................................................................27
1.5.3.2 Sleep Modes ..........................................................................................27
1.6 Digital System.........................................................................................................................27
1.7 Analog System........................................................................................................................28
1.7.1 Delta Sigma ADC...................................................................................................28
1.7.2 Successive Approximation Register ADC..............................................................28
1.7.3 Digital Filter Block ..................................................................................................28
1.7.4 Digital-to-Analog Converters..................................................................................28
1.7.5 Additional Analog Subsystem Components...........................................................28
1.8 Program and Debug ...............................................................................................................28
2. Getting Started 29
2.1 Support ...................................................................................................................................29
2.2 Product Upgrades...................................................................................................................29
2.3 Development Kits ...................................................................................................................29
3. Document Construction 31
3.1 Major Sections ........................................................................................................................31
3.2 Documentation Conventions ..................................................................................................31
3.2.1 Register Conventions.............................................................................................31
3.2.2 Numeric Naming ....................................................................................................32
3.2.3 Units of Measure....................................................................................................32
3.2.4 Acronyms ...............................................................................................................32
Section B: CPU System 35
Top Level Architecture .....................................................................................................................35
4. 8051 Core 37
4.1 Features ................................................................................................................................. 37
4.2 Block Diagram ........................................................................................................................ 37
4.3 How It Works .......................................................................................................................... 38
4.3.1 Memory Spaces ..................................................................................................... 38
4.3.2 Instruction Set........................................................................................................ 38
4.3.3 8051 Core Enhancements ..................................................................................... 38
4.3.4 Interrupt Controller Interface.................................................................................. 38
4.4 CY 8051 Wrapper................................................................................................................... 39
4.4.1 SFR – I/O Interface................................................................................................ 39
4.5 8051 Instructions .................................................................................................................... 39
4.5.1 Internal Data Space Map ....................................................................................... 39
4.5.2 Addressing Modes ................................................................................................. 39
4.5.3 Arithmetic Logic Unit Functions ............................................................................. 40
4.5.3.1 Arithmetic Instructions............................................................................ 40
4.5.3.2 Logical Instructions ................................................................................ 41
4.5.3.3 Data Transfer Instructions...................................................................... 42
4.5.3.4 Boolean Instructions1............................................................................. 43
4.5.3.5 Program Branching Instructions............................................................. 43
4.5.3.6 Instruction Set Details ............................................................................ 44
4.6 8051 Special Function Registers (SFRs) ............................................................................... 62
4.6.1 SFRs......................................................................................................................62
4.6.2 Dual Data Pointer SFRs ........................................................................................ 63
4.6.3 24-Bit Data Pointer SFRs ...................................................................................... 64
4.6.4 I/O Port Access SFRs............................................................................................ 65
4.6.5 Interrupt Enable (IE) ..............................................................................................65
4.7 Program and External Data Spaces ....................................................................................... 66
4.7.1 Program Space ...................................................................................................... 66
4.7.2 External Data Space ..............................................................................................66
4.8 CPU Halt Mechanisms ...........................................................................................................66
5. Cortex™-M3 Microcontroller 67
5.1 Features ................................................................................................................................. 67
5.2 How it Works .......................................................................................................................... 69
5.2.1 Registers ............................................................................................................... 69
5.2.1.1 Special Registers ................................................................................... 71
5.2.2 Operating Modes ................................................................................................... 72
5.2.3 Pipelining ............................................................................................................... 73
5.2.4 Thumb-2 Instruction Set ........................................................................................ 73
5.2.4.1 Data Processing Operations .................................................................. 73
5.2.4.2 Load Store Operations ........................................................................... 74
5.2.4.3 Branch Operations ................................................................................. 74
5.2.4.4 Instruction Barrier and Memory Barrier Instructions............................... 74
5.2.4.5 Saturation Operations ............................................................................ 74
5.2.5 SysTick Timer ........................................................................................................ 74
5.2.6 Debug and Trace: .................................................................................................. 75
5.3 Memory Map........................................................................................................................... 75
5.3.1 Bus Interface to SRAM Memory ............................................................................ 75
5.4 Exceptions .............................................................................................................................. 76
5.4.1 Priority Definitions.................................................................................................. 77
5.4.2 Fault Exceptions .................................................................................................... 77
5.4.3 System Call Exceptions ......................................................................................... 78
5.5 Nested Vector Interrupt Controller (NVIC).............................................................................. 78
28. I 2C 311
28.1 Features................................................................................................................................311
28.2 Block Diagram ......................................................................................................................311
28.3 Background Information........................................................................................................313
28.3.1 I2C Bus Description..............................................................................................313
28.3.2 Typical I2C Data Transfer.....................................................................................313
28.4 How It Works ........................................................................................................................313
28.4.1 Bus Stalling (Clock Stretching).............................................................................314
28.4.2 System Management Bus....................................................................................314
28.4.3 Pin Connections...................................................................................................314
28.4.4 I2C Interrupts .......................................................................................................314
28.4.5 Control by Registers ............................................................................................314
28.4.6 Operating the I2C Interface ..................................................................................315
28.4.6.1 Slave Mode ..........................................................................................316
28.4.6.2 Master Mode ........................................................................................317
28.4.6.3 Multi-Master Mode................................................................................318
28.5 Hardware Address Compare ................................................................................................318
28.6 Wake from Sleep ..................................................................................................................318
28.7 Slave Mode Transfer Examples............................................................................................319
28.7.1 Slave Receive ......................................................................................................320
28.7.2 Slave Transmit .....................................................................................................321
28.8 Master Mode Transfer Examples..........................................................................................322
28.8.1 Single Master Receive .........................................................................................322
28.8.2 Single Master Transmit ........................................................................................323
28.9 Multi-Master Mode Transfer Examples.................................................................................324
28.9.1 Multi-Master, Slave Not Enabled..........................................................................324
28.9.2 Multi-Master, Slave Enabled ................................................................................325
29. Digital Filter Block (DFB) 327
29.1 Features................................................................................................................................327
29.2 Block Diagram ......................................................................................................................327
29.3 How It Works ........................................................................................................................328
29.3.1 Controller .............................................................................................................328
29.3.1.1 FSM RAM.............................................................................................329
29.3.1.2 Program Counter..................................................................................330
29.3.1.3 Control Store ........................................................................................330
29.3.1.4 Next State Decoder ..............................................................................330
29.3.2 Datapath ..............................................................................................................331
29.3.2.1 MAC .....................................................................................................332
29.3.2.2 ALU ......................................................................................................332
29.3.2.3 Shifter and Rounder .............................................................................332
29.3.3 Address Calculation Unit......................................................................................333
29.3.4 Bus Interface and Register Descriptions..............................................................333
29.3.4.1 Streaming Mode ...................................................................................333
29.3.4.2 Block Transfer Modes ..........................................................................334
29.3.4.3 Result Handling ....................................................................................335
35.1 Features................................................................................................................................397
35.2 Block Diagram ......................................................................................................................397
35.3 How It Works ........................................................................................................................398
35.3.1 Reference Driver..................................................................................................398
35.3.2 Low Pass Filter ....................................................................................................398
35.3.3 Analog Mux Bus...................................................................................................398
35.3.4 GPIO Configuration for CapSense.......................................................................398
35.3.5 Other Resources..................................................................................................399
35.4 CapSense Delta Sigma Algorithm ........................................................................................400
36. Temperature Sensor 403
36.1 Features................................................................................................................................403
36.2 Block Diagram ......................................................................................................................403
36.3 How It Works ........................................................................................................................404
36.4 Command and Status Interface ............................................................................................404
36.4.1 Status Codes........................................................................................................405
36.4.2 Temperature Sensor Commands .........................................................................405
Glossary 479
Index 495
This document encompasses the PSoC® 3 CY8C38 Family and the PSoC® 5 CY8C55 Family. In conjunction with the device
datasheet, it contains complete and detailed information about how to use and design with the IP blocks that construct a
PSoC 3 or PSoC 5 device. This document describes the analog and digital architecture to give the designer a better under-
standing of features and limitations of PSoC 3. The routing of both digital and analog signals should be left to the tool
(PSoC Creator™). Hand routing, analog or digital, by use of registers, may conflict with the routing performed by PSoC Cre-
ator and produce unexpected results.
This section encompasses the following chapters:
■ Introduction chapter on page 23
■ Getting Started chapter on page 29
■ Document Construction chapter on page 31
See the PSoC® 3 Registers TRM (Technical Reference Manual) and the PSoC® 5 Registers TRM (Technical Reference Man-
ual) for complete register sets.
Table 1-1. PSoC® 3, PSoC® 5 Architecture TRM (Technical Reference Manual) Revision History
Origin of
Revision Issue Date Description of Change
Change
** 12.15.2008 HMT Preliminary release of the PSoC 3: CY8C38 Family Technical Reference Manual.
*A 02.12.2009 HMT Release for ES10.
*B 06.22.2009 HMT Initial silicon release.
*C 07.14.2009 HMT Initial non NDA release.
*D 09.08.2009 DSG Addressed many issues, changes throughout document.
*E 12.23.2010 DSG Document rewrite to reflect product development.
With a unique array of configurable digital and analog blocks, the Programmable System-on-Chip (PSoC®) is a true system-
level solution, offering a modern method of signal acquisition, processing, and control with exceptional accuracy, high band-
width, and superior flexibility. Its analog capability spans the range from thermocouples (DC voltages) to ultrasonic signals.
PSoC 3 (CY8C38xxxx, CY8C36xxx, CY8C34xxx, CY8C32xxx) and PSoC 5 (CY8C55xxx, CY8C54xxx, CY8C53xxx,
CY8C52xxx) families are fully scalable 8-bit and 32-bit PSoC platform devices that share these characteristics:
■ Fully pin, peripheral compatible
■ Same integrated development environment software
■ High performance, configurable digital system that supports a wide range of communication interfaces, such as USB, I2C,
and CAN
■ High precision, high performance analog system with up to 20-bit ADC, DACs, comparators, opamps, and programmable
blocks to create PGAs, TIAs, mixers, etc.
■ Easily configurable logic array
■ Flexible routing to all pins
■ High performance, 8-bit single-cycle 8051 (PSoC 3) or 32-bit ARM Cortex-M3 (PSoC 5) core
This document describes PSoC 3 and PSoC 5 devices in detail. Using this information, designers can easily create system-
level designs, using a rich library of prebuilt components, or custom verilog, and a schematic entry tool that uses the standard
design blocks. PSoC 3 and PSoC 5 devices provide unparalleled opportunities for analog and digital bill of materials (BOM)
integration, while easily accommodating last-minute design changes.
Analog Interconnect
Digital Interconnect
SIO
SYSTEM WIDE DIGITAL SYSTEM
GPIOs
Sequencer
UDB UDB UDB UDB
Xtal
FS USB USB
Osc
Clock Tree UDB UDB UDB UDB
8-Bit Nx 2.0 PHY
8-Bit SPI Timer
I2C Slave
12-Bit SPI
Logic Timer,
Counter,
UDB UDB UDB UDB
PWM
GPIOs
IMO
GPIOs
Logic
32.768 kHz
UDB UDB UDB UDB
(Optional)
UART 12-Bit PWM
RTC
Timer
SYSTEM BUS
GPIOs
MEMORY SYSTEM CPU SYSTEM Program,
WDT Debug
and 8051 CPU Interrupt
EEPROM SRAM Program
Wake Controller
Debug,
GPIOs
Trace
EMIF FLASH PHUB
Boundary
DMA
ILO Scan
Clocking System
GPIOs
Digital
ANALOG SYSTEM
Power Management LCD Direct
SIOs
System
Filter +
Drive
Block ADCs Nx
POR and Opamp 3 per
LVD –
Auxiliary Opamp
N x SC/CT Blocks ADC
Sleep (TIA, PGA, Mixer, etc.)
Power
+
1.71 to
Temperature
GPIOs
5.5 V
Sensor Nx Nx
1.8-V LDO
N x DAC DEL SIG CMP
ADC –
SMP CapSense
0.5 to 5.5 V
(Optional)
Analog Interconnect
Digital Interconnect
SIO
SYSTEM WIDE DIGITAL SYSTEM
GPIOs
Sequencer
UDB UDB UDB UDB
Xtal D+
FS USB USB
Osc
Clock Tree
UDB UDB UDB UDB
8-Bit Nx 2.0 PHY D-
8-Bit SPI Timer
I2C Slave
12-Bit SPI
Logic Timer,
Counter,
UDB UDB UDB UDB
PWM
GPIOs
IMO
GPIOs
Logic
32.768 kHz
UDB UDB UDB UDB
(Optional)
UART 12-Bit PWM
RTC
Timer
SYSTEM BUS
GPIOs
MEMORY SYSTEM CPU SYSTEM Program,
WDT Debug
and Cortex-M3 CPU Interrupt
EEPROM SRAM Program
Wake Controller
Debug,
GPIOs
Trace
EMIF FLASH PHUB
Boundary
DMA
ILO Scan
Clocking System
GPIOs
Digital
ANALOG SYSTEM
Power Management LCD Direct
SIOs
System
Filter +
Drive
Block Nx
ADCs Opamp
POR and N x SAR 3 per
LVD ADC –
Opamp
N x SC/CT Blocks
Sleep (TIA, PGA, Mixer, etc.)
Power Auxiliary
ADC
+
1.71 to
Temperature
GPIOs
5.5 V
0.5 to 5.5 V
(Optional)
The configurable analog subsystem includes: Higher resolution voltage DAC outputs are created using the
UDB array to create a pulse width modulated (PWM) DAC of
■ Analog muxes
up to 10 bits, at up to 48 kHz. The digital DACs in each UDB
■ Comparators support PWM, PRS, or Delta Sigma algorithms with pro-
■ Voltage references grammable widths.
■ Opamps
■ Mixers 1.7.5 Additional Analog Subsystem
■ Trans Impedance Amplifiers (TIA)
Components
■ Analog-to-Digital Converters (ADC) In addition to the ADCs, DACs, and the DFB, the analog
subsystem provides components such as multiple compara-
■ Digital-to-Analog Converters (DAC)
tors, uncommitted opamps, and configurable Switched
■ Digital Filter Block (DFB) Capacitor/Continuous Time (SC/CT) blocks supporting trans
All GPIO pins can route analog signals into and out of the impedance amplifiers, programmable gain amplifiers, and
device, using the internal analog bus. This feature allows mixers.
the device to interface up to 62 discrete analog signals.
1.8 Program and Debug
1.7.1 Delta Sigma ADC
TAG (4-wire) or Serial Wire Debugger (SWD) (2-wire) inter-
The heart of the analog subsystem is a fast, accurate, con-
faces are used for programming and debug. The 1-wire Sin-
figurable Delta Sigma ADC. With less than 100 µV offset, a
gle Wire Viewer (SWV) can also be used for “printf” style
gain error of ±0.1%, Integral Non-Linearity (INL) less than 1
debugging. By combining SWD and SWV, the designer can
LSB, Differential Non-Linearity (DNL) less than 0.5 LSB, and
implement a full debugging interface with just three pins.
signal-to-noise ratio (SNR) better than 90 dB (Delta Sigma)
in 16-bit mode, this converter addresses a wide variety of Using these standard interfaces enables the designer to
precision analog applications, including some of the most debug or program the PSoC device with a variety of hard-
demanding sensors. ware solutions from Cypress or third party vendors.
The quickest path to understanding any PSoC® device is to read the device datasheet and use PSoC Designer™ or
PSoC Creator™ Integrated Development Environments (IDEs) software. This technical reference manual helps to under-
stand the details of the PSoC 3 and PSoC 5 integrated circuit and its implementation.
For the most up-to-date ordering, packaging, or electrical specification information, refer to the individual PSoC device’s data-
sheet or go to http://www.cypress.com/psoc.
2.1 Support
Free support for PSoC products is available online at http://www.cypress.com. Resources include Training Seminars, Discus-
sion Forums, Application Notes, PSoC Consultants, TightLink Technical Support Email/Knowledge Base, and Application
Support Technicians.
The content sections of this technical reference manual start after this section – Section A: Overview on page 21. The follow-
ing sections include these topics:
■ Section B: CPU System on page 35
■ Section C: Memory on page 119
■ Section D: System Wide Resources on page 145
■ Section E: Digital System on page 211
■ Section F: Analog System on page 343
■ Section G: Program and Debug on page 441
For ease of use, information is organized into sections and chapters that are divided according to device functionality. Each
section begins with some interpretation detail and contains a top level architectural explanation. This is followed by chapters
that contain detailed explanation required for the implementation and use of the individual functions described. The PSoC® 3
Registers TRM (Technical Reference Manual) and the PSoC® 5 Registers TRM (Technical Reference Manual) are contained
in separate .pdf files.
This table lists the units of measure used in this document. BC broadcast clock
BIFC bit implemented functioning connection
Table 3-1. Units of Measure BINC bit implemented no connection
Symbol Unit of Measure BOM bill of materials
°C degrees Celsius BR bit rate
dB decibels BRA bus request acknowledge
fF femtofarads BRQ bus request
Hz Hertz CAN controller area network
k kilo, 1000 CBUS comparator bus
K kilo, 2^10 CI carry in
KB 1024 bytes, or approximately one thousand bytes CMP compare
Kbit 1024 bits CMRR common mode rejection ratio
kHz kilohertz (32.000) CO carry out
k kilohms CPU central processing unit
MHz megahertz CRC cyclic redundancy check
M megaohms CT continuous time
µA microamperes DAC digital-to-analog converter
µF microfarads DAP debug access port on ARM Cortex™-M3 of PSoC 5
µs microseconds DC direct current
µV microvolts DFB digital filter block
µVrms microvolts root-mean-square DOC debug on-chip module/block in PSoC 3
mA milliamperes DoC debug on-chip mode in PSoC 3 and PSoC 5
ms milliseconds DI digital or data input
mV millivolts DMA direct memory access
nA nanoamperes DMAC direct memory access controller
ns nanoseconds DNL differential nonlinearity
nV nanovolts DO digital or data output
ohms DSI digital signal interface
pF picofarads ECO external crystal oscillator
pp peak-to-peak EEPROM electrically erasable programmable read only memory
ppm parts per million EMIF external memory interface
SPS samples per second FB feedback
sigma: one standard deviation FSR full scale range
V volts GIE global interrupt enable
GPIO general purpose I/O
The PSoC® 3 and PSoC® 5 Central Processing Units (CPUs) are different. The PSoC 3 8051 CPU subsystem is built around
a single cycle pipelined 8051 8-bit processor, running up to 67 MHz. The single cycle 8051 CPU runs ten times faster than a
standard 8051 processor. The PSoC 3 instruction set is compatible with the original MCS-51 instruction set. The PSoC 5 CPU
subsystem is built around a 32-bit three stage pipelined ARM Cortex-M3 processor running up to 80 MHz.
System Bus
CPU SYSTEM
8051 or Interrupt
Cortex M3 CPU Controller
MEMORY PROGRAM
SYSTEM and DEBUG
PHUB
DMA
The PSoC® 3 CY8C38xx 8051 core is a high performance, speed optimized 8-bit Central Processing Unit (CPU). It is 100%
binary compatible with the industry standard 8051. The CY8C38 family includes wrapper logic around the 8051 core. This
wrapper includes internal data Random Access Memory (RAM), an external data space interface, a Special Function Register
– Input/Output (SFR – I/O) interface, and a CPU clock divider.
4.1 Features
The PSoC 3 8051 has the following features:
■ Pipelined RISC architecture that executes ten times faster than the industry standard 8051
■ 100% binary compatible with the industry standard 8051 instruction set
■ Most instructions executed in one or two cycles
■ 256 bytes of internal data RAM
■ Dual DPTR extension to the standard 8051 architecture
■ 24-bit external data space that enables access to on-chip memory and registers, and to off-chip memory
■ New interrupt interface that enables direct interrupt vectoring. See 4.3.4 Interrupt Controller Interface on page 38
■ New special function registers (SFRs) enable fast access to PSoC 3 I/O ports
8051 WRAPPER
8051 CPU
Program
Flash
Memory
Memory
Interface
External
SRAM
Data Interrupt Interrupt
Memory Interface Controller
PHUB Interface
Internal Internal
Data Data Debug
RAM Memory on-Chip
(256x8) Interface
Special
SFR to
I/O Function
I/O
Ports Registers
Interface
(SFRs)
rupted instruction, by popping the program counter from the 4.5 8051 Instructions
stack.
The 8051 has a full-featured set of instructions that supports
a number of flexible addressing modes.
4.4 CY 8051 Wrapper
The wrapper logic around the 8051 core provides an inter- 4.5.1 Internal Data Space Map
face to the rest of the PSoC 3 device. See Figure 4-1 on A diagram of the 8051 internal data space is shown in
page 38. The wrapper has the following features: Figure 4-2.
■ The 8051 is one of two bus masters, the other is the
Figure 4-2. 8051 Internal Data Space
DMA controller – see the PHUB and DMAC chapter on
page 91 0xFF
RAM Shared with SFRs
■ The two bus slaves are the on-chip SRAM and the Stack Space Special Function Registers
(indirect addressing, idata space) (direct addressing, data space)
PHUB: 0x80
❐ Accessed within the 8051 external data space 0x7F
RAM Shared with Stack Space
❐ Enables access to all PSoC 3 registers and to exter- (direct and indirect addressing, shared idata and data spaces)
0x30
nal memory
0x2F
Bit Addressable Area
■ An SFR – I/O interface allows direct access to some I/O 0x20
port registers using SFRs – see 4.4.1 SFR – I/O 0x1F
4 Banks, R0-R7 Each
Interface on page 39 0x00
ACALL addr11
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Unconditionally calls a subroutine located at the indicated address. The destination address is obtained by concatenating the five high-order
bits of the incremented PC, opcode bits 7-5, and the second byte of the instruction. The subroutine called must start within the same 2K block
of program memory as the first byte of the instruction following the ACALL.
ADD A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds the register indicated to the accumulator, leaving the result in the accumulator. The carry and auxiliary carry flags are set, respectively,
if there is a carry out of bit 7 or bit 3, and cleared otherwise. When adding unsigned integers, the overflow (OV) flag indicates an overflow
occurred. OV is set if there is a carry out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of bit 6; otherwise OV is cleared. When
adding signed integers, OV indicates a negative number produced as the sum of two positive operands, or a positive sum from two negative
operands.
ADD A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
ADD A, direct Add a direct byte to ACC C, AC, OV 0x25 2 2
(A) (A) + (direct)
Adds the direct byte indicated to the accumulator, leaving the result in the accumulator. The carry, auxiliary carry, and overflow flags are set
as described above.
ADD A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds a byte pointed to by R0 or R1 to the accumulator, leaving the result in the accumulator. The carry, auxiliary carry, and overflow flags are
set as described above.
ADD A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds an immediate byte (the second byte of the instruction) to the accumulator, leaving the result in the accumulator. The carry, auxiliary
carry, and overflow flags are set as described above.
ADDC A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds the register indicated, and the carry flag, to the accumulator, leaving the result in the accumulator. The carry and auxiliary carry flags
are set, respectively, if there is a carry out of bit 7 or bit 3, and cleared otherwise. When adding unsigned integers, the overflow flag indicates
an overflow occurred. OV is set if there is a carry out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of bit 6; otherwise OV is
cleared. When adding signed integers, OV indicates a negative number produced as the sum of two positive operands, or a positive sum
from two negative operands.
ADDC A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds the direct byte indicated, and the carry flag, to the accumulator, leaving the result in the accumulator. The carry, auxiliary carry, and
overflow flags are set as described above.
ADDC A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds a byte pointed to by R0 or R1, and the carry flag, to the accumulator, leaving the result in the accumulator. The carry, auxiliary carry,
and overflow flags are set as described above.
ADDC A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Adds an immediate byte (the second byte of the instruction), and the carry flag, to the accumulator, leaving the result in the accumulator. The
carry, auxiliary carry, and overflow flags are set as described above.
AJMP addr11
Mnemonic Function Operation Flags Opcodes Bytes Cycles
0x01,
0x21,
0x41,
(PC) (PC) + 2 0x61,
AJMP addr11 Absolute jump None 2 3
(PC10-0) page address 0x81,
0xA1,
0xC1,
0Xe1
Unconditionally transfers program control to the indicated address. The address is obtained by concatenating the five high-order bits of the
incremented PC, opcode bits 7-5, and the second byte of the instruction. The destination must be within the same 2K block of program mem-
ory as the first byte of the instruction following the AJMP.
ANL A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between the accumulator and a register, leaving the result in the accumulator.
ANL A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between the accumulator and a direct byte, leaving the result in the accumulator.
ANL A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between the accumulator and a byte pointed to by R0 or R1, leaving the result in the accumulator.
ANL A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between the accumulator and an immediate byte (the second byte of the instruction), leaving the
result in the accumulator.
ANL direct A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between a direct byte and the accumulator, leaving the result in the direct byte.
Performs a bitwise logical AND operation between a direct byte and an immediate byte (the third byte of the instruction), leaving the result in
the direct byte.
ANL C, bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between the carry flag and a bit, leaving the result in the carry flag.
ANL C, /bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical AND operation between the carry flag and the inversion of a bit, leaving the result in the carry flag.
(PC) (PC) + 3
If (A) (direct) then
Compare and jump if not (PC) (PC) + rel
CJNE A, direct, rel If (A) < (direct) then C 0xB5 3 5
equal
(C) 1
Else
(C) 0
Compares the magnitudes of the accumulator and the direct byte, and branches if their values are not equal. The branch destination is com-
puted by adding the signed relative displacement in the last instruction byte to the PC, after incrementing the PC to the start of the next
instruction. The carry flag is set if the unsigned integer value of the accumulator is less than the unsigned integer value of the direct byte; oth-
erwise, the carry is cleared. Neither operand is affected.
(PC) (PC) + 3
If (A) data then
Compare and jump if not (PC) (PC) + rel
CJNE A, #data, rel If (A) < data then C 0xB4 3 4
equal
(C) 1
Else
(C) 0
Compares the magnitudes of the accumulator and the immediate byte (the second byte of the instruction), and branches if their values are
not equal. The branch destination and carry flag are set as described above. The accumulator is not affected.
(PC) (PC) + 3
If (Rn) data then
Compare and jump if not (PC) (PC) + rel 0xB8 –
CJNE Rn, #data, rel If (Rn) < data then C 3 4
equal 0xBF
(C) 1
Else
(C) 0
Compares the magnitudes of the indicated register and the immediate byte (the second byte of the instruction), and branches if their values
are not equal. The branch destination and carry flag are set as described above. The register is not affected.
(PC) (PC) + 3
If ((Ri)) data then
Compare and jump if not (PC) (PC) + rel 0xB6,
CJNE @Ri, #data, rel If ((Ri)) < data then C 3 5
equal 0xB7
(C) 1
Else
(C) 0
Compares the magnitudes of the byte pointed to by R0 or R1 and the immediate byte (the second byte of the instruction), and branches if
their values are not equal. The branch destination and carry flag are set as described above. The byte pointed to by R0 or R1 is not affected.
CLR A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
CLR A Clear accumulator None None 1 1
(A) 0
CLR bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
CLR bit Clear bit None 0xC2 2 3
(bit) 0
CLR C
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
CLR C Clear carry None 0xC3 1 1
(C) 0
CPL A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
CPL A Complement accumulator None 0xF4 1 1
(A) /(A)
Each bit of the accumulator is logically complemented (one’s complement). Bits that previously contained a one are changed to zero and vice
versa.
CPL bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
CPL bit Complement bit None 0xB2 2 3
(bit) /(bit)
The bit variable specified is complemented. A bit that had been a one is changed to zero and vice versa. CPL can operate on the carry or any
directly addressable bit. When this instruction is used to modify an output pin, the value used as the original data will be read from the output
data latch, not the input pin.
CPL C
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
CPL C Complement carry C 0xB3 1 1
(C) /(C)
The carry flag is complemented. A bit that had been a one is changed to zero and vice versa.
DAA
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
if [[(A3-0) > 9] ^ [(AC) = 1]]
then
DA A
Decimal adjust accumula- (A3-0) (A3-0) + 6 C 0xD4 1 3
tor for addition next
if [[(A7-4) > 9] ^ [(C) = 1]]
then
(A7-4) (A7-4) + 6
Adjusts the value in the accumulator resulting from the earlier addition of two variables (each in packed BCD format), producing two four-bit
digits. Any ADD or ADDC instruction may have been used to perform the addition. If accumulator bits 3-0 are greater than nine (xxxx1010-
xxxx1111), or if the AC flag is one, six is added to the accumulator producing the proper BCD digit in the low- order nibble. This internal addi-
tion sets the carry flag if a carry-out of the low order four-bit field propagated through all high-order bits, but does not clear the carry flag oth-
erwise.
If the carry flag is now set, or if the four high-order bits now exceed nine (1010xxxx-1111xxxx), these high-order bits are incremented by six,
producing the proper BCD digit in the high-order nibble. Again, this sets the carry flag if there was a carry-out of the high-order bits, but does
not clear the carry. The carry flag thus indicates if the sum of the original two BCD variables is greater than 100, allowing multiple precision
decimal addition. OV is not affected.
All of this occurs during the one instruction cycle. Essentially; this instruction performs the decimal conversion by adding
00H, 06H, 60H, or 66H to the accumulator, depending on initial accumulator and PSW conditions. DA A cannot simply convert a hexadecimal
number in the accumulator to BCD notation, nor does DA A apply to decimal subtraction.
DEC A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
DEC A Decrement accumulator None 0x14 1 1
(A) (A) – 1
DEC Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
DEC direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
DEC direct Decrement direct byte None 0x15 2 3
(direct) (direct) – 1
The indicated direct byte is decremented by 1. An original value of 0 will underflow to 0xFF. When this instruction is used to modify an output
port, the value used as the original port data will be read from the output data latch, not the input pins.
DEC @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
The byte pointed to by R0 or R1 is decremented by 1. An original value of 0 will underflow to 0xFF. When this instruction is used to modify an
output port, the value used as the original port data will be read from the output data latch, not the input pins.
DIV
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
(A15-8) (A) / (B) result’s bits
DIV Divide C, OV 0x84 1 6
15..8
(B7-0) (A) / (B) result’s bits 7..0
Divides the unsigned integer in the accumulator by the unsigned integer in register B. The accumulator receives the integer part of the quo-
tient; register B receives the integer remainder. If B had originally contained 0, the values returned in the accumulator and register B are
undefined and the overflow flag is set. Otherwise the overflow flag is cleared. The carry flag is cleared.
(PC) (PC) + 2
Decrement and jump if not (Rn) (Rn) - 1 0xD8 –
if (Rn) 0 then
DJNZ Rn, rel None 2 4
zero 0xDF
(PC) (PC) + rel
Decrements the register indicated by 1, and branches to the address indicated by the second operand if the resulting value is not zero. An
original value of 0 will underflow to 0xFF. The branch destination would be computed by adding the signed relative-displacement value in the
last instruction byte to the PC, after incrementing the PC to the first byte of the following instruction.
(PC) (PC) + 3
Decrement and jump if not (direct) (direct) - 1
if (direct) 0 then
DJNZ direct, rel None 0xD5 3 5
zero
(PC) (PC) + rel
Decrements the direct byte indicated by 1, and branches to the address indicated by the second operand if the resulting value is not zero. An
original value of 0 will underflow to 0xFF. The branch destination would be computed as described above. When this instruction is used to
modify an output port, the value used as the original port data will be read from the output data latch, not the input pins.
INC A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
INC A Increment accumulator None 0x04 1 1
(A) (A) + 1
INC Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
INC direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
INC direct Increment direct byte None 0x05 2 3
(direct) (direct) + 1
The indicated direct byte is incremented by 1. An original value of 0xFF will overflow to 0. When this instruction is used to modify an output
port, the value used as the original port data will be read from the output data latch, not the input pins.
INC @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
The byte pointed to by R0 or R1 is incremented by 1. An original value of 0xFF will overflow to 0. When this instruction is used to modify an
output port, the value used as the original port data will be read from the output data latch, not the input pins.
INC DPTR
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
INC DPTR Increment data pointer None 0xC3 1 1
(DPTR) (DPTR) + 1
Increment the 16-bit data pointer by 1. A 16-bit increment is performed; an overflow of the low-order byte of the data pointer (DPL) from 0xFF
to 0 will increment the high-order byte (DPH). This is the only 16-bit register that can be incremented.
JB bit, rel
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 3
JB bit, rel Jump if bit is set if (bit) = 1 then None 0x20 3 5
(PC) (PC) + rel
If the indicated bit is a one, jump to the address indicated; otherwise proceed with the next instruction. The branch destination is computed by
adding the signed relative-displacement in the third instruction byte to the PC, after incrementing the PC to the first byte of the next instruc-
tion. The bit tested is not modified.
(PC) (PC) + 3
Jump if bit is set and clear if (bit) = 1 then
JBC bit, rel None 0x10 3 5
bit bit 0
(PC) (PC) + rel
If the indicated bit is one, branch to the address indicated; otherwise proceed with the next instruction. In either case, clear the designated bit.
The branch destination is computed as described above. When this instruction is used to test an output pin, the value used as the original
data will be read from the output data latch, not the input pin.
JC rel
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
JC rel Jump if carry is set if (C) = 1 then None 0x40 2 3
(PC) (PC) + rel
If the carry flag is set, jump to the address indicated; otherwise proceed with the next instruction. The branch destination is computed as
described above.
JMP @A + DPTR
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Add the 8-bit unsigned contents of the accumulator with the 16-bit data pointer, and load the resulting sum to the program counter. This will
be the address for subsequent instruction fetches. 16-bit addition is performed: a carry-out from the low-order 8 bits propagates through the
high order bits. Neither the accumulator nor the data pointer is altered.
(PC) (PC) + 3
JNB bit, rel Jump if bit is not set if (bit) = 0 then None 0x30 3 5
(PC) (PC) + rel
If the indicated bit is a zero, jump to the address indicated; otherwise proceed with the next instruction. The branch destination is computed
by adding the signed relative-displacement in the third instruction byte to the PC, after incrementing the PC to the first byte of the next
instruction. The bit tested is not modified.
JNC rel
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
JNC rel Jump if carry is not set if (C) = 0 then None 0x50 2 3
(PC) (PC) + rel
If the carry flag is set, jump to the address indicated; otherwise proceed with the next instruction. The branch destination is computed as
described above.
JNZ rel
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
if (A) 0 then
Jump if accumulator is not
JNZ rel None 0x70 2 4
zero
(PC) (PC) + rel
If any bit of the accumulator is a one, branch to the indicated address; otherwise proceed with the next instruction. The branch destination is
computed as described above. The accumulator is not modified.
JZ rel
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
Jump if accumulator is
JZ rel if (A) = 0 then None 0x60 2 4
zero
(PC) (PC) + rel
If all bits of the accumulator are zero, branch to the indicated address; otherwise proceed with the next instruction. The branch destination is
computed as described above. The accumulator is not modified.
LCALL addr16
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 3
(SP) (SP) + 1
((SP)) (PC7-0)
LCALL addr16 Long call None 0x12 3 4
(SP) (SP) + 1
((SP)) (PC15-8)
(PC) addr15-0
Calls a subroutine located at the indicated address. The high-order and low-order bytes of the PC are loaded, respectively, with the second
and third bytes of the LCALL instruction. Program execution continues with the instruction at this address. The subroutine may therefore
begin anywhere in the full 64 KB program memory address space.
LJMP addr16
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Does an unconditional branch to the indicated address, by loading the high- order and low-order bytes of the PC (respectively) with the sec-
ond and third instruction bytes. The destination may therefore be anywhere in the full 64K program memory address space.
MOV A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies the register indicated to the accumulator. The register is not affected.
MOV A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
MOV A, direct Copy a direct byte to ACC None 0xE5 2 2
(A) (direct)
Copies the direct byte indicated to the accumulator. The direct byte is not affected.
MOV A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies a byte pointed to by R0 or R1 to the accumulator. The byte pointed to by R0 or R1 is not affected.
MOV A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Loads the accumulator with an immediate byte (the second byte of the instruction).
MOV Rn, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies the accumulator to the register indicated. The accumulator is not affected.
Copies the direct byte indicated to the register indicated. The direct byte is not affected.
Loads the register indicated with an immediate byte (the second byte of the instruction).
MOV direct, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
MOV direct, A Copy ACC to a direct byte None 0xF5 2 2
(direct) (A)
Copies the accumulator to the direct byte indicated. The accumulator is not affected.
MOV direct, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies the register indicated to the direct byte indicated. The register is not affected.
Copies the direct source byte indicated to the direct destination byte indicated. The direct source byte is not affected.
Copies the byte pointed to by R0 or R1 to the direct byte indicated. The byte pointed to by R0 or R1 is not affected.
Loads the direct byte indicated with an immediate byte (the third byte of the instruction).
MOV @Ri, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies the accumulator to a byte pointed to by R0 or R1. The accumulator is not affected.
Copies the direct byte indicated to a byte pointed to by R0 or R1. The direct byte is not affected.
Loads a byte pointed to by R0 or R1 with an immediate byte (the second byte of the instruction).
MOV C, bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
MOV C, bit Copy a bit to C C 0xA2 2 2
(C) (bit)
The Boolean variable indicated (directly addressable bit) is copied into the carry flag.
MOV bit, C
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
MOV bit, C Copy C to a bit None 0x92 2 3
(bit) (C)
The carry flag is copied into the Boolean variable indicated (directly addressable bit).
(PC) (PC) + 3
DPH immediate
Load DPTR with immedi-
MOV DPTR, #data16 data15...8 None 0x85 3 3
ate data
DPL immediate
data7...0
Loads the data pointer with the 16-bit constant indicated. The 16 bit constant is loaded into the second and third bytes of the instruction. The
second byte (DPH) is the high-order byte, while the third byte (DPL) holds the low-order byte. This is the only instruction that moves 16 bits of
data at once.
MOVC A, @A + DPTR
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Loads the accumulator with a code byte, or constant from program memory. The address of the byte fetched is the sum of the original
unsigned accumulator contents and the contents of the 16-bit DPTR. A 16-bit addition is performed so a carry-out from the low-order eight
bits may propagate through higher-order bits.
MOVC A, @A + PC
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Loads the accumulator with a code byte, or constant from program memory. The address of the byte fetched is the sum of the original
unsigned accumulator contents and the contents of the 16-bit PC. The PC is incremented to the address of the following instruction before
being added to the accumulator. 16-bit addition is performed so a carry-out from the low-order eight bits may propagate through higher-order
bits.
MOVX A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies a byte of external data memory to the accumulator. The 24-bit external address is formed by concatenating the MXAX register (SFR
address 0xEA), the P2AX register (SFR address 0xA0), and the contents of R0 or R1. The external byte is not affected.
MOVX A, @DPTR
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies a byte of external data memory to the accumulator. The 24-bit external address is formed by concatenating the DPX register (SFR
address 0x93 or 0x95) and the contents of DPTR. The external byte is not affected.
MOVX @Ri, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies the accumulator to the external data memory address indicated. The 24-bit external address is formed as described in MOVX A, @Ri
above. The accumulator is not affected.
MOVX @DPTR, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Copies the accumulator to the external data memory address indicated. The 24-bit external address is formed as described above. The accu-
mulator is not affected.
MUL
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
MUL Multiply (A) (A) x (B) result’s bits 7…0 C, OV 0xA4 1 2
(B) (A) x (B) result’s bits 15…8
Multiplies the unsigned 8-bit integers in the accumulator and register B. The low-order byte of the 16-bit product is left in the accumulator, and
the high-order byte in B. If the product is greater than 255 (0xFF) the overflow flag is set; otherwise it is cleared. The carry flag is always
cleared.
NOP
Mnemonic Function Operation Flags Opcodes Bytes Cycles
ORL A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between the accumulator and a register, leaving the result in the accumulator.
ORL A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between the accumulator and a direct byte, leaving the result in the accumulator.
ORL A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between the accumulator and a byte pointed to by R0 or R1, leaving the result in the accumulator.
ORL A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between the accumulator and an immediate byte (the second byte of the instruction), leaving the
result in the accumulator.
ORL direct, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between a direct byte and the accumulator, leaving the result in the direct byte. When this instruction
is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins.
Performs a bitwise logical OR operation between a direct byte and an immediate byte (the third byte of the instruction), leaving the result in
the direct byte. When this instruction is used to modify an output port, the value used as the original port data will be read from the output
data latch, not the input pins.
ORL C, bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between the carry flag and a bit, leaving the result in the carry flag.
ORL C, /bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical OR operation between the carry flag and the inversion of a bit, leaving the result in the carry flag.
POP direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
POP direct Pop from stack (direct) ((SP)) None 0xD0 2 2
(SP) (SP) – 1
The contents of the internal RAM location addressed by the stack pointer are read, and the stack pointer is decremented by one. The value
read is copied to the direct byte indicated.
PUSH direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
PUSH direct Push to stack (SP) (SP) + 1 None 0xC0 2 3
((SP)) (direct)
The stack pointer is incremented by one. The contents of the direct byte indicated are then copied into the internal RAM location addressed
by the stack pointer.
RET
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC15-8) ((SP))
(SP) (SP) - 1
RET Return from subroutine None 0x22 1 4
(PC7-0) ((SP))
(SP) (SP) - 1
Pops the high and low-order bytes of the PC successively from the stack, decrementing the stack pointer by two. Program execution contin-
ues at the resulting address, generally the instruction immediately following an ACALL or LCALL.
RETI
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC15-8) ((SP))
(SP) (SP) - 1
RETI Return from interrupt None 0x32 1 4
(PC7-0) ((SP))
(SP) (SP) - 1
Pops the high and low-order bytes of the PC successively from the stack, and restores the interrupt logic to accept additional interrupts at the
same priority level as the one just processed. The stack pointer is left decremented by two. No other registers are affected; the PSW is not
automatically restored to its pre-interrupt status. Program execution continues at the resulting address, which is generally the instruction
immediately after the point at which the interrupt request was detected. If a lower or same-level interrupt is pending when the RETI instruction
is executed, that one instruction will be executed before the pending interrupt is processed.
RL A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
RL A Rotate ACC left (An + 1) (An) n = 0-6 None 0x23 1 1
(A0) (A7)
The eight bits in the accumulator are rotated one bit to the left. Bit 7 is rotated into the bit 0 position.
RLC A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
(An + 1) (An) n = 0-6
RLC A RLC A C 0x33 1 1
(A0) (C)
(C) (A7)
The eight bits in the accumulator and the carry flag are together rotated one bit to the left. Bit 7 moves into the carry flag; the original state of
the carry flag moves into the bit 0 position.
RR A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
RR A Rotate ACC right (An) (An + 1) n = 0-6 None 0x03 1 1
(A7) (A0)
The eight bits in the accumulator are rotated one bit to the right. Bit 0 is rotated into the bit 7 position.
RRC A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
Rotate ACC right through (An) (An + 1) n = 0-6
RRC A C 0x13 1 1
C (A7) (C)
(C) (A0)
The eight bits in the accumulator and the carry flag are together rotated one bit to the right. Bit 0 moves into the carry flag; the original state
of the carry flag moves into the bit 7 position.
SETB bit
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
SETB bit Set bit None 0xD2 2 3
(bit) 1
SETB C
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
SETB C Set carry None 0xD3 1 1
(C) 1
SJMP rel
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 2
SJMP rel Short jump None 0x80 2 3
(PC) (PC) + rel
Program control branches unconditionally to the address indicated. The branch destination is computed by adding the signed displacement
in the second instruction byte to the PC, after incrementing the PC twice. Therefore, the range of destinations allowed is from 128 bytes pre-
ceding this instruction to 127 bytes following it. Note the an SJMP with a displacement of 0xFE would be a one-instruction infinite loop.
SUBB A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Subtracts the register indicated, and the carry flag, from the accumulator, leaving the result in the accumulator. The carry (borrow) flag is set
if a borrow is needed for bit 7, and otherwise C is cleared. (If C was set before executing the instruction, this indicates that a borrow was
needed for the previous step in a multiple precision subtraction, so the carry is subtracted from the accumulator along with the source oper-
and). AC is set if a borrow is needed for bit 3, and cleared otherwise. OV is set if a borrow is needed into bit 6 but not into bit 7, or into bit 7
but not bit 6. When subtracting signed integers OV indicates a negative number produced when a negative value is subtracted from a posi-
tive value, or a positive result when a positive number is subtracted from a negative number.
SUBB A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Subtracts the direct byte indicated, and the carry flag, from the accumulator, leaving the result in the accumulator. The carry, auxiliary carry,
and overflow flags are set as described above.
SUBB A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Subtracts a byte pointed to by R0 or R1, and the carry flag, from the accumulator, leaving the result in the accumulator. The carry, auxiliary
carry, and overflow flags are set as described above.
SUBB A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Subtracts an immediate byte (the second byte of the instruction), and the carry flag, from the accumulator, leaving the result in the accumula-
tor. The carry, auxiliary carry, and overflow flags are set as described above.
SWAP
Mnemonic Function Operation Flags Opcodes Bytes Cycles
(PC) (PC) + 1
SWAP Swap nibbles within ACC (A3-0) (A7-4), None 0xC4 1 1
(A7-4) (A3-0)
SWAP A interchanges the low and high-order nibbles (four-bit fields) of the accumulator (bits 3-0 and bits 7-4). The operation can also be
thought of as a four-bit rotate instruction.
XCH A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
XCH A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
XCH A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
XCHD A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
XCHD exchanges the low-order nibble of the accumulator (bits 3-0, generally representing a hexadecimal or BCD digit), with that of the byte
pointed to by R0 or R1. The high-order nibbles (bits 7-4) are not affected.
XRL A, Rn
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical exclusive OR operation between the accumulator and a register, leaving the result in the accumulator.
XRL A, direct
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical exclusive OR operation between the accumulator and a direct byte, leaving the result in the accumulator.
XRL A, @Ri
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical exclusive OR operation between the accumulator and a byte pointed to by R0 or R1, leaving the result in the accu-
mulator.
XRL A, #data
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical exclusive OR operation between the accumulator and an immediate byte (the second byte of the instruction), leav-
ing the result in the accumulator.
XRL direct, A
Mnemonic Function Operation Flags Opcodes Bytes Cycles
Performs a bitwise logical exclusive OR operation between a direct byte and the accumulator, leaving the result in the direct byte. When this
instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins.
Performs a bitwise logical exclusive OR operation between a direct byte and an immediate byte (the third byte of the instruction), leaving the
result in the direct byte. When this instruction is used to modify an output port, the value used as the original port data will be read from the
output data latch, not the input pins.
4.6.1 SFRs
Table 4-6 shows the map for the SFRs space.
Table 4-6. SFR Map
0/8
1/9 2/A 3/B 4/C 5/D 6/E 7/F
(Bit Addressable)
0xF8 SFRPRT15DR SFRPRT15PS SFRPRT15SEL
0xF0 B SFRPRT12SEL
0xE8 SFRPRT12DR SFRPRT12PS MXAX
0xE0 ACC
0xD8 SFRPRT6DR SFRPRT6PS SFRPRT6SEL
0xD0 PSW
0xC8 SFRPRT5DR SFRPRT5PS SFRPRT5SEL
0xC0 SFRPRT4DR SFRPRT4PS SFRPRT4SEL
0xB8
0xB0 SFRPRT3DR SFRPRT3PS SFRPRT3SEL
0xA8 IE
0xA0 P2AX SFRPRT1SEL
0x98 SFRPRT2DR SFRPRT2PS SFRPRT2SEL
0x90 SFRPRT1DR SFRPRT1PS DPX0 DPX1
0x88 SFRPRT0PS SFRPRT0SEL
0x80 SFRPRT0DR SP DPL0 DPH0 DPL1 DPH1 DPS
During a MOVX instruction using the DPTR0/DPTR1 register, XRAMADDR[23:16] is always equal to the contents of DPX0
(SFR 0x93) / DPX1 (SFR 0x95).
During a MOVX instruction using the R0 or R1 register, XRAMADDR[23:16] is always equal to the contents of MXAX (SFR
0xEA), and XRAMADDR[15:8] is always equal to the contents of P2AX (SFR 0xA0).
■ SFR bus – allows faster access to a limited set of I/O port registers
SFR registers contain three registers for each I/O port, making a total of 27 registers for 9 I/O ports. The registers function in
this manner:
■ SFRPRTxDR – sets the output data state of the port (where x is port number and includes ports 0-6, 12, and 15)
■ SFRPRTxSEL – selects each SFRPRTxDR register bit to set the output state of corresponding pin:
❐ If the SFRPRTxSEL[y] bit is high, the SFRPRTxDR[y] bit sets the output state for the pin
❐ If the SFRPRTxSEL[y] bit is low, PRTxDR[y] of port logic sets the output state of the pin (where y varies from 0 to 7)
■ SFRPRTxPS – a read-only register that contains pin state values of the port pins
Figure 4-3 shows the connections between the 8051 and the I/O ports.
SFRPRT0DR
I/O
SFRPRT0SEL Port 0
SFRPRT15DR
I/O
8051
SFRs SFRPRT15SEL Port 15
Core
SFRPRT15PS
SFRPRT0PS
The PSoC 5 ARM Cortex-M3 core is a high performance, low power 32-bit Central Processing Unit (CPU). It has an efficient
Harvard 3-stage pipeline core, a fixed 4 GB memory map, and supports the 16/32-bit Thumb-2 instruction set. The Cortex-M3
also features hardware divide instructions and low-latency ISR (Interrupt Service Routine) entry and exit.
The Cortex-M3 processor includes a number of other components that are tightly linked to the CPU core. These include a
Nested Vectored Interrupt Controller (NVIC), a SYSTICK timer, and numerous debug and trace blocks.
This section gives an overview of the Cortex-M3 processor. For further details please see the ARM Cortex-M3 Technical Ref-
erence Manual available at http://www.arm.com. Figure 5-1 shows a diagram of the Cortex-M3 and its interface to different
blocks on the device.
5.1 Features
■ Three stage pipelining operating at 1.25 DMIPS/MHz. This helps to increase execution speed or reduce power.
■ Supports Thumb-2 instruction set:
❐ The Thumb-2 instruction set supports complex operations with both 16- and 32-bit instructions
❐ Atomic bit level read and write instructions
❐ Support for unaligned memory access
■ Improved code density, ensuring efficient use of memory.
■ Easy to use, ease of programmability and debugging:
❐ Ensures easier migration from 8- and 16-bit processors
■ Nested Vectored Interrupt Controller (NVIC) unit to support interrupts and exceptions:
❐ Helps to achieve rapid interrupt response
■ Extensive debug support including:
❐ Serial Wire Debug Port (SWD-DP), Serial Wire JTAG Debug Port (SWJ-DP)
❐ Break points
❐ Flash patch
❐ Instruction tracing
❐ Code tracing
Data
Nested
Interrupt Inputs Watchpoint and
Vectored Cortex M3 CPU Core Embedded
Trace (DWT)
Interrupt Trace Module
Controller (ETM)
(NVIC)
Instrumentation
Trace Module
I- Bus D-Bus S-Bus (ITM)
Trace Pins:
JTAG/SWD Debug Block Trace Port 5 for TRACEPORT or
(Serial and Flash Patch Interface Unit 1 for SWV mode
JTAG) and Breakpoint (TPIU)
(FPB)
C-Bus Cortex M3 Wrapper
AHB AHB
32 KB Bus
SRAM Matrix Bus 256 KB
Matrix Cache ECC
Flash
AHB
32 KB Bus
SRAM Matrix
AHB Bridge & Bus Matrix DMA
PHUB
AHB Spokes
Peripherals
5.2.1 Registers
The Cortex-M3 has 16 32-bit registers (Figure 5-2). They
are:
■ R0 to R12 - general purpose registers
❐ R0 to R7 – can be accessed by all instructions
❐ R8 to R12 – can be accessed by all 32-bit and some
16-bit instructions
■ R13 – Stack Pointer (SP). There are two stack pointers,
with only one available at a time. The SP is always 32-bit
word aligned; bits [1:0] are always ignored and consid-
ered to be ‘0’.
■ R14 – Link register. Stores the return program counter
during function calls.
■ R15 – Program counter. This register can be written to
control program flow.
R5
General Purpose Register
Low Registers
R6 General Purpose Register
PRIMASK
Special registers
FAULTMASK Interrupt Mask registers
BASEPRI
These registers provide ALU flags (zero, carry), execution status, and current executing interrupt number. The three PSRs
can be accessed separately or collectively, using the special instructions MSR and MRS. They can be collectively addressed
as xPSR.
Control Register When the code is in user level, it cannot access the debug
resources and certain important registers.
This register controls the stack pointer selection and the
privilege level of the processor. It has only two bits: In addition to the privilege levels, the processor supports
two types of operating modes:
CONTROL[0]
■ Thread Mode – Thread mode is used by all normal
‘0’ Privileged in Thread Mode applications. During the thread mode the Process Stack
‘1’ User state in Thread mode Pointer (PSP) is used. The thread mode can exist in
both privileged level and user level. Switching from privi-
CONTROL[1] leged level to user level can be done by just writing to
‘0’ Default stack is used the control register but the reverse cannot be done.
When an exception occurs, the system is automatically
‘1’ Alternate stack is used taken to privileged level and at the exit of the exception it
comes back to the user level. Restoring to the privileged
5.2.2 Operating Modes level can be done only by going through an exception
handler that programs the control register for the privi-
The Cortex-M3 supports two privilege levels:
leged mode.
■ Privileged – Code has no limit to resources
■ Handle Mode – Handle mode is used by OS kernel and
■ User – Code has some limits to the resources exception handlers. During this mode, the main stack
Privilege level can be controlled using the control register. pointer (MSP) is used. The handle mode can exist only
in the privileged level.
Privilege Level
User Privileged
Thread Mode
Privileged Handle
Exception Mode
Entry / Exit
Exception
Program Entry / Exit
Control
Register Privileged Thread Default
User Thread Mode
Mode
The Cortex-M3 supports 32-bit multiply instructions and mul- ■ Call and Unconditional branch instructions
tiply accumulate instructions that give 64-bit results. These ■ Decision and Conditional branch instructions
instructions support signed or unsigned values.
■ Combined Compare and Conditional Branch
Another group of data processing instructions are logical ■ Conditional Branching using IT instructions
operations such as AND, ORR (or), EOR (exclusive OR),
and rotate and shift functions. In some cases the rotate The IT (IF-THEN) instruction block is very useful for han-
operation can be combined with other operations. dling small conditional code. It avoids branch penalties
because there is no change to program flow. It can provide a
Another group of data processing instructions is used for maximum of four conditionally executed instructions with
reversing data bytes in a register. These instructions are one condition check.
usually used for conversion between little endian and big
endian data. 5.2.4.4 Instruction Barrier and Memory
The last group of data processing instructions is for bit field Barrier Instructions
processing. Instructions such as BFC, BFI, SBFX, and The Cortex-M3 supports a number of barrier instructions.
UBFX are used to clear, set, and copy bits with sign exten- These instructions are needed with complex memory sys-
sion or zero extension. tems. In some cases, if memory barrier instructions are not
used, race conditions can occur.
5.2.4.2 Load Store Operations
There are three barrier instructions in the Cortex-M3:
One of the most basic functions in a processor is transfer of
■ DMB (Data Memory Barrier) – Ensures that all memory
data. In the Cortex-M3, data transfers can be one of the fol-
accesses are completed before new memory access is
lowing types:
committed. For example, when you do a data write fol-
■ Moving data between register and register lowed immediately by a read on a dual port memory, if
■ Moving data between memory and register the memory write is buffered, the DMB instruction can be
■ Moving data between special register and register used to ensure the read gets the updated value.
■ Moving an immediate data value into a register ■ DSB (Data Synchronization Barrier) – Ensures that all
memory accesses are completed before the next
The command to move data between registers is MOV instruction is executed
(move). For example, moving data from register R3 to regis-
■ ISB (Instruction Synchronization Barrier) – Flushes the
ter R8 looks like this:
pipeline and ensures that all previous instructions are
MOV R8, R3 completed before executing new instructions
Another instruction can generate the negative value of the 5.2.4.5 Saturation Operations
original data; it is called MVN (move negative).
The Cortex-M3 supports two instructions that provide signed
The basic instructions for accessing memory are Load and and unsigned saturation operations: SSAT and USAT (for
Store. Load (LDR) transfers data from memory to registers, signed data type and unsigned data type, respectively).
and Store transfers data from registers to memory. The
transfers can be in different data sizes (byte, half word, Saturation is commonly used in signal processing, for exam-
word, and double word). ple, in signal amplification.
Multiple Load and Store operations can be combined into The saturation operation does not prevent the distortion of
single instructions called LDM (Load Multiple) and STM the signal, but the amount of distortion is greatly reduced in
(Store Multiple). the signal waveform.
ARM processors also support memory accesses with pre- 5.2.5 SysTick Timer
indexing and post-indexing. Two other types of memory
operation are stack PUSH and stack POP. The SysTick timer is integrated with the NVIC and gener-
ates the SYSTICK interrupt. This interrupt can be used for
The Cortex-M3 has a number of special registers. To access task management in a real time system. The timer has a
these registers, use the instructions MRS and MSR. reload register with 24 bits available to use as a countdown
value. The timer can take an internal clock (the free running
5.2.4.3 Branch Operations clock on the CM3 processor) or an external clock through
The branch operations include:
the STCLK. In PSoC 5 devices use one of three sources as, tions. Some instructions cannot support unaligned
ILO (1 kHz), ILO_100 (100 kHz), or the SYSCLK (BUSCLK). accesses.
You can execute code from within the code, SRAM, or the
5.2.6 Debug and Trace: external RAM space.
The Cortex-M3 provides a wide range of debugging compo- The Cortex-M3 uses little-endian format.
nents. The debug unit is tightly linked with the core.
The important features of the debug and trace are: 5.3.1 Bus Interface to SRAM Memory
■ Debug access to all memory and registers in the system The 64 KB of SRAM in PSoC 5 is split into two 32 KB of
including Cortex-M3 register bank when the core is run- SRAM. The SRAM can be accessed by the C-Bus, S-Bus,
ning, halted, or held in reset. and the PHUB's DMA. The priority decoder gives a higher
■ Serial Wire Debug Port (SW-DP) and Serial Wire JTAG priority to the C-Bus in the upper 32 KB of SRAM, whereas
Debug Port (SWJ-DP) debug access. the PHUB DMA takes a higher priority in the lower 32 KB of
■ Flash Patch and Breakpoint (FPB) unit for implementing SRAM. The upper and lower halves of SRAM can be
breakpoints and code patches. accessed simultaneously but with different buses.
For further details about the debug and trace feature, refer
to the Test Controller chapter on page 443 and the 8051
Debug on-Chip chapter on page 455.
0xE00FF000
ROM Table
0xE00FEFFF
External Private
Peripheral Bus
0xE0042000
ETM
0xE0041000
0xFFFFFFFF
TPIU
0xE0040000
Vendor Specific
0xE0100000
Private Peripheral Bus: 0xE00FFFFF
Debug/External 0xE0040000
0xE003FFFF Private Peripheral Bus: 0xE003FFFF
Reserved
Internal 0xE0000000
0xE000F000
NVIC 0xDFFFFFFF
0xE000DFFF
Reserved
0xE0003000 External Device
FPB
0xE0002000
DWT
0xE0001000
ITM 1 GB
0xE0000000 0xA0000000
0x9FFFFFFF
0x43FFFFFF
External RAM
Bit-Band Alias
0x42000000 32 MB
0x41FFFFFF 1 GB
31 MB 0x60000000
0x40100000 0x5FFFFFFF
Bit-Band region
0x40000000 1 MB Peripherals
0.5 GB 0x40000000
0x3FFFFFFF
0x23FFFFFF
5.4 Exceptions system exceptions and 16 and above for external interrupt
inputs. PSoC 5 architecture supports 32 external interrupts.
The Cortex-M3 provides a feature-packed exception archi-
The exceptions are handled by the NVIC.
tecture that supports a number of system exceptions and
external interrupts. Exceptions are numbered 1 to 15 for
Most of the exceptions have programmable priority, and a few have fixed priority. Table 5-2 shows the list of exceptions avail-
able in the Cortex-M3:
A number of system exceptions are useful for fault handling. Bus Faults
There are several categories of faults:
Usage faults can be caused by a number of things, including SysTick Timer Exception
the following:
The SysTick Timer exception takes the vector number 15.
■ Undefined instructions
Cortex-M3 supports a 24-bit down counter. This timer is very
■ Coprocessor instructions (the Cortex-M3 processor does useful to perform task management where the software can
not support a coprocessor, but it is possible to use the be handled inside the timer interrupt.
fault exception mechanism to run software compiled for
other Cortex processors via coprocessor emulation) The SYSTICK Timer can be used to generate interrupts. It
has a dedicated exception type and exception vector. It
■ Trying to switch to the ARM state (software can use this
makes porting operating systems and software easier
faulting mechanism to test whether the processor on
because t he process is the same across different Cortex-
which it runs supports ARM code; since the Cortex-M3
M3 products.
does not support the ARM state, a usage fault takes
place if there is an attempt to switch) The SYSTICK Timer is controlled by four registers. Of the
■ Invalid interrupt return (link register contains invalid/ four registers, TICKINT is used to enable or disable the
incorrect values) timer exception.
overhead of state saving and restoration between inter- 5.5.1.1 Example Procedures in Setting Up
rupts. an Interrupt
■ Processor state automatically saved upon interrupt
Here is a simple example procedure for setting up an inter-
entry, and restored upon interrupt exit, with no instruc-
rupt:
tion overhead.
1. Copy the Hard Fault and NMI handlers to a new vector
table location if vector table relocation is required. (In
5.5.1 Basic Interrupt Configuration simple applications, this might not be needed.)
Each external interrupt has several associated registers. 2. The Vector Table Offset register should also be set up to
■ Enable and Clear Enable get the vector table ready (optional).
3. Set up the interrupt vector for the interrupt. Since the
■ Set Pending and Clear Pending
vector table could have been relocated, you might need
■ Priority Level to read the Vector Table Offset register; then calculate
■ Active Status the correct memory location for your interrupt handler.
This step might not be needed if the vector is hardcoded
■ Exception-masking registers (PRIMASK, FAULTMASK,
in ROM.
and BASEPRI)
4. Set up the priority level for the interrupt.
■ Vector Table Offset
5. Enable the interrupt.
The interrupt enable and clear enable registers are 32-bit
registers. They are used to enable/disable an interrupt. An 5.5.2 Nested Interrupts
interrupt that is waiting for the CPU execution sets the pend-
Nested interrupt support is built into the Cortex-M3 proces-
ing bit in the set pending register. Once the interrupt has
sor core and the NVIC. The nesting is done based on the
been executed by the CPU, the interrupt is cleared automat-
priority of the interrupts. When the processor is handling an
ically by setting the clear-pending register. The interrupts
exception, all other exceptions with the same or lower prior-
can take priorities 0 to 7. The priorities are configured using
ity will be blocked. When a high priority interrupt occurs, the
the 3-bit priority registers. They can be dynamically config-
low priority interrupt is nested and the high priority interrupt
ured during run time.
completes the execution. Since automatic hardware stack-
The Active Status register stores the details of the interrupt ing and unstacking is done, nesting is done without risk of
currently active. A bit set in this register indicates that the losing data in registers. Since Cortex-M3 uses the main
corresponding interrupt is currently active. An interrupt is stack to store the nesting interrupt details, care should be
called active if it is currently executed by the CPU or if it is taken to ensure sufficient stack space is available.
already nested and put to the stack. Once the interrupt exe-
Reentrant exceptions are not supported in the Cortex-M3.
cution is complete, the active status bit of the interrupt is
automatically cleared. With PSoC 5 devices, the addresses
of the interrupt service routine are stored in the Interrupt 5.5.3 Tail-Chaining Interrupts
vector table. The interrupt vector table can be located either The Cortex-M3 uses a number of methods to improve inter-
in RAM or ROM. The position of the vector table is con- rupt latency. Tail-chaining is one such method.
trolled using the Vector Table Offset register.
When an exception takes place but the processor is han-
The exception masking registers, PRIMASK, FAULTMASK dling another exception of the same or higher priority, the
and BASEPRI, are special registers used to mask the inter- exception will be pended. When the processor has finished
rupts and exceptions. executing the current exception handler, instead of POP, the
■ PRIMASK – When set, all interrupts except NMI and registers go back into the stack and PUSH it back in again,
Fault interrupts are masked skipping the unstacking and the stacking. In this way the
■ FAULTMASK – When set, all interrupts except NMI are timing gap between the two exception handlers is greatly
masked reduced.
The cache block is an instruction cache only. It is responsible for servicing instruction fetches from the CPU. It stores lines of
code from the flash in its internal buffer for fast accesses made by the CPU at a later time.
6.1 Features
■ Single Port Cache RAM (CRAM) – either one read or one write at a time
■ Instruction cache
■ Fully associative
■ 512 bytes total cache memory in PSoC 3
■ Control to enable and disable cache
■ Designed to put flash into sleep automatically to save power
CPU PHUB
FLASHIF FLASHIF
CRAMIF CSRs
(clk_cpu ver) (clk_bus ver)
CRAM
64x64
ECC NV_WRAPPER
FLASH
CRAMIF logic handles the communication between the Figure 6-2. Cache Lines
cache and the other blocks -CPU, background fill (BFILL),
and PHUB requests.
Each cache line has tag information. The address that is 6.3.2 Cache Line Locking:
used to look up the cache is broken down into these fields:
Each cache line can be locked so that it is not replaced at
Figure 6-4. Cache Byte Format next the flash instruction request. A cache line can be
locked by setting TAG_LOCK bit of corresponding tag regis-
ter CACHE_TAG [0…7] to 1.
The LRU points to the cache line, which is the oldest of the it is good idea to also turn ON BFILL to improve cache per-
used cache lines. The cache line that is evicted can be the formance. However since background fill is a speculative
line which is pointed by the LRU, however if the line pointed function, it could be create what turns out to be wasteful
by LRU is locked, then the unlocked line which is closer is reads from the flash. Thus for highly power sensitive appli-
evicted. The process of replacing the cache line can be cations, it may be desirable to disable the BFILL function to
understood by above figure. save some power at the expense of performance.
The cache block is an Instruction cache only. It services instruction fetches from the CPU. It stores lines of code from the
flash in its internal buffer for fast accesses made by the CPU at a later time.
7.1 Features
■ Instruction cache
■ Direct mapped
■ 128 bytes total cache memory
■ Registers for measuring cache hit/miss ratios
■ Error correction code (ECC) support
■ Error logging and interrupt generation
■ Designed to put flash into sleep automatically to save power
CPU
2
5
Cache Control RAM PHUB
4
Flash Interface 3
11
External
Memory
7.3 Cache Enabling and is executed and at the end of the code under measurement,
the HITMISS register should be read. The cache hit ratio
Disabling can be computed as-
To enable the cache, set the DISABLE bit (Bit 0) of Cache hit ratio = the number of cache hits (HITMISS
CACHE.CC_CTL register t to 0. [31:16])/Number of cache misses (HITMISS[15:0])
PSoC® 3 and PSoC® 5 devices use a high-performance bus for peripheral access and bulk data transfer. The high-perfor-
mance bus and the associated central controller are known as the peripheral hub (PHUB). The PHUB is a programmable and
configurable central bus backbone within a PSoC 3 or PSoC 5 device that ties the various on-chip system elements together.
It consists of multiple spokes; each spoke is connected to one or more peripheral blocks. The PHUB also includes a direct
memory access controller (DMAC), which is used for data transfer. The DMAC supports multiple DMA channels.
There are two bus masters (blocks that can initiate bus traffic) in PSoC 3 and PSoC 5 devices. These are the DMAC and the
CPU. An arbiter in the PHUB is responsible for arbitrating requests from the CPU and the DMAC. Upon receiving a request
from the microcontroller or the DMAC, the PHUB relays the request to the appropriate peripheral spoke.
8.1 PHUB
PHUB manages arbitration between the CPU and the DMAC.
8.1.1 Features
The PHUB has the following features:
■ Industry-standard Advanced Microcontroller Bus Architecture High-performance Bus (AMBA -HB) lite protocol
■ 8 spokes connected to various peripherals
■ 8-/16-/32-bit data-width support
■ Peripherals of various address widths connected to the same spoke
■ Includes programmable DMAC with 24 direct memory access (DMA) channels
■ Byte order and data width difference translation
CPU
PHUB
CPU
Interface CHn
CSRs
Channel[n]
CHn
CSRs
Config/
Status
Channel
Arbitration
CFGMEM Spoke 0
Local
DMAC SRAM
Memory
TDMEM
Local Spoke /
PHUB
Config/Status Spoke Arbitration
Spokes to Peripherals
The PHUB is used to connect the CPU to memory and Address Data
Spoke Width Width Peripheral Names
peripherals, including SRAM, flash, EEPROM, analog sub- (in bits) (in bits)
system, digital blocks, digital filter block, and others. 0 14 32 SRAM
The PHUB connects to the peripherals using a spoke. There IO interface, port interrupt control unit
1 9 16
(PICU), external memory interface (EMIF)
are eight spokes. Each spoke connects to one or more
PHUB local spoke, power management,
peripherals. Each spoke is configured for: 2 19 32
clock, serial wire viewer (SWV), EEPROM
■ Address width – The address width of a spoke depends 3 11 16 Delta-sigma ADC, analog interface
on the maximum number of addresses required for the USB, CAN, fixed-function I2C, fixed-function
4 10 16
peripherals connected to the spoke. timers
5 11 32 Digital filter block (DFB)
■ Data width – The data width of a spoke can be 16 or
32 bits. Eight-bit data transfer can be performed on 16- UDB set 0 registers (including DSI, configu-
6 17 16
ration, and control registers), UDB interface
and 32-bit spokes.
UDB set 1 registers (including DSI, configu-
7 17 16
■ Number of peripherals – This depends on the device ration, and control registers)
architecture. Each spoke is usually connected to multiple
■ The peripherals connected to each spoke can have data
peripherals.
widths longer than the spoke. For example, a Delta-
Table 8-1 shows the address width, data width, and periph- Sigma ADC can support up to 20-bit data although it is
erals connected to each spoke in PSoC 3 and PSoC 5 placed in the 16-bit spoke (spoke 03).
device.
In this case, the PHUB uses an internal FIFO to accom-
modate the width differences during data transfer.
■ One peripheral can extend across multiple spokes. In 8.2 DMA Controller
this case, the peripheral will have different address
spaces that are connected to each spoke. The DMA Controller (DMAC) transfers data between mem-
For example, Table 8-1 shows that UDB registers ory and peripherals.
extend across two spokes. UDB registers can be ■ Uses the PHUB for data transfer
accessed in 8-bit mode and also in 16-bit mode. In this ■ Includes 24 DMA channels
case, the 8-bit mode access needs a different address
space than the 16-bit mode access though they reside in ■ Includes 128 transaction descriptors (TD)
the same spoke. ■ Eight levels of priority per channel
■ Peripherals of different data widths can be connected to ■ Transactions can be triggered by any digitally routable
a single spoke. signal, the CPU, or another DMA channel
An example of this is spoke 3, which is connected to the ■ Transactions can be stalled or canceled
analog interface (digital-to-analog converter) and delta-
■ Each transaction can be from 1 to 64 KB
sigma ADC. The delta-sigma ADC can support up to
20-bit data, and the digital-to-analog converter register is ■ Large transactions can be broken into smaller bursts of 1
8-bit. to 127 bytes.
■ Spoke 0 is connected to SRAM. The CPU can access ■ Each channel can be configured to generate an interrupt
the SRAM without going through the PHUB. The DMAC at the end of transfer
accesses the SRAM through PHUB. ■ Supports byte swapping, for conversion between big-
The spoke address width, data width, and peripherals are endian and little-endian formats
fixed in a device and cannot be changed. The spoke and the ■ Handles data-width differences
peripheral details affect the time required for data transfer.
interspoke and intraspoke transfers take different amounts 8.2.1 Local Memory
of time.
As shown in Figure 8-1 on page 92, the PHUB includes
The effects of spoke data width, and interspoke and intra- local memory to store configuration data. The local memo-
spoke transfer, on latency of data transfer are explained in ries are called
8.1.4 Arbiter.
■ Configuration memory (CFGMEM)
■ Transaction descriptor memory (TDMEM)
8.1.4 Arbiter
The PHUB also includes a 16-byte FIFO for data handling
The PHUB receives data read or write requests from either
during data transfers.
the CPU or the DMAC. The PHUB processes each request
to determine which spoke and peripheral should be The CGFMEM is used to store the DMA channel configura-
accessed, and then manages the data access. tion data. There are two registers: CFGMEMn.CFG0 and
CFGMEMn.CFG1 (where n can be from 0 to 23) for each
When the DMAC and CPU initiate transactions in the PHUB
channel. Each register is 32 bits, so the size of CFGMEM is
at the same time, the arbiter decides which request has pri-
8 bytes × 24 channels = 192 bytes.
ority. The priority can be configured for every spoke except
spoke 0. Spoke 0 is accessed only by the DMAC because The TDMEM is used to store the TD configuration data,
the CPU has a separate interface to SRAM. You can config- which includes the number of bytes to transfer, source
ure priority using the “spk_cpu_pri” bits in the PHUB_CFG address, destination address, next TD, and other configura-
register. tion data. Each TD has two registers: TDMEMn.ORIG_TD0
and TDMEMn.ORIG_TD1. Each register is 32 bits, so the
When the CPU and DMAC access different spokes simulta-
size of TDMEM is 8 bytes × 128 TDs = 1 KB of memory.
neously, both accesses are independent and arbitration is
not necessary. This enables a multiprocessing environment. The local memory is accessed through the local spoke of
The exception is the SRAM, which has direct access by the the PHUB (see Table 8-1 on page 92).
CPU and PHUB. In this case, there is no arbitration required
for SRAM. This helps to reduce the SRAM latency access. 8.2.2 How the DMAC Works
The arbitration issues when the CPU and DMA want to The DMAC is one of the bus masters for PHUB. The DMAC
access the same spoke simultaneously are detailed in fur- can perform the following data transfers:
ther sections.
■ Memory to memory
■ Memory to peripheral The source engine selects the spoke to which the source
■ Peripheral to memory peripheral is connected. Once the spoke is available for
data transfer, the data transfer from the source begins.
■ Peripheral to peripheral
■ Destination engine phase
Any DMA channel goes through the following phases to per- This phase selects the spoke on which the destination
form data transfers: peripheral is available. Once the spoke is available, the
■ Arbitration phase data collected in the source engine phase is transferred
to the destination peripheral.
■ Fetch phase
■ Write back phase
■ Source engine phase
This phase is the completion phase were the TD and
■ Destination engine phase DMA channel configurations are updated after data
■ Write back phase transfer.
The total time required for a DMA transfer depends on the Ideal conditions for data transfer are:
time taken for each phase. The DMA transfer can be either ■ Single requestor
an intraspoke DMA transfer or interspoke DMA transfer
■ CPU doesn't interrupt the fetch phase
In an intraspoke transfer, the data transfer happens within ■ Both source and destination spoke are readily available
the same spoke. This transfer makes use of the internal
■ Source spoke and destination spoke are of same width
FIFO.
■ Source and destination address start at even addressing
■ Arbitration phase
■ Transfer count is a multiple of burst count
The DMAC selects which DMA channel to process
based on the priority. ■ Burst count matches the spoke width
■ Fetch phase The number of bursts for transfer (N) =
The DMAC fetches the TD and DMA channel details Transfer count Spoke width
from the configuration registers.
■ Source engine phase 8.2.2.1 Interspoke Transfers
The timing diagram for an interspoke transfer under ideal
conditions is shown in Figure 8-2.
Bus Clock
Arbitration Phase
Fetch Phase
Command Data Control Data Control Burst = 1 Burst = 2 Burst = N
Source Engine
Phase
Write Back
Phase
The total number of cycles for data transfer in the case of interspoke DMA transfers is the sum of cycles required for each
phase.
Total cycle time = Arbitration phase time (1) + Fetch phase (1) + Source Engine phase (N + 3) + Destination engine phase (0,
because it happens in parallel with the source engine phase) + Write back phase (1)
Example
Notes
■ The ADC (decimator) is connected to spoke 3 which is a 16-bit spoke.
■ Memory is in Spoke 0, which is a 32-bit spoke)
For more information about the DMA configuration, refer to the PHUB registers in PSoC 3 Registers TRM and PSoC 5 Regis-
ters TRM.
Bus Clock
Arbitration Phase
Fetch Phase
Command Burst = 1 Burst = 2 Burst = N
Source Engine
Phase
Write Back
Phase
The total number of cycles for data transfer in the case of intraspoke DMA transfer is the sum of the cycles required for each
phase.
Total cycle time = Arbitration phase time (1) + Fetch phase (1) + Source engine phase (N + 1) + Destination engine
phase (N + 1) + Write back phase (1)
In intraspoke DMA transfers, because the source and destination reside in the same spoke, the 16-byte internal FIFO of the
PHUB is used as an intermediate buffer. Once the FIFO is full, the PHUB waits for the FIFO to be emptied and the destination
engine to read the data, and then fills the next set of data. This is the reason why the destination engine phase cannot happen
in parallel with the source engine phase.
Example
You want to move four 32-bit data words from one SRAM location to another SRAM location.
Notes
■ SRAM lies in spoke 0, which is a 32-bit spoke.
Figure 8-4 shows processing of two DMA channels that were requested at the same time. The figure shows only the inter-
spoke transfer. The same is applicable also for intraspoke transfer.
Write back
Phase for Channel 1
Command Data Control Data Control Burst = 1 Burst = 2 Burst = N
Source Engine
Phase for Channel 2
Burst = 1 Burst = 2 Burst = N
Destination Engine
Phase for Channel 2
8.2.2.4 DMA Channel Priority DMA Channel of priority 0 and priority 1 occupy the bus
100%. Rest of the priorities share the bus based on the
Each channel can take a priority from 0 to 7 with 0 being the
number of channels requested at that time. Since priority
highest priority.
0 has higher priority than 1, priority 0 can interrupt prior-
The DMAC supports two different methods to handle the pri- ity 1.
ority: simple priority, and grant allocation fairness algorithm.
In both the cases, a DMA channel of low priority can be
The priority handling method can be changed by writing to interrupted by a high priority channel only during the source
register PHUB.CFG bit “simple_pri” (bit 23). engine phase
■ Simple Priority: This method handles the channels like The Arbitration phase time depends on the number of chan-
any normal priority algorithm where high priority channel nels requesting the DMAC (non-ideal conditions).
can interrupt low priority channel
When there is only 1 channel requesting an idle DMAC, the
■ Grant allocation Fairness algorithm: In this method, the
arbitration phase takes 1 cycle.
channel 0 and 1 take highest priority and no other prior-
ity can interrupt the channels with priority 0 and 1. A
When there is more than 1 channel requesting a free DMAC, the arbitration phase takes 2 cycles.
Scenario 1
Bus Clock
Scenario 2
DMAC is free. Channel B with Priority 1 is executing. Channel A with Priority 0 comes
Scenario 3
DMAC is free. Channel B with Priority 2 is executing. Channel A with Priority 0/1 comes
Bus Clock
Scenario 4
DMAC is free. Channel B with Priority 3 is executing. Channel A with Priority 2 comes
Bus Clock
The below table shows the minimum guarantee for a DMA Since there are as many 24 DMA Channels but only 8 prior-
channel priority to get bus access ity levels, there can be multiple channels taking the same
priority levels.
Table 8-2. Priority Levels and Bus Allocation
DMAC uses the Round Robin method to handle DMA Chan-
Priority Level Bus Allocation Percentage
0 100
nels with same priority. In case of Round Robin algorithm,
1 100 the DMA channel which was not executed recently takes a
2 50 higher priority. The execution of same priority DMA channels
3 25 when round robin algorithm is enabled depends on
4 12.5 ■ The last time when the channel was enabled
5 6.3
■ If the last time is the same for 2 channels, then DMA
6 3.1
7 1.5 Channel with lower number takes higher priority
Ch 1 Ch 2 Ch 3 Ch 4
Last executed
time (t)
Ch 4 Ch 5 Ch 3 Ch 2 Ch 1
Order of
execution
8.2.2.5 DMA Latency in case of Nonideal spoke. When CPU interrupts the fetch phase, the latency
Conditions depends on when the CPU releases the configuration regis-
ters. Typically CPU takes 2 cycles for the access of configu-
The previous section explained the latency in case of ideal ration registers.
condition. But in real time, the ideal condition rarely exists.
This section explains the latency calculation in case of non- Also, there might be some high priority DMA channel in the
ideal conditions. The latency calculation in case of nonideal Fetch phase. These scenarios will also add to the DMA
conditions cannot be explained using formula as against the Channel execution latency.
ideal condition. Source and Destination Spokes in Use
Multiple Requestors The source and destination for a particular DMA Channel
In real time system the PHUB will be requested by multiple should be free for the channel to use it. In real time, a
channels and by CPU also. source or destination spoke may be already used by CPU or
another DMA channel
If there are multiple DMA channels sending request at the
same time, the arbitration phase will take 2 cycles instead of When source and destination spoke is already in use, the
the ideal 1 cycle PHUB does the arbitration. The following flow chart shows
the arbitration mechanism.
CPU Interrupts with Fetch Phase
The fetch phase ideally takes only 1 cycle for the PHUB to
access the configuration registers through the PHUB local
Yes
Channel B using spoke
Yes Yes
No
Latency depends on CPU
processing time No
Current burst for Current burst for
CPU is completed Channel B is
Has the CPU completed
released the spoke? Latency depends on burst
Is the burst
length of the other DMA
completed for
channel
Channel B
CPU process is Yes
interrupted Channel B is
interrupted
Yes
DMA channel accesses
the spoke
The Channel A accesses
DMA channel the spoke
accesses the Channel A
spoke accesses the
spoke
DMA Channel
completes transfer
Channel A
completes transfer
Spoke released
for the DMA
This latency is not measurable and depends on the real time The spoke widths play a very important role in latency.
situation where same spoke can be accessed by multiple There are chances that the source spoke might be smaller
resources. than the destination spoke and vice versa. In this case the
burst count also plays an important role. Let's see some
Source and destination peripherals are not Ready
examples for this condition
When the source or the destination peripheral is not ready to
Scenario 1 (Inter spoke: 16 bit spoke to 32 bit spoke; Burst
send or receive data, then the DMA channel has to wait till it
of 2)
is ready. In case of source peripheral not ready, the DMA
channel will wait for the source peripheral to become ready ■ Source: 16 bit spoke (ADC)
■ Destination: 32 bit spoke (DFB)
In case of destination peripheral not ready, the DMA channel
will use the 16 byte FIFO of the PHUB. It reads the data ■ Burst count: 2 (for 16 bit ADC data)
from the source and fills it in the FIFO till the destination
peripheral is ready. Thus the internal 16 byte FIFO is used
during intra-spoke transfer and also during the conditions
where the source and destination peripherals are no ready.
Bus clock
Peripheral A (16
16 bit spoke 32 bit spoke Peripheral B
bit data)
2 Bytes 2 Bytes 2 Bytes
Burst Count = 2
Bus clock
Peripheral A (32
16 bit spoke 32 bit spoke Peripheral B
bit data)
2 Bytes
SourceAddr++
Burst Count = 4
2 Bytes
Bus clock
Destination address
incremented by destination
spoke width to write the next 2
bytes of data
Bus clock
Burst Count = 2
Bus clock
Peripheral A (8 bit
data)
16 bit spoke
Peripheral B (8 bit
data)
Bus clock
Burst Count = 1
PHUB FIFO to Destination
Peripheral A (16
bit data)
16 bit spoke
Peripheral B (16
bit data)
Bus clock
Burst Count = 2
PHUB FIFO to Destination
The address of the source and destination play a very important role in deciding the latency. The AHB protocol supports read-
ing from even addresses.
Bus Clock
Byte 1
Data Read cycles
for Burst = 4
Byte 2 and 3
Byte 0 of
Addr + 1
As seen from the above figure, when the even addressing is not met, the bus cycle increases. In ideal condition where the
address begins at Byte 0, a single cycle is sufficient to read all the 4 bytes.
Bus Clock
Byte 1
Data Read cycles
for Burst = 2
Byte 0 of
Addr + 1
The data to be transferred can be split into multiple burst - 8.3.2 Auto Repeat DMA
each of same size. This feature is useful under the following
situations: A static pattern is repetitively read from system memory and
written to a peripheral. This is done with a single TD that
■ When the user doesn't want to hog the bus with a single
chain to itself.
channel which has huge data to transfer
■ When the user needs to control the transfer times Figure 8-23. Auto Repeat DMA
TD D
DMA Channel A TD A
Example: If a peripheral was configured as an SPI or I2C (or a series of data phase TDs) can begin (potentially using
slave where an address is received by the external master, scatter gather). After the data phase TDs finish, a status
that address becomes an index or offset into the internal phase TD could be invoked that reads some memory
system bus memory space. This is accomplished with an ini- mapped status information from the peripheral and copies it
tial “address fetch” TD that reads the target address location to a location in system memory specified by the CPU for
from the peripheral and writes that value into a subsequent later inspection. Multiple sets of configuration/data/status
TD in the chain. This causes the TD chain to be modified phase sub-chains can be strung together to create larger
during the process. When the “address fetch” TD completes, chains that transmit multiple packets in this way. A similar
it can move onto the next TD, which has the new address concept exists in the opposite direction for the reception of
information embedded in it. This TD carries out the data the packets.
transfer with the address location requested by the external
master. 8.3.8 Nested DMA
Figure 8-26. Indexed DMA One TD can modify another TD, as the TD configuration
space is memory mapped, just as any other peripheral.
Index
Example: A first TD loads a second TDs configuration and
DMA Channel A TD A TD B then calls the second TD. The second TD moves data as
required by the application. When complete, the second TD
TD C calls the first TD, which again updates the second TDs con-
figuration. This process repeats as often as necessary.
TD D
TD E
PHUB_CH[0..23]_BASIC_CFG Channel Basic Configuration register Sets basic channel configurations in gates inside PHUB
PHUB_CH[0..23]_BASIC_STATUS Channel Basic Status register Provides status information in gates inside PHUB
PHUB_CFGMEM[0..23]_CFG0 PHUB Channel Configuration register 0 Each channel has some configuration information stored in RAM. This
configuration information is called CHn_CFG0/1.
PHUB_CFGMEM[0..23]_CFG1 PHUB Channel Configuration register 1 CHn_CFG0/1 are stored in CFGMEM at {CH_NUM[5:0], 000}.
PHUB_TDMEM[0..127]_ORIG_TD0 PHUB Original Transaction Descriptor 0 Each channel has a TD chain (as short as one TD in length) that pro-
vides instructions to the DMAC for carrying out a DMA sequence for the
channel. The TD chain is comprised of one or more CHn_ORIG_TD0/1
TDs.
PHUB_TDMEM[0..127]_ORIG_TD1 PHUB Original Transaction Descriptor 1
DMAC accesses the CHn_ORIG_TD0/1 chain from TDMEM and the
address in TDMEM of the current TD in the chain is {TD_PTR[7:0], 000}.
The Interrupt Controller provides the mechanism for hardware resources to change the program address to a new location
independent of the current execution in the main code. The interrupt controller also handles continuation of the interrupted
code being executed after the completion of the interrupt service routine.
9.1 Features
The following are features of the interrupt controller:
■ Supports 32 interrupt lines
■ Programmable interrupt vector
■ Configurable priority levels from 0 to 7
■ Support for dynamic change of priority levels
■ Support for individual enable/ disable of each interrupt
■ Nesting of interrupts
■ Multiple sources for each interrupt line (can be either fixed function, UDB, or from DMA)
■ Supports both level trigger and pulse trigger
■ Tail chaining, late arrivals and exceptions are supported in PSoC® 5 devices
Interrupt
Signals
0
16-bit Interrupt Vector
1
Address (IAV)
2
The interrupt signal routing is very flexible with PSoC 3 and PSoC 5 architectures. The interrupt lines pass through a multi-
plexer. The mux selects one among the following: Fixed function IRQ (Interrupt request), UDB IRQ with level, UDB IRQ with
Edge, and DMA IRQ. The IDMUX.IRQ_CTL register is used to configure the mux for the IRQ selection.
1
Interrupt
Controller
UDB IRQs
2
UDB Array
Edge
3
Detect
UDB DRQs
DMA termout (IRQs)
0
Fixed Function DRQs
DMA
1
Controller
Edge
2
Detect
The interrupt controller unit prioritizes and sends the request Table 9-1. Bit Status During Read and Write
to the CPU for execution. The list of interrupt sources and Bit
Register Operation Comment
the corresponding interrupt number is available in the device Value
datasheet. 1 To enable the interrupt
Write
0 No effect
SETEN
9.3.1 Enabling Interrupts 1 Interrupt is enabled
Read
0 Interrupt is disabled
The interrupt controller provides features to enable and dis-
able individual interrupt lines. The Enable register (SETEN) 1 To disable the interrupt
Write
and the Clear Enable register (CLREN), respectively, enable 0 No effect
CLREN
and disable the interrupt lines. Each bit in the register corre- 1 Interrupt is enabled
Read
sponds to an interrupt line; these registers enable and dis- 0 Interrupt is disabled
able interrupts and read the enable status of interrupts. The
register that is updated latest (SETEN or CLREN register)
determines the interrupt enable status. Table 9-1 shows the
status of bits during read and write.
Assertion on the
interrupt Line
Send to Priority
Wait until all Decoding Unit
high priority
interrupts
No
finish
Yes
CPU accepts
request
Interrupt execution
The active interrupt is the one being executed currently. The 1. When a high priority interrupt assertion occurs during the
execution of the low priority interrupt, the low priority
interrupt priority and interrupt number of the active interrupt
interrupt execution is stopped at that point.
are stored in eight level hardware stacks. The hardware
stack is available with the Interrupt controller. There are two 2. The CPU accepts the request, stops the execution of the
low priority interrupt, and pushes the PC.
different stacks used to store the active interrupt details –
one stores the interrupt priority, and the other stores the 3. The CPU sends the acknowledgment (for the high prior-
interrupt number. Following are the details of the stacks: ity interrupt entry) to the interrupt controller.
4. The interrupt controller pushes the interrupt number and
■ STK – Stores the priority of the interrupt
interrupt priority of the low priority interrupt to its stack. It
■ STK_INT_NUM – Stores the interrupt number pushes the higher priority interrupt context to the top of
the stack.
The top of the above stacks have the details of the current
active interrupt and interrupt priority. The registers 5. The interrupt service routine can push the other regis-
ACT_INT_NUM and ACT_VECT store the details of the lat- ters, such as the PSW, GPR, SFR, ACC, and B, to the
CPU stack. The high priority interrupt execution begins.
est interrupt number execution requested to the CPU and its
corresponding vector address. The value in these registers 6. When the higher priority interrupt has been executed,
is valid only between the “Interrupt request to the CPU the CPU sends the IRC. The details of the high priority
interrupt are popped from the interrupt controller stack
(IRQ)” and “Interrupt Entry (IRA).” Any read outside this time
leaving the low priority interrupt at the top of the stack.
frame may result in invalid values.
The details of the low priority interrupt are popped from
the CPU stack. The low priority interrupt continues its
9.4.2 Interrupt Nesting execution from the point of suspension.
PSoC 3 devices support nesting of up to eight interrupts. 7. Because the push and pop of the stack are handled by
Nesting of an interrupt occurs when a high priority interrupt the hardware, there is minimum latency, because no
instruction is involved in the operation.
is asserted during a low priority interrupt execution. In
PSoC 3, the nesting of interrupts uses both the interrupt Figure 9-4 on page 113 shows the states of the stack during
controller stack and the CPU stack. the nesting operation.
■ Interrupt Controller Stack – The interrupt controller
stack is available with the interrupt controller and is used
to store the interrupt number and interrupt priority. There
are two stacks with a depth of eight levels. Following are
the stack details:
❐ STK – Stores the interrupt priority information.
Assertion of INT B
Execution of Continuation
INT A Execution of INT B
of INT A
Register State Register State Register State After Register State After Register State After
Before During Stacking of INT A Execution of INT B All executions
All Executions Execution of INT A
STK_INT STACK_INT_NUM STK_INT STACK_INT_NUM STK_INT STACK_INT_NUM STK_INT STACK_INT_NUM STK_INT STACK_INT_NUM
In Figure 9-4, INT A is suspended, and the high priority 2. During the interrupt assertion, the address of the service
interrupt INT B is executed. During nesting, INT A is pushed routine is retrieved from these registers and given to the
to registers. After INT B is executed, the registers are CPU for execution of the interrupt.
popped. When an interrupt begins to execute the interrupt,
information is pushed to stack; when it finishes, the stack is 9.4.4 Sleep Mode Behavior
popped.
The Interrupt Controller works in all of the power modes
(Active, Stand by, Sleep and Hibernate) unless the user
9.4.3 Interrupt Vector Addresses switches the clocks off manually. All of the registers (status
PSoC 3 devices have a feature that allows a user to specify and configuration) except the pending register and interrupt
the interrupt service routine starting address for every inter- controller stack, retain their values during Sleep mode. The
rupt line. The address of the interrupt service routine is pro- Pending and Interrupt Controller Stack registers are set with
grammable. The call of the interrupt service routine the power on value at wakeup. Because the pending regis-
corresponding to an interrupt line is not a branch instruction. ters are nonretention registers, the requests that are pended
The address of the interrupt service routine is stored in the will be missed when the device goes to sleep.
vector address register, resulting in the direct call of the rou- Do not change the power mode change inside the Interrupt
tine, preventing latency. Service routine. If a change in mode is requested, the
1. The interrupt service routine address is programmable device will finish the ISR, exit the ISR, and then switch the
and is stored in Vector Address registers called power mode.
VECT[0…31].
The clock for the Interrupt Controller can be enabled and
There are 32 vector address registers corresponding to
disabled by setting the register bit “CLOCK_EN” in the
the 32 interrupt lines.
INTC_CLOCK_EN register. When the clock is switched off
Each Vector Address register is 16 bits.
for the Interrupt Controller, the CPU should not access the 9.5.2 Interrupt Nesting
ISR (as the IRA and IRC cannot be processed by the Inter-
rupt Controller). Nesting of an interrupt occurs when a high priority interrupt
is asserted during a low priority interrupt execution. With
PSoC 5 architecture, only the CPU stack is available to
9.5 PSoC 5 Features store all nesting interrupt details.
■ Current interrupt number, current interrupt priority
Because PSoC 5 architecture is based on the Cortex-M3
core, it has additional features supported by the Cortex-M3 ■ Program counter, PSR, R0 to R3, R12 and LR
core. In PSoC 5 devices, the interrupt controller is a part of ■ Depending on the application, other registers from R4 to
the Cortex-M3 core. For more detailed information about the R11
PSoC 5 Interrupt Controller, refer to the ARM Cortex-M3
Technical Reference Manual available at http:// The CPU stack grows down while the CPU handles push
www.arm.com. and pop.
Assertion of INT A
Assertion of INT B
Assertion of INT C
Other register
details of
INT A
Other register
details of
INT A
In Figure 9-5, INT A is suspended, and the high priority interrupt INT B is executed. During nesting, the INT A is pushed to the
stack. During execution of INT B, INT C occurs. So INT B is pushed, and INT C is executed. After INT C is executed, INT B is
popped and executed. After INT B is executed, the stack is popped. When an interrupt begins to execute, interrupt informa-
tion is stored in the stack; when it completes, the stack is popped. The use of both PSP and MSP is shown. It is assumed that
PSP is active during the first interrupt and that the first active interrupt uses the PSP.
9.5.6 Exceptions
PSoC 5 architecture supports 15 different exceptions, as shown in Table 9-3.
These exceptions are used to handle fault conditions that can occur in the system. Exceptions can have fixed priority or con-
figurable priority. Exceptions are handled in the same manner as interrupts. The State register is used to enable or disable
exceptions.
The PSoC® nonvolatile subsystem consists of Flash, byte-writable EEPROM, and nonvolatile configuration options. The CPU
can reprogram individual blocks of Flash, enabling boot loaders. An Error Correcting Code (ECC) can enable high reliability
applications.
A powerful and flexible protection model allows the user to selectively lock blocks of memory for read and write protection,
securing sensitive information. The byte-writable EEPROM is available on-chip for the storage of application data. Addition-
ally, selected configuration options, such as boot speed and pin drive mode, are stored in nonvolatile memory, allowing set-
tings to become active immediately after power on reset (POR).
System Bus
MEMORY SYSTEM
EEPROM SRAM
CPU
SYSTEM
EMIF FLASH
A Nonvolatile Latch (NVL or NV latch) is an array of programmable, nonvolatile memory elements whose outputs are stable at
low voltage. It is used to configure the device at Power on Reset. Each bit in the array consists of a volatile latch paired with a
nonvolatile cell. On POR release nonvolatile cell outputs are loaded to volatile latches and the volatile latch drives the output
of the NVL.
10.1 Features
NV latches include:
■ A 4x8-bit NV latch for device configuration
■ A 4x8-bit Write Once NV latch for device security
10.2.1 PRTxRDM[1:0]
Port Reset Drive mode NVL bits enable selection of one of four drive modes to be in effect between the release of POR and
the configuration of the device by user firmware. These four drive modes are a subset of the drive modes available by writing
to the port drive mode registers. Refer to the I/O System chapter on page 187 for more details. The following is a summary of
the four NVL drive mode settings:
■ 00b – High impedance analog
■ 01b – High impedance digital
■ 10b – Resistive pull up
■ 11b – Resistive pull down
10.2.2 XRESMEN ■ …
■ 0X0A – 11.5 ns delay
GPIO pin (P1[2]) may be configured as an external reset
(XRES_N) pin. The configuration of that pin is controlled ■ 0x0B – 12.5 ns delay
with this NVL bit: ■ 0x0C – Clock disabled
■ 0 – GPIO ■ 0X0D – Clock disabled
■ 1 – XRES_N ■ 0X0E – Clock disabled
■ 0X0F – Clock disabled
10.2.3 CFGSPEED
The Configuration Speed NVL bit determines if the IMO 10.3 Write Once NV Latch
defaults to a fast or slow speed. Refer to the Clocking
System chapter on page 147 for more details. This configu- The Write Once (WO) latch is a type of nonvolatile latch.
ration is intended to balance the need for rapid boot and The cell itself is an NVL with additional logic wrapped
configuration against peak power consumption. around it. Each WO latch device contains 4 bytes (32 bits) of
■ 0 – Slow (12 MHz IMO frequency) data. The wrapper outputs a 1 if a super-majority (28 of 32)
of its bits match a pre-determined pattern (0x50536F43) and
■ 1 – Fast (48 MHz IMO frequency)
it outputs a 0 if this majority is not reached. When the output
is 1, the Write Once NV latch locks the part out of Debug
10.2.4 DPS[1:0] and Test modes; it also permanently gates off the ability to
Debug Port Select NVL bits allow the user to select a erase or alter the contents of the latch. Matching of all bits is
debugging port interface that is active after POR is released. intentionally not required, so that single (or few) bit failures
If the debug port’s disabled setting is used, the acquire func- do not deassert the WO latch output. The state of the NV
tions of the test controller must be used to activate the latch bits after wafer processing is truly random with no ten-
debug port. Refer to the Test Controller chapter on dency toward 1 or 0.
page 443 for more details. These NVL bits do not enable the The WOL only locks the part once the correct 32-bit key
debugger logic; they enable only the physical interface. The (0x50536F43) is loaded into the NVL's volatile memory, pro-
only way to enable the debug logic is for the user's firmware grammed into the NVL's nonvolatile cells, and the part is
or configuration to write the debugger enable bit. reset. The output of the WOL is only sampled on reset and
■ 00b – 5-wire JTAG used to disable the access.
■ 01b – 4-wire JTAG This precaution prevents anyone from reading, erasing, or
■ 10b – SWD (single wire debug) altering the content of the internal memory.
■ 11b – Debug ports disabled
If the device is protected with a WO
latch setting, Cypress cannot perform
10.2.5 ECCEN
failure analysis and, therefore, cannot
For devices that support an Error Correcting Code (ECC) in accept RMAs from customers. The WO
the Flash, this NVL bit is used to set whether ECC is latch can be read via the SWD to electri-
enabled. Refer to the Flash Program Memory chapter on cally identify protected parts.
page 129 for more details.
■ 0 – ECC disabled The user can write the key in WOL to lock out external
■ 1 – ECC enabled access only if no Flash protection is set. However, after set-
ting the values in the WOL, a user still has access to the part
until it is reset. Therefore a user could write the key into the
10.2.6 DIG_PHS_DLY[3:0] WOL, program the Flash protection data, and then reset the
This bit selects the digital clock phase delay in 1 ns incre- part to lock it. Refer to the Flash, Configuration
ments. Refer to the Clocking System chapter on page 147 Protection chapter on page 205 for details on Flash protec-
for more details, tion.
■ 0x00 – Clock disabled
■ 0x01 – 2.5 ns delay
■ 0x02 – 3.5 ns delay
PSoC® 3 and PSoC® 5 devices include on-chip SRAM. These families offer devices that range from 2 to 64 kilobytes. PSoC 3
devices offer an additional 4 kilobytes as a trace buffer.
11.1 Features
PSoC 3 and PSoC 5 SRAM has these features:
■ Organized as up to three blocks of 4 KB each, including the 4 KB trace buffer, for CY8C38 family.
■ Organized as up to 16 blocks of 4 KB each, for CY8C55 family.
■ Code can be executed out of portions of SRAM, for CY8C55 family.
■ 8-, 16-, or 32-bit accesses. In PSoC 3 devices the CPU has 8-bit direct access to SRAM.
■ Zero wait state accesses.
■ Arbitration of SRAM accesses by the CPU and the DMA controller.
■ Different blocks can be accessed simultaneously by the CPU and the DMA controller.
SRAM
32 32
PHUB (Includes 4 KB
Trace Buffer)
Peripheral Peripheral
Figure 11-2 shows internal SRAM organization for the CY8C38 family.
SRAM
8051
CPUIF
CPU
PHUB PHUBIF
SRAM
BANK0
(1 KB x 32)
SRAM
BANK1
(1 KB x 32)
SRAM
BANK2
(1KB x 32)
TC DOC_TRACEBUF_ACTIVE
Cortex-M3
CPU
32
32
PHUB SRAM
Peripheral Peripheral
Figure 11-4 shows internal SRAM organization for the CY8C55 family.
SRAM
Cortex-M3
CPUIF
CPU
PHUB PHUBIF
SRAM BANK0
(32 KB)
Lower SRAM
SRAM BANK1
(32 KB)
Upper SRAM
All data paths to SRAM are 32 bits wide except the data
path from the 8051 CPU, which is 8 bits wide.
PSoC® 3 and PSoC® 5 include on-chip Flash memory. These two families offer devices that range from 16 to 256 kilobytes.
Additional Flash is available for either error correction bytes or data storage.
12.1 Features
PSoC 3 and PSoC 5 Flash memory have the following features:
■ Organized in rows, where each row contains 256 data bytes plus 32 bytes for either error correcting codes (ECC) or data
storage.
■ For PSoC 3 architecture: CY8C38 Family, organized as one block of 64, 128, or 256 rows.
■ For PSoC 5 architecture: CY8C55 Family, organized as either one block of 128 or 256 rows, or as multiple blocks of 256
rows each.
■ Stores CPU program and bulk or nonvolatile data
■ For PSoC 5 architecture: CY8C55 Family, 8-, 16-, or 32-bit read accesses. PSoC 3 architecture has only 8-bit direct
access.
■ Programmable with a simple command / status register interface (see Nonvolatile Memory Programming chapter on
page 473).
■ Four levels of protection (see Nonvolatile Memory Programming chapter on page 473 and Flash, Configuration
Protection chapter on page 205).
Programming
PHUB
Interface
EEPROM NVL
The main region of Flash in the CY8C38 family is 72 KB, When the software has been notified about an existing inter-
consisting of 64 KB of user space and 8 KB of ECC. The rupt in the ECC, the following sequence occurs:
extended region is four rows of 256 bytes each. 1. The software reads the Interrupt Status register
CACHE_INT_SR that provides the valid bits of all inter-
For each row, protection bits control whether the Flash can
rupts in a single read operation.
be read or written by external debug devices and whether it
can be reprogrammed by a boot loader. For more informa- 2. The software examines individual interrupt registers for
more log information (CACHE_INT_LOG[0..5]).
tion see the Nonvolatile Memory Programming chapter on
page 473 and Flash, Configuration Protection chapter on 3. Stored log information is cleared on read of registers.
page 205. 4. After clearing of log information, the status register
(CACHE_INT_SR) is automatically cleared, because it is
Flash can be read by both the CPU and the DMA controller. a collection of valid bits of the log registers.
Flash is erased in 64-row sectors or in its entirety, and it is Logging is always enabled; reporting may be disabled
programmed in rows. Erase and programming operations through the Interrupt Mask Register (CACHE_INT_MSK).
are done by a programming system, using a simple com-
mand/status register interface. For more information see the The following conditions are detected by the hardware and
Nonvolatile Memory Programming chapter on page 473. logged as potential interrupt sources:
■ ECC – Single Bit – A single bit error was encountered
during a fill operation and was fixed.
■ ECC – Multi Bit – A multi-bit error was encountered dur-
ing a fill operation, but it could not be corrected.
■ Attempted Flash Write – If a write to Flash through the
PHUB is attempted.
PSoC® 3 and PSoC® 5 devices have on-chip EEPROM memory. These two families offer devices that range from 512 bytes
to 2 kilobytes.
13.1 Features
PSoC 3 and PSoC 5 EEPROM memory have the following features:
■ Organized in rows, where each row contains 16 bytes
■ Organized as one block of 32, 64, or 128 rows, depending on the device
■ Stores nonvolatile data
■ Write and erase using SPC commands
■ Byte read access by CPU or DMA using the PHUB
■ Programmable with a simple command/status register interface (see Nonvolatile Memory Programming chapter on
page 473)
If a PHUB access is attempted while the SPC is in control of EEPROM, a System Fault Interrupt is generated to the interrupt
controller and the bit EEPROM_error is set in SPC_EE_ERR[0]. Once set, this bit remains set until it is read from the PHUB.
EEPROM can be taken in and out of sleep mode by setting the bit EE_SLEEP_REQ in SPC_FM_EE_CR[4], as shown in
Table 13-1. Before a PHUB access of EEPROM is done, set the firmware EEPROM request bit AHB_EE_REQ in
SPC_EE_SCR[0], then poll for the EEPROM acknowledge bit EE_AHB_ACK in SPC_EE_SCR[1] to be set. Before a PHUB
access of EEPROM is done, firmware should set the EEPROM request bit AHB_EE_REQ in SPC_EE_SCR[0], then poll for
the EEPROM acknowledge bit EE_AHB_ACK in SPC_EE_SCR[1] to be set.
It is also possible to check the current sleep status of the EEPROM by reading the bit EE_AWAKE in SPC_FM_EE_CR[5], as
EEPROM is erased in 64-row sectors, or in its entirety, and is programmed in rows. Erase, programming and read operations
are done by a programming system using a simple command/status register interface. For more information see Nonvolatile
Memory Programming chapter on page 473.
PSoC® 3 and PSoC® 5 architectures provide an external memory interface (EMIF) for connecting to external memory devices
and peripheral devices. The connection allows read and write access to the devices. The EMIF operates in conjunction with
UDBs, I/O ports, and other PSoC 3 and PSoC 5 components to generate the necessary address, data, and control signals.
The EMIF does not intercept address data between the PHUB and the I/O ports. It only generates the required control signals
to latch the address and data at the ports. The EMIF generates a clock to run external synchronous and asynchronous mem-
ories. It can generate four different clock frequencies, which are the bus clock divided by 1, 2, 3, or 4.
14.1 Features
The EMIF supports four types of external memory: synchronous SRAM, asynchronous SRAM, cellular RAM/PSRAM, and
NOR Flash. External memory can be accessed via the 8051 xdata space or the ARM Cortex-M3 external RAM space; up to
24 address bits can be used. The memory can be 8 or 16 bits wide.
External Memory
CPU PHUB DQ
24 24 CLK
DMAC
WRn
Port Logic
CEn
AHB Bus ADSCn
Data Ports
OEn
Read / Write Data
ZZ_
16 16
EM_Clock
EM_WRn DSI Control Port
EM_CEn 6 no_udb mode
6
EM_ADSCn
udb mode
EM_OEn
EMIF
EM_Sleep
Xmem_wr
UDB
Xmem_rd
Custom
Udb_Ready 3 UDB Logic
[7:0]
ADDR
LO A0–A7
Port
ADDR [7:0]
[7:0]
Data
LO D0–D7
Port
Synchronous
PSoC 3/ [7:0]
Data
PSoC 5 D8–D15
Hi
Port
CE -
CE1
OE -
OE
Control WE -
GW
Port
ADSC -
ADSC
EM-Clock
CLK
EM-Sleep
ZZ
Vddd
2
Spare
ADSA
ADV
CE2
BWE
CE3
BWA
BWB
Mode
[7:0]
ADDR
LO A0 – A7
Port
ADDR [7:0]
MID A8 – A15
Port
[1:0]
A16, A17
ADDR
[7:2]
Hi Port
Asynchronous
[7:0]
Data
LO D0 – D7
Port
CE - CE
OE - OE
WE -
Control Port WE
ADSC -
Unused
EM-Clock
Unused
EM-Sleep
Unused
2 Spare
14.4 EMIF Timing An important limitation is that the maximum I/O rate of
PSoC 3 and PSoC 5 GPIO pins is 33 MHz. This makes the
The EMIF is clocked by bus clock – the same signal that maximum frequency of EM_CLOCK 33 MHz. The following
clocks the CPU and the PHUB. Within the EMIF block, the table shows limitations of EM_CLOCK frequency relative to
bus clock can be divided by 1, 2, 3, or 4; the output is the the bus clock:
EM_CLOCK signal to the external memory IC.
Table 14-4. Limitations of EM_CLOCK Relative to Bus
The following table shows the number of PHUB wait states Clock
generated by the EMIF depending on how much the input
Bus Clock Frequency EM_CLOCK = Bus Clock Divided By
clock is divided.
< 33 MHz 1, 2, 3, or 4
Table 14-3. PHUB Wait States Generated by EMIF 33 - 66 MHz 2, 3, or 4
EM_Clock
EM_CEn
EM_Addr Address
EM_OEn
EM_Data Data
EM_ADSCn
EM_Clock
EM_CEn
EM_Addr Address
EM_OEn
EM_Data Data
EM_ADSCn
EM_Addr Address
EM_CEn
EM_OEn
EM_WEn
EM_Data Data
EM_CEn
EM_Addr Address
EM_OEn
EM_WEn
EM_Data Data
14.5 Using EMIF with Memory- itation here is the PSoC 5 cannot initiate 8 bit transfers to
16-bit memories and should not initiate unaligned 16-bit or
Mapped Peripherals 32-bit transfers to an external memory, as the processor
The EMIF can also be used with external peripheral devices may convert these into multiple 8 bit aligned accesses.
that have a bus interface similar to asynchronous memory However, 32 or 16-bit aligned transfers are handled cor-
devices, that is, they address, data, CE-, WE-, and OE-. The rectly by the processor and PHUB.
speed of the interface must be considered in the same man-
ner as described above. The maximum data bus size is 16 14.6.4 8-bit Memory Transfers
bits, and the minimum address bus size is 8 bits. If multiple DMA Transfers: For DMA transfers to/from an 8 bit external
external memory and peripheral devices are used, address memory, the burst count should always be 1, irrespective of
decoding to the multiple device selects may become com- the transfer count. For example, if the burst count is set as 2
plex and must be given careful consideration. in order to transfer two bytes to external memory, the PHUB
will try to do a 16-bit transfer in a single burst instead of
14.6 Additional Configuration breaking the transfer down into two individual transfers with
the 8-bit memory.
Guidelines
The PHUB assumes all peripherals including external mem-
ory are byte addressable. Port logic is natively 16 bits wide,
so care must be taken when setting up communication with
either an 8 or 16 bit external memory. The following section
describes some guidelines to configure the port pins and set
up the memory access methods (either CPU or DMA) for
optimal performance.
All PSoC® 3 and PSoC® 5 memory (Flash, EEPROM, Nonvolatile Latch, and SRAM) and all registers are accessible by the
CPU, DMA controller, and in most cases by the debug systems. This chapter contains an overall map of the addresses of the
memories and registers.
15.1 Features
The PSoC 3 memory map has the following features:
■ Flash is accessed in the 16-bit (64 KB) 8051 code space.
■ All other memories, and all registers, are accessed in the 24-bit 8051 external memory space.
■ 8051 has internal SFRs to provide fast access to some registers. Refer to the 8051 Core chapter on page 37 for details.
The PSoC 5 address map is shown in Table 15-3. For more information refer to the Cortex-M3 chapter.
The System Wide Resources section details three types of I/O, internal clock generators, power supply, boost converter, and
sleep modes.
WDT
RTC
and ILO
Timer
Wake
IMO
Clocking System
The clock generator provides the main/master time bases for the entire device. It allows the user to trade off current, fre-
quency, and accuracy. A wide range of frequencies can be generated, using multiple sources of clock inputs combined with
the ability to set divide values.
16.1 Features
The clock system has these:
■ Four internal clock sources increase system integration:
❐ 3 to 67 MHz Internal Main Oscillator (IMO) ±1% at 3 MHz
❐ 1 kHz, 33 kHz, 100 kHz Internal Low Speed Oscillator (ILO) outputs
❐ 12 to 67 MHz clock doubler output, sourced from IMO, MHz External Crystal Oscillator (MHzECO), and Digital System
Interconnect (DSI)
❐ 24 to 67 MHz fractional Phase-Locked Loop (PLL) sourced from IMO, MHzECO, and DSI
■ DSI signal from an external I/O pin or other logic as well as a clock source
■ Two external clock sources provide high precision clocks:
❐ 4 to 33 MHz External Crystal Oscillator (MHzECO)
❐ 32.768 kHz External Crystal Oscillator (kHzECO) for Real Time Clock (RTC)
■ Dedicated 16-bit divider for bus clock
■ Eight individually sourced 16-bit clock dividers for the digital system peripherals
■ Four individually sourced 16-bit clock dividers for the analog system peripherals
■ IMO has a USB mode that auto locks to the USB bus clock, requiring no external crystal for USB. (USB equipped parts
only)
External I/O
3 MHz -48 MHz 4 MHz - 33 1/33/100 kHz
or DSI 32 kHz ECO
IMO MHz ECO ILO
0 MHz - 33 MHz
dsi_clkin
12 MHz - clk_imo2x
48 MHz clk_imo
USB Clk Mux +
clk_pll
Doubler clk_dsi_glb Div2
clk_imo2x
clk_32k
clk_ilo
clk_dsi_glb
clk_xtal
7 7
Digital (User) 0 clk_sync_d
s
dsi_d[n] Clock Mux and 1 clk_imo Analog (User)
dsi_a[n] k
16-Bit Divider Clock Mux and 1-
2 clk_xtal e
clk_sync_a[n] Bit Divider w
3 clk_ilo
...
4 clk_pll
...
x8 5 clk_32k
6 clk_dsi_glb
x4
The components of the clocking system block diagram are 16.3 Clock Sources
defined as follows:
■ Internal Main Oscillator (IMO) Clock sources for the device are classified as internal oscil-
lators and external crystal oscillators. There is an option of
■ Internal Low-speed Oscillator (ILO)
using a PLL or a frequency doubler to derive higher fre-
■ A 4 to 33 MHz External Crystal Oscillator (MHzECO) quency outputs from existing clocks. Signals can be routed
■ A 32 kHz External Crystal Oscillator (kHzECO) from the DSI and used as clocks in the clock trees.
■ Digital System Interconnect (DSI) signal, which can be
the clocks developed in UDBs or off-chip clocks routed 16.3.1 Internal Oscillators
through pins PSoC devices have two internal oscillators: the Internal
■ A PLL to boost the clock frequency on select internal Main Oscillator (IMO) and the Internal Low Speed Oscillator
and external sources (ILO).
■ Five types of clock outputs:
❐ Digital clocks
❐ Analog clocks
❐ Special purpose clocks
❐ System clock
❐ USB clock
FASTCLK_IMO_CR [2:0]
FASTCLK_IMO_CR [5]
Osc
(3/6/12/
IMOCLK
24/48
IMO
MHz) clk_imo
dsi_clkin OUT
CLK IMOCLK X 2
IMO Doubler MUX
XCLK MUX
SRC
MUX
clk_eco_Mhz
CLKDIST_CR[6]
clk_ilo1K
1 kHz Osc
ILO
clk_ilo33K
Divide by 3 Out
BIAS Mux
SLOWCLK_ILO_CR0 [2]
SLOWCLK_ILO_CR0 [5]
clk_ilo100K
100 kHz Osc
CLKDIST_CR [3:2]
The ILO clocks are all disabled in the Hibernate mode. The crystal pins are shared with a standard I/O function
SLOWCLK_ILO_CR0 [4] is the power down mode bit gov- (GPIO / LCD / Analog Global), which must be tristated to
erning the wakeup speeds of the device. Setting the bit operate the crystal oscillator with an attached external crys-
slows down the startup, but it provides a low power opera- tal.
tion.
The crystal output routes to the clock distribution network as
a clock source option, and it can also route through the IMO
16.3.2 External Oscillators doubler to produce doubled frequencies, if the crystal fre-
PSoC devices have two external crystal oscillators: the MHz quency is in the valid range for the doubler.
Crystal Oscillator (MHzECO) and the 32.768 kHz Crystal The oscillator allows for a wide range of crystal types and
Oscillator (kHzECO). frequencies. Startup times vary with frequency and crystal
quality. The xcfg bits of the FASTCLK_XMHZ_CFG0 [4:0]
16.3.2.1 MHz Crystal Oscillator register are used to match the oscillator settings to the crys-
The 4-33 MHz external crystal oscillator MHzECO circuit tal. The oscillator can be enabled by
provides for precision clock signals. The block supports a FASTCLK_XMHZ_CSR [0].
variety of fundamental mode parallel resonance crystals.
Figure 16-4 is a block diagram of the MHzECO.
When used in conjunction with the on-chip PLL, a wide
range of precision clock frequencies can be synthesized, up
to 67 MHz.
Figure 16-4. MHzECO Block Diagram
External Xop
Components
clk_eco_Mhz
4-33 MHz
Crystal Osc
FASTCLK_XMHZ_CSR[6]
Xerr and Xprot
FASTCLK_XMHZ_CSR[7]
Xosc Out
clk_eco_Mhz
MHz XOSC
clk_imo
If the FASTCLK_XMHZ_CSR[6] bit is set, the fault recovery Figure 16-6. kHzECO Block Diagram
option is enabled. In this case, when the crystal oscillator
External Xo
fails, the crystal oscillator output is driven low. The IMO is Components
enabled (if it is not already running), and the IMO output
routes through the crystal oscillator output mux. In this way, clk_eco_Khz
32 kHz
the system can continue to operate through a crystal fault. Crystal Osc
This functionality is diagrammed in Figure 16-5. Caps 32 kHz
Crystal Xi
Low Power Operation
The MHz crystal oscillator operation is not required in the Low Power Operation
SLEEP/HIBERNATE modes. This means that you need to
disable the oscillator in order to enter SLEEP/HIBERNATE The oscillator operates at two power levels, depending on
modes. The 32 kHz crystal oscillator can be kept active, for the state of the LPM bit (SLOWCLK_X32_CR [1]) and the
precise timing (RTC), in the SLEEP/HIBERNATE modes. If device sleep mode status. In Active mode, by default, a
the MHz crystal oscillator is not disabled when the device is hardware interlock forces the oscillator into its high power
put into any of these modes, the mode entry is skipped, and mode, which consumes 1-2 µA and minimizes sensitivity to
the code continues to execute in active mode. Because this noise. If the LPM mode is set for a low power mode, the
clock must be disabled to enter SLEEP mode, a typical oscillator goes into Low power only when the device goes to
approach is to switch clock trees to the IMO source and then SLEEP/HIBERNATE. If LP_ALLOW (SLOWCLK_X32_CFG
disable the crystal oscillator (and the PLL also, if it is on). [7]) is set, the oscillator enters low power mode immediately
Then SLEEP/HIBERNATE mode can be entered. After wak- when the LPM bit is set.
ing up from a sleep mode, the crystal oscillator can be reen- When enabled, the oscillator does not stabilize instantly, and
abled and used as a clock source when stable. requires some time to oscillate consistently. Two two status
monitors are available for this. The DIG_STAT
16.3.2.2 32.768 kHz Crystal Oscillator (SLOWCLK_X32_CR[4]) status bit indicates oscillation is
The 4 MHz to 33 MHz external crystal oscillator kHzECO cir- stable by comparing it with a signal (33 kHz ILO) that the
cuit produces a precision timing signal at very low power. user must enable with the ILO. The ANA_STAT
The circuit uses an inexpensive external 32.768 kHz crystal (SLOWCLK_X32_CR[5]) bit uses an internal analog monitor
and associated network capacitors that can be used to pro- to measure oscillator amplitude. The oscillator must always
duce a real time clock. Current consumption can be much be started in high power mode to avoid excessively long
less than 1 µA. startup delays.
The RTC timing is derived from the 32 kHz external crystal oscillator, as shown in Figure 16-7. Therefore, for the functioning
of the RTC, the 32 kHz external crystal must be enabled through the register SLOWCLK_X32_CR [0]. The generated 32 kHz
is divided to achieve a one pulse per second. The register PM_TW_CFG2[4] enables one pulse per second functionality.
By enabling the bit PM_TW_CFG2[5], the RTC generates an interrupt every second. The interrupt is routed through the DSI
and is brought out as an interrupt. Refer to the UDB Array and Digital System Interconnect chapter on page 255 for more
details on usage. RTC functionality is available for use in all power modes except the Hibernate mode.
To Clock
clk_eco_Khz Distribution
External 32 kHz
Oscillator Divide by Generates a
32768 one-pps
Interrupt
32 kHz En
Crystal
PM_TW_CFG2 [4] PM_TW_CFG2 [5]
SLOWCLK_X32_CR [0]
clk_imo Q-Divider
CLK 4 Bits
clk_eco_Mhz UP clk_pll
MUX (1-16) Filter and
PFD
dsi_clkin FASTCLK_PLL_Q DOWN VCO
To Clock
Distribution
P-Divider
Lock Detect
8 Bits
FASTCLK_SR [0]
(4-256)
FASTCLK_PLL_P
PLL
The PLL takes inputs from the IMO, the crystal oscillator
MHzECO, or the DSI, which can be an external clock.
dsi_clkin
clk_imo2x
USB CLK
IMO + clk_usb
MUX
Doubler PLL Mux 48 MHz
4-33 MHz clk_xtal dsi_gp
XTAL 3-62 MHz Prescale Master Clock
Mux
33KHz PLL 8-bit divider
clk_sync
Watch clk_imo
clk_pll
XTAL
clk_spc
ILO 36 MHz
1, 33, 100
KHz
dsi_d0 clk_bus
resync
16-Bit clk_d0
Divide clk_d_ff0
resync
16-Bit
Phase
Divide
mod
dsi_d1
clk_d1
resync
16-Bit s8misc_delay_top
Divide clk_d_ff1 11
clk_sync_d
DigitalPhaseMux
dsi_d2
clk_d2
resync
16-Bit
Divide clk_d_ff2
Ana3 Phase Ana2 Phase Ana1 Phase Ana0 Phase
Mux Mux Mux Mux
dsi_d3
resync
dsi_a0 resync
dsi_d4 clk_d4 16-Bit
resync
16-Bit clk_a0
Divide
Divide clk_d_ff4
Ph- Sel dig-resync clk_ad0
dsi_d5 dsi_a1
resync
clk_d5 16-Bit
resync
16-Bit clk_a1
clk_d_ff5 Divide
Divide
Ph- Sel dig-resync clk_ad1
dsi_d6 dsi_a2
resync
resync
dsi_d7 dsi_a3
resync
resync
All of the clocks available in the device are routed across the ■ Digital clock
device through digital and analog clock dividers. There are ■ Analog clock
certain peripherals that require specific clock source for its
■ USB clock
operation. For example, Watchdog Timer (WDT) requires
Internal Low Speed Oscillator (ILO). In such cases, the cor- The clock distribution provides a set of eight dividers for the
responding clock source is directly routed to the peripheral. digital clock tree and four analog clock dividers for the ana-
log clock tree. All of the clock sources come as input options
The clock distribution can be considered to be a combina-
for all of the clock dividers through eight input mux. Also, the
tion of the following clock trees.
divider outputs are synchronized to their respective domain
■ System clock clocks.
A Master Clock Mux is available for distributing the sync for the network: clk_sync_dig and the analog system clocks,
clocks. There are options to provide delay on the digital sync clk_sync_a. The master clock must be configured to be the
clock. All eight digital dividers are synchronized to the same fastest clock in the system. The master clock also provides
digital clock, but each of the analog clock divider outputs a mechanism for switching the clock source for multiple
can be synchronized to analog clocks of different delays. clock trees instantaneously, while maintaining clock align-
The clock distribution also is responsible for the generation ments. For systems that must maintain known clock rela-
of the major clock domains in the device, such as the Sys- tionships, clock trees select the clk_sync_dig (or
tem clock, bus clock, and others. clk_sync_a*) clock as their input source.
CLKDIST_MSTR1_SRC_SEL [1:0]
Divide-by-1
clk_pll
clk_imo 8-Bit Divider
(1-256) D Q
clk_eco_MHz CLKDIST_MSTR0 clk_sync
dsi_clkin
The USB Clock Mux, shown in Figure 16-11, provides the clock to the USB logic.
CLKDIST_UCFG_SRC_SEL[1:0]
IMOCLK
IMOCLKX2
PLL clk_usb
Divide-by-2
DSI
dsi_glb_div[0]
CLKDIST_UCFG_DIV2
The USB clock mux selects the USB clock from these clock USB Mode Operation
sources.
This device works with an automatic clock frequency locking
■ imo1x (these options are available inside the IMO block): circuit for USB operation. This design allows for small fre-
❐ 48 MHz DSI clock subjected to the accuracy of the quency adjustments based on measurements of the incom-
source of the clock ing USB timing (frame markers) versus the IMO clock rate.
❐ Crystal oscillator will not work at 48 MHz, so it has to With this clock locking loop, the clock frequency can stay
be multiplied by PLL to get to 48 MHz within spec for the USB Full Speed mode (±0.25% accu-
❐ Cannot use 48 MHz IMO due to clock accuracy rate). The IMO must be operated at 24 MHz for proper clock
issues locking, with the doubler supplying 48 MHz for USB logic.
■ imo2x (these options are available inside the IMO block): The USB locking feature for the IMO can be enabled by the
register bit FASTCLK_IMO_CR [6].
❐ 24 MHz crystal with doubler
❐ 24 MHz IMO with doubler with USB lock Alternately, a 24 MHz crystal controlled clock (doubled to 48
❐ 24 MHz DSI input with doubler MHz) can be supplied for Full Speed USB operation. Other
crystal frequencies, such as 4 MHz could be used with the
■ clk_pll:
PLL to synthesize the necessary 48 MHz.
❐ Crystal with PLL to generate 48 MHz
Valid frequency for the PLL output, in this case, is 48 MHz.
❐ IMO with PLL to generate 48 MHz
The DSI signal, dsi_glb_div [0], provides another DSI signal
❐ DSI input with PLL to generate 48 MHz
choice in addition to the clk_imo option above. As with the
■ DSI input: PLL, this clock must have USB accuracy and be 48 MHz.
❐ 48 MHz
In this situation, any of the choices can produce a valid
48 MHz clock for the USB. If the internal main oscillator is
selected, it must be run with the oscillator locking function
enabled, in which case it self tunes to the required USB
accuracy when USB traffic arrives at the device.
Start (enable)
Start (enable)
The divider automatically reloads its divide count after Divider outputs can each be configured to give one of four
reaching the terminal count of zero. The divider count is set waveforms, as described below.
in the register CLKDIST_DCFG[0..7]_CFG0/1 for digital
dividers and CLKDIST_ACFG[0..3]_CFG0/1 for analog 16.4.3.1 Single Cycle Pulse Mode
dividers.The counter is driven by the clock source selected
In Single Cycle Pulse mode, by default, the divider gener-
from an 8-input mux, and the source selection is done in the
ates a single high pulse clock at either the cycle after the ter-
register CLKDIST_DCFG[0..7]_CFG2[2:0] for digital divid-
minal (zero) count or the half-count, and is otherwise low.
ers and CLKDIST_ACFG[0..7]_CFG2[2:0] for analog divid-
This produces an output clock that is high for one cycle of
ers. There are two divider output modes: single-cycle pulse
the input clock, resulting in a 1-of-N duty cycle clock. This is
and 50% duty cycle.
illustrated in Figure 16-12.
In either output mode, a divide value of 0 causes the divider
to be bypassed, giving a divide by 1. In this case, the input 16.4.3.2 50% Duty Cycle Mode
clock is passed to the output after a resync, if the sync In 50% Duty Cycle mode, the output produces a clock that
option is selected (see Clock Synchronization on page 158). has an approximate 50% duty cycle, depending on whether
For a load value of M, the total period of the output clock is the total number of counter cycles is even or odd. The 50%
N = M + 1 cycles (of the selected input clock). For example, clock rising edge occurs at the equivalent rising edge loca-
a load value of 4 gives a 5-cycle long output clock period. tion of the 1/N clock.
even, allowing for a nominal 50% duty cycle. The clock is 16.4.4 Clock Synchronization
high for the first (M + 1)/2 cycles, and then goes low for the
remaining (M + 1)/2 cycles. All digital and analog divider outputs have an option to be
synchronized to the clk_sync_dig signals (CLKDIST_DCFG
If M is even, the total cycle count is odd, which means that [x]_CFG2[3] or CLKDIST_ACFG[x]_CFG2[3]), as shown in
the output clock is high longer than it is low (in standard Figure 16-13.
phase mode). Specifically, it is high for the first (M/2) + 1
cycles and then low for the remaining M/2 cycles. This is Each digital divider can be synchronized to the digital phase
illustrated in Figure 16-12 on page 157 for M = 3 and M = 4. mux output by setting the sync bit (CLKDIST_DCFG
[x]_CFG2[3]). The phase delay for the digital divider is
The CLKDIST_DCFG[x]_CFG2[4] or based on the phase shift field of Nonvolatile Latch (NVL) bits
CLKDIST_ACFG[x]_CFG2[4] bit in the configuration register DIG_PHS_DLY[3:0].
for each clock output can be set high to provide the 50%
duty cycle mode. An exact 50% duty cycle cannot be guar- Each of the four analog dividers can be synchronized to four
anteed in all cases, as it depends on the phase and fre- distinct phase shifted clocks. The phase on the respective
quency differences between the output clock and the sync analog dividers sync clocks can be provided in the
clock. PHASE_DLY field (CLKDIST_ACFG[x]_CFG3[3:0]). The
analog clocks become synchronized when the SYNC bit is
16.4.3.3 Early Phase Option set (CLKDIST_ACFG[x]_CFG2[3]). These divided clocks
synchronized to the analog clocks are called clk_a.
In addition to the two duty cycle choices, the outputs can be
phase shifted to either go high after the terminal count, or at The output of each clock tree provides for selection of one of
the half-period cycle. The default is referred to as Standard four output clocks:
phase, with the rising edge of the output after the terminal ■ Resynchronized clock – A clock running at a maximum
count. rate of clk_sync/2 is resynchronized by the phase
delayed clk_sync. This output is activated by setting the
The other option is referred to as the Early Phase because
sync bit.
the output can be considered to be shifted earlier in time to
an approximate count that is one-half of the divide value. ■ Phase delayed clk_sync (such as clk_sync_dig) –
The CLKDIST_DCFG_CFG2 [5] or CLKDIST_ACFG_CFG2 The clock tree runs at the same rate as clk_sync, but just
[5] bit in the configuration register for each clock output can outputs this clock with proper phase delay. Note that the
be set high to give the Early Phase mode, with the rising input clock source is ignored in this case. The output
edge near the half count. buffer is designed to match the final sync flop delay.
■ Unsynchronized divided clock – This produces an
Analog clock dividers are similar in their architecture to digi-
asynchronous clock, subject to the limitations described
tal dividers. However, they have an extra resync circuit to
in Asynchronous Clocks on page 160. This mode is
synchronize the analog clock to the digital domain clocks.
applicable when the sync bit is reset and the divider has
Therefore, each of the analog dividers also has an output
a nonzero divide value.
synchronized with the digital domain. This clock is synchro-
nized to the output of the digital phase mux. The digital syn- ■ Bypassed clock source – This routes the clock trees
chronized analog divider output is called clk_ad. This divider selected source to the output without going through the
is useful for clean communication between analog and digi- divider. This happens when the divider value is set to 0
tal domain. and sync bit is reset. As in the previous case, this also
produces an asynchronous clock.
clkout _ sel
clk_sync_d Clock
(or clk_sync_a0-a3) tree
output
Clk_sync
1.5 ns 1 ns 0.5 ns 0 ns
Clk_sync_a0 Clk_sync_a2
Ana0 Ana2
Clk_sync_a1 Clk_sync_a3
Ana1 Ana3
Digital
DIG_PHS_DLY [3:0]
Phase
Clk_sync_dig
The phase shifter consists of a chain of (nominally) 0.5 ns The clk_sync_dig phase shift selection must be applied at
buffers connected in cascade, with the output of each buffer power up through NVL settings, because changing its value
ported out of the circuit (21 outputs). The input to this chain can cause clock glitching; the clk_bus clock should not be
is clk_sync from the master clock divider. Five 5-bit muxes stopped for such a change. The analog phase shift selec-
select the sync clock to drive the resync circuits. One is tions can be made dynamically, because their output clocks
clk_sync_dig for the digital clock dividers (clk_bus and all can be disabled during any phase shift change.
digital clock dividers). The other four are independent delay
Outputs in the delay chain may have increased jitter. The
selections, one for each analog divider. The selected phase
expectation is that, in systems that need a low-jitter analog
value is defined in NVL bits for the digital and ACFG
clock, the undelayed output (first tap) is selected because it
[n]_CLKDIST_ACFG_CFG3}_PHASE_DLY for the analog
has the lowest jitter.
clocks.
The system will not go into a sleep mode if either the MHz
crystal oscillator or the PLL are enabled. If either of these
clocks are enabled, the part will simply continue execution
without entering a sleep mode. Therefore, to enter a sleep
PSoC® 3 and PSoC® 5 devices have separate external analog and digital supply pins, labeled respectively Vdda and Vddd.
The devices have two internal 1.8V regulators that provide the digital (Vccd) and analog (Vcca) supplies for the internal core
logic. The output pins of the regulators (Vccd and Vcca) have very specific capacitor requirements that are listed in the data-
sheet.
17.1 Features
These regulators are available:
■ Analog regulator for the analog domain supply
■ Digital regulator for the digital domain supply
■ Sleep regulator for the sleep domain
■ I2C regulator for powering the I2C logic
■ Hibernate regulator for supplying keep alive power for state retention during hibernate mode
Vddio2 1 µF Vddd
Vddio0
0.1 µF 0.1 µF
Vddd
Vccd
Vssd
Vddio2
Sleep
Regulator
Digital
Vdda
Domain
Vdda
Analog Vcca
Vssd
Digital Regulator
0.1 µF
Regulators .
1 µF
Vssa
Analog
Domain
Hibernate
Regulator
Vddio1
Vddio3
Vccd
Vddd
Vssd
0.1 µF 0.1 µF
0.1 µF
Vddio1 Vddd Vddio3
For the 1.71 V < Vcc < 1.89 V external supply, power up the
device with Vccd/Vcca pins. In this mode, short the Vddd pin
Vccd and short the Vdda pin to Vcca. The internal regulator
remains powered by default. After power up, disable the
regulators, using register PWRSYS. CR0 to reduce power
consumption.
The input voltage can be from various sources, such as a battery source or solar cells. The converter uses an external induc-
tor to boost the voltage. An external Schottky Diode must be connected between the pins IND and Vboost when boost voltage
is greater than 3.6V.
Optional Schottky
Diode Required When
Vboost > 3.6V
10 µH
Vbat IND Vboost
Vdda
22 0.1 Vddd 0.1
µF µF 22 µF
PSoC µF
Vssb
Vssa
Vssd
The boost converter is enabled or disabled by the register on the rising and falling edge of the clock when the out-
bit BOOST_CR1 [3]. The device provides the option of put voltage is less than the programmed value. This is
changing the boost output voltage by writing into the register called automatic thump mode (ATM) and is enabled in
BOOST_CR0 [4:0]. By default, at startup the boost con- the BOOST_CR2[0].
verter is enabled and configured for a 1.8V output. If the In device sleep mode, all comparators and other circuits are
boost converter is not used, the pin Vbat should be tied to turned off, except for the band gap. This configuration inhib-
ground, and the IND pin should be left floating. its output; the boost output is High Z. Output voltage is the
voltage on the output load capacitor minus any loads being
17.3.2.1 Modes of Operation supplied by the capacitor during sleep time.
The boost converter has two main operating modes Over a prolonged period of time, output voltage decays. The
selected by the register BOOST_CR0 [6:5]; these are: microcontroller can manage power during periodic wakeups
■ Active – This is the normal mode of operation where the to implement a digital control loop and maintain the required
Boost Regulator actively generates a regulated output voltage during sleep mode.
voltage from the battery input. The switching frequency
is selected by BOOST_CR1 [1:0] and is not synchro- 17.3.2.2 Status Monitoring
nized to any other clock. The switching frequency selec-
Status monitoring for input and output voltages of the boost
tions are 2 MHz, 500 kHz, and 125 kHz, respectively.
converter are available in the status register BOOST_SR.
■ Standby – In this mode, only the band gap and boost
■ Output Voltage Monitor – The register
circuit comparators are active, while other systems are
BOOST_SR[4:0] gives a status of the output voltage
disabled, thus reducing power consumption of the boost
against the set nominal voltage output.
circuit itself. Output voltage is continuously monitored
and supervisory data provided in BOOST_SR [4:0]. This Bit 4: ov – Above overvoltage threshold (nominal + 50
mV).
register provides supervisory data against the output
voltage selected. Therefore, the processor can use the Bit 3: vhi – Above High regulation threshold (nominal
thump bit BOOST_CR0 [7] to switch the transistor ON +25 mV).
for a 1 µs pulse. Bit 2: vnom – Above Nominal threshold (nominal).
The converter can be configured to provide low power, Bit 1: vlo – Below Low regulation threshold (nominal to
low current regulation in the standby mode. A 32 kHz 25 mV).
clock is present which generates inductor boost pulses Bit 0: uv – Below undervoltage limit (nominal to 50 mV).
Vdda Vddd
RESET_CR1[3]
Interrupt Controller
17.3.3.1 Low Voltage Interrupt enabled. In addition, the real-time status of each LVI circuit
is available and captured in a real-time status register bit in
The LVI circuit generates an interrupt when it detects a volt-
RESET_SR2, so that the user can determine if an under /
age below the set value. These low voltage monitors are off
over voltage condition is still in effect.
by default, but the trip level for the LVI can be set in the reg-
ister RESET_CRO from 1.7V to 5.45V in steps of 250 mV. 17.3.3.2 High Voltage Interrupt
The LVI circuit has a persistent status register bit in The HVI circuit generates an interrupt when it detects a volt-
RESET_SR0 that is set until cleared by the user by reading age above the fixed, safe operating value of 5.75V on the
from the register or until a POR. This bit is set whenever the external analog supply. There is just one HVI for both analog
voltage goes below the set value. There is distinct monitor- and digital supplies. The selection between monitoring the
ing for low voltage on the analog and digital supply. The digital or analog supply is done by the RESET_CR1[3] bit.
analog low voltage interrupt (ALVI), enabled by These high voltage monitors are off by default, but this fea-
RESET_CR1[1] and RESET_CR0[7:4], sets the ALVI ture can be enabled in the register RESET_CR1 [2].
threshold. The digital low voltage interrupt (DLVI), enabled
by RESET_CR1[0] and RESET_CR0[3:0], sets the DLVI The HVI circuit has a persistent status register bit in
threshold. Apart from this, when the voltage monitoring is RESET_SR0 that is set until it is cleared by the user by
enabled and corresponding PRES bit is also enabled in reading or writing to the register or until a POR reset. This
RESET_CR3[7:6], the low voltage condition would trigger a bit is set when the analog voltage value goes beyond the
corresponding reset. threshold value.
The interrupt is generated only when the corresponding bit The interrupt is generated only when the corresponding bit
in register RESET_CR1 is set and corresponding bits in in the register RESET_CR1 [2] is unmasked. Even if the
RESET_CR3[7:6] cleared. Even if the interrupt output is not interrupt output is not used to generate a processor inter-
used to generate a processor interrupt, the status registers rupt, the status registers are updated by the circuit when-
are updated by the circuit whenever LVI functions are ever HVI functions are enabled. In addition the real-time
output of each HVI circuit is available and captured in a real- moment when voltage detection is being enabled. One way
time register bit in RESET_SR2, so that the user can deter- to achieve this is by disabling the LVD interrupt before
mine if an overvoltage condition is still in effect. enabling the voltage detection and enabling it after some
time, which avoids the potential glitch caused while
17.3.3.3 Processing a Low/High Voltage enabling.
Detect Interrupt
During Sleep mode, LVI and HVI circuits may be buzzed
Both low and high voltage interrupt circuits (LVI, HVI) cause (periodically activated). If an interrupt occurs during buzzing,
the same interrupt output signal, which is made available to the system will first go through its wakeup sequence; then
the Interrupt Controller. the interrupt is recognized and serviced.
The PSoC® 3 and PSoC® 5 devices feature a set of four power modes with a goal of reducing the average power consump-
tion of the device.
18.1 Features
The PSoC 3 and PSoC 5 power mode features, in order of Sleep and Hibernate modes are used when processing is
decreasing power consumption, are: not necessary for an extended time. All subsystems are
■ Active automatically disabled in these two modes, regardless of the
settings in the active template register. Some subsystems
■ Alternative Active
have an additional available bit [PM_Avail_CRx] that can
■ Sleep mark a subsystem as unused and prevent it from waking
■ Hibernate back up. This reduces the power overhead of waking up the
part, in that not all subsystems are repowered.
Active and alternative active are the main processing
modes, and the list of enabled peripherals is programmable The allowable transitions between power modes are illus-
for each mode. trated in Figure 18-1.
Active
Manual
Sleep Hibernate
Alternate
Active
The various power modes reduce power by affecting the fol- Power savings, resume time, and supported wakeup
lowing resources: sources depend on the particular mode. The four global
■ Regulators for the digital and analog supply in the device power-reducing modes are described in Table 18-1 and are
listed in decreasing order of power consumption.
■ Clocks such as the IMO, ILO, and External crystal oscil-
lator (ECO32K, ECOM)
■ Central Processing Unit (CPU) and all other peripherals
18.2 Active Mode nate active mode. While in alternate active mode, if any
interrupt is generated, the device automatically transitions to
Active mode is the primary power mode of the PSoC device. active mode and begins executing the firmware in active
This mode provides the user with an option to use every mode.
possible subsystem/peripheral in the device. All of the
clocks in the device are available for use in this mode. 18.3.1 Entering Alternative Active Mode
Each power-controllable subsystem is enabled or disabled Alternative Active mode is entered by writing into
in Active mode, using the active power configuration tem- [PM_MODE_CSR]. Firmware must ensure the SPC Idle bit
plate bits [PM_ACT_CFGx registers]. This is a set of 14 reg- in the SPC_SR[1] register is '1' prior to writing to the
isters in which each bit is allocated to enable/disable a PM_MODE_CSR [2:0] register to ensure any SPC com-
distinct power controllable subsystem. When a subsystem is mands have completed.
disabled, the clocks are gated and/or analog bias currents
are reduced. The essential difference between Active and Alternative
Active mode is that the device cannot wake up from Sleep/
Firmware may be used to dynamically enable or disable Hibernate mode into the Alternative Active mode.
subsystems by setting or clearing bits in the active configu-
ration template. It is possible for the CPU to disable itself,
18.3.2 Exiting Alternative Active Mode
while the rest of the system remains in Active mode. The
CPU Active mode bit is not sticky; therefore the CPU is Any interrupt or writing the [PM_MODE_CSR] register can
always awakened whenever the system returns to Active return the system to Active mode.
mode.
General Registers
PM_ACT_CFGx Active mode template
PM_STBY_CFGx Alternate Active mode template
PM_AVAIL_CRx Available settings for limited Active mode transition
PM_AVAIL_SRx Availability Status register
PM_MODE_CFG0 Not used
PM_MODE_CFG1 Interrupt and settings for low power modes
PM_MODE_CSR Power Mode Control and Status register
PM_INT_SR Power Mode Interrupt Status register
PM_TW_CFG0 Fast Timewheel (FTW) Configuration register
PM_TW_CFG1 Central Timewheel (CTW) Configuration register
PM_TW_CFG2 Configuration settings for CTW and FTW
The Watchdog Timer (WDT) circuit automatically reboots the system in the event of an unexpected execution path. This timer
must be serviced periodically. If not, the CPU resets after a specified period of time. Once the WDT is enabled it cannot be
disabled except during a reset event. This is done to prevent any errant code from disabling the WDT reset function. To use
the WDT function, the user is required to enable the WDT function during their startup code.
19.1 Features
The WDT has the following features:
■ Protection settings to prevent accidental corruption of the WDT
■ Optionally-protected servicing (feeding) of the WDT
■ A configurable low power mode to reduce servicing requirements during sleep mode
■ A status bit for the watchdog event that shows the status even after a watchdog reset
1024 Ticks
256 ms – 384 ms
128 Ticks
Watchdog Watchdog Reset
Counter
32 ms – 48 ms (3 Counts)
16 Ticks
4 ms – 6 ms PM_WDT_CFG [1:0]
ILO 2 Ticks
Clear Enable
1 kHz
Central Timewheel
PM_WDT_CR PM_WDT_CFG[4]
The WDT timeout is between two and three programmable 19.3.3 Operation in Low Power Modes
tap periods, based on the free-running Central Timewheel. A configurable low power mode of the WDT reduces servic-
See the PSoC® 3 Registers TRM (Technical Reference ing requirements during sleep mode. The register
Manual) and the PSoC® 5 Registers TRM (Technical Refer- PM_WDT_CFG[6:5] governs the low power mode for the
ence Manual). WDT.
Each time the central timewheel crosses the programmed If the Watchdog-Timer (WDT) is enabled, these two bits
tap point, the Watchdog counter increments. When the define how the WDT behaves when the part enters sleep/
counter reaches three, a Watchdog reset is asserted, and idle/hibtimers (low power) mode. By default its left to 01, the
the counter is reset. When the WDT is serviced in software, system will automatically use the longest WDT interval when
the counter is reset to zero. Sleep/Idle/Hibtimers mode is entered - so SW isn't burdened
The time between servicing and the first tap crossing is usu- with waking just to feed the WDT. This is true regardless of
ally less than the complete tap period; therefore, software the value programmed in the wdt_interval register. Upon
should be programmed to service the WDT within two tap wakeup, the interval will remain at the highest setting until
periods. Actual WDT timeouts may differ slightly from nomi- the WDT is fed the first time by the user. A feeding at this
nal, caused by inaccuracy of the frequency of the ILO. point will cause the interval to automatically return to the
normal setting (value in wdt_interval). If this field is set to
NOCHANGE ('00'), the system does not change the interval
19.3.1 Enabling and Disabling the WDT
and does not feed the WDT when entering Sleep/Idle/Hib-
The WDT is enabled by setting the PM_WDT_CFG [4] regis- timers mode. If DISABLED (wdt_lpmode=11), the WDT is
ter bit. After this bit has been set, it cannot be cleared again turned off when Sleep/Idle/Hibtimers mode is entered and
except by a power reset event. This is done so that errant remains disabled until the first feeding by the user after
code cannot accidentally disable the Watchdog. Active mode is reentered.
Users must either reenable the Watchdog function at startup
after a reset occurs or include code to reenable the function 19.3.4 Watchdog Protection Settings
should a reset occur, allowing a dynamic choice whether to By use of the registers MLOGIC_SEG_CR and
enable the Watchdog. MLOGIC_SEG_CFG0, Watchdog timer registers are pro-
A status bit (RESET_SR0[3]) becomes set on the occur- tected from accidental corruption as follows:
rence of a Watchdog reset. This bit remains set until cleared ■ Clear, low-power enable, and Watchdog enable registers
by the user, by reading or writing to the register, or until a are protected as segment 0 as one-time system settings.
POR reset. All other resets leave this bit untouched. ■ The servicing of WDT clear is protected in segment 1 as
a reconfigurable system setting.
19.3.2 Setting the WDT Time Period and
See 22.3 Configuration Segment Protection on page 206.
Clearing the WDT
The user can select a tap from the central timewheel using
the register PM_WDT_CFG[1:0]. Based on the tap selected,
the WDT is timed at various periods, shown in Figure 19-1
on page 175. The Watchdog Timer counts until reaching
three counts, based on the tap from the central timewheel. If
the firmware does not clear the WDT before this time, a
Watchdog reset is initiated.
PSoC® 3 and PSoC® 5 architectures support several types of resets that allow error-free operation during power up for any
voltage ramping profile, user-supplied external or software resets, and recovery from errant code operation.
20.1.5 Identifying Reset Sources These two registers have specific status bits allocated for
the various RESET sources, except POR. The bits are set
When the device comes out of reset, it is beneficial to know on the occurrence of the corresponding reset, and remain
the cause of the reset. This is achieved in the device set after the reset, until the tstrst_en bit (bit 4) is cleared in
through the registers RESET_SR0 and RESET_SR1. All the Test Controller TC_TST_CR2 and they are cleared by
types of resets mentioned above set corresponding status the user or a POR reset.
bits in the RESET_SR0/1 registers. These persistent status
bits are only available when the tstrst_en bit (bit 4) is set in Therefore, all of the other RESET sources can be identified
the Test Controller TC_TST_CR2. after the reset. In the case of POR or the entire register is
cleared, indicating a power on reset.
POR
Hibernate
System
RESET
WRES_ENA
WRES
Hibernate
SRES
Hibernate
XRES
Figure 20-2 is a diagram showing the operation of various RESETs with the change in Vdd/Vcc. The diagram also shows the
functioning of RESETs in a normal power up.
CPU State
Vddd/
Vdda Pin
Core
Vccd/Vcca Trip
Level
POR
XRES
HRES
WRES
SRES
Legend
Reset
Boot
User Code Runs
20.4 Boot Process and Timing PSoC 3 life cycle consists of reset, boot, and user phases.
Figure 20-3 gives a brief view of these phases.
The boot process trims and configures the silicon to its ideal
state before the first line of the user code is executed. The
Figure 20-3. Boot Process
The process from supply voltage stabilization to user code gling of the external pins P1_0 and P1_1 and the configura-
entry is shown in the Figure 20.4. After the voltage is high tion finishes, the system moves into the user mode. Toggling
enough, the NVL Data load is initiated. The NVL load takes of P1_0 and P1_1 would imply a debug port acquire is being
care of loading configuration data stored in the NV Latches. attempted which would have to trigger a debug port entry.
These are configuration data that control the reset behavior
The process from supply voltage stabilization to user code
of the device. The maximum time for this NVL load is 10 s
entry is shown in the Figure 20.4. After the voltage is high
from the time of initiation. This resets the I/Os to the NVL
enough, the NVL Data load is initiated. The NVL load takes
drive mode settings as well as setting the other Manufactur-
care of loading configuration data stored in the NV Latches.
ing Configuration data for the device. At this point the device
These are configuration data that control the reset behavior
enters the reset state. The two types of NVL loads that hap-
of the device. The maximum time for this NVL load is 10 s
pen here are explained in section 20.4.1 Manufacturing
from the time of initiation. This resets the I/Os to the NVL
Configuration NV Latch.
drive mode settings as well as setting the other Manufactur-
If the external reset pin (XRES_N) is asserted low, the ing Configuration data for the device. At this point the device
device stays in the reset state. If the external reset pin enters the reset state. The two types of NVL loads that hap-
(XRES_N) is not asserted and all the voltages are at their pen here are explained in 20.4.1 Manufacturing Configura-
correct operating values it triggers the reset hold off circuitry tion NV Latch.
to begin bringing the device out of the reset state.
If the external reset pin (XRES_N) is asserted low, the
The IMO clock is then started in a fast IMO (FIMO) mode device stays in the reset state. If the external reset pin
which is a faster start up version of the IMO. The reset hold (XRES_N) is not asserted and all the voltages are at their
off counter continues to hold the device in reset until the correct operating values it triggers the reset hold off circuitry
other systems like band-gap and precision resets stabilize. to begin bringing the device out of the reset state.
The length of the hold off is approximately 20 s to allow
The IMO clock is then started in a fast IMO (FIMO) mode
enough time for these circuits to stabilize. If the band-gap or
which is a faster start up version of the IMO. The reset hold
precision reset blocks are not ready or there is a problem
off counter continues to hold the device in reset until the
with any of these devices stabilizing by the end of the hold-
other systems like band-gap and precision resets stabilize.
off counter, a fresh reset cycle is initiated and the hold-off
The length of the hold off is approximately 20 s to allow
counter is restarted. If there are no problems and the hold-
enough time for these circuits to stabilize. If the band-gap or
off counter completes and the device is released from reset.
precision reset blocks are not ready or there is a problem
After releasing from reset the IMO is switched to either 12 or with any of these devices stabilizing by the end of the hold-
48 MHz, the system bus clock is started, and the boot cycle off counter, a fresh reset cycle is initiated and the hold-off
begins. Until now the bus clock was fed from the FIMO counter is restarted. If there are no problems and the hold-
which has lesser accuracy compared to the IMO. Once the off counter completes and the device is released from reset.
reset is released it moves into the IMO which is more pre-
After releasing from reset the IMO is switched to either 12 or
cise. The boot phase is explained in section 20.4.3 User
48 MHz, the system bus clock is started, and the boot cycle
Mode. During this boot configuration time, if there is no tog-
begins. Until now the bus clock was fed from the FIMO
which has lesser accuracy compared to the IMO. Once the gling of the external pins P1_0 and P1_1 and the configura-
reset is released it moves into the IMO which is more pre- tion finishes, the system moves into the user mode. Toggling
cise. The boot phase is explained in section 20.4.3 User of P1_0 and P1_1 would imply a debug port acquire is being
Mode. During this boot configuration time, if there is no tog- attempted which would have to trigger a debug port entry.
XRES_N
IPORXA
~20us
BG + Precision RESET READY
System_resets
clk_bus
Checksum Done
In this phase two types of NV Latches are loaded to set 20.4.1.1 Device Configuration NV Latch
reset states and trims in the device. The two types of the
Device Configuration is similar to Manufacturing Configura-
configuration are explained below. Both the configuration
tion NV in that it occurs while the device is in reset; however,
explained in sections 20.4.1 Manufacturing Configuration
it differs in that customers are selecting optional configura-
NV Latch and 20.4.1.1 Device Configuration NV Latch occur
tion settings not trim values for circuits. Manufacturing con-
simultaneously in the reset phase.
figuration and device configuration occur in parallel. One
such example of a device configuration is the NV latches
20.4.1 Manufacturing Configuration NV that determine the I/O drive modes during reset which deter-
Latch mine the reset state of the drive mode registers.
There are some circuits that must receive part specific trim
values before the device comes out of reset. Manufacturing 20.4.2 Boot Phase
NV latches provides these trim values. Conceptually an
Though many settings for the device are done using NV
example of such a circuit is the power on reset. This circuit
latch setting during the preboot process, there are other trim
is responsible for holding the device in reset until a safe sup-
values that require to be written during the boot process.
ply voltage is reached. The POR circuit requires a trim value
These values are stored in reserved space in the Flash
which would be stored in an NV latch. NV latch's output is
memory (I/O System chapter on page 187) and the boot
stable at approximately 1 V while the lowest operating volt-
process takes care of moving this data to the corresponding
age in the PSoC 3 platform is 1.71 V.
blocks. This loading of the configuration happens using the
DMA and the PHUB. A DMA channel fetches the configura-
tion bytes from the flash and places them in the SRAM. The
check sum block does a check sum to determine integrity.
The I/O system provides the interface between the CPU core and peripheral components to the outside world. The flexibility
of PSoC® devices and the capability of its I/O to route any signal to any pin greatly simplifies circuit design and board layout.
There are two types of I/O pins on every device, general purpose I/O (GPIO) and special I/O (SIO); those with USB provide a
third type. Both GPIO and SIO provide similar digital functionality. The primary differences are their analog capability and
drive strength. Devices that include USB also provide two USBIO pins that support specific USB functionality as well as spe-
cialized general purpose capability.
All I/O pins are available for use as digital inputs and outputs for both the CPU and digital peripherals. In addition, all I/O pins
can generate an interrupt. All GPIO pins can be used for analog input, CapSense®, and LCD segment drive, while SIO pins
are used for voltages in excess of Vdda and for programmable output voltages and input thresholds.
21.1 Features
The PSoC I/O system has these features, depending on the pin type.
USBIO features:
■ USB 2.0 compliant I/O
■ 25 mA source/24 mA sink current
0
PRT[x]PS
PICU[x]INTTYPE[y]
PICU[x]INTSTAT PRT[x]INP_DIS
Interrupt
Pin Interrupt signal Logic
PICU[x]SNAP
PRT[x]DM2 Drive
Logic Slew
PRT[x]DM1 PIN
Cntl
PRT[x]DM0
Analog
1 0
1 0
CapSense Global Control 1
PRT[x]_CAPS_SEL[y] Switches
PRT[x]AG
Analog Global Bus
PRT[x]AMUX
Analog Mux Bus
LCD
Display Data
PRT[x]LCD_COM_SEG Logic and
PRT[x]LCD_EN MUX
0
PRT[x]PS
PRT[x]SIO_DIFF
Reference
PRT[x]SIO_CFG Generator
PRT[x]SYNC_OUT
PRT[x]DM2 Drive
Logic Slew
PRT[x]DM1 PIN
Cntl
PRT[x]DM0
PRT[x]DBL_SYNC_IN
0
USBIO_CR1[0,1]
PICU[x]INTTYPE[y]
PICU[x]INTSTAT
Interrupt
Pin Interrupt Signal Logic
PICU[x]SNAP
D+ pin only
USBIO_CR1[7] USB or I/O
USB SIE Control for USB Mode Vio Vio 3.3V Vio
USBIO_CR1[4,5] 0
In
Digital System Output 1
Drive
PRT[x]BYP 5k 1.5k
Logic
PIN
USBIO_CR1[2] D+ 1.5k
USBIO_CR1[3] D+D- 5k
USBIO_CR1[6] Open Drain
21.3.2 I/O Drive Modes The I/O pin drive state is based on the port data register
value (DR) or on a DSI signal, if bypass mode is selected.
Each GPIO and SIO pin is individually configurable into one The actual I/O pin voltage is determined by a combination of
of the eight drive modes listed in Table 21-1 and shown in the DR value, the selected drive mode, and the load at the
Figure 21-4, which depicts a simplified pin view based on pin. The state of the pin can be read from the Port Status
each of the eight drive modes. register (PS) or routed to a DSI signal, or both. Three config-
uration bits are used for each pin (DM [2:0]) and set in the
PRTxDM [2:0] registers.
Vio Vio
DR DR DR DR
Pin Pin Pin Pin
PS PS PS PS
DR DR DR DR
Pin Pin Pin Pin
PS PS PS PS
21.3.2.1 Drive Mode on Reset Drive mode, a 0 must be written to that pin’s Data Register
bit.
The factory drive mode default is high impedance analog
mode, which is appropriate for most designs. The Drive 21.3.2.5 Open Drain, Drives High and Drives
Mode on Reset feature allows the user to change the factory
Low
default to any of the four listed drive modes if the application
requires faster configuration to low or high logic levels. The Open Drain modes provide high impedance in one of the
Reset drive mode is set at POR release. The Drive Mode on data states and strong drive in the other. Pins are used for
Reset setting is a port wide setting and is not set per pin. digital input and output in these modes. A common applica-
Each pin is individually configured during the device configu- tion for these modes is driving I2C bus signal lines.
ration step after POR release; this setting overwrites the
reset drive mode. The Resistive Pull Up Drive Mode on 21.3.2.6 Strong Drive
Reset also sets the Port Data Register to 0xFF to ensure the The Strong Drive mode is the standard digital output mode
port is pulled up; all other modes leave the Data Register for pins; it provides a strong CMOS output drive in both high
0x00. and low states. Strong drive mode pins must not be used as
■ High impedance analog inputs under normal circumstances. This mode is often used
■ High impedance digital to drive digital output signals or external FETs.
■ Resistive pull up
21.3.2.7 Resistive Pull Up and Pull Down
■ Resistive pull down
The Resistive Pull Up and Pull Down mode is a single mode
Refer to the Nonvolatile Latch chapter on page 121 for and is similar to the Resistive Pull Up and Resistive Pull
details. Down modes, except that, in the single mode, the pin is
always in series with a resistor. The high data state is pull up
21.3.2.2 High Impedance Analog while the low data state is pull down. This mode is used
High Impedance Analog mode is the default reset state; when the bus is driven by other signals that may cause
both output driver and digital input buffer are turned off. This shorts.
state prevents a floating voltage from causing a current to
flow into the I/O digital input buffer. This drive mode is rec- 21.3.3 Slew Rate Control
ommended for pins that are floating or that support an ana-
GPIO and SIO pins have fast and slow output slew rate
log voltage. High impedance analog pins cannot be used for
options for strong drive modes – not resistive drive modes.
digital inputs. Reading the pin state register returns a 0x00
The fast slew rate is for signals between 1 MHz and 33
regardless of the data register value.
MHz.
To achieve the lowest device current in sleep modes, all I/
Because it results in reduced EMI, the slow option is recom-
Os must either be configured to the high impedance analog
mended for signals that are not speed critical – generally
mode, or they must have their pins driven to a power supply
less than 1 MHz. Slew rate is individually configurable for
rail (ground) by the PSoC device or by external circuitry.
each pin and is set by the PRTxSLW registers.
21.3.2.3 High Impedance Digital
21.3.4 Digital I/O Controlled by Port
High Impedance Digital mode is the standard high imped-
Register
ance (High Z) state recommended for digital inputs. In this
state, the input buffer is enabled for digital signal input. The Port Control registers (see Table 21-2 on page 193)
have separate configuration bit for each port pins. In addi-
21.3.2.4 Resistive Pull Up or Resistive Pull tion to port control registers, the device also provides regis-
Down ter for port-wide and pin wise configuration.
Resistive modes provide a series resistance in one of the The port wide configuration register writes the same config-
data states and strong drive in the other. Pins can be used uration for all the port pins in a single write. This is useful to
for digital input and output in these modes. Interfacing to configure all the port pins to a specific configuration.
mechanical switches is a common application for these
The pin wise configuration register writes to all configuration
modes. If a pull up is needed with the Resistive Pull Up
bits for a specific I/O pin in a single write. This is useful to
Drive mode, a 1 must be written to that pin’s Data Register
configure individual port pins to a specific configuration.
bit. If a pull down is required with the Resistive Pull Down
Outputs are driven from the CPU by writing to the port data 21.3.4.2 Pin Wise Configuration Register
registers (PRTx_DR) Digital inputs are read by the CPU Alias
through the pin state registers (PRTx_PS}).
The port pin configuration registers (PRTxPC0 through
21.3.4.1 Port Configuration Registers PRTxPC7) access several configuration or status bits of a
single I/O port pin at once, as shown in Figure 21-5 on
Table 21-2 lists port control registers. page 193.
Table 21-2. Functional Registers Accessed through Pin and Figure 21-5 shows an example of a read from
Port Configuration Registers {PRT*_PC[4]}. Bit four of the port control registers associ-
Address Description ated with the port configuration register is read and driven
A bit set in this register connects the corresponding
onto the data bus.
PRT[0..11]_BYP port pin to the Digital System Interconnect (DSI),
and disconnects it from the DR register.
Each bit controls the output edge rate of the corre-
PRT[0..11]_SLW sponding port pin – fast edge rate mode (Slew=0) or
slow edge rate mode (Slew=1)
Each bit set controls the bidirectional mode of the
corresponding port pin.
PRT[0..11]_BIE
0 = Output always enabled
1 = Output Enable controlled by DSI input
This register reads the logical pin state for the cor-
PRT[0..11]_PS
responding GPIO port.
The combined value of these registers –
PRTx_DM2, PRTx_DM1, and PRTx_DM0 – deter-
PRT[0..11]_DM[0..2]
mines the unique drive mode of each pin in a GPIO
port.
Data written to this register specifies the high
PRT[0..11]_DR (Data=1) or low (Data=0) state for the GPIO pin at
each bit location of the selected port.
Data Register Bypass – (Port 3 BYP) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Slow Slew Rate – (Port 3 SLW) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Bidirectional Enable – (Port 3 BIE) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Pin Input State – (Port 3 PS) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Drive Mode 2 – (Port 3 DM2) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Drive Mode 1 – (Port 3 DM1) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Drive Mode 0 – (Port 3 DM0) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
Data Output – (Port 3 DR) Pin 7 Pin 6 Pin 5 Pin 4 Pin 3 Pin 2 Pin 1 Pin 0
21.3.4.3 Port Wide Configuration Register access during normal operation, while the PHUB bus pro-
Alias vides full control to all I/O registers.
The Port Configuration Register accesses several available As shown in Table 21-3, SFR registers contain three regis-
configuration registers on a port-wide basis with a single bit ters for each I/O port.
write.
Table 21-3. SFR Registers
This register PRT*_PRT aliases a subset of the configura-
Addressa Description
tion registers, allowing the user to configure a complete port
Sets the output data state for port x with
in a single write. SFR_USER_GPIOx respect to setting in SFR_USER_GPIOx_SEL
register
Figure 21-6. {PRT*.PRT} Write Example
Sets output for each bit in port x register to
SFR_USER_GPIOx_SEL
corresponding pin in port x
Write
Data bus Read only register; contains pin state value of
SFR_USER_GPIRDx
port x
a. x is port number and includes ports 0-6, 12, and 15
write 8
PRT[x].PRT
bit [1] Table 21-4 shows three examples illustrating results from
1 setting selected bits in the SFR register.
1
21.3.6 Digital I/O Controlled Through DSI
PRT[x].BIE 7 0 GPIO, USBIO, and SIO pins are connected to the internal
bit [6] peripheral blocks through the UDB via the digital system
1 interconnect (DSI). Any peripheral connected to the UDB
can be connected to any I/O pin through the DSI.
PRT[x].SLW 7 0
Each port has 20 unique connections to the UDB through
bit [7]
DSI: eight inputs, eight outputs, and four output control sig-
1 nals.
PRT[x]_OUT_SEL1[0], PRT[x]_OUT_SEL0[0]
PRT[x]_OUT_SEL1[7], PRT[x]_OUT_SEL0[7]
PRT[x]_OUT_SEL1[1], PRT[x]_OUT_SEL0[1]
PRT[x]_OUT_SEL1[6], PRT[x]_OUT_SEL0[6]
PRT[x]_OUT_SEL1[2], PRT[x]_OUT_SEL0[2]
PRT[x]_OUT_SEL1[5], PRT[x]_OUT_SEL0[5]
PRT[x]_OUT_SEL1[3], PRT[x]_OUT_SEL0[3]
PRT[x].OUT_SEL1[4],PRT[x].OUT_SEL0[4]
Lower Upper
Nibble Nibble
DSI IN DSI IN
DSI[0]
DSI[1]
DSI[2]
DSI[3]
DSI[4]
DSI[5]
DSI[6]
DSI[7]
PRT[x]_DR[7:0]
in in in in in in in in
GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO
Figure 21-8. Mapping of DSI Control Signal to Port Pin Output Enable
Dynamic
Output Control
PRT[x]_OE_SEL1[0], PRT[x]_OE_SEL0[0]
PRT[x]_OE_SEL1[1], PRT[x]_OE_SEL0[1]
PRT[x]_OE_SEL1[2], PRT[x]_OE_SEL0[2]
from UDB
PRT[x]_OE_SEL1[3], PRT[x]_OE_SEL0[3]
PRT[x]_OE_SEL1[4], PRT[x]_OE_SEL0[4]
PRT[x]_OE_SEL1[5], PRT[x]_OE_SEL0[5]
PRT[x]_OE_SEL1[6], PRT[x]_OE_SEL0[6]
PRT[x]_OE_SEL1[7], PRT[x]_OE_SEL0[7]
dsi_oe[0]
dsi_oe[1]
dsi_oe[2]
dsi_oe[3]
PORT LOGIC
CONTROL
PRT[x]_BIE[7:0]
oe oe oe oe oe oe oe oe
GPIO GPIO GPIO GPIO GPIO GPIO GPIO GPIO
21.3.7 Analog I/O For analog I/O pins, the drive mode should be configured to
High Z Analog in most situations, which disables the input
The only way that analog signals can pass to and from the buffer. The input buffer can also be disabled using the port
PSoC core is through GPIO. input disable (PRTx_INP_DIS) register. The buffer should
To connect a pin to an internal analog resource through remain enabled to allow simultaneous use of the pin as a
analog global bus or analog mux line, each GPIO connects digital input and analog input or output.
to one of the analog global lines and to one of the analog
mux lines. The switches that connect the I/O pin to Analog 21.3.8 LCD Drive
global lines and analog mux line are configured by the
All GPIO pins can be configured for LCD drive capabilities.
{PRT*_AG} and {PRT*_AMUX} registers.
{PRT*_LCD_EN} registers are used to enable individual
Refer to the Analog Routing chapter on page 359 for a pins for LCD drive. {PRT*_LCD_COM_SEG} registers are
description of the analog global network configuration. used to select whether a pin is set as a common or segment
Selected pins provide direct connections to specific analog drive pin.
features, such as DACs or uncommitted opamps.
In LCD mode, the GPIO pins are configured into a High Z Figure 21-9. SIO Configuration Diagram
output mode, allowing the LCD drivers to control the pin
SIO Pair
state.
All GPIO pins can be used to create CapSense buttons and PRT[x]SIO_DIFF
sliders. The primary analog bus for CapSense is the AMUX-
BUS, which has two nets (AMUXBUSL and AMUXBUSR) ANALOG Reference
Global Generator
for two simultaneous sensing operations. These can also be
shorted to form a single net that connects to all GPIOs. See
PRT[x]SIO_CFG
the CapSense® chapter on page 397 for more information.
SIO
21.3.10 External Memory Interface (EMIF)
The EMIF uses the port interface and the UDB to connect to
external memory. When in EMIF mode, the ports directly
21.3.11.2 Adjustable Input Level
pass to the pads the address and data out from the PHUB.
Data reads from the EMIF pass through the port to the SIO pins support a differential input mode with programma-
PHUB. See the EMIF chapter on page 133 for more infor- ble thresholds. The SIO pair input buffer voltage levels are
mation. set by the vref_sel and vtrip_sel bits of the
{PRT*_SIO_DIFF} register. See the following table.
21.3.11 SIO Functions and Features Table 21-6. SIO Differential Input Buffer Reference Voltage
GPIO and SIO provide similar digital functionality. The pri- Selection
mary differences are in their analog capability and drive vref_sel[y] vtrip_sel[y] Mode Description
strength. This section describes adjustable input and output 0 0 0.5 × vcc_io
level and hot swap features that are available only with SIO.
0 1 0.4 × vcc_io
1 0 0.5 × vohref
21.3.11.1 Regulated Output Level
1 1 vohref
SIO port pins support the ability to provide a regulated high
output level. This can be useful for interfacing to external
signals with voltages lower than the SIO Vddio. This regu-
lated output sets the Voh for the SIO pair. The SIO are
grouped into pairs. Each pair shares the same reference
generator, thus the regulated output level applies for both
pins.
vohref
(From Analog Global)
voutref
5 (To Output Buffer)
R
0
R
R
1
4
R 0
R vtrip_sel
vinref
vgnd 1 (To Input Buffer)
0
vref_sel
1
vtrip_sel
21.3.11.3 Hot Swap System reset (XRES_N, active low, resistive pull up) func-
tionality is supported on either the dedicated XRES_N pin or
SIO pins support hot swap capability. It is possible to con-
the P1[2] GPIO (since the XRES_N pin is not bonded on the
nect to another system without loading the signals con-
48-pin package). The IEEE 1149.1 JTAG TAP five pin inter-
nected to the SIO pins and without applying power to the
face may be enabled on the P1[0:1,3:5] pins.
PSoC device.
Serial wire debug is supported over the USBIO pins
The unpowered PSoC device can maintain a high imped-
(P15[6:7]) or the same pins as TMS / TCK (P1[0:1]). Analog
ance load to the external device while preventing the PSoC
function fixed pin assignments include two pairs of VIDAC
device from being powered through a GPIO pin’s protection
outputs to support high-current mode, two VREF inputs, and
diode.
four sets of analog output buffer pins. The “left side” VIDAC
and analog buffer pins are assigned to port 0 and are avail-
21.3.12 Special Functionality able on all package options. The “right side” VIDAC and lin-
Special purpose capability may uniquely exist on some pins ear buffer pins are assigned to port 3 and are available on
such as: all package options except the 48-pin package.
See the Nonvolatile Latch chapter on page 121 for more 21.3.17 Sleep Mode Behavior
information.
The GPIO/SIO pad will maintain the current pin state during
If the NVLs are set to 0x00 for the port, by default all I/Os sleep modes. Port pin interrupts remain active in all sleep
reset to the High Impedance Analog state but are repro- modes, allowing the PSoC device to wake from an exter-
grammable on a port-by-port basis. They can be reset as nally generated interrupt.
High Impedance Analog, Pull Down, or Pull Up, based on
the requirements of the application. 21.3.18 Low Power Behavior
In all low power modes, I/O pins retain their states until the
part is awakened and changed or reset. To awaken the part,
use a pin interrupt, because the port interrupt logic contin-
ues to function in all low power modes.
21.4 Port Interrupt Controller Unit 21.4.2 Interrupt Controller Block Diagram
This section describes the functions of the port interrupt Figure 21-11 is a block diagram of the PICU showing the
controller unit (PICU) for PSoC I/O. function of control signal generation and data manipulation
blocks. These blocks send appropriate control signals to
interrupt-generating pin logic blocks, simultaneously record-
21.4.1 Features
ing these signals in status and snap registers.
The features of the PICU are as follows:
■ All eight pins in each port interface with their own PICU
and associated interrupt vector
■ Pin status bits provide easy determination of interrupt
source down to the pin level
■ Rising/falling/either edge interrupts are handled
■ Pin interrupts can be individually enabled or disabled
■ Interfaces to the PHUB for read and write into its regis-
ters
■ Sends out a single interrupt request (PIRQ) signal to the
interrupt controller
Figure 21-11. PICU Block Diagram
Status
Register
PHUB PHUB Interface
Snap Shot
Register
PSoC® 3 and PSoC® 5 devices offer a host of Flash and configuration protection options and device security features that
can be leveraged to meet the security and protection requirements of an application. These requirements range from protect-
ing configuration settings or Flash data to locking the entire device from external access. The following section discusses in
detail these features together with their usage cases.
Byte 0 in Flash Hidden Row 0: Contains protection Byte 1 in Flash Hidden Row 0: Contains protection
bits for Flash rows 0 through 3 bits for Flash rows 4 through 7
Protection is cumulative in that modes have successively Table 22-1. Flash Protection Modes
higher protection levels and include the lower protection External
modes. Flash protection can only be set once. In order to Mode Description Reada Internal Writec
Writeb
change Flash protection settings after they have been set, 00 Unprotected Yes Yes Yes
the Flash contents must be completely erased and repro- 01 Read Protect No Yes Yes
grammed, then the protection levels can be set again. Refer
10 Disable External Write No No Yes
to the Nonvolatile Memory Programming chapter on
11 Disable Internal Write No No No
page 473 for erasing and programming Flash. Table 22-1
a. Applies to Test Controller and Read commands.
shows the protection modes. b. Test controller/3rd party programmers.
c. Boot loading or writes due to firmware execution.
choose any one of these protection levels independent of the key into the WO latch, program the Flash protection
the protection choice for all other rows in the Flash. data, and then reset the part to lock it.
The following list provides a few additional details on the Refer to the Nonvolatile Memory Programming chapter on
features and use cases for each of these protection levels. page 473 for information about writing to the Write Once
■ 00 – No Protection (WO) nonvolatile latch.
■ 01 – Read Protect
No external device can read a flash block that is read 22.3 Configuration Segment
protected. Protection
The SPC Read commands cannot be used to read a
block that is read protected. Part of the PSoC platform’s value to customers is its ability
Only the processor and the PHUB can access a block of to change the functionality of the device in real time. Chang-
Flash that is read protected. ing the functionality can be as simple as enabling an exter-
Offers only read protection. nal crystal or as dramatic as changing the functionality of
UDBs from timers to CRC generators. Based on the applica-
■ 10 – External Write Protection
tion needs, the customer may also want to protect certain
No external device can erase or write a row of Flash that Configuration registers.
is external write protected.
Includes all Read Protect restrictions. Not all configuration registers need the same level of secu-
rity and protection. Hence, the configuration registers are
Boot loaders work at this protection level.
grouped into four segments, with registers assigned to a
■ 11 – Fully Protected segment based on the presumed application use cases. The
The processor cannot erase or write a block of Flash following list defines the different segments. Refer to the
that is fully protected. PSoC® 3 Registers TRM (Technical Reference Manual)
Includes all protections from lower levels of Flash data and the PSoC® 5 Registers TRM (Technical Reference
protection. Manual), to find out the segment to which a particular config-
This level is used when a block of Flash should never be uration register is assigned.
modified by an internal process or external device.
Segment 0. One time system settings. This segment has
system registers that are configured only once during pro-
22.2 Device Security gram execution. The registers in this segment come under
The objective of device security is to prevent the PSoC 3 the following broad categories:
and PSoC 5 device in an application from being used as a ■ Power System
host to compromise the application. The device security fea- ■ Reset
ture is enabled by writing to the Write Once (WO) latch.
■ Watchdog
The WO latch is a type of nonvolatile latch. When the output ■ Internal low speed oscillator (ILO)
is ‘1’, the Write Once NVL locks the part out of Debug and
Test modes; it also permanently gates off the ability to erase Segment 1. Reconfigurable system settings. This segment
or alter the contents of the latch. has registers that can be reconfigured during program exe-
The user can write a correct 32-bit key (0x50536F43) into cution. The registers in this segment come under the follow-
the WO latch to disable the part from entering into Debug ing broad categories:
and Test modes. This precaution prevents anyone from ■ LVI Detect
erasing or altering the content of the internal memory. ■ Voltage regulators
If the device is protected with a WO latch setting, Cypress ■ Power Manager
cannot perform failure analysis and, therefore, cannot ■ Wakeup Sources
accept an RMA from customers. The WO latch is read out
■ Boost Converter
via serial wire debug (SWD) to electrically identify protected
parts. The user writes the key in the WO latch to lock out Segment 2. UDB array configuration registers.
external access only if no Flash protection is set. However,
■ All UDB array configuration registers, such as the clock
after setting the values in the WO latch, a user still has
selection and datapath input/output multiplexer selec-
access to the device until it is reset. The output of the WOL
tion, come under this segment.
is only sampled upon reset. Therefore, a user could write
Segment 3. Analog interface (Registers related to analog If the segment protect bit is ‘0’, the segment’s lock bit can be
interface configuration). written as a ‘0’ or ‘1’ at anytime. If the protect bit is ‘1’, the
segment’s lock bit cannot be modified.
It must be noted that Segment 0 registers can be configured
either as the one time configurable or reconfigurable type. The segment protect (LOCK_PROTECT_x) bit is a write-to1
The same applies to Segment 1 and Segment 2 registers as once bit. It cannot change from a ‘1’ to a ‘0’ except as a
well. But as a best practice, it is advisable to set Segment 0 result of a hardware reset, such as a POR or XRES_N. For
registers as one time configurable. The settings for the rest one time configuration of a segment, it must be locked and
of the segments depend on application requirements. To protected after configuration.
find out the segment to which a register is allocated, see the
segment field for the register in the PSoC® 3 Registers TRM Lock Bit. The segment lock (LOCK_x) bit controls the write
(Technical Reference Manual) and the PSoC® 5 Registers access to the Configuration registers in the segment. Setting
TRM (Technical Reference Manual). the LOCK_x bit prevents write access to the Control regis-
ters; clearing the lock bit allows a write.
Write access to the Configuration registers in various seg-
ments is enabled using the Segment Configuration register For dynamic configuration of a segment, it must not be pro-
(MLOGIC_SEG_CFG0). Write access to the Segment Con- tected and can be locked after every configuration.
figuration register (MLOGIC_SEG_CFG0) is enabled using
Table 22-2 describes the behavior for different protect and
the Segment Control register (MLOGIC_SEG_CR).
lock bit settings.
22.3.1 Locking/Unlocking Segment Table 22-2. Protect and Lock Bit Settings
Configuration Register Protect/Lock Bits Description
The 8-bit Segment Control register (MLOGIC_SEG_CR) is The Configuration registers are not protected and
00b
not locked. They can be written at anytime.
used to control write access to the Segment Configuration
The Configuration registers are not protected but
register (MLOGIC_SEG_CFG0) bits. By default, write locked. This is used to temporarily lock the configu-
01b
access to the Segment Configuration register is disabled. ration and is used in the case of dynamic reconfig-
uration.
Attempted writes will appear to execute normally, but the
The Configuration register are protected and not
contents of the register will remain unchanged. 10b
locked. They can be written at anytime.
Segment configuration write access is enabled by writing The Configuration registers are protected and
11b
locked. This is used for one time configuration.
0xB5 to the Segment Control register and is disabled by
writing 0xB4 to the Segment Control register. Upon device
reset, the Segment Control register resets to the locked
state and disables write to the Segment Configuration regis-
ter.
When illegal values (values other then 0xB4 and 0xB5) are
written to the Segment Control register, it causes a device
reset and is indicated by the Segment reset (SEGRS) bit in
Reset Status (RESET_SR1) register. The segment reset bit
remains set until cleared by the user or POR.
Table 22-3. Segment 0: One Time System Settings Table 22-4. Segment 1: Reconfigurable System Settings
Category Register Names PHUB Address Category Register Names PHUB Address
RESET.CR3 0x46F7 RESET.CR0 0x46F4
RESET.CR4 0x46F8 LVI Detect RESET.CR1 0x46F5
RESET.CR5 0x47F9 RESET.CR2 0x46F6
RESET.TR 0x46FB
Reset
RESET.IPOR_CR0 0x46F0 Volt Regulators PWRSYS.CR1 0x4331
RESET.IPOR_CR1 0x46F1
RESET.IPOR_CR2 0x46F2 PM.TW_CFG0 0x4380
RESET.IPOR_CR3 0x46F3 PM.TW_CFG1 0x4381
PM.TW_CFG2 0x4382
MFGCFG.HIB_TR0 0x4680 Power Manager PM.WDT_CR 0x4384
MFGCFG.HIB_TR1 0x4681 PM.MODE_CFG0 0x4391
MFGCFG.I2C_TR 0x4682 PM.MODE_CFG1 0x4392
MFGCFG.SLP_TR 0x4683 PM.MODE_CSR 0x4393
MFGCFG.BUZZ_TR 0x4684
MFGCFG.WAKE_TR0 0x4685 PM.WAKEUP_CFG0 0x4398
Power System Wakeup Sources
MFGCFG.WAKE_TR1 0x4686 PM.WAKEUP_CFG1 0x4399
MFGCFG.BREF_TR 0x4687
MFGCFG.BG_TR 0x4688 BOOST.CR0 0x4320
MFGCFG.WAKE_TR2 0x4689 BOOST.CR1 0x4321
Boost
MFGCFG.WAKE_TR3 0x468a BOOST.CR2 0x4322
PWRSYS.CR0 0x4330 BOOST.CR3 0x4323
22.3.3 Example
The device peripherals are enabled/disabled by the protect bit for this segment, MLOGIC_SEG_CFG0[3], is
PM_ACT_CFG* registers in Active mode. These registers not set. If the protect bit has been set by the user, the
are mapped in Segment1. The following steps explain the lock bit cannot be modified, other than by a device reset.
procedure to configure these registers and then lock the 3. Write to the Active Power Mode Template registers
configuration information so that runaway code does not (PM_ACT_CFG*) to enable/disable the required periph-
overwrite the values. erals.
1. Write 0xB5 to the Segment Control register 4. Set the lock bit (MLOGIC_SEG_CFG0[2]) and clear the
(MLOGIC_SEG_CR) to enable the write access to the protect bit (MLOGIC_SEG_CFG0[3]) for Segment 1 in
Segment Configuration register. the Segment Configuration register
(MLOGIC_SEG_CFG0).
2. Clear the lock bit for Segment 1 to get write access to
the Configuration registers in Segment 1. This is done by 5. Write 0xB4 to the Segment Control register to disable
clearing the lock bit corresponding to Segment 1, which the write access to the Segment Configuration register.
is MLOGIC_SEG_CFG0[2]. Here, it is assumed that the
The protection settings for Flash memory must be set based on the following criteria:
■ If the application warrants the need for a field upgrade, then set the Disable External Write mode for the Flash rows that
are going to be updated in the field. This allows you to use the bootloader application to update the flash using communi-
cation interfaces such as I2C and USB.
■ If the application code must be protected from being copied or modified to protect IP, the Flash security level for the rows
containing the IP code must be set to Full Protection mode.
Question 2. Is it possible to modify the Flash protection settings that have already been set?
It is not possible to directly alter the Flash protection setting. The only way to change the Flash protection settings is to com-
pletely erase the entire Flash memory using the Erase All command, reprogram the Flash memory, and then set the new pro-
tection settings. Refer to the Nonvolatile Memory Programming chapter on page 473 to learn more about Flash erase/
program commands.
Question 3. Is it possible to reprogram a Flash memory that has been configured with Full Protection?
The only way to reprogram the fully protected rows is to erase the entire Flash memory using the Erase All command, repro-
gram the Flash memory, and then set the new protection settings as described in Question 2 above.
Question 4. Is it necessary to enable protection for the entire Flash memory, or only the for the region of Flash memory that
the application uses?
It is sufficient to configure Flash security for memory regions that are used by the application, leaving the unused locations
unprotected, provided that there is no possibility of the program execution going to the unprotected region. If there is a possi-
bility of code executing from the unprotected region (due to, for instance, function calls), malicious code can be written in the
unprotected region to read the Flash data in the fully protected region. Remember that internal read is permitted in all protec-
tion modes; therefore, it is always a good practice to set protection for the entire Flash memory.
Question 5. Is it ever necessary to configure different protection settings for different memory regions?
Yes, depending on the application requirements. Different flash rows may need different protection settings. A typical exam-
ple would be the case of field upgrade using the bootloader component. The portion of Flash that needs to be upgraded in the
field with bootloadable code must be configured in External Write Protect mode. The remaining Flash memory (base code or
bootloader code, unused flash memory) can be set to Full Protection.
The Read Protection setting is not obeyed in Debug mode, which means the Flash memory can be read regardless of Flash
protection setting. The Write Protection setting is still intact. Setting Full Protection makes it impossible to write to the Flash
memory in Debug mode.
Because the Debug mode is used during the application development phase, there is no need to protect the Flash. After the
application development phase is over, and code has been finalized, the user can disable the debug feature.
Device security is the feature in PSoC 3 and PSoC 5 architecture that prevents the device from entering Debug and Test
modes. To enable device security, write a 32-bit key (0x50536F43) into the Write Once (WO) latch. After writing this key, the
device cannot be reprogrammed by entering test mode. Entering debug mode while using JTAG boundary scan is also not
possible. This prevents external access to registers and nonvolatile memory. Refer to Device Security on page 206 of this
chapter to learn more about device security.
Question 8. What are the risks associated with enabling device security?
If the device is protected with a WO latch setting, Cypress cannot perform failure analysis and, therefore, cannot accept
RMAs from customers. The WO latch can be read via the SWD to electrically identify protected parts.
The answer is both. While flash protection settings and device security are configured independently, enabling device security
does not allow external read or write of Flash memory, regardless of the flash protection settings. There is one important
exception. Even with device security enabled, it is still possible to update the Flash memory using a bootloader application,
provided the Flash memory is not fully protected.
Question 10. Is it possible to implement OTP (one time programmable) functionality such that Flash content can never be
altered after it is programmed?
The Full Protection setting for Flash memory, along with the device security feature can prevent the Flash from ever being
modified. This combination is the highest level of security setting available in PSoC 3 and PSoC 5 devices. The steps to do
this are given below
1. Erase the entire Flash memory using the Erase All command
2. Reprogram the Flash content.
3. Write a 32-bit key (0x50536F43) into the WO latch to enable device security.
4. Set Flash Protection setting to Full Protection.
5. Reset the part to lock it.
The digital subsystems of PSoC® 3 and PSoC® 5 architectures provide these devices their first half of unique configurability.
The subsystem connects a digital signal from any peripheral to any pin through the Digital System Interconnect (DSI). It also
provides functional flexibility through an array of small, fast, low-power Universal Digital Blocks (UDBs).
PSoC Creator™ provides a library of pre-built and tested standard peripherals that are mapped onto the UDB array by the
tool (UART, SPI, LIN, PRS, CRC, timer, counter, PWM, AND, OR, and so on). Nonstandard peripherals are easily imple-
mented using a Hardware Description Language (HDL) such as Verilog. Each UDB contains Programmable Array Logic
(PAL) and Programmable Logic Device (PLD) functionality, together with a small state machine engine to support a wide vari-
ety of peripherals.
In addition to the flexibility of the UDB array, PSoC devices provide configurable digital blocks targeted at specific functions.
These blocks can include 16-bit timer/counter/PWM blocks, I2C slave/master/multi-master, Full Speed USB, and CAN 2.0b.
Refer to the device datasheet for a list of available specific function digital blocks.
System Bus
DIGITAL SYSTEM
Universal Digital Block Array (N x UDB)
8-Bit Timer Quadrature Decoder 16-Bit 16-Bit PRS
CAN I2C
PWM 2.0 Master/Slave
8-Bit Timer
USB D+
UDB UDB UDB UDB
Nx FS PHY D-
I2C Slave
8-Bit SPI
Logic Timer USB 2.0
12-Bit SPI
Counter
UDB UDB UDB UDB
PWM
Logic
UDB UDB
UDB UDB
UART 12-Bit PWM
This chapter shows how the PSoC® 3 and PSoC® 5 Universal Digital Blocks (UDBs) enable the development of programma-
ble digital peripheral functions. The UDB architecture provides balance between configuration granularity and efficient imple-
mentation; UDBs consist of a combination of uncommitted logic similar to programmable logic devices (PLDs), structured
logic (datapaths), and a flexible routing scheme.
23.1 Features
■ For optimal flexibility, each UDB contains several components:
❐ ALU-based 8-bit datapath (DP) with an 8-word instruction store and multiple registers and FIFOs
❐ Two PLDs, each with 12 inputs, eight product terms and four macrocell outputs
❐ Control and status modules
❐ Clock and reset modules
■ A PSoC 3 or PSoC 5 device contains an array of up to 24 UDBs
■ Flexible routing through the UDB array
■ Portions of UDBs can be shared or chained to enable larger functions
■ Flexible implementations of multiple digital functions, including timers, counters, PWM (with dead band generator), UART,
I2C, SPI, and CRC generation/checking
PLD
Chaining
PLD PLD
Clock 12C4 12C4
and Reset (8 PTs) (8 PTs)
Control
Status and
Control
Datapath Datapath
Chaining
Routing Channel
PT0
PT1
PT2
PT3
PT4
PT5
PT6
PT7
IN0 TC TC TC TC TC TC TC TC
IN1 TC TC TC TC TC TC TC TC
IN2 TC TC TC TC TC TC TC TC
IN3 TC TC TC TC TC TC TC TC
IN4 TC TC TC TC TC TC TC TC
IN5 TC TC TC TC TC TC TC TC AND
IN6 TC TC TC TC TC TC TC TC Array
IN7 TC TC TC TC TC TC TC TC
IN8 TC TC TC TC TC TC TC TC
IN9 TC TC TC TC TC TC TC TC
IN10 TC TC TC TC TC TC TC TC
IN11 TC TC TC TC TC TC TC TC
SELIN
(carry in)
OUT0 MC0 T T T T T T T T
OUT1 MC1 T T T T T T T T
OUT2 MC2 T T T T T T T T
OUT3 MC3 T T T T T T T T
SELOUT
(carry out)
OR
Array
XOR Feedback
00: D FF
01: Arithmetic (Carry)
10: T FF on high
11: T FF on low
Set Select
(from previous macrocell) XORFB[1:0] 0: Set not used
SSEL
selin 1: Set from input
1: D FF inverted in out
set 0
sum D Q
clk QB
res
pld_en
reset 1
Output Bypass
BYP
0 0: Registered
COEN
1: Combinational
Carry Out Enable RSEL Reset Select
0:Carry Out disabled 0: Set not used
1: Carry Out enabled 1: Set from input
selout
(to next macrocell)
PLD1 PLD0
7 6 5 4 3 2 1 0
RD MC (Read Only)
System Bus
23.3.1.2 PLD Carry Chain of the PLDs, and then to the next UDB as the carry chain out
“selout”. To support the efficient mapping of arithmetic func-
PLDs are chained together in UDB address order. As shown
tions, special product terms are generated and used in the
in Figure 23-6 the carry chain input “selin” is routed from the
macrocell in conjunction with the carry chain.
previous UDB in the chain, through each macrocell in both
Figure 23-5. PLD Carry Chain and Special Product Term Inputs
{PT5,PT4}
{PT3,PT2}
{PT1,PT0}
{PT7,PT6}
{PT5,PT4}
{PT3,PT2}
{PT1,PT0}
cpt1,cpt0 cpt1,cpt0 cpt1,cpt0 cpt1,cpt0 cpt1,cpt0 cpt1,cpt0 cpt1,cpt0 cpt1,cpt0
selout MC3 MC2 MC1 MC0 MC3 MC2 MC1 MC0 selin
To the next From previous
PLD block PLD block in
in the chain the chain
F1
FIFOs
Datapath Control
Muxes Muxes
A0
8 Word X 16 bit
Overflow Detect
6
Conditions
6
2 Compares
Programmable A1 Programmable
Routing D0 Routing
D1
D1
Data Registers
D0
To/From To/From
Prev Chaining Next
Datapath Datapath
A1
Accumulators
A0
PI
Parallel Input/Output
(to/from Programmable
Routing)
PO
ALU
ALU
Shift
Mask
Input/Output FIFOs
Each datapath contains two 4-byte FIFOs, which can be
individually configured for direction as an input buffer (CPU
or DMA writes to the FIFO, datapath internals read the
Each datapath module has six 8-bit working registers. All The control to load the FIFO from the datapath source is
sampled on the currently selected datapath clock (normal)
registers are readable and writable by CPU or DMA: Normal/Fast or the bus clock (fast). This allows captures to occur at the
highest rate in the system (bus clock), independent of the
Table 23-1. Datapath Working Registers datapath clock.
When this mode is enabled, and the FIFO is in output
Type Name Description mode, a read by the CPU or DMA of the associated accu-
The accumulators may be both a source and a mulator (A0 for F0, A1 for F1) initiates a synchronous trans-
destination for the ALU. They may also be loaded Software fer of the accumulator value into the FIFO. The captured
from a Data register or a FIFO. The accumulators Capture value may then be immediately read from the FIFO. If
Accumulator A0, A1 typically contain the current value of a function, chaining is enabled, the operation follows the chain to the
such as a count, CRC, or shift. These registers MS block for atomic reads by datapaths of multi-byte val-
are nonretention; they lose their values in sleep ues.
and are reset to 0x00 on wakeup. When the datapath is being clocked asynchronously to the
The Data registers typically contain constant data bus clock, the FIFO status signals can be routed to the rest
for a function, such as a PWM compare value, Asynch of the datapath either directly, single sampled to the DP
Data D0, D1 clock, or double sampled in the case of an asynchronous
timer period, or CRC polynomial. These registers
retain their values across sleep intervals. DP clock
The two 4-byte FIFOs provide both a source and Independent Each FIFO has a control bit to invert polarity of the FIFO
a destination for buffered data. The FIFOs can be Clock Polarity clock with respect to the datapath clock.
configured as both input buffers, both output buf-
fers, or as one input buffer and one output buffer.
Status signals indicate the read and write status
FIFOs F0, F1 of these registers. Usage examples include buff- Figure 23-7 shows the possible FIFO configurations con-
ered TX and RX data in the SPI or UART and trolled by the input/output modes. The TX/RX mode has one
buffered PWM compare and buffered timer
period data. These registers are nonretention; FIFO in input mode and the other in output mode. The pri-
they lose their values in sleep and are reset to mary usage example of this configuration is SPI. The dual
0x00 on wakeup.
capture configuration provides independent capture of A0
and A1, or two separately controlled captures of either A0 or
23.3.2.2 Datapath FIFOs A1. Finally, the dual buffer mode can provide buffered peri-
ods and compares, or two independent periods/compares.
FIFO Modes and Configurations
Each FIFO has a variety of operation modes and configura-
tions available:
F0 F0 F1
D0/D1 D0 D1
A0/A1/ALU A0/A1/ALU A0/A1/ALU A0 A1
F1 F0 F1
Figure 23-8 shows a detailed view of the FIFO sources and sinks.
ALU
A0
A1
A0
A1
UDB Local Data Bus
FIFO F0 FIFO F1
D0 D1
A0 A1
When the FIFO is in input mode, the source is the system bus and the sinks are the Dx and Ax registers. When in output
mode, the sources include the Ax registers and the ALU, and the sink is the system bus. The multiplexer selection is statically
set in UDB configuration register CFG15 as shown in the following table for the F0_INSEL[1:0] or F1_INSEL[1:0]:
FIFO Status
Each FIFO generates two status signals, “bus” and “block,” which are sent to the UDB routing through the datapath output
multiplexer. The “bus” status can be used to assert an interrupt or DMA request to read/write the FIFO. The “block” status is
primarily intended to provide the FIFO state to the UDB internals. The meanings of the status bits depend on the configured
direction (Fx_INSEL[1:0]) and the FIFO level bits. The FIFO level bits (Fx_LVL) are set in the Auxiliary Control Working regis-
ter in working register space. Options are shown in the following table:
Output 0 Not Empty Bus Status Asserted when there is at least 1 byte available to be read from the FIFO.
Output 1 At Least Half Full Bus Status Asserted when there are at least 2 bytes available to be read from the FIFO.
Asserted when the FIFO is full. When not full, the datapath internals may write
Output NA Full Block Status bytes to the FIFO. When full, the datapath may idle or generate an overrun condi-
tion.
D1 D1 X
WR_PTR
D2 X
RD_PTR
D3 D3
D4 X X
RD_PTR
D5 D5 X
As shown in Figure 23-10, the fast load operation is independent of the currently selected datapath clock, however, using the
bus clock may cause higher power consumption.
Figure 23-10. FIFO Fast Configuration Sinks
UDB DP
Clock Mux
digital DP clk
clocks DP Operation
bus clk
fx_ld Write
0 FIFO
(In Output Mode)
bus clk
1
FIFO Fast
FIFO Edge/Level Write Mode form is arbitrary (however, it must be at least one datapath
clock cycle in width). An example of this mode is capturing
There are two modes for writing the FIFO from the datapath.
the value of the accumulator using an external pin input as a
In the first mode, data is synchronously transferred from the
trigger. The limitation of this mode is that the input control
accumulators to the FIFOs. The control for that write
must revert to '0' for at least one cycle before another posi-
(FX_LD) is typically generated from a state machine or con-
tive edge is detected.
dition that is synchronous to the datapath clock. The FIFO
will be written in any cycle where the input load control is a Figure 23-11 shows the edge detect option on the FX_LD
'1'. In the second mode, the FIFO is used to capture the control input. One bit for this option sets the mode for both
value of the accumulator in response to a positive edge of FIFOs in a UDB. Note that edge detection is sampled at the
the FX_LD signal. In this mode the duty cycle of the wave- rate of the selected FIFO clock.
Figure 23-11. Edge Detect Option for Internal FIFO Write Sinks
0
fx_write
fx_ld (from Routing) 1
FF
FIFO Edge
dp_clk 0
bus_clk 1
FIFO Fast
As shown in Figure 23-12, reading the accumulator triggers a write to the FIFO from that accumulator. This signal is chained
so that a read of a given byte simultaneously captures accumulators in all chained UDBs. This allows an 8-bit processor to
reliably read 16 bits or more simultaneously. The data returned in the read of the accumulator should be ignored; the captured
value may be read from the FIFOs immediately.
The routed FX_LD signal, which generates a FIFO load, is ORed with the software capture signal; the results could be unpre-
dictable when both hardware and software capture are used at the same time. As a general rule these functions should be
mutually exclusive, however, hardware and software capture can be used simultaneously with the following settings:
■ FIFO capture clocking mode is set to FIFO FAST
■ FIFO write mode is set to FIFO EDGE
With these settings, hardware and software capture work essentially the same and in any given bus clock cycle, either signal
asserted initiates a capture.
It is also recommended to clear the target FIFO in firmware (ACTL register) before initiating a software capture. This initializes
the FIFO read and write pointers to a known state.
Chain X
0 fx_write
1
fx_ld
FIFO EDGE
bus clk
(FIFO FAST)
FIFO Control Bits and F1 is set for output mode, which is a typical configura-
tion for TX and RX registers.
There are four bits in the Auxiliary Control register that may
be used to control the FIFO during normal operation. On the TX side, the datapath state machine uses "empty" to
determine if there are any bytes available to consume.
The FIFO0 CLR and FIFO1 CLR bits are used to reset or
Empty is set synchronously to the DP state machine, but is
flush the FIFO. When a '1' is written to one of these bits, the
cleared asynchronously due to a bus write. When cleared,
associated FIFO is reset. The bit must be written back to '0'
the status is synchronized back to the DP state machine.
for FIFO operation to continue. If the bit is left asserted, the
given FIFO is disabled and operates as a one byte buffer On the RX side, the datapath state machine uses “full” to
without status. Data can be written to the FIFO; the data is determine whether there is a space left to write to the FIFO.
immediately available for reading and can be overwritten at Full is set synchronously to the DP state machine, but is
anytime. Data direction using the Fx INSEL[1:0] configura- cleared asynchronously due to a bus read. When cleared,
tion bits is still valid. the status is synchronized back to the DP state machine.
The FIFO0 LVL and FIFO1 LVL bits control the level at A single FIFO ASYNCH bit is used to enable this synchroni-
which the 4-byte FIFO asserts bus status (when the bus is zation method; when set it applies to both FIFOs. It is only
either reading or writing to the FIFO) to be asserted. The applied to the block status, as it is assumed that bus status
meaning of FIFO bus status depends on the configured is naturally synchronized by the interrupt process.
direction, as shown in the table below.
FIFO Overflow Operation
Table 23-5. FIFO Level Control Bits
Use FIFO status signaling to safely implement both internal
FIFOx Input Mode Output Mode (datapath) and external (CPU or DMA) reads and writes.
LVL (Bus is Writing FIFO) (Bus is Reading FIFO)
There is no built-in protection from underflow and overflow
Not Full Not Empty conditions. If the FIFO is full, and subsequent writes occur
0
At least 1 byte can be written At least 1 byte can be read
(overflow), the new data overwrites the front of the FIFO (the
At Least Half Empty At Least Half Full data currently being output, the next data to read). If the
1
At least 2 bytes can be written At least 2 bytes can be read
FIFO is empty, and subsequent reads occur (underflow), the
read value is undefined. FIFO pointers remain accurate
FIFO Asynchronous Operation regardless of underflow and overflow.
Figure 23-13 illustrates the concept of asynchronous FIFO
operation. As an example, assume F0 is set for input mode
System Bus
async
F0 (TX)
blk_stat
empty empty Empty to
Asynchronously cleared 0
DP state
Synch to by bus write, 1 machine
DP sycnhyronously set by set
DP read d q
async
Synch to
DP
full full Full to
Asynchronously cleared 0
blk_stat DP state
by bus read, 1 machine
F1 (RX) sycnhyronously set by set
DP write d q
DP clk
System Bus
FIFO Clock Inversion Option polarity as the DP clock. When this bit is set, the FIFO oper-
ates at the opposite polarity as the DP clock. This provides
Each FIFO has a control bit called Fx CK INV that controls
support for “both clock edge” communication protocols,
the polarity of the FIFO clock, with respect to the polarity of
such as SPI.
the DP clock. By default the FIFO operates at the same
ALU
A0
A1
UDB Local Data Bus
FIFO Fx FIFO Fx
In internal access mode, the datapath can read and write FIFO status signals have the following definitions (also
the FIFO. In this configuration, the Fx INSEL bits must be dependent on Fx LVL control):
configured to select the source for the FIFO writes. Fx
INSEL = 0 (CPU bus source) is invalid in this mode; they Table 23-6. FIFO Status
can only be 1, 2 or 3 (A0, A1, or ALU). Note that the only Status Signal Meaning Fx LVL = 0 Fx LVL = 1
read access is to the associated accumulator; the data reg- fx_blk_stat Write Status FIFO full FIFO full
ister destination is not available in this mode. fx_bus_stat Read Status FIFO not empty At least ½ full
Arithmetic and Logic Operation When a routed carry is used, the meaning with respect to
each arithmetic function is shown in Table 23-10. Note that
The ALU functions, which are configured dynamically by the
in the case of the decrement and subtract functions, the
RAM control store, are shown in the following table:
carry is active low (inverted).
Table 23-7. ALU Functions
Table 23-10. Routed Carry In Functions
Func[2:0] Function Operation
Carry In Carry In Carry In
000 PASS srca Function
Polarity Active Inactive
001 INC ++srca
INC True ++srca srca
010 DEC --srca
DEC Inverted --srca srca
011 ADD srca + srcb
ADD True (srca + srcb) + 1 srca + srcb
100 SUB srca - srcb
SUB Inverted (srca - srcb) - 1 (srca - srcb)
101 XOR srca ^ srcb
110 AND srca & srcb Carry Out
111 OR srca | srcb
The carry out is a selectable datapath output and is derived
from the currently defined MSB position, which is statically
Carry In
programmable. This value is also chained to the next most
The carry in is used in arithmetic operations. There is a significant block as an optional carry in. Note that in the
default carry in value for certain functions as shown in case of decrement and subtract functions, the carry out is
Table 23-8. inverted.
DEC --srca srca + ffh + ci, where ci is forced to 0 INC True ++srca == 0 srca
ADD srca + srcb srca + srcb + ci, where ci is forced to 0 DEC Inverted --srca == -1 srca
SUB srca - srcb srca + ~srcb + ci, where ci is forced to 1 ADD True srca + srcb > 255 srca + srcb
SUB Inverted srca - srcb < 0 (srca - srcb)
In addition to this default arithmetic mode for carry opera-
tion, there are three additional carry options. The CI SELA Carry Structure
and CI SELB configuration bits determine the carry in for a
Options for carry in, and for MSB selection for carry out gen-
given cycle. Dynamic configuration RAM selects either the A
eration, are shown in Figure 23-15 on page 229. The regis-
or B configuration on a cycle-by-cycle basis. The options are
tered carry out value may be selected as the carry in for a
defined in Table 23-9.
subsequent arithmetic operation. This feature can be used
Table 23-9. Additional Carry In Functions to implement higher precision functions in multiple cycles.
CI SEL A
Carry Mode Description
CI SEL B
Default arithmetic mode as described
00 Default
in Table 23-8.
Carry Flag, result of the carry from
the previous cycle. This mode is used
to implement add with carry and sub-
01 Registered
tract with borrow operations. It can be
used in successive cycles to emulate
a double precision operation.
Carry is generated elsewhere and
routed to this input. This mode can
10 Routed
be used to implement controllable
counters.
Carry is chained from the previous
datapath. This mode can be used to
11 Chained implement single cycle operations of
higher precision involving two or
more datapaths.
Selected MSB
Arithmetic ALU Function
(inc, dec, add, sub)
Default function value
ci Chained (from prev datapath)
ALU ALU ALU ALU ALU ALU ALU ALU
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Registered (from co_msb_reg)
Routed (from interconnect)
co_msb
(to DP output mux)
co_msb_reg
D e fa u lt ( tie v a lu e )
s h ift in le ft ( s il) s o r_ re g
R e g is te r e d (s o r _ r e g )
R o u te d (fr o m in te r c o n n e c t) S e le c te d M S B
C h a in e d (fr o m n e x t D a ta p a th ) S h ift r ig h t o r s h ift le ft s h ift o u t r ig h t ( s o r )
(to D P o u tp u t m u x )
s il 7 6 5 4 3 2 1 0
D e fa u lt ( tie v a lu e )
s h ift o u t le ft ( s o l_ m s b ) R e g is te r e d ( fr o m s o l_ m s b _ r e g )
(to D P o u tp u t m u x ) s h ift in r ig h t (s ir ) R o u te d ( fr o m in te r c o n n e c t)
s o l_ m s b _ r e g C h a in e d (fr o m p r e v D a ta p a th )
Note that the bits that are isolated by the MSB selection are
still shifted. In the example shown, bit 7 still shifts in the sil Table 23-14. Datapath Inputs
value on a right shift and bit 5 shifts in bit 4 on a left shift. Input Description
The shift out either right or left from the isolated bits is lost. Asynchronous dynamic configuration RAM address. There are
RAD2 eight 16-bit words, which are user programmable. Each word
RAD1 contains the datapath control bits for the current cycle.
ALU Masking Operation RAD0 Sequences of instructions can be controlled by these address
inputs.
An 8-bit mask register in the UDB static configuration regis-
When asserted in a given cycle, the selected FIFO is loaded
ter space defines the masking operation. In this operation, with data from one of the A0 or A1 accumulators or from the
the output of the ALU is masked (ANDed) with the value in F0 LD output of the ALU. The source is selected by the Fx
F1 LD INSEL[1:0] configuration bits. This input is edge sensitive. It is
the mask register. A typical use for the ALU mask function is sampled at the datapath clock; when a '0' to '1' transition is
to implement free-running timers and counters in power of detected, a load occurs at the subsequent clock edge.
two resolutions. When asserted in a given cycle, the Dx register is loaded from
D0 LD associated FIFO Fx. This input is edge sensitive. It is sampled
D1 LD at the datapath clock; when a '0' to '1' transition is detected, a
23.3.2.5 Datapath Inputs and Multiplexing load occurs at the subsequent clock edge.
This is a data input value that can be used for either shift in left
The datapath has a total of nine inputs as shown in Table SI
or shift in right.
24-16, including six inputs from the channel routing. These
This is the carry in value used when the carry in select control
consist of the configuration RAM address, FIFO and data CI
is set to "routed carry."
register load control signals, and the data inputs shift in and
carry in. As shown in Figure 23-17, each input has a 6-to-1 multi-
plexer, therefore, all inputs are permutable. Inputs are han-
dled in one of two ways, either level sensitive or edge
sensitive. RAM address, shift in and data in values are level
sensitive; FIFO and data register load signals are edge sen-
sitive.
CFGx
RAD0 MUX[2:0]
These inputs are
edge sensitive
{0, dp_in[5:0], 0} f0_ld
(similar for f1_ld, d0_ld, d1_ld)
CFGx
F0 LD MUX[2:0]
23.3.2.6 CRC/PRS Support Figure 23-18 shows the structural configuration for the CRC
operation. The PRS configuration is identical except that the
The datapath can support Cyclic Redundancy Checking
shift in (SI) is tied to '0'. In the PRS configuration, D0 or D1
(CRC) and Pseudo Random Sequence (PRS) generation.
contain the polynomial value, while A0 or A1 contain the ini-
Chaining signals are routed between datapath blocks to
tial (seed) value and the CRC residual value at the end of
support CRC/PRS bit lengths of longer than 8 bits.
the computation.
The most significant bit (MSB) of the most significant block
To enable CRC operation, the CFB_EN bit in the dynamic
in the CRC/PRS computation is selected and routed (and
configuration RAM must be set to '1'. This enables the AND
chained across blocks) to the least significant block. The
of SRCB ALU input with the CRC feedback signal. When set
MSB is then XORed with the data input (SI data) to provide
to zero, the feedback signal is driven to '1', which allows for
the feedback (FB) signal. The FB signal is then routed (and
normal arithmetic operation. Dynamic control of this bit on a
chained across blocks) to the most significant block. This
cycle-by-cycle basis gives the capability to interleave a
feedback value is used in all blocks to gate the XOR of the
CRC/PRS operation with other arithmetic operations.
polynomial (from the Data0 or Data1 register) with the cur-
rent accumulator value.
D0/D1
(POLY)
A0/A1
(CRC)
MSB
(most significant bit) FB SI
(feedback) (shift in)
srcb srca Tie input to
zero for PRS
ALU operation
(XOR)
SHIFTER
(LEFT)
CRC/PRS Chaining
Figure 23-19 illustrates an example of CRC/PRS chaining across three UDBs. This scenario can support a 17- to 24-bit oper-
ation. The chaining control bits are set according to the position of the datapath in the chain as shown.
How the CRC/PRS feedback signal (cfbo, cfbi) is chained: CRC/PRS Polynomial Specification
■ If a given block is the least significant block, then the As an example of how to configure the polynomial for pro-
feedback signal is generated in that block from the built- gramming into the associated D0/D1 register, consider the
in logic that takes the shift in from the right (sir) and CCITT CRC-16 polynomial, which is defined as x16 + x12
XORs it with the MSB signal. (For PRS, the "sir" signal is +x5 + 1. The method for deriving the data format from the
tied to '0'.) polynomial is shown in Figure 23-20.
■ If a given block is not the least significant block, the
The X0 term is inherently always '1' and therefore does not
CHAIN FB configuration bit must be set and the feed-
need to be programmed. For each of the remaining terms in
back is chained from the previous block in the chain.
the polynomial, a '1' is set in the appropriate position in the
How the CRC/PRS MSB signal (cmsbo, cmsbi) is chained: alignment shown.
■ If a given block is the most significant block, the MSB bit Note This polynomial format is slightly different from the
(according to the polynomial selected) is configured format normally specified in HEX. For example, the CCITT
using the MSB_SEL configuration bits. CRC16 polynomial is typically denoted as 1021H. To con-
■ If a given block is not the most significant block, the vert to the format required for datapath operation, shift right
CHAIN MSB configuration bit must be set and the MSB by one and add a '1' in the MSB bit. In this case, the correct
signal is chained from the next block in the chain. polynomial value to load into the D0 or D1 register is 8810H
X16 + X12 + X5 + 1
1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0
Example CRC/PRS Configuration used, but this feature gives the capability for more elaborate
configurations, such as up to a 16-bit CRC/PRS function in
The following is a summary of CRC/PRS configuration
one UDB using time division multiplexing.
requirements, assuming that D0 is the polynomial and the
CRC/PRS is computed in A0: In this mode, the dynamic configuration RAM bit CFB_EN
1. Select a suitable polynomial (example above) and write still controls whether the CRC feedback signal is ANDed
it into D0. with the SRCB ALU input. Therefore, as with the built-in
2. Select a suitable seed value (for example, all zeros for CRC/PRS operation, the function can be interleaved with
CRC, all ones for PRS) and write it into A0. other functions if desired.
3. Configure chaining if necessary as described above.
4. Select the MSB position as defined in the polynomial
from the MSB_SEL static configuration register bits and
set the MSB_EN register bit.
5. Configure the dynamic configuration RAM word fields:
a. Select D0 as the ALU "SRCB" (ALU B Input Source)
b. Select A0 as the ALU "SRCA" (ALU A Input Source)
c. Select "XOR" for the ALU function
d. Select "SHIFT LEFT" for the SHIFT function
e. Select "CFB_EN" to enable the support for CRC/
PRS
f. Select ALU as the A0 write source
If a CRC operation, configure "shift in right" for input data
from routing and supply input on each clock. If a PRS opera-
tion, tie "shift in right" to '0'.
PLD
Tie shift in to
SI
zero for PRS
(shift in)
operation
Routing Routing
D0/D1
(POLY)
When the
A0/A1 EXT_CRCPRS bit is
(CRC) set, the CI selection
drives the CRC
feedback line.
MSB FB
(Most Significant Bit)
DP Inputs
(feedback)
CI Mux
srcb srca
ALU
(XOR)
SHIFTER
(LEFT) SI Mux
23.3.2.7 Datapath Outputs and Multiplexing There are a total of six datapath outputs. As shown in
Figure 23-22, each output has a 16-1 multiplexer that allows
Conditions are generated from the registered accumulator
any of these 16 signals to be routed to any of the datapath
values, ALU outputs, and FIFO status. These conditions can
outputs.
be driven to the digital routing for use in other UDB blocks,
for use as interrupts or DMA requests, or to I/O pins. The 16 Figure 23-22. Output Mux Connections
possible conditions are shown in the table below:
Output Mux
Table 23-15. Datapath Condition Generation
Name Condition Chain? Description
ce0
ce0 Compare Equal Y A0 == D0 0
cl0
1
cl0 Compare Less Than Y A0 < D0
z0
2
A1 or A0 == D1 or A0 ce1
4
(dynamic selection)
cl1
5
A1 or A0 < D1 or A0
cl1 Compare Less Than Y
(dynamic selection) z1
6
f1_bus_stat
Definition depends on FIFO
f0_bus_stat FIFO0 Bus Status N
configuration
Definition depends on FIFO
f1_bus_stat FIFO1 Bus Status N
configuration
CFGx
CCHAIN0
ce0
(to routing ce0i
and chaining) (from chaining)
Compare Equal
Figure 23-24 illustrates compare less than chaining. In this case, the “less than” is formed by the compare less than output in
this block, which is unconditional. This is ORed with the condition where this block is equal, and the chained input from the
previous block is asserted as less than.
CFGx
CCHAIN0
cl0 cl0i
(to routing (from chaining)
and chaining)
Compare Compare
Less Than Equal
All Zeros and All Ones Detect the currently defined MSB as specified by the MSB_SEL
bits. This condition is not chainable, however the computa-
Each accumulator has dedicated all zeros detect and all
tion is valid when done in the most significant datapath of a
ones detect. These conditions are statically chainable as
multi-precision function as long as the carry is chained
specified in UDB configuration registers. Whether to chain
between blocks.
these conditions is statically specified in UDB configuration
registers. Chaining of zero detect is the same concept as
23.3.2.8 Datapath Parallel Inputs and Outputs
the compare equal. Successive chained data is ANDed if
the chaining is enabled. As shown in Figure 23-25, the datapath Parallel In (PI) and
Parallel Out (PO) signals give limited capability to bring
Overflow routed data into and out of the Datapath. Parallel Out signals
are always available for routing as the ALU asrc selection
Overflow is defined as the XOR of the carry into the MSB
between A0 and A1.
and the carry out of the MSB. The computation is done on
Figure 23-25. Datapath Parallel In/Out
CFB_EN
PI DYN 1 0
(static config bit)
ASRC[7:0]
PI SEL
(static config bit)
Alu
PO[7:0]
Parallel In needs to be selected for input to the ALU. There 23.3.2.9 Datapath Chaining
are two options, static operation or dynamic operation. For
Each datapath block contains an 8-bit ALU, which is
static operation, the PI SEL bit forces the ALU asrc to be PI.
designed to chain carries, shifted data, capture triggers, and
The PI DYN bit is used to enable the PI dynamic operation.
conditional signals to the nearest neighbor datapaths, to
When it is enabled, and assuming the PI SEL is 0, the PI
create higher precision arithmetic functions and shifters.
multiplexer may then be controlled by the CFB_EN dynamic
These chaining signals, which are dedicated signals, allow
control bit. The primary function of the CFB_EN bit is to
single-cycle 16-, 24- and 32-bit functions to be efficiently
enable PRS/CRC functionality.
implemented without the timing uncertainty of channel rout-
ing resources. In addition, the capture chaining supports the
ability to perform an atomic read of the accumulators in
chained blocks. As shown in Figure 23-21, all generated
conditional and capture signals chain in the direction of least
significant to most significant blocks. Shift left also chains
from least to most significant. Shift right chains from most to
least significant. The CRC/PRS chaining signal for feedback
chains least to most significant; the MSB output chains from
most to least significant.
23.3.2.10 Dynamic Configuration RAM An additional asynchronous read port is provided as a fast
path to output these 16-bit words as control bits to the data-
Each datapath contains a 16 bit-by-8 word dynamic configu-
path. The asynchronous address inputs are selected from
ration RAM, which is shown in Figure 23-27. The purpose of
datapath inputs and can be generated from any of the possi-
this RAM is to control the datapath configuration bits on a
ble signals on the channel routing, including I/O pins, PLD
cycle-by-cycle basis, based on the clock selected for that
outputs, control block outputs, or other datapath outputs.
datapath. This RAM has synchronous read and write ports
The primary purpose of the asynchronous read path is to
for purposes of loading the configuration via the system bus.
provide a fast single-cycle decode of datapath control bits.
16
Datapath Control
Read/Write
Inputs
Decoder
Address
bus_addr
Address Decoder
UDBLocal Bus
[2:0] bus_data[15:0]
Read Only
wrl
RO R/W wrh
Read Read
16 16
Config RAM
dyn_cfg_ram rd
[15:0] dpram
The fields of this dynamic configuration RAM word are shown in the following tables. A description of the usage of each field
follows.
Register Address 15 14 13 12 11 10 9 8
61h - 6Fh
CFGRAM FUNC[2:0] SRCA SRCB[1:0] SHIFT[1:0]
(Odd)
Register Address 7 6 5 4 3 2 1 0
60h - 6Eh
CFGRAM A0 WRSRC[1:0] A1 WRSRC[1:0] CFB EN CI SEL SI SEL CMPSEL
(Even)
System Bus
Routing Channel
A more detailed view of the Status and Control module is shown in Figure 23-29. The primary purpose of this block is to coor-
dinate CPU firmware interaction with internal UDB operation. However, due to its rich connectivity to the routing matrix, this
block may be configured to perform other functions.
4-Bit Sync
8
CFGx
3
SC OUT
CTL[1:0]
CFGx
8 INT MD
CFGx
SYNC MD 8
CFGx
STAT MD[7:0]
System Bus
ACTL
CFGx INT EN
SC OUT
CTL[1:0]
INT
SC OUT CTL bits must
be set to select Control CFGx
register bits for output 8 INT MD
8
force_lat_open
UDB Status Read
Interrupt Generation output of the control register is driven directly to the routing
on that write cycle.
In most functions, interrupt generation is tied to the setting of
status bits. As shown in Figure 23-31, this feature is built Figure 23-32. Control Register Direct Mode
into the status register logic as the masking and OR reduc-
tion of status. Only the lower 7 bits of status input can be To
Data Bus
used with the built-in interrupt generation circuitry. The most Routing
significant bit is typically used as the interrupt output and
may be routed to the interrupt controller through the digital
routing. In this configuration, the MSB of the status register
Bus
is read as the state of the interrupt bit. Write
Clock
23.3.3.2 Control Register Operation
One 8-bit control register is available for each UDB. This Control Register Sync Mode
operates as a standard read/write register on the system
bus, where the output of these register bits are selectable as In Sync mode, as shown in Figure 23-33, the control register
drivers into the digital routing fabric. output is driven by a re-sampling register clocked by the cur-
rently selected Status and Control (SC) clock. This allows
The Control register is nonretention; it loses its contents the timing of the output to be controlled by the selected SC
across sleep intervals and is reset to 0x00 on wakeup. clock, rather than the bus clock.
Control Register Operating Modes Figure 23-33. Control Register Sync Mode
will be read back by firmware as a 1 until the completion of Control Register Reset
the pulse, after which it will be read back as a 0. The firm-
The control register has two reset modes, controlled by the
ware can then write another 1 to start another pulse. A new
EXT RES configuration bit, as shown in Figure 23-34. When
pulse cannot be generated until the previous one has been
EXT RES is 0 (the default) then in sync or pulse mode the
completed. Therefore the maximum frequency of pulse gen-
routed reset input resets the synced output but not the
eration is every other SC clock cycle.
actual control bit. When EXT RES is 1 then the routed reset
input resets both the control bit and the synced output.
Routed Reset
0 To
EXT RES
Routing
1
Static configuration Data Bus res res
bit
Bit by Bit
CFG
Bus
Write SC CLK
Clock
23.3.3.3 Parallel Input/Output Mode datapath parallel out. The parallel input connection is always
available, but these routing connections are shared with the
In this mode, the status and control routing is connected to
status register inputs, counter control inputs, and the inter-
the datapath parallel in and parallel out signals. To enable
rupt output.
this mode, the SC OUT configuration bits are set to select
Figure 23-35. Parallel Input/Output Mode
Datapath
po[7:0] pi[7:0]
Datapath Datapath
Parallel Out Parallel In
SC OUT CTL bits must
be set to select
8 8 The INT MD and SYNC
datapath parallel out bits
MD control bits should
for output to routing.
be cleared to enable
SC_IO bits to input mode.
23.3.3.4 Counter Mode ■ In default mode the terminal count is registered. In alter-
nate mode the terminal count is combinational.
As shown in Figure 23-36, when the block is in counter
■ In default mode, the routed enable, if used, must be
mode, a 7-bit down counter is exposed for use by UDB inter-
nal operation or firmware applications. This counter has the asserted for routed load to operate. In alternate mode
following features: the routed enable and routed load signals operate inde-
pendently.
■ A 7-bit read/write period register.
■ A 7-bit read/write count register. It can be accessed only To enable the counter mode, the SC_OUT_CTl[1:0] bits
when the counter is disabled. must be set to counter output. In this mode the normal oper-
ation of the control register is not available. The status regis-
■ Automatic reload of the period to the count register on
ter can still be used for read operations, but should not be
terminal count (0).
used to generate an interrupt because the mask register is
■ A firmware control bit in the Auxiliary Control Working reused as the counter period register. The Period register is
register called CNT START, to start and stop the counter. retention and will maintain its state across sleep intervals.
(This is an overriding enable and must be set for optional For a period of N clocks, the period value of N-1 should be
routed enable to be operational.) loaded. N = 1 (period of 0) is not supported as a clock divide
■ Selectable bits from the routing for optional dynamic value, and will result in the terminal count output of a con-
control of the counter enable and load functions: stant 1.The use of SYNC mode depends on whether or not
❐ EN, routed enable to start or stop counting. the dynamic control inputs (LD/EN) are used. If they are not
used, SYNC mode is unaffected. If they are used, SYNC
❐ LD, routed load signal to force the reload of period.
mode is unavailable.
When this signal is asserted, it overrides a pending
terminal count. It is level sensitive and continues to
load the period while asserted.
■ The 7-bit count may be driven to the routing fabric as
sc_out[6:0].
■ The terminal count may be driven to the routing fabric as
sc_out[7].
Read Read
Only* Write
*Current count value is
only readable when 7-Bit Period
not enabled.
Register
Terminal
Count CFGx CFGx
(TC) EN SEL[1:0] LD SEL[1:0]
{sc_io_in[3:0], sc_in[3:0]}
this mode, the normal operation of the status register is not CNT FIFO1 FIFO0 FIFO1 FIFO0
INT EN
START LVL LVL CLR CLR
available, and the status sticky bit mode is forced off,
regardless of the control settings for this mode. The control
register is not affected by the mode. The counter can still be FIFO0 Clear, FIFO1 Clear
used with limitations. No dynamic inputs (LD/EN) to the
The FIFO0 CLR and FIFO1 CLR bits are used to reset the
counter can be enabled in this mode.
state of the associated FIFO. When a '1' is written to these
Figure 23-37. Sync Mode bits, the state of the associated FIFO is cleared. These bits
must be written back to '0' to allow FIFO operation to con-
Sync Module (Status Register) tinue. When these bits are left asserted, the FIFOs operate
as simple one-byte buffers, without status.
The bus clock input to the reset and clock control is distinct
from the system bus clock. This clock is called
“bus_clk_app” because it is gated just like the other global
digital clocks and used for UDB applications. The system
bus clock is only used for I/O access and is automatically
gated, per access. The datapath clock generator produces
three clocks: one for the datapath in general, and one for
each of the FIFOs.
ext_clk
2
bus_clk PLD1
CFGx CFGx Clock pld1_clk (to PLD1)
EXT CLK SEL[1:0] EXT SYNC Select/Enable
SC
Clock sc_clk (to Status and Control)
Select/Enable
mf
rc_in_gated[3:0]
cnt_routed_ reset (to SC counter)
sysreset Reset
pld0_reset (firmware/system reset)
Select/Enable
pld1_reset (firmware/system reset)
sc_reset (firmware/system reset)
dp_reset (firmware/system reset)
3
1 2 Latch clk
rc_in_gated[3:0] 0 FF 1 1
0 0
2 2 2
{bus_clk_app,ext_clk, gclk[7:0]} 0
Clock Select 4 2
0000: gclk[0] 0100: gclk[4] Clock Invert
CFGx CFGx 0: true
0001: gclk[1] 0101: gclk[5]
CK SEL[3:0] CK INV
0010: gclk[2] 0110: gclk[6] 1: inverted
0011: gclk[3] 0111: gclk[7]
1000: ext_clk
1001: bus_clk_app
The selected clock may be optionally inverted. This limits ON Clock is ON. The selected global clock is free running.
the maximum frequency of operation due to the existence of A gated clock is generated on each positive edge detect of
Positive Edge the clock enable input. Maximum frequency of enable
one half cycle timing paths. Simultaneous bus writes and input is the selected global clock divided by two.
internal writes (for example writing a new count value while
Clocks are generated while the clock enable input is high
a counter is counting) are not supported when the internal Level
('1').
clock is inverted and the same frequency as bus clock. This
limitation affects A0, A1, D0, D1, and the Control register in Clock Enable Usage
counter mode.
There are two general usage scenarios for the clock enable.
Clock Enable Selection Firmware Enable – It is assumed that most functions
The clock enable signal may be routed to any synchronous require a firmware clock enable to start and stop the func-
signal and can be selected from any of the four inputs from tion. Since the boundary of a function mapped into the UDB
the routing matrix that are available to this block. array is arbitrary, i.e., it may span multiple UDBs and/or por-
tions of UDBs, there must be a way to enable a given func-
tion atomically. This is typically implemented from a bit in a
control register routed to one or more clock enable inputs. ■ Each FIFO clock can be inverted with respect to the
This scenario also supports the case where applications selected datapath clock polarity.
require multiple, unrelated blocks to be enabled simultane- ■ When FIFO FAST mode is set, the bus clock overrides
ously. the datapath clock selection normally in use by the FIFO.
Emulated Local Clock Generation – This feature allows
local clocks to be generated by UDBs, and distributed to 23.3.4.2 Reset Control
other UDBs in the array by using a synchronous clock There are two modes of reset control: legacy mode and
enable implementation scheme, rather than directly clocking standard mode. The modes are controlled by the ALT RES
from one UDB to another. Using the positive edge feature of bit in each UDB configuration register CFG31. The default
the clock enable mode eliminates restrictions on the duty for this bit is 0 (legacy mode); it is recommended that it be
cycle of the clock enable waveform. set to 1 for standard mode. Standard mode has greater
granularity - routed resets can be used by individual blocks
Special FIFO Clocking within the UDB. Contact Cypress for information on legacy
The datapath FIFOs have special clocking considerations. mode reset.
By default, the FIFO clocks follow the same configuration as
the datapath clock. However, the FIFOs have special control PLD Reset Control
bits that alter the clock configuration: Figure 23-40 shows the PLD reset system.
M
C
M
C
RES Accumulator
Accumulators
Output
Sync
Registers
RES Carry Out
Register
sysrese
t
RES
RES Shift Out
Left
Register
rc_in[3:0]
RES Shift Out
2 Right Register
ACTL RES
F1 CLR FIFO1 Status
rc_in[3:0]
RES Shift Out
Right
2 Register
CFGx CFGx CFGx
DP RES SEL[1:0] DP RES POL EN RES DP
Reset Select Reset Invert ACTL RES
00: rc_in[0] 0: true F0 CLR FIFO0 Status
01: rc_in[1] 1: inverted
10: rc_in[2]
11: rc_in[3]
ACTL RES
F1 CLR FIFO1 Status
23.3.4.3 UDB POR Initialization As a result of this initialization, conflicting drive states on the
routing are avoided and initial configuration occurs in an
Register and State Initialization order-independent sequence.
Routing Initialization
On POR, the state of input and output routing is as follows:
■ All outputs from the UDB that drive into the routing
matrix are held at '0'.
■ All drivers out of the routing and into UDB inputs are ini-
tially gated to '0'.
A0 A0 A0
A1 A1 A1
A0 A0 A0
A1 A1 A1
Low byte High byte Low byte High byte Low byte
16 bits at 16 bits at 16 bits at
UDB 2 UDB 1 UDB 0
In concat mode, the registers of a single UDB are concate- There is a limitation in the use of DMA with respect to the
nated to form 16-bit registers as shown in Figure 23-46. In 16-bit working register address space. It is inefficient for use
this mode, the 16-bit UDB array data bus has access to when the function is greater than 16 bits. This is because
pairs of registers in the UDB in the format shown in the fig- the addressing overlaps, as shown in Table 23-24.
ure. For example, an access at A0 accesses A0 in the low
byte and A1 in the high byte. Table 23-24. Optimized Address Space for 16-Bit UDB
Function
Figure 23-46. 16-Bit Working Register Concat Access
Address Upper Byte Goes Lower Byte Goes
Mode
0 UDB1 UDB0
UDB i 2 UDB2 UDB1
4 UDB3 UDB2
A1 A0
D1 D0
When the DMA transfers 16 bits to address 0, the lower and
F1 F0 upper bytes are written to UDB0 and UDB1, respectively. On
CTL/CNT ST the next 16 bit DMA transfer at address 2, you overwrite the
ACTL MSK/PER value in UDB1 with the lower byte of that transfer.
00h MC To avoid having to provide redundant data organization in
memory buffers to support this addressing, it is recom-
16 bits at
UDB i
mended that 8-bit DMA transfers in the 8-bit working space
High byte Low byte
be used for functions over 16 bits.
200h
00h
PLD0/PLD1
64 bytes
(32 words x 16 bits)
40h
128
UDB Config Registers
bytes
(32 bytes)
(16 words x 16 bits)
60h
Dynamic Configuration RAM
(16 bytes)
(8 words x 16 bits)
70h
Reserved
(16 bytes)
Read Word
(16 bits)
PER
MC (RO) NA, bus does not write Not allowed directlyd NA, bus does not write
a. The Ax registers can be safely read by using software capture feature of the FIFOs.
b. The Dx registers can only be written to dynamically by the FIFOs. When this mode is programmed, direct read of the Dx registers is not allowed.
c. The CNT register can only be safely read when it is disabled. An alternative for dynamically reading the CNT value is to route the output to the SC register
(in transparent mode).
d. MC register bits can also be routed to the status register (in transparent mode) inputs for safe reading.
8-Bit 16-Bit
Register 7 6 5 4 3 2 1 0
Address Address
Datapath Registers
A0[7:0]
A0 0xh 00xh
(Accumulator 0 Value)
A1[7:0]
A1 1xh 02xh
(Accumulator 1 Value)
D0[7:0]
D0 2xh 04xh
(Data Register 0)
D1[7:0]
D1 3xh 06xh
(Data Register 1)
F0[7:0]
F0 4xh 08xh
(FIFO 0)
F1[7:0]
F1 5xh 0Axh
(FIFO 1)
Status and Control Registers
ST[7:0]
ST 6xh 0Cxh
(Status Register)
CTL[7:0] / CNT[6:0]
CTL/CNT 7xh 0Exh
(Control / Count Register)
MSK[6:0] / PER[6:0]
MSK/PER 8xh 10xh
(Interrupt Mask / Period Register)
Auxiliary Control Register
ACTL 9xh 12xh CNT START INT EN FIFO1 LVL FIFO0 LVL FIFO1 CLR FIFO0 CLR
PLD Macrocell Register
MC Axh 14xh PLD1 MC[3:0] PLD0 MC[3:0]
This chapter describes the structure of the UDB Array and Digital System Interconnect (DSI). Universal Digital Blocks (UDBs)
are organized in the form of a two-dimensional array with programmable interconnect provided by the DSI. In addition to con-
necting UDB components, the DSI routing also provides connection between other hardware resources on the device, such
as I/O pins, interrupts, and fixed function blocks.
24.1 Features
■ Offers a homogeneous array of UDBs which provide flexible function mapping
■ Provides array level interconnect routing between the components of the UDB hardware
■ Provides device level interconnect routing between UDBs, device peripherals, and I/O pins
INT/DMA INT/DMA
Routing Controller
IO Port
IO Port
UDB Array
IO Port
The main components of this system are: system blocks that require connectivity are routed to this
■ UDB Array:- UDB blocks are arrayed within a matrix of interface at the UDB array, which allows connections into
programmable interconnect. UDB pairs consisting of 2 the core of the array or directly between device peripherals.
UDBs are the basic building blocks of the UDB array. Signals in this category include:
UDB pairs are tiled to create an array. UDB pairs can
■ Interrupt requests from all digital peripherals in the sys-
connect with neighboring UDB pairs in seamless fashion
tem
■ DSI- Routing interface tiled at top and bottom of UDB
■ DMA requests from all digital peripherals in the system
array core. Provides general purpose programmable
routing between device peripherals, including UDBs, I/ ■ Digital peripheral data signals that need flexible routing
Os and fixed function blocks. to I/Os
■ System Interface (not shown)- Built in 8/16-bit bus inter- ■ Digital peripheral data signals that need connections to
face with parallel access to all registers to support fast UDBs
configuration. Also provides clock distribution and clock ■ Connections to the interrupt and DMA controllers
gating functionality. ■ Connection to I/O pins
The following section explain in detail the DSI routing and ■ Connection to analog system digital signals
System Interface.
Figure 24-2 and Figure 24-4 show some examples of the
device peripherals that are connected to this interface,
24.3 How It Works including UDBs, I/Os, analog peripherals, interrupts, DMA,
and fixed function peripherals.
The purpose of the DSI is to provide general purpose pro-
grammable connectivity across the device. Peripherals and
Figure 24-2. DSI Example Connections to the Interrupt and DMA Controller
UDB Interrupt
Request
Figure 24-3. DSI Example Connections between Peripherals, I/O Pins, and UDBs
I2C Timer
I/O I/O I/O
Pin Pin SDA SDA SDA SDA Pin EN TC
IN OUT IN OUT
24.4 UDB Array System Interface There are eight digital global clocks, plus the application bus
clock, routed to each bank of UDBs. The UDB local interface
The system interface consists of infrastructure blocks that blocks contain clock gating control registers, which must be
distribute and interface the device system bus to the UDB set by configuration firmware to enable clock distribution.
array bus and to the UDB blocks, the DSI channel routing, There are four registers in each block:
and the UDB pair channel routing. Depending on the config- ■ 8-Bit MDCLK_EN (Master Digital Clock Enable) – This
uration of the array, there is one or more AHB interfaces that register individually enables the digital global clocks at
connect to PHUB spokes providing an interface to the UDB the input to the UDB array.
array system bus. Both 8-bit and 16-bit bus access is sup-
■ 1-Bit MBCLK_EN (Master Bus Clock Enable) – This
ported. The system interface also provides support for clock
register individually enables the application bus clock at
distribution and gating for the digital global clocks and bus
the input to the UDB array.
clock. A gated clock tree distribution is implemented to allow
only those clocks that are in use to be activated. ■ 8-Bit DCLK_ENx (Quadrant Digital Clock Enable) – This
register individually enables the digital global clocks to
Following are the system interface components: the associated quadrant (4 UDBs) of the UDB array.
■ AHB Interface – Connects to a standard PHUB spoke ■ 1-Bit BCLK_ENx (Quadrant Bus Clock Enable) – This
and provides support for up to 1 bank of UDBs (16). register individually enables the bus clock to the associ-
Controls array wait states and translates AHB signaling ated quadrant (4 UDBs) of the UDB array. It also con-
into array register and routing configuration access con- tains bits to put the associated routing channel RAM into
trol. global write mode.
■ DSI Channel IF – Interfaces the UDB array bus to the
DSI routing channel for writing and reading configura- 24.4.1 UDB Array POR Initialization
tion.
The key aspects of POR initialization are summarized as fol-
■ UDB Local IF – Interfaces the UDB array bus to the
lows.
UDB blocks for registers and RAM access, and provides
local clock gating. ■ All UDB clocks are gated off. There are three levels of
clock gating configuration: one at the UDB level for each
■ UDB Pair Channel – Interfaces the UDB array bus to
individual block clock control and a set of registers at the
the pair routing channel for writing and reading configu-
array level that controls master and quadrant clock gat-
ration.
ing.
■ Bank IF – Contains the master clock gating and bank
■ The state of all drivers into the routing matrix is gated to
wide configuration interface signals.
‘0’ with a global routing enable control. This includes
■ 8-Bit WAIT_CFG Register – Sets the read and write UDB block outputs, DSI inputs, and segmentation buf-
wait states for working and configuration registers. fers. Since the routing is initialized to a random state, the
■ 4-Bit BANK_CTL Register – Contains global bank con- state of routing nets will be either ‘0’ or ‘Z’.
trol bits. ■ The inputs of all routing output buffers, including seg-
❐ One bit to globally enable all DSI inputs. On POR, all mentation buffers, are gated to ‘0’ with a global routing
DSI inputs are gated off until the DSI channel is con- enable control. This prevents floating routes from caus-
figured. This bit globally enables DSI inputs to drive ing high power states. This also drives the buffer outputs
the routing. to ‘0’ and that is the state for all DSI outputs.
❐ One to disable all UDB status register clear-on-read ■ Configuration can occur in an order-independent way.
function for debug support.
When configuration is complete, each bank of UDBs has
❐ One to put the embedded DP RAM into test mode for a global routing enable which is asserted to activate the
DFT support. connections (forced gating is disabled).
❐ One to put the bank into global write mode, also for
■ After routing is enabled, a global clock enable bit (bank
DFT support.
enable) can be set (residing in the power manager)
which then enables clocking in the array. The bank
enable bit prevents any spurious operation until the
array is completely configured.
UDB Registers
Working Configuration
Registers Registers
DSI Interface
8-Bit Working 16-Bit Working UDB Bank Array Bank Control
Configuration
UDB Pair
Concatinated
Configuration
UDB Channel
Default Access Interface
Configuration
Figure 24-6 shows the register mapping for working and configuration registers of UDB and DSI.
Bank 0
16-Bit 3000h
Working Registers
Reserved
6A00h 1K Bytes
4000h
Bank 1 DSI
16-Bit Configuration Space DSI Configuration 3K Bytes
16-Bit Working Registers (maximum used: 4800h
Working 4K)
Reserved
Register 6C00h 5000h
Address Bank 0 Control
Bank 5010h 32 Bytes
Space Bank 1 Control
Configuration 5020h
Reserved Space Reserved
Reserved
6E00h Reserved
The CAN peripheral is a fully functional Controller Area Network (CAN) supporting communication baud rates up to 1 Mbps.
The CAN controller is CAN2.0A and CAN2.0B compliant per the ISO-11898 specification. The CAN protocol was originally
designed for automotive applications with a focus on a high level of fault detection and recovery. This ensures high communi-
cation reliability at a low cost. Because of its success in automotive applications, CAN is used as a standard communication
protocol for motion oriented embedded control applications (CANOpen) and factory automation applications (DeviceNet). The
CAN features allow the efficient implementation of higher level protocols without affecting the performance of the microcon-
troller CPU.
PSOC
CAN Drivers
CAN Controller
EN
RX
TX
CAN Transceiver
25.1 Features
■ Compliant with CAN2.0A/B protocol specification:
❐ Standard and extended frames
❐ Remote Transmission Request (RTR) support
❐ Programmable bit rate up to 1 Mbps
■ Receive path:
❐ 16 receive message buffers
❐ 16 acceptance filters and acceptance masks
❐ DeviceNet addressing support
❐ Option to link multiple receive buffers to form a hardware FIFO
■ Transmit path:
❐ Eight transmit message buffers
❐ Programmable priority for each transmit message buffer
■ CAN Transmit (Tx), Receive (Rx), and EN can be routed to any I/O
■ Listen Only mode for auto baud detection
■ Ability to wake up the device from Sleep mode on bus activity
Memory
Buffer
(SRAM)
CAN Module
Memory
Arbiter
Receive
Message
Handler
CAN
Transmit
Bus
TO Message
Advanced
CPU/PHUB Handler
Peripheral
Bus
CAN
(APB)
Coupler
Framer
Interrupt
Controller
Status and
Configuration
Control and
Command
■ Data frames
■ Remote frame
■ Error frame
■ Overload frame
Interframe Interframe
Space Start of Identifier DLC Data CRC ACK End of Space
RTR IDE R0 (Maximum 8
Frame (11 Bits) (4 Bits) Field Field Frame
Bytes)
Control Field
Start of frame. The beginning of a data frame is indicated Data Length Code (DLC). These 4 bits indicate the num-
by the start of frame bit. It is a single dominant bit. ber of data bytes in the data field. The IDE, R0, and DLC
bits constitute the Control Field.
Identifier. For a basic CAN data frame, the identifier is 11
bits long. It is mainly used to filter the data at the receiver Data Field. This field contains the message data. It is of
side. variable length and can have a maximum of 8 bytes.
Remote Transmission Request Bit (RTR). Set the RTR Cyclic Redundancy Check (CRC). Frame checking is car-
bit '0' (dominant) for a data frame and set to '1' (recessive) ried out by the method of cyclic redundancy check (CRC).
for a remote frame. The identifier and RTR bit are known as The field consists of a 15-bit CRC code followed by a CRC
the Arbitration Field. delimiter.
Extended Identifier Bit (IDE). This bit must be a ‘0’ (domi- Acknowledgement Field (ACK). The ACK field is two bits
nant for a standard data frame and a ‘1’ (recessive) for long and recessive by default. When a receiver receives a
extended CAN data frame. message correctly, it overwrites the ACK field with a domi-
nant bit.
R0. Reserved bit.
End of Frame. The end of every frame is indicated by End
of Frame field and it consists of seven recessive bits.
Arbitration Field
Interframe Interframe
Space Start of Identifier Identifier DLC Data CRC ACK End of Space
(11 Bits)
SRR IDE
(18 Bits)
RTR R1 R0 (4 Bits) (Maximum Field Field Frame
Frame
8 Bytes)
Control Field
25.3.2 Remote Frame thereby forcing all other nodes to send out error flags result-
ing in a series of six to twelve dominant bits on the bus.
The CAN bus allows a destination node to request data from
the source by sending a Remote Frame. There are two dif- Error Passive Flag. An error passive flag consists of six
ferences between a Data Frame and a Remote Frame. recessive bits. When an error passive station detects an
First, the RTR bit is transmitted as a recessive bit in the error it sends a passive error flag. A passive error does not
remote Frame. Second, there is no Data Field in the Remote affect any other nodes and the error is detected only if the
Frame. transmitting node detects a bus error. The Error Delimiter
For extended remote frame, the SRR bit is also transmitted consists of eight recessive bits.
as a recessive bit.
25.3.4 Overload Frame
Interframe Space. Interframe space separates the data
The overload frame (EOF) consists of an overload flag and
frames and remote frames from the preceding frames.
an overload delimiter. CAN supports reactive overload
frame which is activated when the following conditions
25.3.3 Error Frame occur:
The Error frame is generated by a node when it detects any ■ Detection of a dominant bit during first two bits of inter-
bus error. The error frame consists of an error flag and error mission
delimiter. The error flag are classified into two types: error ■ Detection of a dominant bit in the last bit of EOF by a
active flag and error passive flag. receiver
■ Detection of a dominant bit by any node at the last bit of
Error Active Flag. When an error active station detects an
error it sends six dominant bits as an active error flag. The error delimiter or overload delimiter
format of the error flag thus violates the rule of bit stuffing
TxREQ
TxMESSAGE1
CAN
To Bus
TxREQ CAN
CPU/PHUB TxMESSAGE7
ABP Framer
Priority
Bus Arbiter
Coupler RTR REQ
RxMESSAGE0
RTR REQ
RxMESSAGE1
RTR REQ
RxMESSAGE15
25.4.1 Message Arbitration The main steps in transmitting a standard data frame are:
1. Write the message into an empty transmit message
The priority arbiter supports a round robin and fixed priority
holding buffer. An empty buffer is indicated by TxREQ
arbitration. The arbitration mode is selected using the con-
flag equal to zero.
figuration register.
a. For standard data frame, write '0' (dominant) to the
RTR and IDE bit.
Round Robin. In a round robin scheme, Buffer 0 is
selected first, then Buffer 1 and so on till Buffer 7, and it con- b. Write the DLC bits appropriately to specify the num-
tinues again with Buffer 0 thus forming a cycle. A particular ber of data bytes to be transferred. The maximum
number of data bytes is limited to eight. Data bytes
buffer is only selected if its TxREQ flag is set. This scheme
with MSb (most significant bit) first in each byte are
guarantees that all buffers receive the same probability to
written in D0, D1…D7 locations.
send a message.
c. The 11-bit message identifiers are written to the
ID[31:21] bit field.
Fixed Priority. Buffer 0 has the highest priority. Designate
Buffer 0 as the buffer for critical messages to guarantee that 2. Choose an appropriate priority arbitration scheme. The
message is sent first. Priority arbitration is selected using internal message priority arbiter selects the message
according to the chosen arbitration scheme.
the CFG_ARBITER bit in the Configuration register
(CAN_CSR_CFG[12]). 3. Request transmission by setting the respective TxREQ
flag to ‘1’.
Note RTR message requests are served before TxMes- 4. The TxREQ flag remains set as long as the message
sage buffers are handled. For example, RTRreq0, transmit request is pending. The content of the message
RTRreq15, TxMessage0, TxMessage1, and TxMessage7. buffer must not be changed while the TxREQ flag is set.
Once the message is transmitted, the TxREQ flag is cleared
25.4.2 Message Transmit Process and the TX_MSG interrupt status bit
Figure 25-6 shows the registers associated with a message [CAN_CSR_INT_SR[11] in the interrupt status register
that is transmitted. CAN_CSR_INT_SR is asserted. The interrupt status bit is
only asserted if the TxINT ENBL (CAN_TX [n]_CMD[2]) is
set to ‘1’.
REGISTERS
COMMAND REGISTER Reserved WPN2 Reserved 1 RTR IDE DLC Reserved WPN1 Tx INT Tx Tx
(CAN_Txn_CMD) [31:24] [23] [22] [21] [20] [19:16] [15:4] [3] ENBL ABORT REQ
[2] [1] [0]
IDENTIFIER ID
(CAN_Txn_ID) [31:3] Reserved [2:0]
n = 0,1,…,7
25.4.3 Message Abort Note 4. Using the WPN flags(wpn1 and wpn2) enables sim-
ple retransmission of the same message by only having to
A message is aborted by setting the TxABORT flag set the TxREQ flag without taking care of the special flags
(CAN_TX [n]_CMD[1]) in the CAN_TX [n]_CMD register. (RTR,IDE,DLC and TxINTENBL).
This bit is automatically cleared by the hardware when the
message is aborted.
25.4.4 Transmitting Extended Data
Note 1. The CAN Buffer register (CAN_CSR_BUF_SR) is Frames
used to read whether any transmission requests are pend- For transmitting an extended data frame certain register set-
ing. tings must change compared to that of a standard data
frame. These changes are as follows.
Note 2. If the write protect bit wpn2 (CAN_TX [n]_CMD[23])
■ For extended date frame, write '1' (recessive) to the IDE
is ‘0’, then the bits [21:16] of the Command register cannot
bit.
be modified because they are protected and provides an
undefined value on read back. ■ The message identifiers are written to the ID[31:3] bit
field.
Note 3. If the write protect bit wpn1 (CAN_TX [n]_CMD[3])
is ‘0’, then the bit [2] of the Command register cannot be
modified. This bit gives a ‘0’ upon read back.
The acceptance filter is configured by the Acceptance Mask Register (AMR) and the Acceptance Code Register (ACR).
CAN Module
RxMESSAGE0 Acceptance Filter 0
1
RxMESSAGE1 Acceptance Filter 1 2 CAN
3 RxMESSAGE CAN Bus
RxMESSAGE2 Acceptance Filter 2
Handler Framer
16
REGISTERS
COMMAND REGISTER Reserved WPN2 Reserved1 RTR IDE DLC Reserved WPNL LINK Rx INT RTR BUFF RTR RTR REPLY MSG AV
(CAN_Rxn_CMD) [31:24] [23] [22] [21] [20] [19:16] [15:8] [7] FLAG ENBL REPLY ENBL ABORT PNDG [0]
[6] [5] [4] [3] [2] [1]
IDENTIFIER ID Reserved
(CAN_Rxn_ID) [31:3] [2:0]
n = 0,1,…,15
The main steps in receiving a message are: Following message fields are covered:
1. After receipt of a new message, the RxMessageHandler ■ Identifier
hardware (as seen in Figure 25-7) searches all receive ■ IDE
buffer starting from RxMessage0 until it finds a valid buf-
fer. A valid buffer is indicated by: ■ RTR
a. Receive buffer is enabled indicated by BUFF ENBL = ■ Data byte 1 and data byte 2
‘1’ (CAN_RX[n]_CMD[3]). For a standard CAN message when IDE=0, the 11 bit
b. Acceptance filter of the receive buffer matches identifier are the bits [31:21] of AMR and ACR.
incoming message.
2. If the RxMessageHandler finds a valid buffer that is
25.5.2.1 Example
empty, then the message is stored and the MSG AV flag A message and the acceptance filter settings to accept that
of this buffer is set to ‘1’. message are shown in Figure 25-9 on page 271.
3. If the Rx INT ENBL flag is set, then the RX_MSG flag
(CAN_CSR_INT_SR[12]) of the interrupt controller is
asserted.
4. If the receive buffer already contains a message indi-
cated by MSG AV = ‘1’ and the Link Flag is not set, then
the RX_MSG_LOSS interrupt flag
(CAN_CSR_INT_SR[10]) is asserted. The existing mes-
sage is overwritten with the new received message.
Note The CAN Buffer register (CAN_CSR_BUF_SR) deter-
mines if any receive message buffer is available.
M e s s a g e F ra m e
Id e n tifie r
S ta rt RTR ID E
of DLC
F ra m e 0 X X 0 0 1 1 0 0 1 0 0 0
YES
ACCEPT MESSAGE
=
NO
R EJEC T M ESSA G E
ID E RTR R
Do Not S
ACR 0 X X 0 0 1 1 0 0 1 0 C a re 0 0 V 0
D
31 30 29 28 27 26 25 24 23 22 21 20 3 2 1 0
ID E RTR R
S
AMR 0 1 1 0 0 0 0 0 0 0 0 A ll O n e s 0 0 V
D
31 30 29 28 27 26 25 24 23 22 21 20 3 2 1 0
M asked
As seen in the Figure 25-9, the shaded areas are masked AMR Settings:
bits. When a bit is set to ‘1’ in the AMR register, the corre-
ID[28:21],ID[31] = 0
sponding bit in the ACR register is not checked against the
ID[30],ID[29]= 1
received message frame. In the example, bits 30, 29, and
ID[20:3] = All Ones
bits from 3 to 20 are set to ‘1’ and are masked. Since other
IDE = 0
bits in the AMR register are written as ‘0’, the respective bits
RTR = 0
in the ACR register are compared with message bits as
shown in Figure 25-9. If the corresponding bits in ACR ACR Settings:
match with that of the message, the message is then stored
ID[31:21] = 182h
in the receive message buffer. If the corresponding bits in
ID[20:3] = Do Not Care
ACR do not match with the message, the incoming mes-
IDE = 0
sage is rejected.
RTR = 0
Yes
Accept Message
=
No
Reject Message
R
Do Not S
0 X X 0 0 1 1 0 0 1 0 0 0 Do Not
ACR Care 0
V
ACRD 0 0 0 0 0 X X 1 1 0 Care
D
31 30 29 28 27 26 25 24 23 22 21 20 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 0
Masked
In Figure 25-10 the data field of the message frame is com- ACR Settings:
pared with those bits of the ACRD register, which are not
ID[31:21] = 182h
masked by the AMRD register.
ID[20:3] = Do Not Care
To accept this message, the acceptance filter settings are IDE = 0
as follows. RTR = 0
ACRD [15:6] = 06h
AMR Settings:
ACRD [5:0] = Do Not Care
ID[28:21],ID[31] = 0
The example in Figure 25-10 shows the filtering using 10
ID[30],ID[29] = 1
data bits. Using AMRD, up to 16 data bits, can be used for
ID[20:3] = All Ones
filtering.
IDE = 0
RTR = 0
AMRD [15:11], AMRD[8:6] = 0 25.5.4 Filtering of Extended Data Frames
AMRD[10:9], AMRD [5:0] = All Ones Filtering the extended data frame is very similar to the stan-
dard date frame with the following exception.
■ IDE bit in AMR and ACR registers must be set to check
for extended data frame.
■ Do not set the Link flag of the last buffer of an array. As shown in Figure 25-11:
When a receive buffer already contains a message (MSG ■ The message buffer0 of node1 transmits a remote frame
AV=’1’) and a new message arrives for this buffer, then this into the CAN bus.
message is discarded (RX_MSG_LOSS Interrupt). To avoid ■ The RTR request is received by the RxMessageHandler
this situation, several receive buffers are linked together. of node 2 and sends it to the acceptance filters.
When the CAN controller receives a new message, the ■ The acceptance filter settings of the receive message
RxMessageHandler searches for a valid receive buffer. If buffer 15 matches with that of the message and then the
one is found that is already full (MSG AV = ‘1’) and the ‘Link message is moved to the receive message buffer 15.
Flag’ is set, the search for a valid receive buffer is continued.
■ If the RTR Auto Reply feature is enabled, the receive
If found, the message is transferred to that buffer thereby
message buffer 15 will transmit the message with the
forming an array. If no other buffer is found, then the
same identifier as it received (without CPU intervention).
RX_MSG_LOSS interrupt is set.
It is possible to build several message arrays. Each of these ■ The acceptance filter of the receive message buffer 1 of
arrays must use the same AMR and ACR. node1 has the same identifier settings as that of the
transmitted message node 1. Hence, the RTR message
will be stored in the receive message buffer 1 of node 1.
Node 1
Node 2
Receive Message
Message Buffers Acceptance Buffers
Node 1 Filters Node 2
RTR
REQ FILTER0 RxMESSAGE0
TxMESSAGE0
CAN Bus Rx FILTER1
TxMESSAGE1 Priority Message RxMESSAGE1
Arbiter Handler
Acceptance
Filters
RxMESSAGE0
FILTER0
RxMESSAGE1 FILTER1 Rx Priority
CAN Bus Arbiter
Message
Handler
RxMESSAGE15 FILTER15
8 39 70
9 40 71
10 41 72
11 42 73
12 43 74
13 44 75
14 45 76
15 46 77
16 47 78
17 48 79
18 49 80
19 50 81
20 51 82
21 52 83
22 53 84
23 54 85
24 55 86
25 56 87
26 57 88
27 58 89
28 59 90
29 60 91
30 61 92
31 62 93
32 63 94
33 64 95
34 65 96
35 66 97
36 67 98
37 68 99
38 69 100
Synchronization
Sample Point Sample Point. This is the point at which the state of the
Segment bus is read and the bit is interpreted. It is located at the end
1 or 3 Sample Mode
of tseg1.
of tseg2 must be greater than the synchronization jump Note 1. Sampling_mode bit in the Configuration register
width. (CAN_CSR_CFG) specifies whether or not one sampling
point is used in the receiver path or three sampling points
The Configuration register CAN_CSR_CFG is used for set-
with majority decision are used.
ting the bit rate prescaler (BRP), tseg1, tseg2, and the syn-
chronization jump width. CAN peripheral clock (CAN_CLK)
Note 2. Edge_mode bit in the Configuration register
is generated by dividing the system clock (CLK_BUS) by
(CAN_CSR_CFG) specifies whether or not the high to low
(BRP+1). See the Clocking section for detailed information
edge is used for synchronization or both edges are used.
on available options to generate the system clock. For N
time quanta in a bit time, the CAN peripheral clock fre-
quency must be configured to N time the CAN bus bit rate. 25.8 Error Handling and
Figure 25-14. Bit Timing Block Diagram Interrupts in CAN
clk_bus can_clk According to the CAN protocol specification, there are five
Divider different types of errors. Each CAN node in the bus tries to
detect an error, and when it does, it sends out an error
frame. The different types of errors and the process of error
BRP (CAN_CSR_CFG[14:0]) handling are explained in the following sections.
25.8.1.5 STUFF Error that indicate if the Transmit Error Counter and Receive Error
Counter, respectively, are greater than or equal to 96 deci-
When there are six consecutive equal bit levels in a mes-
mal. This is a feature. It serves as an error warning because
sage field that is coded by the message of bit stuffing, a
an error count value greater than and around 96 indicates a
STUFF error is detected during the bit time of the sixth con-
heavily disturbed bus.
secutive bit level.
Error Active. An error active node can take part in normal The interrupt controller contains an interrupt status and an
bus communication. When it detects an error it sends out an interrupt enable register. The interrupt status register
ERROR ACTIVE FLAG. (CAN_CSR_INT_SR) stores internal interrupt events. Once
a bit is set, it remains set until it is cleared by writing a '1' to
Error Passive. An error passive node takes part in bus it. The interrupt enable register has no effect on the interrupt
communication. When it detects an error it sends out an status register.
ERROR PASSIVE FLAG. After sending out the ERROR
The interrupt enable register (CAN_CSR_INT_EN) controls
PASSIVE FLAG, it waits before proceeding with further
which particular bits from the interrupt status register are
transmission. An error passive node sends additional 8
used to assert the interrupt output INT_N. INT_N is asserted
recessive bits during the interframe space. This period is
if a particular interrupt status bit and the respective enable
also known as suspend transmission since no transmission
bit are set.
takes place.
The various interrupt sources in CAN are as follows:
Bus Off. A node that is in Bus Off does not take part in any
bus communication. It has no effect on the bus. rx_msg. Indicates a message received.
The error status in CAN is indicated by the error status reg-
tx_msg. Indicates a message sent.
ister CAN_CSR_ERR_SR. The bits ERR_STATE
(CAN_CSR_ERR_SR[17:16]) indicate which error state the
rx_msg_loss. Is set when a new message arrives but the
CAN node is in. The error states in CAN are determined
RxMessage flag MSG AV is set.
according to the values of two counters:
■ Transmit Error Counter (CAN_CSR_ERR_SR[7:0]) bus_off. The CAN has reached the bus off state.
■ Receive Error Counter (CAN_CSR_ERR_SR[15:8])
crc_err. A CAN CRC error detected.
The error counters are modified according to the CAN 2.0B
Specification. form_err. A CAN message format error detected.
A node is in ‘error active’ state if the Transmit Error Counter
ack_err. A CAN message acknowledge error detected.
or the Receive Error Counter are less than or equal to 127
decimal. A node is in ‘error passive’ state if the Transmit or
stuff_err. A bit stuffing error detected.
Receive Error Counter value exceeds or equals 128 deci-
mal. A node is in ‘Bus Off’ state if the Transmit Error Counter
bit_err. A bit error detected.
exceeds or equals the value of 256 decimal.
An ‘error passive’ node becomes ‘error active’ again when ovr_load. An overload frame received.
both the Transmit Error Count and the Receive Error Count
are less than or equal to 127. arb_loss. The arbitration lost while sending a message.
The PSoC® USB block acts as a USB device that communicates with a USB host. The USB block is available as a fixed func-
tion digital block in the PSoC device. It supports full speed communication (12 Mbps) and is designed to be compliant with the
USB Specification Revision.2.0. USB devices can be designed for plug and play applications with the host and also support
hot swapping. This chapter details the PSoC USB block and transfer modes. For details about the USB specification, see the
USB Implementers Forum web site.
26.1 Features
The PSoC USB has these features:
■ Complies with USB Specification 2.0
■ Supports full speed peripherals device operation with a signaling bit rate of 12 Mbps
■ Supports 8 data endpoints and 1 control endpoint
■ Supports four types of transfers – bulk, interrupt, isochronous, and control
■ Supports Plug and Play
■ Supports two types of logical transfer modes:
❐ Store and Forward mode
❐ Cut Through mode
■ Differential signal (D+ and D-) output
■ Supports maximum packet size of 64 bytes using the Store and Forward mode and maximum packet size of 1023 for Iso-
chronous transfer using the Cut through mode
■ Capable of supplying PS/2 and CMOS signals
■ Supports two Vccd voltage ranges, with a nominal voltage of 3.3 V
Frequency
Tuning
clk_usb
clk_bus data
USB Block
Arbiter
CPU
CPU
Interface
512 Bytes Memory
SRAM Interface
Arbiter
Logic
DMA
SIE Interface
Interface
SIE
Transceiver
D+ D-
26.2.1 Serial Interface Engine (SIE) interrupt for an endpoint is obtained from the
USB_SIE_INT_SR register.
The Serial Interface Engine (SIE) is responsible for handling
the decoding and creating of data and control packets dur- The SIE registers CNT0 and CNT1 hold the count value for
ing transmit and receive. It decodes the USB bit streams each endpoint which reports the number of data bytes in a
into USB packets during receive and creates USB bit USB transfer. In the case of an OUT endpoint, the firmware
streams during transmit. The following are the features of programs the maximum number of bytes that can be
the SIE block: received for the endpoint. The SIE updates the register with
the number of bytes received. In the case of an IN endpoint,
■ Conforms to the USB 2.0 Specification
it holds the number of bytes that will be transmitted.
■ Supports 1 device address
The SIE Control register for each endpoint,
■ Supports 8 data endpoints and 1 control endpoint
USB_SIE_EPx_CR0, holds the mode value. The mode
■ Supports interrupt for each endpoint value determines the response of the USB block to the host.
■ Operates at Full Speed with a 48 MHz Clock (maximum Refer to Table 26-1 for the different mode values. The table
permitted tolerance is ±0.25%) describes the mode values corresponding to each type
■ Integrates an 8-byte buffer in the Control endpoint token: the SETUP, IN and OUT tokens.
The registers for this block are mainly used to configure the Transition error is also reported by the SIE. The bit
data endpoint operations and the Control Endpoint Data buf- “err_in_txn” in the USB_SIE_EPx_CR0 register indicates
fers. The register also controls the interrupt available for the occurrence of an error. When this bit is set and the USB
each endpoint. block is in Store and Forward mode, the hardware automati-
cally retransmits the same data when it receives another IN
The SIE generates an interrupt at the end of a transfer. The token from the host. In Cut Through mode, this bit can be
interrupt enabling and disabling for an endpoint can be done read by the firmware to determine if the data should be
using the USB_SIE_INT_EN register. The status of the retransmitted.
Table 26-1. Mode Values in the MODE bits of the SIE_EPx_CR0 Register
Mode Encoding SETUP IN OUT Comments
Disable 0000 Ignore Ignore Ignore Ignore all USB traffic to this endpoint
NAK IN/OUT 0001 Accept NAK NAK NAK IN and OUT token
When this mode is set, it accepts a SETUP token,
STALLs in case of IN token and ACKs with a zero
Status OUT Only 0010 Accept STALL Check
length packet in case of OUT token. Used for control
endpoint
When this mode is set, it accepts a SETUP token,
STALL IN/OUT 0011 Accept STALL STALL STALLs in case of IN and OUT token. Used for control
endpoint
Reserved 0100 Ignore Ignore Ignore
ISO OUT 0101 Ignore Ignore Always Isochronous OUT
When this mode is set, it accepts a SETUP token,
STALLs in case of OUT token and ACKs with a zero
Status IN only 0110 Accept TX 0 byte STATLL
length packet in case of IN token. Used for control end-
point
ISO IN 0111 Ignore TX Count Ignore Isochronous IN
NAK OUT 1000 Ignore Ignore NAK Send NAK handshake to OUT token
This mode is changed by the SIE to mode 1000 on issu-
ACK OUT (STALL = 0) 1001 Ignore Ignore ACK
ance of ACK handshake to an OUT
ACK OUT (STALL = 1) 1001 Ignore Ignore STALL STALL the OUT transfer
Reserved 1010 Ignore Ignore Ignore
ACK the OUT token or send zero length data packet for
ACK OUT – STATUS IN 1011 Accept TX0 byte ACK
IN token.
NAK IN 1100 Ignore NAK Ignore Send NAK handshake for IN token
Table 26-1. Mode Values in the MODE bits of the SIE_EPx_CR0 Register (continued)
Mode Encoding SETUP IN OUT Comments
This mode is changed by the SIE to mode 1100 after
ACK IN (STALL = 0) 1101 Ignore TX Count Ignore
receiving ACK handshake to an IN data
ACK IN (STALL = 1) 1101 Ignore STALL Ignore STALL the IN transfer
Reserved 1110 Ignore Ignore Ignore
ACK IN – Status OUT 1111 Accept TX Count Check Respond to IN data or Status OUT
These arbiter interrupt requests are routed to only one inter- The USB needs a nominal voltage of 3.3V for its operation.
rupt line which acts as a signal to the interrupt controller. The block uses the regulated digital voltage Vccd. It sup-
ports an internal regulator which is used for voltage regula-
26.2.2.6 Synchronization Block tion. While in the Standard Voltage Range, the voltage is
regulated to 3.3V by the internal regulator. While in the
The USB block uses 2 clocks: the System Clock and the
Lower Voltage Range, the internal regulator should be
USB Clock. The System Clock is used by the Arbiter. The
bypassed. The “reg_enable” bit in the USB_USB_CR1 reg-
USB Clock is used by the SIE and the OsClock module.
ister is used to control the regulator usage.
Since these two are different clocks, synchronization is
required between the blocks. The handling of the synchroni- In all other voltage ranges (that is, 1.7V to 3.15V, 3.45V to
zation is done by this block. 4.35V, and 5.25V to 5.5V, the “suspend,” “pull up,” and “high
impedance drive” modes will work properly because the cur-
rent specification is met. The Drive modes can be selected
26.3 How it Works using the registers USB_USBIO_CR1 and
The USB Block operates at a certain frequency and voltage USB_USBIO_CR2.
range. For proper operation of the USB block, the user must
ensure that the operating ranges are within tolerances. The 26.3.3 Transceiver
following sections discuss the operating ranges required for
The USB block includes the transmitter and the receiver.
the PSoC USB.
The signal between the USB device and the host is a differ-
ential signal. The receiver receives the differential signal
26.3.1 Operating Frequency and converts it to a single ended signal. The single ended
The USB block needs two different clocks to work: the Sys- input is given to the USB block at a nominal voltage range of
tem Clock which controls the Arbiter, memory and the regis- 1.55V to 1.95V. The transmitter converts the single ended
ter block, and the USB clock which controls the SIE and the signal to the differential signal and transmits it to the host.
OsClock. The differential signal is given to the upstream devices at a
nominal voltage range of 0V to 3.3V.
■ Minimum system clock – 24 MHz
■ USB Clock for Full Speed operation – 48 MHz (+0.25% The transceiver also supports the PS/2 signals. It can
tolerance) receive and transmit PS/2 signals at a nominal voltage of 0V
to 5V. The transceiver has the pull up resistors to support
The USB needs a 48 MHz clock to function. The clock to the the PS/2 signals.
USB is called the clk_usb. The clk_usb can be derived from
either IMOCLK, doubler clock (IMOCLK * 2), PLL, or the DSI Apart from the PS/2 signals, the transceiver also supports
clock. For further details on the clock for this block, refer to the CMOS signal levels. The PS/2 and the CMOS modes
the Clocking System chapter on page 147. The OsClock can be selected using the registers USB_USBIO_CR1 and
block of the USB trims the USB clock to lock to the fre- USB_USBIO_CR2.
quency of the USB packets. The USB clock is clocked to the The Transmitter can be manually forced to transmit signals.
USB token as per the USB 2.0 Specification. When the fre- The register USB_USBIO_CR0 is used to manually transmit
quency is locked with other USB bit streams, the block will the signals. Examples are as follows:
locate a particular edge in the USB packet. The number of
■ When the manual transmission is enabled, the register
clock periods between these edges is measured to lock the
can be configured to transmit Single Ended Zero signal
internal oscillator frequency with the frequency of the USB
(that is, D+ and D- are low).
packet. The frequency tuning value is sent to the Clocking
system by the USB Block to lock the frequency. The locking ■ Configurable to transmit the USB signals. The USB sig-
of the frequency is done by the hardware and needs no user nals can be two types:
intervention. The Synchronization Block of the Arbiter han- ❐ D+ low and D- high = J
dles the synchronization of the USB Clock and System ❐ D+ high and D- low = K
Clock.
■ The register also has a bit which is used to read the
received signal levels. The bit can show if D+ < D- or D+
26.3.2 Operating Voltage > D-.
The USB block can operate in two voltage ranges:
■ Standard voltage range – 4.35V to 5.25V
■ Lower voltage range – 3.15V to 3.45V
26.3.6 Interrupts There is only one arbiter line common for all the endpoints.
The interrupts are generated by the SIE and the Arbiter. The SIE Interrupt for SOF
following interrupt lines are available for the interrupt con-
■ Generated whenever the SOF is received.
troller:
■ Nine SIE interrupt lines (one for each endpoint and con- SIE Data Interrupt
trol endpoint)
■ Interrupt generated for the data valid or error in transac-
■ Arbiter interrupt line
tion.
■ SIE interrupt line for SOF
■ One interrupt line common for all endpoints.
■ SIE data endpoints interrupt line
■ The sticky bit “data_valid,” in the USB_SIE_EPx_CNT0
■ Reset interrupt line register, indicates the data valid state.
■ The sticky bit “err_in_txn” in the USB_SIE_EPx_CR0
Nine SIE Interrupts
register indicates the error in transaction state.
■ Generated after the completion of packet transmission.
26.4 Logical Transfer Modes The logical transfer mode is a combination of memory man-
agement and DMA configurations. The Logical Transfer
The USB block in PSoC devices supports two types of logi- modes are related to the data transfer within the USB block
cal transfers. The logical transfers can be configured using (i.e., to/ from the SRAM memory unit for each endpoint). It
the register setting for each endpoint. Any of the logical does not represent the transfer methods between the device
transfer methods can be adapted to support the three types and the host (i.e., the transfer types specified in the USB 2.0
of data transfers (Interrupt, Bulk, and Isochronous) men- Specification).
tioned in the USB 2.0 Specification. The Control transfer is
The USB block supports two basic types of transfer modes
mandatory in any USB device.
and are detailed in Table 26-2 on page 285.
■ Store and Forward mode
■ Cut Through mode
Every endpoint has a set of registers that need to be handled during the modes of operation, as detailed in Table 26-3.
In the Manual Memory Management case, the endpoint Figure 26-2. No DMA Access IN Transaction
read and endpoint write address registers are updated by
Write WA register (based on
the firmware. So the memory allocation can be done as required memory allocation)
required by the user and the memory allocation decides
which endpoints are active. (i.e., the user can decide to
share the 512 bytes for all the 8 endpoints or a lesser num- Write packet size to
Byte Count register
ber of endpoints).
Value automatically
In the Automatic memory management case, the endpoint written to the SRAM
read and endpoint write address registers are updated by Write data to Data specified by WA
register location. WA++
the USB block. The block assigns memory to the endpoints
which have been activated using the EP_ACTIVE register. No
The size of memory allocated depends on the value in the
Is all
BUF_SIZE register. The rest of the memory, after allocation, data written to
is called the “Common Area” memory and used for the SRAM?
transfer of data.
Yes
In the following text, the algorithm for the IN and OUT trans-
action for each mode is discussed. An IN transaction is Write the RA
when the data is read by the USB host (for example, PC). register (same as
initial WA register)
An OUT transaction is when the data is written by the USB
host to the USB device (in this case, PSoC 3 or PSoC 5).
The choice of using the DMA and memory management can Set mode value in
CR0 register
be configured using the USB_ARB_CFG register and the
mode is common to all endpoints.
No
Is all data
transmitted?
Yes Interrupt
Generated
Set the mode as NAK for the
last byte in transfer. Status
bits set by the block
Figure 26-3. No DMA Access OUT Transaction 26.4.1.2 Manual DMA Access
Write WA register (based on This is the Manual Memory Management mode with Manual
required memory allocation) DMA Access. This mode requires the configuration of the
DMA controller. See DMA Interface on page 282 for details
To inhibit CRC
and constraints regarding DMA transfers to the USB block.
set the “crc_bypass” bit Write maximum packet size to
in the ARB_EPx_CFG Byte Count register
This mode is similar to the No DMA Access except that the
register
write/read of packets is performed by DMA. A DMA request
for an endpoint is generated by setting the DMA_CFG bit in
Set mode value in
CR0 register the ARB_EPx_CFG register. When the DMA service is
granted and is done (DMA_GNT), an arbiter interrupt can be
programmed to occur. The transfer is done using a single
Wait DMA cycle or multiple DMA cycles. After completion of
Is OUT every DMA cycle the arbiter interrupt (DMA_GNT) is gener-
No command ated. Similarly, when all the bytes of data (programmed in
received?
Responds the byte count) have been written to the memory, the arbiter
automatically
with ACK interrupt occurs and the IN_BUF_FULL bit is set.
Yes (configured as
mode value)
IN Transaction (CPU Write, SIE Read). The steps for an
Data received from IN transaction on an IN endpoint are shown in Figure 26-4.
host written to SRAM
location WA
WA++
No
Is all
data written to
SRAM?
Yes
SIE Data
Interrupt
Write the RA value
(same as initial Generated
WA)
Data in Data
register is read USB Block reads the data at
by CPU and location RA and writes to Data
given to device. register
RA++ is done
automatically.
No
Is all
data read from
SRAM?
Yes
End
Figure 26-4. Manual DMA IN Transaction Figure 26-5. Manual DMA OUT Transaction
Write WA register (based on required memory allocation)
Write WA register (based on
required memory allocation)
Write Packet size to Byte Count register
Is all
data written to
Is all data SRAM?
No
transmitted?
Interrupt
Generated Yes
Yes
SIE Data
Interrupt
Write the RA value
(same as initial Generated
WA)
OUT Transaction (CPU Read, SIE Write). The steps for Configure the
Data in Data DMA request
an OUT transaction on an OUT endpoint are shown in register is
Figure 26-5. read by DMA
and given to USB block reads the data at
device. location RA and writes to Data
RA++ register
No
Is all
data read from
SRAM?
At the end of
every DMA cycle,
Yes DMA_GNT
interrupt is
End generated.
Yes
Wait
Is IN command
No
received
Block automatically sends
the ACK. (Configured as
Yes Mode value)
Is the complete
Yes data available No
in the memory
RA++
No
SIE reads data from SRAM In the mean time, the PHUB
Is all data in buffer (specified by location RA) and initiates the transaction. The
transmitted? transmits to host data from the device is copied
to the common area. The data
RA++
No from the USB is written to the
SRAM by the DMA.
Set the data valid bits Is all data in buffer
transmitted?
End Yes
Wait
Yes
The process is continued
till all the data is transferred Initiate PHUB
transfer.
End
OUT Transaction (CPU Read, SIE Write). The steps for Figure 26-8. IN Transaction
an OUT transaction on an OUT endpoint are shown in
Set the mode bits to
Figure 26-7. ACK the IN token
Yes
Program the Mode register for the endpoint
Wait
Is the
No OUT command received Generates Interrupt and sets the bit to
from host? indicate that IN token is received.
Yes
Read the status bit and the
Data valid bit
The DMA writes the received
data to the SRAM in location
specified by WA
Is data in Yes
SRAM > (DMA_THRES,
DMA_THRES_MSB)? Read the EP0_DRx register to find the
type of request
Yes
Copy the required data to the
The process DMA request is EP0_DRx registers
is continued raised
till all the data Data in the Data
is transferred
USB Block writes register is read and
the data from Set the data valid bit and the mode bits.
given to the USB
SRAM to the Data Also update the byte count value
device by the DMA.
register
No RA is incremented
automatically. No
26.4.3 Control Endpoint Logical Transfer Blocks generates interrupt on receiving ACK from
host and sets the IN byte received bit.
The control endpoint has a special logical transfer mode. It
doesn’t share the 512 bytes of memory. Instead it has dedi-
cated 8 byte register buffer. The IN and OUT transaction for Are all bytes
transferred?
the control endpoint is detailed below:
Yes
End
Figure 26-9. OUT Transaction 26.5 PS/2 and CMOS I/O Modes
Program the mode
bits for ACK_OUT The USB transceiver is designed in such a way that, apart
No from the USB signals, it can also transmit other signal lev-
els. The pull up resistors are available at the transmitter end,
Is the SETUP token which enables additional signal levels. The registers
received?
USB_USBIO_CR1 and USB_USBIO_CR2 must be config-
Yes ured to get different signal levels.
The block ACKs The “test_res” bit in the USBIO_CR2 register puts the trans-
the SETUP token
mitter in pull up mode where the pull up resistors are con-
nected.
Generates Interrupt and sets a bit in
EP0_CR register to indicate that The I/O mode bit in the USBIO_CR1 register puts the USB
SETUP token was received. in either USB mode or Drive mode. When put in Drive mode,
the USB signals are disabled and the bits DMI and DPI are
Read the Data valid bit in EP0_CNT used to drive D- and D+, respectively. There are two differ-
ent drive modes. In CMOS Drive mode, D+ follows the DPI
and D- follows the DMI. In the case of Open Drain mode, the
Is data valid? pull up resistors play a role. In this state, when the DPI and
DMI bits are set to high, D+ and D- are high impedance.
Yes
The pull up resistors can be connected between Vdd and
Read EP0_DRx to read the type of request
D+ and D-, independent of the Drive modes. The bit
“p2puen” is used for this.
Update the mode bits to ACK an An internal pull up of 1.5 k is also supported and can be
OUT token
enabled using the register USBIO_CR1. The USBIO_CR1
No register is also used to poll the state of the D+ and D- pins.
Is OUT token
received?
Yes
Interrupt generated. No
No
Is data valid? No
Yes
Yes
End
General Registers
USB_CR0 USB Control register 0 To enable the USB and store the USB Device address
USB_CR1 USB Control register 1 To monitor the bus activity and control the regulator operation
USBIO_CR0 USB I/O Control register 0 To control the operation on D+ and D- signals
USB_BUF_SIZE Dedicated endpoint buffer size register Stores the dedicated buffer size for each endpoint
USB_EP_TYPE Endpoint Type register Stores the type of endpoint either IN/OUT
USB_EP0_DRx
Control endpoint Data register The endpoint 0 is the control endpoint
x= 0 -7
USB_EP0_CR Endpoint 0 Control register
SIE Registers
USB_SIE_EP_INT_EN Interrupt enable register To enable the interrupts for each endpoint
USB_SIE_EP_INT_SR Interrupt status register To find the status of interrupt for each endpoint
USB_SIE_EPx_CNT0
Non control endpoint Count register Handles the Data toggle state and MSB of the 11 bit counter
x= 1- 8
USB_SIE_EPx_CNT0
Non control endpoint Count register LSB of the 11 bit counter
x= 1- 8
USB_SIE_EPx_CR0 Controls the mode for the endpoint and stores the state of error, ACK
Non control endpoint Control register
x=1-8 and NACK for the endpoint.
OsClock Registers
OSCLK_DR0 OsClock Lock register 0 The LSB of the Oscillator locking circuit output
OSCLK_DR1 OsClock Lock register 1 The MSB of the Oscillator locking circuit output
Arbiter Registers
USB_ARB_EPx_CFG Stores the configuration for the transfer modes, reset of pointers and
Endpoint configuration register
x=1–8 CRC
USB_ARB_Epx_INT_EN
Endpoint Interrupt enable register To enable the required interrupts
x=1–8
USB_ARB_Epx_SR To indicate status like overflow, underflow, DMA grant and Local buffer
Endpoint status register
x = 1- 8 full
USB_ARB_RWx_WA
Endpoint Write address register Stores the LSB 8 bits of the Write address pointer
x=1–8
USB_ARB_RWx_WA_MSB
Endpoint Write address register Stores the MSB 1 bit of the Write address pointer
x=1–8
USB_ARB_RWx_RA
Endpoint Read address register Stores the LSB 8 bits of the Read address pointer
x=1–8
USB_ARB_RWx_RA_MSB
Endpoint Read address register Stores the MSB 1 bit of the Read address pointer
x=1–8
USB_ARB_CFG Arbiter Configuration register
USB_ARB_INT_EN Arbiter Interrupt Enable register To enable the interrupt for each endpoint
USB_ARB_INT_SR Arbiter Interrupt Status register To store the interrupt status for each endpoint
USB_CWA Common Area Write Address register The LSB 8 bits of the Write address pointer
USB_CWA_MSB Common Area Write Address register The MSB 1 bit of the Write address pointer
USB_DMA_THRES DMA Threshold Count register The LSB 8 bits of the DMA threshold count register
USB_DMA_THRES_MSB DMA Threshold Count register The MSB 1 bit of the DMA threshold count register
USB_SOF0 Start of Frame register 0 LSB 8 bits of the Start of Frame counter
USB_SOF1 Start of Frame register 1 MSB 3 bits of the Start of Frame counter
USB_BUS_RST_CNT Bus reset count register The reset counter for the USB
Timer blocks in PSoC® devices are 8/16 bits and configurable to act as Timer, Counter, or Pulse Width Modulator (PWM)
blocks that play important roles in embedded systems. PSoC devices give a maximum of four instances of the block. If addi-
tional blocks are required, they can be configured in the UDBs using PSoC Creator™. Timer blocks have various clock
sources and are connected to the General Purpose Input/Output (GPIO) though the Digital System Interconnect (DSI).
27.1 Features
■ 8/16-bit timer/counter/PWM that acts as a down counter
■ Supports the following modes:
❐ Timer
❐ Gated Timer
❐ Pulse-width Modulator (PWM)
❐ One Shot
■ Supports interrupts upon:
❐ Terminal count – the final value in the Count register is reached
❐ Compare true – the timer value matches with the Compare register
❐ Capture – capture of timer value on edge detection in the Capture signal
■ Counts when Enable signal is asserted
■ Supports the free running timer
■ Period reload on start, reset, and terminal count
■ Selectable clock source
■ Supports kill and dead band features
Clock
Timer Block
DSI
Configuration registers
DSI CFG0 and CFG1
Terminal Count Terminal Count
Output signal Output pin
Capture Period PER1 PER0
signal registers (MSB) (LSB)
Compare Compare
Output signal Output pin
Capture CAP1 CAP0
registers (MSB) (LSB)
Timer Reset pin Timer
Enable
Terminal Count
signal Count
Enable pin Interrupt signal
registers CNT_CMP1 CNT_CMP0
(MSB) (LSB) Capture/Compare Interrupt signal
Kill pin Compare Interrupt signal to
registers Interrupt Controller
Capture pin Kill Timer Stop
signal Interrupt signal
External Route Registers Timer Enable
RT0 and RT1 Interrupt signal
CLK_BUS_EN_SEL[2:0] CFG1
CLK BUS
Clock
EN Bit
Enable
0xFFFF 0xFFFF
0xFFFE 0xFFFE
0xFFFD 0xFFFD
0x1000
0x1 0x1
Count Value 0x0
0x0
Capture
Input Pin
Capture
0xFFFD 0x1000
Register
Capture
Interrupt
Figure 27-4 is a timing diagram for the timer reset signal (Period register = 0xFFFF).
Clock
EN Bit
Enable
Timer
Reset
0xFFFF 0xFFFF
0xFFFE 0xFFFE
0xFFFD 0xFFFD
0x0100 0x0100
0x00FF 0x00FF
Count Value
0x1
0x0000 0x0
Clock
EN Bit
Period changed Period changed
without changing EN after EN = 0
Period
0xFFFF 0x00FF 0xE000
Value
Automatic reload Immediate effect
of period after EN = 1
0xFFFF 0xFFFF 0x00FF 0xE000 0xE000
0xFFFE 0xFFFE 0x00FE 0xDFFF 0xDFFF
0xFFFD 0xFFFD 0xDFFE 0xDFFE
0x00FD
Count Value
0x0 0x0 0x0 0x0
Terminal Count
Output Pin
Terminal
Count
Interrupt
Pulse Width Mode The count value is read using 16-bit read in case of a 32-bit
controller and 8-bit read in case of a 8-bit controller. During
The input signal is given to the Enable pin. The timer begins
16-bit read, the count values are read as one 16-bit value
counting at the rising edge of the Enable signal and stops
and the value is captured in the Capture register. During the
counting at the falling edge of the Enable signal. There is a
8-bit read, a read of the CNT0 (LSB value) captures the LSB
latency of one clock cycle for the block to detect the edges.
and MSB in the Capture register. The user can read the
The difference in the count value before and after the count Capture register to obtain the time value.
is equal to the pulse width of the input signal in terms of
Figure 27-6 shows the Gated Timer in Pulse Width mode. In
counts.
this figure, the One Shot mode is disabled, so the timer will
start to count when the next rising edge is encountered.
When the One Shot mode is enabled, the timer stops after
the falling edge and should be enabled again.
Clock
EN Bit
Enable Pin
0xFFFF
0xFFFE
0xFFFD
0x1001
0x1000 0x1000
0x0FFF
0x0FFE
Count Value
0x0100
0x00FF
Final CNT.reg
Value 0x1000 0x00FF
Timer Stop
Interrupt
Period Mode The count value is read, using a 16-bit read in the case of a
32-bit controller and an 8-bit read in case of an 8-bit control-
The input signal is given to the Enable pin. In this mode, the
ler. During a 16-bit read, the count values are read as one
timer begins counting at the rising edge of the Enable signal
16-bit value, and the value is captured in the Capture regis-
and stops counting at the next rising edge. There is a
ter. During the 8-bit read, a read of the CNT0 register (LSB
latency of one clock cycle for the block to detect the edges.
value) captures the LSB and MSB in the Capture register.
The difference in the count value between the start and the The user can read the Capture register to obtain the time
end of the count is equal to the period (in counts) of the value.
input signal.
Figure 27-7 shows the Gated Timer in Period mode. In this
figure, the One Shot mode is disabled; the timer starts to
count when encountering the next rising edge after the
period calculation. When the One Shot mode is enabled, the
timer stops after the second rising edge and should be
enabled again.
Clock
EN Bit
Enable Pin
0xFFFF
0xFFFE
0xFFFD
0x1001
0x1000 0x1000
0x0FFF
0x0FFE
Count Value
0x0100
0x00FF
Final CNT.reg
Value 0x1000 0x00FF
Timer Stop
Interrupt
Clock
EN Bit
IRQ Pin
0xFFFF
0xFFFE
0xFFFD
0x1001
0x1000
Count Value
Final CNT.reg
0x1000
Value
Timer Stop
Interrupt
27.3.4.3 Pulse-width Modulator Mode During the Comparator mode alone, the terminal count out-
put pin acts as the complement to the compare output pin.
The Pulse-width Modulator (PWM) mode is also called the
To use this feature, enable the dead band mode (see Dead
Comparator mode, because the comparison output is a
Band Feature on page 308). Enable the dead band feature
PWM output with a varying duty cycle and a varying period.
by setting ‘1’ in the DB bit of CFG0. In the Comparator
The duty cycle depends on the compare type and compare
mode, the CNT register cannot be read.
value. The period depends on the Period register. For exam-
ple, consider a 16-bit PWM block with a clock of 48 MHz. Compare Types
The period value is set to 0x8000 (32768 in decimal). This
block gives a PWM period as follows: The following is a description of various compare types.
PWM period for this example = (32768 * 1/48MHz) = 682.7 The compare output pin generates a pulse when the timer
microsecond value = the comparator value. In this case, the width of the
pulse = one clock cycle. The compare output interrupt signal
The register configuration for the Comparator mode is: occurs when the compare value = Timer Value.
■ Registers to set – TMRx_CFG0, TMRx_CFG1
MODE_CFG = 001
■ Bit MODE in TMRx_CFG0 = 1 – block acts as Compara-
tor The compare output pin generates a pulse when the timer
value is less than the comparator value. The following
■ Three Bits MODE_CFG in TMRx_CFG1 – Comparator
describes the event:
runs in various compare modes
■ The width of the pulse = one clock cycle x Comparator
The following table lists appropriate register settings. value.
Table 27-2. Register Settings for Compare Type ■ The rising edge occurs when the timer value becomes
less than the comparator value, such as when the less
MODE_CGF Comments
than condition is met.
000 Timer Value == Comparator Value
■ The falling edge of the pulse occurs when the terminal
001 Timer Value < Comparator Value count is reached, such as when the condition changes to
010 Timer Value <=Comparator Value false.
011 Timer Value > Comparator Value ■ When the comparator is disabled (EN = ‘0’) before the
100 Timer Value >= Comparator Value terminal count, the output remains high.
■ The Compare output interrupt signal occurs when the
The Comparator mode compares the timer value and the timer value is less than the Compare value.
Compare register value, using either “==”, “<”, “<=”, “>” or
MODE_CFG = 010
“>=” depending on the mode configuration in the CFG1 reg-
ister. The compare output pin generates a pulse when the timer
value is less than or equal to the comparator value. The fol-
The following describes the compare process:
lowing describes the event:
1. The timer value begins to count when EN = ‘1’.
■ The width of the pulse = one clock cycle x (Comparator
2. When the compare is true, the compare output signal is value + 1).
asserted or the compare interrupt signal is asserted. The
■ The rising edge occurs when the timer value becomes
block continues to count.
equal to the comparator value, such as when the less
3. The CNT register is reloaded with the period value when
than or equal to condition is met.
the terminal count is reached and begins to count com-
pare again. ■ The falling edge of the pulse occurs when the terminal
4. The output of the compare is either the compare output count is reached, such as when the condition changes to
signal or interrupt at the compare. false.
5. The interrupt occurs when the compare interrupt enable ■ When the comparator is disabled (EN = ‘0’) before the
bit is unmasked in the Status register. terminal count, the output remains high.
6. The compare output signal is routed to the GPIO pin ■ The Compare output interrupt signal occurs when the
using the DSI. timer value = Compare value.
The compare output pin generates a pulse when the timer The compare output pin generates a pulse when the timer
value is greater than the comparator value. The following value is greater than or equal to the comparator value. The
describes the event: following describes the event:
■ The width of the pulse = one clock cycle x (Period – ■ The width of the pulse = one clock cycle x (Period –
Comparator value). Comparator value + 1).
■ The rising edge occurs when the Count register is ■ The rising edge occurs when the Count register is
reloaded with the period value, such as when the greater reloaded with the period value, such as when the greater
than condition is met. than or equal to condition is met.
■ The falling edge of the pulse occurs at the end of count ■ The falling edge of the pulse occurs at the end of count
value = (Comparator value + 1), such as when the condi- value = Comparator value, such as when the condition
tion changes to false. changes to false.
■ When the comparator is disabled (EN = ‘0’) before the ■ When the comparator is disabled (EN = ‘0’) before the
condition changes to false, the output remains high. condition changes to false, the output remains high.
■ The Compare output interrupt signal occurs after the ■ The Compare output interrupt signal occurs after the
reload of the period value. reload of the period value.
Clock
EN Bit
Enable
Compare 0x0100
Register
0xFFFF 0xFFFF
0xFFFE 0xFFFE
0xFFFD 0xFFFD
0x0100 0x0100
0x00FF 0x00FF
Count Value
0x1 0x1
0x0 0x0
Compare Timer =
Output Pin Compare
Timer <
Compare
Timer <=
Compare
Timer >
Compare
Timer >=
Compare
■ A dead band period of zero has no effect. The following table shows end criteria (where the block
■ When the rate of change in the compare output is less would stop) for each mode. When an end criterion is met,
than the dead band period, the immediate change is the block stops running and the EN bit is cleared. If the user
ignored. Transitions in the compare and complement wants to run the block again, then the block must be
compare output occur only for the next change in the enabled (EN = ‘1’):
compare output.
Table 27-3. Block Stops
■ When the rate of change in the compare output is more
than the dead band period, the transitions occur at both Modes Sub-Types Criteria
PSoC® 3 and PSoC® 5 devices include a fixed block I2C peripheral designed to interface the PSoC device with an I2C com-
munications bus. Additional I2C interfaces can be created using Universal Digital Blocks (UDBs) and PSoC Creator™. This
chapter describes the fixed block I2C interface. For details on the UDB-based interface, see the component datasheet in
PSoC Creator. Users not familiar with the I2C interface and the basics of an I2C transaction should refer to 28.3 Background
Information.
28.1 Features
The I2C communication block is a serial to parallel processor, designed to connect the PSoC device to a two wire I2C serial
communications bus. To eliminate the need for excessive CPU intervention and overhead, this block gives I2C specific sup-
port for status detection and framing bit generation.
This block operates as a slave, a master, both, or a multimaster. When active in slave mode, the unit listens for a start condi-
tion, or sends or receives data. The master modes works in conjunction with slave mode. The master has the ability to gener-
ate a START and STOP condition and determine whether or not other masters are on the bus. For multimaster mode lock
synchronization is supported.
I2C Registers
Master Mode
PHUB Interface Slave Mode Logic
Logic
IRQ
Serial
Interface
28.3 Background Information ■ Multiple masters are supported, using collision detection
and arbitration if two or more masters simultaneously ini-
The following information is provided to familiarize the user tiate data transfer.
with the I2C bus and the way it transfers data.
For more information, see the I2C-Bus Specification, and
User Manual, Version 03 at http://www.nxp.com/
28.3.1 I2C Bus Description acrobat_download/usermanuals/UM10204_3.pdf.
The Inter IC, or I2C, bus was developed by Philips Semicon-
ductors (now NXP) to provide a simple means to allow multi- 28.3.2 Typical I2C Data Transfer
ple ICs to communicate directly with each other over a
In a typical I2C transaction, the following sequence takes
common bus. Features of the I2C bus include:
place:
■ Only two bus lines are required: (1) serial data (SDA)
1. A master device controls the SCL line and generates a
and (2) serial clock (SCL).
Start condition followed by a data byte. The data byte
■ Serial, 8-bit, bi-directional data transfers can be made at contains a 7-bit slave address and a Read / Write (RW)
up to 100 kbps in the standard mode, up to 400 kbps in bit. The bit sets the direction of the data transfer, relative
the fast mode and up to 1 Mbps in the fast mode plus. to the master. It is high for read and low for write.
See Figure 28-2 for bus states. 2. The slave device recognizes its address and acknowl-
■ Devices are connected to the bus using open collector or edges (ACK) the byte by pulling the data line low during
open-drain output stages, with pull up resistors, for wired the ninth bit time.
AND functions. If the slave does not respond to the first data byte with
■ Each slave device connected to the bus is software an ACK, a Stop condition is generated by the master to
addressable by a unique address. terminate the transfer. A Repeated Start condition may
also be generated for a retry attempt.
■ Simple master/slave relationships exist; masters and
slaves can operate as either transmitters or receivers. 3. The master transmits or receives an indeterminate num-
ber of bytes, depending on the RW direction.
4. When the transfer is complete, the master generates a
Stop condition.
Figure 28-2. I2C Transfer of a Single Data Byte, With Clock Stretching by a Non-PSoC Slave
P
SDA
MSB Acknowledgement Acknowledgement SR
signal from Slave signal from Receiver
Byte complete, Clock line held low while
interrupt within Slave interrupts are serviced.
SCL S or 1 2 7 8 9 1 2 3-8 9 SR
SR or P
ACK ACK
START or STOP or
Repeated Repeated
START START
condition condition
28.4 How It Works ■ Master – The interface generates the Start and Stop
conditions and initiates data transfers by transmitting a
The PSoC 3 and PSoC 5 I2C interface provides support for slave address.
bus status detection and generation of framing bits. It can ■ Multi-Master – The interface provides clock synchroniza-
operate at up to fast mode plus speeds, in these modes: tion and arbitration to allow multiple masters on the
■ Slave – The interface listens for Start and Stop condi- same bus. Slave mode can be enabled at the same time
tions to begin and end data transfers. as master mode.
tions 28.7 Slave Mode Transfer Examples on page 319, 28.4.2 System Management Bus
28.8 Master Mode Transfer Examples on page 322, and
28.9 Multi-Master Mode Transfer Examples on page 324. The System Management Bus (SMBus) is a bus definition
based on the I2C bus. It is similar to, and generally a subset
The I2C interface supports either 7-bit or 10-bit addressing. of, the I2C bus. For more information, see the SMBus Spec-
The hardware supports 7-bit address compare. In slave ification, Version 1.1. The I2C interface generally supports
mode, 7-bit address detection is done by using either a SMBus, although additional firmware support may be
hardware address compare or by the CPU in firmware. A required.
10-bit address detection must be done by the CPU in firm-
ware. In master mode, 10-bit address generation must be 28.4.3 Pin Connections
done by the CPU in firmware.
The I2C block controls the data (SDA) and the clock (SCL)
28.4.1 Bus Stalling (Clock Stretching) to the external I2C interface, through direction connections
to the GPIO/SIO pins. When I2C is enabled, these GPIO/
After a byte is transferred on the I2C bus, a slave device SIO pins are not available for general purpose use.The SDA
may need time to store the received byte or to prepare and SCL connections of the I2C interface can be directly
another byte to be transmitted. In that case, the slave can routed to one of two pairs of assigned pins on the SIO port.
hold the SCL line low before or after acknowledgment of a The connections can also be routed through the DSI to any
byte, which forces the master into a wait state until the slave other pair of GPIO or SIO pins. In all cases, the GPIO or SIO
is ready. This operation is known as stalling the I2C bus. pins must be configured for “Open Drain, Drives Low” mode
Some devices in master mode may not support bus stalling; (see 21.3.2.5 Open Drain, Drives High and Drives Low on
the system design should be checked before using bus stall- page 192).
ing in slave mode.
The I2C must be routed to the SIO pins in order to use the
The I2C interface can stall the bus on every received block in sleep.
address and on every completed byte transfer. After a byte
is transferred, the CPU has half of the SCL clock cycle
period to write/read the next byte before stalling begins.
28.4.4 I2C Interrupts
SCL is released when the next byte is written/read, and the The I2C interface generates interrupts for these conditions:
next byte transfer begins. ■ Byte transfer (receive or transmit) complete
■ I2C bus Stop condition detected
■ I2C bus error detected
Table 28-1. I2C Registers (continued) 2. To route the SDA and SCL to the desired pin pair, set up
I2C_CFG as described in Table 28-2.
Register Usage
3. Select the baud rate (SCL clock frequency) by setting
Control / Status – used to control the flow of data bytes
I2C_CSR
and to keep track of the bus state during a transfer. the I2C_CFG register, bit 2and the I2C_CLK_DIV1 and
I2C.CLK_DIV2 registers as shown in Table 28-3. The
Master Mode Control / Status – implements I2C framing
I2C_MCSR
controls and provides bus status.
formula to determine the baud rate is:
Slave Address – for slave address recognition in hard- Baud Rate = Bus clock frequency / (Clock Division Fac-
I2C_ADR
ware, holds the 7-bit slave address. tor * Oversample Rate)
Data – provides read / write access to the data shift 4. Enable the desired mode of operation, following the
I2C_D
register.
instructions in 28.4.6.1 Slave Mode on page 316,
28.4.6.2 Master Mode on page 317, or 28.4.6.3 Multi-
28.4.6 Operating the I2C Interface Master Mode on page 318.
Operate the I2C interface in this manner:
1. Turn on the I2C interface by setting the I2C_XCFG bit 7,
csr_clk_en.
9 1 7 8 9
ACK = Master
wants to read
another byte.
In slave mode, the I2C interface continually monitors the bus NACK or a Stop condition is a signal that the master
for a Start condition. When a Start condition is detected, the doesn’t want any more bytes – the CPU should let the
following ensues. I2C interface go to an idle state.
1. The first byte, which is the Address / RW byte, starts to 5. When receiving bytes, the slave ACKs / NACKs each
be shifted in. When all eight bits have been received, a byte received from the master.
Byte Complete status is generated. ACK is a signal that the slave can accept another byte.
2. On the following low of the clock, the bus is stalled by NACK is a signal that no more bytes can be accepted –
holding SCL low, until the address byte is read and com-
after generating a NACK the CPU should then let the I2C
pared. An ACK or NACK is then issued, based on that
interface go to an idle state.
comparison.
3. If there is an address match, the RW bit determines the 6. Data transfer is complete when the master generates a
direction of the data transfer, as shown in the two Stop condition.
branches of Figure 28-3. After each byte is received, or 7. At anytime when a Stop condition or Bus Error is
when a new byte can be transmitted, a Byte Complete detected, the I2C interface is automatically reset to an
status is generated, and SCL is held low to stall the bus idle state.
until the CPU handles the interrupt and transfers the
next byte.
4. When transmitting bytes, the slave receives an ACK /
NACK from the master for each byte sent.
ACK is a signal that the master wants another byte.
Slave Address Recognition When hardware address recognition is enabled, the address
portion of the first byte received after a bus Start condition is
The slave address recognition feature can be enabled in
compared to the value in I2C_ADR.
hardware to reduce CPU usage. To enable hardware
■ If no match is detected, the byte is automatically NAKed.
address recognition:
■ If a match is detected, the byte is automatically ACKed,
1. Set the 7-bit slave address in I2C_ADR, bits 0 to 6.
a byte complete interrupt is generated, and the remain-
2. Set I2C_XCFG, bit 0, HW Addr En. der of the transfer is performed as described above.
data
CPU reads the
START 7-Bit Address R/W received byte from
I2C_D register.
ACK
CPU checks Read/
Write Bit
1 7 8 9
Write (TX)
1 7 8 9
ACK = Slave
says OK to
receive more.
Master can
send more or
Stop
Master wants to
send more bytes.
If Enable Slave is not set, the I2C interface is in Master Only 2. When transmitting bytes, the master receives an ACK/
mode and ignores all externally generated Start conditions. NACK from the slave for each byte sent.
ACK is a signal that the slave can accept another byte.
Operation in master mode is as follows:
NACK is a signal that no more bytes can be accepted.
1. To start a transfer, the CPU writes the slave address/
direction byte to I2C_D and sets I2C_MCSR bit 0, Start
Gen (or bit 1, Restart Gen).
In a single-master environment the Start condition is
successfully generated, the byte is transmitted, and a
Byte Complete is generated. If the byte is ACKed by the
slave, data bytes can be sent or received as shown in
the two branches of Figure 28-4.
3. When receiving bytes, the master ACKs/NACKs each Lost Arb bit is set. The hardware waits for a com-
byte received from the slave. mand from the CPU, stalling the bus if necessary.
ACK is a signal that the master wants another byte. The master clears I2C_CSR to release the bus and
allow the transfer to continue, and the I2C interface
NACK is a signal that the master is done accepting
goes back to idle mode. The firmware can then retry
bytes.
the transfer when the bus becomes free again.
4. When data transfer is complete, the CPU issues a Stop
command. The I2C interface generates a Stop condition
and goes to an idle state. 28.5 Hardware Address Compare
Instead of a Stop condition, the CPU can issue a Restart The hardware has the ability to compare the seven address
command, and another transfer is immediately started. bits received on the SDA line with that configured in the
I2C.ADR register. On a true compare, the address is auto-
28.4.6.3 Multi-Master Mode matically ACKed, the SCL line held low, and a byte complete
Multi-master mode becomes enabled when Master mode is interrupt is issued. On reception of the byte complete inter-
enabled by setting the I2C_CFG bit 1, Enable Master. rupt from the hardware, the firmware needs to read bit [0] of
the data register to determine Read/Write direction for the
In Multi-master mode, the CPU starts the transfer in the transfer. The firmware must then set the transmit bit in the
same manner as in a single-master environment. However, I2C.CSR register to release the SCL. On an mismatch the
before generating a Start condition, the master must monitor address is automatically NAKed and the hardware revert to
the Bus Free bit in I2C_MCSR, and wait until the I2C bus is an idle state waiting for the new Start detection.
free.
After a Start condition is generated other outcomes may 28.6 Wake from Sleep
result, causing the CPU to delay or abort the transfer:
■ Another master in a multimaster environment has gener- When the HW address compare is enabled and the device
ated a valid Start, and the bus is now busy. The Start is put to sleep, the slave can be used to wake the device on
condition is not generated. The resulting behavior an I2C HW address match (only when either of the SIO pairs
depends upon whether Slave mode is enabled. are used as I2C pins). While in sleep, the master clock is
disabled. The incoming SCL clock is used to latch the
❐ Slave mode is enabled – A Byte Complete interrupt
address into the block. Once the address matches, the
is generated. When reading I2C_MCSR, the master
sees that the Start Gen bit is still set and that wakeup interrupt is asserted to wake the system up, and the
I2C_CSR has the Address bit set, indicating that the SCL is pulled low until the master clock is operational. After
block has been addressed as a slave. The firmware the system wakes, the I2C block is switched back to normal
may then ACK the address to continue the transfer operation, and all other transaction proceed.
as a slave, or NACK the address.
The I2C Block only responds to transactions during sleep if
❐ Slave mode is not enabled – The Start Gen bit and only if:
remains set, and the transfer is delayed until the bus
becomes free. A Byte Complete is generated when ■ The I2C block is enabled in slave mode and slave mode
the Start condition has been generated and the only
address byte has been transmitted. ■ Hardware address compare is enabled
■ The Start condition is generated, but the master loses ■ There is an address value written in the I2C.ADR
arbitration to another master. The resulting behavior
■ The I2C_ON bit in I2C.XCFG is set to 1'b1
depends upon whether Slave mode is enabled.
❐ Slave mode is enabled – A byte complete interrupt is Follow this procedure before putting the part to sleep, to
generated. When reading I2C_MCSR, the master ensure proper sleep mode I2C operation.
sees that the Start Gen bit is clear, indicating that the 1. The CPU must set the Force NACK bit of the I2C.XCFG
Start condition was generated. However, the Lost register when it wants to put the part into sleep.
Arb bit is set in I2C_CSR. The Address status is also
2. The FW must poll the Ready_To_Sleep bit in the
set, indicating that the block has been addressed as
I2C.XCFG bit. One the bit is high, FW can put the part to
a slave. The firmware may then ACK the address to
sleep.
continue the transfer as a slave, or NACK the
address.
❐ Slave mode is not enabled – A Byte Complete inter-
rupt is generated. The Start Gen bit is clear and the
Start
YES
Write ‘0’ to I2C.CSR to clear all bits.
NO
I2C_CSR[3] == 1, E
Address?
Set I2C_CFG[3:2], Clock Rate,
and I2C_CLK_DIV
to set the SCL frequency. YES
YES I2C_D[0] = 0, NO
Go do slave transmit functions.
I2C Write?
ERROR
Byte Complete, I2C_CSR[0] == 1, NO
E or Error, I2C_CSR[7] != 0, or
Stop, I2C_CSR[5] != 0?
STOP
NO ERROR
YES Stop Status, I2C_CSR[5] == 1, E
or Error, I2C_CSR[7] != 0?
Copy I2C_D to receive data buffer.
YES
Start
Write ‘1’ to I2C_XCFG[7], Clk Gate En, NO Byte Complete, I2C_CSR[0] == 1, ERROR
E
to start up the I2C interface hardware. or Error, (I2C_CSR & 0xA0) != 0?
YES
Write ‘0’ to I2C_CSR to clear all bits
NO
I2C_CSR[3] == 1, E
Address?
Set I2C_CFG[3:2], Clock Rate,
and I2C_CLK_DIV
to set the SCL frequency. YES
NO I2C_D[0] = 0, YES
Go do slave receive functions.
I2C Write?
NO ERROR
Stop Status, I2C_CSR[5] == 1, E
ERROR
NO or Error, I2C_CSR[7] != 0?
Byte Complete, I2C_CSR[0] == 1,
E
or Error, (I2C_CSR & 0xA8) != 0?
YES
YES
Report a successful transfer.
ACK
Byte ACK’ed or NACK’ed?
I2C_CSR[1]
End
E
NACK
Note that, instead of waiting for Byte Complete or Error, an interrupt can be generated for each of these conditions, as well as
for the I2C Stop condition. The interrupt handler can then do some or all of the functions shown.
YES
Set I2C_CFG[3:2], Clock Rate,
and I2C_CLK_DIV
NACK
to set the SCL frequency.
Byte ACK’ed or NACK’ed?
* If address byte is NACK’ed, I2C_CSR[1]
instead of retry, an error can
be reported.
ACK
Set I2C_CFG[7:6], SIO Select and PSelect,
to connect SDA and SCL to the
appropriate pins. Write ‘0’ to I2C_CSR[2] to set Receive mode.
ERROR
Byte Complete, I2C_CSR[0] == 1, NO
E
or Error, (I2C_CSR & 0xA0) != 0 or
I2C_MCSR[2] != 1?
NO ERROR
YES Stop Status, I2C_CSR[5] == 1, E
or Error, I2C_CSR[7] != 0?
Copy I2C_D to receive data buffer.
YES
YES
Report and handle error. End
YES
Set I2C_CFG[3:2], Clock Rate,
and I2C_CLK_DIV
NACK
to set the SCL frequency.
Byte ACK’ed or NACK’ed?
* If address byte is NACK’ed, I2C_CSR[1]
instead of retry, an error can
be reported.
ACK
Set I2C_CFG[7:6], SIO Select and PSelect,
to connect SDA and SCL to the
appropriate pins. Write ‘1’ to I2C_CSR[2] to set transmit mode.
YES
Copy first/next byte from transmit data buffer to I2C_D. Write ‘0’ to I2C_CSR[2]
Write ‘1’ to I2C_CSR[2] to start transmitting byte. to generate a Stop condition.
ERROR NO
Byte Complete, I2C_CSR[0] == 1, NO Stop Status, I2C_CSR[5] == 1, ERROR
E E
or Error, (I2C_CSR & 0xA0) != 0 or or Error, I2C_CSR[7] != 0?
I2C_MCSR[2] != 1?
YES YES
NACK End
E
Write to I2C_CSR[4]. A Stop
condition is automatically
generated by the hardware,
regardless of the value written. Report and handle error.
Defining single master operations allows the following ■ There is no need to Enable Slave (I2C_CFG[0]) when
assumptions to be made: enabling the master mode, as the interface will never be
■ There is no need to check for bus busy (I2C_MCSR[3]) forced into slave mode due to bus busy or lost arbitra-
or Lost Arb (I2C_CSR[6]). tion.
Start
NO
Write ‘0’ to I2C_CSR to clear all bits. Write ‘1’ to I2C_MCSR[0], Start Gen,
to start the transfer.
Start condition? NO
I2C_MCSR[0] == 0 Bus became
busy.
Set I2C_CFG[7:6], SIO Select and PSelect,
to connect SDA and SCL to the YES
appropriate pins.
YES
Set I2C_D = Slave Addr/Read or Write
Start
NO
Write ‘0’ to I2C_CSR to clear all bits.
YES
Set I2C_CFG[1], Enable Master,
and I2C_CFG[0], Enable Slave,
to start both modes.
Bus became busy,
YES or lost arbitration?
I2C_MCSR[0] == 1 and
I2C_CSR[3] == 1
Set I2C_D = Slave Addr/Read or Write.
NO
Report and handle error. Continue with address Continue with data transfer
recognition as a slave. as in single master.
Some PSoC® devices have a dedicated hardware Digital Filter Block (DFB) used to filter applications. The heart of DFB is a
multiply and accumulate unit (MAC), which can do 24 bit * 24 bit multiply and 48 bit accumulate in one system clock cycle. In
addition, there are data RAMs to store data and coefficients of digital filters.
29.1 Features
■ Two 24-bit wide streaming data channels
■ Two sets of data RAMs each that can store 128 words of 24-bit width each
■ One interrupt and two DMA request channels
■ Three Semaphore bits to interact with system software
■ Data alignment and coherency protection support options for input and output samples
The Controller consists of a small amount of digital logic and memories. The memories in the controller are filled with assem-
bled code that make up the data transform function the DFB is intended to perform.
The Datapath subblock is a 24-bit fixed point, numerical processor containing a Multiply and Accumulator (MAC), a multi-
function Arithmetic Logic Unit (ALU), sample and coefficient and data RAM (data RAM is shown in Figure 29-1) as well as
data routing, shifting, holding, and rounding functions. The datapath block is the calculation unit inside the DFB.
The addressing of the two data RAMs in the datapath block are controlled by the Address Calculation Units (ACUs). There
are two (identical) ACUs, one for each RAM.
These three subfunctions make up the core of the DFB block and are wrapped with a 32-bit DMA-capable AHB-Lite Bus Inter-
face with Control/Status registers. Each of these four subfunctions are discussed in the following sections.
D a ta p a th
MAC S ta g e S ta g e
In p u t fr o m
ALU R e g is te r R e g is te r CPU/ DMA
S h ift A B
H o ld
Bus
Round In te r fa c e
D a ta D a ta H o ld H o ld
O u tp u t to
RAM A RAM B R e g is te r R e g is te r CPU/ DMA
A B
C o n tr o l
d fb _ in tr
C o n tr o lle r
ACU A ACU B d fb _ d m a r e q 1
d fb _ d m a r e q 2
A d d r e s s C a lc u la tio n U n it
d fb _ g lo b a li1 & 2 d fb _ g lo b a lo 1 & 2
D S I s ig n a ls
F ig u re 3 0 - 1 . D ig ita l F ilte r B lo c k D ia g r a m
Fjump addr
Fjump limit
Jump addr
FSM RAM Loop
PC PC
fsm_addr[4:0]
nstate[4:0]
fstate[4:0]
A B
loop
csa_addr[5:0] csb_addr[5:0]
Next State
Conditions
Logic
RAM Selection
To Datapath,
eob
ACU, and
Bus Interface
The contents of FSM RAM, the two control store RAMs, the correct CS RAM output. Opcode execution then switches to
ACU RAM, and potentially the two datapath RAM (if initial and stays with the CS RAM until the next jump condition.
conditions are required) must be loaded by the system
before use. The contents of the DFB RAMs are stored in 29.3.1.1 FSM RAM
flash memory from where they are written into the RAM
FSM RAM is 64x32 RAM. It is used as ROM. The FSM RAM
before the DFB operation is enabled.
is filled with control flow information implementing the
The next state decode logic and the FSM RAM comprise the desired function of the DFB prior to use. This RAM is loaded
main DFB branch control. The next state decoder generates typically at system boot time, but is not restricted to any par-
the FSM RAM’s address and the RAM produces next state ticular time as long as the DFB is not running (run is deas-
information as well as branch flag masks. These masks serted in DFB_CR[0]). The code in this and the Control
enable the use of flags as jump conditions for conditional Store RAMs can be altered at anytime to change the func-
branching. This state machine controls the program counter tion performed by the DFB. In fact, some applications have
to produce the address for the Control Store RAMs. the algorithm loaded routinely and swapped out when sev-
eral channels of data need processing or when one channel
There are two identical Control Store (CS) RAMs and an
needs multiple transforms – when the code is too large to fit
associated Program Counter to allow an interleaving meth-
in the available space.
odology for CS opcode fetches. The CS RAMs are 64x32
each. The FSM RAM is addressed as two banks of 32x32. The
Bank selection is achieved using the CSR bit (DFB_CR[1]).
Both CS RAMs are sometimes filled with identical data. It is
The primary use of the two banks is to allow two separate
possible to effectively double the control store instruction
code stores to load and jump between without incurring the
space by using different contents in each RAM. It is during
reload penalty of the FSM RAM.
branch conditions that next state address calculations hap-
pen. Hence, the two possible branch addresses are sup-
plied – one to each RAM. When the branch condition is
determined, late in the cycle, the controller simply picks the
Table 29-1 shows the bit fields used for the controller by the 32-bit FSM RAM.
The outputs of these two 32-bit wide RAMs are muxed to one control bus (based upon which is presently the active RAM
denoted by DFB_SR[0]) and provide the following bit-fields to the ACUs and Datapath unit listed in Table 29-2.
29.3.1.4 Next State Decoder 2. Datapath status inputs such as sign, threshold, and
equal.
The Next State Decoder is combination logic that controls
❐ Dpsign – A jump based on the MSB of the ALU out-
the state transitions in the FSM RAM. The next state
put. If ALU output goes negative, assert.
decoder is the logic that gives the address (state address) to
❐ Dpthresh – Datapath Threshold – Asserted when the
the FSM. The result of the next state decoder is governed
ALU detects a sign change, such as a zero crossing
by the branching signal conditions. You get a state transition
detection.
when one of these two conditions exist:
❐ Dpeq – Datapath Equity – Asserted when the ALU
■ EOB is high and the signal condition goes high. This is hardware detects an output value of zero.
the jump on true branch.
3. Acueq – ACU A or B REG is equal to MREG or LREG, if
■ Loop (cfsmram[23]) is low meaning no loop, EOB is modflag is set. ACU A or B REG is equal to 127 or 0, if
high, and condition is low. This is the flow through condi- modflag is cleared. This means that the pointer to the
tion for a false condition. DP Data registers has reached its upper/lower limit.
Refer to 29.3.2 Datapath on page 331 for clarity.
The branching conditions are:
1. End of block is encountered for a control store block – a
condition for a jump because a jump instruction signifies
the end of the block.
4. IN1 or IN2 – When new data is available in one of the 29.3.2 Datapath
staging registers A or B. Signals a new input cycle and is
available for consumption. Remains asserted until Datapath (DP) is the name used to refer to the numerical
cleared by a bus read command. calculation unit of the DFB. The datapath subblock is a 24-
5. globali1 – Branch control input from DSI port. bit fixed-point numerical processor containing a 48-bit MAC,
a multi-function ALU, sample and coefficient data RAMs as
6. globali2 – Branch control input from DSI port.
well as data routing, shifting, holding and rounding func-
7. The sat_det flag (Saturation) from ALU – This flag is set
tions.
when saturation occurs in MAC, ALU, or Shifter.
8. Any of the semaphores (refer to the PHUB and The DP architecture makes use of two 128x24 single-port
DMAC chapter on page 91). RAMs (RAM A and RAM B). The RAMs can be loaded from
the bus or from the datapath output (feedback). These
For branching, the branching conditions must be enabled.
RAMs hold data and coefficients with size and location
The ENGLOBALS, ENSATRND, ENSEM, SETSEM, and
under full DFB controller control.
CLEARSEM commands are used.
The heart of the DP unit is a 48-bit Multiply and Accumulator
If the ALU command is ENSEM, then the data on
(MAC). Two 24-bit values can be multiplied and the result
acu_addr[2:0] is written to the register sem_en for enabling
added to the 48-bit accumulator in each clock cycle. This
semaphores to be branching conditions. The acu_addr[2:0]
accumulator or any memory value can be routed to the ALU.
is converted bitwise to enable each of the three sema-
Results from the ALU can then be stored in either Data
phores.
RAM. The MAC is the only portion of the DP that is wider
The SETSEM and CLEARSEM are used to set or clear the than 24 bits. All results from the MAC are passed on to the
semaphores based on the semaphore selected in ALU as 24-bit values representing the high-order 24 bits in
acu_addr[2:0]. the accumulator shifted by one (bits 46:23). The MAC
assumes an implied binary point after the MSB which shifts
Acu_addr[2] -> semaphore2
the result down a bit in the output of the MAC. For this rea-
Acu_addr[1] -> semaphore1
son, bits 46:23 are used instead of 47:24.
Acu_addr[0] -> semaphore0
The DP unit also contains an optimized ALU that supports
The ENGLOBALS command is used to enable the use of
add, subtract, comparison, threshold, absolute value,
external dsi inputs and datapath saturation flags as branch-
squelch, saturation, and other functions.
ing conditions. ENGLOBALS shares an ALU opcode with
ENSATRND. They are differentiated by the acu_addr[3] bit With the exception of the DP RAM addresses, the DP unit is
as shown in Table 29-3. completely controlled by seven control fields totaling 18 bits
coming from the DFB Controller as the DP_CTRL control
Table 29-3. ENGLOBALS and ENSATRND Commands bus (Table 29-2 on page 330). These 18 bits of control are
Acu_addr[0]: enables globali1 listed in Table 29-4.
Englobals Acu_addr[3]=0 Acu_addr[1]: enables globali2
Acu_addr[2]: enables sat_det
Acu_addr[0]: writes to rnd_flag
Acu_addr[1]: writes to sat_flag
Ensatrnd Acu_addr[3]=1
Acu_addr[2]: creates strobe to clear satura-
tion flag
Note how the different signals from Table 29-4 affect the functioning of the different elements in the datapath.
mux1a mux2a
mux3a
mux2a
alu_op[4:0]
mux1a
RAM A
128 x 24
mux3a
shift_op[2:0]
mac_op[1:0]
dp_out
A
Pass Mux
AHB Round AHB
MAC Hold Shift
Bus or Pass
Bus
B
mux3b
Round Flag
mux1b
RAM B
128 x 24
mux2b
mux3b
mux1b mux2b
Round Mode – If DP is in Round mode, any result passing out of the DP unit is being rounded to a 16-bit value. This feature
status is shown in the register setting, DFB_SR [2].
Saturation Mode – If DP is in Saturation mode, any mathematical operation that produces a number outside the range of a
24-bit 2’s complement number is clamped to the maximum positive or negative number. Enabling and disabling saturation
and rounding is under the control of DFB controller. See the ALU instruction set. The status is visible at DFB_SR [1].
29.3.2.1 MAC instead of 47:24. The instruction set for the MAC, ALU and
Shifter is listed in Table 29-7 on page 339, Table 29-6 on
The multiply add function takes two 24-bit signed numbers
page 339, and Table 29-8 on page 340.
and calculates a 48-bit signed result, then adds a signed 48-
bit value ((a*b)+c). 29.3.2.2 ALU
The accumulator consists of a 48-bit register and the multi- The ALU provides data control on the output end of the data
ply adder. path. ALU supports add, subtract comparison, threshold,
Together these two functions, along with some control logic, absolute value, squelch, saturation, and other functions.
make up the MAC. Based on the opcode (mac_op) coming See Table 29-6 for various instructions supported by ALU.
from the DFB controller it can do one of the following opera- The ALU commands as well as inputs are pipelined. This
tion: pipelining can be made use for data movement in some fil-
■ Multiply and accumulate with previous Values tering applications. This pipelining causes a delay of two
■ Clear Accumulator and load with current product. clock cycles for the ALU input to reach the output.
■ Hold accumulator, no multiply (no power in mult)
29.3.2.3 Shifter and Rounder
■ Add ALU value to product and start new accumulation
The shifter at the ALU output can be used to shift the ALU
The output of MAC is higher order 24 bits of multiply accu- results as required. See Table 29-8 for various shifter com-
mulate operation. The MAC assumes an implied binary mands. Rounder rounds the results to a 16 bit value when
point after the MSB, which shifts the result down a bit in the the data path is operating in round mode.
output of the MAC. For this reason, bits 46:23 are used
29.3.3 Address Calculation Unit dence requires the same value on the ACU_addr for all
commands involved.
The Address Calculation Units (ACUs) generate addresses
for each DP RAM. There are two address calculation unit for
supporting sophisticated branching operations.
29.3.4 Bus Interface and Register
Descriptions
The ACU is capable of saving and restoring address, incre-
menting or decrementing address by 1 or n (n is a constant The DFB block is wrapped with a 32-bit AHB-Lite Slave bus
value stored in FREG), flagging a programmable terminal interface. A 32-bit bus was chosen to accommodate the fact
count, and a number of other functions. that the RAMs in the DFB are all 24 bits and most of the bus
transfers to the DFB are 24 bits.
REG – Stores the current value that the ACU is operating on
and outputs it on every cycle, unless a command specifies The DFB has a set of expanded Control and Status Regis-
otherwise. ters (CSR) that are accessible through the system bus at all
times. The registers containing CSR bit information are
FREG – Loads with a value to increment or decrement by, address mapped as 32-bit registers with active bits only in
when using the ADDF and SUBF commands. For example, the low byte. This arrangement works well for both 8-bit and
load two into FREG and then it is possible to increment 32-bit MCUs.
through the data RAMs by two.
The CSRs that hold sample data are 24-bits wide (Staging
MREG – Stores the maximum value before a wraparound if and Hold register) and coherency interlocking HW is
modulo arithmetic is turned on. When the address calcu- included to allow 8-bit and 16-bit accesses.
lated by the ACU exceeds MREG value, it will wraparound
to LREG value, if modulo arithmetic is turned on. In normal mode of operation, the DFB RAMs (except the
input staging and output holding registers) is controlled by
LREG – Stores the minimum value before a wraparound to the DFB controller and is not accessible to CPU/DMA. If
the MREG value when modulus arithmetic is turned on. CPU/DMA needs control of this DFB RAM memory it should
Modulus arithmetic is enabled using the SETMODE ACU make use of DFB_RAM_DIR control bits (one per RAM) to
command and disabled using the UNSETMOD command. give the RAM control to system bus.
Modulus arithmetic prevents the ACU from incrementing
past the value of MREG and from decrementing below the
29.3.4.1 Streaming Mode
value of LREG. Make sure the REG value is within the In streaming mode the filter coefficients and historic data are
LREG:MREG range at the time modulus arithmetic is turned loaded into DFB before starting the DFB operations. Run-
on to avoid unexpected results. time data movement is through the staging and holding reg-
isters.
The ACU (including the ACU RAM) is initialized whenever a
hard reset event occurs or when the RUN bit in the The DFB has:
DEC_CR register is ‘0’. Initialization is as follows: ■ Two 24-bit input staging registers
ACU RAM Contents=0, MREG=127, LREG=0, FREG=2. ■ Two 24-bit output holding registers
The current address and state of the register of both ACUs These registers can be accessed by both DFB as well as
can be stored or retrieved from memory with assembly AHB Bus (CPU/DMA). In reality, these registers are double
instructions. This is used in context switching. A 16x14 ACU buffered, but to the DFB controller and the system bus, they
RAM is used for this purpose. The 16x14 RAM is used by appear as single registers. In streaming mode data to be fil-
both ACUs. The upper seven bits are for ACU B and the tered is streamed in to staging registers. Filter output is
lower seven bits are for ACU A. Thus, each ACU can store streamed out through DFB holding registers.
16 addresses or state elements.
The two sets of input and output registers aid stereo data
The ACU instructions perform incrementing/decrementing of processing applications. Applications requiring more than
the data RAM addresses by one or the value in FREG. two concurrent channels must use block mode.
Apart from this, the modulus arithmetic is used to enable a
wrap around at user defined limits.
Holding Holding
Reg A2 Reg A1
24 Bit 24 Bit
Staging 128 X 24 RAM A A
Reg A
MAC,
ALU,
Shift,
etc.
Staging 128 X 24 RAM B B
Reg B Holding Holding
Reg B2 Reg B1
24 Bit 24 Bit
Input
Select
In input Streaming mode, the sample rate is determined by ters with the low order ACU RAM address bit (acu_addr[0]).
the ADC or other sampling resources providing the input If the address bit is low, Staging register A is read; if the
samples. By definition the DFB must be running (process- address bit is high, B is read. When read, the associated
ing) samples faster than or at the exact same rate as the Stage Valid signal is automatically cleared by the hardware.
sample source to function properly. Therefore, the DFB
Apart from this, the Staging register also has a key coher-
knows how to stall and wait for subsequent input data or
ence byte setting. This setting is available to reduce errors
postpone operation on that channel and switch to another
due to bus access being less wide as compared to the regis-
channel (if in use).
ter width. The staging registers are protected on writes, so
When the calculation engine is finished processing a sam- the underlying hardware does not incorrectly use the field
ple, a bus read instruction can be issued. At this point, the when it is partially updated by the system software. If the
next staged sample is read or, if not present yet, the DFB system software is in the middle of reading from the holding
controller stalls while waiting for the next input sample. If two registers, the DFB will not update the holding registers until
streaming channels are being processed, the DFB control- the coherency key byte is read. The Key Coherency byte is
ler, upon completion of a calculation, can jump to the other basically the user (software) telling the hardware which byte
channel. of the field is written or read last when an update to the field
is desired. In the Staging register the new value availability
The full or empty status of the two Staging registers is visi-
is flagged only when the key coherency byte is written to.
ble to the DFB controller and it can branch based on the sta-
tus information, allowing it control of which channel it is
29.3.4.2 Block Transfer Modes
working on.
Block mode is defined by the system software moving sets
When the bus read instruction is issued by the DFB control-
of samples or coefficient data in and out of the DFB data
ler, it does not request the bus, generate an interrupt, or
RAMs in blocks. This method of using the DFB supports
DMA request. It simply tells the DFB bus interface that it
such features as multi-channel processing and deeper filters
wants the next sample and will wait until it arrives. In this
than the embedded data RAMs will support. It can also be
state, the DFB controller waits until the bus interface signals
used to initialize the DFB RAMs for streaming mode opera-
that the sample has arrived. A one 24-bit word Staging reg-
tion.
ister is used for a sample rate at or below 1 Msps and guar-
anteed bus latency lower than the sample period. There are The DFB datapath block has two 128x24 embedded data
two Staging registers: one for each supported channel. RAMs. These hold the data (signal or coefficients) used in
the calculation of numerical processes. These two RAMs
In streaming mode new samples arrive in the staging regis-
are completely separate memories from the bus’ point of
ters. The DFB controller checks for new data write to staging
view. The DFB views these two RAMs as a working set, as
registers and branch to process data depending on the
shown in Figure 29-5 on page 335.
CFSM code.
128 X 24 RAM A A
MAC
Bus Control ALU
Logic Shift
etc
128 X 24 RAM B B
The primary concept of Block mode is to allow the system Typically, results of DFB applications are streaming in
software full control of what is in the data RAM for each cal- nature. However, in cases where results are created as data
culation cycle of the DFB. In general, this extends the func- sets, Block mode can be used to move the resultant data
tionality of the DFB by trading performance for fundamental sets out of the DFB data RAMs.
features such as the ability to implement filters with more
taps than 128 or to time division multiplex the processing of 29.3.4.3 Result Handling
more than two low sample rate channels. The system soft-
Frequently DFB block output results are generated at peri-
ware burden of Block mode is in the management of the
odic intervals after a series of mathematical calculations.
RAM’s contents. Both system and DFB performance is lost
This also happens after a wait for the input sample stream.
due to software servicing of the DFB and because the DFB
The generation rate of these result elements will vary radi-
must stall while the system software reads/writes the data
cally based on the function being programmed and run on
RAMs. Block mode also creates more bus traffic on the sys-
the DFB.
tem bus for a given sample rate.
To assist system software with the handling of resultant
The system software takes control of memory by putting it
data, the DFB implements two Holding registers, 24 bits
on the system bus with the use of (DFB_RAM_DIR) control
wide, for output results. In reality, these two Holding regis-
bits (one per RAM). It then reads/writes the data and
ters are double buffered, but to the DFB controller and the
“passes” the memory back to the DFB by toggling the con-
system bus, they appear as a single register. They are
trol bit back. While this is happening, the DFB must stall,
referred to as a single register hereafter, but keep in mind
unless it is performing some function that only requires one
there are really two registers to deal with bus latency issues.
of the two data RAMs. The two data RAMs are individually
The fact they are double buffered is transparent to both the
controlled by the system software as to which resource has
bus and the DFB controller. Hardware automatically man-
control of them – the bus or the DFB.
ages the fact that they are double buffered.
Any number of data channels can be supported with Block
The intent of having two fully addressed Holding registers is
mode (within reason). With each added data channel, the
primarily to allow the controller and system software to map
system software has the additional burden of tracking and
filter channels so that DMA requests are much easier to
managing and sample rates supported reduces consider-
support. The two Holding registers are addressed with the
ably since the DFB must be stalled for data movement oper-
low-order ACU address bit out of the Control Store.
ations.
When bus write is asserted in the CS word and the low-
The DFB controller provides a semaphore methodology to
order ACU address bit (acu_addr[0]) is low, Holding register
communicate with the system software as to the status of
A is written and Holding register B is written when the low-
the data RAMs when being passed back and forth for block
order address bit is high.
transfers. Optional interrupt support can be associated with
the setting and clearing of semaphores. There are a couple of methods provided to read the Holding
registers on the system bus. These registers are generic
read only CSRs. They can be read manually by software ware which byte of the field is read last. The Holding
running on the MCU under poled or interrupt control registers are considered read once the key coherency byte
(DFB_INTR_CTRL), or each can be associated with a DMA is read.
request signal and read by the system DMA controller
Note 1 In Block mode, when more than two channels are
(DFB_DMA_CTRL). Pending interrupts from the Holding
being processed, management of the output results is more
register update is monitored from the DFB_SR register.
burdensome to the system software as it can no longer be
Operations on the Holding registers are protected. The constantly mapped one-to-one with a Holding register or
nature of the protection is set by the coherence bits DMA request.
(DFB_COHER). The Holding registers are protected on
Note 2 In 8-bit devices, reading the Holding registers man-
reads so that the underlying HW doesn’t update it when par-
ually results in a multi-cycle operation.
tially read by the System SW or DMA. The key coherency
byte is selected in the Coherency register. The Key Coher- Figure 29-6 explains DFB control signals can be used for
ency byte is basically the user (software) telling the hard- data streaming and result handling.
Figure 29-6. Control Signals for Data Streaming and result handling
Dfb_intr
INTR_CTRL [0]
Stage A
Valid, in1
Dfb_dmareq1
Stage A DMA_CTRL [1:0]
Coherency Key
DFB_COHER[1:0]
Data Write Strobe Hold A
Stage A Stage A Stage A 128 X 24
A
LOW MED HIGH RAM A
[8 Bits] [8 Bits] [8 Bits] MAC,
DMA ALU, DMA
Shift,
CPU etc. CPU
Stage B Stage B Stage B 128 X 24
LOW MED HIGH B
RAM B
[8 Bits] [8 Bits] [8 Bits] Hold B
Data Write Strobe
Input
Stage B
Select Dfb_intr
Coherency Key
DFB_COHER[3:2] INTR_CTRL [1]
Stage B
Valid, in2
Dfb_dmareq2
DMA_CTRL [3:2]
29.3.4.4 Data Alignment To set and clear semaphores bits, two DP ALU commands
are available: SEM_SET and SEM_CLR. For each active
The hardware provides a data alignment feature in the input
high bit of the ACU address, the corresponding semaphore
Staging registers and in the output Holding registers for sys-
bit is either set or cleared.
tem software convenience.
For system software to write into a semaphore bit the regis-
Both staging and holding registers support byte accesses
ter DFB_SEMA is used. The mask bit is set when the corre-
that addresses alignment issues for input and output sam-
sponding semaphore bit in the register is updated.
ples of 8 bits or less. Also, all four of these registers are
mapped as 32-bit registers (only three of the four bytes are Any of the semaphore bits can be optionally (programma-
used) so there are no alignment issues for samples between ble) associated with the system interrupt signal
17 and 24 bits. However, for sample sizes between 9 and (DFB_INTR_CTRL) or either of the DMAREQ
16, it is convenient to read and write these samples on bus (DFB_DMA_CTRL) outputs leaving the DFB, and/or either
bits 15:0, while they source and sink on bits 23:8 of the of the outgoing Global signal. Pending semaphore interrupts
Holding and Staging registers. are monitored from the DFB_SR register.
The CSR DALIGN provides bits that enable an alignment 29.3.4.6 DSI Routed Inputs and Outputs
feature which allows bus bits 15:0 to either be sourced from
Holding register bits 23:8 or sink to Staging register bits The DFB has the option to take two DSI global inputs
23:8. Each Staging and Holding register can be configured (globali1 and globali2) and two DSI global outputs (globalo1
individually with a bit in the DALIGN register. If the bit is set and globalo2).
high, the effective byte shift occurs. For example, if an out- Use of the global outputs is optional. If needed, they can be
put sample from the Decimator is 12 bits wide, aligned to bit programmed to carry one of four different DFB internal sta-
23 of the Decimator Output Sample register, and is desired tus/control signals. These can be routed to the DSI and
to stream this value to the DFB, the similar data alignment used as inputs to other circuits. The global outputs can be
feature of the Decimator can be enabled, allowing the 16 configured to carry semaphore, an interrupt, or DP status
bits of the Decimator Output Sample register to be read on signals as listed in Table 29-5 on page 338. This is done
bus bits 15:0. Setting the alignment feature in the DFB for using the DFB_DSI_CTRL register.
the Staging A input register, these 16 bits can be written on
bus bits 15:0 and will be written into bits 23:8 of the Staging The DSI inputs into the DFB to control operations of the
A register when required. FSM are optionally used as branching inputs to the Control-
ler's next state decoder. See the section on 29.3.1.4 Next
29.3.4.5 DMA and Semaphores State Decoder on page 330 for more details.
The mux control bits are split equally between the A and B paths each having 3 bits. Three bits are allocated and encode the
control of the mux1, mux2, and mux3 functions as shown in Table 29-5.
ALU functions are programmed as shown in Table 29-6 and are encoded in 5 bits.
MAC functions are programmed as shown in Table 29-7 and are encoded in 2 bits.
Shifter functions are programmed as shown in Table 29-8 and are encoded in 3 bits. If deeper shifts are required, data can be
passed through the ALU on multiple cycles.
Two ACUs are supplied. There are 16 functions per ACU as shown in Table 29-9 and are encoded in 4 bits. This RAM is use-
ful when parallel filters or algorithms are implemented and control flow needs to shift from one to the other, while still maintain-
ing the relative addresses for each filter.
The PSoC® analog subsystem provides the device the second half of its unique configurability. All analog performance is
based on a highly accurate absolute voltage reference with less than 0.2% error over temperature and voltage. The configu-
rable analog subsystem includes analog muxes, comparators, mixers, voltage references, analog-to-digital converters (ADC),
digital-to-analog converters (DAC), and digital filter bocks (DFB). All GPIO pins can route analog signals into and out of the
device, using the internal analog bus. This feature allows the device to interface up to 62 discrete analog signals.
System Bus
Digital
ANALOG SYSTEM
LCD Direct
Filter +
Drive
Block Nx
ADCs Opamp
N x SAR
ADC
N x SC/CT Blocks
(TIA, PGA, Mixer, etc.)
SPC ADC
Temperature +
Sensor Nx Nx
N x DAC Del Sig CMP
ADC
CapSense
The PSoC® 3 and PSoC® 5 Switched Capacitor (SC) – Continuous Time (CT) block is a general purpose block constructed of
a rail-to-rail amplifier with arrays of switches, capacitors, and resistors. Register configurations select the block functional
topology, power level, and bandwidth.
30.1 Features
The PSoC SC/CT block has these features:
■ Multiple configurations:
❐ Naked Opamp
❐ Continuous Time Unity Gain Buffer
❐ Track and Hold Amplifier
❐ Continuous Time Programmable Gain Amplifier
❐ Continuous Time Trans Impedance Amplifier
❐ Continuous Time Mixer
❐ Sampled Mixer (non return-to-zero sample and hold -- NRZ S/H)
❐ Delta Sigma Modulator
■ Routability to GPIO
■ Routable reference selection
■ Programmable power and bandwidth
■ Sample and hold configuration
Vin
Mod Gain 0 : 850 fF
V out Mod Gain1 : 425fF
SC: 850 fF comp<1:0>
TIA : 850 fF 1. 25 fF – 5 pF
Vout
V ref
Vin
CT, TIA : 850 fF
SC: 850 fF
Trk Hld : 4.0 pF
20
30.4 Naked Opamp 10
175 uA
250 uA
0 330 uA
The naked opamp mode provides direct access to the input -10
400 uA
and output terminals of the opamp. All of the other circuitry -20
(resistors and capacitors) is disconnected in this mode. This 0.001 0.01 0.1 1 10 100 1000 10000
The naked opamp is selected by setting the MODE[2:0] bits 30.4.1.1 BIAS_CONTROL
in the SC[0...3]_CR0 to 000. The opamp is a two stage The bias control option doubles the current through the
design with a rail-to-rail input folded cascade first stage and amplifier stage. AC open loop stability analysis for all contin-
a class A second stage. The opamp is internally compen- uous time modes shows that leaving this option set to ‘1’
sated. To accommodate varying load conditions, the com- and then controlling the bandwidth/stability using the capac-
pensation capacitor and output stage drive strength is itor options results in a greater overall bandwidth once the
programmable. circuit is stabilized than using the option of less current in
The setting to apply is determined from the minimum the first stage. The bias current is doubled by setting the
required slew rate determined from the signal swing and SC[0..3]_CR2[0] register bit.
time, and load capacitance. This is primarily a consideration
for the stability reasons.
For all continuous time modes, the output was modeled with
two 150 switches with an 8 pF load in between, then fol-
lowed b ya 300 impedance and a 50 pF external load.
V IN
V OUT
The unity gain buffer is used when an internally generated signal with high output impedance, such as a voltage DAC output,
is required to drive a load; or when an external source with a high impedance is required to drive a significant on-chip load,
such as the Continuous Time Mixer.
Rfb = 20 k to 1 Mohm
rval [000]:rval[101]
R in =20k or 40k
rval< 110 > : rval< 111>
R in = 9.6k or 19.6k
V in 0
1
V out
1
V ref 0
0.3k
pga _ rlad
sc_pga_ gndVref
sc _ gain
The PGA can be implemented as either a positive gain or The positive gain (non-inverting) topology is shown in
negative gain topology, or as half of a differential amplifier. Figure 30-6.
The specific gain configuration is selected by the SC_GAIN
bit [5] in register SCL[0..3]_CR1. Any added input resistance
from analog routing affects the PGA gain.
Figure 30-6. PGA Positive Gain (Noninverting) Topology RLAD is at very high impedance to minimize gain errors. The
output of the differential amplifier is
VIN VOUT+ - VOUT- = Gain*(VIN+ - VIN-). Equation 2
VOUT
The common mode voltage of the output remains at the
common mode voltage of the input.
VOUT+ 101 1 32 1 1 3
110 0 24 1 0 2
110 1 48 1 1 0
111 0 25 1 0 2
111 1 50 1 1 0
RIN RFB
RLAD The negative gain (inverting) topology is shown in
Figure 30-7.
RLAD
RIN RFB 30.7 Continuous Time
Transimpedance Amplifier
The Transimpedance Amplifier (TIA) is a continuous time
opamp with dedicated and selectable feedback resistor. The
VOUT- TIA is selected by setting the MODE[2:0] bits in the
VIN- SC[0..3]_CR0 register to ‘001’.
Figure 30-9. Transimpedance Amplifier Configuration The CFB options for TIA mode are larger than for the other
continuous time modes, as shown in Table 30-9. The feed-
C FB
back capacitance is set in bits [3:2] of the SCL[0..3]_CR2
register.
00 0.00
V IN
01 1.30
10 3.30
V REF 11 4.60
000 20
001 30
010 40
011 80
100 120
101 250
110 500
111 1000
Signal
Ca rr ier
Mult
0 10 20 30 40
R mix = 20 k or 40k
sc_clock
!sc_clock
Rmix = 20 k or40k
V in
V out
1
0
V ref
sc_clock
30.9 Sampled Mixer In this example, we have a 500 kHz down-converted signal,
but we are sampling it at 2 MHz. Since the ADC and the
The Sampled Mixer is a nonreturn-to-zero (NRZ) sample switched capacitor block can both run at the same 2 MHz
and hold circuit with very fast response. The mixer is sample rate, there is no need to low pass filter the output of
selected by setting the MODE[2:0] bits in the SC[0..3]_CR0 the switched capacitor block. Its output can be fed directly
register to ‘011’. The discrete time mode has a maximum into the ADC input.
FCLK of 4 MHz. The maximum input frequency in discrete
A few examples illustrate the frequency shifting capabilities
time mode is 14 MHz. The mixer output is designed to either
of the mixer. For a signal frequency at 1.36 MHz, and a car-
drive an off-chip ceramic filter (i.e., 455 kHz Murata Cerafil)
rier at 1.28 MHz, the output frequency is the difference
or the internal ADC through the on-chip analog routing. In
between the two frequencies, as shown in Figure 30-12.
order for the ADC to correctly sample the mixer output, the
sample clock for the ADC and mixer must be the same. Figure 30-12. Sampled Mixer N = 1
The sample and hold mixer is primarily used for down-con-
version mixing. The down conversion is achieved by filtering
the desired harmonics of the mixed product of the input fre-
quency and sample clock frequency. Correct frequency
planning is required to achieve the desired results. For a
given input carrier frequency, FIN, a sample clock frequency,
FCLK, can be chosen to provide the desired IF frequency,
FIF, for the system.
Signal
Provided that FCLK is less than 4 MHz, and FIN is less than
Carrier
14 MHz:
Dif f
If 0 5 10 15 20 25 30 35
2N – 1-
--------------- F CLK F IN N F CLK Equation 5
2 For a higher frequency signal at 13.6 MHz, and the carrier at
then 3.2 MHz, the output is at the same frequency, but longer
separation between the samples, as shown in Figure 30-13.
F IF = N F CLK – F IN Equation 6 Figure 30-13. Sampled Mixer N = 3
If
2N + 1
N F CLK F IN ---------------- F CLK Equation 7
2
then
F IF = F IN – N F CLK Equation 8
configuration are the reference option and the clock division of the input clock. This is achieved by resetting the
option. SC[0..3]_CR1[4] bit.
Figure 30-14. Switched Capacitor Discrete Time Mixer Table 30-13. Clock Division Option for Sample and Hold
Configuration
C1 1 Mixer
Vin
SC_DIV SC_CLOCK Requirements
SC_CLOCK should be set to half the desired sample
1&!sc_gndVref 2 0
frequency
Vref SC_CLOCK should be set to the desired sample
1&sc_gndVref 1
frequency
sc_gndVref
V out
!sc_gndVref
Vref
2&!sc_gndVref
Vref
2&sc_gndVref
1
C4 Vin
2
The use of the internal ground can cause different step sizes
up versus down because the amplifier does not respond
identically when the negative terminal jumps below ground.
To avoid this distortion, use the external reference option
and set it to 500 mV or greater.
The Delta Sigma Modulator is selected by setting the MODE[2:0] bits in the SC[0..3]_CR0 register to ‘101’. The integrator out-
put is compared to a reference level and fed back to the input in a feedback loop. The modulator output is clocked at the high
sampling rate, and needs to be decimated down to the signal band of interest using a decimation filter.
+
Out
Sample / Hold Integrator Comparator
Input
The modulator can also be used as an incremental modulator by using a reset switch that is placed across the integrating
capacitor. The accuracy of the sampled data from the first-order modulator is determined from several factors: the maximum
input signal bandwidth, oversampling ratio, and the sampling clock jitter. The oversampling clock is limited to a maximum of
4 MHz. Oversampling below x64 does not produce a stable output. Table 30-14 below shows the expected performance from
a system simulation.
The Signal-to-Noise Ratio (SNR) values include the effects of limit cycle oscillations.
The configuration diagram of the discrete time first-order modulator is shown in Figure 30-16 on page 356. There are two
mode-specific usage options: a reset switch placed across the integrating capacitor and a gain setting to adjust the allowable
input amplitude range.
Sampling Phase
C 5 = 1.7pF
C 4 = 850fF
Gain 0: C 1 = 850F
Gain 1: C 1 = 425F C 2 = 850fF
V in
sc_dyn_cntrl
V ref
Vout_mod = 1
Gain 0: C3 = 425fF Comparator Vout _mod
Gain 1: C3 = 850fF V ref
Integrating Phase
C 5 = 1.7pF
C 4 = 850fF
Vout_mod = 0 V out
Vout_mod = 1
V ref
V ref
30.10.1 First-Order Modulator, Incremental The range of the allowed input amplitude can be set using
Mode the SC_GAIN SC[0..3]_CR1[5] control signal as shown in
Table 30-16.
The dynamic control input SC[0..3]_CR1[5] can be used to
reset the integrating capacitor if to perform an incremental Table 30-16. First-Order Modulator, Input Amplitude
conversion: SC_GAIN Maximum Input Amplitude
0 ± half VREF
Table 30-15. First-Order Modulator, Integrating/Incremental
Mode 1 ± 2 VREF
SC_DYN_CNTRL State
0 Integrating
Reset. VOUT is connected to amplifier negative
1
terminal.
!sc_dyn_cntrl VOUT
VIN
Ctrk_hld = 12.0 pF
(pfet gate cap)
PSoC® 3 and PSoC® 5 have a flexible analog routing architecture to route signals between GPIOs and analog resource
blocks such as the ADC, Switched Capacitor, DAC, etc. One of the strong points of this flexible routing architecture is that it
allows dynamic configuration of input/output connections to the different analog blocks. For example, the comparator input
could be switched between two GPIOs, on the fly, by DSI control signals and register settings. Knowing and understanding
the architecture enables efficient and optimal utilization of the device analog routing resources.
31.1 Features
PSoC® analog routing has the following features:
■ Flexible, configurable analog routing architecture
■ Dedicated routing options for LCD drive capability
■ Eight analog globals (AGs) and one analog multiplexer bus (AMUXBUS) for GPIOs on each side
■ Flexible routing options within the analog core to interconnect analog resource blocks using analog local bus (abus)
ANALOG SYSTEM
Delta Sigma
LCD
Channel (1x)
LPF LPF
Switched Switched
Capacitor (2x) Capacitor (2x)
CapSense CapSense
Refbuf Refbuf
SAR0 SAR1
5 8 4 CY8C55 only
4 8 5
Analog Interface
Vssio
Vdab
Vdda
Vsab
Vssa
Vcca
Vssd
* * * *
Upper Left Quadrant Upper Right Quadrant
P15[3]
P15[2]
P12[1]
P12[0]
P12[3]
P12[2]
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
P3[7]
P3[6]
P0[3]
P0[2]
P0[1]
P0[0]
P4[1]
P4[0]
Vio0
Vio3
SIO
SIO
SIO
SIO
* * * * * * * *
AMUXBUSL AMUXBUSR
* *
AGL[4] AGR[4]
AGL[5] AGR[5]
AGL[6] AGR[6]
AMUXBUSL
AGL[7] AGR[7]
AGL[4]
AGL[5]
AGL[6]
AGL[7]
ExVrefL ExVrefL2 44
ExVrefL1
opamp0 opamp2
opamp3 opamp1 GPIO
01 23456 7 0123 3210 76543210 P3[5]
GPIO
GPIO
*
P0[4]
GPIO P3[4]
GPIO
*
P0[5]
GPIO P3[3]
i0 1.024V in0 LPF in1 GPIO
P0[6] *
1.024V
out0 5 out1 ExVrefR
GPIO P3[2]
i2 GPIO
P0[7] * + comp0
-
comp1 +
- i3 P3[1]
1.024V COMPARATOR 1.024V
GPIO
i1 P3[0]
GPIO + comp2 comp3 +
0.256V - 90 - GPXT
P4[2] *P15[1]
GPIO vda, vda/2
GPXT
P4[3] 1.024V out CAPSENSE out 1.024V
*P15[0]
ref ref
GPIO 1.2V
in refbufl refbufr in
1.2V
P4[4]
AGR[7]
AGR[6]
AGR[5]
AGR[4]
AMUXBUSR
GPIO Vssa sc0 sc1 Vssa
*
P4[5] Vin Vin
Vccd
GPIO Vref Vref
1.024V out out 1.024V
P4[6] SC/CT Vssio
GPIO Vin Vin
Vref Vref *
P4[7] Vssd
* out out
Vccd sc2 104 sc3 *
* Vddd
Vssd ABUSL0 ABUSR0
ABUSL1 ABUSR1 Vusb
ABUSL2 ABUSR2
Vssio ABUSL3 ABUSR3
*
Vddd v0 USB IO
v1
GPIO i0
VIDAC i1 * P15[7]
P6[0] v2 36
USB IO
GPIO i2
v3
i3
* P15[6]
P6[1] 0.256V
GPIO
GPIO P5[7]
P6[2] + dsm0 GPIO
GPIO
- DSM P5[6]
vpwra, qtz_ref 28
P6[3] 0.8V vpwra/2 Vssa GPIO
GPIO refs P5[5]
0.7V
P15[4] 1.2V
GPIO
vda,
GPIO 1.024V vda/4 ExVrefL ExVrefR P5[4]
P15[5] CY8C55 only SIO
Vp (+) (+) Vp
GPIO P12[7]
Vn (-) SAR0 SAR1 (-) Vn
P2[0] Vrefhi_out Vrefhi_out SIO
GPIO refs refs P12[6]
P2[1]
1.2V
1.024V vda,
vda/2
SAR ADC vda,
vda/2
1.2V
1.024V GPIO
GPIO CY8C55 only ExVrefL1 ExVrefL2 CY8C55 only
*P1[7]
P2[2] GPIO
GPIO AMUXBUSL 01234567 0123 3210 76543210 AMUXBUSR *P1[6]
P2[3] * ANALOG ANALOG
GLOBALS
ANALOG ANALOG
BUS BUS GLOBALS
GPIO
AMUXBUSR
AGR[0]
AGR[3]
AGR[2]
AGR[1]
P2[4] * TS
VBE
:
AMUXBUSL
* VSS ref
Vio2 ADC
AGL[1]
AGL[2]
AGL[3]
AGL[0]
LPF
AGL[3] AGR[3]
AGL[2] AGR[2]
AGL[1] AGR[1]
AGL[0] AGR[0]
AMUXBUSL AMUXBUSR
13 * * * * *
*
*
Mux Group * * *
P12[4]
P12[5]
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
GPIO
P5[0]
P5[1]
P5[2]
P5[3]
P1[0]
P1[1]
P1[2]
P1[3]
P1[4]
P1[5]
P2[5]
P2[6]
P2[7]
P6[4]
P6[5]
P6[6]
P6[7]
Vio1
Switch Group
SIO
SIO
Connection
* * * * *
Lower Left Quadrant Notes: Lower Right Quadrant
XRES_N
Vssio
Vssb
Vssd
# Size
Vbat
Vb
DFT 24 Small
266 Small (higher z) LCD signals are not shown.
LCD 15 Small Rev. #44
93/122 Large (lower z) June 22, 2009
31.3 How it Works ■ In the lower right half, Px[3:0] maps to AGR[3:0] and
Px[7:4] maps to AGR[3:0]
Analog routing resources in PSoC 3 and PSoC 5 devices ■ In the upper right half, Px[3:0] maps to AGR[7:4] and
include analog globals (AGs), analog mux bus (AMUXBUS), Px[7:4] maps to AGR[7:4]
liquid crystal display bias bus (LCDBUS), and local analog
buses (abus). The analog globals and AMUXBUS go to the This means that two pins on each port are connectable to
GPIOs and provide a way to route signals between the the same global as shown in the diagram. The analog global
GPIOs and the analog resource blocks (ARBs). The LCD- bus connects to inputs and/or outputs of the following ARBs:
BUS is used for LCD bias signal routing. DAC, comparator, output buffer, switched capacitor, Delta
Sigma ADC, and CapSense (which is a virtual block). These
Analog resource blocks include the following: DACs, com- connections are made through switches and muxes.
parators, CapSense, switched capacitors, Delta Sigma PRT[x]_AG registers are used to configure the analog glo-
ADC, and opamps. The analog local buses (abus) are local bals (AGs) for each GPIO port pin. Refer to 31.6 Analog
buses used for connections between ARBs. Routing Register Summary on page 373 for register details.
In addition, there is a VREF bus as shown in Figure 31-2 on Port 12 contains the Special Input/Output (SIO) pins. These
page 361. This VREF bus carries the reference voltages for pins are grouped in pairs for each quadrant of the device
different analog blocks that are generated by the precision (lower right: P12[6] and P12[7], lower left: P12[4] and
reference block. Refer to the Precision Reference chapter P12[5], upper left: P12[2] and P12[3], upper right: P12[0]
on page 413 for details on these reference voltages. and P12[1]), with each pair sharing a reference generation
Analog switches and muxes establish connections between (REFGEN) block. The SIO REFGEN block can select from
the above mentioned analog routing buses and the ARBs. one of two analog globals routed to the pair shown in
Figure 31-2 on page 361. The mux selection is controlled by
All these analog routing resources are explained in detail in the {PRT12_AG} register. Refer to the I/O System chapter
the following sections. on page 187 for details about SIO operation.
Figure 31-4 on page 364 illustrates the difference between
switches and muxes. 31.3.2 Analog Mux Bus (AMUXBUS)
There are two AMUXBUS routes in PSoC 3 and PSoC 5
31.3.1 Analog Globals (AGs) devices. The device can be divided into two halves (left and
The PSoC 3 and PSoC 5 die is divided into four quadrants right), with each half having one AMUXBUS (AMUXBUSR,
as shown in Figure 31-2 on page 361 and Figure 31-3 on AMUXBUSL). The left and right AMUXBUS may be shorted
page 363. The analog global bus has eight routes on each together with an analog switch. Every GPIO has the provi-
side, AGL[7:0] on the left, and AGR[7:0] on the right. Within sion to connect to an AMUXBUS through an analog switch.
each side, the bus is divided into two groups, AGR[3:0] and CapSense applications use the AMUXBUS for their opera-
AGR[7:4] for the right side, and AGL[3:0] and AGL[7:4] for tion. Refer to the CapSense® chapter on page 397 for
the left side. The lower four globals on each side are routed details on using this bus for CapSense applications.
to the GPIO in the lower half of the die and the upper four PRT[x]_AMUX registers are used to configure the AMUX-
globals on each side are routed to the GPIO in the upper BUS routing for each GPIO port pin. Refer to 31.6 Analog
half of the die. All eight analog globals on each side get Routing Register Summary on page 373 for register details.
routed to ARBs on the same side. Analog globals can be
used as single ended or differential signal paths. The left 31.3.3 Liquid Crystal Display Bias Bus
and right half globals may operate independently or they (LCDBUS)
may be joined through the switches that are shown at the
top and bottom of Figure 31-3 on page 363. The LCD bias bus contains five routes that connect to every
GPIO. These routes are continuous around the device
Each GPIO may be connected to an analog global through a periphery and are not separated by switches at the midline
switch in the following manner: as are the analog globals and AMUXBUS. Each LCD route
■ In the lower left half, Px[3:0] maps to AGL[3:0] and is individually configurable so that they are driven by the
Px[7:4] maps to AGL[3:0] analog local bus or LCD bias voltage to the LCD driver buf-
■ In the upper left half, Px[3:0] maps to AGL[7:4] and fer located in the GPIO. Connecting to an analog bus allows
Px[7:4] maps to AGL[7:4] low frequency analog signals to drive off-chip through the
LCD driver buffers.
The LCDBUS mux selections are given in the following table. Refer to the LCD Direct Drive chapter on page 383 for LCD
operation and biasing. Refer to 31.6 Analog Routing Register Summary on page 373 for register details.
AMUXBUSL AMUXBUSR
GPIO GPIO
Px[0] Px[0]
GPIO GPIO
Px[1] 7 6 5 43 2 1 0 Px[1]
GPIO 01 2 3 4 56 7 GPIO
Px[2] Px[2]
GPIO GPIO
Px[3] Px[3]
GPIO GPIO
Px[4] Px[4]
GPIO GPIO
Px[5] Px[5]
GPIO GPIO
Px[6] Upper Left Quadrant Upper Right Quadrant Px[6]
GPIO GPIO
Px[7] Px[7]
GPIO GPIO
Px[0] Px[0]
GPIO GPIO
Px[1] Px[1]
GPIO Lower Left Quadrant Lower Right Quadrant
GPIO
AMUXBUSL
Px[2] Px[2]
GPIO
AMUXBUSR
GPIO
Px[3] Px[3]
GPIO GPIO
Px[4] Px[4]
GPIO GPIO
Px[5] Px[5]
GPIO GPIO
Px[6] 01 2 3 4 56 7 Px[6]
GPIO 7 6 5 43 2 1 0
GPIO
Px[7] Px[7]
AG[3]L AG[3]R
AG[2]L AG[2]R
AG[1]L AG[1]R
AG[0]L AG[0]R
Switch
Connection
31.3.4 Analog Local Bus (abus) Figure 31-4. Difference Between Analog Switches and
Muxes
There are eight analog local bus (abus) routes in PSoC 3
AMUXBUS (1 of 2)
LCDBUS (1 of 5)
abus (1 of 8)
Analog Global (1 of 16)
and PSoC 5 devices, four in the left half (abusl[0:3]) and four
in the right half (abusr[0:3] as shown in Figure 31-2 on
page 361. These are local routes located in the analog sub-
system and are for interconnecting ARBs, which reduces ARB Mux
the usage of AGs. They do not route directly out into GPIOs.
It is possible to short the left and right abus’ together with LCD MUX
IN
four analog switches. ARBs may connect to each other
through analog globals (AG) or the analog local bus (abus).
ARB1
For example, in Figure 31-2 on page 361, a DAC output GPIO
(V1, for example) may be used as a reference for a compar-
ator negative input (COMP1, for example). Using an analog ARB2
GPIO Switch OUT
switch, the DAC output could be placed on AGR0 and the
comparator input switch could also be set to AGR0. Since IN
there are a limited number of available analog globals (eight ARB Switch ARB3
per side), some block to block connections can be made OUT
through analog local bus for direct connections between
blocks. For above example, the DAC output (V1) can be
routed directly to the analog local bus (abusr3) that goes to
the negative input of the comparator (COMP1). This saves
the GPIO routing resource from being used for interconnect-
ing two ARBs. 31.3.5.1 Control of Analog Switches
Analog globals (AGs), analog mux bus (AMUXBUS) and the
31.3.5 Switches and Multiplexers analog local bus (abus) all use analog switches to establish
connections. As stated earlier, analog switches can be
Switches and multiplexers are used to establish connections
grouped together to form multiplexers or switches.
using different analog routing buses. They are placed on the
various buses to direct signals into and out of the GPIOs Each GPIO has two analog switches, one to connect the pin
and ARBs. to the analog global and the other to connect the pin to the
AMUXBUS. The open/close control signals for these analog
In a switch with ‘n’ inputs and one output, zero through ‘n’
switches can be generated by either one of the following two
switches may be on at a time, whereas in a multiplexer
ways:
(mux) with ‘n’ inputs and one output, only one switch may be
on at a time. Note that a group of eight analog switches 1. The registers corresponding to the GPIO pin,
requires eight bits for configuration, whereas, a mux with PRT[x]_AMUX and PRT[x]_AG, can be used to control
the open/close state of the analog switches. This is the
eight analog switches requires only three bits. Figure 31-4
default option.
illustrates the difference between switches and muxes, in
switch and mux symbols. 2. In addition, there is a provision to dynamically control
these switches by means of the DSI control signal that is
For example, in Figure 31-4, there are two muxes (ARB, connected to the input of the port pin logic block. This
LCD). In both these muxes, only one of the analog switches option is enabled by setting the bit in the Port Bidirection
can be selected for routing. In the same figure, there are two Enable register (PRT[x]_BIE). For example, to control
switches (GPIO, ARB). For these switches, more than one pin 3 of port 0, a value of 0x08 is written to PRT[0]_BIE.
analog switch can be selected for routing. Note that both The switch control signal is the logical AND of the regis-
ter setting, as in the first case, and the DSI control sig-
muxes and switches are formed using analog switches.
nal, as shown in Figure 31-5.
Each GPIO is connected through two analog switches to an
analog global and an AMUXBUS. The ARBs use ARB
switches and ARB muxes for input/output routing options.
0
PRT[x]PS
PICU[x]INTTYPE[y]
PICU[x]INTSTAT Input Buffer Disable
Pin Interrupt Signal Interrupt
Logic
PICU[x]SNAP
Analog
1 0
1 0
CapSense Global Control 1
PRT[x]_CAPS_SEL[y] Switches
PRT[x]AG
Analog Global Bus
PRT[x] AMUX
Analog Mux Bus
LCD
Display Data
PRT[x] LCD_ COM_ SEG
Logic and
PRT[x] LCD_EN MUX
LCD Bias Bus 5
In addition, there are control signals that are dedicated for For example, to switch comparator input between two
CapSense applications as shown in Figure 31-5 above. GPIOs that are connected to the same analog global, the
Refer to the CapSense® chapter on page 397 for the usage register settings for the input select of the comparator are
of these control signals. configured to select the analog global to which the GPIOs
are connected. The DSI control signal can dynamically
The analog switches corresponding to the analog resource
select between the two GPIOs after the corresponding
blocks can be controlled only by the register settings of the
PRT[x]_BIE register has been configured.
respective ARBs.
Analog
System
Block
Port
Control
ANAIF
CLK_A_DIG[3:0]
CLK_A[3:0]
AHB
All
Clocks
CLKDIST
UDB
Array Decimator PHUB
Reg DAC3.SW*
Reg DAC2.SW*
AGL4 AGR4
AGL5 AGR5
AMUXBUSL AMUXBUSR
abusl0 dac_data abusr0
abusl2 V 8
dac_data
8 V abusr2
DAC2 DAC3
P0[7] I P3[1]
I dac2_cr dac3_cr
AMUXBUSR
AMUXBUSL 4 4
AGL4 AGR4
AGL5 AGR5
8 4 4 4 4
dac_data_udb
Reg DAC2.SW* dac0_cr_udb dac3_cr_udb Reg DAC3.SW*
dac1_cr_udb dac2_cr_udb
dacn_cr includes strobe, reset, ioff, idir
signals
UDB
31.4.2 Comparator
The comparator routing options and connections to other PSoC subsystems through the analog interface are shown in
Figure 31-8. The input for each comparator is selected by control registers, which are connected to the multiplexer select
lines.The outputs of the comparators are routed to the ANAIF for further processing (see the following figure). The analog
interface contains lookup tables (LUTs) that are used to implement logic functions on comparator outputs. The LUT outputs
(LUTN_OUT) are routed to the UDB block through the Digital System Interconnect (DSI). In addition, LUT outputs can gener-
ate interrupts (LUT_IRQ) to the device. Refer to the Comparators chapter on page 375 to learn more about comparator con-
trol and operation.
AG L0 AG R0
AG L1 AG R1
AG L2 AG R 2
AG L3 AG R 3
AG L4 AG R4
AG L5 AG R5
AG R 6
AG L6
AG L 7
AM UXBU SL
+ AG R 7
AM U XBUSR
abusl0 com p3 abusr0
abusl1
refbufl + _ abusr1
refbufr
R eg C M P2.SW *, C M P2.SW *
com p2 Reg C M P3.SW *, C M P3.SW *
AG L1
AG L3
AG L5
_ AG R 1
AG R 3
AG R 5
AG L7 AG R 7
AM U XBUSL AM U XBU SR
abusl2 4 4 4 4 4 4 4 4 abusr2
abusl3 abusr3
VR EF0 VREF0
VR EF1 VR EF 1
R eg C M P 2.SW *, CM P2.SW * R eg C M P3.SW *, C M P3.SW *
LUT0 LUT1 LUT2 LUT3
U DB
AGL0 dsm0_startup_reset_udb
AGL1
AGL2 dsm0_startup_reset
dsm0_modbitin_udb
AGL3
AGL4
dsm0_extclk_cp_udb
AGL5
AGL6
8 dsm0_dout_udb
AGL7
abusl0
dsm0_dout
abusl2 8
VSSA dec_irq
dsm0_overload
Reg DSM0.SW* DSM _one
ANAIF dsm0_dout2scomp 4
UDB
AG1L
dsm0_overload Decimator dec_start
AG3L
AG5L
_zero
AG7L
AMUXBUSL
dec_clk
abusl1
abusl3
dsm0_clk
VREF dsm0_reset_dec
VSSA dsm0_modbitin
dsm0_extclk_cp_udb
Reg DSM0.SW*
AGL0 AGR0
AGL1 AGR1
AGL2
sc0_modout sc1_modout AGR2
AGL3 AGR3
AGL4 sc0_dyn_cntl sc1_dyn_cntl AGR4
AGL5 AGR5
AGL6 sc0_clk sc1_clk AGR6
AGL7 AGR7
AMUXBUSL AMUXBUSR
abusl0 abusr0
abusl2 abusr2
abusl3 abusr3
VREF VREF
SC1O SC0O
Reg SC0.SW*
Reg SC1.SW*
AGL0
AGR0
AGL2
AGR2
AGL4
AGR4
AGL6
AGR6
abusl0 SC2O SC3O abusr0
abusl2
abusr2
Reg SC3.SW*
AGL1
Reg SC2.SW*
SC2 SC3 AGR1
AGL3 AGR3
AGL5 AGR5
AGL7 AGR7
VREF VREF
abusl1 abusr1
SC3O sc2_modout sc3_modout SC2O
Reg SC2.SW* Reg SC3.SW*
sc2_dyn_cntl sc3_dyn_cntl AG0R
AG0L
AG1L sc2_clk AG1R
sc3_clk AG2R
AG2L
AG3L AG3R
AG4L AG4R
AG5L AG5R
AG6L AG6R
AG7L AG7R
AMUXBUSL AMUXBUSR
abusl1 abusr1
abusl2 abusr2
abusl3 abusr3
VREF VREF
SC3O SC2O
Reg SC2.SW* 4 Reg SC3.SW*
sc_irq 4
sc_dyn_cntl sc_clk_udb sc_modout_sync
UDB
31.4.5 Opamp
The input and output routing options for the output buffer (opamp) are shown in Figure 31-11. Refer to the Opamp chapter on
page 379 for details on configuration and operation of this block.
AGL4 AGR4
AGL6 AGR6
Reg ABUF0.MX* Reg ABUF1.MX*
AG5L AGR5
AG7L AGR7
Reg ABUF2.MX* Reg ABUF3.MX*
AMUXBUSL AMUXBUSR
ABUSL0 ABUSR0
IN0 OUT0 OUT1 IN1 AGR0
AGL0
LPF0 LPF1
LPF0.CR0 LPF1.CR0
31.5 Low Power Analog Routing For example, assume we want to connect P3.5 to P3.4 in a
simple pass-through configuration. This is illustrated
Considerations Figure 31-12. This illustration is taken from the full chip dia-
Figure 31-2 illustrates the analog global routing network, gram shown in Figure 31-2. P3.5 enters the chip on analog
overlaid on top of the ARBs. Each ARB has a set of muxes global AG5. P3.4 enters the chip on analog global AG4. To
and switches that it uses to connect to the global analog connect these two pins together we need to Track Jump
routing. By connecting to one of the analog routing channels between AG4 and AG5. To do this we can use the Compar-
virtually any ARB can be connected to any other ARB or pin ator ARBs comp1 positive input switches (assuming the rest
on the chip. of our project isn't using these switches). The switch for AG4
and AG5 on the Comparator comp1 positive input is closed,
Not all pins or ARBs are connected to every analog global while the rest of the switches remain open. The inputs to the
routing channel. To get a signal from a particular ARB out to Comparator ARB itself are isolated from the switch group via
a specific pin, the PSoC Creator analog routing algorithm a transmission gate.
implements a technique known as “Track Jumping”. Track
jumping connects two analog globals together via one of the Once this configuration is programmed into the device, any
ARBs analog global switching structures, without connecting signal seen on P3.5 will show up on P3.4.
to that particular ARB resource.
Figure 31-13. Simplified diagram of routing P3.5 to P3.4 Using Track Jumping on the Positive Input of Comparator 1.
P3.5
COMPARATOR
P3.4
com p1
input offs et
cancelation
AG 7
AG 6
AG 5
AG4
31.5.1 Mitigating Analog Routes with chosen by using the manual routing components in PSoC
Degraded Low Power Signal Creator, the designer must make certain to avoid routing
which uses the SC/CT block for track jumping purposes if
Integrity the SC/CT is not enabled in Hibernate/Sleep modes.
The analog router in PSoC Creator uses track jumping to
If a design utilizes SC/CT analog switches to realize a
connect analog globals together. Track jumping is done on
design, in Sleep/Hibernate modes but has this block pow-
the muxes/switches of unused ARBs. The auto-router in
ered down, significant degradation in signal integrity may be
PSoC Creator will always choose routes which ensure sig-
experienced. Explicitly Start() components derived from the
nal integrity in all power modes.
SC/CT block and leave on in Hibernate/Sleep if it is neces-
If the auto-router is not sufficient and the designer needs to sary to still use these switches to route the design. Not start-
resort to manual routing techniques to realize a design, then ing the ST/CT block is equivalent to stopping it. By starting
special care should be taken. For performance reasons, the this block its routing resources become available for routing.
SC/CT ARB controls the availability of all of its associated See the PSoC Creator Data Sheet associated with Manual
analog switches. Routing for more details on how to use the MARS tool.
PSoC® 3 and PSoC® 5 devices each have four analog comparator modules. The positive and negative inputs to the compar-
ators come through muxes with inputs from analog globals (AGs), local analog bus (ABUS), Analog Mux Bus (AMUXBUS),
and precision reference. The output from each comparator is routed through a synchronization block to a two-input Lookup
Table (LUT). The output of the LUT is routed to the UDB Digital System Interface (DSI). The comparator can also be used to
wake the device from sleep. An ‘x’ used with a register name denotes the particular comparator number (x = 0 to 3).
32.1 Features
PSoC® comparators have the following features:
■ Flexible input selection
■ Speed power tradeoff
■ Optional 10 mV input hysteresis
■ Low input offset voltage (<1 mV)
■ Glitch filter for comparator output
■ Sleep wakeup
AGL0 AGR0
AGL1 AGR1
AG L2 AGR2
AG L3 AGR3
AGL4 AGR4
AGL5 AGR5
AGR6
AG L6
AG L 7
A M U XB U SL
+ AGR7
AM U X BU S R
abusl0 com p3 abusr0
abusl1
refbufl + _ abusr1
refbufr
R eg C M P 2.S W *, C M P 2.S W *
com p2 R eg C M P 3.S W *, C M P 3.S W *
A G L1
A G L3
A G L5
_ AGR1
AGR3
AGR5
A G L7 AGR7
AM UXBUSL AM UXBUSR
abusl2 4 4 4 4 4 4 4 4 abusr2
abusl3 abusr3
VREF0 V R EF 0
V R E F1 VREF1
R eg C M P 2.S W *, C M P 2.SW * R eg C M P 3.S W *, C M P 3.S W *
LU T 0 LU T 1 LU T2 LU T 3
UDB
All of the possible connections to the positive and negative 32.3.3 Output Configuration
inputs are shown in Figure 32-1. Inputs are configured using Comparator output can pass through an optional glitch filter.
registers CMPx_SW0, CMPx_SW2, CMP_SW3, The glitch filter is enabled by setting the filter enable (FILT)
CMP_SW4, and CMP_SW6. bit in the control (CMPx_CR[6]) register. The output of the
comparator is stored in the CMP_WRK register and can be
read over the PHUB interface.
Four LUTs in the device allow logic functions to be applied 32.3.5 Wake Up from Sleep
to comparator outputs. LUT logic has two inputs:
The comparator can run in sleep mode and the output used
■ Input A – selected using MX_A[1:0] bits in LUT control
to wake the device from sleep. Comparator operation in
(LUTx_CR1:0) register
sleep mode is enabled by setting the override
■ Input B – selected using MX_B[1:0] bits in LUT Control (PD_OVERRIDE) bit in the control (CMPx_CR[2]) register.
(LUTx_CR5:4) register
The logic function implemented in the LUT is selected using 32.3.6 Comparator Clock
control (Q[3:0]) bits in the LUT Control register (LUTx_CR) Comparator output changes asynchronously and can be
register. The bit settings for various logic functions are given synchronized with a clock. The clock source can be one of
in Table 32-1. the four digitally-aligned analog clocks or any UDB clock.
Table 32-1. Control Words for LUT Functions Clock selection is done in mx_clk bits [2:0] of CMP_CLK
Control Word register. The selected clock can be enabled or disabled by
Output (A and B are LUT Inputs)
(Binary) setting or clearing the clk_en (CMP_CLK [3]) bit. Compara-
0000 FALSE(‘0’) tor output synchronization is optional and can be bypassed
0001 A AND B by setting the bypass_sync (CMP_CLK [4]) bit.
0010 A AND (NOT B)
0011 A 32.3.7 Offset Trim
0100 (NOT A) AND B
Comparator offset is dependent on the common mode input
0101 B voltage to the comparator. The offset is factory trimmed for
0110 A XOR B common mode input voltages 0.1V and Vdd - 0.1V to less
0111 A OR B than 1 mV. If the user knows the common mode input range
1000 A NOR B at which to operate the comparator, a custom trim can be
1001 A XNOR B done to reduce the offset voltage further.
1010 NOT B
The Comparator offset trim is performed in the CMPx_TR0
1011 A OR (NOT B) register. This register has two trim fields, trim1
1100 NOT A (CMPx_TR0[3:0]) and trim2 (CMPx_TR0[7:4]). If shorting of
1101 (NOT A) OR B the inputs is desired for offset calibration, the calibration
1110 A NAND B enable field (cal_en) in the control register(CMP_CR[4])
1111 TRUE (‘1’) helps to achieve it
PSoC® 3 and PSoC® 5 devices have four operational amplifiers. An ‘x’ used with register name identifies the particular
opamp number (x = 0 to 3).
33.1 Features
PSoC® operational amplifiers have the following features:
■ 25 mA current drive capability
■ 3 MHz gain bandwidth for 200 pF load
■ Offset trimmed to less than 0.5 mV
■ Low noise
■ Rail-to-rail to within 50 mV of Vss or Vdda for 1 mA load
■ Rail-to-rail to within 500 mV of Vss or Vdda for 25 mA load
■ Slew rate 3 V/µs for 200 pF load
OPAMP0.SW[0] OPAMP1.SW[0]
OPAMP0.SW[1] OPAMP1.SW[1]
P0[3] P3[4]
AGL4 AGR4
AGL6 AGR6
OPAMP0.MX[4] OPAMP1.MX[4]
OPAMP0.MX[3:0] OPAMP1.MX[3:0]
P0[2] P3[5]
OPAMP0.SW[2]
OPAMP1.SW[2]
OPAMP2.SW[0] OPAMP3.SW[0]
OPAMP2.SW[1] OPAMP3.SW[1]
P0[5] P3[2]
AGL5 AGR5
AGL7 AGR7
OPAMP2.MX[4] OPAMP3.MX[4]
OPAMP3.MX[3:0]
OPAMP2.MX[3:0]
P0[4] P3[3]
OPAMP2.SW[2] = analog switch OPAMP3.SW[2]
The PSoC® Liquid Crystal Display (LCD) drive system is a highly configurable peripheral that allows the PSoC device to
directly drive a broad range of LCDs. The flexible power settings allow this peripheral to be used in applications where a bat-
tery is the power source.
34.1 Features
Key features of the PSoC LCD system are:
■ LCD panel direct drive
■ Type A (standard) and Type B (low power) waveform support
■ Wide LCD bias range support (2 V to supply voltage)
■ Static, 1/3, 1/4, and 1/5 bias voltage levels
■ Internal bias voltage generation
■ Up to 62 total common and segment outputs
■ Supports up to 16 common glasses (16:1 mux)
■ Drives up to 736 total segments (16 backplane × 46 front plane)
■ 64 levels of software controlled contrast
■ Ability to move display data from memory buffer to LCD driver through direct memory access (DMA) without CPU inter-
vention
■ Adjustable LCD refresh rate from 10 Hz to 150 Hz
■ Ability to invert LCD display for negative image
■ Various LCD driver drive modes, allowing power optimization
LCD always active mode is used when the device is not in low power mode and when the LCD does not need to be opera-
tional in device low power mode.
LCD low power mode is used when the LCD needs to be operational while the device is in low power mode. This uses the
same LCD always active system, but with some additional hardware.
The LCD drive system doesn't work when the chip is placed in hibernate mode.
LCD CLK
Drive
drq
Display Frame LCD Driver Block Pin
Data DMA Mode[2:0]
LCD Bias
Port Data
LCD Bias Registers LCD CLK
RAM LCD Bias
Generator Drive
Frame LCD Driver Block Pin
Mode[2:0]
LCD Bias
Any LCD drive system requires the bias generating circuitry by setting the appropriate bits of the PRT[0..11]_LCD_EN
and system to interpret the data supplied, in order to display register. These GPIOS can be configured to act as either
correctly on the LCD. PSoC 3 and PSoC 5 contain dedi- common or segment drive pins by setting bits of
cated LCD drive hardware, which works in conjunction with PRT[0..11]_LCD_COM_SEG.
system resources. It contains a dedicated DAC that gener-
The LCD driver blocks are the final interface to the pins.
ates the five bias voltages, V0 to V4, along with ground.
Each pin capable of driving an LCD contains driver logic.
These bias voltages are distributed to all of the drivers of the
The function of this block is to select the bias level. It also
LCD-capable pins.This DAC also helps to set contrast
drives the pin, depending on the LCD refresh state, whether
control.
the pin is configured as common or segment, and the dis-
LCDs have two sets of pins: commons and segments. LCD play data.
functionality in PSoC 3 and PSoC 5 GPIOs can be enabled
The LCD display data resides in the system memory V4, from the LCD DAC are driven to each of the LCD
(SRAM). This display data needs to be transferred to the driver blocks.
LCD driver logic. This is done using the direct memory ■ Analog mux bus and analog local bus can be selected to
access controller (DMAC). The DMAC takes the display drive the LCD driver blocks, instead of the LCD DAC, by
data from the SRAM and loads it into the port data registers. setting the appropriate bits of the LCDDAC_SW[0...4]
The LCD driver latches this port data register value when a registers. This is useful if you require external dividers to
refresh action begins. generate the drive voltages and optimize the power by
Refreshing the LCD requires LCD state updates with accu- switching off the internal DAC. In this mode, there is no
rate timing. This is done using a configurable clock, sourced software contrast control available.
from the internal main oscillator (IMO), which feeds the UDB ■ The LCD DAC can directly drive the LCD pixel, bypass-
block. The UDB is responsible for generating all of the con- ing the LCD driver block. This is useful for driving the
trol signals required by the rest of the blocks of the LCD LCD even when the chip is put to sleep. You can do this
system. by setting the LCDDAC.CR0[3] bit, which enables the
continuous drive of the LCD DAC.
34.3.1 Functional Description
34.3.1.1.1 Contrast Control
This section provides details of the LCD DAC, LCD driver,
Contrast is controlled by varying the DAC output voltage,
UDBs, clocking, DMA, CPU, and RAM, which all contribute
V0. This can be done by setting the LCD contrast control
to generating and sequencing the driving voltage for the
register (LCDDAC_CR1[5:0]), which sets the 6-bit DAC
LCD glass.
input (D[5:0], as shown in Figure 34-2). Thus, it provides
34.3.1.1 LCD DAC 2 ^ 6 = 64 levels of contrast. Table 34-1 shows the V0 range
and step size for 3.0-V and 5.5-V supply voltage.
The LCD DAC is a 6-bit resistor ladder DAC. The LCD DAC
is responsible for contrast control and bias voltage genera- Table 34-1. LCD DAC V0 Range and Step Size
tion for the LCD drive system. When the device is put in low 3.0 V Supply 5.5 V Supply
power mode, the LCD can remain operational. During this V0 Range 2 V to 3 V 2 V to 5.5 V
low power mode, the DAC can directly drive the LCD pixel,
Step Size 27.3 mV 50 mV
bypassing the driver, thus compensating for the leakage.
This is possible in LCD low power mode, which is explained
34.3.1.1.2 Bias Ratio/Multiplex Ratio Selection
in section 34.4 LCD Low Power Mode on page 389.
Bias ratio/multiplex ratio is selected by setting the bias_sel
Figure 34-2. LCD DAC (inputs and outputs)
field of the LCDDAC_CR0 register. This sets the DAC out-
put voltages V1 to V4 as shown in Table 34-2 on page 386.
D[5:0]
pwrdn
V0
continuous drive
enable hv V1
holdb V2
lcd bias select[1:0] V3
V4
V0
hold_n_hw (global)
V1
pwrdn_n (global)
Inputs from LCD DAC V2
V3
V4
GND
com_seg
od_h (global) 1 0 1 0 1 0 1 0
(individual)
dispbInk (global) LCD Bias
LCD Bias
Generator
pwrdn_n (individual)
00 01 10 11
Disp_data (individual)
hold_n_hv (global) fr (global)
drvr_in
mode[2:0] (global)
Buffer
drive (global) bypass_en (global)
pts (global)
ESD Devices
drvr_out
The LCD driver contains three major blocks: Note that these buffer power modes are different than the
1. Buffer and associated control logic for power modes I/O drive modes.
2. 4:1 Output multiplexer Table 34-4. LCD Drive Modes
3. Common/Segment switches
Control Bits
Mode Drive Strength
As shown in Figure 34-3 on page 386, the LCD driver block Mode[2] Mode[1] Mode[0]
receives bias voltages V0 to V4 and GND voltage. It passes 0 0 0 High Drive Seg = 1x, com = 1x
through a set of 2:1 muxes controlled by the COM-SEG bit 0 0 1 High Drive Seg = 1x, com = 2x
of the PRT[x]_LCD_COM_SEG register. This register con-
0 1 0 High Drive Seg = 1x, com = 4x
figures the pin as either a common or segment drive pin. If
0 1 1 High Drive Seg = 2x, com = 2x
the bit is set, it configures the corresponding pin as com-
1 0 0 High Drive Seg = 2x, com = 4x
mon; otherwise, it is configured as a segment drive pin. As
1 0 1 High Drive Seg = 4x, com = 4x
shown in Figure 34-3, V4 and GND voltages are forwarded
to the next mux. If the pin is selected as a segment line, then 1 1 0 Low Drive Seg = 0.1x, com = 0.1x
V0, V2, V3, and GND are forwarded. These are the only 1 1 1 Low Drive Seg = 0.2x, com = 0.2x
voltages required at common and segment lines for any bias The LCD display size and capacitance and the application
ratio, multiplex ratio, and LCD update state. Out of these power budget are two criteria for selecting buffer modes.
four bias levels, only one level is selected by the 4:1 multi- The buffer is enabled only when the drive signal is high.
plexer. The select lines of the multiplexer are driven by dis- Drive signal high time can be configured according to the
play data and the frame signal. Frame is a global signal application requirements. The drive current provided by the
driven by the UDB control logic. This signal toggles every High Drive mode of the buffer (the mode that is normally
time the LCD waveform needs to be updated. Table 34-3 used) is high, so it charges the pixel capacitance quickly.
shows the 4:1 multiplexer output and driver input for differ- The disadvantage of this is higher power consumption. The
ent combinations of COM_SEG, DISP_DATA and the frame time for which the buffer is kept on depends on the power
signal. budget and the LCD waveform's rise time requirements. The
Low Drive mode of the buffer and the DAC are other
Table 34-3. LCD DAC Output Selection
options. It is possible to dynamically select the Low Drive
com_seg disp_data fr drvr_in/out mode by two mode control signals generated by the UDB.
0 0 0 V3 You would do this in the case of extremely leaky glasses,
0 0 1 V2 when it is preferable to use the buffer to drive the LCD con-
0 1 0 GND tinuously throughout the refresh period. This is more effec-
0 1 1 V0 tive than using the DAC, whose current drive ability is lower
1 0 0 V4 than that of the buffer Low Drive mode. Use the DAC when
1 0 1 V1 you have normal glasses and the charge leakage is small. If
1 1 0 V0
the leakage is small enough for the offset to be negligible,
then the pin can be tristated by clearing the bypass_en bit,
1 1 1 GND
after charging the pixel using the High Drive buffer mode.
34.3.1.2.1 Buffer Modes
The output of the 4:1 multiplexer is driven to the buffer,
which drives the common or segment line of the LCD. The
buffer in the LCD drive block has eight modes of operation,
selectable from the Mode[2:0] bits. Mode[0] comes from
LCDDRV_CR[1]; the remaining two bits are driven from the
UDB through the digital system interconnect (DSI).
In normal operation, the buffer in High Drive mode drives the Figure 34-4. The DAC Charging an LCD Segment Pin in
LCD for a while, then a low-power source (either the DAC or Two Different States
the buffer in Low Drive mode) takes over and drives the LCD
Buffer DAC
for the remaining time.
Driving LCD Driving LCD
■ When using High Drive and DAC:
Initially, for some period of time, the buffer quickly
charges the LCD pixel capacitance near to the desired Drive
value. Later, when the drive signal goes low, the DAC
directly drives the LCD for the remaining period (if the
bypass_en bit is set) to sustain the voltage at the LCD
pin. If the bypass_en bit is not set to 1, the pin is tristated t
and no source drives the LCD. This can lead to charge
leakage from the pixel capacitance.
■ When using High Drive and Low Drive: Pixel
The drive signal always remains high. This means that
Voltage
the buffer is always enabled. The UDB controls the time
for which the buffer remains in High Drive and Low Drive
modes. t
Slope depends on drive mode
of buffer selected.
*1:4
Type A Multiplex Type B
Ratio (2x Type A Data Clock)
1/3 Bias
LCD Drive
Voltage Level
Display Data
Frame
LCD CLK
34.3.1.3 UDB To work more effectively with the DMA in transferring data to
the LCD drivers, port data registers are aliased to a sepa-
The UDB performs the following actions in the LCD system:
rate contiguous region in the memory map. These
■ Triggers the DMA periodically to bring the display data PRTx_DR_ALIAS registers are contiguous, to reduce the
from SRAM to the port data registers number of TDs required to move data.
■ Generates various control signals for the functioning of
An additional set of registers (per port), the
the LCD system hardware
PRTx_BIT_MASK registers, mask off the write capability to
❐ The drive signal, which is used to enable the driver the PRTx_DR_ALIAS registers on a bit level. This is an
buffer advantage if all of the pins on a given port are not being
❐ Two mode control signals for the buffer used for LCD; the unused pins can be masked off and used
❐ A synchronous LCD CLK, which is used to latch the for other purposes. The port data register (PRTx_DR) can
port data register value for a particular pin still be used to address pins masked off in the aliased data
❐ The frame signal registers.
The clock for the UDB is derived from the IMO. The clock
value changes with the refresh rate and the number of com- 34.4 LCD Low Power Mode
mons of LCD.
This mode is useful when LCD is required to be functional
34.3.1.4 DMA while the device is in low power mode. This requires special
hardware and firmware logic to wake the system up at regu-
DMA is used to transfer the display data into various port lar intervals, refresh the LCD, and put the device back to
data registers. The display data is stored in SRAM. Data sleep. Periodic refresh should happen at the specified rate,
transfer is initiated by the UDB at the beginning of the LCD even if there are other interrupts in the system.
refresh cycle. Depending on which and how many ports are
configured for the LCD drive, several transaction descriptors LCD low power mode uses all the of components that are
(TDs) associated with the DMA channel may need to be used for LCD always active mode. In addition to this, it also
chained together. uses a programmable wakeup source and small dedicated
digital logic to allow bug-free transitions to and from the low
There is no separate display memory, as such, in PSoC. power mode. Figure 34-6 on page 390 shows the block dia-
Display data resides in the SRAM connected to the periph- gram for the LCD low power mode.
eral hub (PHUB). The image/display buffer can be any block
of available memory.
A complete functional LCD low power system is formed PSoC 3 and PSoC 5 contain several clock sources that
using these major blocks: operate during device low power mode. ILO and OPPS
■ Dedicated LCD hardware timer are examples. These clock sources are used to trigger
periodic interrupts to the device to wake the system up. As
❐ LCD timer
shown in Figure 34-6, these two clock sources are select-
❐ LCD DAC able using a mux. The selected clock is fed to the 6-bit LCD
❐ LCD driver timer. It is a continuously running timer; that is, when the
❐ LCD bias generator timer overflows, the original period is reloaded in the timer
■ System resources register. The terminal count pulse from this timer triggers the
interrupt to the chip. This restores the main clocks of the
❐ Clocks: 1-kHz ILO and 8-kHz one pulse per second
(OPPS) chip. When this happens, the interrupt signal from the LCD
timer is intercepted by the UDB-implemented pulse genera-
❐ UDB implementation for sleep acknowledgement
tor. In response, the block generates a synchronous clock
❐ DMA for frame data transfer that causes several operations. See 34.4.1.2 UDB on
❐ UDB implementation for control signal generation page 391 for more details. Overall, the UDB's role is to pro-
(frame, drive, LCD mode, LCD CLK) vide control signals to various functional blocks of the LCD
❐ DMA for display data transfer low power system.
The blocks in bold are unique to the LCD low power system. At this time, the system must be put back to sleep after the
The other blocks are same as the LCD always active LCD refresh. In an LCD low power system, the CPU issues
system. a chip low power (LP) mode command to the power man-
What makes the LCD low power system different from the agement (PM) controller. (For this, firmware needs to be
LCD always active system? structured in a specific way explained in later section.) Con-
sent is given by the LCD hardware.
■ It can wake the system
■ It can continuously drive the LCD even when the chip is This is because the LCD refresh happens in hardware and
put in low power mode CPU doesn't know when it is completed. So, a control signal
(LP_ACK signal shown in Figure 34-6) is generated from the
UDB, which keeps the LP command from the CPU on hold
until the LCD refresh is completed. This control signal is The source can be selected by setting the clk_sel field of the
driven to the power management controller of the device. LCDTIMER_CFG register.
There are two DMAs used in this architecture. One DMA is The clock timer provides periodic interrupts to the system
used for the transfer of display data to the port data register, PM controller. The interrupt signal is also driven to the UDB
which is the same as in an LCD always active system. the to generate the LCD CLK signal.
other DMA is used to update the frame information into the
control register of the UDB each time the chip wakes up. 34.4.1.2 UDB
LCD low power mode uses the UDB to generate various sig-
34.4.1 Functional Description nals that control the functioning of the LCD system. These
This section gives details of the blocks and features used control signals are generated using the functional blocks
specifically in LCD low power mode. listed below:
■ Pulse generator
34.4.1.1 LCD Timer ■ BGREF timer
The LCD timer is a 6-bit timer dedicated only for the LCD ■ Drive pulse-width modulator (PWM)
drive application. Its period is set based on the required ■ Control register for frame data
refresh rate of the LCD. The period of this timer can be con-
■ Mode control signals to the LCD driver
figured by setting the period field of the LCDTMR_CFG reg-
ister. There are two options for the LCD timer clock source:
■ 1-kHz ILO
■ 8-kHz OPPS. This requires that an external 32-kHz crys-
tal be connected to the system.
BGREF Timer
Drive PWM EN
TC PWM
Drive
S
SR Q LP_ACK
Latch
R
Control Frame
Register
UDB
The pulse generator samples the interrupt signal from the 34.4.1.4 LCD DAC and Driver: Low Power
LCD timer; in response, it generates one synchronous clock Feature
pulse (LCD CLK), which is routed to the BGREF timer and
DMA (for frame data). This synchronous clock triggers these The LCD DAC and driver have some features that are useful
operations: for LCD low power mode functioning and help to achieve the
lowest power consumption when the LCD system is shut
■ Puts the sleep command issued by CPU, if any, on hold
down.
(using signal LP_ACK) until LCD refresh operation is
completed. The LCD DAC can remain active when the chip is put in
■ Enables the BGREF timer. The BGREF timer is used to sleep mode. In this mode, the DAC can continue to drive the
provide a 2.5-µs delay, which is necessary to stabilize inputs of LCD drivers. To enable this mode, set the
the bandgap reference circuit. continuous_drive bit in the LCDDAC.CR0 register to 1. The
LCD DAC receives a pwrdn signal, which shuts the DAC off
■ Triggers the DMA to transfer the frame data into the
when it is HIGH.
UDB control register. Frame is a square wave signal that
is used for proper sequencing of LCD refresh action. The LCD driver receives a display blank signal, dispbInk,
Each cycle of the frame signal represents one common controlled by the LCDDRV.CR register. This signal sets the
update state. output to be either tristated or grounded when the chip is in
low power mode. This function works when the power down
After the DMA transfer for frame data and the BGREF time-
signal (pwrdn_n) signal is low. The pwrdn_n signal is used
out are completed, Drive PWM is enabled. The Drive PWM
when the LCD system needs to be shut down.
output “Drive” signal is routed to all the LCD driver blocks
associated with the GPIO. It enables the LCD buffer to drive The buffer present in the LCD driver can be bypassed by
the LCD glass. The UDB also provides the two signals that setting the bypass_en bit of the LCDDRV.CR register to 1.
set the drive mode of the LCD buffer.
Thus, for operation in sleep mode, for an LCD low power
system, continuous_drive, bypass_en, and pwrdn bit must
34.4.1.3 DMA
be set to 1, and pwrdn_n must be set to 0. This causes the
Two DMA channels are used by the LCD component for: DAC to directly drive the LCD, bypassing the LCD driver
■ Transferring the frame information into the control regis- section, which is shut down in chip low power mode.
ter of the UDB from the system memory (RAM) The various operating modes of the LCD DAC and LCD
■ Transferring the display information from system mem- driver are summarized in Table 34-5 and Table 34-6 on
ory (RAM) into the port register page 393.
ILO
LCD COUNT 1 0 P P- 1 P- 2
LCD TC
LCD INT
LCD CLK
BGREF TIMER P 0
BGREF TIMER TC
PWM TC
LP_ ACK
A refresh timer overflow triggers an interrupt to the PM sys- pleted and the BGREF timer overflows, the LCD drive buffer
tem and also drives the UDB pulse generator logic. After a is enabled using the drive signal from the Drive PWM. This
few microseconds, system clocks are restored. This puts all is when LCD glass refresh begins. The drive mode of the
of the resources on the chip in operation. The UDB-imple- LCD drive buffer determines the current drive. After the drive
mented pulse generator outputs an LCD CLK pulse, which: time is set, the drive line goes low, disabling the buffer. This
■ Triggers the DMA to transfer frame information into the also releases the sleep command hold set by the LCD CLK.
control register of the UDB This causes PM to execute the sleep command issued by
the CPU. During the rest of the period, the LCD is driven
■ Enables the BGREF timer (implemented using UDB)
continuously from the LCD DAC, bypassing the driver buffer.
■ Copies the display data from the port data register into
the driver for the present LCD state Figure 34-9 on page 394 shows the sequence of operations
and relative current consumption for low-power mode.
■ Clears the refresh rate timer interrupt
■ Puts the sleep command from the CPU on hold
D E
DMA Track
Main/CPU Track A B C H
F G
Analog Track
End LCD
Drive Pulse
(LCD lp_ack
Turn On Asserts)
CPU and
Bus Clock
Begin LCD
Chip Drive Pulse
Transition
Relative into Active
Current Mode Turn On Chip
Consumption LCD DAC Transition
and Bias to Sleep
Generator Mode
0 1 2 3
Power
Phase
Main/CPU Track
A) Chip wake up process
B) ‘Main’ execution: Check for interrupts, request sleep
C) Power Manager (PM) asserts low power request (lp_req) to all
subsystems and waits for all acknowledge signals (lp_ack) to assert
H) PM Completes Active -> Sleep Mode transition
DMA Track
D) DMA TD: Update FR value
(must complete before starting ‘G’)
E) DMA TD: Setup Display Data for next LCD refresh cycle
Analog Track
F) LCD DAC and LCD bias generator power up (2.5 µs)
(must complete before starting ‘G’)
G) “Drive” pulse
PSoC® 3 and PSoC® 5 devices have a capacitive sensing feature called CapSense®. This feature allows users to take
advantage of the capacitive properties of their fingers to toggle aesthetically superior buttons, sliders, and wheels. Touch
pads and touch screens are common examples of capacitive sensing interfaces. The underlying principle of these technolo-
gies is the measurement of capacitance between a plate (the sensor) and its environment.
35.1 Features
Features of CapSense include:
■ Resources to support two capacitive sensors scanning simultaneously
■ Configurable low pass filter to remove switching noise for accurate measurement
■ Reference buffer with High Drive mode for faster measurement
AGL<0> AGR<0>
UDBs
AMUXBUSL AMUXBUSR
MUX MUX
LPF LPF
V-I DAC V-I DAC
Comparators Comparators
System Bus
AMUXBUSx
(PSRR). Two reference drivers operate independently; one
drives to AMUXBUSL, and one for AMUXBUSR. The driver
is connected to the AMUXBUS by setting the out_en bit in
the {CAPSx_CFG0}.
1
35.3.3 Analog Mux Bus R s = --------------
fs Cs
All GPIO pins support CapSense operations except SIO and
USB pins. The primary analog mux bus for CapSense is the Here:
AMUXBUS, which has two nets (AMUXBUSL and AMUX- Cs=Sensor Capacitance
BUSR) for two simultaneous sensing operations. These can
also be shorted to form a single net that connects to all 1 and 2 = Non-overlapping clocks, which may be config-
GPIO. Refer to the device datasheet for details about ured in a pseudo random sequence (PRS).
GPIOs available in each package and to the Analog fs = Frequency of the clock
Routing chapter on page 359 for a diagram of AMUXBUS
connectivity for the GPIO. Cmod = External Modulation Capacitance
AMUXBUSL and AMUXBUSR nets connect to all GPIO pins The CapSense methods can generally be done with either
on their respective halves of the device. CapSense uses the switching high or switching low at the GPIO pin. The rest of
AMUXBUS net, along with an analog global net (AGR[0] the hardware is configured with the appropriate polarity to
with AMUXBUSR, and AGL[0] with AMUXBUSL) to provide match to the pull up or pull down choice.
feedback to the reference driver. This feedback is from a pin
Vdd Vdd
AMUXBUSx
AMUXBUSx
1 RS
2
CS
AMUXBUSx
2
CS 1
RS
The CapSense clock is used for switching. Two alternatives GPIOs pins can be made as Shield Electrodes. The shield
are available to generate the CapSense clock (refer also to electrodes help in reliable operation in presence of water
Figure 21-1 on page 188). film or water droplets. The effect of these factors on shield
■ The UDB generates two global clocks (caps_dsi_lft and electrode is measured and is removed from the CapSense
caps_dsi_rt), and routes to GPIO logic of the I/O pins in Buttons. The CapSense algorithms discussed below sup-
the respective side. The PRT[x]_CAPS_SEL[y] registers port the shield electrode.
(per port per pin basis) are set to select the global clock
for switching the sensor during measurement. 35.3.5 Other Resources
■ The DSI output to the I/O pin can be used to source the CSD CapSense techniques use many resources in PSoC 3
CapSense clock from the UDB. The PRTx_BIE[y] must and PSoC 5 devices. These include UDBs, Comparators,
be programmed for input (per port per pin basis) and and V-I DAC. See the Universal Digital Blocks
PRT[x]_CAPS_SEL[y] is cleared to select the DSI output (UDBs) chapter on page 213, Comparators chapter on
signal for the CapSense clock. page 375, and Digital-to-Analog Converter chapter on
With either of these paths, the nonoverlapping clock phases page 409 for more detail on those.
discussed above are automatically generated within the
GPIO switching structure.
35.4 CapSense Delta Sigma 3. As the integration capacitor voltage moves back and
forth across the comparator threshold, the comparator
Algorithm high outputs are counted in an interval to give a measure
of the sense capacitor.
The CapSense Delta Sigma (CSD) algorithm shown in
4. The sense capacitance increases with touch, therefore
Figure 35-5 and Figure 35-6 on page 401 measures capaci-
equivalent resistance decreases. This decreased resis-
tance with the hardware configured like a Delta Sigma mod-
tance causes an increase in the current flowing through
ulator. Delta Sigma capacitive sensing operates by holding switch CapSense resistor.
an integration capacitor voltage near a target threshold, and
5. To maintain the voltage on Cmod near VREF during a
charging or discharging the capacitor, based on the present
touch, the IDAC sinks current for longer duration to com-
state of a comparator output. The sense capacitor is contin-
pensate for the larger sense capacitance. This changes
uously switched between Vdd and the integration capacitor,
the count value accordingly.
which drives the integrated voltage up on each switching
cycle. The CSD algorithm operates as follows: A PRS (pseudo random sequence) clock may be used
instead of a fixed clock source to drive the precharge
1. When the integration voltage reaches the reference volt-
age, the comparator enables current DAC to discharge switches. The PRS clock produces less radiated noise on
the capacitor. the sense capacitor, compared to a fixed clock source,
hence improving EMI and interference performance.
2. When the capacitor voltage discharges below the refer-
ence voltage, the current DAC is disabled to allow the
capacitor to continue charging.
Figure 35-5. CSD Hardware Configuration
VDD
UDB
1 PRSCLK Prescale
and PRS
2
CS IDAC En
Vin UDB
LPF UDB
Vmod
Initialize D Q
C MOD Ref Counter
AMUXBUS
Driver
Vref
C
UDB
CounterClock
Prescale
CMOD
Voltage
Comp Out
when No
Touch
Smaller count
Comp Out
when
Finger is
present
Larger Count
The PSoC® 3 and PSoC® 5 devices have an on-chip Temperature Sensor that is used to measure the internal die tempera-
ture. The temperature sensor uses the Delta Vbe method for digital temperature measurement.
The temperature sensor block has an auxiliary analog-to-digital converter (ADC) for measuring the internal die temperature.
The auxiliary ADC is a 10-bit accurate ADC in the system performance controller (SPC) primarily designed for measuring
temperature sensor output but can also be used for general purposes supplementing the main Delta-Sigma ADC. It is also
possible to route the analog output of diode in temperature sensor block to analog globals to measure temperature more
accurately using the Delta-Sigma ADC in PSoC 3.
36.1 Features
The temperature sensor offers the following features:
■ ± 5 degrees Celsius accuracy over commercial temperature range (-50ºC to +150ºC)
■ Ability to route temperature sensor output to analog global line, AGL3.
Digital
Parallel Current Paths To AGL3 Temperature
Vbe
Auxiliary
Curvature ADC
Temperature
Compensation
Diode
Circuit
eight current mirror paths during conversion (low current SPC_CPU_DATA 8 Data to or from CPU
■ Curvature compensation circuit to increase linearity Status – ready, data available, status
SPC_SR 8
code
when the temperature sensor output is routed to an
external resource with a High Z buffer such as the on-
The command sequence consists of a 2-byte key, followed
chip Delta Sigma ADC.
by command code and the parameters associated with the
■ A two point linear fit calibration routine for accurate tem- command.
perature measurements using the Auxiliary ADC.
■ Key byte #1 – always 0xB6
■ Key byte #2 – 0xD3 plus the command code (ignore
overflow)
■ Command code byte
■ Command parameter bytes
■ Command data bytes
2 -B y te K e y C o m m a n d P a ra m e te r B y te s
0 x B 6 0 x E 1 0 x 0 E n u m S a m p
C o m m a n d C o d e
0 x D 3 + C o m m a n d C o d e
Command Parameters
Once the command and its parameters are sent, the Temperature Sensor/ADC block is configured and starts the conversion.
When the conversion is complete, the DATA READY bit in the Status register (SPC_SR) is set. The CPU must poll this bit to
check if the ADC output is ready. When the bit is high, the first byte (Sign byte) of output is read from the Data register
(SPC_CPU_DATA). The DATA READY bit is reset once a read operation is done. When the second byte (Magnitude byte) is
ready to read, the DATA READY bit becomes high once again and the second byte is read from the Data register
(SPC_CPU_DATA).
Note that AGL3 should not be used by analog blocks other than the temperature sensor output when this command is exe-
cuted. Even though PSoC Creator™ takes care of routing, the user must ensure that there are no resource conflicts in using
AGL3. The command sequence is shown in Figure 36-3.
Command Code
0xD3 + Command Code
spcCLK
------------------------------------------
- Equation 1
clkDivider + 1
The clock divider value (clkDivider) is of 8 bits allowing clock
to have 256 different frequencies ranging from spcCLK
down to spcCLK/256 (spcCLK is 36 MHz). In general, the
slower the clock, the better the linearity that will be
achieved.
The Digital-to-Analog (DAC) Converter is an 8-bit digital-to-analog converter that is configured to output either a voltage or a
current. The 8-bit DAC supports CapSense®, power supply regulation, and waveform generation.
37.1 Features
The DAC has the following features:
■ Adjustable voltage or current output in 255 steps
■ Programmable step size (range selection)
■ Eight bits of calibration to correct ± 25% of gain error
■ Source/sink option for current output
■ Output rate for current IDAC output: 8 Msps
■ Output rate for VDAC voltage output: 1 Msps
■ Monotonic in nature
ISOURCE Range
1x, 8x, 64x
Reference
Scaler Vout Iout
Source
R
3R
ISINK Range
1x, 8x, 64x
For each level, there are 255 equal steps of M/256 where
M = 2.048 mA, 256 µA, or 32 µA. In the 2.040 mA configura-
tion, the block is intended to output a current into an external
600 load.
DAC Bus
(data[7:0])
Register DAC0_SWV[4:0] Register DAC1_SWV[4:0]
AGL0 DAC0_D[7:0] DAC1_D[7:0] AGR0
AGL1 AGR1
AMUXBUS AMUXBUSR
abusl1
L V V abusr1
abusl3 DAC0 DAC1 abusr3
P0[6] I I P3[0]
AMUXBUSL AMUXBUSR
AGL0 AGR0
AGL1 AGR1
Register DAC0_SWI[3:0] DAC0_strobe DAC1_strobe Register DAC1_SWI[3:0]
The user can route output as follows: For example, the implementation of a 12-bit DAC using two
■ Voltage Mode – to the analog globals, analog mux bus, 8-bit DACs require:
or the analog local bus ■ One DAC scaled to the range 0 to 2.048 mA and the
■ Current Mode – to the analog globals, analog mux bus, second one scaled to the range 0 to 32 µA.
or to a specific port ■ The middle 4 bits of the lowest range DAC are used as
inputs to the lower 4 bits. See Figure 37-4 on page 412.
37.3.4 Making a Higher Resolution DAC This architecture may have problems of mismatch in the two
It is possible to achieve a higher resolution current output DACs and therefore might require adjustment and scaling.
DAC by summing the outputs of two 8-bit current DACs, The last two bits of the LSB DAC are used for minor calibra-
each one having a different segment of the input bus for tion requirements.
input. The range of the two DACs used partially overlap.
12-Bit DAC
GND 7:6
Calibration
1:0
Bits
1 µA/Bit 128 64 32 16 8 4 2 1
DACx_CR0 DAC Control register 0 Select DAC mode, range, and speed
DACx_CR1 DAC Control register 1 Control DAC data source, reset, and direction
DACx_SW0 DAC Analog routing register 0 Routing for the DAC voltage output to analog (global) bus
DACx_SW2 DAC Analog routing register 2 Routing for the DAC voltage output to analog (local) bus
DACx_SW3 DAC Analog routing register 3 Routing for the DAC current/voltage output to AMUXBUS
A voltage/current reference with value independent of supply voltage and temperature is an essential building block of many
analog circuits. For example, accurate biasing voltages are critical for many circuit schemes; in ADC, a reference voltage is
required to quantify an input, while in V/I DAC, voltage/current reference is required to define the output full-scale range.
The voltage reference block diagram is illustrated in Figure 38-1 on page 414.
10 µA
IREF(DAC)
Vcca
Vcca
Trim
Buffer Buffered in DSM Block
(I) Buffers 5 µA
1.2V by 10 µA Buffers
Bandgap Vcca VREF2 (DSM)
Generator (V) +_
+
_ 1.024V VREF1 (DSM) Delta Sigma ADC
+_
Vssa Vssa
+_ VREF0 (Comparator)
BG_CR0[3]
+_ VREF (SC)
BG_CR0[2]
0
ABUSL0
1
0.9V +_ VREF (TEMP SENSOR)
0.8V
VREF1_CM (DSM)
Resistor String
Vssa
0.7V
VREF2_CM (DSM)
BG_CR0[1:0]
1
0.256V VREF1 (Comparator)
+_ 2
+_ VREF (DAC)
Vssa
Note 1 Analog supply Vdda or Vdda/2 can be routed to the analog blocks through the analog local bus, ABUSL0. The volt-
age level is selected using the BG_CR0[3] bit and the switch is enabled using the BG_CR0[2] bit.
Note 2 Reference voltage input (VREF1) to the comparator is selected using the BG_CR0[1:0] bits. It selects either bandgap
reference voltage or the analog supply voltage.
Note 3 IREF (DAC) is the reference current for the DAC during IDAC mode operation.
The PSoC® 3 and PSoC® 5 ADC is a high resolution ADC implemented in Delta Sigma technology. Delta Sigma converters
are integrating converters that provide high SNR/resolution by oversampling, noise shaping, averaging, and decimation. A
Delta Sigma Analog-to-Digital Converter (ADC) has two main components: a modulator and a decimator. The modulator con-
verts the analog input signal to a high data rate (oversampling), low resolution (usually 1 bit) bitstream, the average value of
which gives the average of the input signal level. This bitstream is passed through a decimation filter to obtain the digital out-
put at high resolution and lower data rate. The decimation filter is a combination of downsampler and a digital low pass (aver-
aging) filter that averages the bitstream to get the digital output.
39.1 Features
■ 8 - to 20-bit resolution
■ Configurable gain from 0.25 to 256
■ Differential/single ended inputs
■ Optional input buffer with RC low pass filter
■ Internal and external reference options
■ Reference filtering for low noise
■ Incremental/continuous mode
■ Gain and offset correction
Positive
Input Mux
Input Delta Sigma
Buffer Modulator
Negative
Input Mux
High data rate (sampling rate)
low resolution bitstream in
thermometric format q[7:0]
Analog Interface
High data rate (sampling rate) low
resolution bitstream in 2's
complement (4-bit)
Decimator
24-bit Output Register High resolution (max 20 bits) low
data rate (sampling rate/
decimation ratio) output
The input structure is illustrated in Figure 39-2. 0.5 1.5000 1.75 1.7840
1 0.75 0.875 0.892
2 0.3750 0.4375 0.4460
4 0.1875 0.2188 0.2230
8 0.0938 0.1094 0.1115
16 0.0469 0.0547 0.0558
Csumin
inp
Csum1
Cdac
o1p
Csum2 Csumfb
o2n
Cdac
Csum1
inn
Csumin
Quantizer
b[8:0]
QLEV[1:0]
Table 39-5 indicates how to configure power for the individual blocks. Power dissipation, capacitances, clock frequency and
quantization levels are interrelated to each other.
Configuring power without varying the other parameters mentioned above affects the proper operation of the modulator. The
tables below show a set of operational modes that indicate how to configure power based upon the other parameters or vice
versa.
Table 39-6. Power Configuration Based on Quantization Levels and Clock Frequency
Mode - 3 MHz 9 Level Mode - 6 MHz 9 Level Mode - 3 MHz 2 Level and 3 Level
Register Bit
Bit Setting Typical Value Bit Setting Typical Value Bit Setting Typical Value
FCAP1OFFSET 0 0 1
FCAP1[6:0] 1010000 8 pF 0010100 2 pF 1111110 16 pF
FCAP1EN 0 0 0
IPCAP1OFFSET 0 0 0
IPCAP1[6:0] 0101100 4.4 pF 0001011 1.1 pF 0101100 4.4 pF
IPCAP1EN 0 0 0
DACCAP[5:0] 101100 001011 101100
4.4 pF 1.1 pF 4.4 pF
DACCAPEN 0 0 0
RESCAP[2:0] 000 000 000
0fF 0fF 0fF
RESCAPEN 0 0 0
FCAP2[3:0] 1011 0001 1011
0.55 pF 0.1 pF 0.55 pF
FCAP2EN 0 0 0
IPCAP2[2:0] 101 001 101
0.25 pF 0.05 pF 0.25 pF
IPCAP2EN 0 0 0
FACP3[3:0] 1110 0011 1110
1.4 pF 0.3 pF 1.4 pF
FCAP3EN 0 0 0
IPCAP3[2:0] 101 001 101
0.25 pF 0.05 pF 0.25 pF
IPCAP3EN 0 0 0
SUMCAPIN[4:0] 00101 00001 00101
0.25 pF 0.05 pF 0.25 pF
SUMCAPINEN 0 0 0
SUMCAPFB[3:0] 1010 0010 1010
0.5 pF 0.1 pF 0.5 pF
SUMCAPFBEN 0 0 0
SUMCAP1[2:0] 101 001 101
0.25 pF 0.05 pF 0.25 pF
SUMCAP21EN 0 0 0
SUMCAP2[2:0] 101 001 101
0.25 pF 0.05 pF 0.25 pF
SUMCAP2EN 0 0 0
SUMCAP3[2:0] 101 001 101
0.25 pF 0.05 pF 0.25 pF
SUMCAP3EN 0 0 0
QLEVEL[1:0] 10 level=9 10 level=9 00 or 01 level=2 or 3
ODET_TH[4:0] 01100 12 01100 12 01100 12
FCHOP[2:0] 001 Fclk/4 001 Fclk/4 001 Fclk/4
NONOV[1:0] 01 3.5 ns 00 1.5 ns 01 3.5 ns
POWER1[2:0] 010 430 µA 010 430 µA 010 430 µA
POWER2_3[2:0] 010 62 µA 010 62 µA 010 62 µA
POWER_SUM[2:0] 010 62 µA 010 62 µA 010 62 µA
POWER_COMP[1:0] 01 9 µA 10 18 µA 01 9 µA
vpwra Vcmx
(unbuffered VCM)
No Selection 00
VCMBUF0
0.8V 01
NC VCM To the opamps in the
0.7V 10
vpwra/2 DSM
11
vcm_res_div_en
vssd
en_buf_vcm
vcmsel<1:0> en_buf_vref_inn
S1 S8
Resd1
Resd2
Resd3
Resd1
Resd2
Resd3
vdda
refmux<2:0>
vref_res_div_en
vdda/3
vdda/4
P3[2] P0[3]
vgnd
Figure 39-5. Connection Scenario: Internal Reference with No RC Filtering (using P0[3])
S1
Res d1
Res d2
Res d3
No External Reference or
External Filtering
S6
Vref for Quantizer
Resistor String
S5
S3
Vref S4
From +
Mux S0 S2 Vref for ADC
-
Internal reference
Buffered Filtered with
External Capacitor
S1
Res d1
Res d2
Res d3
C (External)
S3
Vref S4
from +
Vref is Driven by
Mux - S0 S2 an External Source
S1
Resd1
Resd2
Resd3
REFBUF0 is
Powered Down
(Output Tristated)
There are several selectable options for internal reference, turbo power modes in the DSM_CR17 register. The com-
based on refmux[2:0] programming in DSM_REF0 register. mon mode voltage buffer, internal reference voltage buffer,
The places in the DSM block (Figure 39-3 on page 419) that and the negative input buffer are powered down, using
require a reference value are: DSM_CR17[1]; DSM_CR17[0], and DSM_REF0[3] register
■ DAC capacitor (Cref) sampling in the first integrator bits, respectively.
■ Reference for the resistive ladder inside the quantizer 1. Power on the VCMBUF0 for the DSM to function.
block 2. Turn on the reference buffer REFBUF1 only when you
want to drive the ADC reference to the negative input
■ Common Mode Voltage (VCM) for the differential cir-
mux of the DSM channel.
cuits. This voltage is typically 0.8V with an option to go to
0.7V for better head rooms. A provision for applying 3. Power down REFBUF0 only when you want to drive ref-
erence to the ADC from an off-chip source (See the
VDD / 2 is also provided.
external reference option in Table 39-10).
39.3.2.8 Reference for DSM: Usage To get low reference noise, the option to filter is provided
Guidelines with the special connections to pins P3 [2] and P0 [3], as
shown in Figure 39-4 on page 427 and Figure 39-7 on
The following table shows the state of various switches and
page 428. Therefore, for low noise floor requirements, use
the two reference buffers for certain selectable reference
the external capacitor filter. Only two pins, P3 [2] and P0 [3],
options.
are dedicated for this purpose in PSoC 3 and PSoC 5
Not every possible combination of closing the switches devices. The switches in Table 39-10 that are marked as
marked S0-S13 is discussed in this section. The configura- ON mean that the switch is closed, and a path is created for
tion of these switches (therefore the reference selection) is reference to reach DSM. Empty cells indicate that the
made in registers DSM_REF2 and DSM_REF3. The refer- switches are open.
ence buffers can be configured in low, medium, high, and
Table 39-10. Analog Reference Modes for the Delta Sigma Channel
SN Mode Switch States REFBUF0
S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13
Internal Reference
1 ON ON ON ON
(No Filtering)
Internal Reference
2 ON ON ON ON ON
(Filter with P3[2])
Internal Reference
3 ON ON ON ON ON
(Filter with P0[3])
External Reference
4 ON ON OFF
only (P3[2])
External Reference
5 ON ON OFF
only (P0[3])
Vpwra is internal ref-
6 ON ON ON OFF
erence
DSMn
vp
vn
ANALOG
dsmn_clk
dsmn_modbitin
dsmn_dout[7:0]
dsmn_startup_reset
dout_sat[7:0]
modbitin_en
mx_startup_reset
1 0
mx_modbitin[3:0]
tempcode_in[7:0]
TEMPCODE- qlev[1:0]
8 2SCOMP
lut_outputs[7:0]
dout2scomp[3:0]
out0[7:0]
out1[7:0]
1 0
mx_dout
dsmn_extclk_cp_udb dsmn_clk_udb
dsmn_startup_reset_udb
dsmn_dout2scomp[3:0]
dec_clk
dsmn_reset_dec
DECIMATOR dsmn_dout_udb[7:0]
dec_irq
dsmn_modbitin_udb dec_start
UDB
39.3.3.1 Conversion of Thermometric Code to input can be enabled by setting the DSM_CR3[4] register
Two’s Complement bit. Modulation input is selected by DSM_CR3[3:0] control
bits.
The following table shows the conversion from thermometric
format to two’s complement for 2, 3, and 9 level quantiza- 39.3.3.3 Clock Selection and Synchronization
tions performed by the analog interface. This two’s comple-
ment input is fed to the decimator. The output of the modulator (quantizer) Q[7:0] can be syn-
chronized with respect to the digitally aligned clock of the
Table 39-11. Two’s Complement Conversion Table analog clock selected for the modulator. As mentioned in
Inputs Output
39.3.2 Delta Sigma Modulator on page 419, clock selection
is done by DSM_CLK[2:0] register bits. Clock synchroniza-
qlev[1:0] dout[7:0] dout2scomp[3:0]
tion is enabled by clearing the DSM_CLK[4] register bit.
00 00000000 1111 -1
00 11111111 0001 +1
39.3.4 Decimator
The decimator takes the 4-bit input (low resolution) in two’s
01 00000000 1111 -1 complement format and converts it into a high resolution
01 00001111 0000 0 output. The 4-bit two’s complement values coming into the
01 11111111 0001 +1
decimator at the input sampling rate are averaged over a
specified number of samples (decimation ratio), down sam-
pled, and passed through an optional post-processing filter,
1x 00000000 1100 -4
achieving a higher resolution. The decimator in PSoC 3 and
1x 00000001 1101 -3
PSoC 5 devices is a fourth order Cascaded Integrator Comb
1x 00000011 1110 -2
(CIC) filter. The decimator structure is shown in Figure 39-9
1x 00000111 1111 -1 on page 432.
1x 00001111 0000 0
1x 00011111 0001 +1 39.3.4.1 Shifters
1x 00111111 0010 +2
There are two shifters in the block — one in front of the CIC
1x 01111111 0011 +3
filter and another one in front of the post processor. The
1x 11111111 0100 +4 input shift values are programmed depending on the deci-
mation ratio and quantization level to ensure that ADC
39.3.3.2 Modulation Input results are available in the Q31 format.
As discussed in 39.3.2.5 Other Configuration Options on The shift values are programmed in register DEC_SHIFT1.
page 426, modulator gain can be inverted by the sign bit in The shift values to be programmed in DEC_SHIFT1 and
DSM_CR3. The sign can also be changed by a direct digital DEC_SHIFT2 for various decimation ratios (DR1 and DR2)
input from LUTs or the UDB. The modulation input assists in and quantization levels are shown in Table 39-12 and
this process. Depending on whether the modulation input is Table 39-13 on page 432.
high or low, the gain is normal or inverted. The modulation
Table 39-12. Programmed Shifter1 Values for Various Decimation Ratios (Programmed in DR1)
Decimation Ratio Quantization Levels Max Values in Range Bit Width Shift Adjustment
8 2, 3 4095 to -4096 12 Left shift 20
8 9 16383 to -16384 14 Left shift 18
16 2,3 65535 to -65536 16 Left shift 16
16 9 262143 to -262144 18 Left shift 14
32 2, 3 1048575 to -1048576 20 Left shift 12
32 9 4194303 to -4194304 22 Left shift 10
64 2, 3 16777215 to -16777216 24 Left shift 8
64 9 67108863 to -67108864 26 Left shift 6
128 2, 3 268435455 to -268435456 28 Left shift 4
128 9 173741823 to -1073741824 30 Left shift 2
Table 39-13. Programmed Shifter2 Values for Various The decimation ratios to be configured for 12, 14, 16 and 20
Decimation Ratios (Programmed in DR2) bit resolutions for 9 level quantization are shown in
Table 39-15.
Value of D2 Right Shift Value
1 No shift, bypass sync (boxcar) filter Table 39-15. Decimation Ratios for 9 Level Quantization
16 4
Final
32 5 Clock, Decimation Ratio
Resolution
64 6 12-bit 6.144 MHz, 16
128 7 14-bit 6.144 MHz, 32
256 8 16-bit 3.072 MHz, 64
512 9 20-bit 3.072 MHz, 16384 (CIC + post processor)
1024 10
39.3.4.3 Post Processing Filter
39.3.4.2 CIC Filter
The Post Processor receives 28-bit data from the output of
The CIC filter has four cascaded integrator sections operat- the CIC Decimation filter for further convenience or post pro-
ing at the modulator sample rate, followed by four cascaded cessing. Available functions are:
comb sections operating at a lower sample rate (determined
■ Add a programmable offset coefficient to the CIC result
by DR1). This combination implements a sinc4 Finite
Impulse Response (FIR) filter. The CIC filter is controlled by ■ Multiply a programmable gain coefficient to the CIC
a finite state machine that allows it to sequence events in result
the various modes of operation of the decimator. The deci- ■ Apply both offset and gain
mation ratio is programmed in the DEC_DR1 register. The ■ Apply a sinc1 FIR filter
registers in CIC filter are 32-bits wide and, therefore, for
■ Apply both a sinc1 filter and offset correction
proper operation, the decimation ratio should not exceed the
values given in Table 39-14. ■ Apply both a sinc1 filter and gain correction
■ Apply all three
Table 39-14. Maximum Decimation Ratio Values for CIC
When more than one of the three functions is enabled to
Level Bit Width Encoding (Decimal) Max Allowed
operate concurrently on the data, they are always performed
2 32 -1, 1 256
in the order: FIR > Offset > Gain. The decimator process is
3 32 -1, 0, 1 215 shown in Figure 39-9.
9 32 -4, -3, -2, -1, 0, 1, 2, 3, 4 152
Sample
Data From
Shifter1
Modulator Sample
CIC - Decimation Data Out of
Decimator
Post Processor
Shifter2
FIR
Offset Gain
Decimation Post
Ratio DR1 Processor
Enabled
Decode of Which
PP Features
are Enabled
The offset value to be added is programmed in registers ■ Offset Value (write protected) – protected on writes so
DEC_OCOR, DEC_OCORM, and DEC_OCORH. The 24-bit that the underlying hardware does not incorrectly use
offset is given in signed two’s complement format. The reg- the field when it is partially updated by the system soft-
isters are coherency interlock protected (see 39.3.5 Coher- ware.
ency Protection on page 433). ■ Output Sample Value (read protected) – protected on
The gain correction coefficient is programmed in registers reads so that the underlying hardware does not update it
DEC_GCOR, DEC_GCORH. The number of bits that are when partially read by the system software or DMA.
valid in the above register is programmed in the Depending on the configuration of the block, not all bits
DEC_GVAL[3:0] register bits. This allows use of a part of of the output sample register are of interest.
the 16-bits for gain correction. The registers are coherency The coherency methodology allows for any size output field
interlock protected. If the gain feature is used, the value pro- and handles it properly. In the COHER register, coherency is
grammed into the DR1 register (CIC decimation ratio) can- both enabled, and a Key Coherency Byte is selected. The
not be smaller than 2+2*GVAL, allowing time for the Key Coherency Byte allows the user to tell the hardware
hardware to do a shift-add multiple during the decimation which byte of the field will be written or read last when an
period. update to the field is desired. Each for the three protected
The FIR filter is a summer that implements the sinc1 filter. It fields has a Coherency Interlock Flag (CIF). This flag signi-
is used in cases where decimation ratios greater than 128 fies whether the field is coherent.
are desired. When the FIR function is enabled, the Post Pro- The coherency hardware understands both 8-bit and 16-bit
cessor sums samples from the CIC filter, DR2 at a time, accesses and when tracking coherency, handles each
where DR2 (10 bits) is the decimation ratio programmed in appropriately. A hard or soft reset sets all CIF to coherent.
the DEC_DR2, DEC_DR2H[1:0] registers.
Gain correction, offset correction, and FIR filtering features 39.3.5.1 Protecting Writes (Gain/Offset) with
can be enabled and disabled in the DEC_CR[6:4] register Coherency Checking
bits. The Post Processor implements saturation logic that Starting from a coherent state (CIF is set), the software can
prevents over- and under-flow wraparound in the accumula- write any of the other non-key bytes. This action flags the
tor. If the DEC_CR[7] bit is set, the ALU does not wrap when field incoherent (clears the CIF). When a field is incoherent,
the most positive or negative number is exceeded. it is ignored by the underlying hardware, and a shadow reg-
The output of the conversion is stored in registers OUT- ister containing the last valid value is used. The field
SAMP, OUTSAMPM, and OUTSAMPH. In some configura- remains flagged incoherent until the Key Coherency Byte is
tions of the block, output results of interest are placed in bits written. At this time, the field is flagged coherent (CIF is
23:8 of the output sample field. To allow reading such val- again set), and the next time the hardware needs the field
ues in one bus cycle, an alignment feature is added to shift value, the new value is used, and the shadow register is
the result right by 8 bits. This feature is enabled by the updated with the new value.
OUTPUT_ALIGN bit of the DEC_SR register.
39.3.5.2 Protecting Reads (Output Sample)
39.3.5 Coherency Protection with Coherency Checking
Starting from a coherent state (CIF is set), the software can
Coherency refers to the hardware added to a block to pro-
read any of the other non-key bytes of the field. This action
tect against malfunctions of the block in cases where regis-
flags the field incoherent (clears the CIF). When a field is
ter fields are wider than the bus access, leaving intervals in
incoherent, it is protected against updates from the underly-
time when fields are partially written or read (incoherent).
ing hardware, and any new samples that may be generated
Coherency checking is an option and is enabled in the
while incoherent are dropped (without warning). The field
DEC_COHER register.
remains flagged incoherent until the Key Coherency Byte is
The hardware provides coherency checking on three regis- read. At this time, the field is flagged coherent (CIF is again
ter fields that are all up to three bytes wide: set), and the next time the hardware generates a new output
■ Gain and Gain Value (write protected) – really two fields, sample result, the field is updated.
but they are checked for coherency as if they are a sin-
gle field protected on writes so that the underlying hard-
ware does not incorrectly use the field when it partially
updated by system software.
No Start No Start
IDLE IDLE
Start Start
Runs Once
Wait 3 Cycles to Prime Wait 3 Cycles to Prime
4 Stage CIC 4 Stage CIC
No Start No Start
IDLE IDLE
Start Start
Terminal Count
The PSoC® 5 architecture has two successive approximation register analog to digital convertors (SAR ADC) in addition to
the delta sigma ADC. The SAR ADC is designed for applications that require medium resolution and high data rate. The SAR
ADC takes its input from the analog globals, locals and the mux bus and the output can be taken from a register or be sent to
the UDB for further processing.
40.1 Features
■ 12-bit resolution
■ Single ended, differential input
■ Rail-to-rail input (0V to Vdda)
■ 1 MSPS sample rate
■ Four power modes
■ Single shot or continuous running mode
Figure 40-1. SAR ADC Block Diagram
AGL0 AGR0
AGL1 AGR1
AGL2 AGR2
AGL3 AGR3
AGL4 AGR4
AGL5 AGR5
AGL6 AGR6
AGL7 AGR7
abusL0 abusR0
abusL2 abusR2
VSSA VSSA
SAR0.SW*, or
DSI selection
AGL0
SAR0 SAR1 SAR0.SW*, or
DSI selection
AGR0
AGL2 AGR2
AGL4 AGR4
AGL6 AGR6
AMUXBUSL AMUXBUSR
abusL1 abusR1
abusL3 abusR3
VREF VREF
VSSA VSSA
SAR0.SW*, or SAR0.SW*, or
DSI selection DSI selection
40.2.6 Operational Modes from the UDB. The selection between software and UDB
trigger is made in SARx_CSR0[2] register bit.
The SAR can be configured in two modes, single capture or
continuous. In single capture, the SAR ADC completes one As long the SOF stays high the conversion continues, the
conversion on a trigger; in the continuous mode the SAR conversion stops once the SOF goes low.
ADC performs continuous conversion. The trigger can be The two modes, single capture and continuous, is realized
either software or hardware. The software trigger comes in the way the SOF bit is configured, i.e., level or edge sen-
from SARx_CSR0[0] register bit and the hardware trigger is sitive SOF. In the level sensitive mode, the SAR ADC per-
forms the conversion as long as the SOF bit is asserted
high. So, the level sensitive mode is used for continuous Table 40-2. SAR Connections
conversion.
SAR0 Decode Table
In the edge sensitive mode, the SAR performs a conversion VP Connection VN Connection
on the edge and the bit is automatically reasserted low on 9 ABUSL[2] 9 Hi-Z (N/C)
the completion of the conversion (on the end of frame A VSSA A Hi-Z (N/C)
(EOF)). So, it has to be reasserted high for the next edge for B Hi-Z (N/C) B Hi-Z (N/C)
the SAR ADC to start conversion. This mode helps in per- C Hi-Z (N/C) C Hi-Z (N/C)
forming single sample conversions.
D Hi-Z (N/C) D Hi-Z (N/C)
In case of hardware enabled SOF, the user can sync the E Hi-Z (N/C) E Hi-Z (N/C)
conversion to a PWM frequency by configuring it in the edge F Hi-Z (N/C) F Hi-Z (N/C)
mode.
The level or edge triggered function of the SOF signal is
configured in the SARx_CSR0[1] register bit.
JTAG (4- or 5-wire) or Serial Wire Debugger (SWD) (2 wire) interfaces are used for programming and debug. The 1-wire Sin-
gle Wire Viewer (SWV) can also be used for “printf” style debugging. By combining SWD and SWV, the designer can imple-
ment a full debugging interface with just three pins. Using these standard interfaces enables the designer to debug or
program the PSoC® device with a variety of hardware solutions from Cypress or third-party vendors.
This section encompasses the following chapters:
■ Test Controller chapter on page 443
■ 8051 Debug on-Chip chapter on page 455
■ Cortex-M3 Debug and Trace chapter on page 465
■ Nonvolatile Memory Programming chapter on page 473
Program
System Bus
Boundary Scan
The PSoC® 3 and PSoC® 5 architectures include a test controller used for the following purposes:
■ Access to I/O pins for boundary scan testing.
■ Access to the device memory and registers (via the PHUB) through either the PSoC 3 Debug on-Chip (DOC) module or
the PSoC 5 Cortex-M3 Debug Access Port (DAP) for functional testing, device programming, and program debugging.
The test controller connects to off-chip devices via the Joint Test Action Group (JTAG) interface or the Serial Wire Debug
(SWD) interface. These interfaces use I/O port pins; the exact number of pins depends on the type of interface used.
41.1 Features
The test controller has the following features:
■ Supports JTAG or SWD interface to a debug host
■ SWD interface available on either GPIO or USB pins
■ Supports boundary scan in accordance with the JTAG IEEE Standard 1149.1-2001 “Test Access Port and Boundary-
Scan Architecture”
■ Supports additional JTAG instructions/registers beyond IEEE Standard 1149, for access to the rest of the device
■ Interfaces to PSoC 3 or PSoC 5 debug modules for access to the rest of the device for program and debug operations
TDI
TDO/SWV
Debug
Test
TMS/SWDIO On- 8051
Controller
Chip
TCK/SWDCK
nTRST
SWV
In PSoC 5 architecture, under certain JTAG instructions, the JTAG or SWD signals are simply passed to the ARM Debug
Access Port (DAP). See Figure 41-2.
Figure 41-2. PSoC 5 Test Controller Block Diagram
TDI
SWDITMS TDI_OUT
SWCLKTCK TMS_OUT
Test
nTDOEN TCK_OUT DAP Cortex-M3
Controller
TDO TDO_IN
SWDOEN SWDO_IN
SWDO
41.3 Background Information most GPIO and SIO port pins have a boundary scan cell
associated with them (see GPIO and SIO block diagrams in
The following information is provided to familiarize the user the I/O System chapter on page 187).
with the JTAG interface and the IEEE 1149 specification.
The interface used to control the values in the boundary
scan cells is called the Test Access Port (TAP) and is com-
41.3.1 JTAG Interface monly known as the JTAG interface. It consists of three sig-
In response to higher pin densities on ICs, the Joint Test nals: (1) Test Data In (TDI), (2) Test Data Out (TDO), and
Action Group (JTAG) proposed a method to test circuit (3) Test Mode Select (TMS). Also included is a clock signal
boards by controlling the pins on the ICs (and reading their (TCK) that clocks the other signals.
values) via a separate test interface. The solution, later for-
TDI, TMS, and TCK are all inputs to the device, and TDO is
malized as IEEE Standard 1149.1-2001, is based on the
output from the device. This interface enables testing multi-
concept of a serial shift register routed across all of the pins
ple ICs on a circuit board, in a daisy-chain fashion, as
of the IC – hence the name “boundary scan.” The circuitry at
shown in Figure 41-3.
each pin is supplemented with a multipurpose element
called a boundary scan cell. In PSoC 3 and PSoC 5 devices,
Figure 41-3. JTAG Interface to Multiple ICs on a Circuit Board
TMS
TCK
TDO
Boundary
Scan Cells
IO Pads
Core
Logic
BYPASS Register
ID Register
Other Register
TCK
Test Access Port
TMS
Controller
TRST
TDO
TMS = 1
test logic reset
TMS = 0
TMS = 0
run test idle
TMS = 1
TMS = 1 TMS = 1
select dr scan select ir scan
TMS = 0 TMS = 0
TMS = 1 TMS = 1
capture dr capture ir
TMS = 0 TMS = 0 TMS = 0 TMS = 0
shift dr shift ir
TMS = 1 TMS = 1
TMS = 1
exit 1 dr exit 1 ir
TMS = 0 TMS = 0 TMS = 0 TMS = 0
pause dr pause ir
TMS = 1 TMS = 1
TMS = 0 TMS = 0
exit 2 dr exit 2 ir
TMS = 1 TMS = 1
update dr update ir
TMS = 1 TMS = 0 TMS = 1 TMS = 0
The registers in the TAP are: The standard set of instructions (values that can be shifted
■ Instruction – Typically 2 to 4 bits wide, holds the current into the instruction register), as specified in IEEE 1149, are:
instruction that defines which data register is placed in ■ EXTEST – Causes TDI and TDO to be connected to the
the TDI-to-TDO shift path. boundary scan path (BSR).
■ Bypass – 1 bit wide, directly connects TDI with TDO, The device is changed from its normal operating mode
causing the device to be bypassed for JTAG purposes. to a test mode. Then, the device's pin states can be
sampled using the capture dr JTAG state, and new val-
■ ID – 32 bits wide, used to read the JTAG manufacturer/
ues can be applied to the pins of the device using the
part number ID of the device.
update dr state.
■ Boundary Scan Path (BSR) – Width equals the number ■ SAMPLE – Causes TDI and TDO to be connected to the
of I/O pins that have boundary scan cells, used to set or BSR, but the device is left in its normal operating mode
read the states of those I/O pins.
During this instruction, the BSR can be read by the cap-
Other registers may be included in accordance with device ture dr JTAG state, to take a sample of the functional
manufacturer specifications. data entering and leaving the device.
■ PRELOAD – Causes TDI and TDO to be connected to 41.3.2 Serial Wire Debug Interface
the BSR, but device is left in its normal operating mode.
The instruction is used to preload test data into the BSR The SWD interface was developed by ARM in response to
prior to loading an EXTEST instruction. the need for a debug interface that uses fewer pins than
JTAG. Boundary scan is not available from the SWD inter-
Optional, but commonly available, instructions are: face. Only two signals are used – a bidirectional data signal
■ IDCODE – Causes TDI and TDO to be connected to an (SWDIO) and a clock for the data signal (SWDCK).
IDCODE register.
Each data transfer consists of two or three phases:
■ INTEST – Causes TDI and TDO to be connected to the
■ Packet Request – External host debugger issues a
BSR. While the EXTEST instruction allows access to the
request to the device.
device pins, INTEST enables similar access to the core-
■ Acknowledge Response – Device sends an acknowl-
logic signals of a device.
edge response to the host.
For more information, see the IEEE Standard, available at
■ Data – Present only when a packet request is followed
http://www.ieee.org.
by a valid (OK) acknowledge response – The data trans-
fer is either:
❐ Device to host, following a read request – RDATA
❐ Host to device, following a write request – WDATA
Figure 41-6 shows a successful SWD write, and Figure 41-7
shows a successful SWD read.
Figure 41-6. Successful SWD Write
Clock
ACK[0:2]
RnW 0
APnDP
Parity
Parity
A[2:3]
Park
Start
Stop
Trn
Trn
1 0 0 WDATA[0:31]
Clock
ACK[0:2]
RnW 1
APnDP
Parity
Parity
A[2:3]
Trn
Park
Start
Stop
Trn
1 0 0 RDATA[0:31]
In Figure 41-6 and Figure 41-7, the following sequence 9. The address, ACK and read and write data are always
occurs: transmitted LS bit first.
1. The start bit initiates a transfer; it is always logic ‘1’. The SWD interface can be reset by clocking 50 or more
2. The APnDP bit determines whether the transfer is an cycles with SWDIO high. To go back to the idle state
Access Port access, ‘1’, or a Debug Port access, ‘0’. SWDIO must be clocked low once.
3. The next bit is RnW, which is ‘1’ for a read from the For more information, see the ARM Debug Interface Archi-
device or ‘0’ for a write to the device.
tecture Specification, available at http://www.arm.com.
4. The ADDR bits are register select bits for the Access
Port or Debug Port.
5. The Parity bit has the parity of APnDP, RnW, and ADDR. 41.4 How It Works on PSoC 3 and
If the number of logical 1s in these bits is odd then Parity PSoC 5 Devices
must be ‘1’, otherwise ‘0’.
a. If the parity bit is not correct, the header is ignored; The PSoC 3 and PSoC 5 JTAG and SWD interfaces comply
there is no ACK response. with standard specifications and offer extensions unique to
b. When the host detects that the header was ignored, PSoC 3 and PSoC 5 architectures.
it must wait for a complete read transfer time before
attempting another transfer. 41.4.1 Clocking
6. The Stop bit is always logic 0.
The clock signal (TCK) for JTAG mode and the data signal
7. The Park bit is not driven by the host, the SWD interface clock (SWDCK) for SWD interface share the same I/O pin
on the device pulls the line high, and the device reads (P1[1]). (An alternate SWDCK can be input on the USB D-
this bit as a logic ‘1.’
pin, P15[7].) Clocking limits apply to both clocks in either
8. The ACK bits are the device-to-host response. Possible mode. The frequency of the clock must be between 1 MHz
values are shown in Table 41-1. and CPU_CLK/3 or 25 MHz, whichever is less.
Table 41-1. SWD Possible ACK Bit Values
41.4.2 PSoC 3 and PSoC 5 JTAG
ACK Code
[2:0]
Meaning Instructions
001 OK – header acknowledged, data transfer follows
The PSoC 3 and PSoC 5 JTAG interface complies with the
WAIT – previous transfer still being processed, host IEEE 1149.1-2001 specification, and provides additional
010
should retry
instructions. The instruction register is 4 bits wide. Instruc-
FAULT – a fault flag is set in the Debug Port control/sta-
100 tions are listed in Table 41-2.
tus register
■ Bits 34 to 3 – 32 bits of data – If the Port register is less than 32 bits wide, only the N LS bits are transferred, where N is
the width of the Port register.
■ Bits 2 to 1 – 2-bit address for Debug or Access Port register select – In PSoC 5 devices, it is transferred to bits [3:2] of the
register select; bits [1:0] are 0.
■ Bit 0 – RnW – 1 = read (from device to debug host); 0 = write (to device from debug host)
In the JTAG capture dr state, or when reading the register from the SWD interface, the structure is as shown in the following
figure.
Figure 41-9. Reading the Register
34 3 2 1 0
ReadResult[34:3] ACK[2:0]
■ Bits 34 to 3 – 32 bits of data – If the Port register is less 41.4.4 JTAG/SWD Addresses (PSoC 3)
than 32 bits wide, only the N LS bits are transferred,
where N is the width of the port register. In the PSoC 3 architecture, the 2-bit address, transferred by
either JTAG or SWD as described above, is used to access
■ Bits 2 to 0 – ACK response code – Depending on the
Debug Port, Access Port, and ID Code registers as shown in
interface, the ACK response is as indicated in
Table 41-4.
Table 41-3.
Table 41-4. JTAG/SWD Addresses (PSoC 3)
Table 41-3. ACK Response for JTAG/SWD Transfers
DPACC APACC
ACK[2:0] JTAG SWD Address
(APnDP = 0) (APnDP = 1)
OK 010 001
00 IDCODE (SWD only)a –
WAIT 001 010
01 DBGPRT_CFG TRNS_ADDR
10 – –
11 – DATA_RW
a. The SWD protocol is designed around direct access to the DP/AP Ac-
cess register as described above. In addition, IDCODE can be read us-
ing the SWD interface with a packet request containing ADDR = 00,
APnDP = 0, and RnW = 1. This feature is not available in JTAG be-
cause JTAG has an IDCODE instruction.
Similar boundary scan paths exist on the 68-pin QFN and 48-pin SSOP parts.
PSoC® 3 debug modules consist of the Debug on-Chip (DOC) and the Single Wire Viewer (SWV). The DOC interfaces
between the CPU and the Test Controller (TC). It is used to debug and trace code execution and to troubleshoot device con-
figuration. The DoC exists only on the 8051-based PSoC 3, CY8C38 family. The ARM Cortex-M3-based PSoC® 5 CY8C55
family uses ARM's CoreSight components for debug and trace. For details see the Cortex™-M3 Microcontroller chapter on
page 67.
The SWV module allows target resident code to communicate diagnostic information to the outside world through a single
pin. Usage examples include data monitoring, viewing OS task switches, printf debugging, and call graph profiling.
42.1 Features
The DOC is capable of taking over the 8051 CPU and using its PHUB interface to access any address accessible by the
CPU. It provides the following features:
■ TC interface for access via either JTAG or SWD
■ Access of CPU internal memory and SFRs, and the Program Counter (PC) (see the 8051 Core chapter on page 37)
■ CPU halt
■ CPU single step through instructions
■ 8 program address breakpoints
■ 1 memory access breakpoint
■ Watchdog trigger breakpoint
■ Breakpoint chaining
■ Trace CPU instruction execution:
❐ Trace CPU program counter (PC), accumulator (ACC), and one byte from CPU internal memory or SFR
❐ 2048 instruction trace buffer if tracing PC only
❐ 1024 instruction trace buffer if tracing PC, ACC, and a memory/SFR byte
❐ Continuous, triggered, or windowed mode
❐ On trace buffer full, either CPU halt or overwrite oldest trace
❐ When not tracing, trace buffer is available as normal SRAM
The SWV has the following features:
■ 32 stimulus port registers
■ Simple, efficient packing and serializing protocol
■ Two pin output modes, UART or Manchester encoding
TDI
TD O /S W V
D ebug
T est
T M S /S W D IO on- 8051
C ontroller
C hip
T C K /S W D C K
nT R S T
SW V
The DOC module interfaces between the CPU and the TC, as shown in Figure 42-2. The memory interface is used for system
reads and writes through the CPU.
Figure 42-2. DOC, CPU, and TC Block Diagram
Internal
Test
Memory RAM
Controller
Interface
Interface
SFRs
Test
Controller
Address
Monitor CPU
Configuration
Trace Breakpoints
Registers
CPU Halt
CPU External
Memory/Registers
Trace
SRAM
If the Watchdog is triggered during debug mode, Watchdog DOC_BKPT_CFG [8], CBKPT_7 DOC_PA_BKPT7
Reset (WRES) can be used as a breakpoint to halt the CPU DOC_BKPT_CFG [9], CBKPT_8 DOC_MEM_BKPT
instead of resetting the system. Bit 10, WDRBKPT, of the
The chain include bits cannot be set unless BC_ENA is set
to 1.
The breakpoints are chained in numeric order; a lower num- To enable tracing, set the trace control bits, TRC_CNTRL, in
bered breakpoint must occur before a higher numbered DOC_TRC_CFG[1:0]. SeeTable 42-10.
breakpoint. For example, PA_BKPT5 cannot be set as the
trigger for PA_BKPT3. When the last breakpoint in the chain Table 42-10. DOC_TRC_CFG[1:0], TRC_CNTRL
is triggered, the CPU is halted. Setting Description
Trace disabled – trace buffer is available for use as
When breakpoint chaining is enabled, breakpoints not in the 00 (default)
SRAM
chain can still be enabled; the CPU can be halted either on
01 Trace in Continuous mode
an individual breakpoint or on a chain of breakpoints.
10 Trace in Trigger mode
The register DOC_BKPTCS is used to determine the break- 11 Trace in Window mode
points in the chain that have or have not yet triggered. There
is one bit for each breakpoint. See Table 42-9. The following applies:
■ In Continuous mode, trace runs constantly until the CPU
Table 42-9. DOC_BKPTCS
is halted.
Remaining Breakpoint
Corresponding Breakpoint ■ In Trigger mode, trace starts running when the CPU PC
in Chain (RBIC) Bit
DOC_BKPTCS [0] DOC_PA_BKPT0 equals the compare value in breakpoint register #6,
DOC_BKPTCS [1] DOC_PA_BKPT1
DOC_PA_BKPT6. The breakpoint enable bit in this reg-
ister need not be set. Trace then runs constantly until the
DOC_BKPTCS [2] DOC_PA_BKPT2
CPU is halted.
DOC_BKPTCS [3] DOC_PA_BKPT3
■ In Window mode, trace starts running when the CPU PC
DOC_BKPTCS [4] DOC_PA_BKPT4
equals the compare value in breakpoint register #6,
DOC_BKPTCS [5] DOC_PA_BKPT5
DOC_PA_BKPT6. Trace then runs constantly until the
DOC_BKPTCS [6] DOC_PA_BKPT6
PC equals the compare value in breakpoint register #7,
DOC_BKPTCS [7] DOC_PA_BKPT7
DOC_PA_BKPT7 or until the CPU is halted. The break-
DOC_BKPTCS [8] DOC_MEM_BKPT
point enable bits in these registers need not be set.
Trace restarts if the PC equals breakpoint register #6
If a bit is set to 1, that breakpoint is part of the chain and has again. If both breakpoint registers have the same value,
not yet triggered. If all bits are set to 0 and breakpoint chain- no tracing is done.
ing is enabled, then all breakpoints in the chain have trig-
gered, and the CPU is halted. The CPU registers written to the trace buffer are controlled
by bit 2, TRC_FLTR, in DOC_TRC_CFG[2]. See
Before the CPU is unhalted, the breakpoint chain enable bit, Table 43-11.
BC_ENA, must be reset to 0.
Table 42-11. DOC_TRC_CFG[2], TRC_FLTR
42.3.5 CPU Reset Registers Written Maximum Number of
Setting
to Trace Buffer Instructions Traced
The CPU can be held in a reset state by setting the bit RST,
PC, accumulator (ACC), and one
in DOC_CPU_RST[0]. This setting has no effect on overall 0
byte of CPU internal memory/SFR – 1024
(default)
system resets. 32 bits total
1 PC only – 16 bits 2048
The registers are written to the trace buffer after the instruc- Figure 42-3. Trace Buffer Memory
tion is executed; the values shown in Table 42-12 are
saved.
CPU DOC
Table 42-12. Saved Values in the Trace Buffer
Register Value Written to Trace Buffer
PC Address (in flash) of the first byte of the instruction
ACC Value after instruction execution write_data_doc
Internal memory/
Value after instruction execution
SFR byte
Trace Enable
write_data1
read_data1 4 KB
For example, if the instruction is POP 0xE0 (0xE0 is the
SFR address of ACC), and TRC_PMEM = 0x81 (the SFR
address of SP), then, in addition to the address of the
instruction, the trace contains the value popped from the
stack and the new value of the stack pointer.
write_data2
PHUB 4 KB
When tracing in trigger point or windowed mode, the internal read_data2
memory/SFR byte must be initialized before tracing can
begin. This is done as follows:
1. Load TRC_PMEM bits with the byte address.
2. Write a value to the memory/SFR at that address. If the write_data3
write_data_phub
value cannot be changed, read it first, then write the 4 KB
read value back to the address. read_data3
3. Set the TRC_CNTRL bits to enable tracing.
The CPU can be halted when the trace buffer is full. This is
controlled by the bit TRC_FULL, in DOC_TRC_CFG[3]. See At anytime, an external debug system can read the trace
Table 42-13. data via the JTAG/SWD interface, TC, DOC, CPU, and
PHUB.
Table 42-13. DOC_TRC_CFG, TRC_FULL
42.3.6.2 Trace Time Stamp
Setting Description
0 (default) Don’t halt CPU, oldest trace is overwritten Two registers are included in the DOC for time stamping
1 Halt CPU (counting the number of cycles in a trace window), as shown
in Table 42-14. The registers can be used only in trace Win-
When the CPU is unhalted, tracing may restart. Because the dow mode. Both registers are 32 bits wide.
CPU is halted when the buffer is full, tracing always restarts
Table 42-14. DOC Time Stamping Registers
at the beginning of the buffer.
Register Value
In Overwrite mode, the overwrite address is not available;
Number of clock cycles from when the trace is enabled
therefore, when the trace buffer is examined, it is impossible ENTR_TS
and CPU started and the trace window is enabled
to tell which trace is the oldest. Number of clock cycles from when the trace is enabled
EXIT_TS
and CPU started to the exit point of the trace window
42.3.6.1 Reading Traces
The trace buffer memory is located in the CPU external
memory space at address 0x002000; in a part with 8K
SRAM the trace buffer is contiguous to SRAM.
Writes to this memory are done either by the DOC in trace
mode or through the PHUB (by the CPU or DMAC). All
reads from the memory are done through the PHUB. See
Figure 42-3.
42.3.7 DOC Registers To select an output protocol, use the Pin Protocol bits, in
register SWV_SWO_SPP[1:0] (register SPPR in the ARM
The DOC registers are accessible only through the TC inter- document). See Table 42-16.
face; they are not accessible through the PHUB.
Table 42-15 shows these registers. Table 42-16. SWV_SWO_SPP[1:0], Pin Protocol Bits
Setting Description
Table 42-15. DOC Registers
00 Reserved
Size
Register Description 01 (default) Manchester
(Bits)
DOC_DBG_CTRL 8 Debug control 10 UART
ST DATA (1 to 8 Bytes) SP
Figure 42-5 shows how a sequence of bytes is transmitted using Manchester bit encoding.
Figure 42-5. Manchester Encoding Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
TRACECLKIN
TRACESWO
0 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 0 0
Start 0 1 1 0 0 1 0 1 Stop
Start D0 D1 D2 D3 D4 D5 D6 D7 Stop
The PSoC® platform provides extensive support for programming, testing, debugging, and tracing both hardware and firm-
ware. PSoC 5 supports four interfaces: JTAG, SWD, SWV, and TRACEPORT. Cortex-M3 debug and trace functionality
enables full device debugging in the final system using the standard production device.
Cortex-M3 debugging features are classified into two types: invasive debugging and noninvasive debugging. Invasive debug-
ging includes program halting and stepping, breakpoints, data watchpoints, register value access, and ROM-based debug-
ging. Noninvasive debugging includes memory access, instruction trace, data trace, software trace, and profiling.
43.1 Features
■ Debug access to all memory and registers in the system, including Cortex-M3 register bank when the core is running,
halted, or held in reset.
■ JTAG or SWD access.
■ Flash Patch and Breakpoint (FPB) block for implementing breakpoints and code patches.
■ Data Watchpoint and Trace (DWT) block for implementing watchpoints, trigger resources, and system profiling.
■ Embedded Trace Macrocell (ETM) for instruction trace.
■ Instrumentation Trace Macrocell (ITM) for support of printf style debugging.
■ Support for six breakpoints and four watchpoints.
■ Trace Port Interface Unit (TPIU) for bridging to a Trace Port Analyzer (TPA).
Debug control and data access occurs through the to bus, memory, and peripherals located in the system bus
Advanced High-performance Bus-Access Port (AHB-AP) space.
interface. This interface is driven by either the Serial Wire
Debug Port (SW-DP) or Serial Wire JTAG Debug Port
(SWJ-DP) components.
43.2 How It Works
Through internal PPB, the debugger can access: The PSoC 5 JTAG and SWD interfaces comply with stan-
dard specifications and offer extensions unique to PSoC 5
■ Nested Vectored Interrupt Controller (NVIC). Debug
architecture.
access to the processor core is made through the NVIC.
■ DWT
43.2.1 Test Controller (TC)
■ FPB
The Test Controller is used for the following purposes:
■ ITM
■ Access to I/O pins for boundary scan testing.
Through external PPB, the debugger can access:
■ Access to the device memory and registers (via the
■ ETM PHUB) through PSoC 5 Cortex-M3 Debug Access Port
■ Trace Port Interface Unit (TPIU) (DAP) for functional testing, device programming, and
program debugging.
Through the DCode bus, the debugger can access memory
located in the code space. The system bus provides access The Test Controller's Debug on-Chip (DoC) differs between
PSoC 5 and PSoC 3 architectures. This is because the IP
43.2.2.1 Debug Port and Access Port 43.3.1 Enabling the Debug
Registers The core debug can be enabled by setting the
The registers are part of the ARM Cortex-M3 Debug Access C_DEBUGEN bit of the Debug Halting Control and Status
Port (DAP). In the PSoC 5 Cortex-M3, the DAP consists of Register.
the SWD/JTAG Debug Port (SWJ-DP) and the AHB Access
Port (AHB-AP). The registers are listed in Table 41-6 on 43.3.2 Halting
page 451.
The debugger can halt the core by setting the C_DEBUGEN
For further information on these ports and their registers, and C_HALT bits of the Debug Halting Control and Status
see the ARM Debug Interface Architecture Specification (for Register. The core acknowledges when halted by setting the
the SWJ-DP), and the ARM Cortex-M3 Technical Reference S_HALT bit of the Debug Halting Control and Status Regis-
Manual (for the AHB-AP), both available at ter.
http://www.arm.com.
43.3.3 Stepping
43.2.2.2 Test Controller Interface Pins
The core can be single stepped by halting the core, setting
Two Nonvolatile (NV) latch bits determine the state of the the C_STEP bit to ‘1’, and then clearing the C_HALT bit to
JTAG/SWD interface pins at reset. The settings of the bits ‘0’. The core acknowledges completion of the step and re-
are shown in Table 41-8 on page 452. halts by setting the S_HALT bit of the Debug Halting Control
The Single Wire Viewer (SWV) interface consists of a single and Status Register.
output signal (TRACESWO) that shares a pin with the JTAG The core can exit halting debug by clearing the
TDO signal. When the pins are configured for SWD mode, C_DEBUGEN bit in the Debug Halting Control and Status
then SWV is also routed to the TDO/TRACESWO pin. Register.
43.3.4 Accessing PSoC Memory and ■ Configuration Register (CFG) – The CFG Register
Registers provides information about the configuration of the
MEM-AP implementation. It indicates whether memory
The Debug Core Register Data Register (DCRDR) and accesses by the MEM-AP are big-endian or little-endian.
Debug Core Register Selection Register (DCRSR) are used
■ Debug Base Address Register (BASE) – The BASE
for accessing the PSoC memory and registers. The register
Register provides an index into the connected memory-
and memory access are 32 bits wide.
mapped resource. This index value points to one of the
To use the registers to read the contents of a register, the following, the start of a set of debug registers or a ROM
following steps should be performed: table that describes the connected debug components.
1. Set the C_DEBUGEN and C_HALT bits of the Debug For more details on the Memory Access Port and registers,
Halting Control and Status Register. This enables the refer to the ARM Debug Interface Architecture Specification,
debug and halts the core. available at http://www.arm.com.
2. Wait for the S_HALT bit of the Debug Halting and Status
Register to be set. This indicates that the core is halted.
3. Write to the DCRSR with bit 16 set to ‘0’, indicating it is a 43.4 System Debug
read operation.
The processor contains several system debug components
4. Poll until the S_REGRDY bit in DHCSR is ‘1’. that facilitate low cost debug, trace and profiling, break-
5. Write the register number to be read into the Debug points, watchpoints and code patching.
Core Register Selector Register.
The system debug components are:
6. Read the value from the Debug Core Register Data Reg-
ister. ❐ Flash Patch and Breakpoint (FPB) unit to implement
breakpoints and code patches.
To write to a register, the following steps should be per-
❐ Data Watchpoint and Trace (DWT) unit to implement
formed:
watchpoints, trigger resources, and system profiling.
1. Make sure the processor is halted by following steps 1 ❐ Instrumentation Trace Macrocell (ITM) for applica-
and 2 mentioned above. tion-driven trace source that supports printf style
2. Write data value to the DCRDR. debugging.
3. Write to the DCRSR with bit 16 set to ‘1’, indicating it is a ❐ Embedded Trace Macrocell (ETM) for instruction
write operation. trace. The processor is supported in versions with
4. Write the register number that you want to write to into and without the ETM.
the DCRSR.
5. Poll until the S_REGRDY bit in DHCSR is ‘1’. When the 43.4.1 Flash Patch and Breakpoint (FPB)
bit becomes ‘1’, the write operation is complete. Unit
The Memory Access Port (MEM-AP) provides access to the The main functions of the FPB are:
memory through the DAP. All accesses to a MEM-AP are
■ Implement hardware breakpoint (generates a breakpoint
made through the MEM-AP registers. All registers are 32
event to the processor to invoke debug modes such as
bits wide. The important registers required for memory
halt or debug monitor).
access include:
■ Patch instruction or data from code memory space to
■ Control/Status Word Register (CSW) – The CSW
SRAM.
Register configures and controls accesses through the
MEM-AP to or from a connected memory system. The FPB unit contains:
■ Transfer Address Register (TAR) – The TAR holds the ■ Two comparators for matching against literal loads from
memory address to be accessed. code space, and remapping to a corresponding area in
■ Data Read/Write Register (DRW) – The DRW holds a system space.
32-bit data value. In write mode, the DRW holds the ■ Six instruction comparators for matching against instruc-
value to write for the current transfer to the address tion fetches from code space, and remapping to a corre-
specified in TAR[31:0]. In read mode, the DRW holds the sponding area in system memory space. Alternatively, it
value read in the current transfer from the address spec- is possible to individually configure the comparators to
ified in TAR[31:0]. return a Breakpoint Instruction (BKPT) to the processor
core upon a match, providing hardware breakpoint capa-
bility.
The FPB has a flash patch control register that contains an 43.4.3 Instrumentation Trace Macrocell
enable bit to enable the FPB. In addition, each comparator (ITM)
comes with a separate enable bit in its comparator control
register. Both of the enable bits must be set to ‘1’ for a com- The ITM is a an application driven trace source that sup-
parator to operate. If the comparison for an entry matches, ports printf style debugging to trace Operating System (OS)
the address is remapped to the address set in the remap and application events, then emit diagnostic system infor-
register plus an offset corresponding to the comparator that mation. The ITM emits trace information as packets. There
matched, or is remapped to a BKPT instruction, if that fea- are three sources that can generate packets. If multiple
ture is enabled. sources generate packets at the same time, the ITM arbi-
trates the order in which packets are output. The three
43.4.2 Data Watchpoint and Trace (DWT) sources in decreasing order of priority are:
■ Software Trace. Software can write directly to ITM stimu-
The DWT has a number of debugging functionalities.
lus registers. This emits packets.
It has four comparators, each of which can be configured as ■ Hardware Trace. The DWT generates these packets,
follows: and the ITM emits them.
■ Hardware watchpoint (generates a watchpoint event to ■ Time Stamping. The ITM can generate timestamp pack-
processor to invoke debug modes such as halt or debug ets that are inserted into a trace stream to help the
monitor) debugger find out the timing of events. The ITM contains
■ ETM trigger (causes the ETM to emit a trigger packet in a 21-bit counter to generate the timestamp. The Cortex-
the instruction trace stream) M3 clock or the bit clock rate of the Serial Wire Viewer
■ PC sampler event trigger (SWV) output clocks the counter.
■ Data address sampler trigger One of the main uses of the ITM is to support printf style
■ The first comparator can also be used to compare debugging. The ITM contains 32 stimulus ports, allowing dif-
against the clock cycle counter instead of comparing to a ferent software processes to output to different ports, and
data address messages that can be separated later at the debug host.
Each port can be enabled or disabled by the Trace Enable
The DWT also has counters for counting: Register (SWV_ITM_TER) and can be programmed (in
■ Clock cycles (CYCCNT) groups of eight ports) to allow or disallow user processes to
■ Folded Instructions: A folded instruction is one that does write to it. The output messages can be collected at the
not incur even one cycle to execute trace port interface or the Serial Wire Viewer (SWV) on the
TPIU.
■ Load Store Unit (LSU) Operations: LSU counts include
all LSU costs after the initial cycle for the instruction The ITM is used in output of hardware trace packets. The
■ Sleep cycles packets are generated from the DWT and the ITM acts as a
trace packet merging unit. To use DWT trace, you need to
■ Cycles per instruction (CPI)
enable the DWTEn bit in the ITM Control Register
■ Interrupt overhead (SWV_ITM_CR).
■ PC sampling at regular intervals to count the number of
ITM has a timestamp feature that allows trace capture tools
core cycles
to find out timing information by inserting delta timestamp
■ Applications and debuggers can use the counter to mea- packets into the traces when a new trace packet enters the
sure elapsed execution time FIFO inside the ITM. The timestamp packet is also gener-
■ Interrupt events trace ated when the timestamp counter overflows.
When used as a hardware watchpoint or ETM trigger, the The timestamp packets provide the time difference (delta)
comparator can be programmed to compare either data with previous events. Using the delta timestamp packets,
addresses or program counters. Otherwise, it compares the the trace capture tools can then establish the timing of when
data addresses. each packet is generated and hence reconstruct the timing
of various debug events.
ETM TRACECLKIN
ATB ATB Asynchronous
Slave Interface FIFO
Port TRACECLK
Trace Out
Formatter
(serializer)
TRACEDATA
ITM
[3:0]
ATB ATB Asynchronous
Slave Interface FIFO
Port TRACESWO
APB
ATB
Slave
Interface
Port
The following functions are included in the TPIU: ■ APB Interface – The APB interface is the programming
■ Asynchronous FIFO – The asynchronous FIFO enables interface for the TPIU.
trace data to be driven out at a speed that is not depen- ■ TRACECLKIN – Decoupled clock from ATB to enable
dent on the speed of the core clock. easy control of the trace port speed. Typically this is
■ Formatter – The formatter inserts source ID signals into derived from a controllable clock source on-chip. Data
the data packet stream so that trace data can be re- changes on the rising edge only.
associated with its trace source. ■ TRACEPORT – It includes TRACEDATA[3:0] and
■ Trace Out – The trace out block serializes formatted TRACECLK.
data before it goes off-chip. ■ TRACESWO – Trace output pin for SWV.
■ ATB Interface – TPIU accepts trace data from the trace
sources ETM or ITM.
TRACEPORT is used for rapid transmission of large trace SWD plus SWV 3
streams. There are five TRACEPORT pins: four data pins, SWV plus TRACEPORT 7
TRACEDATA [3:0] and one clock pin, TRACECLK. TRACE-
PORT supports synchronous mode of operation while
TRACESWO does not.
PSoC® 3 and PSoC® 5 devices have three types of nonvolatile memory: Flash, Electronically Erasable Programmable Read
Only Memory (EEPROM), and Nonvolatile Latch (NVL). These can all be programmed by either the CPU running a boot
loader program or by an external system via the JTAG/SWD interface.
44.1 Features
The nonvolatile memory programming system has the following features:
■ Simple command/status register interface
■ Flash can be programmed at the 288-byte row level
■ Each row of Flash has 256 bytes of data plus an additional 32 bytes for ECC/configuration
■ EEPROM can be programmed at the 16-byte row level
■ All configuration NVL bytes can be programmed simultaneously
■ A single write once NVL byte can be programmed
Programming
PHUB
Interface
EEPROM NVL
Commands and data are sent as a series of bytes to either ■ Key byte #2 – 0xD3 plus the command code (ignore
SPC_CPU_DATA or SPC_DMA_DATA, depending on the overflow)
source of the command. Response data is read via the
■ Command code byte
same register to which the command was sent. The status
register, SPC_SR, indicates whether a new command can ■ Command parameter bytes
be accepted, when data is available for the most recent
■ Command data bytes
command, and a success/failure response for the most
recent command. The command codes are shown in Table 44-2. See 44.3.1.1
Command Code Descriptions on page 475 for details.
Some commands are available only when the device is Some commands use the row latch size for Flash and
being controlled by an external system via the JTAG/SWD EEPROM. Row latch sizes are shown in the following table.
interface and the test controller (see the Test
Controller chapter on page 443). Table 44-4. Row Latch Sizes
Array Type Size (Bytes)
Some commands require an array ID as a parameter. Array
Flash, with ECC Enabled 256
ID codes are shown in Table 44-3.
288
Flash, with ECC Disabled
Table 44-3. Array ID Codes (256 data bytes plus 32 configuration bytes)
EEPROM 16
Array ID
Memory Type
Code
0x00 – 0x3E Single Flash array 44.3.1.1 Command Code Descriptions
0x3F All Flash arrays (used by the Erase All command)
The following are descriptions of the command codes listed
0x40 Single EEPROM array
in Table 44-2 on page 474.
0x80 User NVL array
■ Command 0x00 – Load Byte
0xF8 Write Once NVL array
Command Parameter Bytes – Array ID, Address, Data
A Flash array has, at most, 64 KB plus ECC bytes. PSoC 3 This command loads the given data byte into the volatile
architecture has one Flash array, the size of which is 16 KB, latch for the selected NVL array (in accordance with the
32 KB, or 64 KB plus ECC bytes; therefore, the only valid array ID) at the given address. Only addresses within the
selected NVL array are valid.
array ID is 0x00. PSoC 5 architecture has one or more
arrays, where each array is 64K plus ECC bytes. For exam- ■ Command 0x01 – Load Multiple Bytes
ple, if a PSoC 5 device has 256 KB Flash, there are four Command Parameter Bytes – Array ID, Start address
arrays, and the only valid array IDs are 0x00 – 0x03. high, Start address low, Number of bytes (N), Data0, …,
DataN
An EEPROM array has, at most, 2 KB. PSoC 3 and PSoC 5
This command loads N + 1 given data bytes into a row
devices have one EEPROM array, the size of which is 512
latch for Flash or EEPROM. N may range from 0 to 31
bytes, 1 KB, or 2 KB. for Flash or 0 to 15 for EEPROM. The given start
PSoC 3 and PSoC 5 devices have one user NVL array and address + N must be less than the array row latch size.
one write once NVL array. See Table 44-4.
■ Command 0x02 – Load Row
For commands operating on Flash or EEPROM, all array
Command Parameter Bytes – Array ID, Data0, …,
IDs within the number of Flash and EEPROM arrays are
Data(row latch size -1)
valid. If a non-existent array is selected, the array ID wraps.
For example, if a device has two Flash arrays (IDs = 0 and This command loads the given data bytes into a row
latch for Flash or EEPROM. The number of data bytes
1) and a command is sent with array ID = 3 then the upper
expected equals the row latch size. See Table 44-4.
bits of the ID are truncated and so array ID 1 is selected.
■ Command 0x03 – Read Byte
Some commands require an address as a parameter. As
Command Parameter Bytes – Array ID, Address
with array IDs, any address is valid for a Flash or EEPROM
This command returns a data byte from the selected
array. Upper address bits are truncated to allow only
NVL array (per the array ID), at the given address. Only
addressing of valid locations. For example, if a device has
addresses within the selected NVL array are valid. Note
512 bytes EEPROM and address 0x202 (514) is passed as that when this command is executed all of the data bytes
a parameter, the operation takes place on address 0x002. are transferred from the nonvolatile cells to the volatile
Array IDs and addresses do not wrap for NVL accesses. latch portion of the NVL.
■ Command 0x04 – Read Multiple Bytes
Command Parameter Bytes – Array ID, Start address
high, Start address mid, Start address low, Number of
bytes (N)
This command returns N + 1 data bytes from Flash or
EEPROM, starting at the given address.
In Flash arrays, two address spaces exist – data and
ECC/configuration. Bit 7 of the Address high parameter
selects which of the two address spaces is addressed. If
the bit is 0 then the data space is selected, otherwise the The row must have been previously erased (commands
ECC/configuration space is selected. For example, if the 0x08 and 0x09).
address is 0x80000B and N is 0x08, the command reads For Flash, data bytes and ECC/configuration bytes are
9 ECC/configuration bytes starting at address both programmed. If ECC is enabled, the ECC syn-
0x00000B. drome bytes are automatically generated and loaded
The address plus N must not cross a row boundary – into the ECC/configuration bytes of the row latch before
256 for the Flash data space, 32 for the Flash ECC/con- programming takes place.
figuration space, and 16 for EEPROM. For devices with multiple Flash arrays, the All Flash
Address wrapping applies; if the address is greater than array ID (0x3F) can be used with this command. This
the Flash or EEPROM size, the upper bits are then option causes each Flash array to have its addressed
ignored. For example, 16 bits of address are needed to row programmed with its row latch contents simultane-
access the data space in a 64 KB Flash array, so the ously with the other arrays, reducing the overall Flash
seven LS bits of the Address high parameter are programming time.
ignored. Address 0x045A8B actually addresses ■ Command 0x08 – Erase Sector
0x005A8B.
Command Parameter Bytes – Array ID, Sector ID
Similarly, 13 address bits are needed to access the 8 KB
ECC/configuration space associated with a 64 KB Flash This command erases a sector of Flash/EEPROM. A
array, and 11 address bits are needed to access a 2 KB sector is a block of 64 contiguous rows that starts at a
EEPROM. For example, for a 64 KB Flash array (which 64-row boundary. For Flash arrays, all associated ECC/
also has 8 KB ECC/configuration bytes), valid address configuration bytes are also erased. The sector ID wraps
ranges are: if it exceeds the number of sectors.
■ Command 0x09 – Erase All
❐ Data space – 0x000000 – 0x00FFFF (64 KB)
❐ ECC/configuration space – 0x800000 – 0x801FFF Command Parameter Bytes – None
(8 KB) This command erases all Flash data and ECC/configura-
■ Command 0x05 – Write Row tion bytes, all Flash protection rows, and all row latches
in all Flash arrays on the device.
Command Parameter Bytes – Array ID, Row ID high,
■ Command 0x0B – Protect
Row ID low, Temperature sign, Temperature magnitude
This command erases the addressed Flash/EEPROM Command Parameter Bytes – Array ID, Row Select
row and then programs it with the data in the row latch. If This command programs a Flash protection row with
the row ID is greater than the array size (in rows), then data in the Flash row latch (see 44.3.3 Flash Protection
the row ID wraps (the upper bits are ignored). Settings on page 477). This command can be executed
For Flash, data bytes and ECC/configuration bytes are only if none of the protection bits are currently set – no
both programmed. If ECC is enabled then the ECC syn- Flash protection. Any bytes of the protection row that are
drome bytes are automatically generated and loaded marked as unused space are programmed with 0x00.
into the ECC/configuration bytes of the row latch before This occurs regardless of what values are loaded into
programming takes place. the row latches prior to sending this command.
The die temperature parameters can be acquired by The Row Select parameter is used for Flash arrays that
sending the Get Temperature command (see the Tem- have a row size less than 256 bytes. Because all Flash
perature Sensor chapter on page 403). arrays have 256-byte rows, this parameter should
always be 0x00.
■ Command 0x06 – Write User NVL
When the Flash protection data is programmed, this
Command Parameter Bytes – Array ID command cannot be sent again until an Erase All com-
This command writes all of the bytes in the volatile latch mand is sent first.
for the selected NVL array (per the array ID) to that NVL For devices with multiple Flash arrays, the All Flash
array. All Flash protection bits must be cleared (no Flash array ID (0x3F) may be used with this command. This
protection) or the command fails. causes each Flash array to have its protection row pro-
■ Command 0x07 – Program Row grammed with its row latch contents, simultaneously with
Command Parameter Bytes – Array ID, Row ID high, the other arrays, reducing the overall Flash program-
Row ID low ming time.
This command programs the addressed Flash/EEPROM ■ Command 0x0C – Get Checksum
row with the data in the row latch. If the row ID is greater Command Parameter Bytes – Array ID, Start row high,
than the array size (in rows), the row ID wraps (the upper Start row low, Number of rows high, Number of rows low
bits are ignored). This command computes a 4-byte checksum for the
given number of Flash rows + 1, starting at the given
row. The checksum is computed by a running simple 44.3.3 Flash Protection Settings
addition of all values in the rows. If ECC is disabled, the
computation includes all data from the user space and Each row of Flash has its own protection settings. For each
the ECC / configuration space. If ECC is enabled, the Flash array, Flash protection bits are stored in a “hidden”
computation includes only data from the user space. row in that array. A hidden row is one that is not readable by
the CPU, and contains no CPU program or data bytes. In
If the array ID is All Flash, the checksum computed includes
the hidden row, two bits per Flash row are packed into a
all Flash data on all Flash arrays on the device. The rest of
byte; therefore, each byte in the hidden row has protection
the command parameters are ignored. The checksum value
settings for four Flash rows. As shown in Figure 44-2, the
is returned MS byte first.
Flash rows are ordered so that the first two bits in the hidden
44.3.1.2 Command Failure Codes row correspond to the protection settings of Flash row 0.
In response to commands, a success/failure code is Protection is cumulative in that modes have successively
returned in the SPC_SR register: These codes are higher protection levels and include the lower protection
described in Table 44-5. modes. The following table shows the protection modes.
Page 0 Bits Page 1 Bits Page 2 Bits Page 3 Bits Page 255 Bits
[1:0] [1:0] [1:0] [1:0] ...... [1:0]
The Glossary section explains the terminology used in this technical reference manual. Glossary terms are characterized in
bold, italic font throughout the text of this manual.
accumulator In a CPU, a register in which intermediate results are stored. Without an accumulator, it would be
necessary to write the result of each calculation (addition, subtraction, shift, and so on.) to main
memory and read them back. Access to main memory is slower than access to the accumulator,
which usually has direct paths to and from the arithmetic and logic unit (ALU).
active high 1. A logic signal having its asserted state as the logic 1 state.
2. A logic signal having the logic 1 state as the higher voltage of the two states.
active low 1. A logic signal having its asserted state as the logic 0 state.
2. A logic signal having its logic 1 state as the lower voltage of the two states: inverted logic.
address The label or number identifying the memory location (RAM, ROM, or register) where a unit of
information is stored.
algorithm A procedure for solving a mathematical problem in a finite number of steps that frequently
involve repetition of an operation.
ambient temperature The temperature of the air in a designated area, particularly the area surrounding the PSoC
device.
analog blocks The basic programmable opamp circuits. These are SC (switched capacitor) and CT (continuous
time) blocks. These blocks can be interconnected to provide ADCs, DACs, multi-pole filters, gain
stages, and much more.
analog output An output that is capable of driving any voltage between the supply rails, instead of just a logic 1
or logic 0.
analog signals A signal represented in a continuous form with respect to continuous times, as contrasted with a
digital signal represented in a discrete (discontinuous) form in a sequence of time.
analog-to-digital (ADC) A device that changes an analog signal to a digital signal of corresponding magnitude. Typically,
an ADC converts a voltage to a digital number. The digital-to-analog (DAC) converter performs
the reverse operation.
API (Application Pro- A series of software routines that comprise an interface between a computer application and
gramming Interface) lower-level services and functions (for example, user modules and libraries). APIs serve as build-
ing blocks for programmers that create software applications.
array An array, also known as a vector or list, is one of the simplest data structures in computer pro-
gramming. Arrays hold a fixed number of equally-sized data elements, generally of the same
data type. Individual elements are accessed by index using a consecutive range of integers, as
opposed to an associative array. Most high level programming languages have arrays as a built-
in data type. Some arrays are multi-dimensional, meaning they are indexed by a fixed number of
integers; for example, by a group of two integers. One- and two-dimensional arrays are the most
common. Also, an array can be a group of capacitors or resistors connected in some common
form.
assembly A symbolic representation of the machine language of a specific processor. Assembly language
is converted to machine code by an assembler. Usually, each line of assembly code produces
one machine instruction, though the use of macros is common. Assembly languages are consid-
ered low level languages; where as C is considered a high level language.
asynchronous A signal whose data is acknowledged or acted upon immediately, irrespective of any clock sig-
nal.
attenuation The decrease in intensity of a signal as a result of absorption of energy and of scattering out of
the path to the detector, but not including the reduction due to geometric spreading. Attenuation
is usually expressed in dB.
bandgap reference A stable voltage reference design that matches the positive temperature coefficient of VT with the
negative temperature coefficient of VBE, to produce a zero temperature coefficient (ideally) refer-
ence.
bandwidth 1. The frequency range of a message or information processing system measured in hertz.
2. The width of the spectral region over which an amplifier (or absorber) has substantial gain (or
loss); it is sometimes represented more specifically as, for example, full width at half maxi-
mum.
bias current The constant low level DC current that is used to produce a stable operation in amplifiers. This
current can sometimes be changed to alter the bandwidth of an amplifier.
binary The name for the base 2 numbering system. The most common numbering system is the base
10 numbering system. The base of a numbering system indicates the number of values that may
exist for a particular positioning within a number for that system. For example, in base 2, binary,
each position may have one of two values (0 or 1). In the base 10, decimal, numbering system,
each position may have one of ten values (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9).
bit A single digit of a binary number. Therefore, a bit may only have a value of ‘0’ or ‘1’. A group of 8
bits is called a byte. Because the PSoC's M8CP is an 8-bit microcontroller, the PSoC devices's
native data chunk size is a byte.
bit rate (BR) The number of bits occurring per unit of time in a bit stream, usually expressed in bits per second
(bps).
Boolean Algebra In mathematics and computer science, Boolean algebras or Boolean lattices, are algebraic struc-
tures which "capture the essence" of the logical operations AND, OR and NOT as well as the set
theoretic operations union, intersection, and complement. Boolean algebra also defines a set of
theorems that describe how Boolean equations can be manipulated. For example, these theo-
rems are used to simplify Boolean equations, which will reduce the number of logic elements
needed to implement the equation.
The operators of Boolean algebra may be represented in various ways. Often they are simply
written as AND, OR, and NOT. In describing circuits, NAND (NOT AND), NOR (NOT OR), XNOR
(exclusive NOT OR), and XOR (exclusive OR) may also be used. Mathematicians often use +
(for example, A+B) for OR and for AND (for example, A*B) (since in some ways those opera-
tions are analogous to addition and multiplication in other algebraic structures) and represent
NOT by a line drawn above the expression being negated (for example, ~A, A_, !A).
break-before-make The elements involved go through a disconnected state entering (‘break”) before the new con-
nected state (“make”).
broadcast net A signal that is routed throughout the microcontroller and is accessible by many blocks or sys-
tems.
buffer 1. A storage area for data that is used to compensate for a speed difference, when transferring
data from one device to another. Usually refers to an area reserved for I/O operations, into
which data is read, or from which data is written.
2. A portion of memory set aside to store data, often before it is sent to an external device or as
it is received from an external device.
3. An amplifier used to lower the output impedance of a system.
bus 1. A named connection of nets. Bundling nets together in a bus makes it easier to route nets
with similar routing patterns.
2. A set of signals performing a common function and carrying similar data. Typically repre-
sented using vector notation; for example, address[7:0].
3. One or more conductors that serve as a common connection for a group of related devices.
capacitance A measure of the ability of two adjacent conductors, separated by an insulator, to hold a charge
when a voltage differential is applied between them. Capacitance is measured in units of Farads.
capture To extract information automatically through the use of software or hardware, as opposed to
hand-entering of data into a computer file.
chaining Connecting two or more 8-bit digital blocks to form 16-, 24-, and even 32-bit functions. Chaining
allows certain signals such as Compare, Carry, Enable, Capture, and Gate to be produced from
one block to another.
checksum The checksum of a set of data is generated by adding the value of each data word to a sum. The
actual checksum can simply be the result sum or a value that must be added to the sum to gen-
erate a pre-determined value.
clock The device that generates a periodic signal with a fixed frequency and duty cycle. A clock is
sometimes used to synchronize different logic blocks.
CMOS The logic gates constructed using MOS transistors connected in a complementary manner.
CMOS is an acronym for complementary metal-oxide semiconductor.
comparator An electronic circuit that produces an output voltage or current whenever two input levels simul-
taneously satisfy predetermined amplitude requirements.
compiler A program that translates a high level language, such as C, into machine language.
configuration In a computer system, an arrangement of functional units according to their nature, number, and
chief characteristics. Configuration pertains to hardware, software, firmware, and documentation.
The configuration will affect system performance.
configuration space In PSoC devices, the register space accessed when the XIO bit, in the CPU_F register, is set to
‘1’.
crowbar A type of over-voltage protection that rapidly places a low resistance shunt (typically an SCR)
from the signal to one of the power supply rails, when the output voltage exceeds a predeter-
mined value.
crystal oscillator An oscillator in which the frequency is controlled by a piezoelectric crystal. Typically a piezoelec-
tric crystal is less sensitive to ambient temperature than other circuit components.
cyclic redundancy A calculation used to detect errors in data communications, typically performed using a linear
check (CRC) feedback shift register. Similar calculations may be used for a variety of other purposes such as
data compression.
data bus A bi-directional set of signals used by a computer to convey information from a memory location
to the central processing unit and vice versa. More generally, a set of signals used to convey
data between digital functions.
data stream A sequence of digitally encoded signals used to represent information in transmission.
data transmission The sending of data from one place to another by means of signals over a channel.
debugger A hardware and software system that allows the user to analyze the operation of the system
under development. A debugger usually allows the developer to step through the firmware one
step at a time, set break points, and analyze memory.
dead band A period of time when neither of two or more signals are in their active state or in transition.
decimal A base-10 numbering system, which uses the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 (called digits)
together with the decimal point and the sign symbols + (plus) and - (minus) to represent num-
bers.
default value Pertaining to the pre-defined initial, original, or specific setting, condition, value, or action a sys-
tem will assume, use, or take in the absence of instructions from the user.
device The device referred to in this manual is the PSoC device, unless otherwise specified.
digital A signal or function, the amplitude of which is characterized by one of two discrete values: ‘0’ or
‘1’.
digital blocks The 8-bit logic blocks that can act as a counter, timer, serial receiver, serial transmitter, CRC gen-
erator, pseudo-random number generator, or SPI.
digital logic A methodology for dealing with expressions containing two-state variables that describe the
behavior of a circuit or system.
digital-to-analog (DAC) A device that changes a digital signal to an analog signal of corresponding magnitude. The ana-
log-to-digital (ADC) converter performs the reverse operation.
direct access The capability to obtain data from a storage device, or to enter data into a storage device, in a
sequence independent of their relative positions by means of addresses that indicate the physi-
cal location of the data.
duty cycle The relationship of a clock period high time to its low time, expressed as a percent.
emulator Duplicates (provides an emulation of) the functions of one system with a different system, so that
the second system appears to behave like the first system.
External Reset An active high signal that is driven into the PSoC device. It causes all operation of the CPU and
(XRES_N) blocks to stop and return to a pre-defined state.
falling edge A transition from a logic 1 to a logic 0. Also known as a negative edge.
feedback The return of a portion of the output, or processed portion of the output, of a (usually active)
device to the input.
filter A device or process by which certain frequency components of a signal are attenuated.
firmware The software that is embedded in a hardware device and executed by the CPU. The software
may be executed by the end user, but it may not be modified.
flag Any of various types of indicators used for identification of a condition or event (for example, a
character that signals the termination of a transmission).
Flash An electrically programmable and erasable, volatile technology that provides users with the pro-
grammability and data storage of EPROMs, plus in-system erasability. Nonvolatile means that
the data is retained when power is off.
Flash bank A group of Flash ROM blocks where Flash block numbers always begin with ‘0’ in an individual
Flash bank. A Flash bank also has its own block level protection information.
Flash block The smallest amount of Flash ROM space that may be programmed at one time and the smallest
amount of Flash space that may be protected. A Flash block holds 64 bytes.
flip-flop A device having two stable states and two input terminals (or types of input signals) each of
which corresponds with one of the two states. The circuit remains in either state until it is made to
change to the other state by application of the corresponding signal.
frequency The number of cycles or events per unit of time, for a periodic function.
gain The ratio of output current, voltage, or power to input current, voltage, or power, respectively.
Gain is usually expressed in dB.
gate 1. A device having one output channel and one or more input channels, such that the output
channel state is completely determined by the input channel states, except during switching
transients.
2. One of many types of combinational logic elements having at least two inputs (for example,
AND, OR, NAND, and NOR (also see Boolean Algebra)).
ground 1. The electrical neutral line having the same potential as the surrounding earth.
2. The negative side of DC power supply.
3. The reference point for an electrical system.
4. The conducting paths between an electric circuit or equipment and the earth, or some con-
ducting body serving in place of the earth.
hardware A comprehensive term for all of the physical parts of a computer or embedded system, as distin-
guished from the data it contains or operates on, and the software that provides instructions for
the hardware to accomplish tasks.
hardware reset A reset that is caused by a circuit, such as a POR, watchdog reset, or external reset. A hardware
reset restores the state of the device as it was when it was first powered up. Therefore, all regis-
ters are set to the POR value as indicated in register tables throughout this document.
hexadecimal A base 16 numeral system (often abbreviated and called hex), usually written using the symbols
0-9 and A-F. It is a useful system in computers because there is an easy mapping from four bits
to a single hex digit. Thus, one can represent every byte as two consecutive hexadecimal digits.
Compare the binary, hex, and decimal representations:
bin = hex = dec
0000b = 0x0 = 0
0001b = 0x1 = 1
0010b = 0x2 = 2
...
1001b = 0x9 = 9
1010b = 0xA = 10
1011b = 0xB = 11
...
1111b = 0xF = 15
So the decimal numeral 79 whose binary representation is 0100 1111b can be written as 4Fh in
hexadecimal (0x4F).
high time The amount of time the signal has a value of ‘1’ in one period, for a periodic digital signal.
I2C A two-wire serial computer bus by Phillips Semiconductors (now NXP Semiconductors). I2C is an
Inter-Integrated Circuit. It is used to connect low-speed peripherals in an embedded system. The
original system was created in the early 1980s as a battery control interface, but it was later used
as a simple internal bus system for building control electronics. I2C uses only two bidirectional
pins, clock and data, both running at +5V and pulled high with resistors. The bus operates at 100
Kbps in standard mode and 400 Kbps in fast mode.
ICE The in-circuit emulator that allows users to test the project in a hardware environment, while
viewing the debugging device activity in a software environment (PSoC Designer™).
idle state A condition that exists whenever user messages are not being transmitted, but the service is
immediately available for use.
impedance 1. The resistance to the flow of current caused by resistive, capacitive, or inductive devices in a
circuit.
2. The total passive opposition offered to the flow of electric current. Note the impedance is
determined by the particular combination of resistance, inductive reactance, and capacitive
reactance in a given circuit.
input/output (I/O) A device that introduces data into or extracts data from a system.
instruction An expression that specifies one operation and identifies its operands, if any, in a programming
language such as C or assembly.
instruction mnemonics A set of acronyms that represent the opcodes for each of the assembly-language instructions, for
example, ADD, SUBB, MOV.
integrated circuit (IC) A device in which components such as resistors, capacitors, diodes, and transistors are formed
on the surface of a single piece of semiconductor.
interface The means by which two systems or devices are connected and interact with each other.
interrupt A suspension of a process, such as the execution of a computer program, caused by an event
external to that process, and performed in such a way that the process can be resumed.
interrupt service rou- A block of code that normal code execution is diverted to when the M8CP receives a hardware
tine (ISR) interrupt. Many interrupt sources may each exist with its own priority and individual ISR code
block. Each ISR code block ends with the RETI instruction, returning the device to the point in
the program where it left normal program execution.
jitter 1. A misplacement of the timing of a transition from its ideal position. A typical form of corruption
that occurs on serial data streams.
2. The abrupt and unwanted variations of one or more signal characteristics, such as the inter-
val between successive pulses, the amplitude of successive cycles, or the frequency or
phase of successive cycles.
keeper A circuit that holds a signal to the last driven value, even when the signal becomes un-driven.
latency The time or delay that it takes for a signal to pass through a given circuit or network.
least significant bit The binary digit, or bit, in a binary number that represents the least significant value (typically the
(LSb) right-hand bit). The bit versus byte distinction is made by using a lower case “b” for bit in LSb.
least significant byte The byte in a multi-byte word that represents the least significant values (typically the right-hand
(LSB) byte). The byte versus bit distinction is made by using an upper case “B” for byte in LSB.
Linear Feedback Shift A shift register whose data input is generated as an XOR of two or more elements in the register
Register (LFSR) chain.
load The electrical demand of a process expressed as power (watts), current (amps), or resistance
(ohms).
logic function A mathematical function that performs a digital operation on digital data and returns a digital
value.
lookup table (LUT) A logic block that implements several logic functions. The logic function is selected by means of
select lines and is applied to the inputs of the block. For example: A 2 input LUT with 4 select
lines can be used to perform any one of 16 logic functions on the two inputs resulting in a single
logic output. The LUT is a combinational device; therefore, the input/output relationship is contin-
uous, that is, not sampled.
low time The amount of time the signal has a value of ‘0’ in one period, for a periodic digital signal.
low voltage detect A circuit that senses Vddd and provides an interrupt to the system when Vddd falls below a
(LVD) selected threshold.
M8CP An 8-bit Harvard Architecture microprocessor. The microprocessor coordinates all activity inside
a PSoC device by interfacing to the Flash, SRAM, and register space.
macro A programming language macro is an abstraction, whereby a certain textual pattern is replaced
according to a defined set of rules. The interpreter or compiler automatically replaces the macro
instance with the macro contents when an instance of the macro is encountered. Therefore, if a
macro is used five times and the macro definition required 10 bytes of code space, 50 bytes of
code space will be needed in total.
mask 1. To obscure, hide, or otherwise prevent information from being derived from a signal. It is usu-
ally the result of interaction with another signal, such as noise, static, jamming, or other forms
of interference.
2. A pattern of bits that can be used to retain or suppress segments of another pattern of bits, in
computing and data processing systems.
master device A device that controls the timing for data exchanges between two devices. Or when devices are
cascaded in width, the master device is the one that controls the timing for data exchanges
between the cascaded devices and an external interface. The controlled device is called the
slave device.
microcontroller An integrated circuit device that is designed primarily for control systems and products. In addi-
tion to a CPU, a microcontroller typically includes memory, timing circuits, and I/O circuitry. The
reason for this is to permit the realization of a controller with a minimal quantity of devices, thus
achieving maximal possible miniaturization. This in turn, will reduce the volume and the cost of
the controller. The microcontroller is normally not used for general-purpose computation as is a
microprocessor.
mnemonic A tool intended to assist the memory. Mnemonics rely on not only repetition to remember facts,
but also on creating associations between easy-to-remember constructs and lists of data. A two
to four character string representing a microprocessor instruction.
mode A distinct method of operation for software or hardware. For example, the Digital PSoC block
may be in either counter mode or timer mode.
modulation A range of techniques for encoding information on a carrier signal, typically a sine-wave signal. A
device that performs modulation is known as a modulator.
most significant bit The binary digit, or bit, in a binary number that represents the most significant value (typically the
(MSb) left-hand bit). The bit versus byte distinction is made by using a lower case “b” for bit in MSb.
most significant byte The byte in a multi-byte word that represents the most significant values (typically the left-hand
(MSB) byte). The byte versus bit distinction is made by using an upper case “B” for byte in MSB.
multiplexer (mux) 1. A logic function that uses a binary value, or address, to select between a number of inputs
and conveys the data from the selected input to the output.
2. A technique which allows different input (or output) signals to use the same lines at different
times, controlled by an external signal. Multiplexing is used to save on wiring and I/O ports.
negative edge A transition from a logic 1 to a logic 0. Also known as a falling edge.
noise 1. A disturbance that affects a signal and that may distort the information carried by the signal.
2. The random variations of one or more characteristics of any entity such as voltage, current,
or data.
oscillator A circuit that may be crystal controlled and is used to generate a clock frequency.
output The electrical signal or signals which are produced by an analog or digital block.
parallel The means of communication in which digital data is sent multiple bits at a time, with each simul-
taneous bit being sent over a separate line.
parameter Characteristics for a given block that have either been characterized or may be defined by the
designer.
parameter block A location in memory where parameters for the SSC instruction are placed prior to execution.
parity A technique for testing transmitting data. Typically, a binary digit is added to the data to make the
sum of all the digits of the binary data either always even (even parity) or always odd (odd parity).
pending interrupts An interrupt that has been triggered but has not been serviced, either because the processor is
busy servicing another interrupt or global interrupts are disabled.
phase The relationship between two signals, usually the same frequency, that determines the delay
between them. This delay between signals is either measured by time or angle (degrees).
Phase-Locked Loop An electronic circuit that controls an oscillator so that it maintains a constant phase angle relative
(PLL) to a reference signal.
pinouts The pin number assignment: the relation between the logical inputs and outputs of the PSoC
device and their physical counterparts in the printed circuit board (PCB) package. Pinouts will
involve pin numbers as a link between schematic and PCB design (both being computer gener-
ated files) and may also involve pin names.
positive edge A transition from a logic 0 to a logic 1. Also known as a rising edge.
posted interrupts An interrupt that has been detected by the hardware but may or may not be enabled by its mask
bit. Posted interrupts that are not masked become pending interrupts.
Power On Reset (POR) A circuit that forces the PSoC device to reset when the voltage is below a pre-set level. This is
one type of hardware reset.
program counter The instruction pointer (also called the program counter) is a register in a computer processor
that indicates where in memory the CPU is executing instructions. Depending on the details of
the particular machine, it holds either the address of the instruction being executed, or the
address of the next instruction to be executed.
protocol A set of rules. Particularly the rules that govern networked communications.
PSoC Creator™ The software for Cypress’s next generation Programmable System-on-Chip technology.
pulse A rapid change in some characteristic of a signal (for example, phase or frequency), from a base-
line value to a higher or lower value, followed by a rapid return to the baseline value.
pulse-width modulator An output in the form of duty cycle which varies as a function of the applied measurand.
(PWM)
RAM An acronym for random access memory. A data-storage device from which data can be read out
and new data can be written in.
reset A means of bringing a system back to a know state. See hardware reset and software reset.
resistance The resistance to the flow of electric current measured in ohms for a conductor.
ripple divider An asynchronous ripple counter constructed of flip-flops. The clock is fed to the first stage of the
counter. An n-bit binary counter consisting of n flip-flops that can count in binary from 0 to 2n - 1.
ROM An acronym for read only memory. A data-storage device from which data can be read out, but
new data cannot be written in.
routine A block of code, called by another block of code, that may have some general or frequent use.
routing Physically connecting objects in a design according to design rules set in the reference library.
runt pulses In digital circuits, narrow pulses that, due to non-zero rise and fall times of the signal, do not
reach a valid high or low level. For example, a runt pulse may occur when switching between
asynchronous clocks or as the result of a race condition in which a signal takes two separate
paths through a circuit. These race conditions may have different delays and are then recom-
bined to form a glitch or when the output of a flip-flop becomes metastable.
sampling The process of converting an analog signal into a series of digital values or reversed.
schematic A diagram, drawing, or sketch that details the elements of a system, such as the elements of an
electrical circuit or the elements of a logic diagram for a computer.
seed value An initial value loaded into a linear feedback shift register or random number generator.
serial 1. Pertaining to a process in which all events occur one after the other.
2. Pertaining to the sequential or consecutive occurrence of two or more related activities in a
single device or channel.
settling time The time it takes for an output signal or value to stabilize after the input has changed from one
value to another.
shift The movement of each bit in a word one position to either the left or right. For example, if the hex
value 0x24 is shifted one place to the left, it becomes 0x48. If the hex value 0x24 is shifted one
place to the right, it becomes 0x12.
shift register A memory storage device that sequentially shifts a word either left or right to output a stream of
serial data.
sign bit The most significant binary digit, or bit, of a signed binary number. If set to a logic 1, this bit rep-
resents a negative quantity.
signal A detectable transmitted energy that can be used to carry information. As applied to electronics,
any transmitted electrical impulse.
skew The difference in arrival time of bits transmitted at the same time, in parallel transmission.
slave device A device that allows another device to control the timing for data exchanges between two
devices. Or when devices are cascaded in width, the slave device is the one that allows another
device to control the timing of data exchanges between the cascaded devices and an external
interface. The controlling device is called the master device.
software A set of computer programs, procedures, and associated documentation concerned with the
operation of a data processing system (for example, compilers, library routines, manuals, and
circuit diagrams). Software is often written first as source code, and then converted to a binary
format that is specific to the device on which the code will be executed.
software reset A partial reset executed by software to bring part of the system back to a known state. A software
reset will restore the M8CP to a know state but not PSoC blocks, systems, peripherals, or regis-
ters. For a software reset, the CPU registers (CPU_A, CPU_F, CPU_PC, CPU_SP, and CPU_X)
are set to 0x00. Therefore, code execution will begin at Flash address 0x0000.
SRAM An acronym for static random access memory. A memory device allowing users to store and
retrieve data at a high rate of speed. The term static is used because, once a value has been
loaded into an SRAM cell, it will remain unchanged until it is explicitly altered or until power is
removed from the device.
SROM An acronym for supervisory read only memory. The SROM holds code that is used to boot the
device, calibrate circuitry, and perform Flash operations. The functions of the SROM may be
accessed in normal user code, operating from Flash.
stack A stack is a data structure that works on the principle of Last In First Out (LIFO). This means that
the last item put on the stack is the first item that can be taken off.
stack pointer A stack may be represented in a computer’s inside blocks of memory cells, with the bottom at a
fixed location and a variable stack pointer to the current top cell.
state machine The actual implementation (in hardware or software) of a function that can be considered to con-
sist of a set of states through which it sequences.
sticky A bit in a register that maintains its value past the time of the event that caused its transition, has
passed.
stop bit A signal following a character or block that prepares the receiving device to receive the next
character or block.
switching The controlling or routing of signals in circuits to execute logical or arithmetic operations, or to
transmit data between specific points in a network.
switch phasing The clock that controls a given switch, PHI1 or PHI2, in respect to the switch capacitor (SC)
blocks. The PSoC SC blocks have two groups of switches. One group of these switches is nor-
mally closed during PHI1 and open during PHI2. The other group is open during PHI1 and closed
during PHI2. These switches can be controlled in the normal operation, or in reverse mode if the
PHI1 and PHI2 clocks are reversed.
synchronous 1. A signal whose data is not acknowledged or acted upon until the next active edge of a clock
signal.
2. A system whose operation is synchronized by a clock signal.
tap The connection between two blocks of a device created by connecting several blocks/compo-
nents in a series, such as a shift register or resistive voltage divider.
threshold The minimum value of a signal that can be detected by the system or sensor under consider-
ation.
Thumb-2 The Thumb-2 instruction set is a highly efficient and powerful instruction set that delivers signifi-
cant benefits in terms of ease of use, code size, and performance. The Thumb-2 instruction set is
a superset of the previous 16-bit Thumb instruction set, with additional 16-bit instructions along-
side 32-bit instructions.
transistors The transistor is a solid-state semiconductor device used for amplification and switching, and
has three terminals: a small current or voltage applied to one terminal controls the current
through the other two. It is the key component in all modern electronics. In digital circuits, transis-
tors are used as very fast electrical switches, and arrangements of transistors can function as
logic gates, RAM-type memory, and other devices. In analog circuits, transistors are essentially
used as amplifiers.
tristate A function whose output can adopt three states: 0, 1, and Z (high impedance). The function does
not drive any value in the Z state and, in many respects, may be considered to be disconnected
from the rest of the circuit, allowing another output to drive the same net.
UART A UART or universal asynchronous receiver-transmitter translates between parallel bits of data
and serial bits.
user The person using the PSoC device and reading this manual.
user modules Pre-build, pre-tested hardware/firmware peripheral functions that take care of managing and
configuring the lower level Analog and Digital PSoC Blocks. User Modules also provide high
level API (Application Programming Interface) for the peripheral function.
user space The bank 0 space of the register map. The registers in this bank are more likely to be modified
during normal program execution and not just during initialization. Registers in bank 1 are most
likely to be modified only during the initialization phase of the program.
Vddd A name for a power net meaning "voltage drain." The most positive power supply signal. Usually
5 or 3.3 volts.
volatile Not guaranteed to stay the same value or level when not in scope.
Vss A name for a power net meaning "voltage source." The most negative power supply signal.
watchdog timer A timer that must be serviced periodically. If it is not serviced, the CPU will reset after a specified
period of time.
Numerics A
24-bit data pointer registers ACC (SFR 0xE0) register . . . . . . . . . . . . . . . . . . . . . . . .40
8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 active interrupt
32.768 kHz crystal oscillator . . . . . . . . . . . . . . . . . . . . 151 8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
50% duty cycle mode . . . . . . . . . . . . . . . . . . . . . . . . . 157 PSoC 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 active mode
24-bit data pointer registers . . . . . . . . . . . . . . . . . . 64 entering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
active interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 exiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
arithmetic instructions . . . . . . . . . . . . . . . . . . . . . . 40 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . .171
arithmetic logic unit . . . . . . . . . . . . . . . . . . . . . . . . 40 PSoC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
bit addressing mode . . . . . . . . . . . . . . . . . . . . . . . . 39 active mode boost converter . . . . . . . . . . . . . . . . . . . . .166
block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 alternative active mode . . . . . . . . . . . . . . . . . . . . . . . . .171
boolean instructions . . . . . . . . . . . . . . . . . . . . . . . . 43 entering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
core enhancements . . . . . . . . . . . . . . . . . . . . . . . . 38 exiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
DPTR extension SFR . . . . . . . . . . . . . . . . . . . 38 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . .171
Dual DPTR . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 analog I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196
vectored interrupt controller interface . . . . . . . 38 analog subsystem
CPU halt mechanisms . . . . . . . . . . . . . . . . . . . . . . 66 PSoC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
CY wrapper logic . . . . . . . . . . . . . . . . . . . . . . . . . . 39 analog subsystem components
data transfer instructions . . . . . . . . . . . . . . . . . . . . 42 PSoC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
direct addressing mode . . . . . . . . . . . . . . . . . . . . . 39 analog system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343
dual data pointer registers . . . . . . . . . . . . . . . . . . . 63 architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343
external data memory space . . . . . . . . . . . . . . . . . 66 application diagram
features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 boost converter . . . . . . . . . . . . . . . . . . . . . . . . . . .166
how it works . . . . . . . . . . . . . . . . . . . . . . . . . . 38, 413 arithmetic instructions
immediate constants mode . . . . . . . . . . . . . . . . . . 39 8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
indirect addressing mode . . . . . . . . . . . . . . . . . . . . 39 arithmetic logic unit
instruction set . . . . . . . . . . . . . . . . . . . . . . . . . . 38, 39 8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
instruction set details . . . . . . . . . . . . . . . . . . . . . . . 44 asynchronous clocks . . . . . . . . . . . . . . . . . . . . . . . . . .160
internal data space . . . . . . . . . . . . . . . . . . . . . . . . . 39
interrupt controller interface . . . . . . . . . . . . . . . . . . 38
interrupt enable register . . . . . . . . . . . . . . . . . . . . . 65 B
interrupt nesting . . . . . . . . . . . . . . . . . . . . . . . . . . 112
B (SFR 0xF0) register . . . . . . . . . . . . . . . . . . . . . . . . . . .40
interrupt vector addresses . . . . . . . . . . . . . . . . . . 113
BASEPRI special register in PSoC 5
IO port access registers . . . . . . . . . . . . . . . . . . . . . 65
PSoC 5
jump instructions . . . . . . . . . . . . . . . . . . . . . . . . . . 43
BASEPRI special register . . . . . . . . . . . . . . . .117
logical instructions . . . . . . . . . . . . . . . . . . . . . . . . . 41
bit addressing mode
memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
program branching instructions . . . . . . . . . . . . . . . 43
block diagram
program memory space . . . . . . . . . . . . . . . . . . . . . 66
8051 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
PSoC 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
cache controller . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
register addressing mode . . . . . . . . . . . . . . . . . . . . 39
clock distribution system . . . . . . . . . . . . . . . . . . . .154
register specific instructions mode . . . . . . . . . . . . . 39
clock divider Implementation . . . . . . . . . . . . . . . . .157
special function registers . . . . . . . . . . . . . . . . . . . . 62
clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . .297
wrapper logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Cortex-M3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
CY8C38 family SRAM accesses . . . . . . . . . . . . . .125
T
tail chaining
W
PSoC 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 watchdog reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
timer watchdog timer
introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 clearing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
timer block disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
enabling and disabling . . . . . . . . . . . . . . . . . . . . . 297 enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
input signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 how it works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 operation in low power mode . . . . . . . . . . . . . . . . .176
selection of clock source . . . . . . . . . . . . . . . . . . . 296 protection settings . . . . . . . . . . . . . . . . . . . . . . . . .176