2014-10-10 12:18 PM
First off, I'm relatively new to microcontroller programming, so please bear with me here.
I'm trying to get two-way communication going over a VCP between a device that has an STM32F042 MCU and PuTTY. I've generated code with STMCubeMX, with the USB CDC stuff enabled, as well as several other peripherals.I'm trying to get reception on the device working, but it seems to only receive one packet after a reset. I run the program on the device, open the COM port with PuTTY, hit a key on the keyboard, and the LED that I've set to toggle under CDC_Receive_FS() toggles, and then never again after more keystrokes.I've noticed that USB_IRQHandler() only gets hit that first time. If I set a breakpoint in the function before I make the first keystroke, the breakpoint gets hit, but if I set it after the first one (so as not to interrupt USB communcation), it never gets hit again.I suspect that there's some pointer I need to increment that magically re-enables the interrupt, but I'm really unsure. I've attached what I think is the main file that the user is supposed to modify for packet reception/transmission. All my main function does is run the Cube-generated initialization code, and then go into an infinite empty loop.Thanks in advance! #stm32f0 #cdc #vcp #usb2014-12-14 06:02 PM
Simon,
Were you able to get any further on this problem? I'm trying to work the VCP example for the STM32F042 as well and have come up on the same issue you described..2014-12-14 06:49 PM
It appears that once the UART is finished transmitting the data received in the USB receive, it callsUSBD_CDC_ReceivePacket(&USBD_Device); which I had removed for my project[the uart portion] which prevented the function from ever taking place. For my purpose[evaluating the code] -- I was able to receive additional bytes by changing the following code...
/**
* @brief CDC_Itf_DataRx
* Data received over USB OUT endpoint are sent over CDC interface
* through this function.
* @param Buf: Buffer of data to be transmitted
* @param Len: Number of data received (in bytes)
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len)
{
//HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
//do something with data here...
USBD_CDC_ReceivePacket(&USBD_Device);
return (USBD_OK);
}
2016-01-12 02:34 AM
Dear user,
Please note this issue will be corrected in our next release 4.13. The missing call to USBD_CDC_ReceivePacket will be added. Best regards