This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Access to SD-card from µController AND from USB possible?

Hello,

I use the Evalboard MCB4300 and µVision 5.14 MDK-ARM Professional.
Is it possible to initialize MCI0 to read/write to an SD-Card using fopen()..fwrite()..fclose(),
AND also allow the user to use the SD-card as a mass storage device via USB? (access not at the same time, user selects when the USB-connection is alive) ?

I'm trying to do this, but currently it does not work, but I also do not get any errors from the functions I call.
I call fopen(), fwrite() fputc(), fclose() without errors, but afterwards the file on the sdcard has not changed.
All function calls return without an error (fwrite(), USBD_Initialize(0),USBD_Connect(0),...)
Access to the card from USB works fine.

Am I doing something wrong, or is this basically not supported?

What's wrong with this:

finit("M0:");
fmount("M0:");
f=fopen("M0:test1.txt","a");
fputs("Hello!", f);
fclose (f);
funmount ("M0:");
funinit("M0:"); => file is correct on SDCard

stat=finit ("M0:"); // init again
=> stat=7(fsDriverError) : why?

Later in the code there would follow calls to
ustat=USBD_Initialize (0); /* USB Device 0 Initialization */
ustat=USBD_Connect (0);

Thank you.

Parents
  • Hi,

    I found an Application Note 273,
    Creating a USB Data Logger Application using Middleware and CMSIS.

    Here I found 2 functions:
    USBD_MSC0_SetMediaOwnerUSB()
    and
    USBD_MSC0_SetMediaOwnerFS()
    Using something like this seems to be the correct was to swap the ownership and access the memory card either via USB MSC or file system.

Reply
  • Hi,

    I found an Application Note 273,
    Creating a USB Data Logger Application using Middleware and CMSIS.

    Here I found 2 functions:
    USBD_MSC0_SetMediaOwnerUSB()
    and
    USBD_MSC0_SetMediaOwnerFS()
    Using something like this seems to be the correct was to swap the ownership and access the memory card either via USB MSC or file system.

Children