KB 01: Create a PSoC Project using PSoC Creator
This lesson does the following:
- Demonstrates how PSoC can be programmed to do more than a traditional MCU
- Shows how to use PSoC Creator to create, modify, program, and debug PSoC 5LP projects.
- Provides detailed steps that make it easy to learn PSoC design techniques using the PSoC Creator IDE
Reference DOCs
- PSoC Creator User Guide (V15.00)
- PSoC Creator Quick Start Guide (v18.00)
- PSoC5LP System Reference Guide (V5.90)
This lesson takes you through the design processor, step by step. It guides you through both hardware and firmware design entry.
These instructions assume that you are using PSoC Creator 4.x. The overall development process is the same for other versions of PSoC Creator. However, some of the dialog boxes may be different.
1. Create a New Project
Create a New Project
A project contains all the source code and files required to create a single output module that can be downloaded to a target PSoC 5LP device.
Start PSoC Creator
Find the PSoC Creator 4.x icon to launch the tool by using one of the following methods:
- On the Windows desktop, find the PSoC Creator icon and double-click on it.
- Launch PSoC Creator from Windows Start Menu.
- Use the Windows Start key and type "PSoC Creator" to locate the PSoC Creator, then click on it.
Create New Project
The first step of creating a design is using New Project Wizard to create a new PSoC project. The New Project Wizard will do the following items:
- Select the kit, module, or device
- Select the type of project to create
- Specify the project name and location
- Choose whether to create a new Workspace or add to an existing Workspace
Follows the next steps to open the wizard dialog and configure for a new project:
- To start a new project, you can either:
- Click the "Create New Project..." link on the PSoC Creator Start Page
- Click the Create New Project button
in the menu bar, or
- From the File menu and select "New ➤ Project ..." to open the NEW Project Wizard
- In the "Create Project" dialog, you need to select one of the following types of target device:
- Target kit: Use this option to select a specific kit or the last used kit.
- Target module: Use this option to select a specific module or the last used module.
- Target device: Use this option to select a device family and series, the last used device, or to launch the Device Selector.
- If you are using CY8CKIT-059 Kit, and you have installed the design kit file. You can click "Target kit" and select "CY8CKIT-059 (PSoC 5LP)".
- If you did not install design kit file, or you are using another PSoC 5LP development board, you have to click on "Target device:", select chip type to "PSoC 5LP", and select chip family to "CY8C58LP" or "<Launch Device Selector...>". Or, You can select the specific device you want to use.
- If you select "<Launch Device Selector...>", the system will launch the "Device Selector". It will pull up a list of all the various PSoC5LP parts. Find the exact chip number that is used on the PSoC5LP board, click it to highlight the line, and click OK.
You should probably never need to change this again unless you change to use another PSoC development board. PSoC Creator remembers the parts you have used in the past.
- Next, in the "Select project template" dialog, select an Empty schematic as a project template.
- In the next dialog, you have to enter text for a Workspace name. A workspace is a container for one or more projects. A project is usually contained in a workspace.
- In the Workspace name field, type the name of the Workspace, for example: "PSoC5LP_Lab".
- In the Location field, type the path where you want the project to be saved, or click
and navigate to the appropriate directory.
- In the Project name field, type the name of your project, for example: "MyFirstPSoC".
PSoC Creator organizes applications into Workspace that can contain one or more projects.
- Click Finish button, then PSoC Creator will create a new directory in the "Location" field and create a subdirectory for Workspace. In the Workspace subdirectory, the Project directory will be created.
- After PSoC Creator creates all the folders and files, the main windows will show on the screen, and several new panes are displayed: Workspace Explorer, Schematic (TopDesign.cysch), and Component Catalog.
- By default, PSoC Creator creates a new workspace containing the new project. Files and folders are added to the Workspace Explorer shown in the Source tab.
- In the document panel, the Schematic Editor displays the top-level schematic file (TopDesign.cysch).
- The Component Catalog panel opens to display a list of Components that can be used in your design.
2. Device Selector
Device Selector
If you change the PSoC development board, or you copy
- In the Workspace Explorer panel, expand the "Design Wide Resources (.cydwr)" folder and double-click on the Pins to open the Resource file on the Pins tab. You will see the device pin assignments and device number.
- Make sure the device number is the same as the chip number on your PSoC 5LP board. If different, you can click Project from the menu, then choose Device Selector to open the Device Selector dialog.
- On the Device Selector window, click on the device number that is used on your PSoC 5LP board to highlight it, then click OK. After you select the correct device number, you do not need to change it again unless you use a different PSoC 5LP board.
3. Add/Configure Component
Add/Configure Component
In this step, you drag Components from the Component Catalog onto the Schematic. You then configure each Component and wire them together.
- Cypress Components are always installed. These are developed by Infineon (Cypress) for use in your designs.
- Off-Chip or "External" Components, if installed, are used to document connections the device may have on the development board. They are used for documentation purposes only.
- In the Component Catalog panel, expand the "Digital ➤ Functions" folder and drag a PWM Component onto your TopDesign.cysch.
- Double-click the PWM Component to open the "Configure" dialog, change the Implementation setting to "Fixed Function", and click OK.
- In the Component Catalog, expand the "Digital ➤ Logic" folder, drag a Logic Low '0' Component onto your design, and connect it to the kill terminal on the PWM. Connect another Logic Low '0' to the reset terminal.
You can select the Wire Toolto connect the logic (or press 『w' as a shortcut). The wire is Green, it means that is a digital connection.
- In the Component Catalog, expand the "System" folder, drag a Clock Component onto your design, and connect it to the clock terminal on the PWM.
- Double-click the Clock to open the Configure dialog, change the Frequency value to 250 Hz, and click OK.
- In the Component Catalog, expand the "Ports and Pins" folder, drag a Digital Output Pin Component onto your design, and connect it to the pwm terminal on the PWM.
4. Assign Pins and Connect Hardware
Assign Pins and Connect Hardware
At this point, the hardware design is complete. However, the Pin Component must still be associated with a physical pin.
If you did not assign any pins, after you click Generate Application or Build your project from the Build menu, the PSoC Creator would automatically assign the pin to a physical port/pin on the device. To specify a specific pin, use the Pin Editor to assign the pin for the component.
- In the Workspace Explorer window, expand the "Design Wide Resources (.cydwr)" folder in your project and double-click on the Pins to open the Design Wide Resource (DWR) Pin Editor.
- Pull down the menu in the Port or Pin column and assign Pin_1 to the following pin, depending on the kit you are used:
- You will notice that many pins have some extra text associated with their port/pin information; for example, P1[2] is also labeled as 「XRES[0]:opt」. These are special functions that can be associated with the pin for improved performance rather than mandates that a given pin be used for a specific function.
5. Generate Application
Generate Application
Before you write the code, you have to let PSoC Creator generate all the necessary API files to support the hardware components that you placed in the schematic earlier. To do that, choose the "Generate Application" item in the Build function.
- Select the PSoC Creator menu item Build➤Generate Application, or click the icon (
) on the toolbar.
- If there is no error, PSoC Creator generates several code files under the folder Generated_Source. These are the support files for the components. Do not edit them. They are, in fact, just standard C files, and you could rework them to fit your needs, but the IDE can, and does, frequently regenerate those files, which would wipe out any changes you've made.
7. Write C Code
Write C Code
Add code to the auto-generated file main.c.
- In the Workspace Explorer panel, double-click the main.c file in your project to open it on the Document window.
- Add the following function to main():
PWM_1_Start();
This code assumes that the PWM Component has the default name. If you renamed your PWM Component to something other than the default value, use those names in the _Start() function call.
/* ======================================== * * Copyright YOUR COMPANY, THE YEAR * All Rights Reserved * UNPUBLISHED, LICENSED SOFTWARE. * * CONFIDENTIAL AND PROPRIETARY INFORMATION * WHICH IS THE PROPERTY OF your company. * * ======================================== */ #include "project.h" int main(void) { CyGlobalIntEnable; /* Enable global interrupts. */ /* Place your initialization/startup code here (e.g. MyInst_Start()) */ PWM_1_Start(); for(;;) { /* Place your application code here. */ } } /* [] END OF FILE */
8. Program the Device
Program the Device
The programming process is the same for all the development kit boards.
- Connect the programmer to your PSoC 5LP development board and plug it into your PC with a USB cable.
- Confirm the programmer is connected with PSoC Creator through the USB port.
Select the PSoC Creator menu item Debug ➤ Select Debug Target... A "Select Debug Target" dialog is displayed
CY8CKIT-059 Kit
CY8CKIT-059 already has an onboard programmer, so just plug the CY8CKIT-059 kit into your PC with a USB extension cable.
- Click the Program button (
) in the menu bar.
- If the Select Debug Target dialog displays, select your device, then click Connect and OK.
PSoC Creator will build your design, generate code, and program the device. When programming is complete, the selected LED on the board will blink; press the Reset button if needed.