What does it take to use a usb?

  • Thread starter Thread starter GiTS
  • Start date Start date
  • Tags Tags
    Usb
AI Thread Summary
Using a microcontroller like a PIC to interface with USB memory sticks is challenging because it requires a USB host controller, which adds complexity. While Microchip provides sample code for USB slave operation, finding host code can be difficult. In contrast, interfacing with SD cards is simpler, as they can connect directly to a microcontroller via SPI without needing extensive drivers. For audio recording, an analog microphone can be connected to the microcontroller's ADC, allowing for uncompressed audio data to be captured. However, managing this data requires additional considerations, such as file system handling. Many users find writing to SD cards easier due to the availability of sample code and straightforward SPI communication, making them a preferred choice for projects involving removable storage.
GiTS
Messages
132
Reaction score
0
Is it possible for a microcontroller like PIC to use a USB memory stick?

I wanted to make a small microphone that will record onto USB memory stick or those SD memory chips that go into cameras.

I know nothing of how flash memory works on a technical level but I imagine you have to send commands like start/stop recording.

Please enlighten me as I cannot find information.

Thank you,

-GITS
 
Computer science news on Phys.org
I've used MicroChip 18Fxxx PICs as USB slaves, but you need a USB host to talk to memory sticks and most everything else. Microchip has sample code for the slave operation, which for me was nearly impenetrable until I found a bit of a working example -- I think at Sparkfun. I've not looked into sample host code, but they may have that as well...best to rummage around their support site.
 
Thank you for the information. Wow, a host controller is big. I don't get why there has to be so much to it. It's got 5 pins and some combination of signals has to be able to tell it to write. I'll have to do more research and post it. Maybe someone else is interested in this and would like to share. I mean small cameras write on SD so there has to be a way to make the host smaller.
 
Memory cards like the SD don't usually have native USB interfaces. I think they are more of a bus-like thing, but I haven't worked with them. I also should look into the USB host thing -- as you say, how can it be so hard? Well...Every step forward in technology is accompanied by a backward step in convenience...almost anything I can think of doing would work fine with a bi-directional parallel printer port.
 
Then you have to handle the file system
The easiest way I found was to use fat and a 32Mb limit, format a card in a PC and create a single file with a fixed name. Then just dump the filesystem header bytes. You can write this fixed header structure from your microcontroller rather than implement a full filesystem
 
I'm more familiar with Atmel's ARV microcontrollers, so here's my proposal to make an audio-recording device:

If you want removable storage, pick up an SD card breakout board. SD is a little easire to connect to an MCU since it doesn't need any drivers or ontrollers, just a handful of pull-up resistors. Connect it to an AVR MCU (i.e. Atmega8) via the SPI interface (MOSI-MISO-SCK-SS'). Connect an analog microphone to one the the ADC pins on the MCU. You will have uncompressed audio at your ADC pin.

However, that uncompressed audio will be nothing but a pile of zeros and ones; you will have to decide what you want to do with them.
 
schip666! said:
-- as you say, how can it be so hard?

I like to use the PIC32's, many of which have USB support. Each time I look at using USB communication I always end up just going with a FTDI chip. I tried learning all about USB once and found that its extremely complicated, even with a bunch of sample code. In the end I decided it was better to spend the $3 on a USB->UART interface chip and just be done with it.

Writing data to a SD card is much easier than writing to a USB drive. There's a ton of sample code out there for this for just about all the latest PIC micros. It only requires basic SPI communication as mentioned above.
 
I haven't played with this myself, but here's a relevant article:
http://electronicdesign.com/article/digital/interfacing-a-usb-flash-drive-to-a-pic-microcontro.aspx
 
Last edited by a moderator:
Back
Top