STM32L0 USB CDC VCP Transmit problems
I am using an STM32L053 part and trying to use the USB CDC VCP functionality on an STM32L0-Discovery board. In the past I've gotten the USB CDC VCP functionality working on an STM32F4 on a custom board using the ST USB Library.
For the STM32L0 project I am using the STCubeMX. The first problem I encountered was the CDC receive would not work until I calledUSBD_LL_PrepareReceive.
That was well documented in this link:/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/USB%20middleware%20issue%20with%20CDCVCP%20only%20x%20packets%20receivable%20%28HAL%201.1.0%20and%20Host-Device_Lib%202.1.0%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21¤tviews=517
Now I am having problems with the CDC transmit. If I transmit 8 bytes or less the data is transmitted correctly. For example, I've been transmitting 12345678 and that comes out correctly. Keep in mind these are ASCII strings. Now if I try and transmit 123456789 I get 9 bytes of garbage. I've traced the code all the way down to PCD_WritePMA function. At that point it is still pointing to my buffer of data and the length is 9 bytes. I see it correctly grab the data and join it into 16-bits of data and then write it to memory location 0x40006000 which is the USB 512x16-bit SRAM section. I've attached a screen shot from a USB protocol analyzer that shows the garbage data. Has anyone seen this before?
#vcp #usb #stm32l0 #cdc #murder-by-aggregate