USB Interrupt Transfer Example PSoC 3 / PSoC 5

Similar documents
Writing to Internal Flash in PSoC 3 and PSoC 5

CE56273 Associated Part Families: CY8C38xx/CY8C55xx Software: PSoC Creator Related Hardware: CY8CKIT-001 Author: Anu M D

PSoC 5LP Vendor-Specific USBFS Tutorial

AN USB HID Intermediate with PSoC 3 and PSoC 5LP. Contents. 1 Introduction

CE PSoC 4: Time-Stamped ADC Data Transfer Using DMA

USB BF70x Bulk Library v.1.1 Users Guide Users Guide Revision 1.1. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

PSoC Designer Quick Start Guide

Designing a Low-Cost USB Interface for an Uninterruptable Power Supply with the Cypress Semiconductor CY7C63001 USB Controller

CLD SC58x CDC Library v.1.00 Users Guide Users Guide Revision For Use With Analog Devices ADSP-SC58x Series Processors. Closed Loop Design, LLC

Designing a USB Keyboard with the Cypress Semiconductor CY7C63413 USB Microcontroller

USB BF70x Audio 1.0 Library v.1.2 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors

ECG (EKG) Primer Jingxi Zhang ABSTRACT

CLD BF70x CDC Library v.1.3 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

Get Connected with USB on RX62N RX62N USB

CY3660-enCoRe V and encore V LV DVK Kit Guide

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX

USB Mouse tutorial. Step-by-step project creation. CAK 2005 Petr Stružka UNIS, spol. s r.o.

Cypress HX2VL Configuration Utility Blaster User Guide

DMA& USB INTERFACING FOR KEYBOARD USING CYPRESS PSoC-5

USB BF70x HID Library v.1.1 Users Guide Users Guide Revision 1.1. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

PSoC 1 I 2 C Bootloader

I Introduction to Real-time Applications By Prawat Nagvajara

Firmware Description:

FR Family MB Emulator System Getting Started Guide

Generic Serial Flash Interface Intel FPGA IP Core User Guide

Logitech hidpp 1.0 excerpt for public release

Filter_ADC_VDAC_poll Example Project Features. General Description. Development Kit Configuration

PSoC Filter Block Tutorial

CP2501 Programmer s Guide and API Specification

Multifunction Serial Interface (PDL_MFS) Features. General Description. When to Use a PDL_MFS Component. Quick Start 1.0

Programming Assignment 1: Pushbutton and Light

CE CY8CKIT-042-BLE F-RAM Data Logger

Creating a USB to Serial Bridge Solution using Cypress Low and Full-speed M8 USB Devices

THIS SPEC IS OBSOLETE

Capable of adjusting detection timings for start bit and data bit

AN PSoC 3 and PSoC 5 SFF-8485 Serial GPIO (SGPIO) Initiator Interface. Application Note Abstract. Introduction

2 Unifying receiver (DJ) Software Interface

1. Document Overview Overview Using USB-BASIC-F/W User-Defined Macros User-Defined Information...

Bootloader project Project with a Bootloader Component and communication Component.

The following table lists user modules used in this code example and the hardware resources occupied by each user module.

ECE 381 Lab 1a PSoC5 Blinking LED 1. Launch PSoC Creator 3.3 from the star menu

XS S ERIES TM PMB US TM O PTION C ARD

Table of contents. Rev 1.1

Texas Instruments TUSB8040 EEPROM Programming Utility. User s Guide

WirelessUSB PRoC Development Kit Tutorial

Description of the Simulator

ModusToolbox USB Configurator Guide

Designing Your Own Soft Modules

ORION USB3 Evaluation Kit

4) In response to the the 8259A sets the highest priority ISR, bit and reset the corresponding IRR bit. The 8259A also places

Bootloader project Project with a Bootloader component and communication component.

This process is a fundamental step for every USB device, fore without it, the device would never be able to be used by the OS.

SensorXplorer TM Installation Guide

The BlueNRG-1, BlueNRG-2 BLE OTA (over-the-air) firmware upgrade

USB Device Development Kit for HT32 Series Microcontrollers

Quick Start idds-2 Frequency Synthesizer

FUSB301 Evaluation Board Users Guide

Full Speed USB (USBFS) Features. General Description. When to Use a USBFS USB Full Speed device interface driver

1. What is ProSpeckz IIK?

