Ide User Guide 3DC7pQ5A8h
Ide User Guide 3DC7pQ5A8h
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
Copyright © 2002-2009 Cypress Semiconductor Corporation. The information contained herein is
subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for
the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or
imply any license under patent or other rights. Cypress products are not warranted nor intended to
be used for medical, life support, life saving, critical control or safety applications, unless pursuant to
an express written agreement with Cypress. Furthermore, Cypress does not authorize its products
for use as critical components in life-support systems where a malfunction or failure may reasonably
be expected to result in significant injury to the user. The inclusion of Cypress products in life-support
systems application implies that the manufacturer assumes all risk of such use and in doing so
indemnifies Cypress against all charges.
PSoC Designer™, Programmable System-on-Chip™, and PSoC Express™ are trademarks and
PSoC® is a registered trademark of Cypress Semiconductor Corp. All other trademarks or regis-
tered trademarks referenced herein are property of the respective corporations.
Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation
(Cypress) and is protected by and subject to worldwide patent protection (United States and foreign),
United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of,
and compile the Cypress Source Code and derivative works for the sole purpose of creating custom
software and or firmware in support of licensee product to be used only in conjunction with a
Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification,
translation, compilation, or representation of this Source Code except as specified above is prohib-
ited without the express written permission of Cypress.
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 PARTICULAR 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 reasonably be expected to result in significant injury to the user. The
inclusion of Cypress' product in a life-support systems application implies that the manufacturer
assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
1. Introduction 7
1.1 Application Overview ................................................................................................................8
1.1.1 Chip-Level Editor...........................................................................................................8
1.1.2 System-Level Editor ......................................................................................................9
1.1.3 Code Editor ...................................................................................................................9
1.1.4 Build Manager .............................................................................................................10
1.1.5 Board Monitor..............................................................................................................10
1.1.6 Debugger ....................................................................................................................11
1.1.7 Getting Help ................................................................................................................11
1.2 Chapter Overviews .................................................................................................................11
1.3 Support ...................................................................................................................................12
1.3.1 Technical Support Systems.........................................................................................12
1.3.2 Product Upgrades .......................................................................................................12
1.4 Conventions............................................................................................................................12
1.4.1 Acronyms ....................................................................................................................13
1.5 References .............................................................................................................................14
1.6 Revision History......................................................................................................................14
2. Chip-Level Editor 15
2.1 Chip-Level Editor Overview ....................................................................................................16
2.2 Create a Project......................................................................................................................17
2.2.1 Clone a Project............................................................................................................19
2.2.2 Updating Existing Projects ..........................................................................................19
2.3 Placing User Modules.............................................................................................................19
2.3.1 Rotating a Placement..................................................................................................21
2.3.2 Setting User Module Parameters ................................................................................21
2.3.3 Global Resources........................................................................................................22
2.4 Project Backup Folder ............................................................................................................27
2.5 Specifying Interconnects.........................................................................................................27
2.5.1 Connecting User Modules...........................................................................................28
2.5.2 Digital Interconnect Row Input Window ......................................................................34
2.5.3 Digital Interconnect Row Output Window....................................................................35
2.6 Specifying the Pinout ..............................................................................................................37
2.6.1 Port Connections.........................................................................................................37
2.6.2 Port Drive Modes ........................................................................................................42
2.6.3 Port Interrupts .............................................................................................................43
2.7 Tracking Device Space...........................................................................................................44
2.8 Design Rule Checker..............................................................................................................45
2.9 Generating Application Files...................................................................................................46
2.10 Source Files Generated by Generate Project Operation ........................................................47
2.10.1 About the boot.asm File ..............................................................................................47
2.11 Configuration Data Sheets......................................................................................................48
2.12 APIs and ISRs ........................................................................................................................48
3. System-Level Editor 59
3.1 System-Level Editor Overview ............................................................................................... 60
3.2 Create a New Project ............................................................................................................. 61
3.2.1 Add Design Elements ................................................................................................. 61
3.2.2 Use Pop Up Menus..................................................................................................... 62
3.2.3 Use Navigation Tools .................................................................................................. 63
3.2.4 Use the Design Toolbar ..............................................................................................63
3.2.5 Delete Elements.......................................................................................................... 64
3.2.6 Save a Design ............................................................................................................ 64
3.3 Simulating Your Design .......................................................................................................... 64
3.3.1 Widgets ....................................................................................................................... 64
3.3.2 Navigation Tools ......................................................................................................... 64
3.3.3 LOG.csv File ............................................................................................................... 65
3.3.4 Simulation Controls..................................................................................................... 65
3.4 Drivers .................................................................................................................................... 65
3.4.1 Driver Types................................................................................................................ 65
3.5 Valuators ................................................................................................................................ 66
3.5.1 Interface Valuator........................................................................................................66
3.5.2 Transfer Function Valuator.......................................................................................... 66
3.6 Transfer Functions.................................................................................................................. 67
3.6.1 Transfer Function Types ............................................................................................. 67
3.7 Authoring New Design Elements............................................................................................ 69
3.8 Selecting a Configuration ....................................................................................................... 70
3.8.1 Configuration Properties ............................................................................................. 70
3.8.2 BOM Vendor ............................................................................................................... 71
3.8.3 Assign Pins Automatically........................................................................................... 71
3.9 Assigning Pins ........................................................................................................................ 71
3.9.1 Pin Color Legend ........................................................................................................ 72
3.9.2 Lock Pins .................................................................................................................... 72
3.9.3 Unassign All Pins........................................................................................................ 72
3.9.4 Auto Assign................................................................................................................. 72
3.10 Generating Output .................................................................................................................. 72
3.11 Developing Complex Designs ................................................................................................ 73
3.11.1 Preparing Your Design................................................................................................ 73
3.12 Programming PSoC Flash Memory........................................................................................ 78
3.13 Monitoring Your Design .......................................................................................................... 79
3.13.1 Monitoring Your Board With the I2C-USB Bridge ....................................................... 80
3.13.2 Monitoring Your Board with Other Interfaces .............................................................. 82
3.14 Tuning Your Design................................................................................................................ 82
4. Code Editor 87
4.1 File Definitions and Recommendations ................................................................................. 87
4.1.1 File Types and Extensions .......................................................................................... 88
4.1.2 Project File System ..................................................................................................... 89
5. Assembler 95
5.1 Accessing the Assembler .......................................................................................................95
5.2 The M8C Microprocessor (MCU)............................................................................................95
5.2.1 Address Spaces ..........................................................................................................96
5.2.2 Instruction Format .......................................................................................................96
5.2.3 Addressing Modes ......................................................................................................96
5.2.4 Destination of Instruction Results................................................................................97
5.3 Assembly File Syntax .............................................................................................................97
5.4 List File Format .......................................................................................................................97
5.5 Assembler Directives ..............................................................................................................98
5.6 Instruction Set ........................................................................................................................99
5.7 Compile and Assemble Files ..................................................................................................99
5.8 Calling Assembly Functions From C.....................................................................................100
7. Debugger 109
7.1 Debugger Components.........................................................................................................109
7.2 Menu Options .......................................................................................................................111
7.3 Connecting to the ICE...........................................................................................................112
7.4 Downloading to the Pod........................................................................................................113
7.5 Debug Strategies ..................................................................................................................114
7.5.1 Trace .........................................................................................................................115
7.5.2 Break Points..............................................................................................................116
7.5.3 CPU and Register Views...........................................................................................117
7.5.4 Watch Variables ........................................................................................................118
7.5.5 Dynamic Event Points ...............................................................................................119
7.5.6 End Point Data ..........................................................................................................123
7.6 I2C Debugger........................................................................................................................124
7.6.1 Connecting to the ICE ...............................................................................................124
7.6.2 Enable Debug Mode .................................................................................................124
7.6.3 Downloading to the Device .......................................................................................125
PSoC Designer™ is two tools in one. It combines a full featured integrated development environ-
ment (IDE) (the Chip-Level Editor) with a powerful visual programming interface (the System-Level
Editor). The two tools require and support two different design processes:
In the Chip-Level Editor you specify exactly how you want the device configured. This allows you
direct access to all of the features of your PSoC device and complete control over the routing, sys-
tem resource use, and firmware development:
1. Choose a base device to work with.
2. Choose user modules that configure the PSoC device for the functionality you need in your sys-
tem.
3. Configure the user modules for your chosen application and connect them to each other and to
the proper pins.
4. Generate your project. This prepopulates your project with APIs and libraries that you can use to
program your application.
5. Program in C for rapid development, assembly language to get every last drop of performance, or
a combination of both.
In the System-Level Editor you solve design problems the same way you might think about the sys-
tem:
1. Select input and output devices based upon system requirements.
2. Add a communication interface and define the interface to the system (registers).
3. Define when and how an output device changes state based upon any/all other system devices.
4. Based upon the design, automatically select one or more PSoC Mixed-Signal Controllers that
match system requirements.
5. PSoC Designer completely and correctly generates all embedded code, then compiles and links
it into a programming file for a specific PSoC device.
6. You can then open the project in Interconnect view to review and further configure your design.
All views of the project share a common code editor, builder, and common debug, emulation, and
programming tools. The System-Level Editor creates a special environment that allows the visual
interface to function. This special environment is not created if you choose a Chip-level Project. You
can start with a system-level project and switch to the chip-level view, but the converse is not true.
User Module
Catalog
Data Sheet
Global
Resources
Resource
Placement
Workspace Explorer
Properties
Menus
System View
Driver
Catalog
Workspace Explorer
Datasheet
Properties
Subtabs
The menus allow you to perform various tasks, including opening new or existing designs, as well as
saving, closing, building, and programming designs. Most of these commands are available regard-
less of the areas in which you work.
from the View menu that show details of different aspects of PSoC Designer. You can rearrange the
work area to suit your own work style.
1.1.6 Debugger
The debugger has multiple windows that allow you to interact with and observe the code execution
on the target PSoC device. The debugger is tightly integrated with the rest of the IDE, and there is no
separate debugger view. Instead, there are a number of different windows that you can use to moni-
tor the status of various parts of your target board while debugging, including the following:
Break Points
Memory
Watch Variables
Events
Trace
Output
1.3 Support
Free support for PSoC Designer is available online at http://www.cypress.com. Resources include
training seminars, discussion forums, application notes, PSoC consultants, TightLink technical sup-
port email/knowledge base, and application support technicians.
Before using the Cypress support services, know the version of PSoC Designer installed on your
system. To quickly determine the version of PSoC Designer, click Help > About PSoC Designer.
1.4 Conventions
Here are the conventions used throughout this guide.
1.4.1 Acronyms
These are the acronyms used throughout this guide.
1.5 References
This guide is part of a larger documentation suite for the PSoC Designer application. It is meant as a
reference, not as the complete source of information. For the most up-to-date information, go to
http://www.cypress.com. The documentation listed here provides more specific information on a vari-
ety of topics:
PSoC Designer Help Topics (Online Help)
PSoC Designer Base Project Author Guide
PSoC Designer Channel Author Guide
PSoC Designer Driver Author Guide
PSoC Designer Transfer Function Author Guide
PSoC Designer Development Kit Getting Started Guide
PSoC Programmer Guide
Various PSoC Designer application notes and data sheets
The Chip-Level Editor allows you to work directly with the resources available on a PSoC device,
select and configure user modules, such as analog to digital converters (ADCs), timers, amplifiers,
and others, and route inputs, outputs, and other resources to and from them.
Figure 2-1. Chip-Level Editor Desktop
The System-Level Editor creates a special environment that allows it to generate all necessary
program code based on the elements and logic in the System-Level Project. If you start with an
System-Level Project, you can eventually edit in the Chip-Level Editor. The converse is not true.
If you start with a Chip-Level Project, the environment necessary to generate code from System-
Level designs is not initiated and System-Level Editor functions are disabled in that project.
2. Choose a name and location for the project. By default, a project is created inside a workspace
with the same name as the project, the project is stored in the project directory. If you plan to cre-
ate multiple projects in a single workspace (for example, if your project will use multiple PSoC
devices), click Create a directory for workspace and supply a name for the first project. When
you are finished, click Next.
3. In the Select Project Type dialog box, click View Catalog to access a detailed list of available
parts.
4. In the Parts Catalog Dialog Box, highlight your part of choice. Tabs at the left and characteristic
selections along the top narrow the list of devices. You have several options in this dialog box
including layout display, viewing part image, and sorting part selection (by clicking on a chosen
column title). Click Select to save your selection and exit the dialog box.
5. Once you select a part, click C or Assembler, in the Select Project Type dialog box, to designate
the language in which you want the system to generate the “main” file.
6. Click OK. Your workspace directory with folders is created and is listed in the Workspace
Explorer. If the Workspace Explorer is not visible, choose Workspace Explorer from the View
menu.
data sheet when you click on a user module, select View > Datasheet Window. Right-click on
the user module and select Place. Some user modules have wizards or configuration screens
that appear before the user module can be placed. These will differ by user module. The user
module will be placed in the first available PSoC block in the Interconnect view.
The user module block reference names appear above the currently active blocks. For example,
an ADC10 has one digital block used as a counter (CNT) and two analog blocks, one for the ana-
log to digital conversion (ADC) and the other for a voltage ramp (RAMP). The name of the user
module is separate from these user module block function names. This is because a multiblock
user module may have distinct block actions.
2. If you want to use a placement other than the default, click the Next Allowed Placement icon
to advance the user module to the next available location (active/anchor identified as green, non-
active as blue) or use the faster drag-and-drop capability. Click the target placer (identified as
green and blue highlights) and drag-and-drop the user module to a new location. If a user module
has multiple blocks, it may be possible to drag individual blocks onto a free block. Repeat this
procedure until you have identified the exact location for the user module.
The Next Allowed Placement button shows the next possible set of PSoC blocks in which a user
module may be placed, regardless of any currently placed user modules. If you cannot place the
user module in the highlighted location due to a lack of resources, a Resource Allocation mes-
sage flashes in the lower-left corner of PSoC Designer. Placement is not possible if another user
module occupies the PSoC block, or if a placed user module is using another resource which the
highlighted user module requires.
3. When you identify the location, click the Place User Module icon , or right-click and select
Place.
Once you place the module, it appears on the device, color-coded, bearing the designated name
of the chosen PSoC block. In the Interconnect frame, the inactive target placers (blue highlights)
of multi-block user modules are now identified by a group name across the top.
Some user modules do not consume visible resources in the interconnect view when they are
placed. Examples of this include LCD, I2C Master, I2C Slave and software only user modules.
4. At this time, you can print, save, clear or unplace, and name or rename the placed user module.
To print your placement view, right-click anywhere in the Interconnect view and select Print.
To save your work, click File > Save project.
To clear all user module placements (i.e., remove them from their location on the PSoC
blocks), click Interconnect > Clear All Placements. To unplace one particular module, right-
click it (in either the Interconnect view or the Workspace Explorer) and select Unplace or click
the Unplace User Module icon . This does not remove user modules from PSoC Designer
or from your collection. Your unplaced user modules shown in the Workspace Explorer under
Interconnect > Loadable Configurations > User Modules.
To name or rename user modules, select the user module either in the Workspace Explorer or
the Interconnect view, and type a new name in the user module Properties window.
5. Repeat this process (steps 1-4) for all user modules in your design.
For each user module you add, the system updates the data in the Resource Meter with the number
of occupied PSoC blocks, along with estimated RAM and ROM usage for the current set of selected
user modules. The RAM and ROM numbers grow or shrink depending upon wizard settings and
other user module parameter adjustments. If you select a user module that requires more resources
than are currently available, PSoC Designer does not allow the selection. If you do not see the
Device Resource Meter go to the View menu and select Resource Meter.
If user modules are already placed, then there are some cases when user module placement fails
even if it appears that sufficient PSoC blocks remain unallocated. In such cases, the already placed
user modules are using resources that the selected user module requires.
There are several user modules that require topology selection (i.e., filters). Right-click on the mod-
ule in the Aplication Explorer after it is placed and click User Module Selection Options. Make the
topology choice according to your application.
Some user modules have associated wizards to assist in configuration. To access a wizard, select
the user module in the Workspace Explorer and then right click the mouse. If a wizard exists, it
appears in the menu choices.
1. Click each drop-arrow (in parameter value fields) and make your selections.
Some parameters are integer values. Set these values by clicking the up/down arrows, or double-
click the value and type in the value. If you type a value that is out of range, an error message
appears in the lower-left corner.
2. Repeat this process for all placed user modules.
32K_Select
The 32K_Select parameter allows selection of the internal 32 kHz oscillator or an external crystal
oscillator. A complete discussion of the implications of this selection is found in the PSoC Technical
Reference Manual.
A_Buf_Power
A_Buf_Power allows the user to select the power level for the analog output buffers of the PSoC.
These buffers are used to supply internal analog signals to external pins on the PSoC. Power levels
may affect the frequency response and current drive capability of the output buffers. Complete tables
for the AC Analog Output Buffer Specifications and DC Analog Output Buffer Specifications are con-
tained in the applicable device data sheet.
AGNDBypass
A provision is made in some versions of the PSoC device to provide an external AGND bypass
capacitor to reduce the small amounts of switching noise present on the internal AGND. This feature
is switched on and off using the AGNDBypass global parameter. Typical values for the external
bypass capacitor are 0.01 μF and should not generally exceed 10 μF. The recommended value is 1
μF.
Analog Power
This parameter controls the power to the analog section of the PSoC. Power is controlled in three
stages:
1. All Analog Blocks Off
2. Continuous Time Blocks ON/Switched Capacitor Blocks OFF
3. Continuous Time Blocks ON/Switched Capacitor Blocks ON
For each of the two 'ON' cases, select reference drive levels of high, medium, and low to choose the
current drive capability for the internal reference buffers. All selections of this parameter, whether
used as a User Module Parameter or this Global Resource, need to agree. This selection affects the
total power consumption of the PSoC. Each user module using the reference and the opamp block
associated with it adds slightly to the power consumed by the device. Since the internal reference is
used as an integral part of most switched capacitor circuits, the current drive capability has an impact
on the speed at which the switched capacitor block operates. In general, higher settings for this
parameter allow switched capacitor circuits to operate at higher clock rates, at the expense of higher
power consumption. To estimate the current (and power) consumption per opamp block, refer to the
applicable table in the data sheet for the part: DC Operation Amplifier Specifications (ISOA).
Capture Clock
Selects the clock source for the Timer Capture Clock (TCAPCLK).
Capture Clock/N
Selects the Capture Clock divider value. The TCAPCLK will be Capture Clock source divided by N.
Capture Edge
Selects whether the capture timer data register has the First Hold data or the Most Recent edge
data. This option applies to all four capture timers.
CLKOUT Source
Selects one of the clocks, internal SysClk, external, low power 32 KHz, or CPUCLK to be output
directly on port P0[1].
CPU_Clock
The CPU_Clock selection allows the selection of the M8C clock speed from 93.75 kHz to 24 MHz.
The CPU clock is derived directly from the SysClock. Use an external 32 kHz oscillator and the PLL
Ext_Lock to improve clock accuracy. A discussion of the main oscillator is contained in the PSoC
Technical Reference Manual.
Crystal OSC
Selects the external crystal oscillator when enabled. The external crystal oscillator shares pads
CLKIN and CLKOUT with two GPIOs; P0.0 and P0.1, respectively.
EFTB
The external crystal oscillator is passed through the EFTB filter when this option is enabled.
Low V Detect
Selects the level of the supply voltage at which the low voltage detect interrupt is generated.
LVD ThrottleBack
This parameter allows you to configure the PSoC to lower its own CPU clock speed under low volt-
age conditions. Use of this parameter and the bit it controls is discussed in the PSoC Technical Ref-
erence Manual. Not all PSoC devices incorporate this parameter and bit.
Opamp Bias
Performance of the internal opamps are tailored based upon the application under development by
selecting high or low bias conditions for the analog section of the PSoC. Selecting high bias causes
the opamp to consume more current but also increases its bandwidth and switching speed, lowering
its output impedance. To estimate the current (and power) consumption per opamp block, including
the effect from high or low selection of opamp Bias, refer to the applicable table in the data sheet for
the part: DC Operation Amplifier Specifications (ISOA). To estimate the effect on AC opamp parame-
ters, refer to the applicable AC Operational Amplifier Specifications in the device data sheet.
PLL_Mode
The PSoC Technical Reference Manual discusses use of the phase-locked loop mode.
Ref Mux
The Ref Mux source selection is used to control the range and (potential) accuracy of various analog
resources. The reference chosen controls the maximum voltage that is input to a switched capacitor
circuit and output from a switched capacitor circuit. Both the analog ground level and the peak-to-
peak voltage are selected using this parameter. Values specified with the Ref Mux parameter are in
pairs and consist of [AGND level ± full scale]. Keep in mind that selecting Vdd (supply voltage) as a
reference level couples Vdd changes into the AGND input of internal resources. This directly affects
absolute accuracy of measurements. Using the internal bandgap reference results in better accuracy
but may not offer an exact Vdd/2 input reference. Choices of ± full-scale values also offer a number
of options. These full-scale values may be based on the PSoC internal references or on external
input voltages. The ± full scale values present constraints similar to those for AGND in terms of Vdd
variation and absolute range of input/output. Individual design criteria dictate the best selection for
the AGND and ± full-scale values. Further discussion of the analog reference can be found in the
PSoC Technical Reference Manual.
Sleep_Timer
The Sleep_Timer parameter selects the timing of the sleep interrupt, if enabled. When the sleep
interrupt is active, and the processor is in a sleep state, it is awakened at the rate specified with this
parameter. The Watchdog Reset, if enabled, occurs after three rollover events in the sleep timer (if
the Watchdog counter is not reset). A complete discussion of the relation of these two elements is
found in the PSoC Technical Reference Manual.
Supply Voltage
Selects the nominal operating voltage to be either 3.3V or 5V.
SwitchModePump
An integrated switch mode pump circuit is available for operation of the device from very low voltage
sources. The pump requires a few external components and can be configured to automatically turn
on as supply voltage drops. Further discussion of the switch mode pump is found in the PSoC Tech-
nical Reference Manual.
Timer Clock
Selects the clock source for the 12-bit down counting internal timer (TIMERCLK).
Timer Clock/N
Selects the Timer Clock divider value. The TIMERCLK will be Timer Clock source divided by N.
USB Clock
Selects the source for the USB SIE.
USB Clock/2
This option divides the USB clock source by 2 when the source is an external crystal oscillator.
When the USB clock is the internal 24 MHz Oscillator, then the divide by 2 is always enabled.
V Keep-alive
Allows voltage regulator to source upto 20 µA of current when the voltage regulator is disabled.
V Reg
A 3.3 V regulator output is placed on the pin P1[2] when Enabled, and when Vcc is above 4.35 V. A
1 µF min, 2 µF max capacitor is required on VREG output.
V Reset
Selects the Power on Reset (POR) voltage level.
Watchdog Enable
This parameter activates the Watchdog Timer. The Watchdog Timer is based on a counter that
counts three sleep timer events. To prevent system reset, you must clear this counter before three
sleep timer state events occur, or the PSoC is internally reset. The duration of each sleep timer
event is selected using the Sleep_Timer parameter in the Global Resources frame of PSoC
Designer. A complete discussion of the relation of the sleep and watchdog timers is in the PSoC
Technical Reference Manual.
Global In
Global In connections apply to a PSoC device in this manner:
CY8C25xxx/26xxx as Global In: Input Port Connections.
All other PSoC devices as Global In Odd and Global In Even: Input Port Connections and Global
Connections.
To set Global In connections:
1. Click on the target Globalxxx vertical line.
4. Click OK.
You see a line connecting the digital input port to the global vertical line.
Global Out
Global Out connections apply to a PSoC device in this manner:
CY8C25xxx/26xxx as Global Out: Output Port Connections.
All other PSoC devices as Global Out Odd and Global Out Even: Output Port Connections and
Global Connections.
To set Global Out connections:
2. Select an option from the menu. You see your chosen input option displayed next to the clock
input triangle.
Your choice option also appears in the Control Clock field under User Module Parameters (where
you can click the drop-arrow to change your selection).
Row Broadcast
Row Broadcast connections do not apply to CY8C25xxx/26xxx parts. To set Row Broadcast connec-
tions:
1. Click the Row_0_Broadcast (BC0) or Row_1_Broadcast (BC1) horizontal line.
Figure 2-16. Setting the Row_0_Broadcast Line
2. Click on the Row_x_Input_x Mux in the Digital Interconnect Row Input floating window and select
a Global Input from the menu. (You immediately see a connection from the mux to the Global
Input vertical line.) In this floating window you can also click the white box to toggle the Synchro-
nization value for Row_x_Input_x. Options include SysClk_Sync and Async
2. Click on the Row_x_LogicTable_Input_0 Mux in the Digital Interconnect Row Output floating win-
dow and select an input or output option from the menu.
3. Click Close when finished.
You see connections on the device interface reflecting your row input or output selection.
Once you open the Digital Interconnect Row Global Output window, you can select Row Logic
Table Input, Row Logic Table Select, and Connections to Global Output without closing the win-
dow.
To restore the default pinout, click the Restore Default Pinout button .
Be careful when connecting to pins. The pin settings can be modified either by setting elements to
connect to pins or by setting the pin directly.
Setting the pin directly connects the pin to the appropriate element and disconnects it from any other
element. To have multiple connections to the same pin, make connections from the element to the
pin. For example, suppose a connection to a pin, an analog input mux and an analog output buffer,
simultaneously, is desired. P0[2] can connect to the analog input mux for column 1 and to the analog
output buffer for column 3. The connections must be made from the analog input mux and the ana-
log output buffer. Setting the pin to Default disconnects the pin from both digital buses, but does not
affect analog connections.
Analog Input
To set Analog Input connections.
1. Click on the target Port_0_x.
2. From the Select menu select AnalogInput.
Figure 2-22. Select AnalogInput for a Port
3. Click OK.
On the device you see the new designation color coded according to the legend along side the
device. The port name and selection also appears in the port-related fields underneath User
Module Parameters (where you can click the drop-arrow to change your selection).
Default Input
To set Default Input connections:
1. Click on the target Port_x_x.
2. From the Select menu select Default.
Figure 2-23. Select Default Input for a Port
3. Click OK.
On the device pinout frame you see the designation color coded according to the legend along
side the device. The port name, the Select column value of StdCPU, and the drive mode of High
Z Analog also appears in the port-related fields underneath User Module Parameters (where you
can click the drop-arrows to change your selections).
Global_IN_x
Global_IN_x connections apply to a PSoC device in this manner:
CY8C25xxx/26xxx as Global_IN_x.
All other PSoC devices as GlobalIn[Odd/Even]_x.
To set Global_IN_x connections:
1. Click on the target Port_x_x.
2. From the Select menu select the device-specific Global IN option.
Figure 2-24. Select Global IN for a Port
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name, the Select column value of your chosen option, and the drive mode of High Z
appear in the port-related fields underneath User Module Parameters (where you can click the
drop-arrows to change your selections).
You also see a line between the digital input port and the Global IN vertical line.
Global_OUT_x
Global_OUT_x connections apply to a PSoC device in this manner:
CY8C25xxx/26xxx as Global_OUT_x.
All other PSoC devices as GlobalOUT[Odd/Even]_x.
To set Global_OUT_x connections:
1. Click on the target Port_x_x.
2. From the Select menu select the device-specific Global OUT option.
Figure 2-25. Select Global OUT for a Port
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name, the Select column value of your chosen option, and the drive mode of Strong
appear in the port-related fields underneath User Module Parameters (where you can click the
drop-arrows to change your selections).
You also see a line between the Global OUT vertical line and the digital output port.
StdCPU
To set StdCPU connections:
1. Click on the target Port_x_x or select the port from the menu.
2. From the Select menu select StdCPU.
Figure 2-26. Select StdCPU for a Port
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name and StdCPU also appear in the port-related fields underneath User Module
Parameters (where you can click the drop-arrow to change your selection).
XtalOut
To set the XtalOut connection:
1. Click on Port_1_0 (P1[1]) or select Port_1_0 from the menu.
2. From the Select menu select XtalOut.
Figure 2-27. Select XtalOut for Port 1 0
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name, XtalOut, and the drive mode of High Z also appear in the port-related fields
underneath User Module Parameters (where you can click the drop-arrow to change your
selection).
XtalIn
To set the XtalIn connection:
1. Click on Port_1_1 (P1[1]) or select Port_1_1 from the menu.
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name, XtalIn, and the drive mode of High Z also appear in the port-related fields under-
neath User Module Parameters (where you can click the drop-arrow to change your selection).
ExternalGND
To set the ExternalGND connection:
1. Click on Port_2_4 (P2[4]) or select Port_2_4 from the menu.
2. From the Select menu select ExternalAGND.
Figure 2-29. Set External Ground for Port 2 4
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name and ExternalGND appear in the port-related fields underneath User Module
Parameters (where you can click the drop-arrow to change your selection).
In the device interface you see that all lines from P2[4] are gone.
Ext Ref
To set the Ext Ref connection:
1. Click on Port_2_6 (P2[6]) or select P2[6] from the menu.
2. From the Select menu select ExtRef.
Figure 2-30. Set External Reference for Port 2 6
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name and Ext Ref also appear in the port-related fields underneath User Module Param-
eters (where you can click the drop-arrow to change your selection).
In the device interface you see that all lines from P2[6] are gone.
I2C SDA
To set the I2C SDA connection (this connection is only available for CY8C27xxx parts):
1. Click on Port_1_5 (P1[5]) or select P1[5] from the menu.
2. From the Select menu select I2C SDA.
Figure 2-31.
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name, I2C SDA, and the drive mode of Open Drain High also appear in the port-related
fields underneath User Module Parameters (where you can click the drop-arrow to change your
selection).
In the device interface you see that all lines from Port_1_5 are gone.
I2C SCL
To set the I2C SCL connection (this connection is only available for CY8C27xxx parts):
1. Click on Port_1_7 (P1[7]) or select P1[7] from the menu.
2. From the Select menu select I2C SCL.
Figure 2-32.
3. Click OK.
On the device you see the designation color coded according to the legend next to the device.
The port name, I2C SCL, and the drive mode of Open Drain High also appear in the port-related
fields underneath User Module Parameters (where you can click the drop-arrow to change your
selection).
In the device interface you see that all lines from Port_1_7 are gone.
ChangeFromRead
To specify a ChangeFromRead interrupt:
1. Click on the target Port_x_x.
2. From the Interrupt menu select ChangeFromRead.
Figure 2-33. Set Port Interrupt to Change From Read
3. Click OK.
The port name and ChangeFromRead appears in the port-related fields underneath User Module
Parameters (where you can click the drop-arrows to change your selections).
DisableInt
To disable interrupts:
1. Click on the target Port_x_x.
2. From the Interrupt menu select DisableInt.
Figure 2-34. Set Port Interrupt to Disable
3. Click OK.
The port name and DisableInt appears in the port-related fields underneath User Module Param-
eters (where you can click the drop-arrows to change your selections).
FallingEdge
To specify FallingEdge interrupt:
1. Click on the target Port_x_x.
2. From the Interrupt menu select FallingEdge.
Figure 2-35. Set Port Interrupt to Falling Edge
3. Click OK.
The port name and FallingEdge appears in the port-related fields underneath User Module
Parameters (where you can click the drop-arrows to change your selections).
RisingEdge
To specify RisingEdge interrupt:
1. Click on the target Port_x_x.
2. From the Interrupt menu select RisingEdge.
Figure 2-36. Set Port Interrupt to Rising Edge
3. Click OK.
The port name and RisingEdge appears in the port-related fields underneath User Module
Parameters (where you can click the drop-arrows to change your selections).
The resource meter tracks Analog Blocks, Digital Blocks, RAM, ROM, and the use of device specific
special resources such as the decimator, CapSense™ blocks, or I2C controller. As you place user
modules, you can view how many analog and digital PSoC blocks you have available and how many
you have used. RAM and ROM monitors track the amount RAM and ROM required to employ each
selected user module.
To run the Design Rule Checker, go to: Tools > Design Rule Checker.
In a matter of seconds, you can review the results of the rule evaluation in the Results tab of the Out-
put Status window.
You can run the DRC at any time or any number of times during project development. To run it auto-
matically each time you generate application files, go to: Tools > Options > Interconnect Editor >
General.
You can also set specifics regarding the level of rule checking and result detail, go to:
Tools > Options > Tools > DRC tab.
Full details of the build are sent to the Output window. If the Output window is not visible, select Out-
put from the View menu.
Figure 2-39. The Output Window with Build Messages
NOTE: It is important to note that if you modify any device configurations, you must re-generate the
application files before you resume source programming.
NOTE: If you undo placement of a user module but leave it in your selected collection and generate
application files, associated .asm files remain (just not be updated). If you undo placement and
delete a user module from your collection then generate application files, all associated .asm files
are deleted (removed from source tree project files).
strings if you safely define the interrupt vector and install your own handler. If there is no interrupt
handler for a particular interrupt vector, the comment string “// call void_handler” is inserted
in place of the substitution string.
NOTE: If you install an interrupt handler and make changes directly to boot.asm, the changes are
not preserved if application generation is executed after you make the changes. If you make
changes to boot.asm that you do not want overwritten, hard code the change in boot.tpl (template for
boot.asm).
an .h file for configurations of a 16-bit PWM (Pulse Width Modulator) created during application-code
generation:
Once you generate the device configuration application code, the files for APIs and ISRs are located
in the source tree of Workspace Explorer under the Library Source Files and Library Header Files
folders.
NOTE: If you modify any ISR file and then re-generate your application, changes are not overwritten
if they are placed between user code markers included in the *int.asm file. Source code outside of
the user code marker regions is overwritten and is always re-generated. However, if a user module
is renamed and the application is re-generated, any user modifications within the user code markers
are not updated with the instance name. Any use of the user module instance name within user code
markers must be manually updated.
Figure 2-41. Place Your Custom Code Here
4 Analog Columns
VC3
GPIO
16 Digital Blocks
I2C
Sleep Timer
The configurable interrupts include 16 digital blocks and 4 analog columns. The definition (for exam-
ple, interrupt vector action) of a configurable interrupt depends on the user module that occupies the
block or uses the analog column.
The Chip-Level Editor handles the details of getting user module parameters into source code, so
that the project is configured correctly at startup and exposes subroutines that make for ease-of-use.
Exposing subroutines that make user module parameters easy to use involves PSoC Designer add-
ing files to your project. These files are known as Application Program Interfaces (APIs). Typically,
one of these user module files, added to your project, is an interrupt handler.
Aside from adding API files to your project, the Chip-Level Editor also inserts a call or jump to the
user module’s interrupt handler in the startup source file, boot.asm.
When the application is generated, code is produced for the Timer32_1 User Module. The interrupt
vector table is also altered with the addition of the call to the timer interrupt handler in boot.asm.
org 0 ;Reset Interrupt Vector
IF (TOOLCHAIN & HITECH)
; jmp __Start ;C compiler fills in this vector
ELSE
jmp __Start ;First instruction executed following a Reset
ENDIF
Continuing the example, 2Ch corresponds to DCB03. There are no interrupt handlers at DBB00,
DBB01, and DCB02 (20h, 24h, and 28h) because a 32-bit Timer User Module only requires the inter-
rupt at the end of the chain.
In many cases the actual interrupt handling code is “stubbed” out. You can modify the content of this
stubbed handler to suit your needs. Any subsequent device reconfiguration will not overwrite your
work in the handler if the modification is done in boot.tpl.
1. Right click the Loadable Configuration folder in the Workspace Explorer and select New Load-
able Configuration.
2. You see a new folder with a default name of Configx where x is the number of alternate configu-
rations.
Select the configuration folders to switch from one configuration to the other.
There is always at least one folder with the project name when a project is created. This folder
represents the base configuration. The base configuration has special characteristics. You can-
not delete the base configuration. The new configuration, by default, has global settings and pin
settings identical to the base configuration. Additional configuration folders appear in alphabetical
order from left to right, beginning after the base configuration tab.
3. To change the name right-click the folder and select Rename. The new name appears on the
folder.
NOTE: One requirement for Dynamic Reconfiguration is that user module instance names must
be unique across all configurations. This requirement eliminates confusion in code generation.
Otherwise, all other icon and menu-item functions are identical to projects that do not employ
additional configurations.
4. Proceed with the configuration process (i.e., selecting and placing user modules, setting up
parameters, and specifying pinout).
CustomPinName_DriveMode_0_ADDR
CustomPinName_DriveMode_1_ADDR
CustomPinName_IntCtrl_0_ADDR
CustomPinName_IntCtrl_1_ADDR
The CustomPinName used in the substitution is replaced by the name entered for the pin during
code generation. Custom pin naming allows you to change the name of the pin. The name field is
included in the pin parameter area of the pinout diagram.
The Name column in the Pin Parameter Grid shows the names assigned to each of the pins. The
default name shows the port and bit number. To rename the pin, double-click the name field and type
the custom name. Note that the name must not include any embedded spaces.
The effect of the name is primarily used in code generation when the pin interrupt is enabled. The pin
name is appended to the equates that are used to represent the address and bit position associated
with the pin for interrupt enabling and disabling, as well as testing the state of the port data.
PSoCConfig.asm
The static file PSoCConfig.asm contains:
Exports and code for:
LoadConfigInit – Configuration initialization function
LoadConfig_projectname – Configuration loading function
Code only for:
LoadConfig – General load registers from a table
For projects with additional configurations, a variable is added to the project that tracks the loaded
configurations. The LoadConfig_projectname function sets the appropriate bit in the active con-
figuration status variable.
Additional functions named LoadConfig_ConfigurationName are generated with exports that
load the respective configuration.
For each LoadConfig_xxx function, an UnloadConfig_xxx function is generated and exported
to unload each configuration, including the base configuration. The UnloadConfig_xxx_Bankn
functions are similar to the LoadConfig_xxx functions except that they load an
UnloadConfigTBL_xxx_Bankn and clear a bit in the active configuration status variable. In these
functions, the global registers are restored to a state that depends on the currently active configura-
tion.
With regard to the base configuration, UnloadConfig_xxx and ReloadConfig_xxx functions are
also generated. These functions load and unload only user modules contained in the base configura-
tion. When the base configuration is unloaded, the ReloadConfig_xxx function must be used to
restore the base configuration user modules. The ReloadConfig_xxx function ensures the integ-
rity of the write only shadow registers. Respective load tables are generated for these functions in
the PSoCConfigTBL.asm file.
An additional unload function is generated as UnloadConfig_Total. The
UnloadConfig_Total function loads these tables:
UnloadConfigTBL_Total_Bank0
UnloadConfigTBL_Total_Bank1
These tables include the unload registers and values for all PSoC blocks. The active configuration
status variable is also set to ‘0’. The global registers are not set by this function.
The name of the base configuration matches the name of the project. The project name is changed
to match the base configuration name if you change the name of the base configuration (from the
project name).
A C callable version of each function is defined and exported so that these functions are called from
a C program.
PSoCConfigTBL.asm
The PSoCConfigTBL.asm file contains the personalization data tables used by the functions defined
in PSoCConfig.asm. For static configurations, there are only two tables defined;
LoadConfigTBL_projectname_Bank0 and LoadConfigTBL_projectname_Bank1, which
support the LoadConfig_projectname function. These tables personalize the entire global regis-
ter set and all registers associated with PSoC blocks that are used by user modules placed in the
project.
For projects with additional configurations, a pair of tables are generated for each
LoadConfig_xxx function generated in PSoCConfig.asm. The naming convention follows the
same pattern as LoadConfig_xxx and uses two tables: LoadConfigTBL_xxx_Bank0 and
LoadConfigTBL_xxx_Bank1. These tables are used by UnloadConfig_xxx. The labels for
these tables are exported at the top of the file.
Loading – The tables for the additional configurations’ loading function differ from the base configu-
ration load table. The additional configuration tables only include those registers associated with
PSoC blocks that are used by user modules placed in the project, and only those global registers
with settings that differ from the base configuration. If the additional configuration has no changes to
the global parameters or pin settings, only the placed user module registers are included in the
tables.
Unloading – The tables for additional configurations’ unloading functions include registers that de-
activate any PSoC blocks that were used by placed user modules, and all global registers which
were modified when the configuration was loaded. The registers and the values for the PSoC blocks
are determined by a list in the device description for bit fields to set when unloading a user module,
and are set according to the type of PSoC block. The exceptions are the
UnloadConfigTBL_Total_Bankn tables, which include the registers for unloading all PSoC
blocks.
boot.asm
The boot.asm file is generated similarly to a project that has no additional configurations, unless
there are one or more configurations that have user modules placed in such a way that common
interrupt vectors are used between configurations. In this case, the vector entry in the interrupt vec-
tor table will show the line ljmp Dispatch_INTERRUPT_n instead of a user module defined ISR.
PSoCDynamic.inc
The PSoCDynamic.inc file is always generated. It contains a set of equates that represent the bit
position in the active configuration status variable, and the offset to index the byte in which the status
bit resides, if the number of configurations exceeds eight. A third equate for each configuration indi-
cates an integer index representing the ordinal value of the configuration.
PSocDynamic.asm
The PSoCDynamic.asm file is always generated. It contains exports and functions that test whether
or not a configuration is loaded. The naming convention for these functions is IsOverlayName-
Loaded.
PSoCDynamicINT.asm
The PSoCDynamicINT.asm file is generated only when the user module placement between config-
urations results in both configurations using a common interrupt vector. The reference to the
Dispatch_INTERRUPT_n function is resolved in this file. For each conflicting interrupt vector, one
of these ISR dispatch sets is generated. The ISR dispatch has a code section that tests the active
configuration and loads the appropriate table offset into a jump table immediately following the code.
The length of the jump table and the number of tests depends on the number of user modules that
need the common vector, rather than the total number of configurations. The number of conflicts can
equal the number of configurations, if each configuration utilizes the common interrupt vector. Gen-
erally, there will be fewer interrupt conflicts on a per-vector basis.
2.13.4.8 Limitations
The new displays are based on a bitmap of loaded configurations maintained by the LoadConfig
and UnloadConfig routines, which are generated by the Chip-Level Editor. This bitmap can get out
of synchronization with the actual device configuration in several ways:
The bitmap’s RAM area can be accidentally overwritten.
If overlapping (conflicting) configurations are loaded at the same time, the register labels will be
scrambled.
If an overlapping configuration is loaded and then unloaded, register labels from the original con-
figuration will be used, even though some PSoC blocks will have been cleared by the last
UnloadConfig routine.
The System-Level Editor allows you to select and configure various design elements, such as
inputs, outputs, valuators, and interfaces.
This desktop is where you create your designs. The main area is empty when you create a new
project. The top contains the toolbar. The areas surrounding the design area are configurable, and
can contain a variety of windows available from the View menu.
As you go through the Drivers and Valuators list in the Driver Catalog, A Current Device Description
window (Figure 3-3) opens and provides information about the most recent device you have
selected. If you do not see the window, choose Datasheet Window from the View menu.
Immediately after you release the driver on the desktop, the Add Output Driver window appears.
This window allows you to rename your driver and set any properties that you wish as you add the
driver. The driver datasheet is displayed in the Add Output Driver window to aid you in assigning
property values. You can go back later and edit properties at any time. When you are finished editing
properties, click OK to place the driver in your design.
Elements added to the desktop appear as icons (Figure 3-4). Click and drag elements to any loca-
tion on the desktop.
Replace – Brings up a catalog of drivers and lets you replace the existing driver with the one cho-
sen from the catalog (not applicable to valuators).
Simulation Controls
Widgets
There is no limit to the number of times you can switch back and forth between the Design and Sim-
ulation desktops. When constructing a complex design, it is best to simulate the design incrementally
as you add and define more outputs.
3.3.1 Widgets
A “widget” appears during simulation for every input and output device. The input device widgets
allow you to change the input state. The state of each output is displayed by its widget.
3.4 Drivers
PSoC Designer System-Level Editor has a catalog of devices used to acquire real world inputs, as
well as devices used in real world output functions. These devices are known as drivers. A driver
appears as a single building block used in the construction of a system. It is usually associated with
a physical piece of hardware, such as a temperature sensor.
The I2C slave interface exposes input driver, output driver, and valuator values to an I2C master that
can monitor and/or manipulate their values. The Board Monitor in PSoC Designer uses the I2C inter-
face to monitor your PSoC prototypes. PSoC Designer has a built in I2C master that recieves and
displays input, output, and valuator values in the Board Monitor.
3.5 Valuators
A valuator is a value stored in memory. There are two types of valuators: Interface and Transfer
Function.
StateMachine – The new output state is based upon the current state and the result of evaluating
all transition expressions associated with the current state.
StatusEncoder – The output value depends upon all input conditions that evaluate true. The
conditions are evaluated from top to bottom in order.
TableLookup – The output value is defined by the combinations of inputs states. Not all combi-
nations need to set the output.
LiteralCode – The output value is defined by the result of your function, written in a subset of the
C language.
Refer to Transfer Functions below for more information about these functions.
3.6.1.1 LoopDelay
A LoopDelay provides a way to compare current data to previous data. For example, a loop delay is
used during temperature measurement to measure temperature variation and adjust PWM fan
speed accordingly.
3.6.1.2 SetPointRegion
Set points convert a range of input values into a set number of regions. When a new setpoint thresh-
old is added, it divides the region in which it lies into two regions. Set points are useful in converting
a continuous range of values into a set number of discrete regions.
Hysteresis, also known as deadband, is used to provide a region where a change in the input does
not produce a change in the output. Hysteresis is useful for reducing rapid short-term reversals in a
control state due to sensor characteristics or noise. The default Hysteresis value is 0.
3.6.1.3 StateMachine
A StateMachine is a behavior model composed of states and transitions. A state stores information
about the past (i.e., it reflects the input changes from the system start to the present moment). A
transition is a state change governed by a user-defined rule that must be satisfied to execute the
change.
StateMachine valuator outputs two values: its state and the occurrence of a transition between
states. Output drivers and other valuators use the StateMachine output to govern their activities. The
StateMachine is useful for setting different operation modes for the application or for managing com-
plex processes.
3.6.1.4 PriorityEncoder
A PriorityEncoder provides a method to generate a single output value using only the highest priority
true input. PriorityEncoders are often used to combine multiple hierarchical input states into a single
valuator. For example, use a PriorityEncoder to command a fan to turn at the certain speed com-
manded by multiple temperature input sensors. A PriorityEncoder operation is similar to the following
pseudo code:
If x1 then y1
Else If x2 then y2
Else If x3 then y3
Else If x4 then y4
3.6.1.5 StatusEncoder
A StatusEncoder provides a method to generate a single output value using one or many inputs,
while allowing multiple simultaneous valid expressions. StatusEncoders are often used to combine
multiple input states into a single valuator used for interface communication. A StatusEncoder oper-
ation is similar to the following pseudo code:
If x1 then y1
If x2 then y2
If x3 then y3
If x4 then y4
3.6.1.6 TableLookup
The TableLookup transfer function maps every possible combination of input values to output values
in a one-to-one relationship. The TableLookup has additional flexibility by allowing the outputs to be
expressions rather than just constant values. Input combinations that are not mapped to an output
result in no change to the previously existing output value.
An example application of the table lookup is to turn a fan on when a button is pushed, and to turn
the fan off when the button is released.
3.6.1.7 LiteralCode
Each instance of the LiteralCode transfer function allows you to write a single function using a subset
of the C language. The following subset of the C language is supported:
Repetition structures:
do
while
for
break
continue
Selection structures:
if
else
switch
Standard C operators.
There are three main parts to this window: a list of available device configurations, configuration
properties, and a description of the selected configuration. There are also options to select a bill of
materials (BOM) vendor and to automatically assign the drivers to pins on the selected chip.
This window allows you to choose your desired PSoC device along with some system options that
include defining system voltage and program loop update rate. It only shows the PSoC configura-
tions that meet the input and output requirements of your design. The configurations are listed in
order from least to most expensive.
PSoC Designer automatically assigns the drivers to pins on the selected chip and displays a chip
footprint and the pin assignment.
You can manually reassign any pin by dragging the blue rectangle associated with its input/output
driver off the top of the pin. As you drag, you see that one or more pins on the footprint are high-
lighted in green. The green highlighting indicates that those pins will accept the driver you assigned.
Drop the blue rectangle on any one of these pins.
When you finish assigning pins, click Next for the last step in the build process.
When the hex file generation is complete, PSoC Designer compiles the design and programming
information into a set of custom reports, and then presents the information on the BOM/Schematic
desktop.
Figure 3-9. BOM/Schematic Desktop
.
The BOM Schematic desktop shows the resulting pin assignments on the device. The desktop also
includes hypertext links to the BOM, data sheet, and schematic custom created for your design.
Click on any hyperlink to view the output in a separate window.
4. Click Save and then choose Generate/Build ‘yourproject’ Project from the Build menu.
5. Select the target device configuration and properties.
Automatic pin assignment failed because of conflicts between the drivers. You now begin the pro-
cess of manually assigning drivers to the unassigned pins so that you solve this problem.
Now you place the unassigned drivers on of the available pins.
7. Clear all pin assignments by clicking the Unassign All Pins button.
The result is a screen that looks like this.
All the drivers are now listed on the right of the screen as unassigned drivers.
8. When you click a driver the ports to which you can assign it are highlighted in green. Begin with
LED_bit0.
9. Drag InterfaceSlave_i2c I2CsCLPin to pin 13. The SDAPin will automatically assign to pin 15.
10.Select each of the other drivers and repeat the process until all the drivers are assigned and the
screen looks like this.
The build is now complete and you are ready to move to the next step: programming the part.
The process illustrated here seems simple. You add inputs, outputs, and an interface. Then you
select a part and build the file. If there are conflicts such as encountered in this example you reas-
sign the drivers and complete the process. PSoC Designer automatically takes care of all the under-
lying complexity and puts everything in the proper place.
PSoC Designer creates a .soc file that allows you to open the project Interconnect view. This allows
you to further customize your design. In addition you are able to use the interconnect view to see the
complexity of your design. Here are two views of the pin assignment for this sample project.
Table 3-3. PSoC Designer and PSoC Designer 4.3 Design Views
Your seemingly simple design is, in fact, complex and ready for further customization.
The application loads with the PSoC Designer hex file in memory. Follow instructions in the PSoC
Programmer User Guide to program the PSoC device.
When you are done programming, exit the PSoC Programmer application. Not exiting the applica-
tion may cause some communication errors between PSoC Designer and PSoC Programmer.
The default communication for the board monitor is I2C uses the CY3240-I2USB I2C to USB Bridge
Debugging/Communication Kit. This allows you to monitor the board using the same ISSP (In Sys-
tem Serial Programming) connector that you use to program it.
Monitor Controls
Widgets
The monitor desktop looks very similar to the simulation desktop, except that you are monitoring live
values from your prototype board. The board monitor also enables the use of the variables chart win-
dow that allows you to track any or all of your system variables in real time.
The variables chart allows you to track all or any combination of system variables in real time on a
chart. You can choose which of the available variables appear in the chart window by checking or
clearing the box next to the variable name.
The variables chart supports three different vertical scaling modes:
Table 3-4.
Automatic Scaling The Variables Window uses a preset algorithm to choose a scale that will allow
all selected variables to be displayed.
Manual Scaling Deselect the Auto Scale box and enter a minimum and maximum value for the Y
scale. Only those traces that fall within the selected range will be displayed.
Data Normalized Select the Normalize button and all of the selected variables will be normalized
to a Manual Scale so that they can be viewed on a common scale that you choose. Each variable is
scaled according to that variables Minimum and Maximum. So if a variable has a
max of 5 and a minimum of -5 and the actual values recorded range from -4 to 4,
the data points will be graphed over the middle 80% of the chosen range.
2. If your design does not already have an I2C interface, choose an I2C slave communication inter-
face, and place it on your design. Leave the I2C_Address at the default value of 4.
3. When you do pin assignment for the project, the I2C pins will default to P1[7] and P1[5]. You will
need to move them to P1[0] and P1[1].
4. Build your project and program your board.
5. Switch to the Monitor desktop.
11. Interacting with the controls on the board will register in the board monitor in real time.
2. Make sure that the Flash Interface is Enabled in the Device Configuration properties when you
choose the device for your project.
Exposing tuning values adds some extra code to your design, so you may want to make sure that
you set Expose Tuning Values to No before you do your final build, especially if resources are tight
or you are trying to fit your final design into a smaller, less expensive part.
The following example shows the process of tuning a driver. This example shows tuning of a
CapSense button on a CY3203 CSA CapSense board. To set it up, choose a CSA Properties driver
to set global CSA properties, several CSA buttons, a Diplexed Slider, and an I2C interface. See the
PSoC Express CapSense Guide for details on how to set up this project. Build the project and set up
the board monitor as shown in “Monitoring Your Design” on page 79.
1. In the board monitor desktop, right click on a tunable driver.
2. Touch the button on the board that corresponds to driver tuner displayed.
The button is more sensitive than it needs to be.
5. To see exactly where a button triggers you can move your finger slowly on to the button. Do this
to observe that the Finger Threshold is higher now than it was before.
6. Place a finger fully on the button to observe that it is less sensitive now.
7. Click OK to save the values from the tuner window back to properties in PSoC Designer. Clicking
Cancel discards your changes, and retains the original properties settings.
The Workspace Explorer is shown in the right frame of Figure 4-1. This tree maintains the list of files
that include configurations files, user module source and header files, boot files, and user application
code.
assembled and linked source, they are read only. You can also access the Output tab on the source
tree in the Code Editor by selecting Tools > Options > Code Editor tab and unchecking Enable Out-
put.
4.1.3 boot.asm
This startup file resides in the source tree under Source Files and is important because it defines the
boot sequence. The components of the boot sequence are:
■ Defines and allocates the reset and interrupt vectors.
■ Initializes device configuration.
■ Initializes C environment if using the C Compiler.
■ Calls main to begin executing the application code.
When a project is created, the template file, boot.tpl, is copied into the project directory. Each time
the project is generated, the boot.asm file is generated from the local boot.tpl file.
boot.asm is re-generated every time device configurations change and application files are gener-
ated. This is done to make certain that interrupt handlers are consistent with the configuration. If you
make changes to boot.asm that you do not want overwritten, modify the local project boot.tpl file and
then re-generate file.
4.1.4 main.asm/main.c
If the C complier is not enabled, then the main.asm file is generated for applications written in
Assembly language. If the C Compiler is enabled, the main.c file is generated for a C program. This
file resides in the source tree under Source Files and is important because it holds the _main label
that is referenced from the boot sequence.
4.1.5 PSoCConfig.asm
This is a required Library Source file because it contains the configuration that is loaded at system
power-up.
PSoC Designer overwrites PSocConfig.asm when a device configuration changes and application
files are regenerated, with no exceptions. To manipulate bits, all part register values reside in this file
for your reference.
The registerName registers vary with the chip device description and include all registers associated
with the GPIO ports. For the CY8C25xxx/26xxx device family, registers include:
■ Bypass
■ DriveMode_0
■ DriveMode_1
■ IntCtrl_0
■ intCtrl_1
■ IntEn
For all other PSoC device families, registers include:
■ GlobalSelect
■ DriveMode_0
■ DriveMode_1
■ DriveMode_2
■ IntCtrl_0
■ IntCtrl_1
■ IntEn
The register shadow allocation is determined by user modules and Dynamic Reconfiguration. As the
register allocation changes, the macro generation changes accordingly.
Psocgpioint.h – This file contains the same information as Psocgpioint.inc except that it is in a form
needed for C code. In the case of the register shadows, this file does not generate macros, but
rather defines a symbol that allows manipulation of the shadow as a global variable. For each regis-
ter shadow associated with a custom pin definition, a variable named CustomName
_registerNameShadow is defined, where CustomName and registerName are the same as
previously defined for Psocgpioint.inc. The variable name is then used to manipulate the shadow
register. For example, to set a pin value to ‘1’ within the port, do this:
CustomName_registerNameShadow |= CustomName_MASK;
CustomName_registerName_ADDR = CustomName_registerNameShadow;
Globalparams.h – This file has the same contents as globalparams.inc, except it also has #define
statements.
New File File > New [Ctrl] [N] Adds a new file to the project
2. In the Find what field of the Find in Files dialog box, type or click the drop-arrow to choose a pre-
viously searched word.
Search by standard grep (Global Regular Expression Print) methods. Grep searches the input
files for lines containing a match to a given pattern list. For options, see grep.pdf in the \Docu-
mentation\Supporting Documents subdirectory of the PSoC Designer installation direc-
tory.
3. In the In files/file types field, type or click the drop-arrow to choose a previously searched file or
file type. Separate multiple files by using a comma.
4. Select the folder or files from the Look In menu or select the button button, to search a dif-
ferent project directory than the directory of your current open project. When Look In is set to
Current Document or All Open Documents, the File Types Filter is ignored.
5. Click a check in the specifics: Match whole word, Match case, Search subdirectories, and Search
up, if desired.
6. When finished, click Find Next, Find In Files, or Mark All (to highlight all occurences of the
found text). Click Close to close the Find in Files dialog box.
7. The results of the Find In Files search is diplayed in the Output window. Double-click to open the
file. The cursor is placed at the beginning of the found text.
The Mark All and Replace All functions only work when Look In is set to Current Document or All
Open Documents. It will not mark or replace text in unopened documents.
In this chapter you receive high-level guidance on programming assembly language source files for
the PSoC device. For comprehensive details, see the PSoC Designer Assembly Language User
Guide.
Instructions in an assembly file have one operation on a single line. For readability, separate each
keyword type by tabbing once or twice (approximately 5-10 white spaces). See the PSoC Designer
Assembly Language User Guide for type definitions and an example of assembly file syntax.
The Output Status (or error-tracking) window of Code Editor is where the status of file compiling and
assembling resides. Each time you compile and assemble files, the Output Status window is cleared
and the current status is entered as the process occurs.
When compiling is complete, you the see the number of errors. Zero errors signify that the compila-
tion and assemblage was successful. One or more errors indicate problems with one or more files.
This process reveals syntax errors. Such errors include missing input data and undeclared
identifier. For a list of all identified compile (and build) errors with solutions see the PSoC
Designer Assembly Language User Guide. For further details on compiling and building see “Build-
ing a Project” on page 103 in this guide.
At any time you can ensure a clean compile and assemble (or build) by accessing Project > Clean,
then clicking the Compile/Assemble or Build icon. The “clean” deletes all lib\libPSoc.a,
obj\*.o, and lib\obj\*.o files. These files are regenerated upon a compile or build (in addition
to normal compile and build activity).
For example, an assembly function that is passed a single byte as a parameter and has no return
value looks like this:
C function declaration (typically in a .h header file)
#pragma fastcall16 send_byte
void send_byte( char val);
C function call (in a .c file)
send_byte( 0x37);
Assembly function definition (in an .asm file)
export _send_byte
; Fastcall16 inputs (single byte)
; A – data value
; Fastcall16 return value (none)
_send_byte:
mov reg[ PRT1DR],A
ret
An assembly function that is passed two bytes and returns one byte might look like this:
C function declaration (typically in a .h header file)
#pragma fastcall16 read_indexed_reg
char read_indexed_reg( char bank, char index);
C function call (in a .c file)
val = read_indexed_reg( 0x01, index);
Assembly function definition (in an .asm file)
export read_indexed_reg
; Read byte from specified IO register
; Fastcall16 inputs (two single bytes)
; A – bank number (0 or non-zero)
; X – register number
; Fastcall16 return value (single byte)
; A – read data
_read_indexed_reg:
cpl A
jnz get_data:
or F, FLAG_XIO_MASK; switch to bank 1
get_data:
mov A, reg[X]
and F, ~FLAG_XIO_MASK; make sure we’re in bank 0
ret
Functions with more complex input parameters or return values can be written using these tables.
Note that the #pragma fastcall16 has replaced #pragma fastcall and use of #pragma fastcall is dep-
recated.
In this chapter you learn the details of building a project, discover more about the C Compiler as well
as the basic, transparent functions of the system Linker and Loader, and Librarian. For comprehen-
sive details on the C Compiler, see the PSoC Designer C Language Compiler User Guide.
Each time you build your project, the Output Status window in Code Editor is cleared and the current
status is entered as the process occurs.
When the build is complete, you see the number of errors and warnings. Zero errors signify a suc-
cessful build. One or more errors indicate problems with one or more files. If there are errors, the
program image (.hex file) is available for download to the ICE. For a list of all identified compile and
build errors with solutions see the PSoC Designer Assembly Language User Guide.
6.2 C Compiler
In addition to the development tools provided by Cypress Semiconductor, third party development
tools are available for PSoC devices. This gives developers a choice of tools when working with
PSoC devices. For information on how to install and use third party compilers with PSoC Designer,
refer to documentation supplied by the manufacturer of the tool.
The iMAGEcraft compiler enables you to quickly create a complete C application for a PSoC device.
Its built-in macro assembler allows assembly language code to seamlessly merge with C code.
The compiler compiles each .c source file to an .s assembly file. The assembler then translates each
.asm or .s file into a relocatable object file, .o. After all the files are translated into object files, the
builder and linker combine them together to form an executable file.
The iMAGEcraft C Compiler comes complete with embedded libraries providing port and bus opera-
tions, standard keypad and display support, and extended math functionality. For comprehensive
details on the C Compiler, see the PSoC Designer C Compiler User Guide.
To set compiler options in PSoC Designer, select Project Settings > Build > Compiler. You can select
a compiler option from the compilers you have installed. Depending on the compiler selected, the
settings will differ.
■ The Enable Paging checkbox is used to enable or disable large memory model appliations (appli-
cations using more than 256 bytes of RAM) on target chips with more than 256 bytes of RAM.
Unchecking this box for these chip restricts RAM usage to the first 256 bytes and decreases pro-
gram execution time and size associated with manipulating RAM paging registers.
■ Stack Page is an indicator of the RAM page on which the stack will be allocated for a large mem-
ory model application.
■ Stack Page Offset enables setting the start address of the stack for a large memory model appli-
cation such that the stack page can be shared between the stack and static variables.
■ Code Compression Techologies are used to reduce the application's Flash footprint.
Condensation (duplicate code), is a search of the binary code image for instruction sequences that
occur multiple times. These instruction sequences are placed into subroutines. Each occurrence of a
repeated instruction sequence is then replaced with a call to the applicable subroutine.
Sublimation (eliminate unused user module APIs) is the elimination of usused assembly code
bounded by the .section and endsection directives in AREA UserModules. If execution flow does not
go to the label immediately below the .section directive, the entire block of code up to the next .end-
section directive is removed.
Refer to the ImageCraft C Compiler Guide for more information.
Refer to the HI-TECH C(R) PRO for the PSoC(R) Mixed-Signal Array Pro guide for more information.
6.3 Linker
The linking functions in the build process are transparent to the user. Building your project links all
the programmed functionality of the source files (including device configuration) into a .hex file,
which is the file used for downloading and debugging.
The linking process links intermediate object and library files generated during compilation and
assembly, checks for unresolved labels, and then creates a .hex and a .lst file, as well as assorted .o
and .dbg files. For descriptions of these files, refer to “Source Files Generated by Generate Project
Operation” on page 47.
To set linker options in PSoC Designer, select Project Settings > Build > Linker. This screen config-
ures the linker specific options based on the compiler selection made in the Compiler screen. The
Selected C compiler box indicates which compiler (and linker) is currently selected.
Refer to the HI-TECH C(R) PRO for the PSoC(R) Mixed-Signal Array Pro guide for more information.
6.4 Librarian
The library and archiving features of PSoC Designer provide system storage and reference.
There are two types of Librarian files (located in the source tree): Library Source and Library Head-
ers. Source file types include archived and assembly language such as libPSoc.a and PSocCon-
fig.asm. Header files are intermediate reference and include files created during application code
generation and compilation. Both types are generated and used by PSoC Designer and are unique
to each specific project.
In this chapter you learn how to download your project to the In-Circuit Emulator (ICE), use debug
strategies, and program the part. For additional information about the ICE and the development kit,
refer to Application Note AN2018, Care and Feeding of ICE Pods at http://www.cypress.com/.
Some PSoC devices do not use an external emulator (ICE cube or ICE-4000) for debugging.
Instead, the PSoC Designer I2C Debugger debugs on-chip through a 5-pin ISSP header and
MiniProg3. This section highlights the differences between the debuggers explained in previous sec-
tions and the I2C Debugger supported by these devices.
There are separate user guides for two of the key debugger components:
■ PSoC ICE User Guide
■ PSoC Programmer User Guide
The PSoC ICE User Guide teaches you how to connect the ICE to your computer, configure the soft-
ware to enable communication and debugging between PSoC Designer and the Pod, and trouble-
shoot the ICE installation. The PSoC Programmer User Guide (referred in 7.7 “Programming the
Part“ on page 130) teaches you how to open a HEX file, select a communication port, set a device,
set a programming mode, program, verify, read, and run a checksum.
The following PSoC part families support I2C debugging:
■ CY8CTMA300
■ CY8CTMG300
■ CY8CTST300
I2C debugging requires the following components:
■ PSoC Designer 5.0 SP4 or later
■ PSoC Programmer 3.05 or later
■ A MiniProg3
■ A USB cable
■ A Target board with a 5-pin ISSP header (common with other PSoC devices)
The “ICE connected to:” list shows parallel ports (i.e., LPT1…3) supporting the original PSoC ICE.
The definition of the USB ports are determined by this coding:
USB/yywwTxxx
Where:
yy: Year the ICE was manufactured
ww: Work week the ICE was manufactured
T: Type of USB connection where:
C: ICE Cube
D: USB Adapter/Dongle for a legacy ICE
xxx: Manufacturing sequence number
Once you have set your debugger port, and are connected to your ICE, check the PC to ICE com-
munication link by using the Connect button or by selecting the Debug > Connect/Disconnect
menu item. The results of the connection attempt are displayed in the Output window. A successful
connection displays this message:
Connecting . . .
ICE Port: USB/0611C003
Pod powered by the ICE
Connected.
The status bar shown in Figure 7-3 also shows information associated with debugging.
Main Menu/ Source Tree Watch Variable Edit Memory Output Registers Break Points
Toolbars Window Window Window Window Window Window Window
Area
In the status bar of the Debugger subsystem you find ICE connection indication, debugger target
state information, and Accumulator, X, Stack Pointer, Program Counter, and Flag register values.
To help with troubleshooting, you can view your application source files inside the Debugger sub-
system. If the project source tree is not showing, click View > Workspace Explorer.
The project files that you view in the debugger will be read-only while the debugger is running or
halted at a breakpoint. The source files are editable when the debugger is reset.
7.5.1 Trace
The Trace feature enables you to track and log device activity at either a high or detailed level. Such
activity includes register values, data memory, and time stamps.
The Trace window is displayed when Debug > Windows > Trace is chosen.
The Trace window displays a continuous, configurable listing of project symbols and operations from
the last breakpoint. (The trace shows symbolic, rather than address data, to enhance readability.)
Each time program execution starts, the trace buffer is cleared. When the trace buffer becomes full,
it continues to operate and overwrite old data.
Configure the Trace window by selecting either Debug > Trace Mode or Tools > Options from the
menu. Configuration options include:
PC Only – Lists the PC value and instruction only.
PC/Registers – Lists the PC, instruction, data, A register, X register, SP register, F register, and ICE
external input.
PC/Timestamp – Lists the PC, instruction, A register, ICE external input, and time stamp.
You can save the trace as a text file by selecting File > Save Trace.txt or File > Save Trace.txt as.
The trace log entries are logged before the instruction is executed. The contents of those entries are:
■ PC Register
■ A Register
■ Data Bus
■ External Signals
When using the ICE-4000, the external input value is the binary representation of the 8 center pins
on the 10-pin ICE header. The right and left outside pins are connected to ground while the inputs
accept a 5-volt TTL level signal. The time stamp is displayed as a 32-bit relative count of clock cycles
from the CPU clock source.
The default size of trace is 256 kilobytes. This provides 128K trace instructions in trace mode 1 and
32K trace instructions in trace modes 2 and 3.
You can also view the exact line and column for each break point (or wherever you click your cursor
in the file) across the bottom of PSoC Designer.
RAM – View a RAM memory page. RAM locations can be modified by clicking the data at the spe-
cific location and typing in the new value. Data is entered in hexadecimal notation.
Flash – The Flash window displays the data stored in Flash. This is the program memory; it is read
only.
The current status of all locations can be saved to a .txt file by right-clicking at the top of the window
and selecting Save or Save As.
By default, all variable values are shown in hexadecimal. Right-click inside the Watch Variables win-
dow to display the toggle to show variable values in decimal instead. When the value of a watch vari-
able changes (during program execution), the changed values are presented in red. Values that did
not change during the execution are presented in black.
If the selected watch variable is not within the current context of the debugger, the variable is shown
as disabled. Once you have a program with Local Variables and the Debugger has halted in a func-
tion where they are contained, you see the value of the variable.
You cannot change Variable names. You can cut, copy, paste, and delete values (not names) when
the debugger is halted in a context where the variable exists. Double-click to highlight then right-click
to choose an option. The variable will be shown in red if it is stored in Flash. You cannot alter the
value of variables stored in Flash in the Watch Variable window. For better viewing, you can adjust
the column width of the Local Name window by dragging the heading row column dividers.
The default action for using the Delete option is to set the value to zero (including Floating point
types).
The Local Variables are not “alive” when the program has halted at the initial function scope, for
example:
void cgentest_009(void)
{-------------------------- HALT, NO Locals
uInt32 u32var0;
uInt32 u32var1
-.-.-.-.-.-.-.-.-.-. etc -.-.-.-.-.-.-.-.-.-.
As discussed in “Menu Options” on page 111, you can use the Single Step icon to step through the
project .lst file.
4. Fill in the applicable thread fields (i.e., Low Compare, Input Select, High Compare, Input Mask),
as well as state logic fields (i.e., Next State, Match Count).
As you make your selection in the Input Select drop-down, you see details in the grayed-out,
scrollable box below. Also, use Match Count to specify the number of times an event task occurs
before it performs the selected action.
The input mask for 8-bit threads is applied to the high and low range comparison values, as well
as to the input select value. This is done to support range comparisons on subsets of the bits in
the input select value. All comparisons take place within the bits specified by the input mask.
Other bits are ignored.
The range values are masked during event editing when the thread states are saved by the Apply
button or by switching to a thread state. For example, if the entered low compare value is 06 HEX
and the input mask value is 05 HEX, the low compare value after the mask is applied is 04 HEX.
The input select value is masked at run time.
5. When finished, click Apply. The individual event is now configured and its information appears at
row 0.
If you forget to apply your entries, you are prompted to save. Click Yes or No.
To clear all events in the dialog box, click Clear All. To disable all events in the dialog box, click
Disable All.
6. Click row 1 and repeat steps 3-5 to configure another event. Repeat this process for each addi-
tional event. (You can configure up to 65 events.)
7. Click Close to exit the dialog box. All entries are saved.
As you run events, you can view messages regarding the status in the Debug tab of the Output Sta-
tus window. For instance, if you check Break as part of an event, “Hit Event state break” appears in
the Output Status window as the debugger hits the event.
For complete training on debugging and Dynamic Event Points, try PSoC Designer Module 3:
Debugging with PSoC. Review and sign up under Training > On-Demand at
http://www.cypress.com/.
Stack Overflow
To create an event to break when the Stack Pointer reaches FF:
1. Access the Debugger Events dialog box by clicking Debug > Events.
12.Set Input select to A, Low compare and High compare to 32, and leave the Input Mask at FF.
13.Under State Logic set Next state to 3, the Match Count to 10, and check Trace Off and Break.
14.Click Apply to save, then close the Events window.
Area 1 Data...
0x00: 8A 47 6F 84 35 2A 01 28 14 46 00 93 F3 B3 5D 60
0x10: B8 6C C4 A8 31 71 19 41 99 4A 89 AC CE 11 8D 28
0x20: 06 9D 43 8D 22 EE 6C 92 88 3B 33 61 93 A0 16 27
0x30: 8C 0C 9A F0 AA 21 E4 62 80 FA 48 C6 9E E3 66 22
0x40: C8 31 02 8E 14 50 5A 74 AB 38 6F 15 6C 21 E4 DA
0x50: E5 A0 00 1A 0E EA C1 6E 59 46 9A 50 33 06 1F 98
0x60: 8E C3 F4 30 FD 12 01 43 38 52 95 20 D1 EF 71 94
0x70: 1C F8 7B 52 97 E6 12 3C 0C 56 92 2C 89 05 B5 D6
0x80: 1A 1A 80 0B 1E 09 48 3D 4E AB 38 2C CA 42 B4 3A
0x90: 33 DB 13 A3 44 D9 8B 3B 51 DC 00 2D 1D A3 BD 32
0xA0: 01 E7 A1 24 4A 99 04 D8 83 63 C4 EF 88 4A 28 18
0xB0: 48 81 96 16 51 1C F3 9D 1C 2F 92 36 2A AE 5F 6D
0xC0: 9C BC 0A FC D5 17 96 CF 61 20 FD 14 C4 09 E4 57
0xD0: D2 6C 51 36 3E AE 19 E2 99 5E 04 A1 C6 A9 D1 D0
0xE0: 5E 2D C1 70 97 F5 73 61 57 00 3D CB 77 E5 97 33
0xF0: 33 34 84 C7 2E 82 07 EA 76 9C 24 63 2B 7D 41 20
Area 2 Data...
0x03: 84 35 2A 01
Once you have set your ICE device, and are connected, check the communication link by using the
Connect button or by selecting the Debug > Connect/Disconnect menu item. The results of the
connection attempt are displayed in the Output window and the status bar
cally. A hex file generated with Debug Mode enabled will not run on the PSoC device unless it is con-
nected to the Debugger. Before generating production code, disable debug mode.
The I2C Debugger doesn’t use the external emulator and has a limited number of break points.
Active Break points will be shown with solid icon as shown in Figure 7-13:
Usually, the contents of the watch variable's memory location are displayed and modifiable in the
Value field. There are two conditions when the data is not displayed in the Value field:
1. When the Data Type of the watch variable is 'struct' the memory contents will not be displayed in
the 'Value' field.
2. When the 'Elements' field is greater than 1 and the 'Display As' value is not ASCII (non-character
array) the memory contents will not be displayed in the 'Value' field.
When the Display As property is changed, the value from memory is displayed in the Value field. If
you changed the Value and did not click OK before changing the Display As value, the data change
is lost.
When a display format is applied to an array or a struct watch variable, all the elements (or fields) of
the variable are displayed in the selected format.
To display a single element or field of an array or struct, select just that element from the Watch Win-
dow and then edit the format of just that element.
The image of the Watch Window shown in Figure 7-17 shows a single watch variable named
yStruct, of type YourStruct. It contains 4 fields named myStruct, msArray, iArray and f.
The display format of the msArray field is set to Binary. Every data element contained in msArray
is displayed in binary format. The format of iArray and f are the default of Decimal.
The display format of each field of yStruct.myStruct was set individually. The display format of
yStruct.myStruct.a is Hexadecimal. The format of yStruct.myStruct.b is Decimal, and the
format of yStruct.myStruct.c is set to ASCII.
Checking the Hexadecimal item in the Watch Window's pop-up menu toggles all data in the window
to hexadecimal format. When Hexadecimal is un-checked, the data formats return to their original
display format.
Note that when the native format of an item has been set to Hexadecimal, toggling the Watch Win-
dow Hexadecimal setting will appear to have no effect on that item.
Make sure the pod is not connected to a circuit board (your development board or the PSoC pup)
when you program the part. Otherwise, programming (the part) may fail.
To program the part, place the part in the programming socket on the pod, then select Program >
PSoC Programmer to launch PSoC Programmer. PSoC Programmer is a standalone device pro-
gramming application. If PSoC Programmer is not installed, the icon is grayed out. It can be down-
loaded from the Cypress web site. Using this PSoC Designer accessory you can quickly program,
read, verify, and checksum. Refer to the PSoC Programmer’s User Guide for additional information.
Alternatively, the device can be programmed on the target board using the Serial Programming
Header on the Pod. The five connections that must be made from the Serial Programming Header to
the pins on the target device are listed in Table 7-3.
NOTE: Note: It is important to note that there is a limit to the amount of current that can be supplied
to the Vdd pin from the emulator pod (500 mA at 5V). If you draw greater current through the Vdd pin
on the programming header, this could damage the emulator. You must supply the connections on
the target board for serial programming in the system.
Once part programming is complete, you test the program part directly on your development circuit
board.
Flash Program Memory Protection (FPMP) allows you to select one of four protection (or security)
modes for each 64-byte block within the Flash, based upon the particular application.
A simple text file called flashsecurity.txt is used as the medium for the Flash security. This text file
contains comments describing how to alter the Flash security. PSoC Designer validates the correct-
ness of the Flash security data before it is used.
NOTE: The flashsecurity.txt file for PSoC Designer v. 2.xx and higher projects that use Flash writes
must be set to the correct protection modes. The defaults are set to full-protect mode. To change the
protection mode, the part must be bulk erased and re-programmed using the flash security settings.
PSoC Designer also adds the FPMP file to a cloned project. This is especially useful when cloning
projects created with earlier versions of PSoC Designer because earlier versions did not carry this
feature. Note that if you do clone a project created in an earlier version of PSoC Designer, you are
prompted to update your project, (see “Updating Existing Projects” on page 19).
NOTE: If, for some reason, flashsecurity.txt is missing or was deleted from the project, the default
behavior is to apply Mode Bit 11 Full Protection to the entire program memory.
This information contains instructions on modifying flashsecurity.txt and appears at the beginning of
this file in PSoC Designer.
; Edit this file to adjust the Flash security for this project.
; Flash security is provided by marking a 64-byte block with a
; character that corresponds to the type of security for that
; block, given:
;
; W: Full (Write protected)
; R: Field Upgrade (Read protected)
; U: Unprotected
; F: Factory
For example, if you have a Flash data table that can be changed using a Flash write routine, you
might have assembly code that looks like this:
area Table (ROM, ABS)
org 3C80h
widgetTable:
export WidgetTable
db 57h ; W
db 49h ; I
db 44h ; D
db 47h ; G
db 45h ; E
db 54h ; T
; …. More table entries continue
You then unprotect the Flash block associated with this table at address 3C80h and make your
change in the flashsecurity.txt file as shown in Figure 8-4.
To move the image to a different location on the screen, hold down the ALT key,
click in the image with the mouse and drag the image to a place where you want it
on the screen.
To zoom out, hold down the CTRL+SHIFT keys and click.
D S
I2C SDA Pin 1_5
BSS145
G
D S
I2C SCL Pin 1_7
BSS145
G
Pin X (to enable I2C)
100k
Notes:
Place the N channel FETs used in this block so that the source of the FETs
attaches to the PSoC GPIO pin (otherwise the body diodes in the FETs will con-
duct in the same way as the protection diodes).
This drawing illustrates the BSS145 from Infineon, but you may select something
less expensive as long as they are N ch FETs with an RdsON rating for Vgs <=
PSoC Vdd. For example, if PSoC Vdd = 3.5V you need an NCH FET with a spec-
ified Rds ON for a Vgs <= 3.5V (such as the BSS145).
Setting “Pin X” drive mode to “strong” and writing a 1 to the pin Drive Register
enables the PSoC on the I2C bus. Write a 0 to the pin drive register to disable the
I2C.
This appendix describes the build utilities and process and provides examples for PSoC Designer.
Make and sed are standard tools with documentation in the Documentation/Supporting Doc-
uments folder of the PSoC Designer installation directory.
B.2.3.1 Makefile
This file is a general-purpose MAKE file for all PSoC projects. Therefore, use care when changing
the actions in this file, because they apply to all PSoC builds. This file is located in the tools folder, off
the main PSoC Designer installation path.
The relevant makefile targets are:
Makemake target
When you use the psocmakemake.exe utility, this target produces the project.mk from the
project.SOC file (see Section B.2.3.2 project.mk).
Depend target
This runs mkdepend.exe with the appropriate arguments to generate include file dependencies.
All target
This is the default target that compiles, links, and builds.
Clean target
This removes all object files.
PROJNAME=c24
DEVICE=CY8C24423
BASEDEVICE=CY8C24000B
PROJPATH=C:/temp/BASEPA~1/c24
PSOCDIR=C:/PROGRA~1/CYPRES~1/PSOCDE~1
INCLUDE_PATH=C:/PROGRA~1/CYPRES~1/PSOCDE~1/tools/include/CY8C24~1
CSRCS=
LIBCSRCS=
ASMSRCS= main.asm
LIBASMSRCS= delsig8_1.asm delsig8_1int.asm psocconfig.asm psocconfigtbl.asm
OBJECT_SOURCES= main.asm
FILLVALUE=0x30
LASTROM=0xfff
LASTRAM=0xff
CODECOMPRESSOR=
MORE_CFLAGS=-Wf-Osize
RELSTART=0x150
CDEFINES=
LIBS=
LIB_PATH=
ENABLE_ALIGN_SHIFT=0
LMM=
SYS_INC_CONTENTS:=SYSTEM_STACK_PAGE:_equ_...etc…
SYSTEM_TOOLS=1
CONFIG_NAMES=c24
The section provides a description of each of the symbolic names found in a project.mk file. You can
look at the master make file in an editor and use a text search utility to see how these symbolic
names are used.
PROJNAME – Helps the master make file create the file name for the .hex, .lst, and .map files.
DEVICE – Not actually used by the master make file, but used by the psocmakemake.exe utility to
get things out of the device description XML files. This is a shell environment variable that is set
before running the ‘makemake’ target.
BASEDEVICE – Used to help create the proper path to a device family specific library. This is a shell
environment variable that is set before running the ‘makemake’ target.
PROJPATH – Helps create a path to link in the project’s user module library (libpsoc.a)
PSOCDIR – Helps form a path to invoke a sub-make target called ‘expanded_lib_prereq’. This is
also used in formulating other paths.
INCLUDE_PATH – PSoC Designer version 4.2 with Service Pack 1 has a limitation to the use of this
make variable in the master make file. The makemake target (psocmakemake.exe process) essen-
tially creates only one path for this variable using the PSOCDIR and BASEDEVICE values. The
MORE_CFLAGS – This variable adds ImageCraft commands when compiling C files. The PSoC
Designer ImageCraft compiler settings will hide or allow certain settings based on the project device.
For example, for a device that does not have a hardware Multiplier/Accumulator (MAC) the value in
MORE_CFLAGS is set to ‘-Wf-nomac’.
-Wf-nomac: Does not generate code to use the MAC.
-Wf-Osize: Uses calls to math library functions instead of inlining the code.
-Wf-LMM8: Tells the compiler to generate paged RAM code for eight pages.
-D_LMM: Needed for C code using >1 page of RAM.
-g -e -c: These are always used by the master make file. They are, respectively, add
debug information, accept C++ comments, and compile file only.
RELSTART – This is the relocatable start address, for example 0x140. This is the starting address
for the text area (above the TOP area).
CDEFINES – This is added to a command line for compiling C source files. ‘Defines’ are prefixed
with a ‘-D’ and un-defines are prefixed with a ‘-U’. For example:
CDEFINES=-DSET_SPI –DMAX=2 –UADD_DBG
LIBS – This is a list of object (.o) and library (.a) files that you wish to link in from outside the project.
The elements must be separated by white space.
LIB_PATH – These are folder locations that should hold the LIBS. Elements in this list should be
separated by semicolons (;). Short (e.g., 8.3) path names should be used.
ENABLE_ALIGN_SHIFT – This is not used.
LMM – This helps the master make file when a project wishes to use paged RAM. The values are a
1 or nothing.
SYS_INC_CONTENTS – The value (e.g., list) for this variable is quite long. This value is a mecha-
nism used by PSoC Designer to push information about memory settings into an include file that the
master make file creates. Possibly, the additional elements in this list could be added so that you can
put your ‘equates’ in the memory include file. The master make file effectively creates the memory
include file by redirecting memhead.tpl from the proper device include folder to the top of the mem-
ory include file. Then each element in this list is placed in the memory include file after replacing
‘_equ_’ with ‘ equ ‘ (spaces added where underscores were). The remainder of the memory include
file comes from the redirection of the memfoot.tpl file (in the proper devices include folder). Again,
reading the master make file and understanding this will help a lot.
SYSTEM_TOOLS – This value is 1 for ImageCraft.
CONFIG_NAMES – This lists (white space separated) the overlay (or configuration) names created
in the device editor. This helps the master make file create linker switches to ensure that the RAM
data declared in User Modules gets located on the same RAM page for each overlay.
B.2.3.4 project.dep
Created by the ‘mkdepend’ via the make depend command. This file contains the include dependen-
cies for the project. It is rewritten by the build process.
B.2.3.5 local.dep
This file contains additional file dependencies and make commands. It is not touched by the make
process.
Since this is the last thing in the make file, assignments here override those in the main make file.
See B.4.2 Boot Loader Example on page 151.
B.2.3.6 custom.lkp
This is a ‘legacy’ file inserted via sed into the linker arguments. This is typically used to locate ‘areas’
with the -b switch (for example: -bfoo:0x1C00.0x1FFF)
B.2.3.7 opts.txt
This is a file created by PSoC Designer to take the GUI settings for the compiler and linker and
translate them to ImageCraft arguments and other MAKE variables used by the master make file.
The contents of this file gets pulled into the project.mk file
There should be a String value (REG_SZ) in this key named COMPILER_LICENSE. Its values are
your license (case sensitive). Create this key by exporting the key and then importing it onto another
PC or add it manually. This registry key location changed in PSoC Designer version 4.2 (icc.exe).
Earlier versions of icc.exe look for the license in the ‘AddIn’ key.
You then need to put your PSoC project files in a folder on the other PC. When you build your project
on the other machine make sure that the PSOCDIR variable, as well as other path-related variables
(e.g. INCLUDE_PATH), in a project.mk or local.mk file, point to the appropriate paths.
obj/%.o : ../common/%.c
ifeq ($(ECHO_COMMANDS),novice)
echo $(call correct_path,$<)
endif
OBJECT_SOURCES=$(C_ORDER) $(ASM_ORDER)
A)
analog PSoC blocks Basic programmable opamp circuits. There are SC (switched capacitor) and CT (con-
tinuous time) blocks. These blocks can be interconnected to provide ADCs, DACs,
multi-pole filters, gain stages, and much more.
Application Program- A series of software routines that comprise an interface between a computer applica-
ming Interface (API) tion and lower-level services and functions (for example, user modules and libraries).
APIs serve as building blocks for programmers that create software applications.
Code Editor PSoC Designer subsystem where users edit and program C Compiler and assembly
language source files.
assemble (combined Assembling, in PSoC Designer, translates all relative-addressed code into a single
with compiling) .rom file with absolute addressing.
build/link Building your project in PSoC Designer links all the programmed functionality of the
source files and loads it into a .rom file, which is the file you download for debugging
and programming.
compile (combined Compiling, in PSoC Designer, takes the most prominent, open file and translates the
with assembling) code into object source code with relative addresses.
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.
design (export/ One or more loadable configurations that can be exported from a project then imported
import) and used in a new or existing project. A loadable configuration consists of one or more
“placed” user modules with module parameters, Global Resources, set pinouts, and
generated application files.
design browser Venue to identify reusable designs for import to PSoC Designer projects.
Chip-Level Editor PSoC Designer subsystem where you choose/configure your device.
digital PSoC blocks The 8-bit logic blocks that can act as a counter, timer, serial receiver, serial transmitter,
CRC generator, pseudo-random number generator, or SPI.
dynamic reconfigura- Dynamic Reconfiguration allows for applications to dynamically load and unload con-
tion figurations. With this feature, your single PSoC MCU can have multiple functions.
family of devices PSoC family of devices consists of several device groups: CY8C21xxx, CY8C22xxx,
CY8C24xxx, CY8C25xxx, CY8C26xxx, CY8C27xxx, CY8C29xxx
ICE-4000 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).
ice-Cube In-Circuit Emulator (ICE) that replaces the ICE-4000 and USB adapter for seamless
USB connection, debugging, and programming.
interrupt service rou- A block of code that normal code execution is diverted to when the M8C receives a
tine (ISR) hardware 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, return-
ing the device to the point in the program where it left normal program execution.
link/build Linking your project in PSoC Designer links all programmed functionality of the source
files (with absolute addressing) and loads it into a .rom file, which is the file you down-
load for debugging and programming.
miniProg1 Developmental programmer that provides a low-cost solution for learning about, pro-
gramming and evaluating the PSoC.
pod Part of the ICE that emulates functionality, in which debugging occurs.
PSoCEval1 Evaluation board that provides a low-cost solution for learning about, programming,
and evaluating the PSoC.
PSoC Designer The software for Cypress MicroSystems’ Programmable System-on-Chip technology.
PSoC Programmer New, multi-functional programming software accessible from within PSoC Designer.
source tree Project file system displayed by default in left frame of Workspace Explorer.
subsystem PSoC Designer has three subsystems: Chip-Level Editor, Code Editor, and Debugger.
USB adapter Port connection to work the ICE in PSoC Designer v. 4.1 or later.
user modules Accessible, preconfigured function that, once placed and programmed, will work as a
peripheral in the target device.
A linker/loader 105
address spaces 96
addressing modes 96
analog input connection 38 C
analog section, manually turning off C compiler 104
troubleshooting 140 Chip-Level Editor 11
application editor code generation 55
adding existing files 93 active configurations display 57
adding new files 93 boot.asm 56
additional generated files 90 IO register labels 57
file definitions and recommendations 87 limitations 57
modifying files 92 PSoCConfigTBL.asm 56
removing files 93 PSoCDynamic files 57
searching files 94 compatibility with existing projects 19
troubleshooting 138 compiler
working in 92 C compiler 104
application files, generating 46 compiling and assembling files 99
application programming interfaces 48 components of the debugger 109
AreaName not defined, troubleshooting 142 configuring events, debugger 120
assembler connecting user modules 28–34
accessing 95
connection to global input 34
address spaces 96
addressing modes 96 connection to global output 36
clean compile/assemble/build 100 CPU register window 118
compiling/assembling files 99 creating
destination of instruction results 97 a project directory 17
directives 98 customizing linker actions 106
file syntax 97
instruction format 96
instruction set 99
list file format 97
D
microprocessor (MCU) 95 debugger
assembling and compiling files 99 breakpoints 117
assembly functions, calling from C 100 components 109
configuring events 120
connecting to the ICE 112
CPU register window 118
B debug strategies 115
backup folder for projects 27 development kit 109
bank register 0 and 1 window 118 downloading to pod 114
dynamic event points 120
boot.asm file
event examples 122
about 47
flash memory window 118
code generation 56
header to device pin connections 132
in application editor 90
local watch variables 119
breakpoints 117 menu options 111
build utilities 145 programming the part 130
builder RAM memory window 118
building a project 103 registers 0 and 1 window 118
C compiler 104 trace 116
library source 107 trace log entries 117
troubleshooting 139
typical event uses 121
watch variables 119
default input connection 38
design rule checker 45
running 45
development kit 109
device editor
interrupt vectors 50
troubleshooting 137
digital interconnect row input window 34
dynamic event points 120
dynamic reconfiguration
add configurations 52
application editor 55
code generation 55
delete configurations 53
global parameters 54
port pin settings 54
rename configurations 54
E
event examples
find memory write 122
register A value, trace on and off, and match count 123
stack overflow 122
F
file definitions and recommendations in application editor 87
file errors in FPMP 135
file syntax 97
file types and extensions 88
flash memory window 118
flash program memory protection
file errors 135
flashsecurity.txt file 134
options 133
flashsecurity.txt file 133, 134
G
general troubleshooting issues 142
generating application files 46–47
global resources 22–26
global variables 119
Globalparams.h file 91
globalparams.inc file 91
H
headers and library header folders 89
hot swapping, I2C troubleshooting 140
L
lib (librarian) file folder 88
library headers 107
library source 88, 107
library source folder 89
linker/loader 105
list file format 97
M
main.asm file 90
main.c file 90
N
name user modules 20
O
obj (objects) file folder 88
options for modifying source files 92
output file folder 88
output tab 89
P
parameters, user modules 21
parts catalog 18
pinout specification 37
placing user modules 19–??
POD detection, troubleshooting 141
port connections
analog input 38
analog output buffer 38
default input 38
Ext Ref 41
ExternalGND 41
Global_IN_x 39
Global_OUT_x 39
I2C SDA 42
StdCPU 40
XtalIn 40
XtalOut 40
port drive modes 42
port interrupts
ChangeFromRead 43
DisableInt 43
FallingEdge 44
RisingEdge 44
programming parts in debugger 130
project
backup folder 27
building 103
file system 89
project cloning warnings, troubleshooting 142
PSoC dynamic files 57
PSoCConfig.asm file 55
in application editor 90
PSoCConfigTBL.asm file 56
PSoCgpioint.h file 91
PSoCgpioint.inc file 90
R
RAM memory window 118
registers
S
shadow registers 90
source files folder 89
source files generated by generate application operation 47
source tree 89
stack overflow, event examples 122
system interface 88
system supervisor call 133
T
trace issues, troubleshooting 140
trace window 116
tracking device space 44
troubleshooting
analog section, manually turning off 140
application editor 138
AreaName not defined 142
debugger 139
device editor 137
general troubleshooting issues 142
I2C hot swapping 140
ICE configuration 139
incorrect code compilation 139
POD detection 141
project cloning warnings 142
trace issues 140
USB hub 141
U
updating user module parameters 21
USB hub, troubleshooting 141
user modules
deploying interconnectivity 27
global resources 22–26
name 20
placing 19–??
removing 21
rename 20
restore default pinout 37
restore global resource defaults 22
rotating a placement 21
setting parameters 21
specifying pinout 37
tracking device space 44
V
version control system 89
W
watch variables
array types 119
global 119
working in application editor 92
working with ISRs 49
write only register shadows 90