2
\$\begingroup\$

I use STM32G474 and USB in V-COM mode with default transmit function:

uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len){
  uint8_t result = USBD_OK;
  /* USER CODE BEGIN 7 */
  USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
  if (hcdc->TxState != 0){
    return USBD_BUSY;
  }
  USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
  result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
  /* USER CODE END 7 */
  return result;
}

While project works perfectly when it is connected to PC running Linux (ubuntu 20.04, oracle 8.4 sending data for days without error) it can transfer only 1 (in rare cases 2-5) pack when it is connected to Windows 10 21H1 PC - after first transmission of 1536 bytes pack hcdc->TxState is always 1, while data is correctly received with PC
USB Receiving part works normally and gets every packet that both win/lin PCs is transmitting to board running this project
Both PCs are running same software (written in Java, both same JDK version), same cable used

FS packet size is set to 64 while whole buffer for single transmission is 1536 bytes, heap and stack size is 2000

I tried installing old stm32 vcom driver and inserting additional delays in transmission code but nothing changed

What else should I try?

Update:
I tried reducing length of buffer for single transition:

CDC_Transmit_FS((uint8_t*) (&adcCopyToUSB), **256**) 

Gives me ~20-60 transferred packs before lockup

CDC_Transmit_FS((uint8_t*) (&adcCopyToUSB), **63**) 

gives ~100-200 transferred packs before lockup

If I re-plug usb cable everything starts again (board is powered not via usb so mcu is not resetted)
I tried Eltima's serial port terminal and got same problems with lockup after 2-2.5kB transmitted so it's is not java/host software

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Changing cable fixed problem - seems like Windows and Linux drivers behaves differently when packets are lost and while Linux driver is immune to this problem, Windows one leads to packet stuck for some reason

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.