Hi
I could find a lot of sample codes which are just based on USB device or just USB Host, But I need to connect an USB Flash card to MCU through USB Host and at the same time I need to connect MCU as a device to PC.
With this way I should connect data between Flash card to PC as a Mass storage device by firmware (I don't know OTG can helps me or not?).
For example if you connect this device to PC you can see a removable device which is exactly that Flash card on USB host of MCU.
Besides, my MCU is LPC2478 or LPC2388.
How could I implement such a project?
Thanks in advance
> But I need to connect an USB Flash card to MCU through USB Host
Just to expose a "Flash card" (SD, MMC, Compact Flash card) to a PC, USB device role is enough. No host role is required.
Start with one of these examples,
KEIL, LPC2368 / LPC2378 USB Mass Storage Device Example http://www.keil.com/download/docs/336.asp
or
LPCUSB sourceforge.net/.../ main_msc.c
Tsuneo
I wanna connect an USB flash memory(not MMC or SD), so I need USB host
The word "Flash card" makes your post confusing. Use "USB drive/stick" instead, to make your point clear.
> For example if you connect this device to PC you can see a removable device which is exactly that Flash card on USB host of MCU.
Surely the project is feasible, but it is beyond the beginner's who is asking such a question. It's not just a simple combination of a MSC (Mass-Storage Class) host and a device project.
I recommend you to learn about MSC on a device, first. Above examples and this book will help you.
"USB Mass Storage" by Jan Axelson http://www.lvr.com/usbms.htm
And then, learn on control and bulk transfer on the host of NXP LPC family
USBHostLite ics.nxp.com/.../
Thanks about your answer
but this is my web log: http://electrorc.blogfa.com/
its in Persian but I have a lot of experiences about Memory cards and the others,
I saw these sample codes, but I don't enough time to implement it and it'll takes me a long time.
maybe my question was wrong, I want to combine these code with each other besides I have to add some other functions to my project. but I didn't see any project about using USB host and device at the same time.
my question is:
Does anybody have such an experience or any link about it?
the best way is changing MSD project that SD read/write functions to could read/write from USB stick
other questions:
Does USBHostLite support FAT32?
I need to support FAT32 too.
I've found VNC1L from FTDI which is USB host driver and could support in different usages but it's really slow, do you know another IC with this functionality but faster than VNC1L?
I don't have enough time and I need your experiences
thanks in advance
You are a beginner of USB, anyway :-)
If your project would simply combine host and device roles, I would show you the way. For example, in this topic, we discussed on the way to switch host and device role on LPC1768 http://www.keil.com/forum/17667/
Obviously, the OP of above topic was a USB beginner. But the project should be accomplished without modifying USB host/device stack code. Then, I've explained on this theme.
On the other hand, your project requires significant rewrite of the stack code. To do so, you should have enough background on USB coding. Then, I said it's beyond beginners'.
Your project is a hard exercise for USB device and host, but its function is no more than a USB extender cable. Is it really worth to do?
> but I don't enough time to implement it and it'll takes me a long time.
Then, give it up.
Thanks Tsuneo Chinzei
I'll never give it up, although I should test some other ways, for instance VNC1L is not good at speed but it can satisfy me reduce the costs and time.
thanks a lot but if you can give us some more information.
A.Taroosheh
VNC1L doesn't help your project at all. VNC1L provides just top-level file system I/O for the host role. But your project requires lower-level media access protocol (SCSI command - sector read/write). VNC2 fits to your purpose well.
You seem to be trapped in common beginner's misunderstanding on MSC (Mass-Storage Class), that is, file system call on a PC application is directly passed to MSC device. It's wrong.
When a MSC device attached to PC, File-System Manager resides on the PC side. File-System manager puts lower-level media access protocol (SCSI command). USB Mass Storage Class carries these SCSI commands. On the MSC device, a parser executes these SCSI commands to read / write sectors on the media attached to the device. In this way, USB MSC accepts all type of file system (FAT, NTFS, ETX3/4 -Linux, HFS+ -MacOSX).
In your project, the device side receives SCSI command from PC host, and the host side relays the command to a USB stick.
I didn't explain my project. I know VNC1L is fully match with my project. (there is no real time activity on USB stick by Microcontroller) In brief I can say after connection between PC and this device, these project should do some activity on USB stick and after that USB stick should be released and connected to PC directly. in this position my device doesn't have any effect on USB stick.
I just need a kind of bi-directional tri-state buffer to disconnect USB stick at the first moments and after those activities by means of buffers USB stick can connect to PC.
Is it right?
> I didn't explain my project.
Huh? Then, what was all fuss so far? You still have some misunderstanding, but I don't want to waste my valuable time with you any more. Bye
I don't know what's going wrong with this topic, these questions and you?
Specially the last one!!!
Here is a forum and everybody can have their question in different ways.
I don't have any experience about USB, I don't have any experience about How to develop and implement one USB based project. yes I've used some application notes to use them for my aims.
Is there any problem?
I wanna use USB host and device at the same time. I don't want to engage with all different points of USB, because it's not valuable for me (if I can I just use these application notes as a module to run my USB)
for instance if you want to work with FAT you would like to engage with full details in FAT.
of course NOT. you'll run just FlashFS. but I can say you have some misunderstanding because you don't know how to find ROOT sector. I know but I've never use such a thing because FlashFS or something else would does.
So here I don't want to know what the hell USB is. because USB is a tiny part of my project.
here I asked if you want, help us.
but I've just explained what I need and you just say you have misunderstanding.
Is it your help? OK I got it.
Is it wrong that I want to connect USB stick to MCU and do some activities and after those release it to connect to PC?
Is there any "misunderstanding"?
if yes so say something.
I just said I want to run USB host and device at the same time, where is "misunderstanding"?
there is no way to run both at the same time, is it that "misunderstanding" which is your all answers?
till here if you said something about it you didn't wast our time, but if you want say "you have some misunderstanding" don't wast ... our time :(
Either your english is very bad, or you really have misunderstood a lot.
Many processors can be host on one USB interface and device on another USB interface.
But it isn't trivial to just tunnel USB commands through that processor and just ignore the USB device side and the USB host side. You still have physical USB device and host controllers in the chip, and these controllers needs to be handled. What do you think happens if you disconnect the USB thumb drive? The host controller needs to handle the device disconnect. But at the same time, you need to take care of the failure to tunnel commands that the USB device controller may receive from a PC.
When you do get help, don't tell the helpers they are wrong. Especially when the helper does know whay more than you do about USB communication.
Don't blame this forum for your inability to see all aspects of your problem.
If you do want to tunnel without caring about any host or device controller, then you really must disconnect the USB controllers in the processor and just wire the USB thumb drive to the PC. As soon as you involve the microcontroller, you must spend time understanding the full problem and taking care of both host and device controller at all times, which includes connect/disconnect of PC while thumb drive is, or isn't, connected, or connect/disconnect of thumb drive while PC is or isn't connected.
Maybe till now you didn't understand me.
I need to combine USB host and device with each other and due to I don't know about USB I need sample code, link, or application note or else
then I found it takes a long time and Tsuneo Chinzei said give it up.
OK for this project I for reducing the time I found another way and this is my solution. it works properly but know it's not complete. here is the schematic
" help me. maybe your helps be useful for anyone else.
Hi Per,
You are also trapped in the OP's bad manner. He doesn't explain his real project, exactly as he want to do. Instead, he asks on nonsense fake example, which he would think related to his real one. When we respond to the fake example seriously, he says, "I didn't explain my project."
It's bad manner to ask a question. I don't have patience to reply seriously to such a manner. Every time we respond to his question, we have to expect, "it wasn't the real question"
my real question from first post to end was clear, "How to combine USB host with device"
but all your answer was "misunderstanding"
I said, I found a trick with VNC1L to cope my project but I need sample and application note about it. but you and the others just said "misunderstanding"
if you review my all posts you can see that my question was "How to combine USB host with device".
if anybody wants to ask one question he or she should explain it with full details. I wanna combine them you asked me how you can connect and disconnect USB stick. how you can manage the PC and UB on MCU.
OK doesn't matter.
attention to manager of this forum: would you please remove this topic?
because these quarrels are not suitable for this website.
thanks a lot about your answers