Using the TMS320C5509 USB Bootloader

Console Framework Module Guide

Design UART Loopback with Interrupts

USB Dog Terminator. User's Manual.

* USB Full-Speed Hub Controller

NIOS CPU Based Embedded Computer System on Programmable Chip

How to use the PSoC based 16C450 Replacement

PSoC Designer: Integrated Development Environment

AN434: CP2110/4 Interface Specification

USB Complete. The Developer's Guide Fifth Edition. Jan Axelson. Lakeview Research LLC Madison, WI 53704

Base Timer Channel (BT) Features. General Description. When to Use a PDL_BT Component 1.0

DPScope SE Programming Interface Description

Daintree Light Sensor Demo Application Note

H O S T. FX2 SX2 Back - to - Back Setup. Project Objective. Overview

AN SIO Tips and Tricks in PSoC 3 / PSoC 5. Application Note Abstract. Introduction

PLX USB Development Kit

University of Massachusetts Amherst Computer Systems Lab 2 (ECE 354) Spring Lab 1: Using Nios 2 processor for code execution on FPGA

AN4869 Application note

MCUXpresso SDK USB Stack User s Guide

AC : INTERFACING THE USB PRINTER INTERFACE USING VINCULUM HOST CONTROLLER

AN6010. Using the Host Port Interface (HPI) in Cypress OTG-Host. Application Note Abstract. Introduction. HPI Overview

NIOS CPU Based Embedded Computer System on Programmable Chip

DEVICE DRIVERS AND TERRUPTS SERVICE MECHANISM Lesson-15: Writing Device Driving ISRs in a System

P&E Microcomputer Systems, Inc. P.O. Box 2044, Woburn, MA 01888, USA

AN721 CP21XX DEVICE CUSTOMIZATION GUIDE. 1. Introduction USB Logos and Certification Testing USB Vendor IDs and Product IDs

Emulating an asynchronous serial interface (USART) via software routines

BASICS OF THE RENESAS SYNERGY PLATFORM

Procedure to Create Custom Report to Report on F5 Virtual Services

PSoC Creator Component Data Sheet

Making USB Device Drivers Easier Using the HID Class

CE58957 demonstrates how to implement the fade and toggle feature to the backlight LEDs of CapSense buttons.

Contents. Cortex M On-Chip Emulation. Technical Notes V

User Guide Laird Configuration and Test Utility Software. Version 1.0

Integrating the MC9S08JS16/8 USB Bootloader to Your Application

Start a New Project with Keil MDK-ARM Version 5 and ST Micro Nucleo-F446RE

CY4615B AT2LP DDK User s Guide

Tutorial for Altera DE1 and Quartus II

ice40 UltraPlus Image Sensor Elliptical Crypto Engine (ECC) Demo - Radiant Software User Guide

EE475 Lab #3 Fall Memory Placement and Interrupts

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4465

Windows Device Driver and API Reference Manual

Transcription:

USB Interrupt Transfer Example PSoC 3 / PSoC 5 Project Objective This code example demonstrates how to perform USB Interrupt Transfer from a PC using the USB HID driver and PSoC 3 device. Overview USB interrupt transfer is a transfer type where in the USB host interrupts the USB device at regular interval and performs an USB transfer. This interval is selected by the user and a guaranteed data transfer occurs during this interval. A full speed USB component in PSoC 3 / PSoC 5 is used in this project that enumerates as a generic HID class device. This project transfers 64 or lesser number of bytes of data from the PC to the PSoC 3 / PSoC 5 device using the USB interrupt Out endpoint. The sent data is modified by the PSoC 3 / PSoC 5 device and is sent back to the PC using interrupt In endpoint. A GUI is created using C# for sending data from the PC to the PSoC 3 / PSoC 5 device and to read back the data from the PSoC 3 / PSoC 5 device. For other related USB Examples and resources scroll to the Section, Error! Reference source not found., that is at the end. Top Design The following figure illustrates the components and their routing: The following figure shows pin placement (as in.cydwr file). The USB uses the fixed pins, P15 [6] and P15 [7]. After the USB is placed on the TopDesign, the pins are automatically blocked.

