English
Language : 

PIC24FJ256GB110-I Datasheet, PDF (206/328 Pages) Microchip Technology – 64/80/100-Pin, 16-Bit Flash Microcontrollers with USB On-The-Go (OTG)
PIC24FJ256GB110 FAMILY
17.5.3 SEND A FULL-SPEED BULK DATA
TRANSFER TO A TARGET DEVICE
1. Follow the procedure described in Section 17.5.1
“Enable Host Mode and Discover a Connected
Device” and Section 17.5.2 “Complete a Con-
trol Transaction to a Connected Device” to
discover and configure a device.
2. To enable transmit and receive transfers with
handshaking enabled, write 1Dh to U1EP0. If
the target device is a low-speed device, also set
the LSPD bit (U1EP0<7>). If you want the hard-
ware to automatically retry indefinitely if the
target device asserts a NAK on the transfer,
clear the Retry Disable bit, RETRYDIS
(U1EP0<6>).
3. Set up the BD for the current (EVEN or ODD) Tx
EP0 to transfer up to 64 bytes.
4. Set the USB device address of the target device
in the address register (U1ADDR<6:0>).
5. Write an OUT token to the desired endpoint to
U1TOK. This triggers the module’s transmit
state machines to begin transmitting the token
and the data.
6. Wait for the Transfer Done Interrupt Flag,
TRNIF. This indicates that the BD has been
released back to the microprocessor, and the
transfer has completed. If the retry disable bit is
set, the handshake (ACK, NAK, STALL or
ERROR (0Fh)) is returned in the BD PID field. If
a STALL interrupt occurs, the pending packet
must be dequeued and the error condition in the
target device cleared. If a detach interrupt
occurs (SE0 for more than 2.5 µs), then the
target has detached (U1IR<0> is set).
7. Once the transfer done interrupt occurs (TRNIF
is set), the BD can be examined and the next
data packet queued by returning to step 2.
Note:
USB speed, transceiver and pull-ups
should only be configured during the mod-
ule setup phase. It is not recommended to
change these settings while the module is
enabled.
17.6 OTG Operation
17.6.1 SESSION REQUEST PROTOCOL
(SRP)
An OTG A-device may decide to power down the VBUS
supply when it is not using the USB link through the Ses-
sion Request Protocol (SRP). Software may do this by
clearing VBUSON (U1OTGCON<3>). When the VBUS
supply is powered down, the A-device is said to have
ended a USB session.
An OTG A-device or Embedded Host may re-power the
VBUS supply at any time (initiate a new session). An
OTG B-device may also request that the OTG A-device
re-power the VBUS supply (initiate a new session). This
is accomplished via Session Request Protocol (SRP).
Prior to requesting a new session, the B-device must
first check that the previous session has definitely
ended. To do this, the B-device must check for two
conditions:
1. VBUS supply is below the Session Valid voltage, and
2. Both D+ and D- have been low for at least 2 ms.
The B-device will be notified of condition 1 by the
SESENDIF (U1OTGIR<2>) interrupt. Software will
have to manually check for condition 2.
Note:
When the A-device powers down the VBUS
supply, the B-device must disconnect its
pull-up resistor from power. If the device is
self-powered, it can do this by clearing
DPPULUP (U1OTGCON<7>) and
DMPULUP (U1OTGCON<6>).
The B-device may aid in achieving condition 1 by dis-
charging the VBUS supply through a resistor. Software
may do this by setting VBUSDIS (U1OTGCON<0>).
After these initial conditions are met, the B-device may
begin requesting the new session. The B-device begins
by pulsing the D+ data line. Software should do this by
setting DPPULUP (U1OTGCON<7>). The data line
should be held high for 5 to 10 ms.
The B-device then proceeds by pulsing the VBUS
supply. Software should do this by setting VBUSCHG
(UTOGCTRL<1>). When an A-device detects SRP sig-
naling (either via the ATTACHIF (U1IR<6>) interrupt or
via the SESVDIF (U1OTGIR<3>) interrupt), the
A-device must restore the VBUS supply by setting
VBUSON (U1OTGCON<3>).
The B-device should not monitor the state of the VBUS
supply while performing VBUS supply pulsing. When the
B-device does detect that the VBUS supply has been
restored (via the SESVDIF (U1OTGIR<3>) interrupt),
the B-device must re-connect to the USB link by pulling
up D+ or D- (via the DPPULUP or DMPULUP).
The A-device must complete the SRP by driving USB
Reset signaling.
DS39897B-page 204
Preliminary
© 2008 Microchip Technology Inc.