cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 USB Virtual Com Port weird problem/settings solved?

Christoph Eschenbach
Associate III
Posted on January 30, 2017 at 18:23

Hey there,

I am trying to put up a VCP for Nucleo144 STM32F429 and had hard time figuring out why i cannot connect with my Terminal Program board with the CubeMX generated Sourcecode.

I dont know why but this worked for me now:

In CubeMX:

   Board Selection->STM32->Nucleo144->F429ZI

Pinout Tab:

   Peripherals:

      USB_OTG_FS->Device Only

      RCC->Enable HSE->Bypass

MiddleWares:

   Enable USB_DEVICE->Communication Device Class(Virtual Com Port)

Clock Configuration:

   PLL Source Mux: HSE 8MHz         /M= 4, *N = 168, /P = 2, /Q =7

   System Clock Mux: PLLCLK-> 168MHz

   APB1 peripheral clocks 42 MHz

Configuration Tab:

   Connectivity->USB_FS->Parameter Settings->VBUS Sensing-> Disabled

   Project Settings->Linker Settings:

   Heap from 0x200 to 0x2000

   Stack from 0x400 to 0x600

Project Settings

In IAR Embedded Workbench:

      USB_HS_MAX_PACKET_SIZE  from 512 to 256

      CDC_DATA_HS_MAX_PACKET_SIZE from 512 to 256

      (this doesnt really affected the problem so i changed it back to 512 since im using FS-mode)

Still I cannot connect via a Terminal from Host PC.

So i searched and now this happens:

   Back in CubeMX taking a harder look at USB_DEVICE in Configuartion Tab.

   I changed USBD_MAX_STR_DESC_SIZ the default 512 to 64 bytes, because description says between 1 and 64. Why    default is 512 then?

->Still cannot connect.

   Changed USBD_DEBUG_LEVEL to 3.

I finally can connect to device via Terminal.

I will try to rebuild this scenario tomorrow to see if this option really making me that trouble.

Could these settings have such impact on the right configuration?

3 REPLIES 3
Imen.D
ST Employee
Posted on January 30, 2017 at 22:55

Hi,

Try to change the buffers size and HS max packet size from 512 to 64, as t

he maximum packet size for full speed devices is 64 bytes. 

Also, i

ncrease the heap and stack size. 

Please keep me updated on your 

scenario results.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on January 31, 2017 at 08:51

stack and heap size were increased...

the buffer and packet size should only affect when i start with transmit and receive calls?

I made quick rebuild this morning with following result:

Rebuild:

CubeMx

      Board Selection->STM32->Nucleo144->F429ZI

Pinout Tab:

   Peripherals:

      USB_OTG_FS->Device Only

      RCC->Enable HSE->Bypass

   MiddleWares:

      Enable USB_DEVICE->Communication Device Class(Virtual Com Port)

   Clock Configuration:

      PLL Source Mux: HSE 8MHz         /M= 4, *N = 168, /P = 2, /Q =7

      System Clock Mux: PLLCLK-> 168MHz

      APB1 peripheral clocks 42 MHz

USB_FS Configuration

   VBUS sensing Disable

   USB_DEVICE Configuration

   USBD_MAX_STR_DESC_SIZ from 512 to 64

   USBD_DEBUG_LEVEL to 3

Project Settings:

   ->HAL Settings: Enable Full Assert

   ->Code Generator: Copy only the necessary libary files

Generate Code

In IAR no changes…

I made no Transmit or Receive calls and i can connect to device via terminal program.

CubeMX -> USBD_DEBUG_LEVEL to 0

Generate Code

In IAR no changes..

   I made no Transmit or Receive calls and i get Error in Terminal programm

CubeMX -> USBD_DEBUG_LEVEL to 1

   I made no Transmit or Receive calls and i get Error in Terminal programm

CubeMX -> USBD_DEBUG_LEVEL to 2

   I made no Transmit or Receive calls and i can connect to device

So there must be any effect of USBD_DEBUG_LEVEL to initialization or connection?

I will know test Transmit and Receiving on the working project and hope upcoming problems

can be more easily managed then this one.

Christoph Eschenbach
Associate III
Posted on January 31, 2017 at 12:47

In the working project i just added a few lines source code to generate a array with Data which i send after a Delay

with the CDC_Transmit_FS():

  while (1)

  {

    HAL_Delay(1000);

    CDC_Transmit_FS(testData, 8);

  }

without any changes to Buffer etc. actually i am wondering this works because I made no changes to the generated source code.

USB_HS_MAX_PACKET_SIZE and CDC_DATA_HS_MAX_PACKET_SIZE are still 512

and APP_RX_DATA_SIZE and APP_TX_DATA_SIZE is still 4

why is it working?