Component Configuration To configure a full speed USB component, right click on the component and select configure (or double click on the component). This opens up a configuration wizard with various configurable parameters for USB as shown from Figure 1 to Figure 6. The following figures show the component parameter settings for the USBFS component used in the project. Figure 1. Device Descriptor In the figure, the String Cypress and Interrupt_Transfer_Example added to the device Descriptor are automatically updated in the String descriptor tab. Figure 2. Configuration Descriptor

In the figure, the String USB_Example is automatically updated in the String descriptor tab. Figure 3. Interface Descriptor In the figure, the String USB Interrupt Interface is automatically updated in the String descriptor tab.

Figure 4. HID Class Descriptor In the figure, the HID Report InterruptHIDReport is created in the HID descriptor tab. The following sections describe the creation of a HID report. Figure 5. In Endpoint Descriptor

Figure 6. Out Endpoint Descriptor The PSoC 3 / PSoC 5 device is configured as a generic HID device with one Out Interrupt endpoint and one In Interrupt endpoint, each having a data buffer size of 64 bytes (see Figure 5 and Figure 6). On every scanning interval (10 ms as specified by the endpoint configuration) the host checks for any In or Out packet from or to the HID device and performs an In or Out operation. When an Out data packet is sent to the device using the GUI, an Out endpoint interrupt is raised at the PSoC 3 / PSoC 5 device. When the interrupt occurs, the received data bytes are read and the same data is incremented and loaded back to the In Interrupt endpoint. This In Endpoint data is read by the PC when the user performs data read operation from the GUI (The details of the GUI are discussed in later section). The Usage page for the HID is defined as vendor specific. The In and Out reports are defined in the HID descriptors; the logical minimum and logical maximum are fixed to 0 and 255 respectively. The same values are also used for usage minimum and usage maximum. An In report and an Out report, each having a data size of 64 bytes, are declared in the HID descriptor. To create a HID report, HID Descriptor tab in the USBFS configuration page should be selected. The HID descriptor is a set of HID Items. To add any items to the descriptor, select one of the HID items list (for example, USAGE ) and choose any required value from the item Value (for example, Pointer ). Then click Add to add this item to the report. The complete report can be seen on the left pane. Figure 7. HID Report Descriptor

Design Wide Resources The clock tree for the project is shown in Figure 8. (The clock tree for a project can be reached by double clicking on the design wide resource file (USB_Interrupt_Transfer_Example.cydwr file) in the workspace explorer and clicking on the Clocks tab. The clocks configuration wizard can be opened by double clicking on the clocks listed in the Clocks tab). Figure 8. Clock Tree The clock for the USB component is derived from IMO. The frequency of the IMO has to be 24 MHz. The D+ and D- pins are also mapped to the corresponding pins using the design wide resources window. In the current code

example, USB is declared as self powered from a 3.3 V source. The USB bus voltage is not used for any functionality. The other settings in the.cydwr file can be kept in the default state. Operation The main routine for this project is as follows. GUI 1. The Global interrupts are enabled for USB operation 2. The USBFS user module is started at 3.3 V mode operation. (The USB can work from 3.3 V to 5 V) 3. After the user module initialization, the code waits for USB enumeration operation to be completed 4. After the enumeration completes, the Interrupt OutEndpoint is enabled for receiving data from the PC 5. When the Out endpoint interrupt occurs, the received data from PC is incremented by one and the In endpoint is filled with the incremented data 6. The Read request can be sent from the GUI by clicking on the Read button; the In endpoint data will be sent to the PC on the read request Figure 9 shows the complete implementation of the project, that includes the GUI on the PC and the PSoC3 interaction. Figure 9. Implementation of the project For exchanging data between the PC and PSoC 3 / PSoC 5, a simple GUI is developed in C# that uses the PSoCFirstTouchUSBNetLib.dll file, which in turn uses the CyUSB.sys driver for communicating to the PSoC 3 / PSoC 5 device. The dll file, placed in folder \GUI\Interrupt_Transfer_Example\bin\Release, exposes two simple APIs, ReadFromPSoC and WriteToPSOC, which send and receive data to the PSoC device.

