cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4P5VGT - CDC, MSC and Pen Drive Support on USB

mahapusha
Associate III

Dear Members,

We are using STM32L4P5VGT, with USB (supports OTG). The said product has a USD card with an SDIO interface to store the sensor data. The USB is planned to be used following purposes.
1. CDC for Laptop serial communication to send real-time sensor data in office climate.
2. MSC (upload the stored data on the USD card to the Laptop, ie stored data in the field and dump in the office). I know, that it can be done using CDC also, using command and reply base mechanism. Already been used in one of the products, using the STM32L1 series processor.
3. Support for Pen Drive - To dump the data from the USD card to the External Pen Drive in the field.

I have used CDC for serial communication and USD data dump using command and response mechanisms. Similarly, I have worked on real-time data streaming using a USB device/CDC class and a Pen Drive with a USB Host. Never worked on OTG mode.

I need advice from you, who has already done or is aware of the best solution.

Is it only OTG solution for this or other modes eg device or host?

I have seen some examples of CDC plus MSC in USB device mode, but not sure, if is it possible to use here a drive.

Let me know a good approach, and link for any example if available.

Thanks in advance

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
mahapusha
Associate III

We have implemented it as below.
Our main requirement is CDC, Pen Drive (USB Host) is needed once in a while. I have merged the HOST and Device projects in a single one because OTG is not supported by STM32MXCube, and kept Device as default. Whenever Host service is needed, activate using the Keyboard and restart the system again, now start the Host and do the functionalities of it clear the Host mode and restart again in CDC mode. It works perfectly for me. The low side of this solution is the need to use a HOST to HOST USB cable. I cannot use another connector, otherwise, in the field, I need a converter for the Pen drive to connect to it.
Thanks for the multiple suggestions from the community.
Regards

 

View solution in original post

4 REPLIES 4
FBL
ST Employee

Hi @mahapusha 

To communicate with a laptop as a USB device and sending real-time sensor data using the CDC, you may need to implement an OTG solution to switch between host and device modes in order to get file system access to write data from SD card to pen drive.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Pavel A.
Evangelist III

The best solution maybe is just to pop the uSD card out of your device (it is removable not for nothing!) and replace with a clean one. Insert the card from the device into your PC/laptop and read the data. Quick, easy, no fumbling with USB host mode, no need for USB host connector.

 

FBL
ST Employee

Indeed, if it is possible to remove the microSD card from your device manually, using a card reader to transfer data would be simpler. In your implementation, you can handle mounting the file system and detect card removal by checking a GPIO pin.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

mahapusha
Associate III

We have implemented it as below.
Our main requirement is CDC, Pen Drive (USB Host) is needed once in a while. I have merged the HOST and Device projects in a single one because OTG is not supported by STM32MXCube, and kept Device as default. Whenever Host service is needed, activate using the Keyboard and restart the system again, now start the Host and do the functionalities of it clear the Host mode and restart again in CDC mode. It works perfectly for me. The low side of this solution is the need to use a HOST to HOST USB cable. I cannot use another connector, otherwise, in the field, I need a converter for the Pen drive to connect to it.
Thanks for the multiple suggestions from the community.
Regards