AN75320 Getting Started With PSoC® 1 Author: Robert Murphy, Ashutosh Srivastava Associated Project: Yes Associated Part Family: All PSoC 1 Families Software Version: PSoC Designer™ 5.4 SP 1 and higher Related Application Notes: For a complete list of the application notes, click here. To get the latest version of this application note, or the associated project file, click here. ® AN75320 introduces you to PSoC 1, an 8-bit processor with programmable digital and analog blocks that enable implementation of custom functions. This application note describes the PSoC 1 architecture and development tools, and shows how to create your first design. This document guides you to more resources to accelerate in-depth learning about PSoC 1. Contents 1 2 3 4 5 6 Introduction ...............................................................2 Get Started ...............................................................2 2.1 PSoC Designer ................................................3 2.2 Code Examples ...............................................4 2.3 PSoC Designer Help ........................................5 2.4 Technical Support ............................................5 Comparison of PSoC 1 Families...............................6 PSoC 1 Feature Set .................................................7 4.1 M8C Processor and Memory ...........................8 4.2 Programmable Digital Subsystem ....................8 4.3 Programmable Analog Subsystem ..................8 4.4 System-wide Resources ..................................8 4.5 GPIO System ...................................................9 4.6 CapSense ........................................................9 4.7 Dynamic Reconfigurability ............................. 10 Development Tools ................................................. 10 5.1 Software: PSoC Designer IDE ....................... 10 5.2 Hardware ....................................................... 10 PSoC 1 Learning Resources .................................. 11 www.cypress.com 6.1 PSoC 1 Data Sheets...................................... 11 6.2 Learning PSoC 1 Designer ............................ 12 6.3 Application Notes ........................................... 12 6.4 Knowledge Base Articles ............................... 12 6.5 Technical Reference Manual (TRMs) ............ 12 6.6 Device Errata ................................................. 12 6.7 Technical Support .......................................... 12 7 My First PSoC 1 Design ......................................... 13 7.1 About the Design ........................................... 13 7.2 Creating My First PSoC 1 Design .................. 13 7.3 Route PWM Signals....................................... 18 7.4 Add Coding .................................................... 19 7.5 Configure Pinout ............................................ 21 7.6 Build and Program ......................................... 21 7.7 Setting Up the CY3210-PSoCEval1 Board .... 23 7.8 Setting Up the CY8CKIT-001 Board .............. 25 8 Summary ................................................................ 27 9 Related Application notes ....................................... 27 Document No. 001-75320 Rev. *E 1 ================ Getting Started With PSoC® 1 ________________________________________________________________________________________________________________ 1 Introduction PSoC 1 is a true programmable embedded system-on-chip, integrating custom analog and digital peripheral functions, memory, and an M8C microcontroller on a single chip. This is different from most mixed-signal embedded systems, which use a combination of a microcontroller (MCU) and external analog and digital peripherals. This type of system typically requires many integrated circuits in addition to the MCU, such as opamps, ADCs, and digital ASICs. PSoC 1 provides a low-cost alternative to the combination of MCU and external ICs. In addition to reducing overall system cost, the programmable analog and digital sub-systems allow great flexibility, in-field tuning of the design, and accelerates time to market. The system resources of PSoC 1 can be dynamically reconfigured during run time to perform completely different functions. Dynamic reconfigurability is possible during instances where the resources have been consumed in a design. This allows you to reuse PSoC 1 system resources and maximize the integration value proposition. ® The capacitive touch-sensing feature in PSoC 1, known as CapSense , offers unprecedented signal-to-noise ratio (SNR), best-in-class waterproofing, and a wide variety of sensor types such as buttons, sliders, trackpads, and proximity sensors. This application note helps you explore the PSoC 1 architecture and development tools, and learn how to create your first project using PSoC Designer™, the development tool for PSoC 1. This document also guides you to more resources to accelerate in-depth learning about PSoC 1. In addition to PSoC 1, the Cypress PSoC portfolio also contains PSoC 3, PSoC 4, and PSoC 5LP devices. These PSoC devices offer different system architecture and peripherals. For more information, refer to the Cypress Platform PSoC Solutions Roadmap. 2 Get Started Cypress provides a wealth of data at www.cypress.com to help you to select the right PSoC device for your design, and to help you to quickly and effectively integrate the device into your design. For a comprehensive list of resources, ® ® see the knowledge base article How to Design with PSoC 1, PowerPSoC , and PLC – KBA88292. Following is an abbreviated list for PSoC 1: Overview: PSoC Portfolio, PSoC Roadmap Product Selectors: PSoC 1, PSoC 3, PSoC 4, PSoC 5LP In addition, PSoC Designer includes a device selection tool. Application notes: Cypress offers a large number of PSoC application notes covering a broad range of topics, from basic to advanced level. Recommended application notes for getting started with PSoC 1 are: ® AN75320 - Getting Started with PSoC 1. ® AN2094 - PSoC 1 - Getting Started with GPIO. ® AN74170 - PSoC 1 Analog Structure and Configuration with PSoC Designer™ ® AN2041 - Understanding PSoC 1 Switched Capacitor Analog Blocks ® AN2219 - PSoC 1 Selecting Analog Ground and Reference Note: For CY8C29X66 devices related application notes, click here. Development Kits: CY3210-PSoCEval1 supports all PSoC 1 mixed-signal array families, including automotive, except the CY8C25/26xxx devices. The kit includes an LCD module, potentiometer, LEDs, and breadboarding space. CY3214-PSoCEvalUSB features a development board for the CY8C24x94 PSoC device. Special features of the board include USB and CapSense development and debugging support. Note: For CY8C29X66 devices related development kits, click here. The MiniProg1 and MiniProg3 devices provide interfaces for flash programming and debug. www.cypress.com Document No. 001-75320 Rev. *E 2 ================ Getting Started With PSoC® 1 ________________________________________________________________________________________________________________ 2.1 PSoC Designer PSoC Designer is a free Windows-based Integrated Design Environment (IDE). Develop your applications using a library of pre-characterized analog and digital peripherals in a drag-and-drop design environment. Then, customize your design leveraging the dynamically generated API libraries of code. Figure 1 shows PSoC Designer windows. Note: This is not the default view. 1. Global Resources – all device hardware settings. 2. Parameters – the parameters of the currently selected User Modules. 3. Pinout – information related to device pins. 4. Chip-Level Editor – a diagram of the resources available on the selected chip. 5. Datasheet – the datasheet for the currently selected UM 6. User Modules – all available User Modules for the selected device. 7. Device Resource Meter – device resource usage for the current project configuration. 8. Workspace – a tree level diagram of files associated with the project. 9. Output – output from project build and debug operations. Note: For detailed information on PSoC Designer, open PSoC Designer IDE, go to Help > Documentation, open the “Designer Specific Documents” folder, and open the “IDE User Guide.pdf” document. Figure 1. PSoC Designer Layout www.cypress.com Document No. 001-75320 Rev. *E 3 ================ Getting Started With PSoC® 1 ________________________________________________________________________________________________________________ 2.2 Code Examples The following webpage lists the PSoC Designer based code examples. These code examples can speed up your design process by starting you off with a complete design, instead of a blank page, and also show how PSoC Designer User Modules can be used for various applications. http://www.cypress.com/documentation/code-examples/psoc-1-code-examples To access the code examples integrated with PSoC Designer, follow the path Start Page > Design Catalog > Launch Example Browser as shown in Figure 2. Figure 2. Code Examples in PSoC Designer In the Example Projects Browser shown in Figure 3, you have the following options. Keyword search to filter the projects. Create a new project (and a new workspace if needed) based on the selection. This can speed up your design process by starting you off with a complete, basic design. You can then adapt that design to your application. Listing the projects based on category. Review the datasheet for the selection (on the Description tab). Review the code example for the selection. You can copy and paste code from this window to your project, which can help speed up code development, or www.cypress.com Document No. 001-75320 Rev. *E 4 ================ Getting Started With PSoC® 1 ________________________________________________________________________________________________________________ Figure 3. Code Example Projects, with Sample Codes 2.3 PSoC Designer Help Visit the PSoC Designer home page to download the latest version of PSoC Designer. Then, launch PSoC Designer and navigate to the following items: 2.4 IDE User Guide: Choose Help > Documentation > Designer Specific Documents > IDE User Guide.pdf. This guide gives you the basics for developing PSoC Creator projects. Simple User module Code Examples: Choose Start Page > Design Catalog > Launch Example Browser. These code examples demonstrate how to configure and use PSoC Designer User modules. Technical Reference Manual: Choose Help > Documentation > Technical Reference Manuals. This guide lists and describes the system functions of PSoC 1 devices. User module datasheets: Right-click a User module and select “Datasheet.” This datasheet explains the parameters and APIs of the selected user module. Device Datasheet: Choose Help > Documentation > Device Datasheets to pick the datasheet of a particular PSoC 1 device. Imagecraft Compiler Guide: Choose Help > Documentation > Compiler and Programming Documents > C Language Compiler User Guide.pdf. This guide provides the details about the Imagecraft compiler specific directives and Functions. Technical Support If you have any questions, our technical support team is happy to assist you. You can create a support request on the Cypress Technical Support page. If you are in the United States, you can talk to our technical support team by calling our toll-free number: +1-800-5414736. Select option 8 at the prompt. www.cypress.com Document No. 001-75320 Rev. *E 5 ================ Getting Started With PSoC® 1 ________________________________________________________________________________________________________________ You can also use the following support resources if you need quick assistance. 3 Self-help Local Sales Office Locations Comparison of PSoC 1 Families PSoC 1 includes thirteen device families. Table 1 shows the features available in these device families. Table 1. PSoC 1 Device Selector Summary Table Device Family Features 29x66 28xxx 27x43 24x94 24x93 24x33 24x23A 23x33 22x45 21x45 21x34 21x23 32K 16K 16K 16K 32K 8K 4K 8K 16K 8K 8K 4K SRAM (KB) 2K 1K 256B 512B 2K 256B 256B 256B 1K 512B 512B 256B ADC 1 14-bit (DS) 4x14bit (DS) 11-bit (DS) 14-bit (DS) 10-bit (INC) 11-bit (DS) 11-bit (DS) 11-bit (DS) 8-bit (SS) 8-bit (SS) 10-bit (SS) 10-bit (SS) - 10-bit (150 Ksps) - - - 8-bit (300 Ksps) - 8-bit (300 Ksps) 10-bit (150 Ksps) 10-bit (150 Ksps) - - 4 4 4 2 2 2 2 2 4 4 2 2 4 4 4 2 - 2 2 2 - - - - 4 4 4 2 - 2 2 2 - - - - 8 6 4 2 3 (Timer) 2 2 2 4 2 2 2 UART/SPI 4 3 2 1 1 SPI 1 1 1 2 1 1 1 I2C 1 2 1 1 1 (Slave) 1 1 1 1 1 1 1 CapSense Buttons - 43 - 49 - - - - 37 23 23 - GPIO 64 44 44 50 36 26 24 26 38 24 24 16 USB - - - FS 2.0 FS 2.0 - - - - - - - ECO Y Y Y N Y Y Y Y Y Y N N SMP Y Y Y N N N Y N Y Y Y Y MAC 2 2 1 2 0 1 1 1 1 1 0 0 Flash (KB) (DS/SS) ADC 2 (SAR) Comparator DAC (8-bit) PGA (x48 Gain) TCPWM (16-bit) FS = Full Speed, SMP = Switch Mode Pump, ECO = External Crystal Oscillator, MAC = Multiply Accumulate, INC = Incremental, DS = Dual Slope, SS = Single Slope, PGA = Programmable Gain Amplifier, TCPWM = Timer Counter Pulse Width Modulator, UART = Universal Asynchronous Receiver Transmitter, SPI = Serial Peripheral Interface, I2C = Inter-Integrated Circuit www.cypress.com Document No. 001-75320 Rev. *E 6 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 4 PSoC 1 Feature Set PSoC 1 has a large set of capabilities and features, which include a CPU core, a digital subsystem, an analog subsystem, a memory subsystem, and system resources, as Figure 4 shows. The following sections give brief descriptions of each feature. For more information, see the PSoC 1 family device datasheet, technical reference manual (TRM), and application notes listed in PSoC 1 Learning Resources. Figure 4. PSoC 1 Architecture (CY8C29466) Port 7 Port 6 Port 5 Port 4 Port 3 Port 2 Port 1 Port 0 Analog Drivers SYSTEM BUS Global Digital Interconnect Global Analog Interconnect PSoC CORE Supervisory ROM (SROM) SRAM Flash Nonvolatile Memory CPU Core (M8C) Interrupt Controller 24 MHz Internal Main Oscillator (IMO) Internal Low Speed Oscillator (ILO) Sleep and Watchdog Phase Locked Loop (PLL) 32 KHz Crystal Oscillator (ECO) Multiple Clock Sources DIGITAL SYSTEM ANALOG SYSTEM Digital PSoC Block Array Analog Ref Analog PSoC Block Array DBB00 DBB01 DCB02 DCB03 DBB10 DBB11 DCB12 DCB13 CT CT CT CT DBB20 DBB21 DCB22 DCB23 SC SC SC SC SC SC SC SC DBB30 DBB31 DCB32 DCB33 1 to 4 Digital Rows Analog Input Muxing 1 to 4 Analog Columns SYSTEM BUS Digital Clocks Multiply Accumulate (MACs) POR and LVD Decimators I2C System Resets Switch Mode Pump Internal Voltage Reference USB IO Analog Multiplexer SYSTEM RESOURCES Figure 4 shows the feature available in the CY8C29466 device. Subsets of these features are available in other devices; see Table 1. www.cypress.com Document No. 001-75320 Rev. *E 7 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 4.1 M8C Processor and Memory PSoC 1 has an M8C processor, which is an 8-bit RISC CPU with Harvard architecture. It is capable of operating at a maximum frequency of 24 MHz, providing 4 MIPS performance. The M8C has 37 instructions. PSoC 1 devices have as much as 2 KB of SRAM and as much as 32 KB of flash, as Table 1 shows. For more details, refer to the PSoC 1 Technical Reference Manual. 4.2 Programmable Digital Subsystem The digital subsystem of PSoC is unique because of its programmability and routing systems. Table 1 lists the various PSoC 1 parts and the digital resources available in each device. The digital blocks in PSoC 1 are sub-divided into Digital Basic Blocks (DBBs) and Digital Communication Blocks (DCBs). The number of DBBs and DCBs are always equal. 4.2.1 Digital Basic Blocks (DBBs) DBBs are basic configurable digital resources, which you can program to function as timers, counters, or PWMs. Each DBB allows you to place an 8-bit resource. Creating a 16-bit, a 24-bit, or a 32-bit digital resource requires two, three, or four DBBs, respectively. 4.2.2 Digital Communication Blocks (DCBs) DCBs not only allow you to place basic digital resources (timer, counter, or PWM), but they also allow you to place communication resources, such as SPI and UARTs. You can place DBB components in DCBs. However, you cannot place DCB resources in DBBs. 4.3 Programmable Analog Subsystem The unique analog subsystem of PSoC 1 is composed of analog blocks arranged in a column configuration. These analog blocks are either continuous time (CT) or switched capacitor (SC) blocks. 4.3.1 Continuous Time (CT) Blocks The CT blocks inside PSoC are programmable analog blocks that you can configure as either comparators or programmable gain amplifiers (PGAs). The CT blocks are built around low-noise and low-offset opamps. The large number of analog multiplexers in the CT block provides high configurability. For more information on the structure and composition of CT blocks, refer to Chapter 22 of the PSoC 1 Technical Reference Manual. 4.3.2 Switched Capacitor (SC) Blocks SC blocks are also built around low-noise, low-offset opamps surrounded by analog multiplexers. These blocks are unique because groups of capacitors and switches surround the opamps and multiplexers. There is no resistor array as there are in the CT blocks. For additional information on the SC block architecture, refer to Chapter 23 of the PSoC 1 Technical Reference Manual or AN2041 – Understanding PSoC 1 Switch Capacitor Analog Blocks. 4.4 System-wide Resources 4.4.1 C l o c k i n g S ys t e m PSoC includes an advanced clocking system with multiple clock sources, many of which are programmable. You can derive the main clock source from either the internal 24-MHz internal main oscillator (IMO) or an external clock source of up to 24 MHz. In addition, for a low-speed oscillator, you can use either a 32-kHz oscillator circuit or an internal low-speed oscillator (ILO). For more information on clocks available in PSoC 1, refer to AN32200 - PSoC® 1 - Clocks and Global Resources. 4.4.2 Switch Mode Pump (SMP) The switch mode pump (SMP) is a DC/DC boost circuit supported by PSoC to allow the device to operate from a single 1.5-V battery. PSoC has an internal FET and an independent PWM hardware to run the boost circuit. You need only an external battery, inductor, diode, and capacitor to complete the boost circuitry. For more information, refer to Chapter 30 of PSoC 1 Technical Reference Manual. www.cypress.com Document No. 001-75320 Rev. *E 8 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 4.4.3 Multiply Accumulate (MAC) The Multiply Accumulate, or MAC, provides an 8-bit signed multiplier with a 32-bit accumulator for summation. The MAC is extremely useful in performing math operations and implementing digital filters. You can use the MAC by writing to and reading from certain registers of the device. After multiplication, you can either read the value out of the register or store it in the accumulator. You can clear the accumulator reset it to a value of zero by writing to the c lear registers (MACx_CL1 and MACx_CL2). For more information, refer to Chapter 26 of PSoC 1 Technical Reference Manual. 4.4.4 Voltage Reference PSoC 1 contains many options for voltage references. The three main terms are: 1. AGND 2. RefHi 3. RefLo Analog signals in the device are biased to analog ground (AGND). The voltage location of AGND depends on the developer, who has a range of options. Analog signals higher than AGND are considered positive, while voltages below it are considered negative. RefHi and RefLo refer to the upper and lower limits of the analog system. For more details, refer to AN2219 - PSoC® 1 Selecting Analog Ground and Reference. 4.4.5 2 Dedicated I C Hardware 2 The I C communications block is a serial-to-parallel processor, designed to interface the PSoC device to a two-wire 2 I C serial communications bus. To eliminate the need for excessive M8C microcontroller intervention and overhead, 2 the block has I C-specific support for status detection and generation of framing bits. 2 Following are the major features and capabilities of the PSoC I C hardware controller: ® 2 Industry-standard Philips I C bus-compatible interface Master and slave operation, multi-master capable 2 Only two pins (SDA and SCL) are required to interface to the I C bus Standard data rate of 100/400 kbps; also supports 50 kbps 7-bit addressing mode; 10-bit addressing supported 2 Additional information on using I C can be found in AN50987: Getting Started with I2C in PSoC 1. 4.5 GPIO System The GPIO system provides an interface between the CPU, the peripherals, and the outside world. Each GPIO, when used as a digital I/O, can source 10 mA per pin and can sink 25 mA per pin. In total, the device is capable of sinking 200 mA, with 100 mA per side. Therefore, even number pins on any port can handle a total of 100 mA, and odd number pins on any port can handle an additional 100 mA. The device can source a total of 80 mA or 40 mA per side. ® For more details, refer to Chapter 6 of the PSoC 1 Technical Reference Manual and AN2094 - PSoC 1 - Getting Started with GPIO. 4.6 CapSense Some PSoC 1 devices support capacitive touch sensing known as CapSense. Capacitive touch sensors are userinterface devices that use human body capacitance to detect the presence of a finger on or near (proximity) a sensor. Capacitive sensors are aesthetically superior, easy-to-use, and have long lifetimes. CapSense allows you to replace expensive and unreliable mechanical buttons with capacitive buttons that are simple copper traces on the PCB. CapSense supports a wide variety of sensors such as buttons, sliders, trackpads and proximity sensors. To see which PSoC 1 devices support CapSense, see Table 1. For additional information, refer to AN64846 - Getting Started with CapSense. www.cypress.com Document No. 001-75320 Rev. *E 9 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 4.7 Dynamic Reconfigurability With PSoC 1, you can start a project design without knowing all the details of the end product, and then add resources as needed. As long as the digital or analog resources are available, you can adjust, adapt, and grow. Even in instances where the resources have been consumed in a design, PSoC can be dynamically reconfigured during run time to perform a different function. This allows you to reuse resources in PSoC and maximize the integration value proposition. For details, refer to AN2104 - PSoC® 1 - Dynamic Reconfiguration With PSoC® Designer™. 5 Development Tools Cypress supports PSoC 1 with high-quality development tools such as the PSoC Designer software tool, hardware tools including development kits, programming hardware, and debugging hardware. These tools help you to configure the device, develop the application code, then build, debug, and deploy an embedded design. 5.1 Software: PSoC Designer IDE Cypress‟s PSoC Designer is an integrated development environment (IDE) used to customize, configure, and program PSoC 1 devices. You can download this tool from http://www.cypress.com/products/psoc-designer. PSoC Designer is a fully-contained environment where you can create your PSoC application by configuring the analog and digital peripherals, write application code, and perform other functions discussed in this application note. In addition, this software lets you program a PSoC device and debug a project using the PSoC ICE-Cube debug platform. Figure 5 shows the layout of PSoC Designer and a description of each section of the IDE is given in the PSoC Designer section. Note that this is not the default layout of PSoC Designer. Any windows seen in the following figure that do not appear when you open Designer can be added by navigating through the View dropdown menu in the toolbar. Figure 5. PSoC Designer Layout 5.2 Hardware Cypress provides various PSoC 1 hardware kits to fulfill your design requirements. To choose your PSoC 1 device, refer to PSoC 1 Kits and PSoC 1 Kit Selector Guide. The following section provides a list of the development kits, the programming hardware, and the debugging hardware. www.cypress.com Document No. 001-75320 Rev. *E 10 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 5.2.1 D e ve l o p m e n t K i t s Cypress provides several development kits to help you easily prototype your PSoC 1 design. Table 2 lists the some of the development kits that support the evaluation of PSoC 1. For complete list of the development kits/board, refer to Development Kits. Table 2. PSoC 1 Development Kits Development Kit 5.2.2 Description CY3210-PSOCEVAL1 The CY3210 PSoC Eval1 Kit enables you to evaluate and experiment Cypress's PSoC 1 programmable system-on-chip design methodology and architecture CY8CKIT-001 The CY8CKIT-001 PSoC Development Kit provides a common development platform where you can prototype and evaluate different solutions. Programming Hardware You can choose from several options for programming devices from Cypress-provided and third-party tools. Cypress offers four programming devices: MiniProg1, MiniProg3, ICE-Cube, and CY3207-ISSP. MiniProg1 The MiniProg1 is the ISSP programmer that is included with many PSoC 1 kits. You can use this programmer for all PSoC 1 devices, except the CY25/26xxx devices. The MiniProg1 cannot be used to program PSoC 3 or PSoC 5 devices. MiniProg3 The MiniProg3 is the ISSP programmer that comes with the CY8CKIT-001 Development Kit. The MiniProg3 is an allin-one programmer for PSoC 1, PSoC 3, and PSoC 5 devices, a debug tool for PSoC 3 and PSoC 5 architectures, 2 2 and a USB-I C bridge for debugging I C serial connections and communicating with PSoC devices. Third-Party Programmers See the list of third-party programmer tools at http://www.cypress.com/documentation/developmentkitsboards/general-psoc-programming. These tools have been designed, tested, and qualified by Cypress to support programming of PSoC 1 devices. 5.2.3 Debugging Hardware CY3215A-DK CY3215A-DK In-Circuit Emulation Lite Development Kit includes an in-circuit emulator (ICE). While the ICE-Cube is primarily used to debug PSoC 1 devices, it can also program PSoC 1 devices using ISSP. Rather than using the blue CAT5 cable or the flex cable to interface with debug pods, you can use the yellow ISSP cable to program devices. This makes the ICE-Cube useful for both debug and production environments. See AN73212 – Debugging with PSoC 1 for more details. 6 PSoC 1 Learning Resources This section provides a list of PSoC 1 learning resources to help you to get started and to develop complete applications with PSoC 1. Many resources are available for PSoC 1 developers, including datasheets, reference manuals, videos, and application notes. 6.1 PSoC 1 Data Sheets Visit the PSoC 1 Datasheets page for PSoC 1 datasheets that list the features and electrical specifications of all PSoC 1 device families. www.cypress.com Document No. 001-75320 Rev. *E 11 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 6.2 Learning PSoC 1 Designer Visit the PSoC Designer home page to download the latest version of PSoC Designer. Launch PSoC Designer and navigate to the following items: PSoC Designer User Guides: Visit the PSoC Designer User Guide page for a PSoC Designer User Guide. 6.2.1 IDE User Guide: Launch PSoC Designer > Help > Documentation > Designer Specific Documents > IDE User Guide. This guide gives you the basics on developing PSoC Designer projects. 6.2.2 Example Projects : Launch PSoC Designer > Design Catalog > Example projects. These example projects demonstrate how to configure and use PSoC Designer Components. 6.2.3 PSoC Designer Training These trainings help to design and demonstrate the Intro to PSoC Designer, Dynamic Reconfiguration, and Debugging with PSoC. 6.2.4 Component Datasheets: Launch PSoC Designer > Workspace Explorer. Under the Chip tab, right-click on a Component and select Datasheet. 6.3 Application Notes Application notes assist you with understanding specific features of the device and designing your PSoC 1 application. Visit the PSoC 1 Application Notes page for a complete list of PSoC 1 application notes. 6.4 Knowledge Base Articles These are a database of frequently asked technical support questions and their answers. Visit the Knowledge Base Articles page for a complete list of PSoC 1 knowledge base articles. 6.5 Technical Reference Manual (TRMs) The TRM provides complete detailed descriptions of the internal architecture of the PSoC 1 devices. Visit the PSoC 1 Technical Reference Manuals page for a list of PSoC 1 TRMs. 6.6 Device Errata These documents list any specification of the device that deviates from either the device datasheet or technical reference manual. Visit the Device Errata page for a list device errata documents. 6.7 Technical Support If you have any queries or questions, our technical support team is happy to assist you. You can create a support request using the Cypress Technical Support link. If you are in the United States, you can talk to our technical support team by calling our toll-free number +1-800-5414736. Select option 8 at the prompt. You can also use the following support resources if you need quick assistance: Self-help Local Sales Office Locations www.cypress.com Document No. 001-75320 Rev. *E 12 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 7 My First PSoC 1 Design This section shows you the step-by-step process of building a simple design with PSoC 1 using PSoC Designer, then programming it into a PSoC device, and configuring PSoC 1 demonstration boards to view the results of the application. 7.1 About the Design This design creates a simple project that produces two PWM outputs (one using a hardware resource and the other using software) on two GPIOs. One GPIO will display a blinking LED at a fixed rate, while another GPIO will show a pulsing, or heartbeat, LED. The project also measures an analog voltage using an ADC User Module. 7.2 Creating My First PSoC 1 Design 7.2.1 Create Project You start with creating a project in PSoC Designer. Here, you select the device, and then set the development language as C. This example project uses CY8C29466-24PXI, because that is the part that accompanies the CY3210-PSoCEval1 kit. 1. In PSoC Designer, select File > New Project and name it AN75320, as shown in Figure 6. Figure 6. Creating a New PSoC Designer Project 2. Click on Device Catalog to select the device as shown in Figure 7. Figure 7. Device Catalog www.cypress.com Document No. 001-75320 Rev. *E 13 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Note If you are developing this project with another kit, use the following part numbers: CY3214-PSoCEvalUSB: CY8C24994-24LTXI 3. Click on Create Project with „CY8C29466-24PXI’ and then click OK. CY3271-PSoC First Touch: CY8C20634-12FDXI The project workspace opens, and displays the Chip Editor and the Workspace Explorer. Press Ctrl and click to zoom in the Chip Editor view, which shows the block diagram of the selected device. 7.2.2 Select User Module In this step, you select the required components from the User Module catalog and configure them. The user module window is on the lower right as shown in Figure 8; select View > User Module Catalog to display it. Figure 8. User Module Catalog Window This project uses the following user modules: One ADC User Module 1. To place the user modules, perform the following steps: On the User Module Catalog, expand the ADCs folder. 2. Right-click EzADC and select Place. The EzADC Configuration window opens. 3. In the Configuration window, select Double Stage Modulator and click OK. (This configuration uses two switchedcapacitor blocks for better performance). 4. Under the PWMs folder, right-click PWM8, and select Place. 5. Repeat the placement process to place two PWM8 User Modules in the design. 6. From the Misc Digital folder, right-click LCD, and select Place. Two PWM8 User Modules One LCD User Module After you have placed the required user modules, the Designer window will look like Figure 9. In addition, the placed user modules are displayed in the Workspace Explorer. Note that each user module placed is named as ComponentName_1, and so on. For example, the EzADC User Module is listed as EzADC_1. www.cypress.com Document No. 001-75320 Rev. *E 14 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Figure 9. EzADC and PWM User Modules Placement in the Chip Editor (Digital Blocks) Figure 10. EzADC User Module Placement in the Chip Editor (Analog Blocks) 7.2.3 Set User Module Parameters In this step, you configure the parameters for the user modules that you placed in the design. When you click on a user module from either the Workspace Explorer or the Chip Editor, the Parameters window for the selected user module appears on the left hand side, where you can edit the parameters. Refer to the diagrams for the parameters to set or change. 1. Select EzADC_1 and change its parameters based on Table 3. After you have made the changes, the window looks similar to Figure 11. Parameters that are to be changed from their default values are highlighted. Table 3. EzADC_1 User Module Parameters www.cypress.com Parameter Value Description Name EzADC _1 Give the User Module name Data Format Unsign ed Sets the output to unsigned data as input is positive only Resolution 14 Bit Sets the max resolution for EzADC Sample rate 0.007 Sample rate depend on resolution. See the user module datasheet of EzADC. Input Analog Column _Input MUX_0 Select the analog input data bus to receive the input analog voltage for the source. Offset Compensation Enable Enables the correlated double sampling Document No. 001-75320 Rev. *E 15 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Parameter Value Description Buffer Gain 1.000 Sets the PGA gain to 1 for unity amplification Reference VSS Sets the reference for the PGA to perform offset compensation AGND Output Disable Disables the AGND output. This option can be used to bring out the internal AGND to connect bipolar signals to the ADC Offset Compensation Frequency 2 Sets the number of ADC samples after which offset is corrected Figure 11. EzADC_1 User Module Parameters Select PWM8_1 and change its parameters as per Table 4. After you have made the changes, the window appears as shown in Figure 12. Note that the user module is now renamed as LED1_PWM. Table 4. LED1_PWM User Module Parameters Parameter Value Description Name LED1_PWM Assign a name to the User Module. Clock VC3 Choose the clock source as VC3. Enable High Select enable as High for continuous count. Compare Out Row_0_Output_2 Connect the compare output to a GPIO via a row output bus. Terminal Count Out None This is an auxiliary counter. You don‟t need to connect it to any of the row output buses. Period 254 Set the period of the counter. Pulse Width 127 Sets the pulse width of the PWM output (50% duty cycle). Compare Type Less Than Or Equal Select full range for the compare type function. Interrupt Type Terminal Count This selection triggers the interrupt on the terminal count of the counter register. Clock Sync Sync to SysClK Synchronizes the clock input to system clock Invert Enable Normal This determines the sense of the enable input signal. www.cypress.com Document No. 001-75320 Rev. *E 16 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Figure 12. PWM_1 User Module Parameters 2. Select PWM8_2 and edit its parameters to the settings as Figure 13 shows. Note that the user module is now renamed to LED2_PWM. Figure 13. PWM_2 User Module Parameters 3. Select the LCD_1 user module and change its parameters as per Table 5. After you have made the changes, the window looks similar to Figure 14. Table 5. LCD_1 User Module Parameter Parameter Value Description Name LCD_1 Give the User Module name LCD Port Port_2 This sets interfaces the LCD display module to assigned Port BarGraph Disable Disables the bar graph function Figure 14. LCD Parameters www.cypress.com Document No. 001-75320 Rev. *E 17 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 4. Open Global Resources window from View > Global Resources to configure the source clock VC3 for PWMs clock frequency and the Ref Mux for ADC input data range. Leave other parameter to their default value. After changes, the Global Resources window looks similar to Figure 15. For more information on Global Resources, see the IDE User Guide. Figure 15. Global Resources Parameters 7.3 Route PWM Signals In this section, you route the PWM signals from PWM user modules to selected GPIO. To see the signal on a GPIO pin, you must implement routing for the PWM signals. In addition, this design implements the logic in the row outputs by feeding the two PWM outputs into an XOR. The difference of the period of the two PWM signals, XORed together, will create the effect of pulsing (heartbeat). 1. Connect CompareOut of LED1_PWM to Row_0_Output_2. 2. Connect the CompareOut of LED2_PWM to Row_0_Output_3. 3. Connect the CompareOut of LED1_PWM to Port_1_2 using auto routing. Press Shift and select the CompareOut pin of LED1_PWM and connect it with Port_1_2 as Figure 16 shows. You may also manually connect LED1_PWM to Port_1_2 using GlobleOutOdd_2 Figure 16. PWMs Connected to Row Outputs www.cypress.com Document No. 001-75320 Rev. *E 18 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 4. Click on the Row_0_Output_2 Digital Interconnect to open the configuration options as shown in Figure 17. Figure 17. RO0[2] Digital Interconnect View 5. Click on the LogicTable_Select (indicated by the square box in the middle) and select A_XOR_B from the dropdown list as shown in Figure 18, and then click Close. Figure 18. Digital Interconnect Configuration 6. Confirm that the digital routing diagram looks as Figure 19 shows. If they match, then the configuration of the pulsing heartbeat LED is now complete. Figure 19. Designer Chip View 7.4 Add Coding In this step, you add the code to configure all the user modules and GPIOs to implement a software LED that will produce a blinking LED. You add the custom code that follows on to the main.c file for the project. 1. In Workspace Explorer, locate the Source Files folder under the AN75320 Folder and open the main.c file. 2. Copy the C code listed below and pastes it into the main.c file, replacing the existing code. Code 1. Project 1 main.c /* part specific constants and macros */ #include <m8c.h> /* PSoC API definitions for all User Modules */ #include "PSoCAPI.h" /* Definitions for all input and output operation */ #include "stdio.h" www.cypress.com Document No. 001-75320 Rev. *E 19 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ /* Macros to set ADC parameters */ #define GAIN 1 #define MAX_ADC_COUNTS 16383 #define ADC_RANGE 5000 /* Macros to select port 1 */ #define PORT_1_3 PRT1DR /* Variable to store the ADC result */ WORD adc_result; /* Variable to store the measured input in millivolts */ WORD v_in; void main(void) { static unsigned int index; /* Buffer used for the long to ASCII conversion */ char LCDBuffer[17]; /* Initializes LCD to use the multi-line 4-bit interface LCD_1_Start(); */ /* Enable global interrupts */ M8C_EnableGInt ; /* Set the position to print the character */ LCD_1_Position(0,0); /* print the Hello World in the first line */ LCD_1_PrCString("Hello World!"); /* Starts the LED1_PWM and LED2_PWM, high enable input begins the Counter */ LED1_PWM_Start(); LED2_PWM_Start(); /* Initializes and starts the EzADC User Module resources */ EzADC_1_Start(EzADC_1_HIGHPOWER); /* Starts the ADC conversion */ EzADC_1_GetSamples(0); while(1) { /* Wait for the ADC result to be available */ while(!(EzADC_1_fIsDataAvailable())); /* Read the ADC result and clear the data ready flag */ adc_result = EzADC_1_iGetDataClearFlag(); /* Calculate input voltage in mV */ v_in = (DWORD)adc_result*ADC_RANGE / MAX_ADC_COUNTS / GAIN; /* Convert the input voltage to an ascii string */ csprintf(LCDBuffer, "ADC INPUT:%4dmV", v_in); /* Set the position to print the character */ LCD_1_Position(1,0); /* print the voltage in the second line */ www.cypress.com Document No. 001-75320 Rev. *E 20 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ LCD_1_PrString(LCDBuffer); /* Toggle the pin 1[3]*/ PORT_1_3 ^= 0x08; /* Give some delay to view toggling effect*/ for(index = 0; index < 22000; index++); } } 3. 7.5 Include local.mk file attached with the project to enable floating point for the ADC. See the local.mk file for more information on this function. Configure Pinout In this step, you configure the GPIO drive mode for the pin to drive the LED. You configure the pinout for the selected device from the Pinout view. (View > Pinout). The Pinout panel appears on the lower-left side of the workspace. 1. On the Pinout view, expand the options for P0[1], P0[5, ]P1[2], and P1[3]. Configure the pins as shown in Figure 20. Figure 20. Pin Configuration 7.6 Build and Program In this step, you connect the MiniProg1 device to your computer, and the program the PSoC device with the built project. 1. Select Build > Generate/Build ‘AN75320’ Project or press F6. (See Figure 21). www.cypress.com Document No. 001-75320 Rev. *E 21 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Figure 21. Build and Generate Option 2. The output window should show the build status with RAM/Flash usage and number of errors and warnings as shown in Figure 22. Figure 22. Output Window 3. Connect MiniProg 1 / MiniProg 3 to your computer. 4. Connect the MiniProg 1 / MiniProg 3 to the programming header of the board. For details, refer to step 4 in section Setting Up the CY3210-PSoCEval1 Board. 5. Select Program > Program Part (See Figure 23). The Program Part window appears as shown in Figure 24. Figure 23. Program Part Option 6. On the Program Part window, do the following: a) Click the Connect button (next to the Port Selection field) to connect the device. b) Set the Acquire Mode to Power Cycle if the MiniProg is supplying power to the device and it can acquire the device by cycling power. This is the default option. For this project, use the default option. c) Set the Acquire Mode to Reset if the device is externally powered and the MiniProg can only acquire the device by resetting it. www.cypress.com Document No. 001-75320 Rev. *E 22 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 7. Click the Program button to program the device as shown in Figure 24. Figure 24. Programming Status 8. 7.7 When the program operation is completed, press the Power button to toggle power for the device. The programmer now supplies power to the board. Observe one LED flashing and another LED fading in and out. Setting Up the CY3210-PSoCEval1 Board This demonstration is compatible with the CY3210-PSoCEval1 hardware. For more information on this kit, see http://www.cypress.com/documentation/development-kitsboards/cy3210-psoceval1. Figure 25. A View of the CY3210-PSoCEval1 Kit www.cypress.com Document No. 001-75320 Rev. *E 23 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Perform the following steps to configure and program the CY3210-PSoCEval1 kit. Note that this kit requires a programming device, such as a MiniProg or ICE-Cube. 1. With no cables connected to the demo board, ensure that J1, J2, and J3 are not in position. 2. Place a wire connecting P0[1] to VR, P1[2] to LED1, and another wire connecting P1[3] to LED2 (see Figure 26). Figure 26. CY3210-PSoCEval1 Pin Connections 3. Ensure that a CY8C29466-24PXI is the device currently on the board. 4. To supply the board, connect the MiniProg 1 / MiniProg 3 to the programming header (J11). Alternatively, connect a 12-V DC power supply to J10 on the kit. Alternatively, you can connect a 9-V battery to J12. In addition, connect a programming device to J11. While using an external power supply or battery, use reset mode of programming. The board connections can be seen in Figure 27. Figure 27. Power and Program Connections www.cypress.com Document No. 001-75320 Rev. *E 24 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ 7.8 Setting Up the CY8CKIT-001 Board When you use a CY8C29x66 processor module, this demonstration is compatible with the CY8CKIT-001 hardware. For more information on this kit, see http://www.cypress.com/?rID=37464. Perform the following steps to configure and program the CY8CKIT-001 kit. Note that this kit requires a programming device, such as a MiniProg or ICE-Cube. Additionally, this kit supports on-chip debug when using the ICE-Cube. Figure 28. A View of the CY8CKIT-001 Kit 1. With no cables connected to the demo board, set the following jumpers to configure the development board as shown in Table 6: Table 6. Jumper Settings Jumper 2. Setting VDD Select (SW3) 5-V (Up Position) 5-V Source (J8) VREG (Upper two pins VDD Digital (J7) VDD (Upper two pins) VDD Analog (J6) VDD (Upper two pins) LCD Power (J12) ON (Lower two pins) VDDIO Select (J2-J5) VDD (Upper-left two pins) Place a wire connecting P0[1] to VR, P1[2] to LED1, and another wire connecting P1[3] to LED2 (See Figure 29). www.cypress.com Document No. 001-75320 Rev. *E 25 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Figure 29. Alternative View of Pin Connections 3. Connect a programming device, such as a MiniProg or ICE, to J5 on the PSoC 1 processor module. 4. Connect power to the board with either a 12-V DC power supply or a 9-V battery or using power from programmer. Ensure that while using an external power supply or battery, use reset mode of programming. See Figure 30 for board connections. Figure 30. Power and Program Connections www.cypress.com Document No. 001-75320 Rev. *E 26 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Regardless of which development kit you use to test the application, you will observe the following: 8 1. The LCD displays “Hello World” and “ADC INPUT:----mV” 2. One LED blinks rapidly. 3. The second LED pulses with the light intensity alternatively and slowly increasing and decreasing. Summary This application note has explored the PSoC 1 architecture and development tools. This also described the tools you need to start PSoC 1 projects. PSoC 1 is a true programmable embedded system-on-chip integrating configurable analog and digital peripheral functions, memory, and an M8C microcontroller on a single chip. This application note has also guided you to a comprehensive collection of resources to accelerate in-depth learning about PSoC 1. For more information on any of the topics mentioned, refer to any of the links or references made, or visit http://www.cypress.com/products/psoc-1. 9 Related Application notes This application note covers the basic details about PSoC 1. You can refer to specific application notes for more information and projects regarding a specific topic. Getting Started AN2096 - PSoC® 1 - Using the ADCINC Analog to Digital Converter AN2041 – Understanding PSoC 1 Switch Capacitor Analog Blocks AN2168 – PSoC 1 Understanding Switched Capacitor Filters AN16833 - Signal Mixing with PSoC® Switched Capacitor Blocks AN2094 - PSoC® 1 - Getting Started with GPIO AN44168 - PSoC® 1 Device Programming using External Microcontroller (HSSP). AN2141 - PSoC® 1 Glitch Free PWM Flash AN13666 - PSoC® 1 Driving Analog Buffer Output to the Rail Digital TM AN74170 – PSoC 1 Analog Structure and Configuration with PSoC Designer Programming AN2219 - PSoC® 1 Selecting Analog Ground and Reference GPIO AN77759 - Getting Started with PSoC 5LP Switched Capacitor Blocks AN79953 – Getting Started with PSoC 4 Analog AN54181 - Getting Started with PSoC 3 AN2015 - PSoC 1 Reading and Writing Flash & E2PROM I2C AN50987 – Getting Started with I2C in PSoC 1 www.cypress.com Document No. 001-75320 Rev. *E 27 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ SPI Sleep Mode AN51234 - Getting Started with SPI in PSoC® 1 AN47310 - PSoC® 1 Power Savings Using Sleep Mode LCD AN56384 - PSoC® 1 Segment LCD Direct Drive AN2152 - PSoC® 1 Graphics LCD and PSoC® Interface www.cypress.com Document No. 001-75320 Rev. *E 28 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Document History ® Document Title: AN75320 - Getting Started With PSoC 1 Document Number: 001-75320 Revision ECN Orig. of Change Submission Date Description of Change ** 3498585 RLRM 1/17/2012 New application note *A 3846596 GULA 12/19/2012 Updated project to PSoC Designer 5.3. Updated all the relevant screenshots. Removed incorrect mention of PSoC Creator Added references to all Application Notes and Technical Reference Manual. Corrected the SC-based Integrator circuit. Minor content edits. *B 4064460 GULA 07/16/2013 Updated the UM parameters screenshots Updated the board images Added a section on Auto-routing Added links for the App Notes and kits Replaced section on CY3215-DK with details about CY3215A-DK. Added Next Steps section for details about the specific App Notes *C 4365121 ASRI 04/29/2014 Updated all the section of the AN Added ADC functionally into AN project and modified the project Added links for the various document for PSoC 1 learning resources and kits *D 4617532 DIMA 01/14/2015 Added Get Started. Completing Sunset Review. *E 4905704 ASRI 09/02/2015 Minor updates in all the sections Added Figure 8, Figure 10 and Figure 22 Added links for documents in PSoC 1 learning resources Updated the project to PSoC Designer 5.4 SP1 Updated to new template Updated project to PSoC Designer 5.4 SP1. Updated all the relevant screenshots. www.cypress.com Document No. 001-75320 Rev. *E 29 ================ Getting Started With PSoC® 1 _________________________________________________________________________________________________________ Worldwide Sales and Design Support Cypress maintains a worldwide network of offices, solution centers, manufacturer‟s representatives, and distributors. To find the office closest to you, visit us at Cypress Locations. Products PSoC Solutions Automotive cypress.com/go/automotive psoc.cypress.com/solutions Clocks & Buffers cypress.com/go/clocks PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP Interface cypress.com/go/interface Cypress Developer Community Lighting & Power Control cypress.com/go/powerpsoc Memory cypress.com/go/memory PSoC cypress.com/go/psoc Touch Sensing cypress.com/go/touch USB Controllers cypress.com/go/usb Wireless/RF cypress.com/go/wireless Community | Forums | Blogs | Video | Training Technical Support cypress.com/go/support All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone Fax Website : 408-943-2600 : 408-943-4730 : www.cypress.com © Cypress Semiconductor Corporation, 2012-2015. 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. This 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 prohibited 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. www.cypress.com Document No. 001-75320 Rev. *E 30