byte[] ReadFromPSoC(): The API ReadFromPSoC() returns a byte array containing the input report from the PSoC HID device. Example: PSoCData = gfirsttouchdevice.readfrompsoc(); WriteToPSoC(byte[] PSoCData): The API WriteToPSoC() sends a byte array as an OUT report to the PSoC HID device. Example: gfirsttouchdevice.writetopsoc(psocdata); The PSoC device is acquired by the GUI application depending on the VID and PID of the device by using the method FindFirstTouchDevice(). FindFirstTouchDevice(int VendorId, int ProductId) : The API returns a handle to a connected USB device with the Vendor ID and Product ID specified as its input arguments. Example: gfirsttouchdevice = FirstTouchHidDevice.FindFirstTouchDevice(0x4b4, 0xF100); To open the GUI click on the Interrupt_Transfer_Example.exe file, placed in the folder \GUI\ Interrupt_Transfer_Example \bin\release. Figure 10. Snapshot of the GUI When the USB device (PSoC 3 / PSoC 5) is programmed and connected to PC, the GUI task bar shows Connected at the bottom left corner. When the device is not connected or when it is not working properly as a USB device, the task bar shows as disconnected. Users can send custom data by clicking the SendCustomData radio button. A predetermined sequence of 64 bytes can be sent by selecting the SendRandomData button. When the SendCustomData option is selected, the data to be sent is entered in the text box and when the Write button is clicked, 64 bytes of the data inside the text box (zero is inserted if all the data is not present) is sent to the PSoC 3 / PSoC 5 (that is, the Out endpoint in PSoC 3 / PSoC 5 receives this data). This operation triggers out endpoint interrupt inside the PSoC 3 / PSoC 5 device. This interrupt routes the program to CY_ISR(USBFS_EP_2_lSR) inside the USBFS_episr.c file. In the ISR: 1. A flag to indicate the occurrence of interrupt is set (USB_interruptFlag) 2. In the main code, when this flag is set, the function ProcessEP2Data is called 3. The function ProcessEP2Data does the following: a. Reads how many bytes have been sent to the Out endpoint b. Reads the bytes sent to the Out endpoint and stores to a local buffer c. Increments the received data d. Puts the incremented data to the In endpoint buffer so that when the Read button is clicked in the GUI, the data from the In endpoint buffer is sent to PC Figure 11. Snapshot of the Loopback Data

Note The read operation must be performed only after the data is written to the device. This is because the firmware is written to act in such a manner. Once an OUT transfer is made by clicking the Write button, this data is received by PSoC, incremented and loaded to the In Endpoint. The USB HID implementation in the PC checks every 10 ms to see if there is In Endpoint data from PSoC. Once the In Endpoint is loaded with data, during the next request from the PC, this data is read. This happens whether or not the Read button is pressed. Later when the Read Button is pressed the data read during the previous successful In Endpoint transfer is displayed on the GUI. Hardware Connections The project is tested with the PSoC Development Kit CY8CKIT-001 The kit should be used with the default state of the jumpers. Refer CY8CKIT-001 PSoC Development Kit Guide The DVK switch supply (SW3) should be set to 3.3 V If the USB should be run at 5 V, change the SW3 position to 5 V In the main.c, initialize the USB to run at 5 V. Use the API USBFS_Start with parameter USBFS_5V_OPERATION Connect a USB cable from the DVK USB port to PC USB port.

Output Build the project and program the chip. Note The default device selection is PSoC 3 (CY8C3866AXI-040).To use this project with PSoC 5 family, do the following: Go to Project Device Selector Select PSoC 5 device (CY8C5588AXI-060), build the project again and program the PSoC 5 device as follows: Figure 12. Device Selector Reset the device by pressing the SW4 (Reset Switch). The device enumerates and gets automatically bound to HID driver. (The PC pops up a window at the Taskbar mentioning that A New Hardware was found and Is ready to use Open the PC GUI software provided with this code example (located in the code example folder in GUI\Interrupt_Transfer_Example \bin\release\ Interrupt_Transfer_Example.exe). Enter up to 64 byte of data in hexadecimal number format with or without spaces between the numbers and click the Write button. The GUI parses the data and sends it accordingly.

Figure 13. USB Interrupt Transfer Tool Write Operation. The GUI sends 64 bytes of hexadecimal value to the target through USB port. The GUI will pop up saying Data Sent It automatically appends 0s if the user enters less than 64 bytes. The PSoC 3 / PSoC 5 device receives 64 bytes and increments the received values and keeps it ready for the PC to read through USB port. Click the Read button, the 64 bytes of data read from PSoC 3 are displayed on the GUI. The read data are write data incremented by 1 as shown below. Figure 14. USB Interrupt Transfer Tool Read Operation