View previous topic :: View next topic |
Author |
Message |
toto
|
Posted: Tue Oct 13, 2015 1:06 pm Post subject: Share sd card with two microcontroller |
|
|
Hello,
I have two microcontroller on my pcb and need to know how to interfacing both with the same sd card. Any idea?
Thanks
Best regards
toto
(BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Wed Oct 14, 2015 12:15 am Post subject: |
|
|
Directly sharing an SD card is possible, but you have to do some of the port line switching manually - ie set various lines to input ( floating ) on one processor while using the other to control the card. Means adding a bit of code before and after the actual data read/write from each side to make sure the lines on the other side are not interfereing.
Specifically you need to control SCK and MOSI on both processors, and the CS lines on each, to enable the card chip select from the correct processor. THe MISO lines can both be connected to card DO, since they are always inputs on the processor side.
I am not sure if all AVR processors allow to control the I/O states of the port lines once you enable hardware SPI. You need to check the datasheet for the processor you use. Of course if you use software SPI, that does not apply, but it will be significantly slower.
Another way is to put the card only on one processor, and have an independent comms channel between the two processors. Do all the card accesses only on one, and send the data to the other with appropriate commands. You can still use the SPI bus for both, but treat one processor only as a slave, while the master talks to that slave, and to the card in separate transfers. Of course that means double data transfers, but its conceptually simpler. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Wed Oct 14, 2015 10:08 am Post subject: |
|
|
Hello toto
I would use a tri-state buffer eg 74LVT126 this way you can test to see if the other AVR is using the card with the added bonus that you can have 5V on the AVRs
Regards Paul |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Wed Oct 14, 2015 11:39 am Post subject: |
|
|
I think that the hardware will be the easy part.
Software will give you more head deck.
Do both avr need to communicate at the same time to the SD?
Why do you need 2 avr's can't it be done in 1 avr or maybe arm? _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
toto
|
Posted: Wed Oct 14, 2015 7:53 pm Post subject: |
|
|
Hello,
What want is this:
I have a atmega2560 that on power up load parameters
from a file or if desired make firmware update, after that
the Atmega2560 dont use more the sd card.
Now, i want add to the project another Atmega, connected
to a GSM modem. Trough the GSM modem i want the possibility
To download via Ftp a new firmware to the sd card. After the
download of the update file, the controller rename the file
and trough a transistor make a reset on the Atmega2560, the
Atmega2560 look at power up for this file and then make
the update of the firmware
Thats it why i need access the sd card with both controller, but
not at same time
Regards
toto |
|
Back to top |
|
|
|