Microchip Technology DM240015 Data Sheet

Page of 472
PIC24FJ128GC010 FAMILY
DS30009312B-page 270
 
 2012-2013 Microchip Technology Inc.
19.2
USB Buffer Descriptors and the 
BDT
Endpoint buffer control is handled through a structure
called the Buffer Descriptor Table (BDT). This provides
a flexible method for users to construct and control
endpoint buffers of various lengths and configurations.
The BDT can be located in any available 512-byte,
aligned block of data RAM. The BDT Pointer
(U1BDTP1) contains the upper address byte of the
BDT and sets the location of the BDT in RAM. The user
must set this pointer to indicate the table’s location.
The BDT is composed of Buffer Descriptors (BDs)
which are used to define and control the actual buffers
in the USB RAM space. Each BD consists of two 16-bit,
“soft” (non-fixed-address) registers, BDnSTAT and
BDnADR, where n represents one of the 64 possible
BDs (range of 0 to 63). BDnSTAT is the status register
for BDn, while BDnADR specifies the starting address
for the buffer associated with BDn.
Depending on the endpoint buffering configuration
used, there are up to 64 sets of Buffer Descriptors, for
a total of 256 bytes. At a minimum, the BDT must be at
least 8 bytes long. This is because the “USB 2.0 OTG
Specification”
 mandates that every device must have
Endpoint 0 with both input and output for initial setup. 
Endpoint mapping in the BDT is dependent on three
variables:
• Endpoint number (0 to 15)
• Endpoint direction (RX or TX)
• Ping-pong settings (U1CNFG1<1:0>)
 illustrates how these variables are used to
map endpoints in the BDT.
In Host mode, only Endpoint 0 Buffer Descriptors are
used. All transfers utilize the Endpoint 0 Buffer Descrip-
tor and Endpoint Control register (U1EP0). For received
packets, the attached device’s source endpoint is
indicated by the value of ENDPT<3:0> in the USB status
register (U1STAT<7:4>). For transmitted packets, the
attached device’s destination endpoint is indicated by
the value written to the Token register (U1TOK).
FIGURE 19-7:
BDT MAPPING FOR ENDPOINT BUFFERING MODES
Note:
Since BDnADR is a 16-bit register, only
the first 64 Kbytes of RAM can be
accessed by the USB module.
EP1 TX Even
EP1 RX Even
EP1 RX Odd
EP1 TX Odd
Descriptor
Descriptor
Descriptor
Descriptor
EP1 TX 
EP15 TX 
EP1 RX 
EP0 RX 
PPB<1:0> = 00
EP0 TX 
EP1 TX 
No Ping-Pong
EP15 TX 
EP0 TX 
EP0 RX Even
PPB<1:0> = 01
EP0 RX Odd
EP1 RX 
Ping-Pong Buffer
EP15 TX Odd
EP0 TX Even
EP0 RX Even
PPB<1:0> = 10
EP0 RX Odd
EP0 TX Odd
Ping-Pong Buffers
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Descriptor
Note:
Memory area is not shown to scale.
Descriptor
Descriptor
Descriptor
Descriptor
Buffers
on EP0 OUT
on All EPs
EP1 TX Even
EP1 RX Even
EP1 RX Odd
EP1 TX Odd
Descriptor
Descriptor
Descriptor
Descriptor
EP15 TX Odd
EP0 RX
PPB<1:0> = 11
EP0 TX
Ping-Pong Buffers
Descriptor
Descriptor
Descriptor
on All Other EPs
Except EP0
Total BDT Space:
Total BDT Space:
Total BDT Space:
Total BDT Space:
128 Bytes
132 Bytes
256 Bytes
248 Bytes