Universal serial bus full-speed device interface (USB)
RM0365
1033/1080
DocID025202 Rev 7
Note:
In case of double-buffered or isochronous endpoints in the OUT direction, this address
location is referred to as USB_COUNTn_RX_1.
In case of double-buffered or isochronous endpoints in the IN direction, this address location
is used for USB_COUNTn_TX_1.
This table location is used to store two different values, both required during packet
reception. The most significant bits contains the definition of allocated buffer size, to allow
buffer overflow detection, while the least significant part of this location is written back by the
USB peripheral at the end of reception to give the actual number of received bytes. Due to
the restrictions on the number of available bits, buffer size is represented using the number
of allocated memory blocks, where block size can be selected to choose the trade-off
between fine-granularity/small-buffer and coarse-granularity/large-buffer. The size of
allocated buffer is a part of the endpoint descriptor and it is normally defined during the
enumeration process according to its maxPacketSize parameter value
(See “Universal
Serial Bus Specification”).
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
BLSIZE
NUM_BLOCK[4:0]
COUNTn_RX[9:0]
rw
rw
rw
rw
rw
rw
r
r
r
r
r
r
r
r
r
r
Bit 15
BL_SIZE:
Block size
This bit selects the size of memory block used to define the allocated buffer area.
–
If BL_SIZE=0, the memory block is 2-byte large, which is the minimum block
allowed in a half-word wide memory. With this block size the allocated buffer size
ranges from 2 to 62 bytes.
–
If BL_SIZE=1, the memory block is 32-byte large, which allows to reach the
maximum packet length defined by USB specifications. With this block size the
allocated buffer size theoretically ranges from 32 to 1024 bytes, which is the longest
packet size allowed by USB standard specifications. However, the applicable size is
limited by the available buffer memory.
Bits 14:10
NUM_BLOCK[4:0]:
Number of blocks
These bits define the number of memory blocks allocated to this packet buffer. The actual
amount of allocated memory depends on the BL_SIZE value as illustrated in
Table 179
.
Bits 9:0
COUNTn_RX[9:0]:
Reception byte count
These bits contain the number of bytes received by the endpoint associated with the
USB_EPnR register during the last OUT/SETUP transaction addressed to it.
Table 179. Definition of allocated buffer memory
Value of
NUM_BLOCK[4:0]
Memory allocated
when BL_SIZE=0
Memory allocated
when BL_SIZE=1
0 (‘00000)
Not allowed
32 bytes
1 (‘00001)
2 bytes
64 bytes
2 (‘00010)
4 bytes
96 bytes
3 (‘00011)
6 bytes
128 bytes
...
...
...
14 (‘01110)
28 bytes
480 bytes