AnsweredAssumed Answered


Question asked by Pabouctsidis.Alex on Aug 18, 2014
Latest reply on Jul 11, 2016 by gonzalez.laurent

I'm trying to get a virtual com port working on the stm32f4 discovery board. This is something that I've managed to do in the past using the old USB libraries and std peripheral libraries. However, since st is pushing its users to use the STM32Cube i'm trying to setup my new project with it instead.

Unfortunately i'm having a fair amount of issues in getting it to work properly. Furthermore, the generate code is so different than what i'm used to seeing, i'm not sure how to modify in order to work as required; with a simple Tx and Rx circular buffer.

At the moment my code compiles without issues and I have a loop which calls the following code every ~1s :

  char string[12] = "Flyability\r\n";

I modified the CDC_Transmit_FS to copy the function input string into the UserTxBuffer (But doesn't append the data, which is what a proper Tx circular buffer requires):

uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
  uint8_t result = USBD_OK;
  /* USER CODE BEGIN 8 */ 
  uint16_t i;
  USBD_CDC_SetTxBuffer(hUsbDevice_0, UserTxBufferFS, Len);   
  result = USBD_CDC_TransmitPacket(hUsbDevice_0);
  /* USER CODE END 8 */ 
  return result;

If i run the application, the code works and i receive the test strings in my console, but only for a couple seconds, after which no more data is received on the com port. At this point the returned result value is equal to 1 (USB BUSY).

Any help with these 2 issues (where to modify the code to implement a proper Tx/Rx circular buffer, and why it only works for the first couple seconds) would be greatly appreciated.