2024-04-24 04:11 AM
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
Solved! Go to Solution.
2024-08-11 06:41 AM
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
2024-08-01 09:11 AM
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.
2024-08-01 01:12 PM - edited 2024-08-01 01:14 PM
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.
2024-08-01 11:40 PM
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.
2024-08-11 06:41 AM
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