2023-06-30
06:44 AM
- last edited on
2023-06-30
07:58 AM
by
Amelie ACKERMANN
Hi all,
I am trying to USB CDC communication with my STM32 nucleo board. I want to send consecutive numbers and verify that they are consecutive and calculate the data rate.
I obtain errors, non consecutive numbers (irregularly), when I increase the amount of bytes I send. What can I do to solve this problem?
This is the code that I am using to send consecutive numbers:
uint32_t data[32];
USBD_StatusTypeDef status = 0 ;
while (1)
{
for (uint16_t i=0; i<32; i++)
{
data[i]=cnt++;
}
//HAL_Delay(1);
status = USBD_FAIL;
while (status != USBD_OK){
status = CDC_Transmit_FS(data, sizeof(data));
}
}
2023-06-30 11:03 AM
Do you understand how USB works that CDC_Transmit_FS needs time to complete? You cannot send a new data until the previous one is sent out. Also, mind the packet size specified for the USB endpoint, are you sending too short packets?