Skip to main content
SSnum.1
Visitor II
October 11, 2022
Question

USB-Host CDC STM32F4, why are 2 USB_CDC_ReceiveCallback interrupts called when 64bytes are received ?

  • October 11, 2022
  • 1 reply
  • 1039 views

I want to programme a USB host CDC. This works as far as it goes. 

This means I can receive and send data. 

My problem is that the receive interrupt is called 2 times for data packets with 64 bytes.

It is also always called once too often for packets >64 bytes. This means that it is called 3 times for 128 bytes.

The result is that I always receive the last packet 2 times. 

Has anyone already observed this problem?

Best regards

Snumeli

This topic has been closed for replies.

1 reply

gbm
Lead III
October 11, 2022

This is the normal behavior of USB CDC class. CDC host or device must send a zero-length packet (ZLP) to complete every n*ENDPOINT_SIZE bytes long payload data, otherwise the transfer of data is considered to be in progress (not finished). ST USB CDC stack neither filters out the incoming ZLPs nor it emits the ZLPs when they are required. CDC_Receive must check for zero length.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice