AnsweredAssumed Answered

Need help on USB device CDC VCP stack

Question asked by Mr_M_from_G on Jun 24, 2016
Latest reply on Jun 29, 2016 by Mr_M_from_G
Hello,
I built a small project to try USB device CDC VCP stack. I created the sources with CubeMX 4.15.1 for STM32L152, using the Nucleo board.
Code is running and I see the USB device with one IN, one OUT and one interrupt endpoint with Microsoft's usbview. Also I can send data using
 HAL_Delay (100);
CDC_Transmit_FS ((uint8_t*)("123456 "),7);
in the main while loop. It comes out on RealTerm correctly.
Now I want to receive data and get them out of the usb stack in CDC_Receive_FS in usb_cdc_if.c. I wrote a small function that copies Len data from Buf to an external fifo buffer from where they are sent to USART1. But output to RealTerm from USART1 is nonsense, has nothing to do with sent data. Now I stepped back through the various functions that finally call CDC_Receive_FS and found PCD_ReadPMA in stm32l1xx_hal_pcd.c. There the received data are copied from the buffer that is filled by usb hardware (called packet memory area) to a buffer called user memory area who's address is passed to the function. In the copying loop I inserted  copying to the mentioned fifo, so data from there is also send via USART1. And this is succesful. Data comes out at Realterm as sent.
Now I meanwhile tried for two days to find out how data are passed or buffer pointers are initialized but it is very complicated. At the moment it seems that the buffer used as user memory area in PCD_ReadPMA is not at the same address as the buffer set with USBD_CDC_SetRxBuffer which is done in CDC_Receive_FS.

Are there any USB experts online who can help me?

Thanks a lot

Martin

Outcomes