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 https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32Java%2fReal%20bug%20in%20the%20USB%20CDC&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=198

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;
    }
    else
    {
        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)
  {
    BSP_LED_Toggle(LED1);
    BSP_LED_Toggle(LED2);
    BSP_LED_Toggle(LED3);
    BSP_LED_Toggle(LED4);
    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;
          
  HAL_Delay(10);
}

The code is running on the STM3240G-Eval board.

Does anyone have an idea to solve this problem?

Thanks in advance

Outcomes