Skip to main content
Visitor II
August 29, 2020
Question

STM32F103 USB doublebuffered BulkOut endpoint problem with transfers bigger than 64bytes

  • August 29, 2020
  • 0 replies
  • 696 views

Hello, I have an project with STM32F103 and using CubeMX drivers. I successfully setup the driver, but I have a problem when trying to send out from pc packets biggest than 64 bytes. (64bytes is the enpoint buffer & max packet size). On PC I'm using simple testing program which sends packets with different lengths from 10bytes to 200bytes. Expected behavior is that interrupt occurs for every 64bytes, then the buffer is swapped and next packet is received, but this is not working as expected.

My registers settings:

CNTR: 0xBF00
EP0 - CONTROL RX/TX
 ADDR_TX: 0x58
 COUNT_TX: 0x0
 ADDR_RX: 0x18
 COUNT_RX: 0x8400 (only setting)
EP1 - DATA IN (Single buffered)
 ADDR_TX: 0x98
 COUNT_TX: 0xAD
 ADDR_RX: 0xA0BA - not cleared, but not used...
 COUNT_RX: 0x800 (only setting)
EP2 - DATA OUT (Double buffered)
 ADDR_TX: 0x118
 COUNT_TX: 0x0
 ADDR_RX: 0xD8
 COUNT_RX: 0x8400 (only setting)

For transfers from 10 to 60 bytes everything works nicely:

INT: USB_EP2R: 0xF142 count: 10 countPma0: 10 countPma1: 0 USB_EP2R: 0x7102
INT: USB_EP2R: 0xB102 count: 20 countPma0: 0 countPma1: 20 USB_EP2R: 0x3142
INT: USB_EP2R: 0xF142 count: 30 countPma0: 30 countPma1: 0 USB_EP2R: 0x7102
INT: USB_EP2R: 0xB102 count: 40 countPma0: 0 countPma1: 40 USB_EP2R: 0x3142
INT: USB_EP2R: 0xF142 count: 50 countPma0: 50 countPma1: 0 USB_EP2R: 0x7102
INT: USB_EP2R: 0xB102 count: 60 countPma0: 0 countPma1: 60 USB_EP2R: 0x3142

But for 70bytes transfer I got:

INT: USB_EP2R: 0xF142 count: 64 countPma0: 64 countPma1: 0 USB_EP2R: 0xB102
INT: USB_EP2R: 0xB102 count: 0 countPma0: 0 countPma1: 0 USB_EP2R: 0x3142

So it seems that the interrupt is called nicely, but the count registers are empty for the second part of the transfer. I can't figured out what is going wrong. Can anybody help me with this strange problem?

    This topic has been closed for replies.