Renesas V850E2 Guida rapida

APPLICATION NOTE
R01AN0011EJ0102 Rev.1.02 Page 1 of 151
Jan 23, 2012
V850E2/MN4
USB MSC (Mass Storage Class) Driver
Summary
This application note describes the sample MSC (Mass Storage Class) driver for the USB function controller that is
incorporated in the V850E2/MN4 microcontroller.
The application note consists primarily of the following parts:
•Sampler driver specifications
•Environment for developing application programs that make use of the sample driver
•Reference information that is useful for using the sample driver
Target Device
RTE-V850E2/MN4-EB-S incorporating the V850E2/MN4 (μPD70F3512)
Contents
1. Introduction........................................................................................................................................2
2. Overview ...........................................................................................................................................3
3. USB Overview.................................................................................................................................10
4. Sample Driver Specifications..........................................................................................................20
5. Development Environment............................................................................................................110
6. Sample Driver Application.............................................................................................................142
7. Outline of the Starter Kit................................................................................................................149
R01AN0011EJ0102
Rev.1.02
Jan 23, 2012

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 2 of 151
Jan 23, 2012
1. 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.2 Intended Audiences
This application note is intended for the users who have basic understanding of the capabilities of the V850E2/MN4
microcontroller and who are to develop application systems utilizing that microcontroller.
1.3 Objective
The objective of this application note is to help the users acquire an understanding of the specifications for the
sample program for utilizing the USB function controller incorporated in the V850E2/MN4 microcontroller.
1.4 Organization
This application note is divided into the following topics:
•Overview of the USB standards
•Specifications for the sample driver
•Development environment (CubeSuite, Multi (Note1), or IAR Embedded Workbench (Note2))
•Application of the sample driver
(Note 1) Multi is a registered trademark of Green Hills SoftwareTM, Inc.
(Note 2) IAR Embedded Workbench is a registered trademark of IAR Systems AB.
1.5 How to Read this Document
The readers of this document are assumed to have general knowledge about electronics, logic circuits, and
microcontrollers.
⎯If you want to know the hardware capabilities and electrical characteristics of the V850E2/MN4 microcontroller
→Refer to the separately available V850E2/MN4 Microcontroller User’s Manual [Hardware].
⎯If you want to know the instruction set of the V850E2/MN4 microcontroller
→Refer to the separately available V850E2M User’s Manual [Architecture].

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 3 of 151
Jan 23, 2012
2. Overview
This application note describes the sample MSC (Mass Storage Class) driver for the USB function controller
incorporated in the V850E2/MN4 microcontroller. It is composed of the following topics:
•Specifications for the sample driver
•Environment for developing application programs that are to use the sample driver
•Reference information useful for making use of the sample driver
In this section, an overview of the sample driver and the description of the applicable microcontrollers are
introduced.
2.1 Overview
2.1.1 Features of the USB Function Controller
The USB function controller of the V850E2/MN4 microcontroller, which is the control target of this sample
driver, has the features listed below.
•Conforms to the USB (Universal Serial Bus Specification) 2.0.
•Operates as a full-speed (12 Mbps) device.
•Endpoints are configured as summarized in the table below.
Table 2.1 V850E2/MN4 Microcontroller’s Endpoint Configuration
Endpoint Name FIFO Size (Bytes) Transfer Type Remarks
Endpoint0 Read 64 Control transfer (IN) ⎯
Endpoint0 Write 64 Control transfer (OUT) ⎯
Endpoint1 64 ×2 Bulk transfer 1 (IN) 2-buffer configuration
Endpoint2 64 ×2 Bulk transfer 1 (OUT) 2-buffer configuration
Endpoint3 64 ×2 Bulk transfer 2 (IN) 2-buffer configuration
Endpoint4 64 ×2 Bulk transfer 2 (OUT) 2-buffer configuration
Endpoint7 64 Interrupt transfer (IN) ⎯
Endpoint8 64 Interrupt transfer (IN) ⎯
•Automatically responds to USB standard requests (except part of requests)
•Bus-powered or self-powered mode selectable
•Internal or external clock selectable (Note 2)
Internal clock: External 9.6 MHz ×20 (internally) ÷4 (48 MHz)
or External 7.2 MHz ×20 (internally) ÷3 (48 MHz)
External clock: Input to the USBCLK pin (fUSB = 48 MHz)
(Note 2) The internal clock is selected for the sample driver.

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 4 of 151
Jan 23, 2012
2.1.2 Features of the Sample Driver
The MSC (Mass Storage 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.
•Operates as a self-powered device.
•Recognized as a bulk-only device of the mass storage class when connected to the host.
•Can be formatted for arbitrary file systems by the host.
•Allows file and folder data to be written into internal RAM.
•Allows the file and folder data to be read out of internal RAM.
•Occupies memory areas of the following sizes (excluding that of the vector table):
ROM: Approx. 9.0 Kbytes
RAM: Approx. 25.5 Kbytes (Note 3)
(Note3) 24 Kbytes of the RAM area (approx. 25.5 Kbytes) is used as the data storage area.
For this reason, the data in the storage area is initialized when device power is turned off or
when the Reset SW is pressed.

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 5 of 151
Jan 23, 2012
2.1.3 Sample Driver Configuration
The sample driver is available in three versions, i.e., the CubeSuite version, the Multi version, and the IAR
Embedded Workbench version. Use the correct version of the sample driver according to your development
environment.
Each version of the sample driver is made up of the files that are described below.
(1) CubeSuite Version
The CubeSuite version of the sample driver comprises files that are summarized below.
Table 2.2 CubeSuite Version Sample Driver File Configuration
Folder File Outline
main.c Main routine
scsi_cmd.c SCSI command processing
usbf850.c USB initialization, endpoint control, bulk transfer, and control transfer
usbf850_storage.c MSC-specific processing
src
cstart.asm Bootstrap
main.h main.c function prototype declaration
scsi.h SCSI related macro definitions
usbf850.h usbf850.c function prototype declarations
usbf850_desc.h Descriptor definitions
usbf850_errno.h Error code definitions
usbf850_storage.h usbf850_storage.c function prototype declarations
usbf850_types.h User type declarations
include
reg_v850e2mn4.h USB function register definitions
Remarks: The sample driver package comes also with a set of project-related files for the CubeSuite (Renesas
Electronics’ integrated development tool suit). For further information, see section 5.2.1, Setting up
the Host Environment.

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 6 of 151
Jan 23, 2012
(2) Multi Version
The Multi version of the sample driver comprises files that are summarized below.
Table 2.3 Multi Version Sample Driver File Configuration
Folder File Outline
main.c Main routine
scsi_cmd.c SCSI command processing
usbf850.c USB initialization, endpoint control, bulk transfer, and control transfer
usbf850_storage.c MSC-specific processing
initial.s Bootstrap
src
vector.s Interrupt vector table declarations
main.h main.c function prototype declarations
scsi.h SCSI-related macro definitions
usbf850.h usbf850.c function prototype declarations
usbf850_desc.h Descriptor definitions
usbf850_errno.h Error code definitions
usbf850_storage.h usbf850_storage.c function prototype declarations
usbf850_types.h User type declarations
reg_v850e2mn4.h USB function register definitions
include
df3512_800.h V850E2/MN4 register definitions
Remarks: The sample driver package comes also with a set of project-related files for the Multi (Green Hills
SoftwareTM, Inc. integrated development tool suit). For further information, see section 5.4.1,
Setting up the Host Environment.

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 7 of 151
Jan 23, 2012
(3) IAR Embedded Workbench Version
The IAR Embedded Workbench version of the sample driver comprises files that are summarized below.
Table 2.4 IAR Embedded Workbench Version Sample Driver File Configuration
Folder File Outline
main.c Main routine
scsi_cmd.c SCSI command processing
usbf850.c USB initialization, endpoint control, bulk transfer, and control transfer
src
usbf850_storage.c MSC-specific processing
main.h main.c function prototype declarations
scsi.h SCSI-related macro definitions
usbf850.h usbf850.c function prototype declarations
usbf850_desc.h Descriptor definitions
usbf850_errno.h Error code definitions
usbf850_storage.h usbf850_storage.c function prototype declarations
usbf850_types.h User type declarations
include
reg_v850e2mn4.h USB function register definitions
Remarks: The sample driver package comes also with a set of project-related files for the IAR Embedded
Workbench. For further information, see section 5.6.1, Setting up the Host Environment.

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 8 of 151
Jan 23, 2012
2.2 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.5 List of Supported V850E2/MN4 Microcontroller Products
Internal Memory InterruptModel Name Part Number
Flash
Memory RAM
Internal
USB
Function Internal
Note4 External
Note 4
UM
μ
PD70F3510 1 Mbytes 64 Kbytes
+ 64 Kbytes
Host and
Function 180 29
μ
PD70F3512 1 Mbytes 64 Kbytes
+ 64 Kbytes
Host and
Function 190 29
μ
PD70F3514 1 Mbytes 64 Kbytes ×2
+ 64 Kbytes
Host and
Function 196 29
V850E2/MN4
μ
PD70F3515 2 Mbytes 64 Kbytes ×2
+ 64 Kbytes
Host and
Function 196 29
V850E2/MN4
User’s Manual
[Hardware]
(R01UH0011EJ)
(Note 4) Includes nonmaskable interrupts

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 9 of 151
Jan 23, 2012
2.2.2 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.
Primary memory controller (SRAM/SDRAM connectable)
Secondary memory controller (SRAM/SDRAM connectable)
•Serial interfaces
Asynchronous serial interface UART: 6 channels
Clock synchronous serial interface CSI: 6 channels
Asynchronous serial interface UART (FIFO): 4 channels
Clock synchronous serial interface CSI (FIFO): 4 channels
I2C: 6 channels
CAN: 2 channels (μPD70F3512, μPD70F3514, and μPD70F3515)
USB function controller: 1 channel
USB host controller: 1 channel
Ethernet controller : 1 channel (μPD70F3512, μPD70F3514, and μPD70F3515)
•DMA controllers
DMA controller: 16 channels
DTS: 128 channels maximum

V850E2/MN4 USB MSC (Mass Storage Class) Driver
R01AN0011EJ0102 Rev.1.02 Page 10 of 151
Jan 23, 2012
3. 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. For
example, it supports the hot-plug feature and allows a maximum of 127 devices to be connected together through the
use of additional connection nodes called hubs. The ratio of the PCs having the USB interface installed to the entire
PCs that are presently available is reaching almost 100%. It can safely be said that the USB interface has become the
standard interface for connecting the PC and peripheral devices.
The USB standard is formulated and managed by the organization called the USB Implementers Forum (USB-IF).
For details on the USB standard, visit the USB-IF’s official web site (www.usb.org).
3.1 Transfer Modes
The USB standard defines four types of transfer modes (control, bulk, interrupt, and isochronous). The major
features of the transfer modes are summarized in table 3.1.
Table 3.1 USB Transfer Modes
Transfer Mode
Item
Control Transfer Bulk Transfer Interrupt Transfer Isochronous
Transfer
Feature Transfer mode that
is used to exchange
information
necessary for
controlling
peripheral devices.
Transfer mode that
is used to handle a
large amount of data
nonperiodically.
Transfer mode that
is used to transfer
data periodically and
has a narrow band
width.
Transfer mode used
in applications that
are required of high
realtime
performance.
High speed (480
Mbps) 64 bytes 512 bytes 1 to 1024 bytes 1 to 1024 bytes
Full speed (12
Mbps) 8, 16, 32, or 64
bytes 8, 16, 32, or 64
bytes 1 to 64 bytes 1 to 1023 bytes
Allowable packet
size
Low speed (1.5
Mbps) 8 bytes ⎯1 to 8 bytes ⎯
Transfer priority 3 3 2 1
Questo manuale è adatto per i seguenti modelli
2
Indice

















