cancel
Showing results for 
Search instead for 
Did you mean: 

Nucelo F207ZG USB CDC Example code

Manikandan K
Associate III
Posted on March 22, 2017 at 08:50

Hi, I'm using Nucleo F207ZG board and i did my testing of GPIO using STM32CubeMx(HAL lib) with Eclipse IDE on Ubuntu 04, Now i want to use the USB as Communication Device Class (CDC) but i'm not familiar with usb so is there any example coding for tranfer the data from/to Nucleo board/PC

Note: this post was migrated and contained many threaded conversations, some content may be missing.
20 REPLIES 20
Imen.D
ST Employee
Posted on March 22, 2017 at 09:30

Hi,

I suggest you to start from the '

CDC_Standalone' 

application

in STM32CubeF2 firmware package

provided within

STM322xG_EVAL

 as an implementation example: 

STM32Cube_FW_F2_V1.4.0\Projects\STM322xG_EVAL\Applications\USB_Device\CDC_Standalone

I recommend you to check the 'STM32Cube USB device library' User manual UM1734. 

Hope this help you.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Manikandan K
Associate III
Posted on March 22, 2017 at 09:56

Thank you Imen ,

One more question , Whether the sample program given in the STM322xG_EVAL  and STM32F207ZG-Nucleo both are applicable for Nucleo F207ZG board ? then what is the difference between both of the folders ?

Manikandan

Posted on March 22, 2017 at 11:35

Use diff or merge to see. 

More generally the NUCLEO will have a subset of the EVAL board functionality, and frequently uses different pins, but the concepts are portable with minimal effort. 

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on March 22, 2017 at 12:39

Thank you for your kind reply ,

I'm going to use Eclipse IDE and Ubuntu 16.04 , How i can see the output ?

Is there any Eclipse plugin for serial terminal window or otherwise i want to use separate serial terminal like cutecom ?

If i use cutecom means, whether i want to install STM32 Virtual COM Port Driver on Linux machine or or using usb-acm driver is enough ah ?

How can i install STM32 Virtual COM Port Driver  on Ubuntu machine?

Posted on March 23, 2017 at 17:23

Hey M,

there is no need to install these 'drivers' the usb-acm is sufficient. Just do as u proposed and use a common terminal-application (cutecom, minicom, or even 'cat /dev/ttyACMx'). As far you send / receive (on the STM32-side) without using the uart, the bauderate in the app (on PC-side) doesen't matter.

To find the appropriate device you simply can use dmesg in a terminal right after plugging the usb it will show you the device (like ttyACM0, ttyACM1,..),

but double check the 'Product:'-String it should say  'STM32 Virtual ComPort' not 'STM32 STLink'. The second one is the Programming-connection if you use e.g. the debug interface at the same time..

hope this helps

gr rg

Posted on March 24, 2017 at 07:50

Thank you for spending time for me ,

I attached St in build link with USB Micro B cable (CN1) to ubuntu machine and also connected Micro B cable (CN13) to another USB port of same ubuntu machine but it not showing properly , Ubuntu machine detect only St-link.

[ 6153.780987] cdc_acm 2-2:1.2: ttyACM0: USB ACM device

If i use both side Micro B cable means any problem ?

Sample output

[ 6153.549166] usb 2-2: new full-speed USB device number 6 using xhci_hcd

[ 6153.678548] usb 2-2: New USB device found, idVendor=0483, idProduct=374b

[ 6153.678552] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 6153.678554] usb 2-2: Product: STM32 STLink

[ 6153.678556] usb 2-2: Manufacturer: STMicroelectronics

[ 6153.678558] usb 2-2: SerialNumber: 0671FF485550755187094334

[ 6153.678794] usb 2-2: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes

[ 6153.780987] cdc_acm 2-2:1.2: ttyACM0: USB ACM device

[ 6153.781367] usbcore: registered new interface driver cdc_acm

[ 6153.781371] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

[ 6153.797895] usb-storage 2-2:1.1: USB Mass Storage device detected

[ 6153.798014] scsi host2: usb-storage 2-2:1.1

[ 6153.798238] usbcore: registered new interface driver usb-storage

[ 6153.800577] usbcore: registered new interface driver uas

[ 6154.135971] usb 2-2: USB disconnect, device number 6

[ 6154.136343] cdc_acm 2-2:1.2: failed to set dtr/rts

[ 6154.501180] usb 2-2: new full-speed USB device number 7 using xhci_hcd

