cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F107VCT USB Receive Message hangs

David Wallén
Associate III

I am building a USB driver based on the USB CDC library code generated by CubeMX. The MCU is configured to support 64 byte USB messages through CubeMX

Sending messages from a host computer and parsing them on the MCU works fine when the USB payload is 8 chars (i.e. 8 bytes) or smaller. I can see in Wireshark that such messages are padded out to be 64 bytes on the wire.

When 9 chars are being sent the MCU stops execution (without going to the hardware fault handler) and without hitting a breakpoint I inserted at the start of the CDC_Receive_FS function.

I can see the USB message (padded out to 64 bytes, just like when having 8 chars as payload) going out from the PC using Wireshark and the hardware acknowledges the message, but the MCU halts without reaching any breakpoints.

My main questions:

  1. Does anyone know why this would halt? Perhaps some simple setting I am missing?
  2. Is there any lower level code I can place breakpoints in to really try and figure out what is going on? To me it is not clear what function actually calls CDC_Receive_FS

My implementation of CDC_Receive_FS:

static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
  /* USER CODE BEGIN 6 */
  
   //My custom parser
  USBDRIVER_receive(&(project.usbDriver), Buf, Len);
 
  //CubeMX Generated functions
  USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
  USBD_CDC_ReceivePacket(&hUsbDeviceFS);
 
 
  return (USBD_OK);
  /* USER CODE END 6 */ 
}

Thanks in advance!

1 REPLY 1
David Wallén
Associate III

Bump! :)