AnsweredAssumed Answered

STM32F10x HAL USB debug issue

Question asked by lenoe on Oct 30, 2016
Latest reply on Jan 6, 2018 by Ben K
Hello everyone!
I tried to create a CDC to PC interchange project in Cube on STM32F103C8T6 (as you can see in attached file) and I have some kind of trouble — debug doesn't works properly.

During debug my sample project any VCP terminal that I have shows that device doesn't works (any data can not be received or transmitted from device), but debug still continues normally.
So, without debug the following code works fine:
static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
  /* USER CODE BEGIN 6 */
//  USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
//  USBD_CDC_ReceivePacket(&hUsbDeviceFS);
//  return (USBD_OK);
    for (int i = 0; i < *Len; i++)
            UserTxBufferFS[i] = UserRxBufferFS[i];
 
    USBD_CDC_SetTxBuffer(&hUsbDeviceFS, &UserTxBufferFS[0], *Len);
    USBD_CDC_TransmitPacket(&hUsbDeviceFS);
             
    USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &UserRxBufferFS[0]);
    USBD_CDC_ReceivePacket(&hUsbDeviceFS);
    return (USBD_OK);
  /* USER CODE END 6 */
}
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;
}
I can receive any transmitted data from device.

Is anyone know how to solve this?

Attachments

Outcomes