Hello everybody,
I am working on a project where data like GPS,Heart Rate, Acceleration etc logs in to a SD card, then through SD to USB converter(USB2240) the files from SD card can be viewed from a computer..
i have came up with an issue.
I am using Atmega2560V as my Main Controller, interfacing SD card using SPI, meanwhile SD to USB converter also uses SPI to read files from the SD card... So, in a case when i plugged in the USB cable and want to display files on my computer, At this time does it hurts to my main main controller.? ?
Do i need any transistor switches in between Atmega2560V and SD card, so whenever i connects USB cable the switch disconnects connections between the SD card and Atmega2560V.?
On the other hand, USB2240 comes with a SD Detect pin which detects SD card in a slot, When ever i insert SD card this pin goes LOW and USB2240 starts working- I attached this pin to one of my Atmega2560V GPIO, SD card will be always in the slot.When ever USB cable connected this pin goes digital LOW and switches will disconnects, And wherever USB cable is not connected this pin goes HIGH and the switches connects plus USB2240 doesn't work..
Please provide suggestions, Do i really need switches.? If 'Yes' what should i use in that place..
Thank you
Please see attached images with this forum...


You can't have two devices connected to one SD card. If device A has opened file A and device B then opens file B, writes from A will go into file B. (If they work at all.)
It's tempting to put one SD slot and have two methods of accessing it. But it doesn't work. Your switches idea may work.
It is possible with a Teensy 3.5 or 3.6 to have the SD card acessible via the Teensy's USB connection but that software is relatively new. I don't know if it's fully working yet.
SPI is all digital logic level signals, so probably the best solution is to use a digital MUX which selects whether the Arduino or the USB2240 is connected to the SD Card.
WIthout a MUX you can make the SPI pins of the Arduino digital inputs. That should allow the USB2240 to communicate with the SD card, but how do you disconnect the the USB2240 pins when the Arduino needs the SD? You can do it with it's RESET pin or by removing it's power, but that could be a problem if you use the USB2240 to detect when the computer is connected.
Why don't you let the Mega read the SD card as well when it's connected to a PC?
Hello,
Thank you for your replies,
Why don't you let the Mega read the SD card as well when it's connected to a PC?
How do i do that.?
In between Atmega2560V and SD cardi am using Lvc125a buffer gate, shall i Turn it OFF power supply using a transistor switch.?
if 'Yes' Which switch would you prefer.?
OR
Lvc125a buffer chip comes with the 'CE' pin, Shall i use this feature to Turn it OFF using any GPIO of of controller.??
Thank you
The LVC25a looks like a good choice for the MEGA side of the interface. But how are you going to cut off the USB adaptor when the MEGA wants to talk to the card? You will need more than 4 lines as the USB adaptor is probably using all the SD pins.
How does the MEGA get informed that the USB is plugged in so it doesn't attempt to access the card?
Hello Morgan,
Thank you for your reply
how are you going to cut off the USB adaptor when the MEGA wants to talk to the card?
USB220 comes with the SD detect pin, I have connected that to one of the I/O of Atmega2560V and when i pull it LOW, the USB2240 recognise the SD card and goes in full working mode, and when it's high it goes into sleep.
You will need more than 4 lines as the USB adaptor is probably using all the SD pins.
I am using LVC125A in between MCU and SD Card - using only MISO,MOSI,SCK and CS pins in use..
How does the MEGA get informed that the USB is plugged in so it doesn't attempt to access the card?
I am connecting +5V_USB line coming from the USB connector with voltage divider to one of the I/O pin of Atmega2560V and Reading it's digital value..