I'm getting USBD_BUSY when i try to transmit data via virtual com port
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-12-28 5:57 AM
char *data = "Hello World";
while (1) {
HAL_GPIO_TogglePin(LD2_GPIO_Port,LD2_Pin);
HAL_Delay(1000);
CDC_Transmit_FS((uint8_t*)data,strlen(data)); }
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
{
uint8_t result = USBD_OK;
/* USER CODE BEGIN 7 */
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
if (hcdc->TxState != 0){
return USBD_BUSY;
}
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
/* USER CODE END 7 */
return result;
}
I'm trying to transmit MPU6050 sensor readings to my computer via virtual comport.I'm using STM32 Nucleo F446RE. As far as i can see in debug mode there is no issue in sensor and sensor readings. Problem is I can't transmit them using USB. Are there anyone who have experienced this issue before?
Labels:
- Labels:
-
STM32F4 Series
-
USB
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-12-28 6:04 AM
- Do you have the F446 USB connected to your PC? The target MCU USB connector in not present on the Nucleo64 board - you need to use some extension borad with USB connector.
- You cannot transfer anything via VCOM until it's connected, physically and logically - the terminal is open. Typically, the VCOM is operational about 50 ms after the terminal connection is established.
- Calling CDC_Transmit_FS() from main will sooner or later lead to a hangup - you may call it only from an ISR of the same priority as USB interrupt.
- Start with VCOM character echo, then try to add your functionality.
My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
