Page 2
Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from or related to all Unintended Uses of Cypress products.
Safety Information Regulatory Compliance ® The CY8CKIT-040 PSoC 4000 Pioneer Kit is intended for use as a development platform for hardware or software in a laboratory environment. The board is an open system design, which does not include a shielded enclosure. For this reason, the board may cause interference to other electrical or electronic devices in close proximity.
Page 6
General Safety Instructions ESD Protection ESD can damage boards and associated components. Cypress recommends that the user perform procedures only at an ESD workstation. If an ESD workstation is not available, use appropriate ESD protection by wearing an antistatic wrist strap attached to the chassis ground (any unpainted metal surface) on the board when handling parts.
Introduction ® Thank you for your interest in the PSoC 4000 Pioneer Kit. The kit is designed as an easy-to-use and inexpensive development kit, highlighting the unique flexibility of the PSoC 4000 architecture. Designed for flexibility, this kit offers footprint compatibility with several third-party Arduino™ shields. In addition, the board features an RGB LED, integrated USB programmer/debugger, a program/ ®...
Page 8
Introduction Figure 1-1. Kit Contents Inspect the contents of the kit; if you find any part missing, contact your nearest Cypress sales office for help: www.cypress.com/go/support. Download the latest version of the kit setup file from www.cypress.com/CY8CKIT-040. ® CY8CKIT-040 PSoC...
Figure 1-2. PSoC Creator Features PSoC Creator also enables you to tap into an entire tool ecosystem with integrated compiler chains and production programming programmers for PSoC devices. For more information, visit www.cypress.com/psoccreator. Visit PSoC Creator training page for video tutorials on learning and using PSoC Creator.
Introduction 1.2.1 PSoC Creator Code Examples PSoC Creator includes a large number of code examples. These examples are available from the PSoC Creator Start Page, as Figure 1-3 shows. Code examples can speed up your design process by starting you off with a complete design, instead of a blank page.
Introduction Figure 1-4. Code Example Projects with Sample Code 1.2.2 Kit Code Example In addition to the examples built into PSoC Creator, this kit includes a simple example, which can be used to quickly evaluate the functionality of this kit. The example is described in the Code Examples chapter on page 49.
Introduction 1.2.3 PSoC Creator Help Visit the PSoC Creator home page to download the latest version of PSoC Creator. Then, launch PSoC Creator and navigate to the following items: Quick Start Guide: Choose Help > Documentation > Quick Start Guide. This guide gives you ■...
Introduction Technical Support If you have any questions, you can create a support request at 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 num- ber: +1-800-541-4736.
Software Installation This section describes the installation of the CY8CKIT-040 PSoC 4000 Pioneer Kit software and the prerequisites. Before You Begin All Cypress software installations require administrator privileges. However, this is not the case for installed software. Before you install the kit software, close any other Cypress software that is cur- rently running.
Page 16
PSoC Creator 3.2 Service Pack 1 or later: Download the latest version from www.cypress.com/psoccreator. b. PSoC Programmer 3.23.1 or later: Download the latest version from www.cypress.com/programmer. c. Cypress Document Manager 1.0 Service Pack 1 or later: Download the latest version from www.cypress.com/cypressdocumentmanager. ® CY8CKIT-040 PSoC...
<Install_Directory>\CY8CKIT-040 PSoC 4000 Pioneer Kit\<version> Default location: Windows 7 (64-bit): C:\Program Files (x86)\Cypress\CY8CKIT-040 PSoC 4000 Pioneer Kit\<version> Windows 7 (32-bit): C:\Program Files\Cypress\CY8CKIT-040 PSoC 4000 Pioneer Kit\<version> Note: For Windows 7/8/8.1 users, the installed files and the folder are read only. To change the property, right-click the folder and choose Properties >...
Software Installation Uninstall Software You can uninstall the CY8CKIT-040 PSoC 4000 Pioneer Kit software using one of the following methods: Go to Start > All Programs > Cypress > Cypress Update Manager > Cypress Update Man- ■ ager. Select the Uninstall button that corresponds to the kit software.
Kit Operation Kit USB Connection The PSoC 4000 Pioneer Kit connects to the PC over a USB interface (see Figure 3-2). The kit enu- merates as a composite device and three separate devices appear under the Device Manager in the Windows operating system. See Table 3-1, and Figure...
Kit Operation Programming and Debugging PSoC 4000 The kit allows programming and debugging of the PSoC 4 device in two modes: 3.3.1 Using the Onboard PSoC 5LP Programmer and Debugger ■ 3.3.2 Using the CY8CKIT-002 MiniProg3 Programmer and Debugger ■ 3.3.1 Using the Onboard PSoC 5LP Programmer and Debugger The default programming interface for the kit is a USB-based, onboard programming interface.
Kit Operation 3. The kit’s onboard programmer will enumerate on the PC and in the software tools as KitProg. Open an example project in PSoC Creator (such as Project: Blinking LED on page 54) and initiate the build by choosing Build > Build Project or pressing [Shift] [F6]. See Figure 3-6.
Page 24
Kit Operation Note The CY8CKIT-002 MiniProg3 is not part of the PSoC 4000 Pioneer Kit contents. It can be pur- chased from the Cypress Online Store. Figure 3-8. PSoC 4 Programming/Debug Using MiniProg3 Figure 3-9. MiniProg3 Configuration in PSoC Creator Note: Ensure that both MiniProg3 (with or without power) on header J6 and KitProg are not con- nected to the onboard PSoC 4 at the same time.
Kit Operation USB-I C Bridge The PSoC 5LP also functions as a USB-I C bridge. The PSoC 4 communicates with the PSoC 5LP using an I C interface, and the PSoC 5LP transfers the data over the USB to the USB-I C software utility on the PC called the Bridge Control Panel (BCP).
Kit Operation To use the USB-I C functionality, select the KitProg USB-I C in the BCP (Figure 3-10). On success- ful connection, the Connected and Powered status boxes turn green (Figure 3-11). Figure 3-11. KitProg USB-I C Connected in Bridge Control Panel USB-I C is implemented using the USB and I C components of PSoC 5LP.
167), PSoC Programmer displays a warning indicating that new firmware is available. Open PSoC Programmer from Start > All Programs > Cypress > PSoC Programmer<version>. When PSoC Programmer opens, a WARNING! window pops up saying that the programmer is cur-...
Page 28
Kit Operation Click OK to close the window. On closing the warning window, the Actions and Results window dis- plays Please navigate to the Utilities tab and click the Upgrade Firmware button, as shown in Figure 3-13. Figure 3-13. Upgrade Firmware Message in PSoC Programmer Click the Utilities tab and then the Upgrade Firmware button.
Figure 4-4. Figure 4-4. Block Diagram PSoC 4 is a new generation of programmable system-on-chip devices from Cypress for embedded applications. The PSoC 4000 family is the smallest member of the PSoC 4 platform with CapSense, TCPWM, I C master or slave, and up to 20 GPIOs support. PSoC 4000 is a cost-optimized, entry- level PSoC4 device targeted as socket replacements for obsolete and/or proprietary 8-bit and 16-bit MCUs.
■ Deep Sleep mode with wake-up on interrupt and I2C address detect ❐ Capacitive Sensing ■ Cypress Capacitive Sigma-Delta (CSD) provides best-in-class signal-to-noise ratio (SNR) and ❐ water tolerance Cypress-supplied software component makes capacitive sensing design easy ❐ Automatic hardware tuning (SmartSense™) ❐...
Page 34
Hardware Industry-Standard Tool Compatibility ■ After schematic entry, development can be done with ARM-based industry-standard develop- ❐ ment tools 4.3.1.2 PSoC 5LP An onboard PSoC 5LP (CY8C5868LTI-LP039) is used to program and debug PSoC 4. The PSoC 5LP connects to the USB port of the PC through a USB Mini-B connector and to the SWD interface of the PSoC 4 device.
Page 35
Hardware Digital peripherals ■ 20 to 24 programmable logic device (PLD)-based universal digital blocks (UDBs) ❐ Full CAN 2.0b 16 RX, 8 TX buffers ❐ Full-Speed (FS) USB 2.0 12 Mbps using internal oscillator ❐ Four 16-bit configurable timers, counters, and PWM blocks ❐...
Page 36
Hardware Precision, programmable clocking ■ 3- to 62-MHz internal oscillator over full temperature and voltage range ❐ 4- to 25-MHz crystal oscillator for crystal PPM accuracy ❐ Internal PLL clock generation up to 67 MHz ❐ 32.768-kHz watch crystal oscillator ❐...
Page 38
Hardware Protection Circuit The power supply rail has reverse-voltage, overvoltage, short circuits, and excess current protection features, as seen in Figure 4-5. The Schottky diode (D4) ensures power cannot be supplied to the 5-V domain of the board from ■ the I/O header.
Page 39
Hardware When using a separate power supply for the PSoC 4 with USB powering (regulator output on the ■ USB supply must be within 0.5 V of the separate power supply), remove jumper J13. Connect the positive terminal of voltage supply to the positive terminal of the ammeter and the negative termi- nal of the ammeter to the lower pin (P4.VDD) of J13.
Page 40
Hardware 4.3.1.5 Arduino Compatible Headers (J1, J2, J3, J4, and J12) This kit has five Arduino compatible headers: J1, J2, J3, J4, and J12. You can develop applications based on the Arduino shield's hardware. An Arduino shield compatible Trackpad board is also sup- plied with the kit.
Page 41
Hardware Figure 4-9. Arduino Compatible Headers Functionality of Unpopulated Header J12 The J12 header is a 2×3 header that supports Arduino shields. This header is used on a small sub- set of shields and is unpopulated on the PSoC 4000 Pioneer Kit. Note: The J12 header functions only in 5 V mode.
Page 42
Hardware 4.3.1.6 PSoC 5LP GPIO Header (J8) A limited set of PSoC 5LP pins are brought to this header. Refer to Developing Applications for PSoC 5LP on page 130 for details on how to develop custom applications. See Pin Assignment Table on page 163 for pin details.
Page 43
Hardware 4.3.1.7 CapSense Circuit The baseboard contains a header (J5) for CapSense proximity wire connection (see Figure 4-12). A 2.2-nF capacitor (C1) is present on CMOD pin, P0[4], for CapSense operation. An optional resistor R1 can be loaded to convert the current output from IDAC to a voltage output in non-CapSense applications.
Page 44
Hardware 4.3.1.8 Board LEDs The PSoC 4000 Pioneer Kit board has three LEDs. A green LED (LED2) indicates the status of the programmer. See KitProg Status LED States on page 167 for a detailed list of LED indications. An amber LED (LED1) indicates the status of power supplied to the board. The kit also has a general- purpose tricolor (RGB) LED (LED3) for user applications that connect to specific PSoC 4 pins.
Page 45
Hardware Figure 4-15. Status LED and RGB LED 4.3.1.9 Push Buttons The kit contains only a Reset push button, as shown in Figure 4-16. The Reset button is connected to the XRES pin of PSoC 4 and is used to reset the onboard PSoC 4 device. The push button con- nects to ground on activation (active low).
Page 46
Hardware 4.3.1.10 Cypress Ferroelectric RAM (F-RAM) The baseboard contains an F-RAM device (FM24W256); see Figure 4-17, which can be accessed through I C lines by either of the PSoC devices – PSoC 5 LP or PSoC 4 – or by both. The F-RAM is 256 Kb (32 KB) in size with the I C speed up to 1 Mbps.
Hardware 4.3.2 CY8CKIT-040 CapSense Trackpad Shield Board The kit also includes an Arduino-compatible CapSense Trackpad shield board. The Trackpad in the kit is a 6x5 elements capacitive sensing array. Figure 4-18 shows the pin mapping of the Trackpad. The modulation capacitor (Cmod) used for CapSense is connected to pin P0[4], and an optional bleeder resistor (R1) can be connected across the Cmod.
54. Follow these steps to open and program an example project: 1. Launch PSoC Creator from the Windows Start menu (Start > All Programs > Cypress > PSoC Creator<version> > PSoC Creator<version>). 2. Open the example project by clicking <Project_name>.cywrk below Examples and Kits > Kits >...
Page 50
Code Examples 3. Build the code example by choosing Build > Build CY8CKIT_040_Blinking_LED.cywrk to gen- erate the hex file, as shown in Figure 5-2. Figure 5-2. Build Project from PSoC Creator 4. To program, connect the board to a computer using the USB cable connected to port J10, as described in Kit USB Connection on page 21.
Page 51
Code Examples 6. If the device is not yet acquired, PSoC Creator will open the Select Debug Target window. Select KitProg/<ID> and click the Port Acquire button, as shown in Figure 5-4. Figure 5-4. Acquire Device from PSoC Creator 7. After the device is acquired, it is listed in a tree structure below the KitProg (see Figure 5-5).
Page 52
Code Examples 8. Click OK to exit the window and start programming, as shown in Figure 5-6. Figure 5-6. Program Device from PSoC Creator Notes: The Debug port is disabled by default in one of the example projects (Project: CapSense Proxim- ■...
Page 53
Code Examples Figure 5-7. R57 Location on the Board Figure 5-8. Debug Port Pin Functionality Selection ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Code Examples Project: Blinking LED 5.2.1 Project Overview The CY8CKIT_040_Blinking_LED.cyprj example uses a PWM block to blink the red LED of the RGB LED, as shown in Figure 5-9. The PWM output is connected to pin P3_2 (red) of the RGB LED. The PWM block is configured as a digital clock signal generator with a frequency of 1 Hz.
Code Examples 5.2.2.2 Firmware Details Figure 5-11 shows the flow chart of code implemented in main.c. Figure 5-11. Blinking LED Project Flow Chart Start Initialize and Start PWM component Put CPU to sleep 5.2.2.3 Hardware Connections No specific hardware connections are required for this project because all connections are hard- wired on the board.
Code Examples Project: CapSense Proximity and UART 5.3.1 Project Overview The project CY8CKIT_040_Proximity_UART.cyprj implements a capacitive proximity sensor con- trolling the brightness of a LED. The project configures the sensor as a CapSense proximity widget with SmartSense Auto-tuning. Firmware Details on page 61 presents the firmware flow and explains the firmware blocks in detail.
Code Examples 5.3.2 Project Description 5.3.2.1 PSoC Creator Component Configuration CapSense The CapSense Component is configured in SmartSense Auto-tuning mode with one proximity sen- sor for the design with the parameters shown in Table 5-2. Table 5-2. CapSense Component Parameters Parameter Tab Present Value...
Page 59
Code Examples Component to generate the proper period macro for the 15-bit PRSm. Though the output of PRSm has a variable frequency with a maximum frequency of 8 MHz (16 MHZ/2), the repeat rate of PRSm is considered to be the period in this context. Note: The Compare value should be a minimum of '1';...
Page 60
Code Examples TX (Software TX UART) The software transmit TX is used to send out proximity sensor related data for debugging. The con- figuration for the component is shown in Figure 5-15. The TX pin is selected in firmware through the TX_PORT/TX_PIN macros defined in the main.h file.
Page 61
Code Examples 5.3.2.2 Firmware Details Firmware Structure The firmware is written in a modular format, with different aspects of the functionality provided as separate functions for easy understanding. The header provides a list of handy macros for configur- ing the project's key aspects according to user requirements. The comments in the header file pro- vide the details on the macro.
Page 62
Code Examples The firmware does the following: The CapSense/input initialization part tunes the CapSense system parameters using Smart- ■ Sense. The output initialization part configures the PWM and the software UART TX output. ■ The infinite loop code is divided into two phases: input process and output process. ■...
Page 63
Code Examples Table 5-4 provides a quick reference to some key CapSense Component variables/arrays. Table 5-4. CapSense Component Key Variables Variable/Array Name Description Usage This array contains the raw data for each sensor. The array size is equal to the total number of sen- sors (CapSense_TOTAL_SENSOR_COUNT).
Page 64
Code Examples Table 5-5 provides a quick reference to some key CapSense Component macro definitions. Table 5-5. CapSense Component Macros Macro Format Sample Description CapSense_TOTAL_SEN- Defines the total number of sensors – SOR_COUNT within the CapSense Component. The constant denotes the sensor number of a sensor in the CapSense block.
Page 65
Code Examples Table 5-6. CapSense Component APIs Description/Usage The API sets the CapSense block settings for the selected widget and void CapSense_ScanWidget(uint32 starts scanning the widget. widget) It can be used if scanning of only an individual widget is desired. The API scans the selected sensor.
Page 66
Code Examples 5.3.2.3 Hardware Connections A wire in the form of a loop is connected to jumper J5 (P2_0), as shown in Figure 5-17. To enable the UART TX connection to the PSoC 5LP USB-UART bridge, make sure R57 is populated on the board (by default it is populated on the board).
0x00 0xFF 0xFF Follow these steps to set up the BCP for viewing the data: 1. Open the BCP software available from All Programs > Cypress > Bridge Control Panel <ver- sion> > Bridge Control Panel <version>. ® CY8CKIT-040 PSoC...
Page 68
Code Examples 2. Route the TX pin of the device to any available RX that can connect to the PC COM port. CY3240 (refer to AN2397) or KitProg in CY8CKIT-040 can be used for this purpose. Note: In CY8CKIT-040, Pin 3_0 is routed directly to the RX pin of the PSoC 5 LP USB-UART bridge through a zero-ohm resistor.
Page 69
Code Examples 4. Select the COM port and RX8 as the protocol, as shown in Figure 5-21. Figure 5-21. Bridge Control Panel - COM Port and Protocol Selection 5. Choose Tools > Protocol Configuration or press [F7] and configure the RX8 protocol parame- ters, as shown in Figure 5-22.
Page 70
Code Examples 6. Choose Chart > Variable Settings and set the variable names and types, as shown in Figure 5-23. Or click Load and then select the CapSense Proximity UART - Variable.ini file sup- plied with the project (...\Firmware\PSoC 4\Bridge Files\) in the Open window that appears.
Page 71
Code Examples 8. Click the command line and then click Repeat, as shown in Figure 5-25 to start receiving the packets (make sure you have powered the device and programmed with the project's firmware, the TX is connected to the RX line of the COM, and the COM port is selected in the BCP). Figure 5-25.
Page 72
Code Examples 9. You should start receiving data. Click the Chart tab to view the graph, as shown in Figure 5-26. Figure 5-26. Bridge Control Panel - Chart for Viewing Debug Data Signal LED Intensity (PRSm duty cycle) ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc.
Page 73
Code Examples Raw count and Baseline ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Code Examples Project: CapSense Touchpad with I C Tuner 5.4.1 Project Overview The project CY8CKIT_40_CapSense_I2C.cyprj demonstrates the implementation of a CapSense Trackpad using SmartSense and an EzI2C-based CapSense Tuner window for viewing the Track- pad coordinates. The project is a simple implementation using SmartSense (minimal tuning). The EzI2C block of PSoC 4000 is interfaced through the PSoC 5LP based USB-I C bridge to the PC GUI.
Page 75
Code Examples Figure 5-28. PSoC Creator Schematic Design of CapSense Trackpad Project with I C Tuner ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Code Examples 5.4.2 Project Description 5.4.2.1 PSoC Creator Component Configuration CapSense The CapSense Component is configured in SmartSense Auto-tuning mode with a 6x5 CapSense touchpad widget for the design, according to the parameters given in Table 5-9. Table 5-9. CapSense Component Parameters Parameter Tab Present Value...
Page 77
Code Examples Figure 5-29. CapSense Touchpad Parameters SCB (EzI2C Mode) The Serial Communication Block (SCB) configured in EzI2C mode is used for the CapSense Tuner. The parameters of the Component are shown in Figure 5-30. Figure 5-30. SCB (EZI2C Mode) Component Parameters ®...
Page 78
Code Examples 5.4.2.2 Firmware Details Figure 5-31 shows the flow chart of code implemented in main.c. Figure 5-31. CapSense Touchpad With I C Tuner Project Flow Chart Start Initialize CapSense and Enable Tuner Process CapSense and Send data over tuner 5.4.2.3 Hardware Connections Plug the Trackpad shield board into the Arduino headers of the kit, as shown in Figure 5-27.
Code Examples Figure 5-32. Pin Selection for CapSense I C Project 5.4.3 Verify Output Build and program the code example and reset the device. Launch the CapSense Tuner window as explained in the following steps. 5.4.3.1 Launching Tuner Window The Tuner window from PSoC Creator must be up and running for the code example to work. To launch the GUI, follow these steps: 1.
Page 80
Code Examples 2. To launch the Tuner, right-click the CapSense Component in PSoC Creator and click Launch Tuner, as shown in Figure 5-34. Figure 5-34. Launch Tuner 3. The Tuner window opens. Click Configuration to open the configuration window, as shown in Figure 5-35.
Page 81
Code Examples 5.4.3.2 Verify Output 1. To start the scanning and communication process, click Start in the Tuner window, as shown in Figure 5-37. Figure 5-37. Start Communication 2. Select a sensor in the Tuning tab. A red outline is displayed on the selected sensor. Different CapSense parameters are shown on the bottom right.
Page 82
Code Examples 4. Select the sensor parameters to observe, as shown in Figure 5-39. The graph of the selected parameters appears. Figure 5-39. Sensor Parameter Graph ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 83
Code Examples 5. Touch a sensor or slider element and see the increase in Raw count and Signal, as shown in Figure 5-40. Figure 5-40. Raw Count Increase ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Code Examples Project: Color Palette 5.5.1 Project Overview The project CY8CKIT_040_Color_Palette.cyprj demonstrates the capability of PSoC 4000 device to interface with a capacitive Trackpad and control an RGB LED based on the color selected by touch- ing the sticker on top of the Trackpad. The sticker will also include a slider area (part of Trackpad), which will control the color brightness of the RGB LED.
Page 85
Code Examples Table 5-11. CapSense Component Parameters Parameter Tab Present Value Rationale Automatically adjust sensitivity for different system Tuning method Auto(SmartSense) environments. Threshold mode General Automatic Enable run-time threshold calculation for 5:1 SNR. Raw data noise Filter out noise/unwanted spikes in raw count. This First Order IIR 1/8 filter setting can be tweaked based on requirement.
Page 88
Code Examples TX (SW TX UART) The software transmit TX is used to send out sensor data for debugging if enabled in firmware (refer to main.h in the project). The configuration for the Component is shown in Figure 5-44. The SW TX can be sent over to PC using either an RS-232 connector (with a voltage level translator in between) or through USB-UART bridge available in the CY8CKIT-040 PSoC 5 LP UART Bridge or CY3240 bridge configured as UART bridge, as documented in AN2397.
Page 89
Code Examples 5.5.2.2 Firmware Details Firmware Structure The color palette firmware is written in a modular format with different aspects of the functionality provided in separate functions, source, and header files. This enables users to understand the firm- ware structure better and to modify the firmware easily to meet the application requirements. The key aspects of the firmware can be modified to meet a different application requirement using vari- ous macros defined in the main.h file.
Page 90
Code Examples Firmware Flow Chart Figure 5-45 shows the flow chart of code implemented in main.c. Figure 5-45. Color Palette Project Flow Chart Start Enable proximity and initialize all blocks (CSD, PrISM, Debug Interface, and WDT) While(1) Loop Switch(MODE) SLEEP_SCAN PROX_SCAN ACTIVE ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 91
Code Examples Scan Proximity Scan all sensors Sensor including Prox Mode = SLEEP_SCAN Scan Gang Sensor Is it active? Is Prox Active? and Enter Sleep Scan Update PrISM duty based on End of loop Mode = PROX_SCAN Sleep Is it active? previous color and exit sleep scan and proximity distance Mode = ACTIVE Is Any Sensor and Exit sleep scan Active? End of loop Mode = ACTIVE End of loop ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 92
Code Examples Scan all sensors excluding Prox Is any sensor Increment NO_ACT active? counter Get Trackpad Is NO_ACT > 5 Is NO_ACT > 2.5 position secs? secs? Process co‐ ordinates to obtain color and brightness detail Mode = SLEEP_SCAN Start dimming LED and enter sleep scan Update PrISM duty based on color and brightness level Reset NO_ACT to 0 End of loop ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 93
Code Examples Firmware Implementation Details The firmware consists of three different modes: active scanning (ACTIVE_SCAN), sleep scanning (SLEEP_SCAN), and proximity scanning (PROX_SCAN) Active Scanning: Active scanning primarily performs two tasks: ■ Scans the touchpad ❐ Updates the color based on touchpad activity ❐...
Page 94
Code Examples Figure 5-48 through Figure 5-51 explain the process of generating the intensity levels for the RGB LEDs. The color palette and the saturation slider are both part of the Trackpad area. The following steps summarize the flow. 1. The Trackpad coordinates are obtained as shown in the mapping in Figure 5-48.
Page 95
Code Examples 2. Intensity levels of the RGB colors, before applying saturation, are calculated as shown in Figure 5-50. Along the X-Pos, the color palette is divided into six windows. In each window, one color is at maximum brightness, one is at minimum brightness, and one moves from maximum to minimum or vice versa.
Page 96
Code Examples 3. After the primary color intensities (from the color palette) are derived from step 2, either the brightness level or the saturation level selected by the slider is applied. The selection between brightness and saturation is done using DO_SATURATION macro defined in main.h. a.
Page 97
Code Examples Proximity Scanning Mode: ■ In proximity scanning mode, the device primarily scans the proximity sensor, and the touchpad sensors are scanned for activity. The previously selected RGB color is turned on with intensity proportional to the proximity signal strength. The device enters active scanning mode when a Trackpad element is touched.
Page 98
Code Examples 5.5.2.3 Hardware Connections The example requires the CapSense Trackpad shield connection, as explained in Project: Cap- Sense Touchpad with I2C Tuner on page 74. The RGB LED and CMOD connections are hardwired on the board. Optionally, a proximity loop can be connected, as shown in setup 1 in Figure 5-52.
Page 99
Code Examples Figure 5-53. Setup 2 Open CY8CKIT_040_Color_Palette.cydwr under the Source vertical tab in the Workspace Explorer and select the suitable pin. Table 5-13. Pin Connection Pin Name Port Name Trackpad_X0 P0_3 Trackpad_X1 P0_7 Trackpad_X2 P0_6 Trackpad_X3 P0_5 Trackpad_X4 P0_0 Trackpad_X5 P0_1 Trackpad_Y0...
Code Examples 5.5.3 Verify Output Build and program the code example onto the device. The default color for the RGB LEDs is blue. Therefore, when you move over the proximity sensor before touching the Trackpad, the RGB LED turns blue. Follow these steps to verify the code. 1.
Follow these steps to open and use the PSoC Creator CSD_ADC code example. 1. Launch PSoC Creator from Start > All Programs > Cypress > PSoC Creator <version> > PSoC Creator <version>. Note that the CSD_ADC Component is supported in PSoC Creator 3.2 or higher.
Page 103
Code Examples 2. On the Start page, click Find Example Project… under Examples and Kits, as shown in Figure 5-57. Figure 5-57. Open Code Example from PSoC Creator 3. In the Find Example Project window, set the Device family to PSoC 4000 and Keyword to CSD_ADC as shown in Figure 5-58.
Page 104
Code Examples 5. Select ADC_VoltageInput and click the Create New Workspace button. Save the workspace to a desired location. 6. This example demonstrates a voltage ADC implementation in PSoC 4000. The example also explains how to perform a two-point calibration for improved accuracy. The firmware controls a PWM output based on ADC output and the ADC data is sent out through UART as well.
Advanced Topics This section describes some of the advanced features available in the kit. Note: For all new example projects created in this section, rename the Components as shown in associated Component images. This is required because the C files attached with the user guide fol- low the Component names as shown in these images.
Page 106
Advanced Topics 2. Drag and drop an I C Component to the top design, as shown in Figure 6-2. Figure 6-2. I C Component in Component Catalog 3. To configure the I C Component, double-click or right-click the I C Component and select Con- figure, as shown in Figure 6-3.
Page 107
Advanced Topics 4. Configure the I C with the settings and click OK, as shown in Figure 6-4 Figure 6-5. Figure 6-4. I C ‘Configuration’ Tab Figure 6-5. ‘I C Tab ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 108
Advanced Topics 5. Select pin P1[2] for the I C SCL and pin P1[3] for the I C SDA in the Pins tab of <project.cydwr>, as shown in Figure 6-6. Figure 6-6. Pin Selection 6. Place the code available in USB_I2C-main.c, which is attached to this PDF document, in your main.c project file.
Page 109
I C block will be generated. Figure 6-7. Clock Settings in cydwr File 8. Open BCP from Start > All Programs > Cypress > Bridge Control Panel <version number>. ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 110
Advanced Topics 9. Connect to KitProg/ under Connected I C/SPI/RX8 Ports, as shown in Figure 6-8. Figure 6-8. Connect to KitProg/ in BCP ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 111
Advanced Topics 10.Open Protocol Configuration from the Tools menu and select the appropriate I C Speed. Make sure the I C speed is the same as the one configured in the I C Component. Click OK to close the window, as shown in Figure 6-9.
Page 112
Advanced Topics Figure 6-11. NACK Indication in BCP ‘‐’ Indicates No Acknowledgment (NACK) 12.From the BCP, read five bytes of data from the I C slave device with slave address 0x08, as shown in Figure 6-12. The log shows whether the transaction was successful. Figure 6-12.
The PSoC 4000 Pioneer Kit has an onboard Ferroelectric RAM chip that can hold up to 32 KB of data. Cypress F-RAM products combine the nonvolatile data storage capability of ROM with the benefits of RAM, which include a high number of read and write cycles, high-speed read and write cycles, and low power consumption.
Advanced Topics 6.2.2 Write/Read Operation The device datasheet includes details on how to perform a write/read operation with the F-RAM. Figure 6-14 Figure 6-15 provide a snapshot of the write/read packet structure as a quick refer- ence. Figure 6-14. F-RAM Single/Multiple-Byte Write Packet Structure Figure 6-15.
Advanced Topics In the previous figures, "Slave Address" denotes the address of the F-RAM slave device. [Address MSB: Address LSB] forms the 16-bit address of the memory location in the F-RAM to be accessed for read/write operation. The first two bytes following the slave address byte during a write operation constitute the initial memory address to be accessed.
Page 116
Advanced Topics 2. From the Components Catalog, place an I C (SCB mode) Component in the TopDesign from Communication > I C > I C (SCB mode) [<version>] and configure it as I C in the Configura- tion tab with the parameters shown in Figure 6-17.
Page 117
Advanced Topics 7. In the command window, copy and paste the code from the F-RAM_BCP_Commands.txt file attached to this document. 8. By default the F-RAM device is configured with a 0x50 slave address. If the value has been changed as explained in Address Selection on page 113, then change the slave address in the command window (replace “50”...
Advanced Topics 10.If the write transfer is successful, then check back the data using a read command to the same address by sending the second command line, as shown in Figure 6-20. The read command on the same locations will yield a '0' at 0x0000 (flag cleared) and 0xFD at 0x0001 (inverse of 0x02 sent).
Page 119
Advanced Topics 1. Create a new PSoC 4 project in PSoC Creator, as shown in Figure 6-21. Select an appropriate location for your project and rename it as required. Figure 6-21. Create a New Project From PSoC Creator ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc.
Page 120
Advanced Topics 2. Drag and drop a UART (SCB) component from the Component Catalog shown in Figure 6-22 the top design. Figure 6-22. UART Component Under Component Catalog 3. To configure the UART, double-click or right-click the UART Component and select Configure, as shown in Figure 6-23.
Page 121
Advanced Topics 4. Configure the UART as shown in Figure 6-24, Figure 6-25, and Figure 6-26 and then click OK. Figure 6-24. ‘Configuration’ Tab Figure 6-25. ‘UART Basic’ Tab ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 122
Advanced Topics Figure 6-26. ‘UART Advanced’ Tab 5. Select P4[0] for UART RX and P4[1] for UART TX in the Pins tab of <Project_Name>.cydwr, as shown in Figure 6-27. Figure 6-27. Pin Selection 6. Place the code available in USB_UART-main.c, which is attached to this PDF document, in your main.c project file.
Page 123
Advanced Topics 8. Connect the RX line of the PSoC 4 to J8_10 and the TX line of the PSoC 4 to J8_9, as shown in Figure 6-28 Figure 6-29. Notes: Before connecting the RX line, remove R57 connecting P3[0] of the PSoC 4000 device to the ■...
Page 124
Advanced Topics Note: UART RX and UART TX can be routed to any digital pin on PSoC 4 based on the configura- tion of the UART Component. An SCB implementation of the UART will route the RX and TX pins to either one of the following subsets: (P0[4], P0[5]) or (P3[0],P3[1]) or (P4[0],P4[1]).
Page 125
Advanced Topics 2. Open HyperTerminal, choose File > New Connection, enter a name for the new connection, and click OK, as shown in Figure 6-31. Figure 6-31. Open New Connection HyperTerminal 3. For PuTTY, double-click the PuTTY icon and select Serial under Connection, as shown in Figure 6-32.
Page 126
Advanced Topics 4. A new window opens, where you can select the communication port, as shown in Figure 6-33. a. In HyperTerminal, select COMx (or the specific communication port that is assigned to the Kit- Prog USB-UART) in Connect using and click OK. This code example uses COM12. b.
Page 127
Advanced Topics 5. In HyperTerminal, select Bits per second, Data bits, Parity, Stop bits, and Flow control under Port Settings and click OK, as shown in Figure 6-34. Make sure that the settings are identical to the UART settings configured for PSoC 4. In PuTTY, select Speed (baud), Data bits, Stop bits, Parity, and Flow control under Configure the serial line shown in Figure 6-33...
Page 128
Advanced Topics Figure 6-35. Select Communication Type in PuTTY 6. Enable Echo typed characters locally under File > Properties > Settings > ASCII Setup to display the typed characters in HyperTerminal, as shown in Figure 6-36. In PuTTY, enable Force on under Terminal >...
Page 129
Advanced Topics Figure 6-37. Enable Echo of Typed Characters in PuTTY 7. The COM terminal software displays both the typed data and the echoed data from the PSoC 4 UART, as shown in Figure 6-38 Figure 6-39. Figure 6-38. Data Displayed on HyperTerminal ®...
Advanced Topics Figure 6-39. Data Displayed on PuTTY Developing Applications for PSoC 5LP The PSoC 4000 Pioneer Kit has an onboard PSoC 5LP whose primary function is that of a program- mer and a bridge. You can build either a normal project or a bootloadable project using the PSoC 5LP.
Advanced Topics Figure 6-40. PSoC 5LP Block Diagram 6.4.1 Building a Bootloadable Project for PSoC 5LP All bootloadable applications developed for the PSoC 5LP should be based on the bootloader hex file, which is programmed onto the kit. The bootloader hex file is available in the kit files or can be downloaded from the kit webpage.
Page 132
Advanced Topics To build a bootloadable application for the PSoC 5LP, follow this procedure: 1. In PSoC Creator, choose New > Project > PSoC 5LP; click the expand button adjacent to Advanced and select the Device as CY8C5868LTI-LP039, as shown in Figure 6-42.
Page 133
Advanced Topics 2. Navigate to the schematic view and drag and drop a Bootloadable Component on the TopDesign. Figure 6-43. Bootloadable Component in Component Catalog ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 134
Advanced Topics 3. Set the dependency of the Bootloadable Component by selecting the Dependencies tab in the configuration window and clicking the Browse button, as shown in Figure 6-44. Select the Kit- Prog_Bootloader.hex and KitProg_Bootloader.elf files; click Open, as shown in Figure 6-45 Figure 6-46 and then click OK on the Configuration window.
Page 136
Advanced Topics 4. In the General tab, check the Manual application image placement checkbox and set the Placement address as “0x00002800” as shown in Figure 6-47. Figure 6-47. Bootloadable Component-General Tab 5. Develop your custom project. 6. The NVL setting of the Bootloadable project and the KitProg_Bootloader project must be the same.
Page 137
Advanced Topics 9. To download the project onto the PSoC 5LP device, open the Bootloader Host tool, which is available from PSoC Creator. Choose Tools > Bootloader Host, as shown in Figure 6-49. Figure 6-49. Open Bootloader Host Tool from PSoC Creator 10.In the Bootloader Host tool, click Filters and add a filter to identify the USB device.
Page 138
Advanced Topics 11. In the Bootloader Host tool, click the Open File button to browse to the location of the bootload- able file (*.cyacd), as shown in Figure 6-51. Figure 6-51. Open Bootloadable File from Bootloader Host Tool Figure 6-52. Select Bootloadable .cyacd File from Bootloader Host 12.Click the Program button in the Bootloader Host tool to program the device.
Pioneer Kit\<version>\Firm- ware\Programmer\KitProg This advanced functionality requires a MiniProg3 programmer, which is not included with this kit. The MiniProg3 can be purchased from www.cypress.com/go/CY8CKIT-002. To build a normal project for the PSoC 5LP, follow these steps: ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 140
Advanced Topics 1. In PSoC Creator, choose New > Project > PSoC 5LP Design; click the expand button adjacent to Advanced and select Device as CY8C5868LTI-LP039; as shown in Figure 6-53. Figure 6-53. Create a New Project in PSoC Creator 2.
■ PSoC 5LP Factory Program Restore Instructions The CY8CKIT-040 PSoC 4000 Pioneer Kit features a PSoC 5LP device that comes factory-pro- grammed as the onboard programmer and debugger for the PSoC 4 device. In addition to creating applications for the PSoC 4 device, you can also create custom applications...
Page 142
Advanced Topics 3. The following message shown in Figure 6-54 appears in the PSoC Programmer results window: "KitProg Bootloader device is detected." Figure 6-54. PSoC Programmer Results Window ® CY8CKIT-040 PSoC 4000 Pioneer Kit Guide, Doc. # 001-91316 Rev. *F...
Page 143
Advanced Topics 4. Switch to the Utilities tab in PSoC Programmer and click the Upgrade Firmware button, as shown in Figure 6-55. Unplug all other PSoC programmers (such as MiniProg3 and DVKProg) from the PC before clicking the Upgrade Firmware button. Figure 6-55.
Page 144
Advanced Topics 5. After programming is completed, the following message appears: “Firmware Update Finished at <time>,” as shown in Figure 6-56. Figure 6-56. Firmware Update Complete 6. The factory program is now successfully restored on the PSoC 5LP. It can be used as the pro- grammer/debugger for the PSoC 4 device.
Page 145
Restore PSoC 5LP Factory Program Using USB Host Tool 1. Launch the Bootloader Host tool from Start > Cypress > PSoC Creator. Using the File > Open menu, load the Kit Prog.cyacd file, which is installed with the kit software.
Page 146
Advanced Topics 2. Configure the Pioneer Kit in Service mode. To do so, while holding down the reset button (SW1 Reset), plug the PSoC 4000 Pioneer Kit into the computer using the included USB cable (USB A to Mini-B). This puts the PSoC 5LP into service mode, which is indicated by the blinking green status LED.
If PSoC 5LP is programmed with a standard application, restore the factory program by using the fol- lowing method. 1. Launch PSoC Programmer 3.23.1 or later from Start > Cypress > PSoC Programmer. 2. Use the File > Open menu to load the KitProg.hex factory program hex file, which is shipped with the kit.
Page 148
Advanced Topics 4. Ensure that MiniProg3 is the selected port in PSoC Programmer and the 10-pin connector (10p option) is selected, as shown in Figure 6-60. If the board is not powered over USB, select the Power Cycle programming mode. Figure 6-60.
For more details on licensing and the µC/Probe tool, refer to the µC/Probe Users’ Manual at http://micrium.com/download/%c2%b5cprobe-3-0-users-manual/. In Micrium µC/Probe version 3.3, the Cypress KitProg is supported as a means of communication to the target device connected to the computer. When an example project is built in PSoC Creator, it produces the output files in HEX, LST, MAP, RPT, and ELF formats.
Page 150
Advanced Topics The ELF file lists all the symbols (variables), symbol types, and its addresses. The Micrium µC/ Probe tool reads the ELF file and detects these symbols (global variables) used in the code. The µC/Probe tool provides a host of graphical controls such as sliders, RGB palette, graphs, and donuts.
Page 151
Advanced Topics 5. Drag and drop a RGB Palette from Writable Controls in the Toolbox onto the Datascreen to visualize the RGB output. Figure 6-63. Adding RGB Palette Control 6. Next, add a Line Chart from Charts in the Toolbox onto the Datascreen to visualize the X, Y posi- tion of the finger on the trackpad.
Page 152
Advanced Topics 8. Click the ELF button in the Symbol Browser window. Figure 6-66. ELF Button in Symbol Browser 9. Browse and point to the CY8CKIT_040_Color_Palette.ELF file to load the symbols (global vari- ables) from the CapSense example project. Wait until the ELF file is loaded. The ELF file is in the collapsed state by default.
Page 153
Advanced Topics 12.Drag and drop the global variable µcARGB on to the RGB Palette to see the RGB output. Simi- larly, drag and drop xPos and yPos on to the Line Chart control to the see the X and Y position of the finger on the trackpad.
Page 154
Advanced Topics Figure 6-70. Assigning y Position Output to Line Chart Control 13.By default, the Y axis of the Line Chart is plotted for values between 0 and 10000. To change the Y axis scale to 0 to100, click the Line Chart control. In the Line Chart control toolbar that appears, click the Properties Editor icon.
Page 155
Advanced Topics Figure 6-72. Properties Editor of Line Chart Control 14.In the Properties Editor, change the Max property of Y axis to 100. Notes: You may use the Series properties to change the line graph colors of xPos and yPos. Also, the Symbols Manager shows the global variables associated with the control.
Page 156
Advanced Topics 16.In the µC/Probe setting window, select Cypress PSoC Prog and select KitProg/<Kit Prog num- ber> from the drop-down list for Port and click OK to start communication between the CY8CKIT- 040 and the µC/Probe tool. Figure 6-74. µC/Probe Settings 17.Click the Run button to start.
Page 157
The µC/Probe project for the CY8CKIT_040_Proximity_UART project is already created and packaged along with the kit contents. The µC/Probe projects can be found in the installation folder at <Install directory>/ CY8CKIT-040 PSoC 4000 Pioneer Kit/<version>/uCProbe. 1. Open the CY8CKIT-040_Proximity_UART example project in PSoC Creator.
Appendix CY8CKIT-040 Schematics Input Voltage Range VIN is 5-12V NO LOAD TP1 RED V3.3 VBUS NO LOAD R2 ZERO NCP1117DTARKG SOD123 VOUT 3216 3216 10 uFd 25v 120 ohm 22 uFd 0603 232 ohm 1.0 uF CR2032 Coin Cell Battery Holder VBUS V3.3...
Page 159
Appendix PLACE CAPS CLOSE TO POWER PINS P4_VDD 0.1 uF 1.0 uF 0402 0603 ZERO ZERO P0_0 P1_6 P0[0] P1[6] ZERO ZERO P0_1 P1_5 P0[1] P1[5] ZERO P0_2 P1_4 P0[2] P1[4] CY8C4014LQI-422 ZERO P0_3 P1_3 P0[3] P1[3] P0_4 P1_2 P0[4] P1[2] P1_1 VCCD...
Page 162
Appendix P1_2 0.1 uF 0402 P1_3 FM24W256 ZERO ZERO ZERO ZERO NO LOAD NO LOAD NO LOAD NO LOAD ZERO ZERO ZERO ZERO F-RAM A.1.1 CapSense Touchpad Shield Board P1_2 P1_3 CSX1 P1_7 P3_1 P1_4 P1_1 ROW0 V5.0 P1_6 V3.3 P1_5 /XRES P1_4...
Appendix Pin Assignment Table This section provides the pin map of the headers and their usage. A.2.1 Arduino Compatible Headers (J1, J2, J3, J4, and J12) Power Connector (J1) Baseboard Signal Trackpad Shield Signal J1_01 J1_02 J1_03 J1_04 V5.0 J1_05 V3.3 J1_06 RESET...
Appendix Use of Zero-ohm Resistors and No Load Unit Resistor Usage Power supply Solder zero-ohm resistors to access voltage from VBUS (USB). Unsolder the resistors to communicate with an external PSoC C connection between PSoC 5LP R24 and R25 using the PSoC 5LP. Removing these will disable the PSoC 4 I and PSoC 4 communication with the PSoC 5LP device.
Appendix KitProg Status LED States User Indication Scenario Action Required by user Bootload the KitProg.cyacd file: in PSoC Programmer, con- LED blinks fast: LED starts blinking at power up, nect to the kit, open the Utilities tab and press Upgrade if bootloadable file is corrupt.
CY8CKIT-040 Baseboard Reference Value Description Manufacturer Mfr Part Number PCB, 68.58 mm x 53.34 mm, High Tg, ENIG finish, 4 layer, Color = RED, Silk Cypress = WHITE. 2200 pFd CAP CER 2200PF 50V 5% NP0 0805 Murata GRM2165C1H222JA01D C2,C9,C10,C12, C14,C15,C17,C2 0.1 uFd...
Appendix Trackpad/Touchpad Sticker Details Regulatory Compliance Information The CY8CKIT-040 PSoC 4000 Pioneer Kit has been tested and verified to comply with the following electromagnetic compatibility (EMC) regulations: EN 55022:2010 Class A - Emissions ■ EN 55024:2010 Class A - Immunity ■...
Appendix Migrating Projects Across Different Pioneer Series Kits All Cypress Pioneer series kits are Arduino Uno compatible and have some common onboard peripherals such as RGB LED, CapSense, and user switch. However, the pin mapping in each of the boards is different due to differences in pin functions of the PSoC device used. This guide lists the pin maps of the Pioneer series kits to allow for easy migration of projects across different kits.
Need help?
Do you have a question about the CY8CKIT-040 PSoC 4000 Pioneer Kit and is the answer not in the manual?
Questions and answers