cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 Discovery, USB CDC bug

rshams9
Associate II
Posted on May 21, 2015 at 08:56

Hi,

I create a project using STM32CubeMx with keil MDK5. my hardware is Discovery F3 and I make a loopback just by following code:

static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)

{

  /* USER CODE BEGIN 6 */

CDC_Transmit_FS (Buf, *Len);

  return (USBD_OK);

  /* USER CODE END 6 */ 

}

I think there is something wrong with USB library or the code generated by the CubeMx. My problem is this code just return first character. tx routing works fine but problem is with receiving.

Another issue is when you powered up the board with debugging USB when you disconnect and reconnect USB CDC,  windows shows unknown device message on screen. I mean just for the fist time PC will recognize CDC device any reconnect after that will fail becuse there is somthing wrong in USB lib.

If anyone has experienced such problem please tell here. and if you have solved this problem please help me.

thanks in advance. 

#usb #stm32f3 #cdc
4 REPLIES 4
jones.david
Associate II
Posted on May 25, 2015 at 09:23

check if there is a breakpoint in your keil so it pause cpu to answer host

rshams9
Associate II
Posted on May 25, 2015 at 20:13

No break points and pauses. just the code generated with the CubeMx and I just added one line that I mentioned above. I'm pretty sure that's STAPI bug.

taraben
Senior
Posted on May 27, 2015 at 00:03

place an

USBD_CDC_ReceivePacket(hUsbDevice_0);

before returning

CDC_Transmit_FS (Buf, *Len);

USBD_CDC_ReceivePacket(hUsbDevice_0);

return (USBD_OK);

This will put USB back in receive state.

HTH, Adib.

rshams9
Associate II
Posted on May 28, 2015 at 19:38

thank you so much  adib, you are a life saver !