cancel
Showing results for 
Search instead for 
Did you mean: 

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

SSnum.1
Associate

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

1 REPLY 1
gbm
Lead III

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