[ 6154.630484] usb 2-2: New USB device found, idVendor=0483, idProduct=374b

[ 6154.630488] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 6154.630490] usb 2-2: Product: STM32 STLink

[ 6154.630492] usb 2-2: Manufacturer: STMicroelectronics

[ 6154.630494] usb 2-2: SerialNumber: 0671FF485550755187094334

[ 6154.630647] usb 2-2: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes

[ 6154.684629] usb-storage 2-2:1.1: USB Mass Storage device detected

[ 6154.684794] scsi host3: usb-storage 2-2:1.1

[ 6154.685121] cdc_acm 2-2:1.2: ttyACM0: USB ACM device

[ 6155.681986] scsi 3:0:0:0: Direct-Access MBED microcontroller 1.0 PQ: 0 ANSI: 2

[ 6155.682864] sd 3:0:0:0: Attached scsi generic sg2 type 0

[ 6155.683414] sd 3:0:0:0: [sdb] 2080 512-byte logical blocks: (1.06 MB/1.02 MiB)

[ 6155.683588] sd 3:0:0:0: [sdb] Write Protect is off

[ 6155.683598] sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00

[ 6155.683766] sd 3:0:0:0: [sdb] No Caching mode page found

[ 6155.683775] sd 3:0:0:0: [sdb] Assuming drive cache: write through

[ 6155.691434] sdb:

[ 6155.692392] sd 3:0:0:0: [sdb] Attached SCSI removable disk

[ 6157.034842] usb 2-2: USB disconnect, device number 7

[ 6157.049496] cdc_acm 2-2:1.2: failed to set dtr/rts

[ 6157.081220] FAT-fs (sdb): unable to read boot sector to mark fs as dirty

[ 6157.521227] usb 2-2: new full-speed USB device number 8 using xhci_hcd

[ 6157.650528] usb 2-2: New USB device found, idVendor=0483, idProduct=374b

[ 6157.650532] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 6157.650534] usb 2-2: Product: STM32 STLink

[ 6157.650536] usb 2-2: Manufacturer: STMicroelectronics

[ 6157.650537] usb 2-2: SerialNumber: 0671FF485550755187094334

[ 6157.650688] usb 2-2: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes

[ 6157.704652] usb-storage 2-2:1.1: USB Mass Storage device detected

[ 6157.704760] scsi host4: usb-storage 2-2:1.1

[ 6157.705109] cdc_acm 2-2:1.2: ttyACM0: USB ACM device

[ 6158.701865] scsi 4:0:0:0: Direct-Access MBED microcontroller 1.0 PQ: 0 ANSI: 2

[ 6158.702218] sd 4:0:0:0: Attached scsi generic sg2 type 0

[ 6158.702542] sd 4:0:0:0: [sdb] 2080 512-byte logical blocks: (1.06 MB/1.02 MiB)

[ 6158.702719] sd 4:0:0:0: [sdb] Write Protect is off

[ 6158.702724] sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00

[ 6158.703542] sd 4:0:0:0: [sdb] No Caching mode page found

[ 6158.703549] sd 4:0:0:0: [sdb] Assuming drive cache: write through

[ 6158.714652] sdb:

[ 6158.722194] sd 4:0:0:0: [sdb] Attached SCSI removable disk

Thank you for your consideration...

Manikandan

Posted on March 24, 2017 at 08:03

In usbd_conf.c   I did hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;

And Heap size as 4000 and stack size as 2000

Then aslo it's STm Target board not  detect , what i want to do ? Is there is problem in USB Cable whic i fixed Micro B usb cable in CN13

And what about jumper JP4 , (I'm using USB as device only so i OFF it )

Manikandan K
Associate III
Posted on March 27, 2017 at 08:29

Hi all,

Finally i got solution for my doubt ,

Actually what i did mistake means in STM32cubeMx i giving a input frequency as 25 Mhz, but in Nucleo F207ZG board only having 8 Mhz . Now i set  it as 8 Mhz and my USB_CDC(Virtual com port is working good in GtkTerm ),

Now UART is not needed only UART communication through USB .

For coding i refer to the webside 

https://www.youtube.com/watch?v=Jpul3w10tOU

Manikandan

Posted on May 22, 2017 at 12:07

Hi

K.Manikandan

,

I am also trying the same with STM32F207ZG nucleo board... and as you said i changed i/p clock to 8 MHz...but still i didn't get it working, It is not recognizing USB...can you suggest the steps that you followed to get it working...

Thanks.