Transmision Usb En Psoc

Páginas: 8 (1782 palabras) Publicado: 18 de octubre de 2012
USBUART in PSoC® 3 / PSoC 5

CE60246
Project Name: USBUART_Example_Project Programming Language: C ® Software Version: PSoC Creator™ 1.0 Related Hardware: CY8CKIT-001 Prerequisites: USBUART_Lib Author: Dan Sweet

Objective
CE60246 demonstrates the use of a custom developed USBUART component with PSoC 3 / PSoC 5.
®

Overview
The USBUART component uses a USB interface to emulate a COMport. This custom component is based on a standard USB component, modified to enumerate and act as a CDC USB device. High-level communication functions are available on the PSoC device side and the PC communicates through a standard terminal program. This example project demonstrates a PSoC project using a USBUART component to echo any data sent to it from a PC terminal.

Component List
InstanceName USBUART_1 Component Name USBUART Version 1.0 Component Category Custom Comments VID, PID, Device Release, Mfr String and Product String are set

The USBUART component is the only component used in this example. To use this component in a project, a dependency must be set pointing to the library project containing the USBUART component. The instructions for adding this component to yourown project are mentioned in the following section.

Importing a Custom Component in a Project
Follow these steps to add the USBUART component to a new project:



Right click on the project name in the Workspace Explorer and select Dependencies.

June 20, 2011

Document No. 001-60246 Rev. *E

1

[+] Feedback

CE60246

 

Add a new User Dependency. Navigate to and selectthe USBUART_Component_Library.cyprj file provided with the example project. Ensure Components is selected and the Code check box is cleared.



Click OK and the USBUART component now appears in a new tab in the Component Catalog. It is now ready to be placed on your schematic.

Top Design

June 20, 2011

Document No. 001-60246 Rev. *E

2

[+] Feedback

CE60246

ComponentConfiguration
USBUART

Note Each USB product must have a unique combination of Vendor ID (VID) and Product ID (PID). The default values provided here are used as an example, but a unique VID (assigned by the USB Implementers Forum) and PID must be used in a final product.

Design Wide Resources
Changes must be made in the Clocks tab in the design wide resources file (.cydwr) to use USB on the PSoC3 device. The clocks can be configured by clicking Edit Clock in the Clocks tab. You must make the following changes.

    

IMO: Select Osc 24.000 MHz. PLL: Select Input from IMO and desired frequency as 48MHz. ILO: Select 100 kHz. USB: Enable and select IMOx2 – 48.000 MHz. Master Clock: Select PLL_OUT– 48.000 MHz.

June 20, 2011

Document No. 001-60246 Rev. *E

3

[+] Feedback CE60246

Operation
This project echoes any data sent to it through the PC COM terminal. During initialization, global interrupts are enabled and the USBUART component is started and enumerated. In the main loop, the receive buffer is checked for data. If data exists, the data is read out of the buffer and written back to the PC. After writing data to the PC, the PSoC must wait for thetransmission to complete before continuing; otherwise, the PSoC may send new data to the PC before it is ready. This code is shown in Code 1.
Code 1 USBUART Example Code
#include uint8 Count; uint8 Buffer[128]; void main() { /* Initialization Code: */ CYGlobalIntEnable; USBUART_1_Start(0, USBUART_1_3V_OPERATION);//!!NOTE!! Make sure this matches your board voltage!while(!USBUART_1_bGetConfiguration()); USBUART_1_CDC_Init(); /* Main Loop: */ for(;;) { Count = USBUART_1_bGetRxCount(); if(Count != 0) { USBUART_1_ReadAll(Buffer); USBUART_1_Write(Buffer, Count); while(!USBUART_1_bTxIsReady()){} } } }

/* Check for input data from PC */ /* Echo data back to PC */ /* Wait for Tx to finish */

Apart from the standard USBFS APIs, the following APIs are implemented for this component. uint8...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • que es un usb
  • que es usb
  • USB
  • La usb
  • Usb
  • Psoc
  • transmisión
  • Transmision

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS