ifconfig
ifconfig

Reputation: 6832

STM32cube USB VCP doesn't appear on Windows 10

I'm trying to figure out how to enable USB VCP functionality on my STM32F103-based Blue Pill board. In following Shawn Hymell's guide and attempting to troubleshoot with this other SO Q/A, I currently have the following (minified) main.c: (Git Gist with full file)

#include "main.h"
#include "usb_device.h"
#include <string.h>

int main(void) {
  char msg[50];
  uint8_t state = 0;

  HAL_StatusTypeDef ret_status;
  MX_USB_DEVICE_Init();

  sprintf(msg, "Restart!\n");
  ret_status = HAL_UART_Transmit(&huart1, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
  HAL_Delay(1000);

  while (1) {
      HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, state ? GPIO_PIN_RESET : GPIO_PIN_SET);
      sprintf(msg, "Hello World! LED State: %d\n", state);
      ret_status = HAL_UART_Transmit(&huart1, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
      ret_status = CDC_Transmit_FS((uint8_t*)msg, strlen(msg));

      state = state == 1 ? 0 : 1;
      HAL_Delay(500);
  }
}

I can tell that the program is (otherwise) running properly because the UART adapter shows that char msg is being output at the correct interval and the board's PC13 LED is flashing. However, my Windows 10 computer doesn't even recognize that there is a USB device plugged in, only showing the FTDI adapter's COM port and my STLink v2:

enter image description here

As of now, I've tried the following potential fixes from the other SO Q/A:

case CDC_SET_LINE_CODING:
  tempbuf[0]=pbuf[0];
  tempbuf[1]=pbuf[1];
  tempbuf[2]=pbuf[2];
  tempbuf[3]=pbuf[3];
  tempbuf[4]=pbuf[4];
  tempbuf[5]=pbuf[5];
  tempbuf[6]=pbuf[6];
  break;
case CDC_GET_LINE_CODING:
  pbuf[0]=tempbuf[0];
  pbuf[1]=tempbuf[1];
  pbuf[2]=tempbuf[2];
  pbuf[3]=tempbuf[3];
  pbuf[4]=tempbuf[4];
  pbuf[5]=tempbuf[5];
  pbuf[6]=tempbuf[6];
  break;

Has anyone else seen something like this before? I'm not sure what to try next.

Upvotes: 1

Views: 818

Answers (1)

ifconfig
ifconfig

Reputation: 6832

Actually, my problem was far more simple than I thought. In my infinite wisdom, I decided to try this on a breadboard I'd previously been using for CANbus testing, without disconnecting the CAN circuit.

enter image description here (ref)

This was never going to work, as the CANbus pins I'd been trying to use (and left plugged in) share functionality with the USB port. The VCP immediately showed up and worked after I unplugged the breadboard wires I'd connected to PA11 and PA12. I feel dumb, but relieved, right now.

Upvotes: 1

Related Questions