cancel
Showing results for 
Search instead for 
Did you mean: 

Some help with the USB on the STM32F446VET .

MBolo.1
Associate III

Hi , I'm writing here to ask community some help with the F446VET chip. I tried the Cube Ide and CubeMX to perform all the settings.

What have been done so far :

  1. In the USB_DEVICE--> Class for FS IP is set to "Communication Device Class(Virtual Port Com)"
  2. In the RCC->HSE and LSE are both enabled (pins PH0/PH1 and PC14/PC15)
  3. I use the PA12/PA11 pins as for USB
  4. And in the USB_OTG_FS Mode is set to Device_Only .

After I flash the code generated on the board and connect through the USB connected to the pins A12 and A11 Windows is continuously trying to recognize the device , over and over again with the message "Device Description Failed " . Tried on other laptop and the same stuff.

Other suggestions and help would be appreciated, thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
MBolo.1
Associate III

Hi, to everyone who looked here I eventually found the solution.

In the usbd_cdc_if.c file had to add this code :

1
 /* USER CODE BEGIN INCLUDE */
#define APP_RX_DATA_SIZE 2048// !!! aded by me
#define APP_TX_DATA_SIZE 2048
/* USER CODE END INCLUDE */
 2 
/* Private variables ---------------------------------------------------------*/
uint8_t buffer[7]; //!!!!!!Added by me
/* USER CODE END PV */
 3 
case CDC_SET_LINE_CODING:
    		        buffer[0]=pbuf[0];   //////////Added by me
    			buffer[1]=pbuf[1];
    	    	    	buffer[2]=pbuf[2];
    	    	    	buffer[3]=pbuf[3];
    	    	    	buffer[4]=pbuf[4];
    	    	    	buffer[5]=pbuf[5];
    	    	    	buffer[6]=pbuf[6];
 
    break;
 
    case CDC_GET_LINE_CODING:
    			pbuf[0]=buffer[0];
    	    	    	pbuf[1]=buffer[1];
    	    	    	pbuf[2]=buffer[2];
    	    	    	pbuf[3]=buffer[3];
    	    	    	pbuf[4]=buffer[4];
    	    	    	pbuf[5]=buffer[5];
    	    	    	pbuf[6]=buffer[6];
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
  /* USER CODE BEGIN 6 */
  USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
  USBD_CDC_ReceivePacket(&hUsbDeviceFS);
  CDC_Transmit_FS(Buf, *Len); // ADED BY ME !!!!!!!!!!!!!
  return (USBD_OK);
  /* USER CODE END 6 */
}

and this solves the problem.

Moderator you can consider this problem closed.

View solution in original post

3 REPLIES 3
Mike_ST
ST Employee

In the F4 software package:

https://www.st.com/en/embedded-software/stm32cubef4.html

(CubeMX automatically donwload it on your PC, default dir is C:\Users\Login\STM32Cube\Repository)

There is an example:

STM32Cube_FW_F4_V1.26.2\Projects\STM32446E_EVAL\Applications\USB_Device\CDC_Standalone

Please compare the 2 projects to find what is missing.

MBolo.1
Associate III

Hi, thank you for your answer. I checked the files how you recommended and everything looks fine.

Today a connected the logical analyzer to the usb connector to see what signals I'm getting and this are the signals

0693W00000FBXOmQAP.jpgthe rest of them a repeating and they are similar to this one.

MBolo.1
Associate III

Hi, to everyone who looked here I eventually found the solution.

In the usbd_cdc_if.c file had to add this code :

1
 /* USER CODE BEGIN INCLUDE */
#define APP_RX_DATA_SIZE 2048// !!! aded by me
#define APP_TX_DATA_SIZE 2048
/* USER CODE END INCLUDE */
 2 
/* Private variables ---------------------------------------------------------*/
uint8_t buffer[7]; //!!!!!!Added by me
/* USER CODE END PV */
 3 
case CDC_SET_LINE_CODING:
    		        buffer[0]=pbuf[0];   //////////Added by me
    			buffer[1]=pbuf[1];
    	    	    	buffer[2]=pbuf[2];
    	    	    	buffer[3]=pbuf[3];
    	    	    	buffer[4]=pbuf[4];
    	    	    	buffer[5]=pbuf[5];
    	    	    	buffer[6]=pbuf[6];
 
    break;
 
    case CDC_GET_LINE_CODING:
    			pbuf[0]=buffer[0];
    	    	    	pbuf[1]=buffer[1];
    	    	    	pbuf[2]=buffer[2];
    	    	    	pbuf[3]=buffer[3];
    	    	    	pbuf[4]=buffer[4];
    	    	    	pbuf[5]=buffer[5];
    	    	    	pbuf[6]=buffer[6];
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
  /* USER CODE BEGIN 6 */
  USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
  USBD_CDC_ReceivePacket(&hUsbDeviceFS);
  CDC_Transmit_FS(Buf, *Len); // ADED BY ME !!!!!!!!!!!!!
  return (USBD_OK);
  /* USER CODE END 6 */
}

and this solves the problem.

Moderator you can consider this problem closed.