CY8C28xxx PSoC Rocks! | Cypress Semiconductor
CY8C28xxx PSoC Rocks!
This example project mimics the classic beginner program, ‘Hello World’, but in this case we are announcing that, ‘PSoC Rocks!’ This example will introduce the user to the CY8CKIT-001 hardware, PSoC Designer software, and help the user create a very simple and easy to understand project.
The classic ‘Hello World’ program is widely used as an entry level coding example to new and first time users. This example program involves the user creating a program that prints or reports a phrase to some display. In this example we will be printing ‘PSoC Rocks!’ to an LCD screen using our CY8CKIT-001 development kit.
This example project will utilize the following hardware.
- CY8C28xxx Device Family Processor Module (CY8CKIT-020)
- Miniprog3 (CY8CKIT-002)
- LCD Module
All of the above hardware is included in the CY8CKIT-001.
Steps to Set Up Hardware:
To set up this hardware please perform the following actions:
- Insert the CY8CKIT-020 processor module into the CY8CKIT-001 socket.
- Insert the LCD Module into the module socket.
Steps to Create Project
To begin the example project create a new project using PSoC Designer.
- Open PSoC Designer by navigating Start -> All Programs -> Cypress -> PSoC Designer 5.x-> PSoC Designer 5.x. This will launch the PSoC Designer application.
- In the Recent Projects window at the top left please select the New Project… link.
In the New Project window please enter in the name of the project “CY8C28445_PSoC_Rocks”. Please select the project location by selecting the Browse button. Click OK.
The Select Project Type window will open. You can either click the drop down menu to select the target device or launch the device catalog by clicking the View Catalog button. We will be selecting the “CY8C28445-24PVXI” device.
- If you select the parts via the View Catalog option then please scroll down to the “CY8C28445-24PVXI” device and select the Select button.
- You will return to the Select Project Type window. Please select the “C” radio button for main.c file generation. This will mean that you will be developing a C-based project rather than an assembler based project. Select OK.
After you select the OK button PSoC Designer will open the Chip Editor view. In the following section we will cover the various options and actions available in the Chip Editor view. We will begin setting parameter values and designing our system.
Introduction to the Chip Editor View
After creating the project PSoC Designer will present the user with the Chip Editor view. The default layout includes six important windows. They are numbered in the figure below.
- Global Resources: Global settings for the target PSoC device.
- Parameters: When a User Module is placed this window will have selection options that pertain to the chosen User Module
- Pinout: This window provides pinout parameter selection and naming options for all of the pins on the selected PSoC.
- Chip Editor: This section includes all of the digital and analog blocks available on the PSoC along with the available row inputs and outputs. Each PSoC device will differ in the number of blocks available. More will be discussed in subsequent sections on this topic. Users can zoom in on the display using Ctrl+Click, zoom out of the display using Ctrl+Shift+Click, and pan the display using Alt+Click.
- Workspace Explorer: Lists all of the User Modules, source files and project structure.
- User Modules: Treed listing of available users modules for chosen device. This list changes depending on the device selected.
For additional information on the Chip Editor window and the dockable secondary windows please see the PSoC Designer User Guide included with every installation.
User Module Placement and Configuration
In this section we will discuss how to design the embedded system by setting global parameters for the PSoC, adding User Modules, and making pin selections.
- Please navigate to the User Module window and select Misc Digital>LCD. Right click on LCD and select Place. You will notice that the Workspace Explorer window was updated and now lists the LCD user module, “LCD_1”.
- Select the LCD user module in the Workspace Explorer. You will notice that the User Module Parameters window updates and now offers selections pertaining to the LCD user module.
Under the Parameters window please rename the user module from “LCD_1” to “LCD”. Set the LCDPort value to Port_2. Leave the BarGraph selection set to Enable.
After making our selections above one will notice that the Port_2 pins have been consumed in the Chip Editor and Pinout windows. The LCD user module is a firmware only user module and does not use any Digital or Analog block resources.
- Now that all of the user module placement and configuration is complete we need to generate the project source files based on our selections. Please navigate to the menu panel and select the Generate Configuration Files button. The output window will display the actions when generating the configuration files and report any design rule check (DRC) warnings. DRC warnings are used to warn the user if they have selections in their project that are outside of the best practices.
Now that we have completed the user module selection and configuration we will proceed to add source code to call the user module code we generated.
Adding Source Code
When generating the project we selected that the project be generated for C language development. We will now add our C code to the main.c file.
Navigate to the Workspace Explorer window, expand the source files directory and double-click the main.c file.
- The main.c file is now open in the editor tab window. Users will notice that the Workspace Explorer is still available on the right side of the window and users can navigate between the text editor and the Chip Editor by using the tabs at the top of the editor window below. Users can open additional files by double-clicking in the Workspace Explorer. These files will open as new tabs.
To enable and use the LCD user module we need to add code to our Main function. This code will execute and display the string on the LCD screen. The code is linked below and should be added into the main function.
char theStr = "PSoC Rocks!"; // Define RAM string
LCD_Start(); // Initialize LCD
LCD_Position(0,0); // Place LCD cursor at row 0, col 0.
LCD_PrString(theStr); // Print the value held by theStr to the LCD
Once the code has been entered into the main.c file we will then build the project by selecting Build>Generate/Build, pressing F6, or by selecting the Build button . As a general note PSoC Designer comes with a free unlimited compiler from ImageCraft.This standard compiler is set as a default. For more information please see the PSoC Designer release notes and/or the PSoC Designer Compiler User Guide included in the Designer installation.
- The build status will be displayed in the Output window. The output window will display either a successful build or a list of build errors associated with the project. In this case we will have no build errors.
- Next we will want to set up our kit so we can program our project onto our target device. First make sure that the Miniprog3, included in the CY8CKIT-001 kit, is connected to the white 5-pin programming connector on the CY8C28xxx family processor module (CY8CKIT-020). Make sure that the Miniprog3 is also connected to the PC using the USB cable.
Once the Miniprog3 has been connected to the PC and the target board please select Program>Program Part from inside PSoC Designer. This will launch he PSoC Designer embedded programmer. Please choose the Power Cycle radio button under the Acquire Mode and then select the Program button, which is located at the bottom right of the embedded programmer. Once programming begins all of the features will be grayed out save the Abort button.
- Now that the device is programmed we want to power the CY8CKIT-001 and see the message displayed on the LCD screen. We can power our target board using the Miniprog3. To do this keep the Embedded Programmer open and select the Toggle Power button . You should see that the message, “PSoC Rocks!”, is now displayed on the LCD screen.
Summary of the Project:
The goal of this project was to introduce the user to the PSoC Designer software tool, creating a new project, selecting and configuring user modules, and programming a target device. In this example we were able to quickly create an embedded program and utilize the pre-defined code delivered with each user module to achieve an end goal of displaying a message on an LCD screen. Please see the related projects for additional example projects.
LED Blinky: The user will interface with a button to control and flash an LED
DIM LED: The user will utilize a pulse width modulator (PWM) to dim an LED
ADC LCD: Use a potentiometer to display an analog voltage value on an LCD screen.