PSOC 4 Overview
PSoC 4 is a microcontroller built by Cypress Semiconductor, which includes on-chip programmable analog and digital peripherals and an internal routing architecture to connect the peripherals and physical pins to an internal ARM Cortex-M0 processor core. The PSoC programmable hardware features are defined using Cypress's PSoC Creator software suite. PSoC Creator includes a schematic capture interface to define, connect, and configure the programmable blocks, and an IDE for writing C code that runs on ARM processor within the PSoC.
Development Tools Installation
In program the PSoC devices, the following software is required:
- MS Windows XP, 7, or 8
- IE7 or higher
- .NET framework 2.0 SP2 or higher
- PSoC Creator http://www.cypress.com/psoccreator/
- USB-Serial SDK http://www.cypress.com/?docID=47673
PSoC Creator requires an account on cypress.com. Obtaining an account and registering the software is free.
After installing both PSoC Creator and the USB-Serial SDK, hold the button on the PSoC 4200 prototyping kit and plug it into a USB port. Check the Windows Device Manager to see if a new "USB Serial Port (COM#)" shows up under "Ports (COM & LPT)". If so, you should be able to upload programs to the board from PSoC Creator.
The board may show up as "USB-Serial" devices with missing drivers, such as this:
To fix this, right click on each new device, select "Update Driver Software...", and manually select the location of the Cypress USB SDK installation folder:
Example Project Workflow
The following walkthrough implements an example design using a T flip-flop to toggle an LED each time a button is pushed. The code archive can be found below in the Project Examples section.
Create A New Project
Open PSoC Creator. Click File>New>Project....
In the New Project dialog, select Empty PSoC 4 Design, edit the name of the project/workspace, and set the project as Bootloadable in the advanced section. The bootloadable component is required when using the small PSoC 4200 prototyping kit since it does not have built in USB debugging functionality.
Add Hardware Components
The new project opens by default with the schematic editor window. Use the component tree on the right side of the screen to drag components onto the blank schematic. This example uses:
- Digital Output Pin
- Digital Input Pin
- Toggle Flip-Flop
- Logic High
Arrange the components and connect them using the wire tool. The wire tool can be selected either with the toolbar on the left hand side of the editor, or by pressing the w hot-key.
Note: The blue components (GND, resistor, switch, LED) are for documentation purposes only. They can be found in the Off-Chip tab of the component tree. In order to connect the off-chip components to the pins, you will need to change a setting in the pin configuration dialog- see Configure Pins below.
Double click on the Bootloadable component in the schematic. This will open the settings configuration dialog for the component. Click on Browse... to select the Bootloader Hex file that you want to use as a bootloader on the device.
The bootloader Hex file can be obtained from the Cypress website in the Example Projects file for the CY8CKIT-49-42xx kit: [Example Projects for CY8CKIT-49-42xx]
Extract the example project files and select the bootloader Hex file at <extracted folder location>\CY8CKIT-049-42xx Example Projects\SCB_Bootloader_42xx\UART_Bootloader.cydsn\CortexM0\ARM_GCC_473\Debug\UART_Bootloader.hex. The Bootloader ELF File should auto populate.
Double click on the Digital Input pin. This will open the settings configuration dialog for the pin. You can change the name of the pin here. Check the Show External Terminal box to enable the connection of off-chip documentation components in the schematic.
Click on the General tab in the pin configuration dialog. Since the input switch is connected to ground when closed and floats when opened, the input pin needs to be configured as Resistive Pull Up.
The same configuration can be done to rename the output pin. For the output pin, the drive mode can be left as Strong Drive since it will be driving an LED.
To associate the pins in the schematic with physical pins on the chip, open the .cydwr design-wide resource file from the project file hierarchy on the left of PSoC Creator. In this file you can drag and drop pin names from the list on the right and place them on physical pins of the chip in the package view.
Click Build>Build <ProjectName> in the PSoC Creator menu. This will implement the hardware design and compile any code necessary to access any of the hardware objects from your software. The output log at the bottom of the screen should show you if compilation was successful and alert you of any errors. At this point, if you have software routines to add to the design, you could insert them into the main.c file in the project file hierarchy.
Upload To Chip
To program the design to the CY8CKIT-49-42xx, you can use the Bootloader Host Tool under Tools>Bootloader Host... in the PSoC Creator menu. Hold the user button on the prototyping kit and plug it into a USB port. The Bootloader Host tool should show the board as USB Serial Port (COM#). If it does not, you may need to revisit the USB driver installation procedures.
Use the ... browse button or the folder icon in the bootloader host window to select the .cyacd for your project. Then use the arrow icon to upload the design to the CY8CKIT-49-42xx board. After the upload is complete, the chip should reboot and run your program.
- File:ToggleFlipFlop.cywrk.Archive01.zip - A hardware only design that toggles the LED each time the button is pushed
- File:SoftwareBlink.cywrk.Archive01.zip - A software only design that toggles the LED every 500ms
- File:TimerPWM.cywrk.Archive01.zip - A design using multiple hardware peripherals, triggering interrupts, and modifying parameters via software to make a pulsating LED