AnsweredAssumed Answered

Data transfer halted in USB CDC

Question asked by manu.v on Jan 15, 2015
Latest reply on Apr 3, 2015 by manu.v

Hi everybody,

I modified USB CDC standalone project from STM32Cube_FW_F4 v1.3.0 to send data through IN endpoint.

The first 12 Kib of data can be sent without any problem. The next packet of data is sent but the interrupt does not trigger at the end of the transmission. No more data can be sent.

The modifications of this example are :
1) Bug correction according to

2) The CDC_SendData has been added to usbd_cdc_interface.C file :
void CDC_SendData(uint8_t * data, uint32_t size)
    /* Add data to buffer */
    if ((UserTxBufPtrIn+size) < APP_RX_DATA_SIZE)
        memcpy(&UserTxBuffer[UserTxBufPtrIn], data, size);
        UserTxBufPtrIn += size;
        memcpy(&UserTxBuffer[UserTxBufPtrIn], data, APP_RX_DATA_SIZE - UserTxBufPtrIn);
        memcpy(UserTxBuffer, &data[APP_RX_DATA_SIZE - UserTxBufPtrIn],
               size - APP_RX_DATA_SIZE + UserTxBufPtrIn);
        UserTxBufPtrIn = size - APP_RX_DATA_SIZE + UserTxBufPtrIn;

3) The Toggle_Leds function (in main.c file) has been modified:
static void Toggle_Leds(void)
  static uint32_t ticks, k = 0;
  static uint8_t data[64];
  if(ticks++ == 0xff)
    ticks = 0;

  memset(&data, k, sizeof(data));
  data[sizeof(data)-2] = 0x13;
  data[sizeof(data)-1] = 0x10;
  CDC_SendData(data, sizeof(data));
  k = (k+1) % 128;

The code is running on the STM3240G-Eval board.

Does anyone have an idea to solve this problem?

Thanks in advance