APPLICATION NOTE V850E2/MN4 USB CDC (Communication Device Class) Driver R01AN0010EJ0101 Rev.1.01 Feb 01, 2012 Introduction This application note describes the sample CDC (Communication Device Class) driver for the USB function controller that is incorporated in the V850E2/MN4 microcontroller.
V850E2/MN4 1. USB CDC (Communication Device Class) Driver Introduction 1.1 Note The sample program introduced in this application note is provided only for reference purposes. Renesas does not guarantee normal operation of the sample program under any circumstances. When using the sample program, make extensive evaluations of the driver on a user’s set. 1.
V850E2/MN4 2. USB CDC (Communication Device Class) Driver Overview This application note describes the sample CDC (Communication Device Class) driver for the USB function controller incorporated in the V850E2/MN4 microcontroller.
V850E2/MN4 2.1.2 USB CDC (Communication Device Class) Driver Features of the Sample Driver The CDC (Communication Device Class) sample driver for the V850E2/MN4 microcontroller has the features listed below. For details about the features and operations of the sample driver, see section 4, Sample Driver Specifications. • Conforms to the USB Communication Device Class Version 1.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Multi Version The Multi version of the sample driver comprises files that are summarized below. Table 2.3 Folder src Multi Version Sample Driver File Configuration File main.c usbf850.c usbf850_communication.c initial.s vector.s main.h usbf850.h usbf850_communication.h usbf850_desc.h usbf850_errno.h usbf850_types.h reg_v850e2mn4.h df3512_800.h XXX_CDC_VISTA.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver IAR Embedded Workbench Version The IAR Embedded Workbench version of the sample driver comprises files that are summarized below. Table 2.4 Folder src IAR Embedded Workbench Version Sample Driver File Configuration File main.c usbf850.c usbf850_communication.c main.h usbf850.h usbf850_communication.h usbf850_desc.h usbf850_errno.h usbf850_types.h reg_v850e2mn4.h XXX_CDC_VISTA.
V850E2/MN4 2.2 USB CDC (Communication Device Class) Driver V850E2/MN4 Microcontroller For details on the V850E2/MN4 microcontroller that is to be controlled by the sample driver, refer to the user’s manual [hardware] of the individual products. 2.2.1 Applicable Products The sample driver is applicable to the products that are listed below. Table 2.
V850E2/MN4 2.2.2 USB CDC (Communication Device Class) Driver Features The major features of the V850E2/MN4 are listed below. • Internal memory RAM: Single core, 64 Kbytes; Dual core, 64 Kbytes × 2 Flash memory: 1 Mbyte • Flash cache memory Single core: 16 Kbytes (4-way associative) Dual core: 16 Kbytes (4-way associative) × 2 • External bus interface Equipped with 2 systems of memory controllers.
V850E2/MN4 3. USB CDC (Communication Device Class) Driver USB Overview This section provides a brief description of the USB standard to which the sample driver conforms. USB (Universal Serial Bus) is a standard for interfacing various peripheral devices with a host computer with a common connector. It provides an interface that is more flexible and easier to use than conventional interfaces.
V850E2/MN4 3.2 USB CDC (Communication Device Class) Driver Endpoints An endpoint is an item of information used by the host device to identify a specific communication counterpart. An endpoint is specified by a number from 0 to 15 and the direction (IN or OUT). An endpoint need be provided for each data communication channel that is to be used by a peripheral device and cannot be shared by two or more communication channels*1.
V850E2/MN4 3.4 USB CDC (Communication Device Class) Driver Requests According to the USB specification, communication is initiated by the host device issuing a command called a request to all function devices. The request contains data such as the direction and type of processing and the address of the target function device. Each function device decodes the request, determines whether the request is directed to itself, and responds to the request only when it is directed to the device. 3.4.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Class Requests Class requests are unique to the device class. Response processing for class requests corresponding to the CDC abstract control model is implemented in the sample driver. The sample driver can respond to the following requests. • Send Encapsulated Command This request is used to issue commands in the communication class interface control protocol format.
V850E2/MN4 3.5 USB CDC (Communication Device Class) Driver Descriptors In the USB specification, a set of information that is specific to a function device and is encoded in a predetermined format is called a descriptor. Each function device sends its descriptor in response to a request from the host device. 3.5.1 Types The following five types of descriptors are defined: • Device descriptor This descriptor is present in all types of devices.
V850E2/MN4 3.5.2 USB CDC (Communication Device Class) Driver Formats The size and field structure of descriptors varies depending on the descriptor type as summarized in the tables below. The data in each field is arranged in little endian format. Table 3.
V850E2/MN4 USB CDC (Communication Device Class) Driver Table 3.
V850E2/MN4 4. USB CDC (Communication Device Class) Driver Sample Driver Specifications This section contains a detailed description of the features and operations of the USB communication device class (CDC) sample driver for the V850E2/MN4 microcontroller. It also describes the specifications for the functions of the sample driver. 4.1 Overview 4.1.
V850E2/MN4 4.1.2 USB CDC (Communication Device Class) Driver Request Handling This section describes the USB requests supported by the sample driver. (1) Standard Requests The sample driver performs the following response processing for requests that the V850E2/MN4 does not automatically respond: (a) GET_DESCRIPTOR_string This request is used by the host to get the string descriptor of a function device.
V850E2/MN4 4.1.3 USB CDC (Communication Device Class) Driver Descriptor Settings The descriptor settings that the sample driver makes are summarized in the tables below. The settings of the individual descriptors are defined in the header file named “usbf850_desc.h.” (1) Device Descriptor This descriptor is sent in response to a GET_DESCRIPTOR_device request.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver Interface Descriptor This descriptor is sent in response to a GET_DESCRIPTOR_configuration request. Since the hardware automatically responds to the GET_DESCRIPTOR_configuration request, the settings are stored in the USFA0CIEn registers (n = 0 to 255) when the USB function controller is initialized. Since the sample driver uses two endpoints, two endpoint descriptors are set up. Table 4.
V850E2/MN4 (4) USB CDC (Communication Device Class) Driver Endpoint Descriptor This descriptor is sent in response to a GET_DESCRIPTOR_configuration request. Since the hardware automatically responds to the GET_DESCRIPTOR_configuration request, the settings are stored in the USFA0CIEn registers (n = 0 to 255) when the USB function controller is initialized. Since the sample driver uses three endpoints, three endpoint descriptors are set up. Table 4.
V850E2/MN4 (5) USB CDC (Communication Device Class) Driver String Descriptor This descriptor is sent in response to a GET_DESCRIPTOR_string request. When the sample driver receives a GET_DESCRIPTOR_string request, it fetches the string descriptor settings from the header file named “usbf850_desc.h” and stores them in the USFA0E0W registers of the USB function controller. Table 4.
V850E2/MN4 4.2 USB CDC (Communication Device Class) Driver Operations When the sample driver is started, it performs the sequence of processes that are illustrated in the figure below. This section describes the individual processes. Start Initialize CPU Initialize USB function controller Execute sample application Figure 4.1 Sample Driver Processing Flow R01AN0010EJ0101 Rev.1.
V850E2/MN4 4.2.1 USB CDC (Communication Device Class) Driver CPU Initialization Processing The CPU initialization processing routine sets up the parameters that are necessary for using the USB function controller. Start of CPU initialization Enable HCLK output H BUS initialization processing Initialize USB clock Initialize VBUS signal End of CPU initialization Figure 4.
V850E2/MN4 4.2.2 USB CDC (Communication Device Class) Driver USB Function Controller Initialization Processing The USB function controller initialization processing routine sets up the parameters necessary for starting the use of the USB function controller.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver Initializing the EPC Circuit Loads the USFA0EPCCTL register with “0x00000000” to cancel the EPC reset signal. (4) Initializing the USB Function Buffer Loads the USFBC register with “0x00000003” to enable the USBF buffer and floating provisions. (5) Setting up NAK for Control Endpoint Sets the EP0NKA bit of the USFA0E0NA register to 1.
V850E2/MN4 (9) USB CDC (Communication Device Class) Driver Setting up the Interrupt Mask Register Sets the mask bits associated with the interrupt sources of the USB function controller. The following registers are accessed during this processing: (a) The USFA0ICn registers (n = 0 to 4) are loaded with “0x00. This setting causes all interrupt sources to be cleared. (b) The USFA0FIC0 register is loaded with “0xF7” and the USFA0FIC1 register with “0x0F.
V850E2/MN4 4.2.3 USB CDC (Communication Device Class) Driver USBF Interrupt Processing (INTUSFA0I1) Of the interrupt requests (INTUSFA0I1) from the USB function controller, only those for which the interrupt mask has been cleared at initialization are reported. Therefore applications must clear the interrupt masks at initialization for all required interrupts. For all reported interrupts, the corresponding required processing will be performed.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver SETRQ Interrupt Processing If the SETRQ bit in the USFA0IS0 register is 1, the SETRQC bit in the USFA0IC0 register will be cleared to 0. Next, if both the SETCON bit in the USFA0SET register and the CONF bit in the USFA0MODS register are 1, the flag that indicates that set configuration request was processed (usbf850_busrst_flg) is cleared.
V850E2/MN4 4.3 USB CDC (Communication Device Class) Driver Function Specifications This section describes the functions that are implemented in the sample driver. 4.3.1 List of Functions Table 4.9 shows a list of functions that are implemented in the source files for the sample driver. Table 4.9 Source File main.c Sample Driver Functions Function Name main cpu_init SetProtectReg Description Main routine Initializes the CPU. Processes access to a write-protected register. usbf850.
V850E2/MN4 4.3.2 USB CDC (Communication Device Class) Driver Correlation among the Sample Driver Functions There are some sample driver functions that call another function during their execution. This function call relationships are shown below. main usbf850_recv_buf usbf850_data_receive usbf850_send_buf usbf850_rdata_length usbf850_send_null usbf850_ep_status usbf850_data_send Figure 4.6 Function Calls within main Processing R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_intusbf0 usbf850_buff_init usbf850_fifo_clear usbf850_sendstallEP0 usbf850_classreq usbf850_send_encapsulated_command usbf850_get_encapsulated_response usbf850_set_line_coding usbf850_set_line_coding usbf850_get_line_coding usbf850_set_control_line_state usbf850_sendstallEP0 usbf850_standardreq usbf850_sendstallEP0 usbf850_getdesc usbf850_sendstallEP0 usbf850_send_EP0 usbf850_sendstallEP0 Figure 4.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_classreq usbf850_send_encapsulated_command usbf850_sendstallEP0 usbf850_recieve_EP0 usbf850_sendstallEP0 usbf850_data_send usbf850_get_encapsulated_response usbf850_set_line_coding usbf850_receive_EP0 usbf850_sendstallEP0 usbf850_buff_init usbf850_fifo_clear usbf850_sendnullEP0 usbf850_get_line_coding usbf850_send_EP0 usbf850_sendstallEP0 usbf850_set_control_line_state usbf850_sendnullEP0 usbf850_sendstallEP0 Figure 4.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_send_buf usbf850_send_null usbf850_ep_status usbf850_ep_status usbf850_data_send usbf850_recv_buf usbf850_data_receive usbf850_rdata_length Figure 4.9 Function Calls in USB Communication Class Processing (2/2) R01AN0010EJ0101 Rev.1.
V850E2/MN4 4.3.3 USB CDC (Communication Device Class) Driver Function Descriptions This section contains a description of the functions that are implemented in the sample driver. (1) Functional Description Format The functional descriptions are given in the format shown below. Function Name [Synopsis] Gives a synopsis of the function. [C language format] Shows the format in C language [Parameters] Describes the parameters (arguments).
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Main Routine Functions main [Synopsis] Perform main processing. [C language format] void main(void) [Parameters] None [Return Value] None [Function] This function is called first when the sample driver is started. The function initializes first the CPU and then the USB function controller. Next, it performs the sample application processing and monitors the flag (usbf850_rsuspd_flg) that indicates that a suspend has occurred.
V850E2/MN4 USB CDC (Communication Device Class) Driver cpu_init [Synopsis] Initialize CPU. [C language format] void cpu_init(void) [Parameters] None [Return Value] None [Function] This function is called during initialization processing. It initializes the H bus and sets up the USB clock and other parameters that are necessary to use the USB function controller. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver SetProtectReg [Synopsis] Access write-protected register. [C language format] void SetProtectReg(volatile UINT32 *dest_reg, UINT32 wr_dt, volatile UINT8 *prot_reg) [Parameters] Parameter volatile UINT32 *dest_reg UINT32 wr_dt volatile UINT8 *prot_reg Description Protected register address Write value Protect command register address [Return Value] None [Function] This function writes a value into the given write-protected register.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver USB Function Controller Processing Functions usbf850_init [Synopsis] Initialize USB function controller. [C language format] void usbf850_init(void) [Parameters] None [Return Value] None [Function] This function is called during initialization processing. It allocates and sets up the data area, and sets interrupt request masks and other parameter items that are necessary to use the USB function controller. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_intusbf0 [Synopsis] Endpoint0 monitor processing Endpoint2 monitor processing [C language format] void usbf850_intusbf0(void) [Parameters] None [Return Value] None [Function] This function is an interrupt service routine that is called by the INTUSFA0I1 interrupt. For USB function controller interrupts that are not masked, it verifies the details of the interrupt and processes the interrupt that occurred. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_intusbf1 [Synopsis] Resume interrupt processing [C language format] void usbf850_intusbf1(void) [Parameters] None [Return Value] None [Function] This function is an interrupt service routine that is called by the INTUSFA0I2 interrupt. It clears the flag that indicates the suspend state and updates the resume flag. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_data_send [Synopsis] USB data transmit processing for bulk/interrupt in endpoints [C language format] INT32 usbf850_data_send(UINT8 *data, INT32 len, INT8 ep) [Parameters] Parameter UINT8 *data INT32 len INT8 ep Description Pointer to transmit data buffer Transmit data length Endpoint number of the endpoint to be used for data transmission [Return Value] Symbol len (>=0) DEV_ERROR Description Size of the data that was transmitted normally.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_data_receive [Synopsis] Receive USB data. [C language format] INT32 usbf850_data_receive(UINT8 *data, INT32 len, INT8 ep) [Parameters] Parameter UINT8 *data INT32 len INT8 ep Description Pointer to receive data buffer Receive data length Endpoint number of the endpoint to be used for data reception [Return Value] Symbol len (>=0) DEV_ERROR Description Size of the data that was transmitted normally.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_rdata_length [Synopsis] Get USB receive data length. [C language format] void usbf850_rdata_length(INT32 *len , INT8 ep) [Parameters] Parameter INT32* len INT8 ep Description Pointer to the address storing the receive data length Endpoint number of the data receiving endpoint [Return Value] None [Function] This function reads the receive data length of the specified endpoint. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_send_EP0 [Synopsis] Send USB data for Endpoint0. [C language format] INT32 usbf850_send_EP0(UINT8* data, INT32 len) [Parameters] Parameter UINT8* data INT32 len Description Pointer to transmit data buffer Transmit data size [Return Value] Symbol DEV_OK DEV_ERROR Description Normal termination Abnormal termination [Function] This function transfers data from the transmit data buffer to the transmit FIFO for Endpoint0, one byte at a time.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_receive_EP0 [Synopsis] Receive USB data for Endpoint0. [C language format] INT32 usbf850_receive_EP0(UINT8* data, INT32 len) [Parameters] Parameter UINT8* data INT32 len Description Pointer to receive data buffer Receive data size [Return Value] Symbol DEV_OK DEV_ERROR Description Normal termination Abnormal termination [Function] This function reads data from the receive FIFO for Endpoint0 into the receive data buffer, one byte at a time.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_send_null [Synopsis] Send Null packet for Bulk/Interrupt In Endpoint.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_sendnullEP0 [Synopsis] Send NULL packet for Endpoint0. [C language format] void usbf850_sendnullEP0(void) [Parameters] None [Return Value] None [Function] This function sends a Null packet from the USB function controller by clearing the FIFO for Endpoint0 and setting the bit that specifies the end of data to 1. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_sendstallEP0 [Synopsis] Send STALL response for Endpoint0. [C language format] void usbf850_sendstallEP0(void) [Parameters] None [Return Value] None [Function] This function causes the USB function controller to return a STALL response by setting the bit that indicates the use of a STALL handshake to 1. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_ep_status [Synopsis] Notify state of FIFO for Bulk/ Interrupt In Endpoint.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_fifo_clear [Synopsis] Clear FIFO for Bulk/ Interrupt Endpoint. [C language format] void usbf850_fifo_clear(INT8 in_ep, INT8 out_ep) [Parameters] Parameter INT8 in_ep INT8 out_ep Description Data transmitting Endpoint Data receiving Endpoint [Return Value] None [Function] This function clears the FIFO for the specified Endpoint (Bulk/Interrupt) and the data receive flag (usbf850_rdata_flg). R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_standardreq [Synopsis] Process standard request not automatically responded by USB function controller. [C language format] void usbf850_standardreq(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to the address storing the receive data length [Return Value] None [Function] Function that is called for the CPUDEC interrupt factor for INTUSFA0I1 interrupt processing.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_getdesc [Synopsis] Process GET_DESCRIPTOR request. [C language format] void usbf850_getdesc(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to the address storing the receive data length [Return Value] None [Function] This function is called to process standard requests that are not automatically responded by the USB function controller.
V850E2/MN4 (4) USB CDC (Communication Device Class) Driver USB Communication Class Processing Functions usbf850_classreq [Synopsis] Process CDC class request. [C language format] void usbf850_classreq(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to area storing the request data [Return Value] None [Function] This function is called for the CPUDEC interrupt source during INTUSFA0I1 interrupt processing.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_send_encapsulated_command [Synopsis] Send Encapsulated Command request processing [C language format] void usbf850_send_encapsulated_command(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to area storing the request data [Return Value] None [Function] This function calls the data reception processing function (usbf850_data_receive()) to acquire the data received by Endpoint0 and calls the data transmissio
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_set_line_coding [Synopsis] Set Line Coding request processing [C language format] void usbf850_set_line_coding(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to area storing the request data [Return Value] None [Function] This function calls the data reception processing function (usbf850_data_receive()) to acquire the data received by Endpoint0 and writes that data to a UART_MODE_INFO structure.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_get_line_coding [Synopsis] Get Line Coding request processing [C language format] void usbf850_get_line_coding(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to area storing the request data [Return Value] None [Function] This function calls the data transmission processing function (usbf850_data_send()) to send the value of the UART_MODE_INFO structure from Endpoint0. R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver usbf850_set_control_line_state [Synopsis] Set Control Line State request processing [C language format] void usbf850_set_control_line_state(USB_SETUP *req_data) [Parameters] Parameter USB_SETUP *req_data Description Pointer to area storing the request data [Return Value] None [Function] This function calls the Endpoint0 null packet transmit processing function (usbf850_sendnullEP0()). R01AN0010EJ0101 Rev.1.
V850E2/MN4 5. USB CDC (Communication Device Class) Driver Sample Application Specifications This section describes the sample application that is included in the sample driver. 5.1 Overview This sample application is provided as a simple example of use of the USB communication device class driver and is embedded in the main routine of the sample driver. This sample application performs the sequence of processing required to read data received by the USB function controller and transmit that read data.
V850E2/MN4 (1) USB CDC (Communication Device Class) Driver User Data FIFO Initialization Verification The sample application calls user data FIFO status notification function (usbf850_get_bufinit_flg()). If the FIFO is in the normal state it proceeds to transmit processing result verification, and if the FIFO is in the initialized state it clears the transmission result (clears the CDC user data transmit result to 0).
V850E2/MN4 5.3 USB CDC (Communication Device Class) Driver Function Usage In the source file main.c, which includes the sample application, use of the sample driver functions is coded as shown below. For detailed information on these functions, see section 4.3, Function Specifications. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #pragma ioreg #include "usbf850_types.h" #include “main.h" #include “usbf850_errno.h" #include “usbf850.h" #include “usbf850_communication.h" #include "reg_v850e2mn4.
V850E2/MN4 (1) USB CDC (Communication Device Class) Driver Definitions and Declarations The two header files usbf850.h and usbf850_communication.h are included so that the sample driver functions can be used. Also, a user buffer with a size adequate for processing one packet of data is provided for user data (the maximum packet size for bulk endpoints in USB full speed is 64 bytes). (2) CPU Initialization The CPU initialization function (cpu_init()) is called.
V850E2/MN4 6. USB CDC (Communication Device Class) Driver Development Environment This section gives an example of constructing an environment for developing application programs using the USB communication device class sample driver for the V850E2/MN4 and the procedures for debugging them in that environment. 6.1 Development Environment This section introduces a sample development configuration of hardware and software tool products. 6.1.
V850E2/MN4 6.1.2 USB CDC (Communication Device Class) Driver Program Development The hardware and software that are summarized below are required to develop a system using the sample driver. Table 6.1 Example of Program Development Environment Configuration Component Products Hardware Host machine Product Example ⎯ Software CubeSuite Multi IAR Embedded Workbench CX850 CCV850 ICCV850 Integrated development tool Compiler 6.1.3 Remarks PC/AT™ compatible (OS: Windows XP or Windows Vista®) V1.40 V5.
V850E2/MN4 6.2 USB CDC (Communication Device Class) Driver Setting up a CubeSuite Environment This section explains the preparatory steps that are required to develop or debug using CubeSuite which is introduced in section 6.1, Development Environment. See section 6.4, Setting up a Multi Environment, when using Multi for program development and debugging. See section 6.6, Setting up IAR Embedded Workbench Environment, when using IAR Workbench for program development and debugging. 6.2.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver Installing Device Files Copy the V850E2/MN4 device files for CubeSuite in the folder where CubeSuite is installed. Example: D:\Renesas Electronics CubeSuite\CubeSuite\Device_Custom Figure 6.3 Example of Destination Folder for Storing the Device Files (4) Setting up a Workspace Follow the procedure given below when using the project-related files that come with the sample driver package.
V850E2/MN4 <2> USB CDC (Communication Device Class) Driver The “Open” dialog box will appear. Select the project file for CubeSuite which is located in the “prj” folder in the directory in which the sample driver is installed. Figure 6.5 Selecting the CubeSuite Project File R01AN0010EJ0101 Rev.1.
V850E2/MN4 (5) USB CDC (Communication Device Class) Driver Setting up the Build Tool Follow the procedure given below to select the version of CX850 which is to be used as the build tool and to designate V850E2M MINICUBE as the debugging tool. <1> Select “CX (Build Tool)” from the “Project Tree” for CubeSuite to display its properties. Figure 6.
V850E2/MN4 <3> USB CDC (Communication Device Class) Driver Select “V850E2M MINICUBE (Debug Tool)” from the project tree and select “Using Debug Tool” → ”V850E2M MINICUBE” from the right-click menu. Figure 6.8 Selecting the Debugging Tool R01AN0010EJ0101 Rev.1.
V850E2/MN4 6.2.2 USB CDC (Communication Device Class) Driver Setting up the Target Environment You connect the target device to be used for debugging to the host machine. The procedure is common to CubeSuite, Multi, and IAR Embedded Workbench. (1) Connecting to the Debugging Port Connect between the RTE-V850E2/MN4-EB-S and the host machine. Connect the RTE-V850E2/MN4-EB-S and the host machine via the MINICUBE for debugging.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Host Driver Installation This section presents the procedure for using the virtual COM port host driver included with this sample driver. <1> When connection of the RTE-V850E2/MN4-EB-S is recognized by the host machine, it displays the “New hardware detected” message and starts the “Found New Hardware Wizard”. <2> The “Found New Hardware Wizard” dialog opens. Select, “No, not this time” and click “Next”. Figure 6.
V850E2/MN4 <4> USB CDC (Communication Device Class) Driver The next screen will be displayed. Select “Don’t search. I will choose the driver to install.” and click “Next”. Figure 6.12 Add New Hardware Wizard (3) <5> The next screen will be displayed. Click “Have Disk”. Figure 6.13 Add New Hardware Wizard (4) R01AN0010EJ0101 Rev.1.
V850E2/MN4 <6> USB CDC (Communication Device Class) Driver The “Install From Disk” dialog will open. Click “Browse...” to display the inf file folder in the directory that holds the sample driver. Figure 6.14 Browsing for .inf Files <7> Select the .inf file in the folder (XP, Vista, or Win7) that matches the OS used on the host system and click Open. Figure 6.15 Selecting a .inf File <8> The system will return to the “Install From Disk” dialog.
V850E2/MN4 <9> USB CDC (Communication Device Class) Driver The system will return to the “Found New Hardware Wizard”. Select “Renesas Electronics V850E2/MN4 Virtual UART” and click “Next”. Figure 6.17 Selecting the Device Driver to Install <10> The driver installation process will start. Figure 6.18 Driver Installation in Progress (1) R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver <11> The “Hardware Installation” dialog will be displayed. Click “Continue Anyway”. Figure 6.19 Driver Compatibility Verification Dialog <12> The driver will be installed. Depending on the computer environment, some amount of time may be required. <13> Click “Finish” after installation is completed. (3) Verify Device Allocation Open the Windows “Device Manager”.
V850E2/MN4 6.3 USB CDC (Communication Device Class) Driver Debugging in the CubeSuite Environment This section explains the procedure to debug an application program that is developed in the workspace introduced in section 6.2, Setting up the CubeSuite Environment. 6.3.1 Generating a Load Module To write a program into the target device, it is necessary to compile its source file that is coded in C or assembly language into a load module.
V850E2/MN4 6.3.2 USB CDC (Communication Device Class) Driver Loading and Executing You write (load) the generated load module into the target for execution. (1) Writing a Load Module Shown below is the procedure to write a load module into the RTE-V850E2/MN4-EB-S via CubeSuite. <1> Choose “Download” from the “Debug” menu and start the debugger. Figure 6.22 Starting the Debugger <2> The downloading of the load module is started via the debugging tool. Figure 6.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Running the Program Press the CubeSuite’s button or choose “Go” from the “Debug” menu. Figure 6.24 Running the Program R01AN0010EJ0101 Rev.1.
V850E2/MN4 6.4 USB CDC (Communication Device Class) Driver Setting up a Multi Environment This section explains the preparatory steps that are required to develop or debug using Multi which is introduced in section 6.1, Development Environment. 6.4.1 Setting up the Host Environment You create a dedicated workspace on the host machine. (1) Installing the Multi Integrated Development Tools Install Multi. Refer to the GHS user’s manual for details.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver Installing Device Files Copy the V850E2/MN4 device files for Multi in the folder where Multi is installed. Example: C:\Green\V800.V517D\devicefile Figure 6.26 Example of Destination Folder for Storing the Device Files (4) Starting Multi Select and start Multi Project File in “V850E2_MN4(CDC)_GHS.gpj” which is included in the sample driver package from the Explorer. Figure 6.27 Selecting the Multi Project File R01AN0010EJ0101 Rev.1.
V850E2/MN4 (5) USB CDC (Communication Device Class) Driver Setting up the Debugging Tool Given below is the procedure to use MINICUBE as the debugging tool. <1> Choose “Connect” from the Multi’s “Connect” menu to open the Connection Chooser. Figure 6.28 Starting the Connection Chooser <2> Select the “Create New Connection Method” icon from the “Connection Chooser” dialog box. Figure 6.29 Selecting the Create a new Connection Method R01AN0010EJ0101 Rev.1.
V850E2/MN4 <3> USB CDC (Communication Device Class) Driver In the “Create New Connection Method” dialog box, enter an arbitrary name in the Name textbox and select “Custom” in the Type combo box, then click the “Create…” button to create MINICUBE connection settings. In the example shown here, the name is set to “MINICUBE” in the Name textbox. Figure 6.30 Creating the Create New Connection Method <4> Connection Editor will then start.
V850E2/MN4 6.4.2 USB CDC (Communication Device Class) Driver Setting up the Target Environment You connect the target device to be used for debugging to the host machine. The procedure is common to CubeSuite, Multi, and IAR Embedded Workbench. (1) Connecting to the Debugging Port Connect between the RTE-V850E2/MN4-EB-S and the host machine. Connect the RTE-V850E2/MN4-EB-S and the host machine via the MINICUBE for debugging.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Host Driver Installation This section presents the procedure for using the virtual COM port host driver included with this sample driver. <1> When connection of the RTE-V850E2/MN4-EB-S is recognized by the host machine, it displays the “New hardware detected” message and starts the “Found New Hardware Wizard”. <2> The “Found New Hardware Wizard” dialog opens. Select, “No, not this time” and click “Next”. Figure 6.
V850E2/MN4 <4> USB CDC (Communication Device Class) Driver The next screen will be displayed. Select “Don’t search. I will choose the driver to install.” and click “Next”. Figure 6.35 Add New Hardware Wizard (3) <5> The next screen will be displayed. Click “Have Disk”. Figure 6.36 Add New Hardware Wizard (4) R01AN0010EJ0101 Rev.1.
V850E2/MN4 <6> USB CDC (Communication Device Class) Driver The “Install From Disk” dialog will open. Click “Browse...” to display the inf file folder in the directory that holds the sample driver. Figure 6.37 Browsing for .inf Files <7> Select the .inf file in the folder (XP, Vista, or Win7) that matches the OS used on the host system and click “Open”. Figure 6.38 Selecting a .inf File <8> The system will return to the “Install From Disk” dialog.
V850E2/MN4 <9> USB CDC (Communication Device Class) Driver The system will return to the “Found New Hardware Wizard”. Select “Renesas Electronics V850E2/MN4 Virtual UART” and click “Next”. Figure 6.40 Selecting the Device Driver to Install <10> The driver installation process will start. Figure 6.41 Driver Installation in Progress (1) R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver <11> The Install Hardware dialog will be displayed. Click Continue. Figure 6.42 Driver Compatibility Verification Dialog <12> The driver will be installed. Depending on the computer environment, some amount of time may be required. <13> Click “Finish” after installation is completed. (3) Verify Device Allocation Open the Windows “Device Manager”.
V850E2/MN4 6.5 USB CDC (Communication Device Class) Driver Debugging in the Multi Environment This section explains the procedure to debug an application program that is developed in the workspace that is introduced in section 6.4, Setting up the Multi Environment. 6.5.1 Generating a Load Module To write a program into the target device, it is necessary to compile its source file that is coded in C or assembly language into a load module.
V850E2/MN4 6.5.2 USB CDC (Communication Device Class) Driver Loading and Executing You write (load) the generated load module into the target for execution. (1) Programming the Load Module Shown below is the procedure to program a load module into the RTE-V850E2/MN4-EB-S via Multi. <1> Choose “Connect” from the Multi’s “Connect” menu to open the Connection Chooser. Figure 6.
V850E2/MN4 <3> USB CDC (Communication Device Class) Driver MULTI Debugger will then start. Choose “Debug Program” from the “File” menu and download the load module. Figure 6.47 Choosing a MULTI Debugger Menu The load module is generated in the “prj” folder under the name of “V850E2_MN4_CDC_GHS”. Select it and click the “Open” button. Figure 6.48 Selecting the Load Module R01AN0010EJ0101 Rev.1.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Running the Program Press the MULTI Debugger’s button or choose “Go on Selected Items” from the “Debug” menu. Figure 6.49 Running the Program R01AN0010EJ0101 Rev.1.
V850E2/MN4 6.6 USB CDC (Communication Device Class) Driver Setting up an IAR Embedded Workbench This section explains the preparatory steps that are required to develop or debug using IAR Embedded Workbench which is introduced in section 6.1, Development Environment. 6.6.1 Setting up the Host Environment You create a dedicated workspace on the host machine. (1) Installing the IAR Embedded Workbench Integrated Development Tools Install IAR Embedded Workbench.
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver Installing Device Files Copy the V850E2/MN4 device files for IAR Embedded Workbench in the folder where IAR Embedded Workbench is installed. Example: C:\Program Files\IAR Systems\Embedded Workbench 6.0 for V850 Kickstart\v850\inc Figure 6.51 Example of Destination Folder for Storing the Device Files (4) Starting the IAR Embedded Workbench Select the “V850E2_MN4(CDC)_IAR.
V850E2/MN4 (5) USB CDC (Communication Device Class) Driver Debugging Tool Settings This section presents the procedure when MINICUBE is used as a debugging tool. <1> Move the mouse pointer to the “V850E2_MN4(CDC)_IAR-Release” (or “Debug”), right click, and select “Options”. The Options dialog will be displayed. Figure 6.53 Option Selection <2> In the “Options for node “V850E2_MN4(CDC)_IAR”” dialog, select “Debugger” in the “Category” area. Figure 6.54 Debugger Selection R01AN0010EJ0101 Rev.1.
V850E2/MN4 <3> USB CDC (Communication Device Class) Driver Select “MINICUBE E2x” in the “Driver” item in the “Setup” tab and click “OK”. Figure 6.55 Debugger Selection R01AN0010EJ0101 Rev.1.
V850E2/MN4 6.6.2 USB CDC (Communication Device Class) Driver Setting up the Target Environment You connect the target device to be used for debugging to the host machine. The procedure is common to CubeSuite, Multi, and IAR Embedded Workbench. (1) Connecting to the Debugging Port Connect between the RTE-V850E2/MN4-EB-S and the host machine. Connect the RTE-V850E2/MN4-EB-S and the host machine via the MINICUBE for debugging.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Host Driver Installation This section presents the procedure for using the virtual COM port host driver included with this sample driver. <1> When connection of the RTE-V850E2/MN4-EB-S is recognized by the host machine, it displays the “New hardware detected” message and starts the “Found New Hardware Wizard”. <2> The “Found New Hardware Wizard” dialog opens. Select, “No, not this time” and click “Next”. Figure 6.
V850E2/MN4 <4> USB CDC (Communication Device Class) Driver The next screen will be displayed. Select “Don’t search. I will choose the driver to install.” and click “Next”. Figure 6.59 Add New Hardware Wizard (3) <5> The next screen will be displayed. Click “Have Disk”. Figure 6.60 Add New Hardware Wizard (4) R01AN0010EJ0101 Rev.1.
V850E2/MN4 <6> USB CDC (Communication Device Class) Driver The “Install From Disk” dialog will open. Click “Browse...” to display the inf file folder in the directory that holds the sample driver. Figure 6.61 Browsing for .inf Files <7> Select the .inf file in the folder (XP, Vista, or Win7) that matches the OS used on the host system and click “Open”. Figure 6.62 Selecting a .inf File <8> The system will return to the “Install From Disk” dialog.
V850E2/MN4 <9> USB CDC (Communication Device Class) Driver The system will return to the “Found New Hardware Wizard”. Select “Renesas Electronics V850E2/MN4 Virtual UART” and click “Next”. Figure 6.64 Selecting the Device Driver to Install <10> The driver installation process will start. Figure 6.65 Driver Installation in Progress (1) R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver <11> The “Hardware Installation” dialog will be displayed. Click “Continue Anyway”. Figure 6.66 Driver Compatibility Verification Dialog <12> The driver will be installed. Depending on the computer environment, some amount of time may be required. <13> Click “Finish” after installation is completed. (3) Verify Device Allocation Open the Windows “Device Manager”.
V850E2/MN4 6.7 USB CDC (Communication Device Class) Driver Debugging in the IAR Embedded Workbench Environment This section explains the procedure to debug an application program that is developed in the workspace introduced in section 6.6, Setting up the IAR Embedded Workbench Environment. 6.7.1 Generating a Load Module To write a program into the target device, it is necessary to compile its source file that is coded in C or assembly language into a load module.
V850E2/MN4 6.7.2 USB CDC (Communication Device Class) Driver Loading and Executing You write (load) the generated load module into the target for execution. (1) Writing a Load Module Shown below is the procedure to write a load module into the RTE-V850E2/MN4-EB-S via IAR Embedded Workbench. <1> Select “Download and Debug” from the “Project” menu in the IAR Embedded Workbench. Figure 6.69 Starting the Debugger <2> The downloading of the load module is started via the debugging tool.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Running the Program Press the IAR Embedded Workbench’s button or choose “Go” from the “Debug” menu. Figure 6.70 Running the Program R01AN0010EJ0101 Rev.1.
V850E2/MN4 6.8 USB CDC (Communication Device Class) Driver Operation Verification The results of executing the sample application included in the driver can be verified if a target device with the sample driver loaded is connected to the host machine via USB. First, run a terminal emulator (such as Tera Term) and verify that entered data is displayed. Note: For details on the sample application, see section 5, Sample Application Specifications. Figure 6.
V850E2/MN4 7. USB CDC (Communication Device Class) Driver Using the Sample Driver This section presents information that users need to know when using this USB communication device class sample driver for the V850E2/MN4 microcontroller. 7.1 Overview Normally, the need to modify the following sections will arise when using the sample driver. (1) Customization Rewrite the following sections as needed. • • • • The sample application section in the file main.
V850E2/MN4 7.2 USB CDC (Communication Device Class) Driver Customization This section describes the sections you should rewrite when using the sample driver. 7.2.1 Application Section The section indicated below in the file main.c codes some simple processing as an example of using the sample driver. Declare and code the processing actually required for the application in this section of the program.
V850E2/MN4 7.2.2 USB CDC (Communication Device Class) Driver Register Settings The registers that the sample driver uses (writes to) and their settings are defined in the file “usbf850.h.” By rewriting these values in the file according to the actual application, you can configure the operation of the target device through the sample driver. (1) File “usbf850.h” Defines the settings of the USB function controller registers. 7.2.3 Contents of the Descriptors The file “usbf850_desc.
V850E2/MN4 7.2.4 USB CDC (Communication Device Class) Driver Virtual COM Port Host Driver Settings The following sort of customization is also possible in relation to the driver installed in section 6.2.2 Setting up the Target Environment. (1) Changing the COM Port Number When a USB device connection is recognized, the host automatically allocates a COM port number for that device. However, this can be changed to be an arbitrary number.
V850E2/MN4 <3> USB CDC (Communication Device Class) Driver On the “Port Settings” tab, click “Advanced”. Figure 7.3 Port Settings Tab Display <4> The “Advanced Settings for COMn” dialog (where n is the number allocated by the host) will open. Select an arbitrary port number from the drop down list for the “COM Port Number” field. Figure 7.4 COM Port Number Specification Notes: 1. Do not select a port number that conflicts, i.e. that is being used by another device. 2.
V850E2/MN4 (2) USB CDC (Communication Device Class) Driver Changing the Properties Certain of the device properties and other information used by the Windows “Device Manager” can be changed to arbitrary values. The following items can be changed. <1> Device name (device list) <1> Figure 7.5 Device Name in the Device Manager <2> Device name, manufacturer name, and version (device properties) <1> <1> <2> <2> <3> Figure 7.6 Device Properties R01AN0010EJ0101 Rev.1.
V850E2/MN4 USB CDC (Communication Device Class) Driver Since these items are displayed based on information coded in the host driver (in the .inf file), they can be changed by modifying the .inf file. The figure shows the parts in the .inf file that corresponds to the numbered items above. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 ; .
V850E2/MN4 (3) USB CDC (Communication Device Class) Driver Changing the Vendor ID and Product ID When changing the vendor ID and product ID in the device descriptor, the same content must also be specified in the host driver (.inf file). In the .inf file, the vendor ID and product ID must be notated with the following format at the 15th line in listing 6-2. Vendor ID: A 4-digit hexadecimal number prefixed with “VID_”. Product ID: A 4-digit hexadecimal number prefixed with “PID_”. R01AN0010EJ0101 Rev.1.
V850E2/MN4 7.3 USB CDC (Communication Device Class) Driver Function Usage Processing that is frequently used or is of high generality is provided as functions that can simplify application coding and lead to reduced code size. See section 4.3, Function Specifications, for details on each of these functions. The following sections of the sample application shown in the listing can be reused as an example of the application of these predefined processing units.
V850E2/MN4 8. USB CDC (Communication Device Class) Driver Outline of the Starter Kit This section gives a brief description of the RTE-V850E2/MN4-EB-S starter kit for the V850E2/MN4, manufactured by Midas lab Inc. 8.1 Outline The RTE-V850E2/MN4-EB-S is a starter kit that allows you to experience the development of an application system using the V850E2/MN4.
V850E2/MN4 8.3 USB CDC (Communication Device Class) Driver Major Specifications The major specifications of the RTE-V850E2/MN4-EB-S are given below.
V850E2/MN4 USB CDC (Communication Device Class) Driver Website and Support Renesas Electronics Website http://www.renesas.com/ Inquiries http://www.renesas.com/inquiry All trademarks and registered trademarks are the property of their respective owners. R01AN0010EJ0101 Rev.1.
Revision Record Rev. 1.00 1.
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 manual, refer to the relevant sections of the manual. If the descriptions under General Precautions in the Handling of MPU/MCU Products and in the body of the manual differ from each other, the description in the body of the manual takes precedence. 1.
Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website.