2016-06-24 01:52 AM
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 Martin2016-06-28 12:57 AM
Hello,
I found the bug myself in my own code. Sorry for posting this and thanks to all who took a look at it. Martin2016-06-28 02:10 AM
Hi Mr_M_from_G,
I'm interested to know how you resolved this issue.It may be helpful for other forum users. Regards2016-06-29 07:28 AM
Hello,
the Fifo I mentioned was not properly initialized. Filling data in and getting data out did not access the same memory adress area, so output had nothing to do with input. After adding initialization it worked fine. Martin