sd card -> mbed-> usb-> pc

21 Nov 2011

I am currently working to make an alarm clock which you can customise the songs, so you can load your songs into the sd card which should be connected to the mbed. And your PC can read the sd card via the mbed. I am just wondering how can you program the mbed to make the pc realise that the sd card is connected to the mbed. And also, how can you make the usb host coonect to the sd card. Hope i made myself clear enough. Thanks :) and really looking forward to your reply.

21 Nov 2011

I do believe that is what this program does.

http://mbed.org/users/okini3939/programs/USB_MSC/m0fwra

Matthew

21 Nov 2011

hey thanks you so much for the reply.I have looked at this website, but I am not sure which is the code that I want? As I am using the SD card as a memory and the usb host on the mbed. For the website you gave me, is it using mbed as an usb device so that you don't need to use the sd card? I saw one of your post 'Mount SD through mbed?'as well, it seems like the question I wanna ask, have your figured it out yet? Many thanks:)

21 Nov 2011

No problem. The program that I linked allows an SD card connected to the MBED, then the MBED connected to the PC as a USB device. The program then registers itself with the PC as a mass storage device, and serves up the contents of the SD card. I have not tested it myself as I moved on to other projects, however I did order a cool components board a week or so ago and plan to test it out as soon as it comes in.

Matthew

21 Nov 2011

Thanks so much for the quick reply haha! May I ask are you gonna use the usb port on the mbed or need to buy a usb type a? and how much is yoru components? as my budget for this project is quite low..and will you share the code later on the forum after you tested? I am sure it will work out for yor design! and sorry for so many questions..many thanks!

21 Nov 2011

Hello, for this use (mbed acting as USB Mass storage device - like flashdisk) You can use one half of USB cable with USB A connector if low on budget. Simply connect white wire to D- pin, green to D+ pin and black to GND pin. If you will not use battery or any external power connect red wire to Vin pin and mbed will be powered from PC if connected via this cable. But as I understand You will connect mbed to PC only to load new track.

As Mathew wrote, in this program mbed is USB Mass Storage device where SD card is used only as storage space (because mbed itself has only 2 MB) also it is like USB SD card reader but if You change program You can use both ways, load track to sd card via USB from PC or load track directly to SD card from PC.

As I remember Christian Lerche started thread about audio player with capability of loading tracks via USB but he uses AT45DB* flash chip via SPI. You can find it here http://mbed.org/forum/mbed/topic/2867/ Christian said he will share code after clean up so it may help You because it seems it is very close to Your project with only SD card instead of flash chip. BTW SD card is implemented in example link above so very much of work is done.

If You will want to use mbed as USB host, You will be able to connect flash disk or kb, mouse to it but loose the capability of connecting mbed to PC an loading tracks via usb. For this You can use half of USB EXTENDING cable and to get USB port. Here You will connect red wire to Vusb pin to power device connected to port, black to GND, green and white must use 15K pull-down resistor each if using mbed as USB host - specified at BlueUSB program http://mbed.org/users/peterbarrett1967/notebook/blueusb---bluetooth-and-usb-host-controller-for-mb/. There is also http://mbed.org/users/igorsk/programs/MSCUsbHost/5yfq4 USB host for flash disks only.

Hope this can help You

22 Nov 2011

Hello!!!thanks guys for all the replies!! I think i have midunderstood the mbed. is the code going to work only for the module (the mbed board)? I think i am only gonna buy the LPC1768..so can i make my own pcb and put the lpc1768 on it or i have to buy the mbed board from this website to use the code?

22 Nov 2011

also do i need a music decoder to decode the mp3 format and play the music out through the loudspeaker? many thanks :)

22 Nov 2011

Hello, as far as I know, code will work on Your custom board too but (correct me) You will have to connect everything to same pins on LPC1768 as You connected to mbed. Here is table explaining which pin on mbed is which pin on LPC1768 chip from Christian Lerche (thanks). It is http://mbed.org/users/Lerche/notebook/lpc1768-pin-functions/. Then You will need to bootload Your custom board with firmware made here in compiler. You can try to look at wiki page here http://mbed.org/cookbook/lpc-bootloader. About MP3 decoder there is example using VS1002 MP3 Decoder http://mbed.org/cookbook/VS1002-MP3-Decoder and http://mbed.org/cookbook/MP3-Player.

01 Dec 2011

Hi all,

Just a post to say that a USB mass storage class is under development. I hope provide this class before the end of next week. I want to design it in order to it can be easily used with all kinds of chips (sdcard, flash,...). The idea is to inherit from USBMSD and to define three or four virtual functions: init, readBlock, writeBlock, getCapacity.

I hope that this will help.

Sam

01 Dec 2011

Those are great news, Samuel. Thank You for Your work in USB for mbed.

04 May 2013

The above discussion referenced http://mbed.org/users/okini3939/programs/USB_MSC/m0fwra as a means for accessing an mbed's attached SD card as a file from the PC.

I imported the program "as is" to test it. However, it would not compile due to multiple definitions in the link. Has anyone tried to run this program recently? any thoughts on fixing the problems would be appreciated.

I am assuming that the main.cpp simply connects an SD card for file access by the PC via the USB cable. Jim

04 May 2013

was able to compile the program by deleting the chanNSF.lib that was present in the downloaded program. I then modified the code to connect my SD card using the pins that I used. Also placed the test.txt file on the SD card. I use this exact SD card setup regularly so I am positive that it is fully functional for read/write accessing by the mbed.

When I ran the program, I saw the blinking LED as expected and the expected text sent back to the PC. I expected/hoped that I would be able to see the mbed SD card as a connected device from the PC. However, I did not.

I am looking for a way to view a SD card attached to the mbed as a drive from the PC. Any ideas on how to do this?

- Jim

04 May 2013

Have a look at: http://mbed.org/handbook/USBMSD. At the bottom there is an example program that does what I think you want it to do :)