cancel
Showing results for 
Search instead for 
Did you mean: 

After the new firmware package for STM32WB, v1.2, I am not able to see the STM32WB on COM port after running a simple USB CDC code to enable serial communication.

HSing
Associate II
//main.c file
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usb_device.h"
#include "gpio.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "usbd_cdc_if.h"
/* USER CODE END Includes */
 
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
 
/* USER CODE END PTD */
 
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
 
/* USER CODE END PD */
 
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
 
/* USER CODE END PM */
 
/* Private variables ---------------------------------------------------------*/
 
/* USER CODE BEGIN PV */
 
/* USER CODE END PV */
 
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
extern USBD_HandleTypeDef hUsbDeviceFS;
//extern uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
/* USER CODE END PFP */
 
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
 
/* USER CODE END 0 */
 
/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
  
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USB_Device_Init();
  /* USER CODE BEGIN 2 */
  char dataOut[256];
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
 
	
	  sprintf(dataOut, "HelloWorld");
	  //CDC_Transmit_FS(( uint8_t * )dataOut, strlen( dataOut ));
	  USBD_CDC_SetTxBuffer(&hUsbDeviceFS, ( uint8_t * )dataOut, strlen( dataOut ));
	  USBD_CDC_TransmitPacket(&hUsbDeviceFS);
	  HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}

The mentioned code should send "HelloWorld" every second over USB. I have connected both the USBs to STM32WB. I able to see one port which is used to for debugging/downloading but can't see the other one. Anyone with any idea?

2 REPLIES 2
LVent
Associate II

Yes, there is an issue in the code generation with this package version.

Try to add 0x00 in the third position in the declaration of USBD_CDC_DeviceDesc in usbd__desc.c file.

MWB_CHa
ST Employee

Hi,

Why not checking the CDC example provided in STM32WBCube package first and then compare it with your generated code ?

If you use one of ST boards (ie. Nucleo or Dongle) then the application would work straight forward.

Basically what you need to check first place is:

  • USB clock source (normally it should be CRS, so check that CRS is running and configured correctly and that USB is using it as source clock)
  • USB dedicated VDD IO shall be connected to 3.3V on the board
  • USB interruption is configured correctly and with right priority

I hope it helps.