Full Speed (FS) USB communication with STM32F407VG Discovery Board
I'm trying to test out Full Speed USB Communication with the STM32F407 DISCOVERY board.
I'm sending 1 MB of data to the serial port of the computer and receiving them and saving the data using a python script. The speed I'm getting is close to 350 kB/s (~0.34 MB/s), but USB FS theoretical speed is 1.2 MB/s. Is there a way to increase the speed or am I doing something wrong to get such a lower speed?
In the clock configuration, HCLK is 168 MHz (max) and PLLQ is set to 7, giving a 48 MHz USB clock.
This is the function I'm using to send the data.
void send_very_large_data()
{
uint8_t chunk[64]; // 64-byte chunk (USB FS max packet size)
memset(chunk, 'A', sizeof(chunk)); // Fill with 'A' for testing
uint32_t totalSize = 1 * 1024 * 1024; // 1MB for testing (change as needed)
uint32_t sentBytes = 0;
// Loop to send data in 64-byte chunks
while (sentBytes < totalSize)
{
// Wait for USB to be ready for the next transmission
while (CDC_Transmit_FS(chunk, sizeof(chunk)) == USBD_BUSY);
sentBytes += sizeof(chunk);
}
}
I have attached pictures of the changed configuration from Cube MX.
