Skip to main content
Visitor II
June 30, 2023
Question

USB CDC communication

  • June 30, 2023
  • 1 reply
  • 875 views

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));

}
}

 

This topic has been closed for replies.

1 reply

Pavel A.
June 30, 2023

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?