Home

SH7216 Group USB Function Module

image

Contents

1. When data direction changes the Data stage is completed EPOo receive No and advance to the Status stage complete interrupt USBIFR1 EPO0TS Executes the Status stage of the control OUT transfer Clears EPOo receive complete flag USBIFR1 EPO0TS 0 GetPacket Reads USBEP0Oo receive data size register USBEPSZ0o Reads data from USBEPOo register USBEPDROo When set EPOORDFN to 1 Reading data from the EPOoFIFO i completed y USBTRG EPOORDFN 1 lt vy Operation end Figure 2 10 Data OUT Stage Operation Flow RO1AN2201EJ0100 Rev 1 00 Page 13 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 2 4 3 Status Stage The direction of the data transaction in the Status stage differs from that of the Data stage the data OUT transaction is executed during the Status stage of the control IN transfer and the data OUT transaction is executed during the Status stage of the control OUT transfer 1 Status Stage of the Control IN Transfer The USB host sends an OUT token and a O byte data packet The USB device first receives the OUT token and then receives the 0 byte data packet Then it returns an ACK handshake to the USB host The USB function module receives the OUT token and the O0 byte data packet and automatically sends an ACK handshake to the USB host Then the USB function mod
2. The reserved addresses are provided for the possible future expansion of functions Do not access these addresses the correct operation of LSI is not guaranteed if they are accessed 4 Clock Signals After applying a reset only release the reset line after the operating clock signal has become stable When switching the clock signal during program execution wait until the target clock signal has stabilized When the clock signal is generated with an external resonator or from an external oscillator during a reset ensure that the reset line is only released after full stabilization of the clock signal Moreover when switching to a clock signal produced with an external resonator or by an external oscillator while program execution is in progress wait until the target clock signal is stable 5 Differences between Products Before changing from one product to another i e to a product with a different part number confirm that the change will not lead to problems The characteristics of an MPU or MCU in the same group but having a different part number may differ in terms of the internal memory capacity layout pattern and other factors which can affect the ranges of electrical characteristics such as characteristic values operating margins immunity to noise and amount of radiated noise When changing to a product with a different part number implement a system evaluation test for the given product Notice Description
3. USB function module USB Serial communication interface SCI eoeoo 1 2 Applicable Conditions MCU SH7216 Operating frequency Internal clock 200 MHz Bus clock 50 MHz Peripheral clock 50 MHz MTU2S clock 100 MHz AD clock 50 MHz Integrated development environment Renesas Electronics High performance Embedded Workshop Ver 4 07 00 C compiler Renesas Electronics SuperH RISC engine Family C C Compiler Package Ver 9 03 00 Release 02 Compile options High performance Embedded Workshop default settings cpu sh2afpu fpu single include WORKSPDIR inc WORKSPDIR src inc object CONFIGDIR FILELEAF obj debug gbr auto fpscr safe chgincpath errorpath global_volatile O opt_range all infinite_loop O del_vacant_loop 0 struct_alloc 1 nologo 1 3 Related documents The following application note is related to this application note Refer to it as necessary in conjunction with this application note SH7216 Group USB Function Module USB Mass Storage Class Application Note REJO6B0897 SH7216 Group USB Function Module USB HID Class Application Note REJO6B0898 SH7216 Group Protocol Conversion between Ethernet and USB Application Note ROIANOO66EJ SH7216 Group USB Multifunction Operation of USB Function Module Application Note ROIANO0294EJ SH7216 Group Using USB to Reprogram Flash Memory in User Program Mode Application Note ROIANO316EJ SH7216 Group Peripheral LibUSB Demo Application Note ROIANO8
4. Is Eplnfo 0 PresentState STALL T No Judged by bit7 in OUT Host to device bmRequest ransfer direction IN Device to host y Disables interrupt Set TRANS_OUT state Set TRANS_IN state Set STALL Set the interrupt enable bit Set the interrupt enable bit USBEPSTL EPOSTL 1 for control OUT transfer for control IN transfer EPOITSE EPOoTSE EPOiTRE 1 EPOITSE EPOoTSE 1 i PutPacket Writes data to FIFO Operation end Figure 2 6 Setup Stage Operation Flow RO1AN2201EJ0100 Rev 1 00 Page 10 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 2 4 2 Data Stage The Data stage of the control IN transfer is composed of single or multiple data transactions The Data stage of the control IN transfer is composed of one data IN transaction This is called Data IN stage processing The Data stage of the control OUT transfer is composed of one data OUT transaction This is called Data OUT stage processing 1 Data IN Stage First the USB host sends an IN token When the USB device receives the IN token it sends a data packet to the USB host and waits for an ACK handshake from the USB host If the USB device cannot send a data packet when it receives the IN token it returns a NAK handshake to the USB host Figure 2 7 shows the data IN transaction sequence When the USB function module
5. data in the control transfer bulk OUT transfer bulk IN transfer and interrupt transfer to the USB host Table 2 1 shows those configurations RO1AN2201EJ0100 Rev 1 00 Page 4 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Table 2 1 Endpoint Configurations FIFO Buffer DMA Endpoint Name Transfer Type Max Packet Size Capacity Transfer Endpoint 0 EPOs Setup 8 bytes 8 bytes EPOi Control in 16 bytes 16 bytes EPOo Control out 16 bytes 16 bytes Endpoint 1 EP1 Bulk in 64 bytes 64 x 2 128 bytes Possible Endpoint 2 EP2 Bulk out 64 bytes 64 x 2 128 bytes Possible Endpoint 3 EP3 Interrupt in 16 bytes 16 bytes Endpoint 4 EP4 Bulk in 64 bytes 64 x 2 128 bytes Possible Endpoint 5 EP5 Bulk out 64 bytes 64 x 2 128 bytes Possible Endpoint 6 EP6 Interrupt in 16 bytes 16 bytes Endpoint 7 EP7 Bulk in 64 bytes 64 bytes Endpoint 8 EP8 Bulk out 64 bytes 64 bytes Endpoint 9 EP9 Interrupt in 16 bytes 16 bytes 2 2 USB Communication via the USB Function Module As an example of using the USB function module for USB communication the sample program implements the USB communication features listed in the table below Table 2 2 USB Communication Functions USB Communication Features Detect a connection to the USB host The port pulls up the D pin to detect a connection Control transfer Decodes requests processes the Data stage and Status stage of the USB request trans
6. returns an ACK handshake When the USB device receives the OUT token when it is unable to receive data packets it ignores subsequent data packets and returns a NAK handshake When the USB host receives a NAK handshake it attempts to resend the OUT token and data packet to the USB device Figure 2 14 shows the OUT transaction sequence When the USB function module receives an OUT token when it is unable to receive data packets it automatically discards subsequent data packets and returns a NAK handshake to the USB host When the USB function module receives an OUT token when it can accept data packets it holds the data from the USB host in the EP1FIFO and returns an ACK handshake to the USB host Then the USB function module generates the data receive complete interrupt using the EPIFULL bit in the USBIFR1 register The sample program reads the data in the EPI FIFO and stores it in the bulk OUT transfer RAM during the interrupt set the EP1 read complete flag by setting the EP1RDEN bit in the USBTRG register to 1 and waits for the next interrupt to be generated When the interrupt is generated if there is no area in the EP1FIFO to store data the sample program disables the EP1 FULL interrupt and the interrupt process is completed while it is in a suspended state When serial communication is used to create an area in the bulk OUT transfer RAM enabling the EPI FULL interrupt causes the suspended EP1FULL interrupt to be generated and moves the data in
7. the EPI FIFO to the bulk OUT transfer RAM in the interrupt handler and sets the EP1 read complete flag to wait for the next interrupt to be generated RO1AN2201EJ0100 Rev 1 00 Page 16 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Handshake 34 Packet issued by the host Figure 2 14 Bulk OUT Transaction Sequence Serial OUT transfer Sends data in the bulk OUT transfer RAM to the serial device by serial OUT transfer Sample Program Software USBIFR1 interrupt Packet issued by the device The suspended EP1FULL interrupt occurs when serial OUT transfer allocates the RAM area Serial OUT transfer y Executes the ActBulkOut Operation start function in the USBIFR1 interrupt handler ActBulkOut The bulk OUT transfer RAM is not full l GetPacket Disables EP1FULL interrupt USBIER2 EP1FULL 0 Get size of the received data Read USBEPSZ1 Reads data from USBEP1 Data Register USBEPDR1 to store it in the bulk OUT transfer RAM USBTRG1 EP1RDFN 1 When set EP1RDFN to 1 Reading data from the EP1FIFO is completed Suspends EP1 FULL interrupt until allocating the RAM area can be stored the one packet data by serial OUT transfer i y Operation end Figure
8. to the USB HOSt ccceeeesecceeeeeeaeeeeeeeeeeeseeeeeeseeeeeeessseeeseeeeesesaaenees 6 24 Control TEAST OF so srisiscanaeuasisannaiuvwwsinunnirsecaosiuwaleauewnnneaduiuasiovucniasenouuwalecuensanaaddvwaulsetduisivalenusnantaxuminaaaivwanis 7 25 Bulk Transier ecaa a e A a a 16 3 System Example of the USB Communication ClasS cccccccssseeeeeeeeeeeeeeeeeeeeeeeeeaaeesseeeeeseaaaaeeees 20 3 1 OV ORNVICW 2 ccc eccceccccccccuceccucecececucuucusecscuuausecscacauausecseauausenecseatuuausenstseauausenstauausenscseauausenstastenseavaenens 20 32 Operalon FloW casa case cee essnsge ange cena sone EA en E E pr EEA AOE 21 3 3 Serial COMMUNICATION ccccccceccececcececceccccecuccecuccecucccuecucuucucuececuenecsuaeceeausacaeuecsenecsuaenecsuaeeaenes 22 3 4 Environment Settiing ccccccccsssssseeceecccceeesseeeeeeeceeauseeeeeecsceeeaaseeeeeeceseeaauseeeeeeessesaaseeeeessessaaaess 25 4 Reference DOCUMENMS ccccccececccccccccececececauaeauaeneneneceneneneneneneneneueuenenenenenenenenenenenenensnensueranavananas 26 RO1AN2201EJ0100 Rev 1 00 Page 2 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 1 Overview This document explains how to use the SH7216 USB function module and how to implement the system applied to the USB communication class as an application example for the USB function module 1 Functions Used Interrupt controller INTC Pin function controller PFC
9. use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics products are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility o
10. 14 RENESAS SH7216 Group USB Communication Class Application Note 3 4 2 Parameter Setting of Serial Application You need to set the parameter of the serial applications terminal 1 and terminal 2 on the PC Table 3 4 lists the settings Table 3 4 Parameter Setting Items Description Connection Select the port number connected to an RS 232C serial cable or a USB cable Bit rate B 115 200 bps Data bits D 8 Parity P None Stop bit S 1 Flow control F on Xoff 4 Reference Documents User s Manual Hardware SH7214 Group SH7216 Group User s Manual Hardware Rev 4 00 R01UH0230EJ0400 User s Manual Software SH 2A SH2A FPU User s Manual Software Rev 3 00 REJO9B005 1 Website and Support Renesas Electronics website http www renesas com Inquiries http www renesas com contact All trademarks and registered trademarks are the property of their respective owners RO1AN2201EJ0100 Rev 1 00 Page 26 of 26 August 20 2014 RENESAS SH7216 Group USB Function Module SE ey USB Communication Class Application Note as Description roo l Aug 20 2014 Firstediionssued OOOO O O OOOO AE S ee All trademarks and registered trademarks are the property of their respective owners General Precautions in the Handling of MPU MCU Products The following usage notes are applicable to all MPU MCU products from Renesas For detailed usage notes on the products covered by this document refer to the relev
11. 2 15 Bulk OUT Transfer Operation Flow RO1AN2201EJ0100 Rev 1 00 August 20 2014 rtENESAS Page 17 of 26 SH7216 Group USB Communication Class Application Note 2 5 2 Bulk IN Transfer A bulk IN transfer consists of single or multiple transactions The USB host sends an IN token in the IN transaction When the USB device receives the IN token it sends a data packet to the USB host and waits for an ACK handshake from the USB host When the USB device receives the IN token when it is unable to send data packets it returns a NAK handshake to the USB host Figure 2 16 shows the IN transaction sequence When the USB function module receives an IN token when there is no valid data in the EP2FIFO it automatically returns a NAK handshake to the USB host The USB function module determines if there is any valid data in the EP2FIFO using the EP2PKTE bit in the USBTRG register When the module receives the IN token when there is valid data in the EP2FIFO the USB function module sends the data in the EP2FIFO to the USB host and waits for an ACK handshake from the USB host When the ACK handshake is received the USB function module sets the data transmit complete flag using the EP2EMPTY bit in the USBIFR2 register The sample program periodically transfers data in bulk transfer mode within the main loop When the serial communication generates data in the bulk IN transfer RAM that should be transmitted to the USB host the sample program confirm
12. 201EJ0100 Rev 1 00 August 20 2014 ENESAS Page 19 of 26 SH7216 Group USB Communication Class Application Note 3 System Example of the USB Communication Class USB to serial conversion system is implemented in this sample program as the USB communication class typical example 3 1 Overview The sample program converts USB to serial using the USB function module and the serial communication interface SCI embedded in the SH7216 MCU To transfer keyboard input characters text files or binary files activate the terminal software both on the USB host PC in this case and on the serial device For example some characters are input using the keyboard of the USB host and the characters are transferred to the serially connected device On the other hand some characters are input using keyboard of the serially connected device for transfer to the USB host A system configuration of the USB to serial conversion is shown in Figure 3 1 and Table 3 1 lists its specifications USB to serial conversion LSI SH7216 USB B connector Serial connector j USB cable Serial cable N Serial device USB to serial converter PC FA machine Terminal adapter etc a Hardware configuration Serial application Serial application Virtual serial port driver USB to serial conversion driver Serial port driver USB driver USB driver Hardware Hardware Hardware Hardware USB USB Serial Serial b Software configuration Figure
13. 3 1 System Configuration Table 3 1 System Specification Detect a connection to the USB host The port pulls up the D pin to detected by the USB host 1 Decode requests processes the Data stage and Status stage of the USB request transmitted from the USB host in the control transfer 2 Sends the descriptor information to Get Descriptor command to connect with the USB host as a USB communication class 3 Descriptor samples are described in the SetUsblInfo h file and those data are send to the USB host Supports the following USB communication class commands Get Line Coding Set Line Coding Set Control Line State and Send Break Control transfer USB standard request Control transfer USB communication class request RO1AN2201EJ0100 Rev 1 00 Page 20 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Bulk IN OUT transfer Executes the bulk IN OUT transfer 1 Sends the received data from the USB host in bulk OUT transfer to he serial device by serial OUT transfer 2 Sends the received data from the serial device by serial IN transfer o the USB host in bulk IN transfer USB to serial data conversion Note Table 3 2 lists the default value of the vendor ID and product ID in the device descriptor sample These values MUST be changed when applied to the user system Table 3 2 Vendor ID and Product ID Sample Date _ _ ________________Description V
14. 35 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 301 Tower A Central Towers 555 Langao Road Putuo District Shanghai P R China 200333 Tel 86 21 2226 0888 Fax 86 21 2226 0999 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei 10543 Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics pele alg Pte Ltd 80 Bendemeer Road Unit 06 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Ku Seoul 135 920 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2014 Renesas Electronics Corporation All rights reserved Colophon 4 0
15. 89E5J RO1AN2201EJ0100 Rev 1 00 Page 3 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 2 Applications This sample program uses the USB function module to execute the control IN control OUT bulk IN and bulk OUT transfers The sample program also converts USB to serial signals and vice versa based on the USB communication class 2 1 Features The USB function module has an embedded USB 1 1 compliant USB Device Controller UDC and operates the USB protocols automatically Figure 2 1 is a block diagram of the USB function module On chip peripheral bus USB function module Interrupt request signal USIO USI Status and DMA DTC transfer lt control registers request signal USBRXI0 USBTXIO USBRXI1 USBTXI1 Protocol processor Transceiver USB clock 48 MHz Figure 2 1 Block Diagram of USB The features of the on chip USB function module of the SH7216 are as follows e Automatic processing of USB protocol e Automatic processing of USB standard commands for endpoint 0 Some commands need to be processed through the software e Transfer speed Full speed e Interrupt requests Generation of interrupt signals needed for USB transmission and reception e Clock External input clock generated by USB oscillator 48 MHz e Low power mode e Integrated bus transceiver e Endpoint configurations There are ten mounted endpoints for each transfer mode and transfers
16. QEN ESAS APPLICATION NOTE R01AN2201EJ0100 SH7216 Group Rev 1 00 l l August 20 2014 USB Function Module USB Communication Class Application Note Introduction This document explains how to implement the system applied to the USB communication class as an application example for the SH7216 Group s USB function module This document and the sample program described are examples of the USB function module and are therefore not guaranteed by Renesas Target Device This example supports the following device SH7216 Group RO1AN2201EJ0100 Rev 1 00 Page 1 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Contents Me VOI IS a vin ancena E E E E E E 3 1 1 Functions Used 0 0 ccc e cece ccc cccccccececececcccccececcuuececceuuuececscuauuecscauaunececauuaesecscaeaenenstsuaeaenecetsceteetersnaenens 3 1 2 Applicable Conditions ciao seeiecacecenmesciseeverannscncecosisesiscaenceoodaanwauecndeeseeleannetanciisuctusinsaneetadeddedeennedestenddeans 3 1 3 Related documents ccccccceccccecececsceccucecsceccucucecsccucusecseauausecscseucunenecscsuauaunecseauaunenscauauneravaeeens 3 Ze AOP ae N E E E EE 4 NFS aes cc sree access csc ssc ca acien cuit otcte scimr enced deren ceaemenatelsseieectatsncecesacdeneedanneeenedctanseanedsavetsctaceesepsaeeaiaeeca 4 2 2 USB Communication via the USB Function MOUIe c ccccccecceceececcecceccceccuccccuececeececeaeaes 5 2 3 Detecting a Connection
17. U board ROK572167CO0O1BR to the PC1 Then use an RS 232C serial cable to connect the SH7216 CPU board to the PC2 cross connect PC1 behaves as the USB host and PC2 behaves as the serial device Figure 3 6 shows the USB to serial conversion environment Terminal 1 Terminal 2 ABC DEF USB to serial conversion i USB Serial E communication Communication SH7216 CPU board ROK572167C001BR Serial device PC1 USB host Figure 3 6 USB to Serial Conversion Environment 3 4 1 INF Files After the sample program is loaded and written to the SH7216 CPU board and is connected to the PCI with a USB cable for the first time the device driver needs to be installed on the USB host computer Install the Windows standard USB communication class device driver usbser sys as the device driver INF file is used for the driver installation This sample program includes following INF files in the inf directory 1 RN _CommClass_32 inf Windows 2000 Windows XP Windows Vista 32bit and Windows 7 32bit 2 RN _CommClass_64 inf Windows Vista 64bit and Windows 7 64bit Note VID_045B and PID_0020 MUST be changed according to the Vendor ID and Product ID set in the device descriptor Table 3 3 shows the default values Table 3 3 Vendor ID and Product ID in the INF File Value VID_045B Indicates the Vendor ID 0x045B PID 0020 Indicates the Product ID 0x0020 RO1AN2201EJ0100 Rev 1 00 Page 25 of 26 August 20 20
18. al OUT transfer When the bulk OUT transfer RAM can store the data by the serial OUT transfer the sample program enables the EP1FULL interrupt When the EP1FULL interrupt is enabled the suspended EPIFULL interrupt occurs to transfer data in the bulk OUT transfer Figure 3 4 shows an operation flow of the serial OUT transfer RO1AN2201EJ0100 Rev 1 00 Page 22 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Sample Program Software Serial OUT transfer Operation start D ActSerialOut Calculates transfer length Transfer length is more than 40byte Set transfer length to 40byte ExSerialOut SCI1 SCSSR TDRE 1 Writes transmit data to SCI1 SCTDR r Clears SCI1 SCSSR TDRE bit to 0 Bulk OUT transfer is disabled e bulk OUT transfe RAM can allocate the The suspended EP1FULL interrupt data area occurs when EP1FULL interrupt is enabled by the serial OUT transfer Yes Enables EP1FULL interrupt USBIER2 EP1FULLE 1 C Operation end Figure 3 4 Serial OUT Transfer Operation Flow RO1AN2201EJ0100 Rev 1 00 August 20 2014 RENESAS Page 23 of 26 SH7216 Group USB Communication Class Application Note 3 3 2 Serial IN Transfer Serial IN communication is activated by the serial receive interrupt and executed by the ActSerialIn function The sample program stores s
19. and and executes the Data Stage and the Status stage automatically The software does no operation USB standard Set Configuration request Set Feature USB communication class Get Line Coding request Other USB commands The software returns a STALL handshake The software decodes the command and executes the Data Stage and the Status stage RO1AN2201EJ0100 Rev 1 00 Page 8 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 2 4 1 Setup Stage The Setup stage is composed of one setup transaction The USB host sends a setup token or data packet USB command then returns a handshake in response to the data packet USB command that the USB device received Figure 2 5 shows the setup transaction sequence The USB function module automatically executes the Setup stage Data stage and Status stage in response to the USB requests with some exceptions If the received request is not a USB standard request the USB function module holds the received request in the EPOs data register USBEPDROs and generates the setup request receive complete interrupt using the SETUPTS bit in the USBIFR1 register The sample program reads the USB request held in the data register USBEPDROs during the interrupt and decodes the USB request to determine how to process subsequent stages If the decoded USB request is a request to execute the control IN transfer the sample program writes the first data to tr
20. and Figure 2 4 shows each the control transfer stage configuration Control OUT transfer ae Control IN transfer Figure 2 3 Data Direction in the Data Stage Setup stage Data stage Status stage Control IN transfer Data direction inverted Control OUT transfer a 4 Control transfer without data Multiple transactions Figure 2 4 Control Transfer Stage Configuration a RO1AN2201EJ0100 Rev 1 00 Page 7 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note The USB function module decodes the request and automatically processes the Data stage and Status stage according to the USB standard request Some of the USB standard requests class requests and vendor requests should be executed by the software The sample program executes the Get Descriptor command which is the USB standard request to be processed by the software and the conversion between USB and serial communication as the typical example of the USB communication class To convert USB communication into serial communication the sample program executes USB communication class requests Table 2 3 lists USB commands and processing in the sample program When the sample program receives a USB command that it does not support it returns a STALL handshake Table 2 3 USB Commands and Processing in the Sample Program USB Command Processing in the Sample Program The hardware decodes the comm
21. ansfer to the USB host in the EP01 FIFO and the interrupt is completed Figure 2 6 shows an operation flow of the sample program The function DecComCommand processes USB communication class requests in the sample program DATA USB command Handshake Packet issued by the host Packet issued by the device Figure 2 5 Setup Transaction Sequence RO1AN2201EJ0100 Rev 1 00 Page 9 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Sample Program Software USBIFR1 interrupt Executes the ActControl ee l function in the USBIFR1 interrupt handler Operation Start Call ActControl Therafter ActControl internal operation Clears the setup request Receive complete flag SETUPTS 0 GetPacket Acquires a USB command Set the EPOS read complete flag EPOsRDFN 1 DecStandardCommand Judged by bit 6Jand 5 in bmRequest i Class command is bit 6 5 01 Operates the following commands Set Line Coding Set Control Line State Seeds Supported class Operates only Get line Coding command GetDescriptor command DecComCommands upported standard command y Set STALL state Set STALL state Eplnfo 0 PresentState STALL Prepares GetDescriptor data
22. ant sections of the document as well as any technical updates that have been issued for the products 1 Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual The input pins of CMOS products are generally in the high impedance state In operation with an unused pin in the open circuit state extra electromagnetic noise is induced in the vicinity of LSI an associated shoot through current flows internally and malfunctions occur due to the false recognition of the pin state as an input signal become possible Unused pins should be handled as described under Handling of Unused Pins in the manual 2 Processing at Power on The state of the product is undefined at the moment when power is supplied The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied In a finished product where the reset signal is applied to the external reset pin the states of pins are not guaranteed from the moment when power Is supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited
23. e USB host and waits for an ACK handshake from the USB host When the USB function module receives the ACK handshake it generates the data transmit complete interrupt using the EPOiTS in the USBIFR1 register The sample program identifies the type of the interrupt while it is being processed When it is the data transmit complete interrupt generated by the EPOiTS in the USBIFRI1 register the sample program clears the interrupt to complete the control transfer When it is the IN token receive interrupt generated by the EPOiTR bit in the USBIFR1I register the sample program enables 0 byte data in the EPOiIFIFO by setting the EPOiPKTE bit in the USBTRGI register to 1 and waits for the next interrupt to be generated Figure 2 12 shows an operation flow of the Status stage control OUT transfer by the sample program When the command is a USB communication class command Set Line Coding the sample program calls a Scifnit function to process the command RO1AN2201EJ0100 Rev 1 00 Page 14 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Sample Program Software USBIFR1 interrupt v Executes the ActControlOut l function in the USBIFR1 Operation start interrupt handler Call ActControlOut via ActControllnOut ActControlOut EPOi transmit complete interrupt USBIFR1 EPOiTS Clears 4 transmit lete fl No complete flag BIFR1 EPOiTS Saves control OUT transfer data SetControlOutCont
24. e data packet from the USB host in the EPOoFIFO and returns an ACK handshake to the USB host After the USB function module transmits an ACK handshake it generates the data receive complete interrupt using the EPOoTS bit in the USBIFR1 register When the function module receives the IN token that indicates the Data OUT stage is completed it generates the IN token receive interrupt using the EPOiTR bit in the USBIFR1 register The sample program identifies the type of the interrupt while it is being processed When it is not the data receive complete interrupt the EPOoTS bit in the USBIFRI register the sample program advances to the Status stage When it is the data receive complete interrupt the EPOoTS bit in the USBIFR1 register the sample program reads data in the EPOoFIFO sets the EPOoFIFO read complete bit and waits for the next interrupt to be generated Figure 2 10 shows an operation flow of Data OUT stage by the sample program RO1AN2201EJ0100 Rev 1 00 Page 12 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Handshake Packet issued by the host Packet issued by the device Figure 2 9 Data OUT Transaction Sequence Sample Program Software USBIFR1 interrupt Vv Executes the ActControlOut C Operation start function in the USBIFR1 interrupt handler Call ActControlOut via ActControllnOut ActControlOut
25. endor ID 0x045B Renesas Electronics Product ID 0x0020 SH7216 USB communication class driver 3 2 Operation Flow The sample program enters the main loop after initial settings are completed When the sample program receives a data packet from the serial device in serial IN transfer it stores the received packet in the bulk IN transfer RAM The stored data is transmitted to the USB host in a bulk IN transfer For details on bulk IN transfer refer to 2 5 2 For details on serial IN transfer refer to 3 3 2 When the sample program receives a data packet from the USB host in a bulk OUT transfer it stores the received data packet in the bulk OUT transfer RAM The stored data is transmitted to the serial device in the serial OUT transfer For details on the bulk OUT transfer refer to 2 5 2 For details on serial OUT transfer refer to 3 3 1 Figure 3 2 shows the data flow and Figure 3 3 shows an operation flow USB host Sample program Serial device USB I F Bulk OUT transfer Bulk OUT transfer RAM 256 Byte USB I F Bulk IN transfer Bulk IN transfer RAM Serial IN transfer 256 Byte Figure 3 2 Data Flow RO1AN2201EJ0100 Rev 1 00 Page 21 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Operation start gt Initializes SH7216 Initializes SCI operation Stores data in the bulk IN transfer RAM by the ser
26. ents Changes the state to WAIT y USBTRGO EPOIPKTE 1 Set EPOIPKTE bit to Validate the data in The EPOiFIFO y Disables EPOi transfer request interrupt USBIER1 EPOiITR 0 Clears EPOi transfer request flag USBIFRO EPOITR 0 t Line Coding comman Of the communication E Initializes SCI operation Scilnit Operationend Figure 2 12 Status Stage Control OUT Transfer Operation Flow RO1AN2201EJ0100 Rev 1 00 Page 15 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 2 5 Bulk Transfer A bulk transfer is used to communicate large amounts of data between the USB host and the USB device Bulk transfers are supported via bi directional communication flow for the data direction A bulk OUT transfer is the data flow from the USB host to the USB device and a bulk IN transfer is the data flow from the USB device to the USB host Figure 2 13 shows the data directions of the bulk IN and bulk OUT transfers Bulk OUT transfer Bulk IN transfer Figure 2 13 Data Direction in the Bulk Transfer 2 5 1 Bulk OUT Transfer A bulk OUT transfer is composed of single or multiple OUT transactions The USB host sends an OUT token and a data packet in the OUT transaction The USB device receives the out token first then receives the data packet and then
27. erially received data in the RAM for the bulk IN transfer When the RAM is full the sample program transmits Xoff in serial communication to disable the serial IN communication Figure 3 5 shows an operation flow of the Serial IN Communication Sample Program Software Serial IN transfer SCl1 RIE SCl1 TE or SCI1 RE interrupt occurs Operation start gt A Reads SCSSR register but for TEND bit ActSerialln SCI1 SCSSR FER bit 1 Framing error Yes occurred SCI1 SCSSR PER bit 1 _Erorend _ Yes Error end Parity error occurred Reads the received data from Receive Data Register SCI1 SCRDR r Clears received data register full flag SCI1 SCSSR RDRF bit SCI1 SCSSR ORER bit 1 Overrun error Yes occurred y Clears overrun flag SCI1 SCSSR ORER bit 0 y Writes the received data in the bulk IN transfer RAM emaining bulk transfer RAM area is not more than 64byte Yes l No Disables the serial IN communication Transfers Xoff in the serial OUT transfer v EG Operation end Figure 3 5 Serial IN Transfer Operation Flow RO1AN2201EJ0100 Rev 1 00 Page 24 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 3 4 Environment Setting Use a USB cable to connect the SH7216 CP
28. f each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations Itis the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electr
29. ial IN transfer Initializes USB operation Serial IN transfer is activated by the interrupt from the SCI Data exists in the bulk IN transfer RAM The data is transferred to the USB host ActBulkln vA in the bulk IN transfer Transfers data in the bulk IN transfer User select operation to adopt a standard serial application Pa If ZERO_LENGTH_PACKET macro e e is defined dashed area operation is executed revious packet in the bulk I transfer was max packet size Transfers 0 length data in the bulk IN transfer SSS Ss SSS SS SS SS SS eS SSS SS SS M Stores data in the bulk OUT transfer RAM in the bulk OUT transfer Bulk OUT transfer is activated by the Data exists in the bulk OUT interrupt from the USB transfer RAM The data is transferred to the serial ActSerialOut device by the serial IN transfer Transfers data by the serial IN transfer a Figure 3 3 Operation Flow 3 3 Serial Communication This sample program uses a SCI module for serial communication The serial OUT transfer is executed only when there is data in the bulk OUT transfer RAM and the serial IN transfer is executed only by the serial receive interrupt 3 3 1 Serial OUT Transfer This sample program uses the ActSerialOut function to execute serial OUT transfer Data in the bulk OUT transfer RAM is serially transmitted in seri
30. mitted from the USB host in the control transfer Bulk IN OUT transfers Executes bulk IN OUT transfers RO1AN2201EJ0100 Rev 1 00 August 20 2014 Page 5 of 26 rtENESAS SH7216 Group USB Communication Class Application Note 2 3 Detecting a Connection to the USB Host A connection to the USB host is detected using the cable connect interrupt the BRST bit in the USBIFRO register The cable connect interrupt occurs when a USB device cable is connected to the USB host After the user configures the MCU the sample program pulls up the USB data bus D pin using the general output port The USB host recognizes that a USB device is connected by the pull up Figure 2 2 shows an operation flow of the sample program Sample Program Software Reset Start Set CPG Set Power Down Mode Configures the MCU y Set PFC Set INTC USB and SCI1 y Scilnit Initializes the SCI module Set SCI clock source l Set SMR Set SCI communication parameter y Usbinit v Initializes the USB operation Set SCI interrupt v Clears the interrupt mask level InitBulkMem Initializes work area UsbStart Pull up enabled D pin PB15 to High SetUsbModule Set USB to active Configures End Point Set USBEPIR register Main loop Configures the interrupt Set USBIERO to USBIER2 and USBISRO to USBISR4 regi
31. onics products 11 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics 12 Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics CENESAS SALES OFFICES Renesas Electronics Corporation http www renesas com Refer to http www renesas com for the latest and detailed information Renesas Electronics America Inc 2801 Scott Boulevard Santa Clara CA 95050 2549 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 Dusseldorf Germany Tel 49 211 6503 0 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd Room 1709 Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100191 P R China Tel 86 10 82
32. oup USB Communication Class Application Note Sample Program Software USBIFR1 interrupt Executes the ActControlln function in the USBIFR1 interrupt handler Operation start Call ActControlln via ActControllnOut ActControlln When data direction changes the Data stage is completed Data receive and advance to the Status stage complete interrupt USBIFR1 EPOoT Executes the Status stage of the control IN transfer Clears USBIFR1 EPOITS interrupt flag PutPacket Writes data to peepee ease When set EPOIPKTE to 1 i data in the EPOIFIFO is validated USBTRGO EPOIPKTE 1 Figure 2 8 Data IN Stage Operation Flow 2 Data OUT Stage The USB host sends an OUT token and a data packet The USB device receives the OUT token first then receives the data packet and then returns an ACK handshake When the USB device cannot receive the data packet after it receives the OUT token it ignores subsequent data packets and returns a NAK handshake When the USB host receives the NAK handshake it tries to resend the OUT token and data packet Figure 2 9 shows the Data OUT transaction sequence When the USB function module cannot receive data packets when it receives the OUT token it automatically discards the subsequent data packet and returns a NAK handshake to the USB host When it receives the OUT token when it can accept data it holds th
33. receives an IN token without valid data in the EPOiFIFO it automatically returns a NAK handshake to the USB host When the module receives an IN token with valid data in the EPOiFIFO it sends the data in the EPOiFIFO to the USB host and waits for an ACK handshake from the USB host When the USB function module receives an ACK handshake it generates the data transmit complete interrupt using the EPOiTS bit in the USBIFRO register On the contrary when the module receives an OUT token that indicates the Data IN stage has been completed it generates the data receive complete interrupt using the EPOoTS bit in the USBIFRO register The sample program identifies the type of the interrupt while it is being processed When it is the data receive complete interrupt the EPOoTS bit in the USBIFRO register the sample program advances to the Status stage When it is the data transmit complete interrupt the EPOiTS bit in the USBIFRO register data that should be sent to the USB host was written in the EPOiFIFO and the sample program waits for the next interrupt Figure 2 8 shows an operation flow of the Data IN stage by the sample program DATAO 1 y ACK Handshake Packet issued by the host Packet issued by the device Figure 2 7 Data IN Transaction Sequence RO1AN2201EJ0100 Rev 1 00 Page 11 of 26 August 20 2014 RENESAS SH7216 Gr
34. s if the EP2FIFO is empty When the EP2FIFO is empty the sample program writes the data in the EP2FIFO sets the PE2PKTE bit to 1 and enables the data in the EP2FIFO When the EP2FIFO is not empty the sample program is idle and waits for the USB function module to finish transferring data to the USB host DATAO 1 y ACK Handshake Packet issued by the host Packet issued by the device Figure 2 16 Bulk IN Transaction Sequence RO1AN2201EJ0100 Rev 1 00 Page 18 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note Sample Program Software main loop operation ita in the bulk IN by serial IN transfer Bulk IN transfer called in the a main loopperiodically Operation start D a Serial IN transfer Bulk IN transfer data Is there remaining data to transfer the USB host Is there received data by serial IN transfer exists ActBulkln EP2FIFO is not full USBIFRO EP2 EMPTY 1 PutPacket Writes data to USBEP2 data register USBEPDR2 l USBTRG1 EP2PKTE 1 Vv Serial IN transfer operation When No operation executes set EP2PKTE to 1 data in the EP2FIFO is validated iq y Operation end Figure 2 17 Bulk IN Transfer Operation Flow R01AN2
35. s of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or o
36. sters interrupt ActBusReset Clears SW flags and buffers Clears the bus reset flag USBIFRO BRST 0 Clears all EP FIFOs C Operation end Figure 2 2 Detecting a Connection to the USB Host RO1AN2201EJ0100 Rev 1 00 Page 6 of 26 August 20 2014 RENESAS SH7216 Group USB Communication Class Application Note 2 4 Control Transfer A control transfer is a USB transfer that uses the endpoint 0 as the default pipe and must be supported by all USB devices The USB host issues a USB standard request to the USB device and configures the device A control transfer can be used to issue a class or vendor specific request command A control transfer is composed of a Setup stage Data stage not in all cases and Status stage The Data stage consists of multiple bus transactions Control transfers are supported via bi directional communication flow according to the data direction of the Data stage A control OUT transfer is the data flow from the USB host to the USB device during the Data stage A control IN transfer is the data flow from the USB device to the USB host during the Data stage The Data stage is completed when the USB host transmits a token whose data direction is inverted to the previous data Stages The Status stage is the stage that transmits the inverted token to the USB host Figure 2 3 shows the Data direction in the Data stage
37. therwise misappropriation of Renesas Electronics product Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems and safety equipment etc Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics You should
38. ule generates the data receive complete interrupt using the EPOoTS bit in the USBIFRI register The sample program set the EPOoFIFO read complete bit USBTRGO EPOoRDFN during an interrupt to wait for the next interrupt Figure 2 11 shows an operation flow of the Status stage control IN transfer by the sample program Sample Program Software USBIFR1 interrupt Executes the ActControlln Operation start function in the USBIFR1 interrupt handler Call ActControlln via ActControllnOut ActControlln Clears EPO related interrupt flag other than SETUPTS flag y Changes the state to WAIT l Writes 1 in the EPOo read complete bit USBTRGO EPOORDFN 1 Figure 2 11 Status Stage Control IN Transfer Operation Flow 2 Status Stage of the Control OUT Transfer The USB host sends an IN token The USB device sends a 0 byte data packet to the USB host after it receives the IN token Then the USB device waits for an ACK handshake from the USB host When the USB function module receives the IN token it generates the IN token receive interrupt using the EPOiTR bit in the USBIFR1 register When the USB function module receives an IN token when there is no valid O byte data packet in the EPOiFIFO it automatically returns a NAK handshake to the USB host When the USB function module has a valid 0 byte data packet in the EPOiFIFO when it receives the IN token it sends a 0 byte data packet to th

Download Pdf Manuals

image

Related Search

Related Contents

view manual S2000-WJ04 (pdf 2.3mb)  Maintenance and Service Guide  Untitled    Dataram DTM68104A memory module  Life Fitness Lifecycle Aerobic Trainer 6000 User's Manual  Réserve naturelle de paysages  THE MESONH USER'S GUIDE  South Shore Furniture 2813A4 Instructions / Assembly  

Copyright © All rights reserved.
Failed to retrieve file