498
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
Clock configuration
The USB 2.0 protocol specification stipulates that the USB full-speed module uses a fixed 48MHz clock. In order to
provide an accurate 48MHz clock to USB_FS_Device, a two-stage clock configuration is required, as follows:
In the first stage, the 48MHz working clock is obtained by accurate frequency division of PLLCLK, so when
using USB_FS_Device, it is necessary to ensure that the PLLCLK clock is 48MHz/72MHz/96MHz/144MHz,
otherwise USB_FS_Device cannot work normally;
In the second stage, enable the USB peripheral clock mounted on the APB1 bus, that is, the APB1 bus clock. Its
frequency does not have to be equal to 48MHz, but can be greater or less than 48MHz.
Note:
1
、
The frequency of the APB1 bus clock must be greater than 8MHz, otherwise the data buffer may
overflow/underflow.
Functional description
Based on this module, data exchange can be realized between the microcontroller and the PC host through a USB
connection. The data transfer between the microcontroller and the PC host is based on a 512-byte dedicated SRAM,
which is the Packet Buffer Memory in Figure 19-1. USB peripherals can directly access this SRAM. The actual usage
size of this dedicated SRAM is determined by the number of endpoints used and the endpoint packet buffer size of
each endpoint. Each endpoint has a buffer description table entry, which describes the buffer address, size and the
number of bytes that need to be transferred. For details, please refer to 19.4.2 Buffer Description Table. The SRAM
is mapped to the APB1 peripheral memory area, its address is from 0x4000 6000 to 0x4000 63FF, the total capacity
is 1KB, but only 512 bytes are used due to the bus width, and the buffer description table of each endpoint is also
stored in this SRAM, so the maximum endpoint packet buffer that can be used by each endpoint is less than 512
bytes.
Note:
1
、
USB and CAN1 share this SRAM, so USB and CAN1 cannot be used at the same time.
19.4.1
Access Packet Buffer Memory
As shown in Figure 19-1, the microcontroller communicates with the USB module through the APB1 bus, and the
microcontroller accesses the Packet Buffer Memory through the APB1 wrapper. When the microcontroller and the
USB module both access the Packet Buffer Memory, the Arbiter decides who can access, the arbitration logic is that
half of the APB1 bus cycle is used for the microcontroller to access the Packet Buffer Memory, and the other half of
the cycle is used for the USB module to access the Packet Buffer Memory, in this way, the access conflicts caused
by the continuous access of the microcontroller to the Packet Buffer Memory can be avoided.
Note:
1
、
APB1 bus and USB module access Packet Buffer Memory in different ways.
USB module access Packet Buffer Memory
The USB module accesses the Packet Buffer Memory in 16-bit mode, refer to Figure 19-2. When the USB module